OSDN Git Service

AppliStation-GUI,パッケージ情報ダイアログ周りのリファクタリング・整理
authorttp <ttp@users.sourceforge.jp>
Mon, 23 Nov 2009 10:16:06 +0000 (19:16 +0900)
committerttp <ttp@users.sourceforge.jp>
Mon, 23 Nov 2009 10:16:06 +0000 (19:16 +0900)
AppliStation/AppliStation.PackageInfo/InstallerInfoForm.Designer.cs [moved from AppliStation/InstallerInfoForm.Designer.cs with 97% similarity]
AppliStation/AppliStation.PackageInfo/InstallerInfoForm.cs [new file with mode: 0644]
AppliStation/AppliStation.PackageInfo/InstallerInfoForm.resx [moved from AppliStation/InstallerInfoForm.resx with 100% similarity]
AppliStation/AppliStation.PackageInfo/PackageDescripter.cs [new file with mode: 0644]
AppliStation/AppliStation.PackageInfo/PackageInfoForm.Designer.cs [moved from AppliStation/PackageInfoForm.Designer.cs with 97% similarity]
AppliStation/AppliStation.PackageInfo/PackageInfoForm.cs [new file with mode: 0644]
AppliStation/AppliStation.PackageInfo/PackageInfoForm.resx [moved from AppliStation/PackageInfoForm.resx with 100% similarity]
AppliStation/AppliStation.csproj
AppliStation/InstallerInfoForm.cs [deleted file]
AppliStation/PackageInfoForm.cs [deleted file]
AppliStation/PackageListViewForm.cs

