diff --git a/README.md b/README.md index 5a090e8..fe7df32 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ The SlunkCrypt library and the command-line application currently run on the fol The SlunkCrypt GUI application currently runs on the following platforms: -* **Microsoft Windows** with .NET Framework 4.5 — can be installed on Windows Vista, or later +* **Microsoft Windows** with .NET Framework 4.7.2 — can be installed on Windows 7 SP1, or later GUI Usage @@ -45,10 +45,10 @@ This is how the graphical user interface (GUI) for SlunkCrypt looks on [Windows Prerequisites ------------- -Please be sure to install the **.NET Framework 4.5**, or any later *.NET Framework 4.x* version, before running the SlunkCrypt GUI application: +Please be sure to install the **.NET Framework 4.7.2**, or any later *.NET Framework 4.x* version, before running the SlunkCrypt **Windows GUI** application: -***Note:*** If you are running Windows 8 or later, then almost certainly a suitable version of the .NET Framework is already installed 😎 +***Note:*** If you are running Windows 8.1 or later, then almost certainly a suitable version of the .NET Framework is already installed 😎 Settings -------- 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 dc3b293..251ac3d 100644 --- a/etc/utils/win32/post-install-helper/post-install-launcher.nsi +++ b/etc/utils/win32/post-install-helper/post-install-launcher.nsi @@ -47,14 +47,10 @@ Section DetailPrint ".NET Framework not found!" ${Endif} - !insertmacro PrintStatusMessage "Installing .NET Framework 4.8, please wait..." + !insertmacro PrintStatusMessage "Installing .NET Framework 4.7.2, please wait..." ${Do} ClearErrors - ${If} ${AtLeastBuild} 19042 - ExecShellWait /ALLOWERRORUI "runas" "$EXEDIR\ndp481-web.exe" /passive - ${Else} - ExecShellWait /ALLOWERRORUI "runas" "$EXEDIR\ndp48-web.exe" /passive - ${EndIf} + ExecShellWait /ALLOWERRORUI "open" "$EXEDIR\ndp472-kb4054531-web.exe" /passive ${IfNot} ${Errors} ${OrIf} ${Cmd} `MessageBox MB_ICONEXCLAMATION|MB_RETRYCANCEL|MB_TOPMOST "Failed to launch .NET Framework installer!" IDCANCEL` ${ExitDo} diff --git a/gui/App.config b/gui/App.config index 4e4ea08..1ede395 100644 --- a/gui/App.config +++ b/gui/App.config @@ -1,11 +1,12 @@ - + + diff --git a/gui/SlunkCryptGUI.csproj b/gui/SlunkCryptGUI.csproj index a027dc6..0fafc39 100644 --- a/gui/SlunkCryptGUI.csproj +++ b/gui/SlunkCryptGUI.csproj @@ -9,7 +9,7 @@ Properties com.muldersoft.slunkcrypt.gui slunkcrypt-gui - v4.5.2 + v4.7.2 512 {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 4 diff --git a/gui/SlunkCryptGUI.xaml b/gui/SlunkCryptGUI.xaml index 206ff1d..22a2280 100644 --- a/gui/SlunkCryptGUI.xaml +++ b/gui/SlunkCryptGUI.xaml @@ -11,12 +11,15 @@ Icon="pack://application:,,,/slunkcrypt-gui;component/Resources/Application.ico" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen" - ResizeMode="NoResize" + ResizeMode="CanMinimize" WindowStyle="ThreeDBorderWindow" UseLayoutRounding="True" AllowDrop="True" - Loaded="Window_Loaded" Closing="Window_Closing" - PreviewDragEnter="Window_PreviewDragEnter" PreviewDragOver="Window_PreviewDragEnter" PreviewDragLeave="Window_PreviewDragLeave" PreviewDrop="Window_PreviewDrop" + Closing="Window_Closing" + PreviewDragEnter="Window_PreviewDragEnter" + PreviewDragOver="Window_PreviewDragEnter" + PreviewDragLeave="Window_PreviewDragLeave" + PreviewDrop="Window_PreviewDrop" PreviewKeyDown="Window_PreviewKeyDown"> @@ -43,9 +46,9 @@ - + - + diff --git a/gui/SlunkCryptGUI.xaml.cs b/gui/SlunkCryptGUI.xaml.cs index 6ebf734..b12158a 100644 --- a/gui/SlunkCryptGUI.xaml.cs +++ b/gui/SlunkCryptGUI.xaml.cs @@ -12,6 +12,7 @@ using System.Globalization; using System.IO; using System.Media; using System.Text; +using System.Threading; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; @@ -45,6 +46,7 @@ namespace com.muldersoft.slunkcrypt.gui private readonly DispatcherTimer m_dispatcherTimer; private readonly ReadOnlyObservableCollection m_logFileReadOnly; + private volatile int m_isInitialized = 0; private volatile ModeOfOperation m_modeOfOperation = (ModeOfOperation)(-1); private volatile bool m_busyFlag = false, m_checksumError = false, m_processReceived = false, m_disableAnimation = false; private volatile SlunkCryptRunner m_processRunner = null; @@ -62,7 +64,7 @@ namespace com.muldersoft.slunkcrypt.gui m_defaultStatusText = Label_Status.Text; m_dispatcherTimer = new DispatcherTimer(DispatcherPriority.ApplicationIdle, Dispatcher); m_dispatcherTimer.Tick += DispatcherTimer_Tick; - m_dispatcherTimer.Interval = TimeSpan.FromMilliseconds(200); + m_dispatcherTimer.Interval = TimeSpan.FromMilliseconds(331); m_logFileReadOnly = new ReadOnlyObservableCollection(m_logFile); m_disableAnimation = m_config.DisableBusyIndicator; } @@ -111,10 +113,20 @@ namespace com.muldersoft.slunkcrypt.gui protected override void OnContentRendered(EventArgs e) { base.OnContentRendered(e); - TabControl.MinHeight = TabControl.MaxHeight = TabControl.ActualHeight; - MinWidth = MaxWidth = ActualWidth; - MinHeight = MaxHeight = ActualHeight; - this.BringWindowToTop(); + if (Interlocked.CompareExchange(ref m_isInitialized, 1, 0) == 0) + { + TabControl.MinHeight = TabControl.MaxHeight = TabControl.ActualHeight; + MinWidth = ActualWidth; + MinHeight = MaxHeight = ActualHeight; + CreateIndicatorElements(); + CreateSystemMenu(); + if (m_config.LegacyCompat) + { + Checkbox_Encrypt_LegacyCompat.IsChecked = Checkbox_Decrypt_LegacyCompat.IsChecked = true; + } + this.EnableResize(true); + this.BringWindowToTop(); + } } private void Button_Encrypt_InputFile_Click(object sender, RoutedEventArgs e) @@ -372,19 +384,6 @@ namespace com.muldersoft.slunkcrypt.gui e.Handled = true; } - private async void Window_Loaded(object sender, RoutedEventArgs e) - { - await Task.Yield(); - SystemMenu systemMenu = new SystemMenu(this, SystemMenu_Activated); - m_menuId_disableAnimation = systemMenu.AppendMenu("Disable Busy Indicator"); - m_menuId_enableExpertMode = systemMenu.AppendMenu("Expert Settings"); - if (m_disableAnimation && m_menuId_disableAnimation.HasValue) - { - systemMenu.ModifyMenu(m_menuId_disableAnimation.Value, m_disableAnimation); - } - CreateIndicatorElements(); - } - private void Window_Closing(object sender, CancelEventArgs e) { if (IsBusy) @@ -544,7 +543,7 @@ namespace com.muldersoft.slunkcrypt.gui return; } } - if (enableLegacyCompat) + if (enableLegacyCompat && (!m_config.LegacyCompat)) { if (MessageBox.Show(this, "Legacy compat-mode should not be used to encrypt new files!", "Legacy Compatibility", MessageBoxButton.OKCancel, MessageBoxImage.Warning, MessageBoxResult.Cancel) != MessageBoxResult.OK) { @@ -772,6 +771,17 @@ namespace com.muldersoft.slunkcrypt.gui return null; } + private void CreateSystemMenu() + { + SystemMenu systemMenu = new SystemMenu(this, SystemMenu_Activated); + m_menuId_disableAnimation = systemMenu.AppendMenu("Disable Busy Indicator"); + m_menuId_enableExpertMode = systemMenu.AppendMenu("Expert Settings"); + if (m_disableAnimation && m_menuId_disableAnimation.HasValue) + { + systemMenu.ModifyMenu(m_menuId_disableAnimation.Value, m_disableAnimation); + } + } + private void CreateIndicatorElements() { FontFamily hackFont = new FontFamily(new Uri("pack://application:,,,/"), "./Resources/Fonts/#Hack"); @@ -786,6 +796,7 @@ namespace com.muldersoft.slunkcrypt.gui int numY = (int)Math.Floor(actualHeight / lenY); int offX = (int)Math.Round((actualWidth - (numX * lenX)) / 2.0); int offY = (int)Math.Round((actualHeight - (numY * lenY)) / 2.0); + Canvas.Children.Clear(); for (int i = 0; i < numX; ++i) { for (int j = 0; j < numY; ++j) diff --git a/gui/Utilities/ApplicationConfig.cs b/gui/Utilities/ApplicationConfig.cs index 02fb722..c725a09 100644 --- a/gui/Utilities/ApplicationConfig.cs +++ b/gui/Utilities/ApplicationConfig.cs @@ -38,6 +38,14 @@ namespace com.muldersoft.slunkcrypt.gui.utils } } + public bool LegacyCompat + { + get + { + return ComputeIfAbsent("LegacyCompat", (key) => AppConfHelper.GetConfigValueAsBool(key).GetValueOrDefault(false)); + } + } + // ============================================================================= // Internal methods // ============================================================================= diff --git a/gui/Utilities/WindowHelper.cs b/gui/Utilities/WindowHelper.cs index 69ae61d..b8c85dd 100644 --- a/gui/Utilities/WindowHelper.cs +++ b/gui/Utilities/WindowHelper.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Runtime.InteropServices; -using System.Threading.Tasks; using System.Windows; using System.Windows.Interop; @@ -31,6 +30,25 @@ namespace com.muldersoft.slunkcrypt.gui.utils } } + public static void EnableResize(this Window window, bool enable) + { + if (!ReferenceEquals(window, null)) + { + const int GWL_STYLE = -16; + const uint WS_SIZEBOX = 0x40000; + try + { + WindowInteropHelper interopHelper = new WindowInteropHelper(window); + uint value = NativeMethods.GetWindowLong(interopHelper.Handle, GWL_STYLE); + if (value != 0) + { + NativeMethods.SetWindowLong(interopHelper.Handle, GWL_STYLE, enable ? (value | WS_SIZEBOX) : (value & (~WS_SIZEBOX))); + } + } + catch { } + } + } + private static class NativeMethods { [DllImport("user32.dll", SetLastError = true)] @@ -38,6 +56,12 @@ namespace com.muldersoft.slunkcrypt.gui.utils [DllImport("user32.dll", SetLastError = true)] public static extern bool SetForegroundWindow(IntPtr hWnd); + + [DllImport("user32.dll", SetLastError = true)] + public static extern uint GetWindowLong(IntPtr hWnd, int nIndex); + + [DllImport("user32.dll", SetLastError = true)] + public static extern uint SetWindowLong(IntPtr hWnd, int nIndex, uint dwNewLong); } } }