3 using System.Drawing;
\r
4 using System.Windows.Forms;
\r
5 using NaGet.Packages;
\r
6 using NaGet.Packages.Install;
\r
8 namespace AppliStation
\r
11 /// Description of PackageUninstallConfirmForm.
\r
13 public partial class PackageUninstallConfirmForm : Form
\r
15 private InstalledPackage uninstallPackage;
\r
17 public InstalledPackage UninstallPackage {
\r
18 get { return uninstallPackage; }
\r
20 uninstallPackage = value;
\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
25 Icon icon = getIconForPackage(uninstallPackage);
\r
27 iconLabel.Image = icon.ToBitmap();
\r
28 iconLabel.Size = icon.Size;
\r
33 private static Icon getIconForPackage(InstalledPackage pkg)
\r
35 string iconPath = pkg.UninstallInfo.IconPath;
\r
36 if (! string.IsNullOrEmpty(iconPath)) {
\r
37 if (iconPath.EndsWith(",0") || iconPath.EndsWith(",-0")) {
\r
38 iconPath = iconPath.Substring(0, iconPath.LastIndexOf(','));
\r
40 if (File.Exists(iconPath)) {
\r
41 return Icon.ExtractAssociatedIcon(iconPath);
\r
43 } else if (pkg.Type == InstallerType.ARCHIVE) {
\r
44 string progGrp = Path.Combine(NaGet.Env.ArchiveProgramGroup, pkg.Name);
\r
45 if (Directory.Exists(progGrp)) {
\r
46 string[] lnkFiles = Directory.GetFiles(progGrp, "*.lnk");
\r
48 if (lnkFiles.Length >= 1) {
\r
49 using (NaGet.InteropServices.ShellLink link = new NaGet.InteropServices.ShellLink(lnkFiles[0])) {
\r
50 if (File.Exists(link.GetPath(0))) {
\r
51 return Icon.ExtractAssociatedIcon(link.GetPath(0));
\r
60 public PackageUninstallConfirmForm()
\r
63 // The InitializeComponent() call is required for Windows Forms designer support.
\r
65 InitializeComponent();
\r
67 //
\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
68 if (NaGet.Utils.IsAdministrators()) {
\r
69 runasCheckBox.Checked = false;
\r
70 runasCheckBox.Visible = false;
\r
74 #region runas
\8aÖ
\98A
\r
77 /// runas
\82Å
\8eÀ
\8ds
\82·
\82é
\82©
\94Û
\82©
\r
79 public bool UseRunas {
\r
81 runasCheckBox.Checked = (! NaGet.Utils.IsAdministrators()) && value;
\r
86 return runasCheckBox.Checked;
\r
91 ///
\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
93 public bool GetShouldUseRunas()
\r
95 if (NaGet.Utils.IsAdministrators()) {
\r
96 //
\8aÇ
\97\9d\8eÒ
\8c \8cÀ
\82Å
\93®
\82¢
\82Ä
\82¢
\82é
\8fê
\8d\87\82Í
\95s
\97v
\r
100 return (uninstallPackage.Type != InstallerType.ARCHIVE);
\r
103 void RunasCheckBoxCheckedChanged(object sender, EventArgs e)
\r
108 private void updateUseRunas()
\r
111 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(PackagesInstallConfirmForm));
\r
112 okButton.Image = ((System.Drawing.Bitmap)(resources.GetObject("okButton.Image")));
\r
114 okButton.Image = null;
\r