Portable Tool for an Ideal Windows Setup
C# activatorbloatware-removalcsharpdebloatdebloaterdisable-servicesmonitoring-systemportableprivacy-toolsregistry-tweakssystem-tuningsystem-utilitytelemetrytweakerwindows-10windows-11windows-debloatwindows-defenderwindows-optimizationwindows-tweaks
fix handle null values properly
Greedeksf770afe8be30
diff --git a/.Source/GTweak/App.xaml.cs b/.Source/GTweak/App.xaml.csindex 99e11e56..a23a10b1 100644--- a/.Source/GTweak/App.xaml.cs+++ b/.Source/GTweak/App.xaml.cs@@ -33,7 +33,7 @@ namespace GTweakprivate async void App_Startup(object sender, StartupEventArgs e){- if (e.Args != null && e.Args.Any(arg => string.Equals(arg, "uninstall", StringComparison.OrdinalIgnoreCase)))+ if (e.Args != null && e.Args.Any(arg => string.Equals(arg ?? string.Empty, "uninstall", StringComparison.OrdinalIgnoreCase))){SettingsEngine.SelfRemoval();return;@@ -52,9 +52,12 @@ namespace GTweakprivate void OnDispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e){- ErrorLogging.LogWritingFile(e.Exception);- e!.Handled = true;- Environment.Exit(0);+ if (e != null)+ {+ ErrorLogging.LogWritingFile(e.Exception);+ e.Handled = true;+ Environment.Exit(0);+ }}private void OnUnhandledException(object sender, UnhandledExceptionEventArgs e)diff --git a/.Source/GTweak/Assets/UserControl/FlowColumnPanel.cs b/.Source/GTweak/Assets/UserControl/FlowColumnPanel.csindex 53fb79dd..fc34c88a 100644--- a/.Source/GTweak/Assets/UserControl/FlowColumnPanel.cs+++ b/.Source/GTweak/Assets/UserControl/FlowColumnPanel.cs@@ -89,7 +89,7 @@ namespace GTweak.Assets.UserControl}var columns = CreateOptimalColumns(finalSize.Width, finalSize.Height, visibleChildren);- ArrangeAligned(columns, finalSize.Width);+ ArrangeAligned(columns ?? new List<ColumnInfo>(), finalSize.Width);return finalSize;}diff --git a/.Source/GTweak/Assets/UserControl/ToggleButton.xaml.cs b/.Source/GTweak/Assets/UserControl/ToggleButton.xaml.csindex 817ed790..dcffa58f 100644--- a/.Source/GTweak/Assets/UserControl/ToggleButton.xaml.cs+++ b/.Source/GTweak/Assets/UserControl/ToggleButton.xaml.cs@@ -99,43 +99,45 @@ namespace GTweak.Assets.UserControlprivate void ApplyResource(object value, DependencyProperty dp, DependencyProperty textProperty = null, FrameworkElement target = null){- switch (value)+ if (dp != null || target != null){- case DynamicResourceExtension dynamicResource:- if (target != null && textProperty != null)- {- target.SetResourceReference(textProperty, dynamicResource.ResourceKey);- }- else- {- SetResourceReference(dp, dynamicResource.ResourceKey);- }-- break;-- case StaticResourceExtension staticResource:- if (target != null && textProperty != null)- {- target.SetResourceReference(textProperty, staticResource.ResourceKey);- }- else- {- SetResourceReference(dp, staticResource.ResourceKey);- }-- break;-- default:- SetValue(dp, value);- if (target is TextBlock textBlock && value is string str)- {- textBlock.Text = str;- }-- break;+ switch (value)+ {+ case DynamicResourceExtension dynamicResource:+ if (target != null && textProperty != null)+ {+ target.SetResourceReference(textProperty, dynamicResource.ResourceKey);+ }+ else if (dp != null)+ {+ SetResourceReference(dp, dynamicResource.ResourceKey);+ }+ break;+ case StaticResourceExtension staticResource:+ if (target != null && textProperty != null)+ {+ target.SetResourceReference(textProperty, staticResource.ResourceKey);+ }+ else if (dp != null)+ {+ SetResourceReference(dp, staticResource.ResourceKey);+ }+ break;+ default:+ if (dp != null)+ {+ SetValue(dp, value);+ }+ if (target is TextBlock textBlock && value is string str)+ {+ textBlock.Text = str;+ }+ break;+ }}}+private void ToggleButton_IsEnabledChanged(object sender, DependencyPropertyChangedEventArgs e){if (e.NewValue is bool newBool && !newBool)diff --git a/.Source/GTweak/Core/RelayCommand.cs b/.Source/GTweak/Core/RelayCommand.csindex 9af60e2c..ea0e892e 100644--- a/.Source/GTweak/Core/RelayCommand.cs+++ b/.Source/GTweak/Core/RelayCommand.cs@@ -1,4 +1,4 @@-using System;+using System;using System.Windows.Input;namespace GTweak.Core@@ -19,6 +19,7 @@ namespace GTweak.Corethis._canExecute = _canExecute;}public bool CanExecute(object parameter) => _canExecute == null || _canExecute(parameter);- public void Execute(object parameter) => _execute(parameter);+ public void Execute(object parameter) => _execute?.Invoke(parameter);+}}diff --git a/.Source/GTweak/Core/ViewModel/ConfidentialityViewModel.cs b/.Source/GTweak/Core/ViewModel/ConfidentialityViewModel.csindex 005bd872..5b17f29a 100644--- a/.Source/GTweak/Core/ViewModel/ConfidentialityViewModel.cs+++ b/.Source/GTweak/Core/ViewModel/ConfidentialityViewModel.cs@@ -13,6 +13,6 @@ namespace GTweak.Core.ViewModelprotected override Dictionary<string, object> GetControlStates() => ConfidentialityTweaks.ControlStates;- protected override void Analyze(ConfidentialityTweaks tweaks) => tweaks.AnalyzeAndUpdate();+ protected override void Analyze(ConfidentialityTweaks tweaks) => tweaks?.AnalyzeAndUpdate();}}diff --git a/.Source/GTweak/Core/ViewModel/InterfaceViewModel.cs b/.Source/GTweak/Core/ViewModel/InterfaceViewModel.csindex 50edaaf7..165a05f5 100644--- a/.Source/GTweak/Core/ViewModel/InterfaceViewModel.cs+++ b/.Source/GTweak/Core/ViewModel/InterfaceViewModel.cs@@ -16,6 +16,6 @@ namespace GTweak.Core.ViewModelprotected override Dictionary<string, object> GetControlStates() => InterfaceTweaks.ControlStates;- protected override void Analyze(InterfaceTweaks tweaks) => tweaks.AnalyzeAndUpdate();+ protected override void Analyze(InterfaceTweaks tweaks) => tweaks?.AnalyzeAndUpdate();}}diff --git a/.Source/GTweak/Core/ViewModel/PakagesViewModel.cs b/.Source/GTweak/Core/ViewModel/PakagesViewModel.csindex 240f8da9..4457a718 100644--- a/.Source/GTweak/Core/ViewModel/PakagesViewModel.cs+++ b/.Source/GTweak/Core/ViewModel/PakagesViewModel.cs@@ -60,26 +60,22 @@ namespace GTweak.Core.ViewModelprivate void UpdatePackageState(PakagesModel item){- if (UninstallingPakages.PackagesDetails?.TryGetValue(item?.Name ?? default, out var val) == true)+ if (item != null && !string.IsNullOrEmpty(item.Name)){- item.IsUnavailable = !val.IsUnavailable;-- if (!item.Name.Equals("OneDrive", StringComparison.OrdinalIgnoreCase))+ if ((UninstallingPakages.PackagesDetails?.TryGetValue(item.Name, out var val)) == true){- if (val.Scripts != null && val.Scripts.Any())+ item.IsUnavailable = !val.IsUnavailable;++ if (!string.Equals(item?.Name, "OneDrive", StringComparison.OrdinalIgnoreCase)){- item.Installed = val.Scripts.Any(pattern => UninstallingPakages.InstalledPackagesCache.Any(pkg => Regex.IsMatch(pkg, $"^{Regex.Escape(pattern)}", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)));+ item.Installed = val.Scripts != null && val.Scripts.Any() && val.Scripts.Any(pattern => UninstallingPakages.InstalledPackagesCache.Any(pkg => Regex.IsMatch(pkg, $"^{Regex.Escape(pattern)}", RegexOptions.IgnoreCase | RegexOptions.CultureInvariant)));}else{- item.Installed = false;+ item.Installed = UninstallingPakages.IsOneDriveInstalled;+ return;}}- else- {- item.Installed = UninstallingPakages.IsOneDriveInstalled;- return;- }}}}diff --git a/.Source/GTweak/Core/ViewModel/ServicesViewModel.cs b/.Source/GTweak/Core/ViewModel/ServicesViewModel.csindex 9b3f2f8e..94df4405 100644--- a/.Source/GTweak/Core/ViewModel/ServicesViewModel.cs+++ b/.Source/GTweak/Core/ViewModel/ServicesViewModel.cs@@ -9,6 +9,6 @@ namespace GTweak.Core.ViewModel{protected override Dictionary<string, object> GetControlStates() => ServicesTweaks.ControlStates;- protected override void Analyze(ServicesTweaks tweaks) => tweaks.AnalyzeAndUpdate();+ protected override void Analyze(ServicesTweaks tweaks) => tweaks?.AnalyzeAndUpdate();}}diff --git a/.Source/GTweak/Core/ViewModel/SystemViewModel.cs b/.Source/GTweak/Core/ViewModel/SystemViewModel.csindex cfb332f7..0be4e609 100644--- a/.Source/GTweak/Core/ViewModel/SystemViewModel.cs+++ b/.Source/GTweak/Core/ViewModel/SystemViewModel.cs@@ -13,6 +13,6 @@ namespace GTweak.Core.ViewModelprotected override Dictionary<string, object> GetControlStates() => SystemTweaks.ControlStates;- protected override void Analyze(SystemTweaks tweaks) => tweaks.AnalyzeAndUpdate();+ protected override void Analyze(SystemTweaks tweaks) => tweaks?.AnalyzeAndUpdate();}}diff --git a/.Source/GTweak/Styles/Buttons/ToggleButtons.xaml b/.Source/GTweak/Styles/Buttons/ToggleButtons.xamlindex 694e2ca7..9c39240e 100644--- a/.Source/GTweak/Styles/Buttons/ToggleButtons.xaml+++ b/.Source/GTweak/Styles/Buttons/ToggleButtons.xaml@@ -293,7 +293,7 @@<Setter.Value><ControlTemplate TargetType="{x:Type ToggleButton}"><Grid>- <Border x:Name="BackgroundBorder" Background="Transparent" CornerRadius="4"/>+ <Border x:Name="BackgroundBorder" Background="Transparent" CornerRadius="7"/><Image x:Name="Icon" Width="70" Height="70" Source="{TemplateBinding Tag}" Stretch="Uniform" Opacity="1"><Image.RenderTransform><ScaleTransform ScaleX="1" ScaleY="1" />diff --git a/.Source/GTweak/Utilities/Animation/BrushAnimation.cs b/.Source/GTweak/Utilities/Animation/BrushAnimation.csindex a750b6a1..845d5981 100644--- a/.Source/GTweak/Utilities/Animation/BrushAnimation.cs+++ b/.Source/GTweak/Utilities/Animation/BrushAnimation.cs@@ -31,7 +31,7 @@ namespace GTweak.Utilities.Animationpublic override object GetCurrentValue(object defaultOriginValue, object defaultDestinationValue, AnimationClock animationClock){- if (animationClock.CurrentProgress == null)+ if (animationClock?.CurrentProgress == null){return From ?? defaultOriginValue;}diff --git a/.Source/GTweak/Utilities/Animation/NumberAnimation.cs b/.Source/GTweak/Utilities/Animation/NumberAnimation.csindex 2a842569..111b0755 100644--- a/.Source/GTweak/Utilities/Animation/NumberAnimation.cs+++ b/.Source/GTweak/Utilities/Animation/NumberAnimation.cs@@ -11,17 +11,17 @@ namespace GTweak.Utilities.Animationprivate static readonly DependencyProperty AnimatedValueProperty = DependencyProperty.RegisterAttached("AnimatedValue", typeof(int), typeof(NumberAnimation), new PropertyMetadata(0, OnAnimatedValueChanged));- internal static void SetValue(DependencyObject dObject, int value) => dObject.SetValue(ValueProperty, value);+ internal static void SetValue(DependencyObject dObject, int value) => dObject?.SetValue(ValueProperty, value);- internal static int GetValue(DependencyObject dObject) => dObject.GetValue(ValueProperty) as int? ?? 0;+ internal static int GetValue(DependencyObject dObject) => dObject?.GetValue(ValueProperty) as int? ?? 0;- private static void SetAnimatedValue(DependencyObject dObject, int value) => dObject.SetValue(AnimatedValueProperty, value);+ private static void SetAnimatedValue(DependencyObject dObject, int value) => dObject?.SetValue(AnimatedValueProperty, value);private static void OnValueChanged(DependencyObject dObject, DependencyPropertyChangedEventArgs e){if (dObject is TextBlock textBlock){- int newValue = e.NewValue as int? ?? 0;+ int newValue = (e.NewValue as int?) ?? 0;if (!textBlock.IsLoaded){@@ -47,7 +47,7 @@ namespace GTweak.Utilities.Animation{if (dObject is TextBlock textBlock){- textBlock.Text = string.Format(" {0}", e.NewValue.ToString());+ textBlock.Text = string.Format(" {0}", e.NewValue?.ToString() ?? string.Empty);}}}diff --git a/.Source/GTweak/Utilities/Animation/TypewriterAnimation.cs b/.Source/GTweak/Utilities/Animation/TypewriterAnimation.csindex fefa1191..66aba32b 100644--- a/.Source/GTweak/Utilities/Animation/TypewriterAnimation.cs+++ b/.Source/GTweak/Utilities/Animation/TypewriterAnimation.cs@@ -18,25 +18,29 @@ namespace GTweak.Utilities.Animation}Storyboard storyboard = new Storyboard { FillBehavior = FillBehavior.HoldEnd };-StringAnimationUsingKeyFrames stringAnimation = CreateStringAnimation(textToAnimate, timeSpan);- Storyboard.SetTarget(stringAnimation, textBlock);- Storyboard.SetTargetProperty(stringAnimation, new PropertyPath(TextBlock.TextProperty));- storyboard.Children.Add(stringAnimation);-- DoubleAnimation opacityAnimation = FactoryAnimation.CreateIn(0, 1, timeSpan.TotalSeconds);- Storyboard.SetTarget(opacityAnimation, textBlock);- Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath(UIElement.OpacityProperty));- storyboard.Children.Add(opacityAnimation);-- handler = delegate+ if (stringAnimation != null){- storyboard.Children.Clear();- storyboard.Completed -= handler;- };- storyboard.Completed += handler;+ Storyboard.SetTarget(stringAnimation, textBlock);+ Storyboard.SetTargetProperty(stringAnimation, new PropertyPath(TextBlock.TextProperty));+ storyboard.Children.Add(stringAnimation);- textBlock.BeginStoryboard(storyboard);+ DoubleAnimation opacityAnimation = FactoryAnimation.CreateIn(0, 1, timeSpan.TotalSeconds);+ if (opacityAnimation != null)+ {+ Storyboard.SetTarget(opacityAnimation, textBlock);+ Storyboard.SetTargetProperty(opacityAnimation, new PropertyPath(UIElement.OpacityProperty));+ storyboard.Children.Add(opacityAnimation);+ }++ handler = delegate+ {+ storyboard.Children.Clear();+ storyboard.Completed -= handler;+ };+ storyboard.Completed += handler;+ textBlock.BeginStoryboard(storyboard);+ }}private static StringAnimationUsingKeyFrames CreateStringAnimation(in string textToAnimate, in TimeSpan timeSpan)@@ -47,7 +51,7 @@ namespace GTweak.Utilities.Animation};StringBuilder temp = new StringBuilder();- int totalChars = textToAnimate.Length;+ int totalChars = textToAnimate?.Length ?? 0;if (totalChars != 0){diff --git a/.Source/GTweak/Utilities/Configuration/MonitoringService.cs b/.Source/GTweak/Utilities/Configuration/MonitoringService.csindex a8554550..06506056 100644--- a/.Source/GTweak/Utilities/Configuration/MonitoringService.cs+++ b/.Source/GTweak/Utilities/Configuration/MonitoringService.cs@@ -190,7 +190,11 @@ namespace GTweak.Utilities.Configuration{WqlEventQuery query = new WqlEventQuery("__InstanceOperationEvent", TimeSpan.FromSeconds(1), filter);ManagementEventWatcher managementEvent = new ManagementEventWatcher(new ManagementScope(scope ?? @"root\cimv2"), query);- void handler(object s, EventArrivedEventArgs e) => HandleDevicesEvents?.Invoke(type);+ void handler(object s, EventArrivedEventArgs e)+ {+ Action<DeviceType> handlerEvent = HandleDevicesEvents;+ handlerEvent?.Invoke(type);+ }managementEvent.EventArrived += handler;managementEvent.Start();_watcherHandler.Add((managementEvent, handler));diff --git a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.csindex d135d184..2f1afc06 100644--- a/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs+++ b/.Source/GTweak/Utilities/Configuration/SystemDiagnostics.cs@@ -398,7 +398,7 @@ namespace GTweak.Utilities.Configurationstatic string GetStorageType(object mediaType, string deviceId, ushort busType, string interfaceType){- string storageType = MediaTypeMap.Where(x => x.Keys != null && mediaType != null && x.Keys.Contains(mediaType)).Select(x => x.Type).FirstOrDefault() ?? DiskTypeLabels.Unspecified;+ string storageType = MediaTypeMap.Where(x => x.Keys != null && mediaType != null && x.Keys.Contains(mediaType) && x.Type != null).Select(x => x.Type).FirstOrDefault() ?? DiskTypeLabels.Unspecified;if (isMsftAvailable){@@ -524,7 +524,7 @@ namespace GTweak.Utilities.Configurationprivate static string SizeCalculationHelper<T>(T sizeInBytes) where T : struct, IConvertible{- decimal bytes = Convert.ToDecimal(sizeInBytes);+ decimal bytes = ((IConvertible)sizeInBytes).ToDecimal(null);foreach (string unit in new[] { "B", "KB", "MB", "GB", "TB" }){diff --git a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs b/.Source/GTweak/Utilities/Helpers/CommandExecutor.csindex f1f0eaea..4ded72fa 100644--- a/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs+++ b/.Source/GTweak/Utilities/Helpers/CommandExecutor.cs@@ -103,17 +103,29 @@ namespace GTweak.Utilities.Helpersinternal static Task WaitForExitAsync(this Process process){- if (process.HasExited)+ if (!process.HasExited){- return Task.CompletedTask;+ var tcs = new TaskCompletionSource<object>();++ void Handler(object s, EventArgs e) => tcs.TrySetResult(null);++ process.EnableRaisingEvents = true;+ process.Exited += Handler;++ tcs.Task.ContinueWith(_ => process.Exited -= Handler, TaskScheduler.Default);++ if (process.HasExited)+ {+ tcs.TrySetResult(null);+ }++ return tcs.Task;}- TaskCompletionSource<object> tcs = new TaskCompletionSource<object>();- process.EnableRaisingEvents = true;- process.Exited += delegate { tcs.TrySetResult(null); };- return tcs.Task;+ return Task.CompletedTask;}+internal static string CleanCommand(string rawCommand){if (string.IsNullOrWhiteSpace(rawCommand))@@ -133,7 +145,7 @@ namespace GTweak.Utilities.Helpersreturn lines[0];}- string separator = rawCommand.Contains("&&") ? " && " : rawCommand.Contains("&") ? " & " : " && ";+ string separator = rawCommand?.Contains("&&") == true ? " && " : rawCommand?.Contains("&") == true ? " & " : " && ";return string.Join(separator, lines);}diff --git a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs b/.Source/GTweak/Utilities/Helpers/RegistryHelp.csindex 3cedb1e7..29b7c235 100644--- a/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs+++ b/.Source/GTweak/Utilities/Helpers/RegistryHelp.cs@@ -103,7 +103,7 @@ namespace GTweak.Utilities.Helpersinternal static bool ValueExists(string subKey, string valueName, in bool isNegation = true){- bool result = Registry.GetValue(subKey, valueName, null) == null;+ bool result = (Registry.GetValue(subKey, valueName, null) ?? null) == null;return isNegation ? result : !result;}diff --git a/.Source/GTweak/Utilities/Helpers/UnlockHandleHelper.cs b/.Source/GTweak/Utilities/Helpers/UnlockHandleHelper.csindex 88dff8f4..fa5b10a2 100644--- a/.Source/GTweak/Utilities/Helpers/UnlockHandleHelper.cs+++ b/.Source/GTweak/Utilities/Helpers/UnlockHandleHelper.cs@@ -103,15 +103,27 @@ namespace GTweak.Utilities.HelpersHashSet<int> result = new HashSet<int>();string[] files;- try++ if (string.IsNullOrEmpty(directoryPath)){- files = Directory.GetFiles(directoryPath, "*", SearchOption.AllDirectories);- if (files.Length == 0)+ files = Array.Empty<string>();+ }+ else+ {+ try+ {+ files = Directory.GetFiles(directoryPath, "*", SearchOption.AllDirectories);++ if (files == null || files.Length == 0)+ {+ files = new[] { Path.GetFullPath(directoryPath) };+ }+ }+ catch{files = new[] { Path.GetFullPath(directoryPath) };}}- catch { files = new[] { Path.GetFullPath(directoryPath) }; }string sessionKey = Guid.NewGuid().ToString();diff --git a/.Source/GTweak/Utilities/Maintenance/RegistryExporter.cs b/.Source/GTweak/Utilities/Maintenance/RegistryExporter.csindex e43174d0..5e773415 100644--- a/.Source/GTweak/Utilities/Maintenance/RegistryExporter.cs+++ b/.Source/GTweak/Utilities/Maintenance/RegistryExporter.cs@@ -53,8 +53,8 @@ namespace GTweak.Utilities.Maintenancereturn false;}- string hive = fullPath.Substring(0, index);- string subKey = fullPath.Substring(index + 1);+ string hive = !string.IsNullOrEmpty(fullPath) && index >= 0 && index <= fullPath.Length ? fullPath.Substring(0, index) : string.Empty;+ string subKey = (fullPath != null && index + 1 < fullPath.Length) ? fullPath.Substring(index + 1) : string.Empty;RegistryKey baseKey = hive switch{diff --git a/.Source/GTweak/Utilities/Managers/ExplorerManager.cs b/.Source/GTweak/Utilities/Managers/ExplorerManager.csindex db268214..44dd7fba 100644--- a/.Source/GTweak/Utilities/Managers/ExplorerManager.cs+++ b/.Source/GTweak/Utilities/Managers/ExplorerManager.cs@@ -47,7 +47,7 @@ namespace GTweak.Utilities.Managerscatch (Exception ex) { ErrorLogging.LogDebug(ex); }finally{- if (Process.GetProcessesByName("explorer").Length == 0)+ if (Process.GetProcessesByName("explorer").Length == 0 && launchExplorer != null){launchExplorer.StartInfo.FileName = PathLocator.Executable.Explorer;launchExplorer.StartInfo.Arguments = "/factory,{EFD469A7-7E0A-4517-8B39-45873948DA31}";diff --git a/.Source/GTweak/Utilities/Managers/INIManager.cs b/.Source/GTweak/Utilities/Managers/INIManager.csindex 491b7ba4..d9e7249b 100644--- a/.Source/GTweak/Utilities/Managers/INIManager.cs+++ b/.Source/GTweak/Utilities/Managers/INIManager.cs@@ -41,7 +41,7 @@ namespace GTweak.Utilities.Managersreturn retValue.ToString();}- internal void Write(string section, string key, string value) => WritePrivateProfileString(section, key, value, _pathToConfig);+ internal void Write(string section, string key, string value) => WritePrivateProfileString(section ?? string.Empty, key ?? string.Empty, value ?? string.Empty, _pathToConfig);internal void WriteAll(string section, Dictionary<string, string> selectedDictionary){diff --git a/.Source/GTweak/Windows/ImportWindow.xaml.cs b/.Source/GTweak/Windows/ImportWindow.xaml.csindex 09eff0f8..d6824dce 100644--- a/.Source/GTweak/Windows/ImportWindow.xaml.cs+++ b/.Source/GTweak/Windows/ImportWindow.xaml.cs@@ -31,7 +31,7 @@ namespace GTweak.Windowsprivate void TitleBar_MouseDown(object sender, MouseButtonEventArgs e){- if (e.LeftButton == MouseButtonState.Pressed)+ if (e?.LeftButton == MouseButtonState.Pressed){DragMove();}diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.csindex b6e1ab36..f9c2c124 100644--- a/.Source/GTweak/Windows/MainWindow.xaml.cs+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs@@ -51,12 +51,15 @@ namespace GTweak.Windowsprivate void TitleBar_MouseDown(object sender, MouseButtonEventArgs e){- if (e?.ChangedButton == MouseButton.Left && e.ClickCount != 2)+ if (e?.ChangedButton == MouseButton.Left && e?.ClickCount != 2){if (WindowState == WindowState.Maximized){- _mouseDownWindowPoint = e!.GetPosition(this);- _draggingFromMaximized = true;+ if (e != null)+ {+ _mouseDownWindowPoint = e.GetPosition(this);+ _draggingFromMaximized = true;+ }}else{@@ -143,7 +146,10 @@ namespace GTweak.Windowsawait Task.Delay(100).ConfigureAwait(false);_ignoreMouseClick = false;- e!.Handled = true;+ if (e != null)+ {+ e.Handled = true;+ }}}diff --git a/.Source/GTweak/Windows/MessageWindow.xaml.cs b/.Source/GTweak/Windows/MessageWindow.xaml.csindex 8b3ca781..f5d33e1b 100644--- a/.Source/GTweak/Windows/MessageWindow.xaml.cs+++ b/.Source/GTweak/Windows/MessageWindow.xaml.cs@@ -33,7 +33,7 @@ namespace GTweak.Windowsprivate void TitleBar_MouseDown(object sender, MouseButtonEventArgs e){- if (e.LeftButton == MouseButtonState.Pressed)+ if (e?.LeftButton == MouseButtonState.Pressed){DragMove();}@@ -41,7 +41,7 @@ namespace GTweak.Windowsprivate void BtnAccept_PreviewMouseDown(object sender, MouseButtonEventArgs e){- if (e.LeftButton == MouseButtonState.Pressed)+ if (e?.LeftButton == MouseButtonState.Pressed){Application.Current.Shutdown();}diff --git a/.Source/GTweak/Windows/OverlayWindow.xaml.cs b/.Source/GTweak/Windows/OverlayWindow.xaml.csindex f12b9095..a9c367fc 100644--- a/.Source/GTweak/Windows/OverlayWindow.xaml.cs+++ b/.Source/GTweak/Windows/OverlayWindow.xaml.cs@@ -20,15 +20,18 @@ namespace GTweak.Windowsprivate void Window_Closing(object sender, CancelEventArgs e){- Closing -= Window_Closing;- e!.Cancel = true;- BeginAnimation(OpacityProperty, FactoryAnimation.CreateTo(0.15, () =>+ if (e != null){- ProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule;- disablingWinKeys.objKeyboardProcess = new DisablingWinKeys.LowLevelKeyboardProc(disablingWinKeys.CaptureKey);- disablingWinKeys.ptrHook = DisablingWinKeys.SetWindowsHookEx(13, disablingWinKeys.objKeyboardProcess, DisablingWinKeys.GetModuleHandle(objCurrentModule.ModuleName), 1);- Close();- }));+ Closing -= Window_Closing;+ e.Cancel = true;+ BeginAnimation(OpacityProperty, FactoryAnimation.CreateTo(0.15, () =>+ {+ ProcessModule objCurrentModule = Process.GetCurrentProcess().MainModule;+ disablingWinKeys.objKeyboardProcess = new DisablingWinKeys.LowLevelKeyboardProc(disablingWinKeys.CaptureKey);+ disablingWinKeys.ptrHook = DisablingWinKeys.SetWindowsHookEx(13, disablingWinKeys.objKeyboardProcess, DisablingWinKeys.GetModuleHandle(objCurrentModule.ModuleName), 1);+ Close();+ }));+ }}private void Window_Loaded(object sender, RoutedEventArgs e)diff --git a/.Source/GTweak/Windows/UpdateWindow.xaml.cs b/.Source/GTweak/Windows/UpdateWindow.xaml.csindex b0371b02..7b690939 100644--- a/.Source/GTweak/Windows/UpdateWindow.xaml.cs+++ b/.Source/GTweak/Windows/UpdateWindow.xaml.cs@@ -22,7 +22,7 @@ namespace GTweak.Windowsprivate void TitleBar_MouseDown(object sender, MouseButtonEventArgs e){- if (e.LeftButton == MouseButtonState.Pressed)+ if (e?.LeftButton == MouseButtonState.Pressed){DragMove();}