OSDN Git Service

AppliStation-GUI,GetIconForPackageを別クラスに退避
authorttp <ttp@users.sourceforge.jp>
Sun, 16 Mar 2008 07:21:24 +0000 (07:21 +0000)
committerttp <ttp@users.sourceforge.jp>
Sun, 16 Mar 2008 07:21:24 +0000 (07:21 +0000)
git-svn-id: http://localhost/svn/AppliStation/trunk@875 34ed2c89-c49f-4a4b-abdb-c318350108cf

AppliStation/AppliStation.Util/PackageUtils.cs [new file with mode: 0644]
AppliStation/AppliStation.csproj
AppliStation/PackageUninstallConfirmForm.cs

diff --git a/AppliStation/AppliStation.Util/PackageUtils.cs b/AppliStation/AppliStation.Util/PackageUtils.cs
new file mode 100644 (file)
index 0000000..dc46626
--- /dev/null
@@ -0,0 +1,40 @@
+using System;\r
+using System.IO;\r
+using System.Drawing;\r
+using NaGet.Packages;\r
+using NaGet.Packages.Install;\r
+\r
+namespace AppliStation.Util\r
+{\r
+       public sealed class PackageUtils\r
+       {\r
+               \r
+               public 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
+                       return null;\r
+               }\r
+               \r
+       }\r
+}\r
index 908fae6..fbea416 100644 (file)
@@ -66,6 +66,7 @@
     </Compile>\r
     <Compile Include="AppliStation.Util\ListViewItemSortComparer.cs" />\r
     <Compile Include="AppliStation.Util\NativeMethods.cs" />\r
+    <Compile Include="AppliStation.Util\PackageUtils.cs" />\r
     <Compile Include="AssemblyInfo.cs" />\r
     <Compile Include="ArgParse.cs" />\r
     <Compile Include="PackageListViewForm.cs" />\r
index b38749b..d5a29fb 100644 (file)
@@ -22,41 +22,14 @@ 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
-                               Icon icon = getIconForPackage(uninstallPackage);\r
+                               Icon icon = AppliStation.Util.PackageUtils.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
-                       return null;\r
-               }\r
-               \r
+\r
                public PackageUninstallConfirmForm()\r
                {\r
                        //\r