OSDN Git Service

AppliStation-GUI,インストール除外リストの設定を設定ダイアログに追加
[applistation/AppliStation.git] / AppliStation / AppliStation.Util / ToolStripPetitLauncherMenuItem.cs
index b90d674..f8c5097 100644 (file)
@@ -19,7 +19,7 @@ namespace AppliStation.Util
                private Form invokerForm;\r
                \r
                /// <summary>\r
-               /// 親フォルダ\r
+               /// 親フォルダ\r
                /// </summary>\r
                [ReadOnly(true)]\r
                public string BaseFolderPath {\r
@@ -50,10 +50,6 @@ namespace AppliStation.Util
                                thread = null;\r
                        }\r
                        \r
-                       try {\r
-                               DropDownItems.Clear();\r
-                       } catch (NullReferenceException) {\r
-                       }\r
                        if (Directory.Exists(baseFolderPath)) {\r
                                thread = new Thread(new ThreadStart(buildItems));\r
                                thread.Start();\r
@@ -81,32 +77,41 @@ namespace AppliStation.Util
                        }\r
                }\r
                \r
-               private void _insertItemFor(string filepath, ref bool cmdIsAdded)\r
+               private void _insertItemFor(string filepath, ref bool cmdIsAdded, string basedir)\r
                {\r
                        string extension = Path.GetExtension(filepath).ToLower();\r
+                       \r
+                       string dirname = Path.GetDirectoryName(filepath);\r
+                       string itemtext = NaGet.Utils.GetRelativePath(basedir, filepath);\r
+#if DEBUG\r
+Debug.Assert(! itemtext.Contains(".."), string.Format("{2} -- base:{0}, dirname:{1}", basedir, dirname, itemtext));\r
+#endif\r
+                       \r
                        if (extension == ".exe") {\r
                                switch (NaGet.InteropServices.PEFileInfoUtils.GetPEFileType(filepath)) {\r
-                                       case NaGet.InteropServices.PEFileInfoUtils.PEFileType.WinGUI:\r
-                                               _addToItemsInv(CreateMenuItemForFile(filepath));\r
+                                       case NaGet.InteropServices.PEFileType.WinGUI:\r
+                                               _addToItemsInv(CreateMenuItemForFile(filepath, itemtext));\r
                                                break;\r
-                                       case NaGet.InteropServices.PEFileInfoUtils.PEFileType.WinConsole:\r
-                                       case NaGet.InteropServices.PEFileInfoUtils.PEFileType.MSDosCom:\r
+                                       case NaGet.InteropServices.PEFileType.WinConsole:\r
+                                       case NaGet.InteropServices.PEFileType.MSDosCom:\r
                                                if (! cmdIsAdded) {\r
-                                                       _insertToItemsInv(0, CreateMenuItemForCmdAt(Path.GetDirectoryName(filepath)));\r
+                                                       _insertToItemsInv(0, CreateMenuItemForCmdAt(basedir));\r
                                                        cmdIsAdded = true;\r
                                                }\r
                                                break;\r
                                }\r
                        } else if ((extension == ".bat") || (extension == ".lnk")) {\r
-                               _addToItemsInv(CreateMenuItemForFile(filepath));\r
+                               _addToItemsInv(CreateMenuItemForFile(filepath, itemtext));\r
                        }\r
                }\r
                \r
                        \r
                private void buildItems()\r
                {\r
+                       DropDownItems.Clear();\r
+                       \r
                        try {\r
-                               string folderPath = baseFolderPath;\r
+                               string folderPath = Path.GetFullPath(baseFolderPath);\r
                                ToolStripSeparator sep = new ToolStripSeparator();\r
                                bool cmdIsAdded = false;\r
                                \r
@@ -117,7 +122,16 @@ namespace AppliStation.Util
                                        foreach (string filepath in Directory.GetFiles(folderPath)) {\r
                                                if (baseFolderPath != folderPath) return; // 途中でなんか操作されているならば終了\r
                                                \r
-                                               _insertItemFor(filepath, ref cmdIsAdded);\r
+                                               _insertItemFor(filepath, ref cmdIsAdded, folderPath);\r
+                                       }\r
+                                       \r
+                                       string bindir = Path.Combine(folderPath, "bin");\r
+                                       if (Directory.Exists(bindir)) {\r
+                                               foreach (string filepath in Directory.GetFiles(bindir)) {\r
+                                                       if (baseFolderPath != folderPath) return; // 途中でなんか操作されているならば終了\r
+                                                       \r
+                                                       _insertItemFor(filepath, ref cmdIsAdded, folderPath);\r
+                                               }\r
                                        }\r
                                }\r
                        } catch (ThreadInterruptedException) {}\r
