Skip to content

Portable Tool for an Ideal Windows Setup

handling possible null

Greedeks01fa057e30e8
diff --git a/.Source/GTweak/App.xaml.cs b/.Source/GTweak/App.xaml.cs
index 6b02ad52..80693624 100644
--- a/.Source/GTweak/App.xaml.cs
+++ b/.Source/GTweak/App.xaml.cs
@@ -33,7 +33,7 @@ namespace GTweak
private async void App_Startup(object sender, StartupEventArgs e)
{
- if (e.Args.Any(arg => arg.Equals("uninstall", StringComparison.OrdinalIgnoreCase)))
+ if (e.Args != null && e.Args.Any(arg => arg.Equals("uninstall", StringComparison.OrdinalIgnoreCase)))
{
SettingsEngine.SelfRemoval();
return;
diff --git a/.Source/GTweak/Assets/UserControl/FlowColumnPanel.cs b/.Source/GTweak/Assets/UserControl/FlowColumnPanel.cs
index 7507105c..b3b6c210 100644
--- a/.Source/GTweak/Assets/UserControl/FlowColumnPanel.cs
+++ b/.Source/GTweak/Assets/UserControl/FlowColumnPanel.cs
@@ -101,9 +101,8 @@ namespace GTweak.Assets.UserControl
return;
}
- double contentWidth = columns.Sum(c => c.Width) + Math.Max(0, columns.Count - 1) * HorizontalSpacing;
+ double contentWidth = (columns?.Sum(c => c.Width) ?? 0) + Math.Max(0, (columns?.Count ?? 0) - 1) * HorizontalSpacing;
double extraSpace = Math.Max(0, availableWidth - contentWidth);
-
double xStart = ContentAlignment switch
{
HorizontalAlignment.Center => (availableWidth - contentWidth) / 2.0,
@@ -123,7 +122,7 @@ namespace GTweak.Assets.UserControl
continue;
}
- double shift = (i > 0 && columns.Count > 1) ? (extraSpace * (i / (double)(columns.Count - 1)) * 0.3) : 0;
+ double shift = (columns != null && i > 0 && columns.Count > 1) ? (extraSpace * (i / (double)(columns.Count - 1)) * 0.3) : 0;
double columnX = x + shift;
double y = 0;
@@ -254,6 +253,6 @@ namespace GTweak.Assets.UserControl
return new List<ColumnInfo> { col };
}
- private double CalculateTotalWidth(List<ColumnInfo> columns) => columns.Sum(c => c.Width) + Math.Max(0, columns.Count - 1) * HorizontalSpacing;
+ private double CalculateTotalWidth(List<ColumnInfo> columns) => (columns?.Sum(c => c.Width) ?? 0) + Math.Max(0, (columns?.Count ?? 0) - 1) * HorizontalSpacing;
}
}
diff --git a/.Source/GTweak/Styles/Buttons/Buttons.xaml b/.Source/GTweak/Styles/Buttons/Buttons.xaml
index e6226f9a..ca93f3b3 100644
--- a/.Source/GTweak/Styles/Buttons/Buttons.xaml
+++ b/.Source/GTweak/Styles/Buttons/Buttons.xaml
@@ -1,4 +1,4 @@
-<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008">
<Style x:Key="TitleButtonBase" TargetType="Button">
diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.cs
index 3302d6ee..c4c84f81 100644
--- a/.Source/GTweak/Windows/MainWindow.xaml.cs
+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs
@@ -43,7 +43,7 @@ namespace GTweak.Windows
private void TitleBar_PreviewMouseDown(object sender, MouseButtonEventArgs e)
{
- if (e.ClickCount == 2)
+ if (e!.ClickCount == 2)
{
if (e.OriginalSource is DependencyObject source)
{
diff --git a/.Source/GTweak/Windows/NotificationWindow.xaml b/.Source/GTweak/Windows/NotificationWindow.xaml
index da7086a9..9209a45d 100644
--- a/.Source/GTweak/Windows/NotificationWindow.xaml
+++ b/.Source/GTweak/Windows/NotificationWindow.xaml
@@ -17,7 +17,7 @@
<Grid Grid.Row="0">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" HorizontalAlignment="Right">
- <Button x:Name="ButtonClose" Style="{StaticResource TitleButtonClose}" Margin="0,2.5,3,0" HorizontalAlignment="Right" VerticalAlignment="Center" PreviewMouseLeftButtonUp="ButtonClose_PreviewMouseLeftButtonUp"/>
+ <Button x:Name="ButtonClose" Style="{StaticResource TitleButtonClose}" Margin="0,2.5,2.5,0" HorizontalAlignment="Right" VerticalAlignment="Center" PreviewMouseLeftButtonUp="ButtonClose_PreviewMouseLeftButtonUp"/>
</StackPanel>
<DockPanel VerticalAlignment="Center" HorizontalAlignment="Left" LastChildFill="True">