OSDN Git Service

AppliStation-GUI,パッケージのアイコン取得ルーチンにてZoneAlarm及びアーカイブインストーラ物がアイコンが表示されなかった対策
authorttp <ttp@users.sourceforge.jp>
Wed, 27 Feb 2008 16:15:42 +0000 (16:15 +0000)
committerttp <ttp@users.sourceforge.jp>
Wed, 27 Feb 2008 16:15:42 +0000 (16:15 +0000)
git-svn-id: http://localhost/svn/AppliStation/trunk@858 34ed2c89-c49f-4a4b-abdb-c318350108cf

AppliStation/PackageUninstallConfirmForm.cs

index b922f24..b38749b 100644 (file)
@@ -1,4 +1,5 @@
 using System;\r
 using System;\r
+using System.IO;\r
 using System.Drawing;\r
 using System.Windows.Forms;\r
 using NaGet.Packages;\r
 using System.Drawing;\r
 using System.Windows.Forms;\r
 using NaGet.Packages;\r
@@ -21,17 +22,39 @@ namespace AppliStation
                                label2.Text = string.Format("{0}({1})", uninstallPackage.Name, uninstallPackage.Version);\r
                                label2.Font = new Font(SystemFonts.DefaultFont.FontFamily, SystemFonts.DefaultFont.Size*1.5f);\r
                                \r
                                label2.Text = string.Format("{0}({1})", uninstallPackage.Name, uninstallPackage.Version);\r
                                label2.Font = new Font(SystemFonts.DefaultFont.FontFamily, SystemFonts.DefaultFont.Size*1.5f);\r
                                \r
-                               string iconPath = uninstallPackage.UninstallInfo.IconPath;\r
-                               if (!string.IsNullOrEmpty(iconPath)) {\r
-                                       if (iconPath.EndsWith(",0")) {\r
-                                               iconPath = iconPath.Substring(0, iconPath.Length-2);\r
-                                       }\r
-                                       if (System.IO.File.Exists(iconPath)) {\r
-                                               iconLabel.Image = Icon.ExtractAssociatedIcon(iconPath).ToBitmap();\r
-                                               iconLabel.Size = iconLabel.Image.Size;\r
+                               Icon icon = getIconForPackage(uninstallPackage);\r
+                               if (icon != null) {\r
+                                       iconLabel.Image = icon.ToBitmap();\r
+                                       iconLabel.Size = icon.Size;\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               private static Icon getIconForPackage(InstalledPackage pkg)\r
+               {\r
+                       string iconPath = pkg.UninstallInfo.IconPath;\r
+                       if (! string.IsNullOrEmpty(iconPath)) {\r
+                               if (iconPath.EndsWith(",0") || iconPath.EndsWith(",-0")) {\r
+                                       iconPath = iconPath.Substring(0, iconPath.LastIndexOf(','));\r
+                               }\r
+                               if (File.Exists(iconPath)) {\r
+                                       return Icon.ExtractAssociatedIcon(iconPath);\r
+                               }\r
+                       } else if (pkg.Type == InstallerType.ARCHIVE) {\r
+                               string progGrp = Path.Combine(NaGet.Env.ArchiveProgramGroup, pkg.Name);\r
+                               if (Directory.Exists(progGrp)) {\r
+                                       string[] lnkFiles = Directory.GetFiles(progGrp, "*.lnk");\r
+                                       \r
+                                       if (lnkFiles.Length >= 1) {\r
+                                               using (NaGet.InteropServices.ShellLink link = new NaGet.InteropServices.ShellLink(lnkFiles[0])) {\r
+                                                       if (File.Exists(link.GetPath(0))) {\r
+                                                               return Icon.ExtractAssociatedIcon(link.GetPath(0));\r
+                                                       }\r
+                                               }\r
                                        }\r
                                }\r
                        }\r
                                        }\r
                                }\r
                        }\r
+                       return null;\r
                }\r
                \r
                public PackageUninstallConfirmForm()\r
                }\r
                \r
                public PackageUninstallConfirmForm()\r