OSDN Git Service

na-get-lib,ダウンロード後にファイル名が引き継がれずインストールなどが動作していなかったのを修正
[applistation/AppliStation.git] / AppliStation / PackageUninstallConfirmForm.cs
1 using System;\r
2 using System.IO;\r
3 using System.Drawing;\r
4 using System.Windows.Forms;\r
5 using NaGet.Packages;\r
6 using NaGet.Packages.Install;\r
7 \r
8 namespace AppliStation\r
9 {\r
10         /// <summary>\r
11         /// Description of PackageUninstallConfirmForm.\r
12         /// </summary>\r
13         public partial class PackageUninstallConfirmForm : Form\r
14         {\r
15                 private InstalledPackage uninstallPackage;\r
16                 \r
17                 public InstalledPackage UninstallPackage {\r
18                         get { return uninstallPackage; }\r
19                         set {\r
20                                 uninstallPackage = value;\r
21                                 \r
22                                 label2.Text = string.Format("{0}({1})", uninstallPackage.Name, uninstallPackage.Version);\r
23                                 label2.Font = new Font(SystemFonts.DefaultFont.FontFamily, SystemFonts.DefaultFont.Size*1.5f);\r
24                                 \r
25                                 Icon icon = AppliStation.Util.GUIUtils.GetIconForPackage(uninstallPackage);\r
26                                 if (icon != null) {\r
27                                         iconLabel.Image = icon.ToBitmap();\r
28                                         iconLabel.Size = icon.Size;\r
29                                 }\r
30                         }\r
31                 }\r
32 \r
33                 public PackageUninstallConfirmForm()\r
34                 {\r
35                         //\r
36                         // The InitializeComponent() call is required for Windows Forms designer support.\r
37                         //\r
38                         InitializeComponent();\r
39                         \r
40                         // 管理者権限で動いているならばrunasが必要にはならないので表示しない\r
41                         if (NaGet.Utils.IsAdministrators()) {\r
42                                 runasCheckBox.Checked = false;\r
43                                 runasCheckBox.Visible = false;\r
44                         }\r
45                 }\r
46                 \r
47                 #region runas関連\r
48                 \r
49                 /// <summary>\r
50                 /// runasで実行するか否か\r
51                 /// </summary>\r
52                 public bool UseRunas {\r
53                         set {\r
54                                 runasCheckBox.Checked = (! NaGet.Utils.IsAdministrators()) && value;\r
55                                 \r
56                                 updateUseRunas();\r
57                         }\r
58                         get {\r
59                                 return runasCheckBox.Checked;\r
60                         }\r
61                 }\r
62                 \r
63                 /// <summary>\r
64                 /// 選択されたパッケージを調査して、Runasを使うべきかいなかを返す\r
65                 /// </summary>\r
66                 public bool GetShouldUseRunas()\r
67                 {\r
68                         if (NaGet.Utils.IsAdministrators()) {\r
69                                 // 管理者権限で動いている場合は不要\r
70                                 return false;   \r
71                         }\r
72                         \r
73                         return (uninstallPackage.Type != InstallerType.ARCHIVE)\r
74                                 && (uninstallPackage.Type != InstallerType.ITSELF);\r
75                 }\r
76                 \r
77                 void RunasCheckBoxCheckedChanged(object sender, EventArgs e)\r
78                 {\r
79                         updateUseRunas();\r
80                 }\r
81                 \r
82                 private void updateUseRunas()\r
83                 {\r
84                         AppliStation.Util.NativeMethods.Button_SetElevationRequiredState(okButton, UseRunas);\r
85                 }\r
86                 \r
87                 #endregion\r
88 \r
89         }\r
90 }\r