OSDN Git Service

na-get-lib,ひとまず依存関係解決関数群を作った。
[applistation/AppliStation.git] / AppliStation / Program.cs
index 9b16164..381deae 100644 (file)
@@ -1,4 +1,4 @@
-using System;\r
+using System;\r
 using System.Collections.Generic;\r
 using System.Windows.Forms;\r
 using System.IO;\r
@@ -12,7 +12,7 @@ namespace AppliStation
                PackageListViewForm form;\r
                \r
                /// <summary>\r
-               /// \83A\83v\83\8a\83P\81[\83V\83\87\83\93\82Ì\83I\83v\83V\83\87\83\93\r
+               /// アプリケーションのオプション\r
                /// </summary>\r
                Dictionary<string, object> appArgs;\r
                \r
@@ -24,6 +24,7 @@ namespace AppliStation
                        appArgs["noupdate"] = false;\r
                        appArgs["cmd"] = string.Empty;\r
                        appArgs["pkgsref"] = string.Empty;\r
+                       appArgs["instsref"] = string.Empty;\r
                        \r
                        form = new PackageListViewForm();\r
                }\r
@@ -42,15 +43,15 @@ namespace AppliStation
                void RunInstall()\r
                {\r
                        try {\r
-                               NaGet.Packages.Package[] pkgs = NaGet.Utils.GetDeserializedObject<NaGet.Packages.Package[]>((string) appArgs["pkgsref"]);\r
+                               NaGet.Packages.Install.Installation[] insts = NaGet.Utils.GetDeserializedObject<NaGet.Packages.Install.Installation[]>((string) appArgs["instsref"]);\r
                                \r
                                hideSplashScreen();\r
-                               form.installActionInvoke(pkgs);\r
+                               form.installActionInvoke(insts);\r
                        } catch (UnauthorizedAccessException e) {\r
-                               MessageBox.Show(string.Format("\8aÇ\97\9d\8eÒ\8c \8cÀ\82É\8f¸\8ai\82µ\82Ä\82¢\82È\82¢\82©\81A\8eÀ\8ds\8c \8cÀ\82É\96â\91è\82ª\82 \82è\82Ü\82·\81B\n(\8fÚ\8d×:{0})", e.Message),\r
+                               MessageBox.Show(string.Format("管理者権限に昇格していないか、実行権限に問題があります。\n(詳細:{0})", e.Message),\r
                                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);\r
                        } catch (FileNotFoundException e) {\r
-                               MessageBox.Show(string.Format("\83\\83t\83g\8ew\92è\83t\83@\83C\83\8b{0}\82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ", e.FileName),\r
+                               MessageBox.Show(string.Format("ソフト指定ファイル{0}が見つかりません", e.FileName),\r
                                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);\r
                        }\r
                }\r
@@ -63,10 +64,10 @@ namespace AppliStation
                                hideSplashScreen();\r
                                form.uninstallActionInvoke(pkgs);\r
                        } catch (UnauthorizedAccessException e) {\r
-                               MessageBox.Show(string.Format("\8aÇ\97\9d\8eÒ\8c \8cÀ\82É\8f¸\8ai\82µ\82Ä\82¢\82È\82¢\82©\81A\8eÀ\8ds\8c \8cÀ\82É\96â\91è\82ª\82 \82è\82Ü\82·\81B\n(\8fÚ\8d×:{0})", e.Message),\r
+                               MessageBox.Show(string.Format("管理者権限に昇格していないか、実行権限に問題があります。\n(詳細:{0})", e.Message),\r
                                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);\r
                        } catch (FileNotFoundException e) {\r
-                               MessageBox.Show(string.Format("\83\\83t\83g\8ew\92è\83t\83@\83C\83\8b{0}\82ª\8c©\82Â\82©\82è\82Ü\82¹\82ñ", e.FileName),\r
+                               MessageBox.Show(string.Format("ソフト指定ファイル{0}が見つかりません", e.FileName),\r
                                                Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);\r
                        }\r
                }\r
@@ -81,7 +82,12 @@ namespace AppliStation
                \r
                public void Run(string[] args)\r
                {\r
-                       parseArgs(args);\r
+                       try {\r
+                               parseArgs(args);\r
+                       } catch (ApplicationException e) {\r
+                               MessageBox.Show(e.Message, "AppliStation 起動引数エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+                               return;\r
+                       }\r
                        \r
                        switch ((string) appArgs["cmd"]) {\r
                                case "install":\r
@@ -98,7 +104,7 @@ namespace AppliStation
                \r
                private void parseArgs(string[] args)\r
                {\r
-                       ArgParse parser = new ArgParse(appArgs);\r
+                       NaGet.ArgParser parser = new NaGet.ArgParser(appArgs);\r
                        restAppArgs = parser.Parse(args);\r
                }\r
                \r
@@ -108,7 +114,7 @@ namespace AppliStation
                        Form splashScreen = null;\r
                        \r
                        try {\r
-                               if (args.Length <= 0) { // HACK \88ø\90\94\83p\81[\83X\82Ì\8e\9e\8aÔ\82³\82¦\91Ò\82Ä\82È\82¢\82Ì\82Å\88ø\90\94\82Ì\97L\96³\82Å\95\\8e¦\82ð\94»\92f\r
+                               if (args.Length <= 0) { // HACK 引数パースの時間さえ待てないので引数の有無で表示を判断\r
                                        splashScreen = new Form();\r
                                        splashScreen.FormBorderStyle = FormBorderStyle.None;\r
                                        splashScreen.BackgroundImage = System.Drawing.Bitmap.FromFile(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "SplashScreen.png"));\r
@@ -119,8 +125,11 @@ namespace AppliStation
                                        splashScreen.Show();\r
                                }\r
                                \r
-                               ToolStripManager.VisualStylesEnabled = false; // ToolStrip\82ªLuna\82Å\90Â\82­\82È\82ç\82È\82¢\82æ\82¤\82É\r
-                               Application.EnableVisualStyles(); // Luna\82âVista\82Ì\83f\83U\83C\83\93\82ð\97L\8cø\82É\r
+                               // アーカイブSYSTEM32をパスに足す\r
+                               NaGet.Utils.AddDirectoryToPath(NaGet.Env.ArchiveSystem32);\r
+                               \r
+                               ToolStripManager.VisualStylesEnabled = false; // ToolStripがLunaで青くならないように\r
+                               Application.EnableVisualStyles(); // LunaやVistaのデザインを有効に\r
                                \r
                                Application.ThreadException += AppliStation.Util.ExceptionDialogForm.Application_ThrowException;\r
                                System.Threading.Thread.GetDomain().UnhandledException += AppliStation.Util.ExceptionDialogForm.Application_ThrowException;\r