-using System;\r
+using System;\r
using System.Collections.Generic;\r
using System.Windows.Forms;\r
using System.IO;\r
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
hideSplashScreen();\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
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
\r
+ void RunUpdateAppliStation()\r
+ {\r
+ System.Threading.Thread.Sleep(5000); /* 5sec待って呼び出しもとの終了を待つ */\r
+ \r
+ string newAppliStationDir = Application.StartupPath;\r
+ string targetDir = Environment.CurrentDirectory;\r
+ foreach (string file in Directory.GetFiles(newAppliStationDir)) {\r
+ string ext = Path.GetExtension(file).ToLower();\r
+ if ((ext == ".exe") || (ext == ".dll") ||\r
+ (ext == ".pdb") || (ext == ".png")) {\r
+ File.Copy(file, Path.Combine(targetDir, Path.GetFileName(file)), true);\r
+ }\r
+ }\r
+MessageBox.Show("Installation is completed.");\r
+ System.Threading.Thread.Sleep(10);\r
+ System.Diagnostics.Process.Start(Path.Combine(targetDir, Path.GetFileName(Application.ExecutablePath)));\r
+ hideSplashScreen();\r
+ //Application.Exit(); // Do nothing = exit\r
+ }\r
+ \r
+ /// <summary>\r
+ /// AppliStationの自己更新を行う。アーカイブインストーラによってあらかじめインストールされたファイルを、\r
+ /// カレントディレクトリにコピーするよう新しいAppliStation.exeを呼ぶ。\r
+ /// コピー元がないまたはそれが新しくないならば何もしない。\r
+ /// </summary>\r
+ /// <returns>更新をしたときtrueをかえす。</returns>\r
+ private bool autoUpdateAppliStation()\r
+ {\r
+ if (string.IsNullOrEmpty(appArgs["cmd"].ToString())) {\r
+ string newAppliStationDir = Path.Combine(NaGet.Env.ArchiveProgramFiles, "AppliStation");\r
+ string thisAppliStation = Application.ExecutablePath;\r
+ \r
+ if (Directory.Exists(newAppliStationDir)) {\r
+ string newAppliStation = Path.Combine(newAppliStationDir, Path.GetFileName(thisAppliStation));\r
+ \r
+MessageBox.Show(string.Format("{0}\r\n{1}", newAppliStation, File.Exists(newAppliStation)));\r
+MessageBox.Show(string.Format("{0}\r\n{1}", File.GetLastWriteTime(thisAppliStation), File.GetLastWriteTime(newAppliStation)));\r
+MessageBox.Show(string.Format("{0}", File.GetLastWriteTime(thisAppliStation) < File.GetLastWriteTime(newAppliStation)));\r
+ \r
+ if ( File.Exists(newAppliStation) &&\r
+ (File.GetLastWriteTime(thisAppliStation) < File.GetLastWriteTime(newAppliStation)) ) {\r
+\r
+ System.Diagnostics.Process.Start(newAppliStation, "--cmd=updateAppliStation");\r
+ return true;\r
+ }\r
+ }\r
+ }\r
+ return false;\r
+ }\r
+ \r
private void hideSplashScreen()\r
{\r
if (splashScreen != null && splashScreen.Visible) {\r
try {\r
parseArgs(args);\r
} catch (ApplicationException e) {\r
- MessageBox.Show(e.Message, "AppliStation \8bN\93®\88ø\90\94\83G\83\89\81[", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+ MessageBox.Show(e.Message, "AppliStation 起動引数エラー", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
+ return;\r
+ }\r
+ \r
+ // cmd引数がないときに更新処理を試みる。\r
+ // cmd引数があるときに更新しないのは、AppliStationから「管理者で実行」などで呼び出された場合に\r
+ // 更新処理にならないようにするため。\r
+ if ( string.IsNullOrEmpty((string) appArgs["cmd"]) &&\r
+ autoUpdateAppliStation() ) {\r
+ // アップデートしたときは起動しない\r
return;\r
}\r
\r
+ \r
switch ((string) appArgs["cmd"]) {\r
case "install":\r
RunInstall();\r
case "uninstall":\r
RunUninstall();\r
break;\r
+ case "updateAppliStation":\r
+ RunUpdateAppliStation();\r
+ break;\r
default:\r
RunNormal();\r
break;\r
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
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