From ca875e0831789124a42eccf8dab30b735e1be292 Mon Sep 17 00:00:00 2001 From: ttp Date: Wed, 27 Feb 2008 16:15:42 +0000 Subject: [PATCH 1/1] =?utf8?q?AppliStation-GUI,=E3=83=91=E3=83=83=E3=82=B1?= =?utf8?q?=E3=83=BC=E3=82=B8=E3=81=AE=E3=82=A2=E3=82=A4=E3=82=B3=E3=83=B3?= =?utf8?q?=E5=8F=96=E5=BE=97=E3=83=AB=E3=83=BC=E3=83=81=E3=83=B3=E3=81=AB?= =?utf8?q?=E3=81=A6ZoneAlarm=E5=8F=8A=E3=81=B3=E3=82=A2=E3=83=BC=E3=82=AB?= =?utf8?q?=E3=82=A4=E3=83=96=E3=82=A4=E3=83=B3=E3=82=B9=E3=83=88=E3=83=BC?= =?utf8?q?=E3=83=A9=E7=89=A9=E3=81=8C=E3=82=A2=E3=82=A4=E3=82=B3=E3=83=B3?= =?utf8?q?=E3=81=8C=E8=A1=A8=E7=A4=BA=E3=81=95=E3=82=8C=E3=81=AA=E3=81=8B?= =?utf8?q?=E3=81=A3=E3=81=9F=E5=AF=BE=E7=AD=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://localhost/svn/AppliStation/trunk@858 34ed2c89-c49f-4a4b-abdb-c318350108cf --- AppliStation/PackageUninstallConfirmForm.cs | 39 +++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/AppliStation/PackageUninstallConfirmForm.cs b/AppliStation/PackageUninstallConfirmForm.cs index b922f24..b38749b 100644 --- a/AppliStation/PackageUninstallConfirmForm.cs +++ b/AppliStation/PackageUninstallConfirmForm.cs @@ -1,4 +1,5 @@ using System; +using System.IO; using System.Drawing; using System.Windows.Forms; using NaGet.Packages; @@ -21,17 +22,39 @@ namespace AppliStation label2.Text = string.Format("{0}({1})", uninstallPackage.Name, uninstallPackage.Version); label2.Font = new Font(SystemFonts.DefaultFont.FontFamily, SystemFonts.DefaultFont.Size*1.5f); - string iconPath = uninstallPackage.UninstallInfo.IconPath; - if (!string.IsNullOrEmpty(iconPath)) { - if (iconPath.EndsWith(",0")) { - iconPath = iconPath.Substring(0, iconPath.Length-2); - } - if (System.IO.File.Exists(iconPath)) { - iconLabel.Image = Icon.ExtractAssociatedIcon(iconPath).ToBitmap(); - iconLabel.Size = iconLabel.Image.Size; + Icon icon = getIconForPackage(uninstallPackage); + if (icon != null) { + iconLabel.Image = icon.ToBitmap(); + iconLabel.Size = icon.Size; + } + } + } + + private static Icon getIconForPackage(InstalledPackage pkg) + { + string iconPath = pkg.UninstallInfo.IconPath; + if (! string.IsNullOrEmpty(iconPath)) { + if (iconPath.EndsWith(",0") || iconPath.EndsWith(",-0")) { + iconPath = iconPath.Substring(0, iconPath.LastIndexOf(',')); + } + if (File.Exists(iconPath)) { + return Icon.ExtractAssociatedIcon(iconPath); + } + } else if (pkg.Type == InstallerType.ARCHIVE) { + string progGrp = Path.Combine(NaGet.Env.ArchiveProgramGroup, pkg.Name); + if (Directory.Exists(progGrp)) { + string[] lnkFiles = Directory.GetFiles(progGrp, "*.lnk"); + + if (lnkFiles.Length >= 1) { + using (NaGet.InteropServices.ShellLink link = new NaGet.InteropServices.ShellLink(lnkFiles[0])) { + if (File.Exists(link.GetPath(0))) { + return Icon.ExtractAssociatedIcon(link.GetPath(0)); + } + } } } } + return null; } public PackageUninstallConfirmForm() -- 2.11.0