From af341a08d49951ad1e7e70c31413c113b81dc22d Mon Sep 17 00:00:00 2001 From: ttp Date: Sun, 11 May 2008 02:46:37 +0000 Subject: [PATCH] =?utf8?q?AppliStation-GUI,=E3=82=A4=E3=83=B3=E3=82=B9?= =?utf8?q?=E3=82=B3=E3=83=BB=E3=82=A2=E3=83=B3=E3=82=A4=E3=83=B3=E3=82=B9?= =?utf8?q?=E3=82=B3=E6=99=82=E3=81=8B=E3=81=A4=E3=80=8C=E7=AE=A1=E7=90=86?= =?utf8?q?=E8=80=85=E3=81=A8=E3=81=97=E3=81=A6=E5=AE=9F=E8=A1=8C=E6=99=82?= =?utf8?q?=E3=80=8D=E3=81=AB=E8=A6=AA=E3=83=95=E3=83=AC=E3=83=BC=E3=83=A0?= =?utf8?q?=E3=81=AE=E8=A1=A8=E7=A4=BA=E3=81=8C=E3=83=95=E3=83=AA=E3=83=BC?= =?utf8?q?=E3=82=BA=E3=81=99=E3=82=8B=E5=95=8F=E9=A1=8C=E3=82=92=E4=BF=AE?= =?utf8?q?=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit git-svn-id: http://localhost/svn/AppliStation/trunk@905 34ed2c89-c49f-4a4b-abdb-c318350108cf --- AppliStation/AppliStation.Util/NativeMethods.cs | 29 +++++++++++++++ AppliStation/PackageListViewForm.cs | 49 +++++++++++++++++-------- 2 files changed, 63 insertions(+), 15 deletions(-) diff --git a/AppliStation/AppliStation.Util/NativeMethods.cs b/AppliStation/AppliStation.Util/NativeMethods.cs index f739712..8f091db 100644 --- a/AppliStation/AppliStation.Util/NativeMethods.cs +++ b/AppliStation/AppliStation.Util/NativeMethods.cs @@ -157,6 +157,35 @@ namespace AppliStation.Util #endregion + #region EnableWindow(ƒRƒƒ“ƒgƒAƒEƒg) +// /// +// /// Žw’肳‚ꂽƒRƒ“ƒgƒ[ƒ‹(ƒEƒBƒ“ƒhƒE)‚ւ́A +// /// ƒL[ƒ{[ƒh“ü—Í‚¨‚æ‚у}ƒEƒX“ü—Í‚ð—LŒø‰»‚Ü‚½‚Í–³Œø‰» +// /// +// /// ‘Ώۂ̃Rƒ“ƒgƒ[ƒ‹‚̃nƒ“ƒhƒ‰ +// /// —LŒø‚É‚·‚é‚©–³Œø‚É‚·‚é‚©‚ðŽw’è +// /// ’¼‘O‚ɃEƒBƒ“ƒhƒE‚ª–³Œøó‘Ô‚¾‚Á‚½ê‡‚Ítrue‚ð•Ô‚· +// public static bool Control_EnableWindow(Control ctrl, bool bEnable) +// { +// try { +// return EnableWindow(ctrl.Handle, bEnable); +// } catch { +// ctrl.Enabled = bEnable; +// return true; +// } +// } +// +// /// +// /// Žw’肳‚ꂽƒRƒ“ƒgƒ[ƒ‹(ƒEƒBƒ“ƒhƒE)‚ւ́A +// /// ƒL[ƒ{[ƒh“ü—Í‚¨‚æ‚у}ƒEƒX“ü—Í‚ð—LŒø‰»‚Ü‚½‚Í–³Œø‰» +// /// +// /// ‘Ώۂ̃Rƒ“ƒgƒ[ƒ‹‚̃nƒ“ƒhƒ‰ +// /// —LŒø‚É‚·‚é‚©–³Œø‚É‚·‚é‚©‚ðŽw’è +// /// ’¼‘O‚ɃEƒBƒ“ƒhƒE‚ª–³Œøó‘Ô‚¾‚Á‚½ê‡‚Ítrue‚ð•Ô‚· +// [DllImport("user32.dll")] +// public static extern bool EnableWindow(IntPtr hWnd, bool bEnable); + #endregion + [DllImport("user32.dll", CharSet=CharSet.Auto)] internal static extern IntPtr SendMessage( IntPtr hWnd, UInt32 Msg, UInt32 wParam, UInt32 lParam); diff --git a/AppliStation/PackageListViewForm.cs b/AppliStation/PackageListViewForm.cs index c67ff5b..a2ac143 100644 --- a/AppliStation/PackageListViewForm.cs +++ b/AppliStation/PackageListViewForm.cs @@ -352,10 +352,7 @@ namespace AppliStation Package[] instPkgs = confirm.CheckedPackages; if (confirm.UseRunas) { - this.Enabled = false; installRunasActionInvoke(instPkgs); - this.Enabled = true; - this.Focus(); } else { installActionInvoke(instPkgs); } @@ -366,6 +363,8 @@ namespace AppliStation public void installRunasActionInvoke(Package[] pkgs) { + this.Enabled = false; + string tmpfileName = System.IO.Path.GetTempFileName(); try { NaGet.Utils.PutSerializeObject(tmpfileName, pkgs); @@ -376,17 +375,26 @@ namespace AppliStation procInfo.Verb = "runas"; procInfo.WorkingDirectory = Environment.CurrentDirectory; - using (System.Diagnostics.Process hProc = System.Diagnostics.Process.Start(procInfo)) { - hProc.WaitForExit(); - } - - pkgListsMan.LoadPackageLists(); + System.Diagnostics.Process hProc = System.Diagnostics.Process.Start(procInfo); + hProc.EnableRaisingEvents = true; + hProc.SynchronizingObject = this; + hProc.Exited += delegate(object sender, EventArgs e) { + pkgListsMan.LoadPackageLists(); + + this.Enabled = true; + this.BringToFront(); + + if (File.Exists(tmpfileName)) { + File.Delete(tmpfileName); + } + }; } catch (System.ComponentModel.Win32Exception ex) { MessageBox.Show(ex.Message, "ƒCƒ“ƒXƒg[ƒ‹", MessageBoxButtons.OK, MessageBoxIcon.Error); - } finally { + if (File.Exists(tmpfileName)) { File.Delete(tmpfileName); } + this.Enabled = true; } } @@ -405,6 +413,8 @@ namespace AppliStation internal void uninstallRunasActionInvoke(InstalledPackage[] pkgs) { + this.Enabled = false; + string tmpfileName = System.IO.Path.GetTempFileName(); try { NaGet.Utils.PutSerializeObject(tmpfileName, pkgs); @@ -415,17 +425,26 @@ namespace AppliStation procInfo.Verb = "runas"; procInfo.WorkingDirectory = Environment.CurrentDirectory; - using (System.Diagnostics.Process hProc = System.Diagnostics.Process.Start(procInfo)) { - hProc.WaitForExit(); - } - - pkgListsMan.LoadPackageLists(); + System.Diagnostics.Process hProc = System.Diagnostics.Process.Start(procInfo); + hProc.EnableRaisingEvents = true; + hProc.SynchronizingObject = this; + hProc.Exited += delegate(object sender, EventArgs e) { + pkgListsMan.LoadPackageLists(); + + this.Enabled = true; + this.BringToFront(); + + if (File.Exists(tmpfileName)) { + File.Delete(tmpfileName); + } + }; } catch (System.ComponentModel.Win32Exception ex) { MessageBox.Show(ex.Message, "ƒAƒ“ƒCƒ“ƒXƒg[ƒ‹", MessageBoxButtons.OK, MessageBoxIcon.Error); - } finally { + if (File.Exists(tmpfileName)) { File.Delete(tmpfileName); } + this.Enabled = true; } } -- 2.11.0