diff --git a/etc/utils/win32/post-install-helper/post-install-launcher.ico b/etc/utils/win32/post-install-helper/post-install-launcher.ico index 65990a5..df23e92 100644 Binary files a/etc/utils/win32/post-install-helper/post-install-launcher.ico and b/etc/utils/win32/post-install-helper/post-install-launcher.ico differ diff --git a/etc/utils/win32/post-install-helper/post-install-launcher.nsi b/etc/utils/win32/post-install-helper/post-install-launcher.nsi index 1a10ddf..dc3b293 100644 --- a/etc/utils/win32/post-install-helper/post-install-launcher.nsi +++ b/etc/utils/win32/post-install-helper/post-install-launcher.nsi @@ -26,7 +26,9 @@ SubCaption 4 " " Sleep 333 !macroend -Section "" +Section + BringToFront # Just to be sure! + !insertmacro PrintStatusMessage "Detecting operating system, please wait..." ${IfNot} ${AtLeastBuild} 7601 MessageBox MB_ICONSTOP|MB_TOPMOST "This application runs on Windows 7 (SP1) or later!" @@ -40,7 +42,7 @@ Section "" ReadRegDWORD $0 HKLM 'SOFTWARE\WOW6432Node\Microsoft\NET Framework Setup\NDP\v4\Full' 'Release' ${IfNot} ${Errors} DetailPrint "Installed release: $0" - ${IfThen} $0 >= 528040 ${|} Goto launch_application ${|} + ${IfThen} $0 >= 461808 ${|} Goto launch_application ${|} ${Else} DetailPrint ".NET Framework not found!" ${Endif} diff --git a/gui/SlunkCryptGUI.csproj b/gui/SlunkCryptGUI.csproj index 11c5a71..a027dc6 100644 --- a/gui/SlunkCryptGUI.csproj +++ b/gui/SlunkCryptGUI.csproj @@ -96,6 +96,7 @@ + Designer MSBuild:Compile diff --git a/gui/SlunkCryptGUI.xaml.cs b/gui/SlunkCryptGUI.xaml.cs index fb9f1fb..6ebf734 100644 --- a/gui/SlunkCryptGUI.xaml.cs +++ b/gui/SlunkCryptGUI.xaml.cs @@ -3,6 +3,7 @@ /* This work has been released under the CC0 1.0 Universal license! */ /******************************************************************************/ +using Microsoft.Win32; using System; using System.Collections.ObjectModel; using System.ComponentModel; @@ -19,7 +20,6 @@ using System.Windows.Media; using System.Windows.Media.Effects; using System.Windows.Shell; using System.Windows.Threading; -using Microsoft.Win32; using com.muldersoft.slunkcrypt.gui.ctrls; using com.muldersoft.slunkcrypt.gui.process; @@ -114,6 +114,7 @@ namespace com.muldersoft.slunkcrypt.gui TabControl.MinHeight = TabControl.MaxHeight = TabControl.ActualHeight; MinWidth = MaxWidth = ActualWidth; MinHeight = MaxHeight = ActualHeight; + this.BringWindowToTop(); } private void Button_Encrypt_InputFile_Click(object sender, RoutedEventArgs e) diff --git a/gui/Utilities/WindowHelper.cs b/gui/Utilities/WindowHelper.cs new file mode 100644 index 0000000..69ae61d --- /dev/null +++ b/gui/Utilities/WindowHelper.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Interop; + +namespace com.muldersoft.slunkcrypt.gui.utils +{ + public static class WindowHelper + { + private static readonly IEnumerable enableTopmost = Array.AsReadOnly(new bool[] { true, false }); + + public static void BringWindowToTop(this Window window) + { + if (!ReferenceEquals(window, null)) + { + try + { + WindowInteropHelper interopHelper = new WindowInteropHelper(window); + NativeMethods.BringWindowToTop(interopHelper.Handle); + if (!NativeMethods.SetForegroundWindow(interopHelper.Handle)) + { + foreach (bool flag in enableTopmost) + { + window.Topmost = flag; + } + } + } + catch { } + } + } + + private static class NativeMethods + { + [DllImport("user32.dll", SetLastError = true)] + public static extern bool BringWindowToTop(IntPtr hWnd); + + [DllImport("user32.dll", SetLastError = true)] + public static extern bool SetForegroundWindow(IntPtr hWnd); + } + } +}