2 using System.Collections.Generic;
\r
3 using System.Windows.Forms;
\r
6 namespace AppliStation
\r
12 PackageListViewForm form;
\r
17 Dictionary<string, object> appArgs;
\r
19 string[] restAppArgs;
\r
23 appArgs = new Dictionary<string, object>();
\r
24 appArgs["noupdate"] = false;
\r
25 appArgs["cmd"] = string.Empty;
\r
26 appArgs["pkgsref"] = string.Empty;
\r
27 appArgs["instsref"] = string.Empty;
\r
29 form = new PackageListViewForm();
\r
34 form.Load += delegate(object sender, EventArgs e) {
\r
36 form.updateActionInvoke(((bool)appArgs["noupdate"]) != true);
\r
38 form.UpdatePackageList();
\r
40 Application.Run(form);
\r
46 NaGet.Packages.Install.Installation[] insts = NaGet.Utils.GetDeserializedObject<NaGet.Packages.Install.Installation[]>((string) appArgs["instsref"]);
\r
49 form.installActionInvoke(insts);
\r
50 } catch (UnauthorizedAccessException e) {
\r
51 MessageBox.Show(string.Format("管理者権限に昇格していないか、実行権限に問題があります。\n(詳細:{0})", e.Message),
\r
52 Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
\r
53 } catch (FileNotFoundException e) {
\r
54 MessageBox.Show(string.Format("ソフト指定ファイル{0}が見つかりません", e.FileName),
\r
55 Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
\r
62 NaGet.Packages.Install.InstalledPackage[] pkgs = NaGet.Utils.GetDeserializedObject<NaGet.Packages.Install.InstalledPackage[]>((string) appArgs["pkgsref"]);
\r
65 form.uninstallActionInvoke(pkgs);
\r
66 } catch (UnauthorizedAccessException e) {
\r
67 MessageBox.Show(string.Format("管理者権限に昇格していないか、実行権限に問題があります。\n(詳細:{0})", e.Message),
\r
68 Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
\r
69 } catch (FileNotFoundException e) {
\r
70 MessageBox.Show(string.Format("ソフト指定ファイル{0}が見つかりません", e.FileName),
\r
71 Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Error);
\r
75 private void hideSplashScreen()
\r
77 if (splashScreen != null && splashScreen.Visible) {
\r
78 splashScreen.Hide();
\r
79 splashScreen.Dispose();
\r
83 public void Run(string[] args)
\r
87 } catch (ApplicationException e) {
\r
88 MessageBox.Show(e.Message, "AppliStation 起動引数エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);
\r
92 switch ((string) appArgs["cmd"]) {
\r
105 private void parseArgs(string[] args)
\r
107 NaGet.ArgParser parser = new NaGet.ArgParser(appArgs);
\r
108 restAppArgs = parser.Parse(args);
\r
112 public static void Main(string[] args)
\r
114 Form splashScreen = null;
\r
117 if (args.Length <= 0) { // HACK 引数パースの時間さえ待てないので引数の有無で表示を判断
\r
118 splashScreen = new Form();
\r
119 splashScreen.FormBorderStyle = FormBorderStyle.None;
\r
120 splashScreen.BackgroundImage = System.Drawing.Bitmap.FromFile(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "SplashScreen.png"));
\r
121 splashScreen.Size = splashScreen.BackgroundImage.Size;
\r
122 splashScreen.ShowIcon = false;
\r
123 splashScreen.ShowInTaskbar = false;
\r
124 splashScreen.StartPosition = FormStartPosition.CenterScreen;
\r
125 splashScreen.Show();
\r
128 // アーカイブSYSTEM32をパスに足す
\r
129 NaGet.Utils.AddDirectoryToPath(NaGet.Env.ArchiveSystem32);
\r
131 ToolStripManager.VisualStylesEnabled = false; // ToolStripがLunaで青くならないように
\r
132 Application.EnableVisualStyles(); // LunaやVistaのデザインを有効に
\r
134 Application.ThreadException += AppliStation.Util.ExceptionDialogForm.Application_ThrowException;
\r
135 System.Threading.Thread.GetDomain().UnhandledException += AppliStation.Util.ExceptionDialogForm.Application_ThrowException;
\r
137 Program prog = new Program();
\r
138 prog.splashScreen = splashScreen;
\r
140 } catch (Exception e) {
\r
141 AppliStation.Util.ExceptionDialogForm.Application_ThrowException(null, new System.Threading.ThreadExceptionEventArgs(e));
\r
143 if (splashScreen != null) {
\r
144 splashScreen.Dispose();
\r