@@ -126,15 +140,15 @@ namespace AppliStation.Util
                #endregion\r
                \r
                /// <summary>\r
-               /// 与えられたフォルダを開くメニューアイテムを生成する\r
+               /// ä¸\8eã\81\88ã\82\89ã\82\8cã\81\9fã\83\95ã\82©ã\83«ã\83\80ã\83¼ã\82\92é\96\8bã\81\8fã\83¡ã\83\8bã\83¥ã\83¼ã\82¢ã\82¤ã\83\86ã\83 ã\82\92ç\94\9fæ\88\90ã\81\99ã\82\8b\r
                /// </summary>\r
                /// <param name="folderPath"></param>\r
                /// <returns></returns>\r
-               public static ToolStripMenuItem CreateMenuItemForFolder(string folderPath)\r
+               private static ToolStripMenuItem CreateMenuItemForFolder(string folderPath)\r
                {\r
-                       ToolStripMenuItem item = CreateMenuItemForFile(folderPath);\r
-                       item.Image = GUIUtils.GetShellIconForFolder().ToBitmap();\r
-                       item.Text = "フォルダを開く(&O)";\r
+                       ToolStripMenuItem item = CreateMenuItemForFile(folderPath, "フォルダーを開く(&O)");\r
+                       item.Image = GUIUtils.ShellIconForFolder.ToBitmap();\r
+                       item.ShowShortcutKeys = true;\r
                        return item;\r
                }\r
 \r
@@ -143,12 +157,11 @@ namespace AppliStation.Util
                /// </summary>\r
                /// <param name="filePath">ファイルパス</param>\r
                /// <returns>生成されたメニューアイテム</returns>\r
-               public static ToolStripMenuItem CreateMenuItemForFile(string filePath)\r
+               private static ToolStripMenuItem CreateMenuItemForFile(string filePath, string text)\r
                {\r
                        ToolStripMenuItem item = new ToolStripMenuItem();\r
-                       string fileName = Path.GetFileName(filePath);\r
                        \r
-                       item.Text = fileName;\r
+                       item.Text = text;\r
                        item.ShowShortcutKeys = false;\r
                        item.Tag = filePath;\r
                        item.Click += new System.EventHandler(menuItemForFileClicked);\r
@@ -158,7 +171,7 @@ namespace AppliStation.Util
                                \r
                                StringBuilder sb = new StringBuilder();\r
                                sb.AppendFormat("場所: {0}", Path.GetDirectoryName(filePath));\r
-                               try {\r
+                               if (File.Exists(filePath)) {\r
                                        FileVersionInfo vInfo = FileVersionInfo.GetVersionInfo(filePath);\r
                                        \r
                                        if (! string.IsNullOrEmpty(vInfo.FileDescription))\r
@@ -167,7 +180,7 @@ namespace AppliStation.Util
                                                sb.AppendFormat("\r\n会社: {0}", vInfo.CompanyName);\r
                                        if (! string.IsNullOrEmpty(vInfo.FileVersion))\r
                                                sb.AppendFormat("\r\nファイルバージョン: {0}", vInfo.FileVersion);\r
-                               } catch (Exception) {}\r
+                               }\r
                                item.ToolTipText = sb.ToString();\r
                        } else {\r
                                item.ToolTipText = filePath;\r
@@ -195,11 +208,11 @@ namespace AppliStation.Util
                }\r
                \r
                /// <summary>\r
-               /// 与えられたフォルダのところでコマンドプロンプトを開く。\r
+               /// ä¸\8eã\81\88ã\82\89ã\82\8cã\81\9fã\83\95ã\82©ã\83«ã\83\80ã\83¼ã\81®ã\81¨ã\81\93ã\82\8dã\81§ã\82³ã\83\9eã\83³ã\83\89ã\83\97ã\83­ã\83³ã\83\97ã\83\88ã\82\92é\96\8bã\81\8fã\80\82\r
                /// </summary>\r
-               /// <param name="folderPath">カレントフォルダ及びパスに追加されるフォルダ</param>\r
+               /// <param name="folderPath">カレントフォルダー及びパスに追加されるフォルダー</param>\r
                /// <returns>生成されたメニューアイテム</returns>\r
-               public static ToolStripMenuItem CreateMenuItemForCmdAt(string folderPath)\r
+               private static ToolStripMenuItem CreateMenuItemForCmdAt(string folderPath)\r
                {\r
                        string cmdPath = Environment.GetEnvironmentVariable("comspec");\r
                        if (string.IsNullOrEmpty(cmdPath) || (!File.Exists(cmdPath)))\r