OSDN Git Service

AppliStation-GUI,パッケージ情報パネルのタイトルのバグ修正
[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.PackageUtils.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                         // \8aÇ\97\9d\8eÒ\8c \8cÀ\82Å\93®\82¢\82Ä\82¢\82é\82È\82ç\82Îrunas\82ª\95K\97v\82É\82Í\82È\82ç\82È\82¢\82Ì\82Å\95\\8e¦\82µ\82È\82¢\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\8aÖ\98A\r
48                 \r
49                 /// <summary>\r
50                 /// runas\82Å\8eÀ\8ds\82·\82é\82©\94Û\82©\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                 /// \91I\91ð\82³\82ê\82½\83p\83b\83P\81[\83W\82ð\92²\8d¸\82µ\82Ä\81ARunas\82ð\8eg\82¤\82×\82«\82©\82¢\82È\82©\82ð\95Ô\82·\r
65                 /// </summary>\r
66                 public bool GetShouldUseRunas()\r
67                 {\r
68                         if (NaGet.Utils.IsAdministrators()) {\r
69                                 // \8aÇ\97\9d\8eÒ\8c \8cÀ\82Å\93®\82¢\82Ä\82¢\82é\8fê\8d\87\82Í\95s\97v\r
70                                 return false;   \r
71                         }\r
72                         \r
73                         return (uninstallPackage.Type != InstallerType.ARCHIVE);\r
74                 }\r
75                 \r
76                 void RunasCheckBoxCheckedChanged(object sender, EventArgs e)\r
77                 {\r
78                         updateUseRunas();\r
79                 }\r
80                 \r
81                 private void updateUseRunas()\r
82                 {\r
83                         if (UseRunas) {\r
84                                 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PackagesInstallConfirmForm));\r
85                                 okButton.Image = ((System.Drawing.Bitmap)(resources.GetObject("okButton.Image")));\r
86                         } else {\r
87                                 okButton.Image = null;\r
88                         }\r
89                 }\r
90                 \r
91                 #endregion\r
92 \r
93         }\r
94 }\r