@@ -1,4 +1,4 @@
-namespace AppliStation\r
+namespace AppliStation.PackageInfo\r
 {\r
        partial class InstallerInfoForm\r
        {\r
diff --git a/AppliStation/AppliStation.PackageInfo/InstallerInfoForm.cs b/AppliStation/AppliStation.PackageInfo/InstallerInfoForm.cs
new file mode 100644 (file)
index 0000000..964f643
--- /dev/null
@@ -0,0 +1,46 @@
+using System;\r
+using System.ComponentModel;\r
+using System.Drawing;\r
+using System.Windows.Forms;\r
+\r
+using NaGet.Packages;\r
+using NaGet.Packages.Install;\r
+using System.Reflection;\r
+\r
+namespace AppliStation.PackageInfo\r
+{\r
+       /// <summary>\r
+       /// Description of InstallerInfoForm.\r
+       /// </summary>\r
+       public partial class InstallerInfoForm : UserControl\r
+       {\r
+               private Installer inst;\r
+               \r
+               public InstallerInfoForm()\r
+               {\r
+                       //\r
+                       // The InitializeComponent() call is required for Windows Forms designer support.\r
+                       //\r
+                       InitializeComponent();\r
+               }\r
+               \r
+               public Installer SelectedObject {\r
+                       get { return inst; }\r
+                       set {\r
+                               inst = value;\r
+                               updateInst();\r
+                       }\r
+               }\r
+               \r
+               private void updateInst()\r
+               {\r
+                       installerUrlTextBox.Text = (inst == null || inst.Url == null)?\r
+                               string.Empty : inst.Url.Href;\r
+                                               \r
+                       osValueLabel.Text = PackageDescripter.GetOSValueLabel(inst.Platform);\r
+                       archValueLabel.Text = PackageDescripter.GetArchValueLabel(inst.Platform);\r
+                       \r
+                       cannotRunLabel.Visible = ! ((inst.Platform == null) || inst.Platform.IsRunnable());\r
+               }\r
+       }\r
+}\r
diff --git a/AppliStation/AppliStation.PackageInfo/PackageDescripter.cs b/AppliStation/AppliStation.PackageInfo/PackageDescripter.cs
new file mode 100644 (file)
index 0000000..aeca081
--- /dev/null
@@ -0,0 +1,211 @@
+using System;\r
+using System.Windows.Forms;\r
+using System.Collections.Generic;\r
+using System.Text;\r
+using System.Text.RegularExpressions;\r
+using NaGet.Packages;\r
+\r
+namespace AppliStation.PackageInfo\r
+{\r
+       /// <summary>\r
+       /// パッケージ情報アクセスのための便利メソッド群\r
+       /// </summary>\r
+       public sealed class PackageDescripter\r
+       {\r
+               /// <summary>\r
+               /// インストーラタイプに対応する文字列を生成して返す\r
+               /// </summary>\r
+               /// <param name="instType">インストーラタイプ</param>\r
+               /// <returns>ラベル文字列</returns>\r
+               public static string GetInstallerTypeLabel(InstallerType instType)\r
+               {\r
+                       switch (instType) {\r
+                               case InstallerType.ARCHIVE:\r
+                                       return "自己解凍書庫または書庫";\r
+                               case InstallerType.EXEC_INSTALLER:\r
+                                       return "インストーラー形式";\r
+                               case InstallerType.MSI_PACKAGE:\r
+                                       return "MSIファイル形式";\r
+                               case InstallerType.ITSELF:\r
+                                       return "単体の実行ファイル";\r
+                               default:\r
+                                       return "不明なインストール形式(インストール不能)";\r
+                       }\r
+               }\r
+               \r
+               /// <summary>\r
+               /// OSのラベル文字列を生成する\r
+               /// </summary>\r
+               /// <param name="platform">プラットフォーム</param>\r
+               /// <returns>platformの示すOSバージョン文字列</returns>\r
+               public static string GetOSValueLabel(Platform platform)\r
+               {\r
+                       if (platform == null || string.IsNullOrEmpty(platform.Os)) {\r
+                               return "任意のWindows";\r
+                       } else {\r
+                               return platform.Os.Replace("WIN", string.Empty);\r
+                       }\r
+               }\r
+               \r
+               /// <summary>\r
+               /// アーキテクチャのラベル文字列を生成する\r
+               /// </summary>\r
+               /// <param name="platform">プラットフォーム</param>\r
+               /// <returns>platformの示すアーキテクチャ文字列</returns>\r
+               public static string GetArchValueLabel(Platform platform)\r
+               {\r
+                       switch ((platform != null)? platform.Arch : System.Reflection.ProcessorArchitecture.X86) {\r
+                               case System.Reflection.ProcessorArchitecture.Amd64:\r
+                                       return "x64 (64ビット環境)";\r
+                               case System.Reflection.ProcessorArchitecture.IA64:\r
+                                       return "Itanium";\r
+                               case System.Reflection.ProcessorArchitecture.None:\r
+                               case System.Reflection.ProcessorArchitecture.MSIL:\r
+                                       return "アーキテクチャ依存なし";\r
+                               case System.Reflection.ProcessorArchitecture.X86:\r
+                               default:\r
+                                       return "x86 (32ビット環境)";\r
+                       }\r
+               }\r
+               \r
+               /// <summary>\r
+               /// ライセンスのラベル文字列とリンク情報を生成する\r
+               /// </summary>\r
+               /// <param name="pkg">パッケージ</param>\r
+               /// <param name="text">ラベル文字列</param>\r
+               /// <param name="links">リンク文字列</param>\r
+               public static void GetLicenseValueLabel(Package pkg, out string text, out LinkLabel.Link[] links)\r
+               {\r
+                       string license = pkg.License;\r
+                       string publicSiteUrl = (pkg.Url != null)? pkg.Url.Href : null;\r
+                       \r
+                       List<LinkLabel.Link> linkArray = new List<LinkLabel.Link>();\r
+                       \r
+                       switch (license ?? string.Empty) {\r
+                               case "":\r
+                                       if (string.IsNullOrEmpty(publicSiteUrl)) {\r
+                                               text = "フリーソフトウェア";\r
+                                       } else {\r
+                                               text = "フリーソフトウェア (詳細は公式サイトなどで確認してください)";\r
+                                               linkArray.Add(createLinkToLinkLabel(text, "公式サイト", publicSiteUrl));\r
+                                       }\r
+                                       break;\r
+                               #region オープンソースかつコピーレフト\r
+                               case "GPL":\r
+                               case "GPLv2":\r
+                               case "GPLv2+":\r
+                               case "GPLv3":\r
+                               case "GPLv3+":\r
+                                       text = string.Format("{0} (オープンソース)", license);\r
+                                       if (license.StartsWith("GPLv3")) {\r
+                                               linkArray.Add(new LinkLabel.Link(0, license.Length, @"http://www.gnu.org/licenses/gpl-3.0.html"));\r
+                                       } else {\r
+                                               linkArray.Add(new LinkLabel.Link(0, license.Length, @"http://www.gnu.org/licenses/gpl-2.0.html"));\r
+                                               linkArray.Add(createLinkToLinkLabel(text, "オープンソース",\r
+                                                                               @"http://creativecommons.org/licenses/GPL/2.0/deed.ja"));\r
+                                       }\r
+                                       break;\r
+                               case "LGPL":\r
+                               case "LGPLv2":\r
+                               case "LGPLv2+":\r
+                               case "LGPLv3":\r
+                               case "LGPLv3+":\r
+                                       text = string.Format("{0} (オープンソース)", license);\r
+                                       if (license.StartsWith("GPLv3")) {\r
+                                               linkArray.Add(new LinkLabel.Link(0, license.Length, @"http://www.gnu.org/licenses/lgpl-3.0.html"));\r
+                                       } else {\r
+                                               linkArray.Add(new LinkLabel.Link(0, license.Length, @"http://www.gnu.org/licenses/lgpl-2.1.html"));\r
+                                               linkArray.Add(createLinkToLinkLabel(text, "オープンソース",\r
+                                                                               @"http://creativecommons.org/licenses/LGPL/2.1/deed.ja"));\r
+                                       }\r
+                                       break;\r
+                               case "AGPLv3":\r
+                               case "AGPLv3+":\r
+                                       text = string.Format("{0} (オープンソース)", license);\r
+                                       linkArray.Add(new LinkLabel.Link(0, license.Length, @"http://www.gnu.org/licenses/agpl-3.0.txt"));\r
+                                       break;\r
+                               case "MPL":\r
+                               case "MPLv1":\r
+                               case "MPLv1+":\r
+                                       text = "MPL (オープンソース)";\r
+                                       linkArray.Add(new LinkLabel.Link(0, "MPL".Length, @"http://www.mozilla.org/MPL/MPL-1.1.html"));\r
+                                       break;\r
+                               case "CPL":\r
+                                       text = "CPL (オープンソース)";\r
+                                       linkArray.Add(new LinkLabel.Link(0, "CPL".Length, @"http://opensource.org/licenses/cpl1.0.php"));\r
+                                       break;\r
+                               case "Artistic":\r
+                                       text = "Artisticライセンス (オープンソース)";\r
+                                       linkArray.Add(new LinkLabel.Link(0, "Artisticライセンス".Length, @"http://www.perlfoundation.org/artistic_license_2_0"));\r
+                                       break;\r
+                               #endregion\r
+                               #region オープンソースだが、コピーレフトでない著名なライセンス\r
+                               case "MIT":\r
+                                       text = "MITライセンス (オープンソース)";\r
+                                       linkArray.Add(new LinkLabel.Link(0, "MITライセンス".Length, @"http://www.opensource.org/licenses/mit-license.php"));\r
+                                       break;\r
+                               case "BSD":\r
+                                       text = "修正済BSDライセンス (オープンソース)";\r
+                                       linkArray.Add(new LinkLabel.Link(0, "BSDライセンス".Length, @"http://www.opensource.org/licenses/bsd-license.php"));\r
+                                       break;\r
+                               case "Apache":\r
+                               case "ASLv2":\r
+                               case "ASLv2+":\r
+                                       text = "Apacheライセンス (オープンソース)";\r
+                                       linkArray.Add(new LinkLabel.Link(0, "Apacheライセンス".Length, @"http://www.apache.org/licenses/LICENSE-2.0.txt"));\r
+                                       break;\r
+                               case "zlib":\r
+                                       text = "zlibライセンス (オープンソース)";\r
+                                       linkArray.Add(new LinkLabel.Link(0, "Apacheライセンス".Length, @"http://sourceforge.jp/projects/opensource/wiki/licenses%2Fzlib_libpng_license"));\r
+                                       break;\r
+                               #endregion\r
+                               #region 実質Public Domainなライセンス\r
+                               case "WTFPL":\r
+                               case "WTFPLv2":\r
+                                       text = "WTFPL";\r
+                                       linkArray.Add(new LinkLabel.Link(0, text.Length, @"http://sam.zoy.org/wtfpl/"));\r
+                                       break;\r
+                               case "NYSL":\r
+                                       text = "煮るなり焼くなり好きにしろライセンス";\r
+                                       linkArray.Add(new LinkLabel.Link(0, text.Length, @"http://www.kmonos.net/nysl/NYSL_withfaq.TXT"));\r
+                                       break;\r
+                               case "Public Domain":\r
+                                       text = "パブリックドメイン (著作権帰属なし)";\r
+                                       break;\r
+                               #endregion\r
+                               default:\r
+                                       if (license.StartsWith("http://")) {\r
+                                               text = license;\r
+                                               linkArray.Add(new LinkLabel.Link(0, license.Length, license));\r
+                                       } else {\r
+                                               Regex regex = new Regex(@"^(?<msg>.*)<(?<url>https?://.*)>$", RegexOptions.IgnoreCase);\r
+                                               Match match = regex.Match(license);\r
+                                               \r
+                                               if (match.Success) {\r
+                                                       text = match.Groups["msg"].Value;\r
+                                                       linkArray.Add(new LinkLabel.Link(0, text.Length, match.Groups["url"].Value));\r
+                                               } else {\r
+                                                       text = license;\r
+                                               }\r
+                                       }\r
+                                       break;\r
+                       }\r
+                       \r
+                       links = linkArray.ToArray();\r
+               }\r
+               \r
+               /// <summary>\r
+               /// リンクラベルのリンク生成便利メソッド\r
+               /// </summary>\r
+               /// <param name="text">ラベルテキスト</param>\r
+               /// <param name="word">リンク対象文字列</param>\r
+               /// <param name="link">リンクオブジェクト</param>\r
+               private static LinkLabel.Link createLinkToLinkLabel(string text, string word, string link)\r
+               {\r
+                       int pos = text.IndexOf(word, 0);\r
+                       if (pos >= 0) {\r
+                               return new LinkLabel.Link(pos, word.Length, link);\r
+                       } else throw new ArgumentException(string.Format("label text \"{0}\" does not contain \"{1}\"!", text, word));\r
+               }\r
+       }\r
+}\r
@@ -1,4 +1,4 @@
-namespace AppliStation\r
+namespace AppliStation.PackageInfo\r
 {\r
        partial class PackageInfoForm\r
        {\r
diff --git a/AppliStation/AppliStation.PackageInfo/PackageInfoForm.cs b/AppliStation/AppliStation.PackageInfo/PackageInfoForm.cs
new file mode 100644 (file)
index 0000000..2b8fbad
--- /dev/null
@@ -0,0 +1,166 @@
+using System;\r
+using System.Drawing;\r
+using System.Windows.Forms;\r
+using System.Text;\r
+using System.Text.RegularExpressions;\r
+using System.IO;\r
+using NaGet.Packages.Install;\r
+using NaGet.Packages;\r
+\r
+namespace AppliStation.PackageInfo\r
+{\r
+       /// <summary>\r
+       /// Description of PackageInfoForm.\r
+       /// </summary>\r
+       public partial class PackageInfoForm : Form\r
+       {\r
+               private Package pkg;\r
+               \r
+               public PackageInfoForm()\r
+               {\r
+                       InitializeComponent();\r
+               }\r
+               \r
+               /// <summary>\r
+               /// 現在選択中(=表示中)のパッケージ\r
+               /// </summary>\r
+               public Package SelectedObject {\r
+                       get { return pkg; }\r
+                       set {\r
+                               pkg = value;\r
+                               updateSelectedObject();\r
+                       }\r
+               }\r
+               \r
+               private void updateSelectedObject()\r
+               {\r
+                       bool isInstalledPackage = pkg is InstalledPackage;\r
+                       \r
+                       iconLabel.Image = null;\r
+                       iconLabel.Size = Size.Empty;\r
+                       if (isInstalledPackage) {\r
+                               Icon icon = AppliStation.Util.GUIUtils.GetIconForPackage((InstalledPackage) pkg);\r
+                               if (icon != null) {\r
+                                       iconLabel.Image = icon.ToBitmap();\r
+                                       iconLabel.Size = icon.Size;\r
+                               }\r
+                       }\r
+                       nameLabel.Text = string.Format("{0} ({1})", pkg.Name, pkg.Version);\r
+                       nameLabel.Font = new Font(SystemFonts.CaptionFont.FontFamily, SystemFonts.CaptionFont.Size*1.25f);\r
+                       \r
+                       summaryTextBox.Text = pkg.Summary;\r
+                       \r
+                       if (isInstalledPackage) {\r
+                               UninstallInformation uninstInfo = ((InstalledPackage) pkg).UninstallInfo;\r
+                               \r
+                               string instPath = null;\r
+                               if ((pkg.Type == InstallerType.ARCHIVE)\r
+                                   ||(pkg.Type == InstallerType.ITSELF)) {\r
+                                       instPath = Path.Combine(NaGet.Env.ArchiveProgramFiles, pkg.Name);\r
+                               } else if (Directory.Exists(uninstInfo.InstallLocation)) {\r
+                                       instPath = uninstInfo.InstallLocation;\r
+                               }\r
+                               \r
+                               statusLinkLabel.Links.Clear();\r
+                               if (string.IsNullOrEmpty(instPath)) {\r
+                                       statusLinkLabel.Text = "情報が提供されていません";\r
+                                       statusLinkLabel.Enabled = false;\r
+                               } else {\r
+                                       statusLinkLabel.Text = instPath;\r
+                                       statusLinkLabel.Enabled = true;\r
+                                       statusLinkLabel.Links.Add(0, instPath.Length, instPath);\r
+                               }\r
+                       }\r
+                       urlLinkLabel.Links.Clear();\r
+                       if (pkg.Url != null) {\r
+                               urlLinkLabel.Text = pkg.Url.Href;\r
+                               urlLinkLabel.Links.Add(0, pkg.Url.Href.Length, pkg.Url.Href);\r
+                               urlLinkLabel.Enabled = true;\r
+                               urlLabel.Enabled = true;\r
+                       } else {\r
+                               urlLinkLabel.Text = string.Empty;\r
+                               urlLinkLabel.Enabled = false;\r
+                               urlLabel.Enabled = false;\r
+                       }\r
+                       tagsTextBox.Text = pkg.Tags;\r
+                       setLinkLabelFromLicense(licenseLinkLabel, pkg);\r
+                       typeValueLabel.Text = PackageDescripter.GetInstallerTypeLabel(pkg.Type);\r
+                       if (! string.IsNullOrEmpty(pkg.PackageListName)) {\r
+                               packageListNameValueLabel.Text = pkg.PackageListName;\r
+                               packageListNameValueLabel.Enabled = true;\r
+                       } else {\r
+                               packageListNameValueLabel.Enabled = false;\r
+                       }\r
+                       \r
+                       tabControl1.TabPages.Clear();\r
+                       if (pkg is InstalledPackage && string.IsNullOrEmpty(pkg.Version)) {\r
+                               tabControl1.Visible = false;\r
+                       } else {\r
+                               tabControl1.Visible = true;\r
+                               foreach (Installer inst in pkg.Installer) {\r
+                                       TabPage page = new TabPage(string.Format("インストーラー その{0}", tabControl1.TabCount+1));\r
+                                       page.Dock = DockStyle.Fill;\r
+                                       \r
+                                       InstallerInfoForm instForm = new InstallerInfoForm();\r
+                                       instForm.SelectedObject = inst;\r
+                                       instForm.Dock = DockStyle.Fill;\r
+                                       page.Controls.Add(instForm);\r
+                                       \r
+                                       tabControl1.TabPages.Add(page);\r
+                               }\r
+                       }\r
+                       \r
+                       this.Size = new Size(this.Size.Width, (tabControl1.TabCount>0)? 380 : 250);\r
+               }\r
+               \r
+               /// <summary>\r
+               /// インストーラーの種類についてラベルにテキストを設定する\r
+               /// </summary>\r
+               /// <param name="typeValueLabel">設定先のラベル</param>\r
+               /// <param name="instType">インストーラーの種類</param>\r
+               private static void setLinkLabelFromLicense(LinkLabel linklabel, Package pkg)\r
+               {\r
+                       linklabel.Enabled = true;\r
+                       \r
+                       string text;\r
+                       LinkLabel.Link[] links;\r
+                       PackageDescripter.GetLicenseValueLabel(pkg, out text, out links);\r
+                       \r
+                       linklabel.Text = text;\r
+                       linklabel.Links.Clear();\r
+                       foreach (LinkLabel.Link link in links) {\r
+                               linklabel.Links.Add(link);\r
+                       }\r
+               }\r
+               \r
+               private void linkLabelLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)\r
+               {\r
+                       string linkData = e.Link.LinkData.ToString();\r
+                       \r
+                       if (Directory.Exists(linkData)) {\r
+                               e.Link.Visited = true;\r
+                               System.Diagnostics.Process.Start(e.Link.LinkData.ToString());\r
+                       } else if (System.Text.RegularExpressions.Regex.IsMatch(linkData, @"^(https?|file)://")) {\r
+                               e.Link.Visited = true;\r
+                               try {\r
+                                       System.Diagnostics.Process.Start(e.Link.LinkData.ToString());\r
+                               } catch (System.ComponentModel.Win32Exception) {\r
+                                       MessageBox.Show(string.Format("{0}を開くのに失敗しました。", e.Link.LinkData), "ブラウザ起動エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                               }\r
+                       }\r
+               }\r
+               \r
+               void CloseButtonClick(object sender, EventArgs e)\r
+               {\r
+                       if (! this.Modal) {\r
+                               this.DialogResult = DialogResult.OK;\r
+                               this.Close();\r
+                       }\r
+               }\r
+               \r
+               void PackageInfoFormFormClosed(object sender, FormClosedEventArgs e)\r
+               {\r
+                       this.Dispose(true);\r
+               }\r
+       }\r
+}\r
index fa294e5..20eb7b2 100644 (file)
@@ -1,4 +1,4 @@
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
   <PropertyGroup>\r
     <ProjectGuid>{0FC9CFF6-95CE-4C2D-833D-F6D697CD57EB}</ProjectGuid>\r
     <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>\r
     <Reference Include="System.Xml" />\r
   </ItemGroup>\r
   <ItemGroup>\r
+    <Compile Include="AppliStation.PackageInfo\PackageDescripter.cs" />\r
+    <Compile Include="AppliStation.PackageInfo\InstallerInfoForm.cs" />\r
+    <Compile Include="AppliStation.PackageInfo\InstallerInfoForm.Designer.cs">\r
+      <DependentUpon>InstallerInfoForm.cs</DependentUpon>\r
+    </Compile>\r
+    <Compile Include="AppliStation.PackageInfo\PackageInfoForm.cs" />\r
+    <Compile Include="AppliStation.PackageInfo\PackageInfoForm.Designer.cs">\r
+      <DependentUpon>PackageInfoForm.cs</DependentUpon>\r
+    </Compile>\r
     <Compile Include="AppliStation.Util\ExceptionDialogForm.cs" />\r
     <Compile Include="AppliStation.Util\ExceptionDialogForm.Designer.cs">\r
       <DependentUpon>ExceptionDialogForm.cs</DependentUpon>\r
     <Compile Include="AppliStation.Util\ToolStripWeb2LikeTextBox.cs" />\r
     <Compile Include="AssemblyInfo.cs" />\r
     <Compile Include="PackageListView.cs" />\r
-    <Compile Include="InstallerInfoForm.cs" />\r
-    <Compile Include="InstallerInfoForm.Designer.cs">\r
-      <DependentUpon>InstallerInfoForm.cs</DependentUpon>\r
-    </Compile>\r
-    <Compile Include="PackageInfoForm.cs" />\r
-    <Compile Include="PackageInfoForm.Designer.cs">\r
-      <DependentUpon>PackageInfoForm.cs</DependentUpon>\r
-    </Compile>\r
     <Compile Include="PackageListViewForm.cs" />\r
     <Compile Include="PackageListViewForm.Designer.cs">\r
       <DependentUpon>PackageListViewForm.cs</DependentUpon>\r
     <Compile Include="UserPrefForm.Designer.cs">\r
       <DependentUpon>UserPrefForm.cs</DependentUpon>\r
     </Compile>\r
+    <EmbeddedResource Include="AppliStation.PackageInfo\InstallerInfoForm.resx">\r
+      <DependentUpon>InstallerInfoForm.cs</DependentUpon>\r
+    </EmbeddedResource>\r
+    <EmbeddedResource Include="AppliStation.PackageInfo\PackageInfoForm.resx">\r
+      <DependentUpon>PackageInfoForm.cs</DependentUpon>\r
+    </EmbeddedResource>\r
     <EmbeddedResource Include="AppliStation.Util\ExceptionDialogForm.resx">\r
       <DependentUpon>ExceptionDialogForm.Designer.cs</DependentUpon>\r
     </EmbeddedResource>\r
     <EmbeddedResource Include="AppliStation.Util\ExecutionProgressViewer.resx">\r
       <DependentUpon>ExecutionProgressViewer.cs</DependentUpon>\r
     </EmbeddedResource>\r
-    <EmbeddedResource Include="InstallerInfoForm.resx">\r
-      <DependentUpon>InstallerInfoForm.cs</DependentUpon>\r
-    </EmbeddedResource>\r
-    <EmbeddedResource Include="PackageInfoForm.resx">\r
-      <DependentUpon>PackageInfoForm.cs</DependentUpon>\r
-    </EmbeddedResource>\r
     <EmbeddedResource Include="PackageListViewForm.resx">\r
       <DependentUpon>PackageListViewForm.cs</DependentUpon>\r
     </EmbeddedResource>\r
   </ItemGroup>\r
   <ItemGroup>\r
     <Folder Include="AppliStation.Util" />\r
+    <Folder Include="AppliStation.PackageInfo" />\r
     <ProjectReference Include="..\na-get-lib\na-get-lib.csproj">\r
       <Project>{058E953D-3986-4F74-8516-5A50D267D36A}</Project>\r
       <Name>na-get-lib</Name>\r
     </ProjectReference>\r
   </ItemGroup>\r
-</Project>
\ No newline at end of file
+</Project>\r
diff --git a/AppliStation/InstallerInfoForm.cs b/AppliStation/InstallerInfoForm.cs
deleted file mode 100644 (file)
index 8461fac..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-using System;\r
-using System.ComponentModel;\r
-using System.Drawing;\r
-using System.Windows.Forms;\r
-\r
-using NaGet.Packages;\r
-using NaGet.Packages.Install;\r
-using System.Reflection;\r
-\r
-namespace AppliStation\r
-{\r
-       /// <summary>\r
-       /// Description of InstallerInfoForm.\r
-       /// </summary>\r
-       public partial class InstallerInfoForm : UserControl\r
-       {\r
-               private Installer inst;\r
-               \r
-               public InstallerInfoForm()\r
-               {\r
-                       //\r
-                       // The InitializeComponent() call is required for Windows Forms designer support.\r
-                       //\r
-                       InitializeComponent();\r
-               }\r
-               \r
-               public Installer SelectedObject {\r
-                       get { return inst; }\r
-                       set {\r
-                               inst = value;\r
-                               updateInst();\r
-                       }\r
-               }\r
-               \r
-               private void updateInst()\r
-               {\r
-                       installerUrlTextBox.Text = (inst == null || inst.Url == null)?\r
-                               string.Empty : inst.Url.Href;\r
-                       \r
-                       if (inst.Platform == null || string.IsNullOrEmpty(inst.Platform.Os)) {\r
-                               osValueLabel.Text = "\94C\88Ó\82ÌWindows";\r
-                       } else {\r
-                               osValueLabel.Text = inst.Platform.Os.Replace("WIN", string.Empty);\r
-                       }\r
-                       \r
-                       switch ((inst.Platform != null)? inst.Platform.Arch : System.Reflection.ProcessorArchitecture.X86) {\r
-                               case System.Reflection.ProcessorArchitecture.Amd64:\r
-                                       archValueLabel.Text = "x64 (64\83r\83b\83g\8aÂ\8b«)";\r
-                                       break;\r
-                               case System.Reflection.ProcessorArchitecture.IA64:\r
-                                       archValueLabel.Text = "Itanium";\r
-                                       break;\r
-                               case System.Reflection.ProcessorArchitecture.None:\r
-                               case System.Reflection.ProcessorArchitecture.MSIL:\r
-                                       archValueLabel.Text = "\83A\81[\83L\83e\83N\83`\83\83\88Ë\91\82È\82µ";\r
-                                       break;\r
-                               case System.Reflection.ProcessorArchitecture.X86:\r
-                                       archValueLabel.Text = "x86 (32\83r\83b\83g\8aÂ\8b«)";\r
-                                       break;\r
-                       }\r
-                       \r
-                       cannotRunLabel.Visible = ! ((inst.Platform == null) || inst.Platform.IsRunnable());\r
-               }\r
-       }\r
-}\r
diff --git a/AppliStation/PackageInfoForm.cs b/AppliStation/PackageInfoForm.cs
deleted file mode 100644 (file)
index ea6b07b..0000000
+++ /dev/null
@@ -1,299 +0,0 @@
-using System;\r
-using System.Drawing;\r
-using System.Windows.Forms;\r
-using System.Text;\r
-using System.IO;\r
-using NaGet.Packages.Install;\r
-using NaGet.Packages;\r
-\r
-namespace AppliStation\r
-{\r
-       /// <summary>\r
-       /// Description of PackageInfoForm.\r
-       /// </summary>\r
-       public partial class PackageInfoForm : Form\r
-       {\r
-               private Package pkg;\r
-               \r
-               public PackageInfoForm()\r
-               {\r
-                       InitializeComponent();\r
-               }\r
-               \r
-               /// <summary>\r
-               /// 現在選択中(=表示中)のパッケージ\r
-               /// </summary>\r
-               public Package SelectedObject {\r
-                       get { return pkg; }\r
-                       set {\r
-                               pkg = value;\r
-                               updateSelectedObject();\r
-                       }\r
-               }\r
-               \r
-               private void updateSelectedObject()\r
-               {\r
-                       bool isInstalledPackage = pkg is InstalledPackage;\r
-                       \r
-                       iconLabel.Image = null;\r
-                       iconLabel.Size = Size.Empty;\r
-                       if (isInstalledPackage) {\r
-                               Icon icon = AppliStation.Util.GUIUtils.GetIconForPackage((InstalledPackage) pkg);\r
-                               if (icon != null) {\r
-                                       iconLabel.Image = icon.ToBitmap();\r
-                                       iconLabel.Size = icon.Size;\r
-                               }\r
-                       }\r
-                       nameLabel.Text = string.Format("{0} ({1})", pkg.Name, pkg.Version);\r
-                       nameLabel.Font = new Font(SystemFonts.CaptionFont.FontFamily, SystemFonts.CaptionFont.Size*1.25f);\r
-                       \r
-                       summaryTextBox.Text = pkg.Summary;\r
-                       \r
-                       if (isInstalledPackage) {\r
-                               UninstallInformation uninstInfo = ((InstalledPackage) pkg).UninstallInfo;\r
-                               \r
-                               string instPath = null;\r
-                               if ((pkg.Type == InstallerType.ARCHIVE)\r
-                                   ||(pkg.Type == InstallerType.ITSELF)) {\r
-                                       instPath = Path.Combine(NaGet.Env.ArchiveProgramFiles, pkg.Name);\r
-                               } else if (Directory.Exists(uninstInfo.InstallLocation)) {\r
-                                       instPath = uninstInfo.InstallLocation;\r
-                               }\r
-                               \r
-                               statusLinkLabel.Links.Clear();\r
-                               if (string.IsNullOrEmpty(instPath)) {\r
-                                       statusLinkLabel.Text = "情報が提供されていません";\r
-                                       statusLinkLabel.Enabled = false;\r
-                               } else {\r
-                                       statusLinkLabel.Text = instPath;\r
-                                       statusLinkLabel.Enabled = true;\r
-                                       \r
-                                       addLinkToLinkLabel(statusLinkLabel, uninstInfo.InstallLocation, uninstInfo.InstallLocation);\r
-                               }\r
-                       }\r
-                       urlLinkLabel.Links.Clear();\r
-                       if (pkg.Url != null) {\r
-                               urlLinkLabel.Text = pkg.Url.Href;\r
-                               urlLinkLabel.Links.Add(0, pkg.Url.Href.Length, pkg.Url.Href);\r
-                               urlLinkLabel.Enabled = true;\r
-                               urlLabel.Enabled = true;\r
-                       } else {\r
-                               urlLinkLabel.Text = string.Empty;\r
-                               urlLinkLabel.Enabled = false;\r
-                               urlLabel.Enabled = false;\r
-                       }\r
-                       tagsTextBox.Text = pkg.Tags;\r
-                       setLinkLabelFromLicense(licenseLinkLabel, pkg.License, (pkg.Url!=null)?pkg.Url.Href:string.Empty);\r
-                       setTypeValueLabel(typeValueLabel, pkg.Type);\r
-                       if (! string.IsNullOrEmpty(pkg.PackageListName)) {\r
-                               packageListNameValueLabel.Text = pkg.PackageListName;\r
-                               packageListNameValueLabel.Enabled = true;\r
-                       } else {\r
-                               packageListNameValueLabel.Enabled = false;\r
-                       }\r
-                       \r
-                       tabControl1.TabPages.Clear();\r
-                       if (pkg is InstalledPackage && string.IsNullOrEmpty(pkg.Version)) {\r
-                               tabControl1.Visible = false;\r
-                       } else {\r
-                               tabControl1.Visible = true;\r
-                               foreach (Installer inst in pkg.Installer) {\r
-                                       TabPage page = new TabPage(string.Format("インストーラー その{0}", tabControl1.TabCount+1));\r
-                                       page.Dock = DockStyle.Fill;\r
-                                       \r
-                                       InstallerInfoForm instForm = new InstallerInfoForm();\r
-                                       instForm.SelectedObject = inst;\r
-                                       instForm.Dock = DockStyle.Fill;\r
-                                       page.Controls.Add(instForm);\r
-                                       \r
-                                       tabControl1.TabPages.Add(page);\r
-                               }\r
-                       }\r
-                       \r
-                       this.Size = new Size(this.Size.Width, (tabControl1.TabCount>0)? 380 : 250);\r
-               }\r
-               \r
-               /// <summary>\r
-               /// インストーラーの種類についてラベルにテキストを設定する\r
-               /// </summary>\r
-               /// <param name="typeValueLabel">設定先のラベル</param>\r
-               /// <param name="instType">インストーラーの種類</param>\r
-               private static void setLinkLabelFromLicense(LinkLabel linklabel, string license, string publicSiteUrl)\r
-               {\r
-                       linklabel.Enabled = true;\r
-                       switch (license ?? string.Empty) {\r
-                               case "":\r
-                                       if (string.IsNullOrEmpty(publicSiteUrl)) {\r
-                                               linklabel.Text = "フリーソフトウェア (無償)";\r
-                                               linklabel.Enabled = false;\r
-                                       } else {\r
-                                               linklabel.Text = "フリーソフトウェア (詳細は公式サイトなどで確認してください)";\r
-                                               addLinkToLinkLabel(linklabel, "公式サイト", publicSiteUrl);\r
-                                       }\r
-                                       break;\r
-                               #region オープンソースかつコピーレフト\r
-                               case "GPL":\r
-                                       linklabel.Text = "GPL (オープンソース)";\r
-                                       addLinkToLinkLabel(linklabel, "GPL", @"http://www.opensource.jp/gpl/gpl.ja.html");\r
-                                       addLinkToLinkLabel(linklabel, "オープンソース", @"http://creativecommons.org/licenses/GPL/2.0/deed.ja");\r
-                                       break;\r
-                               case "GPLv2":\r
-                               case "GPLv2+":\r
-                                       linklabel.Text = "GPLv2 (オープンソース)";\r
-                                       addLinkToLinkLabel(linklabel, "GPLv2", @"http://www.gnu.org/licenses/gpl-2.0.txt");\r
-                                       break;\r
-                               case "GPLv3":\r
-                               case "GPLv3+":\r
-                                       linklabel.Text = "GPLv3 (オープンソース)";\r
-                                       addLinkToLinkLabel(linklabel, "GPLv3", @"http://www.gnu.org/licenses/gpl-3.0.txt");\r
-                                       break;\r
-                               case "LGPL":\r
-                                       linklabel.Text = "LGPL (オープンソース)";\r
-                                       addLinkToLinkLabel(linklabel, "LGPL", @"http://www.opensource.jp/lesser/lgpl.ja.html");\r
-                                       addLinkToLinkLabel(linklabel, "オープンソース", @"http://creativecommons.org/licenses/LGPL/2.1/deed.ja");\r
-                                       break;\r
-                               case "LGPLv2":\r
-                               case "LGPLv2+":\r
-                                       linklabel.Text = "LGPLv2 (オープンソース)";\r
-                                       addLinkToLinkLabel(linklabel, "LGPLv2", @"http://www.gnu.org/licenses/lgpl-2.1.txt");\r
-                                       break;\r
-                               case "LGPLv3":\r
-                               case "LGPLv3+":\r
-                                       linklabel.Text = "LGPLv3 (オープンソース)";\r
-                                       addLinkToLinkLabel(linklabel, "LGPLv3", @"http://www.gnu.org/licenses/lgpl-3.0.txt");\r
-                                       break;\r
-                               case "AGPLv3":\r
-                               case "AGPLv3+":\r
-                                       linklabel.Text = "AGPLv3 (オープンソース)";\r
-                                       addLinkToLinkLabel(linklabel, "AGPLv3", @"http://www.gnu.org/licenses/agpl-3.0.txt");\r
-                                       break;\r
-                               case "MPL":\r
-                                       linklabel.Text = "MPL (オープンソース)";\r
-                                       addLinkToLinkLabel(linklabel, "MPL", @"http://www.mozilla.org/MPL/MPL-1.1.html");\r
-                                       break;\r
-                               case "CPL":\r
-                                       linklabel.Text = "CPL (オープンソース)";\r
-                                       linklabel.Links.Add(0, linklabel.Text.Length, @"http://sourceforge.jp/projects/opensource/wiki/licenses%2FCommon_Public_License");\r
-                                       break;\r
-                               case "Artistic":\r
-                                       linklabel.Text = "Artisticライセンス (オープンソース)";\r
-                                       addLinkToLinkLabel(linklabel, "Artisticライセンス", @"http://www.perlfoundation.org/artistic_license_2_0");\r
-                                       break;\r
-                               #endregion\r
-                               #region オープンソースだが、コピーレフトでない著名なライセンス\r
-                               case "MIT":\r
-                                       linklabel.Text = "MITライセンス (オープンソース)";\r
-                                       addLinkToLinkLabel(linklabel, "MITライセンス", @"http://www.opensource.org/licenses/mit-license.php");\r
-                                       break;\r
-                               case "BSD":\r
-                                       linklabel.Text = "修正済BSDライセンス (オープンソース)";\r
-                                       addLinkToLinkLabel(linklabel, "BSDライセンス", @"http://www.opensource.org/licenses/bsd-license.php");\r
-                                       break;\r
-                               case "Apache":\r
-                               case "ASLv2":\r
-                               case "ASLv2+":\r
-                                       linklabel.Text = "Apacheライセンス (オープンソース)";\r
-                                       addLinkToLinkLabel(linklabel, "Apacheライセンス", @"http://www.apache.org/licenses/LICENSE-2.0.txt");\r
-                                       break;\r
-                               case "zlib":\r
-                                       linklabel.Text = "zlibライセンス";\r
-                                       linklabel.Links.Add(0, linklabel.Text.Length, @"http://opentechpress.jp/docs/licenses/zlib-license.shtml");\r
-                                       break;\r
-                               #endregion\r
-                               case "WTFPL":\r
-                               case "WTFPLv2":\r
-                                       linklabel.Text = "WTFPL";\r
-                                       linklabel.Links.Add(0, linklabel.Text.Length, @"http://sam.zoy.org/wtfpl/");\r
-                                       break;\r
-                               case "NYSL":\r
-                                       linklabel.Text = "煮るなり焼くなり好きにしろライセンス";\r
-                                       linklabel.Links.Add(0, linklabel.Text.Length, @"http://www.kmonos.net/nysl/NYSL_withfaq.TXT");\r
-                                       break;\r
-                               case "Public Domain":\r
-                                       linklabel.Text = "パブリックドメイン (著作権帰属なし)";\r
-                                       linklabel.Links.Add(0, linklabel.Text.Length, @"http://e-words.jp/w/E38391E38396E383AAE38383E382AFE38389E383A1E382A4E383B3.html");\r
-                                       break;\r
-                               default:\r
-                                       if (license.StartsWith("http://")) {\r
-                                               linklabel.Text = license;\r
-                                               linklabel.Links.Add(0, license.Length, license);\r
-                                       } else {\r
-                                               linklabel.Text = license;\r
-                                               linklabel.Links.Add(0, 0, string.Empty);\r
-                                       }\r
-                                       break;\r
-                       }\r
-                       \r
-               }\r
-               \r
-               /// <summary>\r
-               /// インストーラーの種類についてラベルにテキストを設定する\r
-               /// </summary>\r
-               /// <param name="typeValueLabel">設定先のラベル</param>\r
-               /// <param name="instType">インストーラーの種類</param>\r
-               private static void setTypeValueLabel(Label typeValueLabel, InstallerType instType)\r
-               {\r
-                       switch (instType) {\r
-                               case InstallerType.ARCHIVE:\r
-                                       typeValueLabel.Text = "自己解凍書庫または書庫";\r
-                                       break;\r
-                               case InstallerType.EXEC_INSTALLER:\r
-                                       typeValueLabel.Text = "インストーラー形式";\r
-                                       break;\r
-                               case InstallerType.MSI_PACKAGE:\r
-                                       typeValueLabel.Text = "MSIファイル形式";\r
-                                       break;\r
-                               case InstallerType.ITSELF:\r
-                                       typeValueLabel.Text = "単体の実行ファイル";\r
-                                       break;\r
-                               default:\r
-                                       typeValueLabel.Text = "不明なインストール形式(インストール不能)";\r
-                                       break;\r
-                       }\r
-               }\r
-               \r
-               /// <summary>\r
-               /// リンクラベルのリンク挿入便利メソッド\r
-               /// </summary>\r
-               /// <param name="linkLabel">対象リンクラベル</param>\r
-               /// <param name="word">リンク対象文字列</param>\r
-               /// <param name="link">リンクオブジェクト</param>\r
-               private static void addLinkToLinkLabel(LinkLabel linkLabel, string word, string link)\r
-               {\r
-                       int pos = linkLabel.Text.IndexOf(word, 0);\r
-                       if (pos >= 0) {\r
-                               linkLabel.Links.Add(pos, word.Length, link);\r
-                       } else throw new ArgumentException(string.Format("label text \"{0}\" does not contain \"{1}\"!", linkLabel.Text, word));\r
-               }\r
-               \r
-               private void linkLabelLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)\r
-               {\r
-                       string linkData = e.Link.LinkData.ToString();\r
-                       \r
-                       if (Directory.Exists(linkData)) {\r
-                               e.Link.Visited = true;\r
-                               System.Diagnostics.Process.Start(e.Link.LinkData.ToString());\r
-                       } else if (System.Text.RegularExpressions.Regex.IsMatch(linkData, @"^(https?|file)://")) {\r
-                               e.Link.Visited = true;\r
-                               try {\r
-                                       System.Diagnostics.Process.Start(e.Link.LinkData.ToString());\r
-                               } catch (System.ComponentModel.Win32Exception) {\r
-                                       MessageBox.Show(string.Format("{0}を開くのに失敗しました。", e.Link.LinkData), "ブラウザ起動エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
-                               }\r
-                       }\r
-               }\r
-               \r
-               void CloseButtonClick(object sender, EventArgs e)\r
-               {\r
-                       if (! this.Modal) {\r
-                               this.DialogResult = DialogResult.OK;\r
-                               this.Close();\r
-                       }\r
-               }\r
-               \r
-               void PackageInfoFormFormClosed(object sender, FormClosedEventArgs e)\r
-               {\r
-                       this.Dispose(true);\r
-               }\r
-       }\r
-}\r
index b280c30..4a5b13d 100644 (file)
@@ -6,6 +6,8 @@ using NaGet.Packages.Install;
 using System.IO;\r
 using System.Collections.Generic;\r
 \r
+using AppliStation.PackageInfo;\r
+\r
 namespace AppliStation\r
 {\r
        /// <summary>\r