From 7fee4f9bf38fdae1a35386ba25871033d77254a3 Mon Sep 17 00:00:00 2001 From: LoRd_MuldeR Date: Mon, 7 Nov 2022 22:29:11 +0100 Subject: [PATCH] GUI: Added command-line option to force pure software rendering. --- gui/App.xaml.cs | 23 +++++++++++++++++++++++ gui/Resources/Hint.png | Bin 0 -> 663 bytes gui/SlunkCryptGUI.csproj | 3 +++ gui/SlunkCryptGUI.xaml | 6 ++++-- gui/SlunkCryptGUI.xaml.cs | 7 ++++++- gui/Utilities/WindowHelper.cs | 8 ++++---- 6 files changed, 40 insertions(+), 7 deletions(-) create mode 100644 gui/Resources/Hint.png diff --git a/gui/App.xaml.cs b/gui/App.xaml.cs index 6dd1f71..81b00df 100644 --- a/gui/App.xaml.cs +++ b/gui/App.xaml.cs @@ -5,6 +5,8 @@ using System; using System.Windows; +using System.Windows.Interop; +using System.Windows.Media; namespace com.muldersoft.slunkcrypt.gui { @@ -15,6 +17,18 @@ namespace com.muldersoft.slunkcrypt.gui AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(ExceptionHandler); } + protected override void OnStartup(StartupEventArgs e) + { + try + { + if (Array.Exists(e.Args, str => StrCaseCmp(str, "--render-mode=software")) || StrCaseCmp(Environment.GetEnvironmentVariable("SLUNK_RENDER_MODE"), "software")) + { + RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly; + } + } + catch { } + } + private static void ExceptionHandler(object sender, UnhandledExceptionEventArgs args) { Exception exception; @@ -36,5 +50,14 @@ namespace com.muldersoft.slunkcrypt.gui } } } + + private static bool StrCaseCmp(string s1, string s2) + { + if ((!ReferenceEquals(s1, null)) && (!ReferenceEquals(s2, null))) + { + return string.Equals(s1.Trim(), s2.Trim(), StringComparison.OrdinalIgnoreCase); + } + return false; + } } } diff --git a/gui/Resources/Hint.png b/gui/Resources/Hint.png new file mode 100644 index 0000000000000000000000000000000000000000..d92ff16d0fa2ad9fccacce2f6fad4f6961f6c61f GIT binary patch literal 663 zcmV;I0%-k-P)Px#1ZP1_K>z@;j|==^1poj532;bRa{vGi!vFvd!vV){sAK>D0xU^HK~y+TrBX|1 z6HydBFEP^;laPuQe;^7vR;-B|u?m7H7F{T~5y61s#wZj-aNk9tP^wVTF5C!(Zbd}I z9~Fxc#SShiwJrTY8q+u>Y0P9MGnsk5Pa_(uP&~tM-@Eso^X|Rx;eSDH_x01|^{R2b zBT3fq#qsu&!tpoUeeej^E}r?#s+$xM6BQgjbUTYFQRF%Vla92CcR36LNLn5vBpp^Ms|8S&!|R_4uCoYxq-uC9n)Z;7ab|d(6K~ zU}CTZg(oqT-kf5-)N*p20MiE7=BIG7XJ#<{;tE0=RBVr*MsrgXhMt2yd>KJsNpOA& zh*HI=oC#z{dNBF$7`E&=f=D!kWUr3oz-B1LJOWsU-DChC`x-lh04K}RdEdMaieh>Q zs=61Xs-wX_gK2FDBf}cPISb0@7p$)?VIoa0NdfV3%Qe`b*pSS{&ujqSp=32+<~0h1 zJW589r^E9_5e^v8ONh%B_^FKa>(oJAHmq6DyaIF5#^Z#ArwJ+G-_eY;tswo4${C2Z z1yTO|meix27|Tck2{z!us~B!-F_8UR;e||$&E|1%7r7yx@}2(sBC#H={+%FA3!;jp z%sBR`ZOog)Tvmq@Y{A(s?G}-#D`R0W(l+(gxff6n53k*Z2+=X6+Zdg*Ke3CsdcNCw x_fLTuQoW7Oie-9Yd>+^s#q)FBR=bP + + + copy /Y "$(SolutionDir)\etc\deps\cpu-capabilities\*.dll" "$(TargetDir)" diff --git a/gui/SlunkCryptGUI.xaml b/gui/SlunkCryptGUI.xaml index be81bda..072fa0a 100644 --- a/gui/SlunkCryptGUI.xaml +++ b/gui/SlunkCryptGUI.xaml @@ -11,7 +11,7 @@ Icon="pack://application:,,,/slunkcrypt-gui;component/Resources/Application.ico" SizeToContent="WidthAndHeight" WindowStartupLocation="CenterScreen" - ResizeMode="CanMinimize" + ResizeMode="CanResize" WindowStyle="ThreeDBorderWindow" UseLayoutRounding="True" AllowDrop="True" @@ -36,6 +36,7 @@ + pack://application:,,,/Resources/Fonts/#Hack @@ -50,7 +51,8 @@ - + + diff --git a/gui/SlunkCryptGUI.xaml.cs b/gui/SlunkCryptGUI.xaml.cs index b12158a..c0aa899 100644 --- a/gui/SlunkCryptGUI.xaml.cs +++ b/gui/SlunkCryptGUI.xaml.cs @@ -17,6 +17,7 @@ using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Input; +using System.Windows.Interop; using System.Windows.Media; using System.Windows.Media.Effects; using System.Windows.Shell; @@ -120,11 +121,15 @@ namespace com.muldersoft.slunkcrypt.gui MinHeight = MaxHeight = ActualHeight; CreateIndicatorElements(); CreateSystemMenu(); + if (RenderMode.SoftwareOnly.Equals(RenderOptions.ProcessRenderMode)) + { + Hint_SoftwareRendering.Visibility = Visibility.Visible; + } if (m_config.LegacyCompat) { Checkbox_Encrypt_LegacyCompat.IsChecked = Checkbox_Decrypt_LegacyCompat.IsChecked = true; } - this.EnableResize(true); + this.DisableMaximizeButton(); this.BringWindowToTop(); } } diff --git a/gui/Utilities/WindowHelper.cs b/gui/Utilities/WindowHelper.cs index b8c85dd..48d65f0 100644 --- a/gui/Utilities/WindowHelper.cs +++ b/gui/Utilities/WindowHelper.cs @@ -30,19 +30,19 @@ namespace com.muldersoft.slunkcrypt.gui.utils } } - public static void EnableResize(this Window window, bool enable) + public static void DisableMaximizeButton(this Window window) { if (!ReferenceEquals(window, null)) { const int GWL_STYLE = -16; - const uint WS_SIZEBOX = 0x40000; + const uint WS_MAXIMIZEBOX = 0x10000; try { WindowInteropHelper interopHelper = new WindowInteropHelper(window); uint value = NativeMethods.GetWindowLong(interopHelper.Handle, GWL_STYLE); - if (value != 0) + if ((value & WS_MAXIMIZEBOX) != 0U) { - NativeMethods.SetWindowLong(interopHelper.Handle, GWL_STYLE, enable ? (value | WS_SIZEBOX) : (value & (~WS_SIZEBOX))); + NativeMethods.SetWindowLong(interopHelper.Handle, GWL_STYLE, value & (~WS_MAXIMIZEBOX)); } } catch { } -- 2.11.0