OSDN Git Service

na-get-lib,ひとまず依存関係解決関数群を作った。
[applistation/AppliStation.git] / AppliStation / PackageInfoForm.cs
index bba3912..72f73f5 100644 (file)
@@ -1,4 +1,4 @@
-using System;\r
+using System;\r
 using System.Drawing;\r
 using System.Windows.Forms;\r
 using NaGet.Packages.Install;\r
@@ -19,6 +19,9 @@ namespace AppliStation
                        InitializeComponent();\r
                }\r
                \r
+               /// <summary>\r
+               /// 現在選択中(=表示中)のパッケージ\r
+               /// </summary>\r
                public Package SelectedObject {\r
                        get { return pkg; }\r
                        set {\r
@@ -34,7 +37,7 @@ namespace AppliStation
                        iconLabel.Image = null;\r
                        iconLabel.Size = Size.Empty;\r
                        if (isInstalledPackage) {\r
-                               Icon icon = AppliStation.Util.PackageUtils.GetIconForPackage((InstalledPackage) pkg);\r
+                               Icon icon = AppliStation.Util.GUIUtils.GetIconForPackage((InstalledPackage) pkg);\r
                                if (icon != null) {\r
                                        iconLabel.Image = icon.ToBitmap();\r
                                        iconLabel.Size = icon.Size;\r
@@ -57,7 +60,7 @@ namespace AppliStation
                                \r
                                statusLinkLabel.Links.Clear();\r
                                if (string.IsNullOrEmpty(instPath)) {\r
-                                       statusLinkLabel.Text = "\8fî\95ñ\82ª\92ñ\8b\9f\82³\82ê\82Ä\82¢\82Ü\82¹\82ñ";\r
+                                       statusLinkLabel.Text = "情報が提供されていません";\r
                                        statusLinkLabel.Enabled = false;\r
                                } else {\r
                                        statusLinkLabel.Text = instPath;\r
@@ -76,8 +79,8 @@ namespace AppliStation
                                urlLabel.Enabled = false;\r
                        }\r
                        tagsTextBox.Text = pkg.Tags;\r
-                       setLinkLabelFromLicense(licenseLinkLabel, pkg.License);\r
-                       typeValueLabel.Text = pkg.Type.ToString();\r
+                       setLinkLabelFromLicense(licenseLinkLabel, pkg.License, pkg.Url.Href);\r
+                       setTypeValueLabel(typeValueLabel, pkg.Type);\r
                        \r
                        tabControl1.TabPages.Clear();\r
                        if (pkg is InstalledPackage && string.IsNullOrEmpty(pkg.Version)) {\r
@@ -85,7 +88,7 @@ namespace AppliStation
                        } else {\r
                                tabControl1.Visible = true;\r
                                foreach (Installer inst in pkg.Installer) {\r
-                                       TabPage page = new TabPage(string.Format("\83C\83\93\83X\83g\81[\83\89 \82»\82Ì{0}", tabControl1.TabCount+1));\r
+                                       TabPage page = new TabPage(string.Format("インストーラ その{0}", tabControl1.TabCount+1));\r
                                        page.Dock = DockStyle.Fill;\r
                                        \r
                                        InstallerInfoForm instForm = new InstallerInfoForm();\r
@@ -96,64 +99,103 @@ namespace AppliStation
                                        tabControl1.TabPages.Add(page);\r
                                }\r
                        }\r
+                       \r
+                       this.Size = new Size(this.Size.Width, (tabControl1.TabCount>0)? 380 : 250);\r
                }\r
                \r
-               private static void setLinkLabelFromLicense(LinkLabel linklabel, string license)\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
-                                       linklabel.Text = "\83t\83\8a\81[\83\\83t\83g\83E\83F\83A (\96³\8f\9e)";\r
-                                       linklabel.Enabled = false;\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 (\83I\81[\83v\83\93\83\\81[\83X)";\r
+                                       linklabel.Text = "GPL (オープンソース)";\r
                                        addLinkToLinkLabel(linklabel, "GPL", @"http://www.gnu.org/licenses/gpl.ja.html");\r
-                                       addLinkToLinkLabel(linklabel, "\83I\81[\83v\83\93\83\\81[\83X", @"http://creativecommons.org/licenses/GPL/2.0/deed.ja");\r
+                                       addLinkToLinkLabel(linklabel, "オープンソース", @"http://creativecommons.org/licenses/GPL/2.0/deed.ja");\r
                                        break;\r
                                case "GPLv2":\r
-                                       linklabel.Text = "GPLv2 (\83I\81[\83v\83\93\83\\81[\83X)";\r
-                                       addLinkToLinkLabel(linklabel, "GPLv2", @"http://www.gnu.org/licenses/gpl-2.0.html");\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
-                                       linklabel.Text = "GPLv3 (\83I\81[\83v\83\93\83\\81[\83X)";\r
-                                       addLinkToLinkLabel(linklabel, "GPLv3", @"http://www.gnu.org/licenses/gpl-3.0.html");\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 (\83I\81[\83v\83\93\83\\81[\83X)";\r
+                                       linklabel.Text = "LGPL (オープンソース)";\r
                                        addLinkToLinkLabel(linklabel, "LGPL", @"http://www.gnu.org/licenses/lgpl.ja.html");\r
-                                       addLinkToLinkLabel(linklabel, "\83I\81[\83v\83\93\83\\81[\83X", @"http://creativecommons.org/licenses/LGPL/2.1/deed.ja");\r
+                                       addLinkToLinkLabel(linklabel, "オープンソース", @"http://creativecommons.org/licenses/LGPL/2.1/deed.ja");\r
                                        break;\r
                                case "LGPLv2":\r
-                                       linklabel.Text = "LGPLv2 (\83I\81[\83v\83\93\83\\81[\83X)";\r
-                                       addLinkToLinkLabel(linklabel, "LGPLv2", @"http://www.gnu.org/licenses/lgpl-2.1.html");\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
-                                       linklabel.Text = "LGPLv3 (\83I\81[\83v\83\93\83\\81[\83X)";\r
-                                       addLinkToLinkLabel(linklabel, "LGPLv3", @"http://www.gnu.org/licenses/lgpl-3.0.html");\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 (\83I\81[\83v\83\93\83\\81[\83X)";\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 (\83I\81[\83v\83\93\83\\81[\83X)";\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\83\89\83C\83Z\83\93\83X (\83I\81[\83v\83\93\83\\81[\83X)";\r
-                                       addLinkToLinkLabel(linklabel, "MIT\83\89\83C\83Z\83\93\83X", @"http://www.opensource.org/licenses/mit-license.php");\r
+                                       linklabel.Text = "MITライセンス (オープンソース)";\r
+                                       addLinkToLinkLabel(linklabel, "MITライセンス", @"http://www.opensource.org/licenses/mit-license.php");\r
                                        break;\r
                                case "BSD":\r
-                                       linklabel.Text = "\8fC\90³\8dÏBSD\83\89\83C\83Z\83\93\83X (\83I\81[\83v\83\93\83\\81[\83X)";\r
-                                       addLinkToLinkLabel(linklabel, "BSD\83\89\83C\83Z\83\93\83X", @"http://www.opensource.org/licenses/bsd-license.php");\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 "NYSL":\r
-                                       linklabel.Text = "\8eÏ\82é\82È\82è\8fÄ\82­\82È\82è\8dD\82«\82É\82µ\82ë\83\89\83C\83Z\83\93\83X";\r
-                                       linklabel.Links.Add(0, linklabel.Text.Length, @"http://www.kmonos.net/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 = "\83p\83u\83\8a\83b\83N\83h\83\81\83C\83\93 (\92\98\8dì\8c \94ñ\93K\97p)";\r
+                                       linklabel.Text = "パブリックドメイン (著作権帰属なし)";\r
                                        linklabel.Links.Add(0, linklabel.Text.Length, @"http://e-words.jp/w/E38391E38396E383AAE38383E382AFE38389E383A1E382A4E383B3.html");\r
                                        break;\r
                                default:\r
@@ -170,11 +212,34 @@ namespace AppliStation
                }\r
                \r
                /// <summary>\r
-               /// \83\8a\83\93\83N\83\89\83x\83\8b\82Ì\83\8a\83\93\83N\91}\93ü\95Ö\97\98\83\81\83\\83b\83h\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
+                               default:\r
+                                       typeValueLabel.Text = "不明なインストール形式(インストール不能)";\r
+                                       break;\r
+                       }\r
+               }\r
+               \r
+               /// <summary>\r
+               /// リンクラベルのリンク挿入便利メソッド\r
                /// </summary>\r
-               /// <param name="linkLabel">\91Î\8fÛ\83\8a\83\93\83N\83\89\83x\83\8b</param>\r
-               /// <param name="word">\83\8a\83\93\83N\91Î\8fÛ\95\8e\9a\97ñ</param>\r
-               /// <param name="link">\83\8a\83\93\83N\83I\83u\83W\83F\83N\83g</param>\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