Skip to content

Portable Tool for an Ideal Windows Setup

upd. implement adaptive window scaling for high DPI displays

Greedeks20be3ba105b0
diff --git a/.Source/GTweak/Windows/MainWindow.xaml b/.Source/GTweak/Windows/MainWindow.xaml
index 49cfa6b3..a39498b8 100644
--- a/.Source/GTweak/Windows/MainWindow.xaml
+++ b/.Source/GTweak/Windows/MainWindow.xaml
@@ -29,7 +29,7 @@
<DockPanel Grid.Column="0" VerticalAlignment="Center" LastChildFill="False" Height="48">
<Image Width="20" Height="20" Source="/GTweak.ico" Stretch="Uniform" DockPanel.Dock="Left" VerticalAlignment="Center" Margin="15,0,0,0" />
- <TextBlock x:Name="TitleName" Text="GTweak" FontSize="17" FontFamily="{StaticResource Jura}" Foreground="{StaticResource Brush_Accent}" VerticalAlignment="Center" Margin="10,0,20,0" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" KeyboardNavigation.IsTabStop="False" Width="61">
+ <TextBlock x:Name="TitleName" Text="GTweak" FontSize="17" FontFamily="{StaticResource Jura}" Foreground="{StaticResource Brush_Accent}" VerticalAlignment="Center" Margin="10,0,20,0" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" KeyboardNavigation.IsTabStop="False" Width="65">
<TextBlock.CacheMode>
<BitmapCache RenderAtScale="2" EnableClearType="True"/>
</TextBlock.CacheMode>
diff --git a/.Source/GTweak/Windows/MainWindow.xaml.cs b/.Source/GTweak/Windows/MainWindow.xaml.cs
index 25049675..8add4b2d 100644
--- a/.Source/GTweak/Windows/MainWindow.xaml.cs
+++ b/.Source/GTweak/Windows/MainWindow.xaml.cs
@@ -31,6 +31,25 @@ namespace GTweak.Windows
InitializeComponent();
App.TweaksImported += delegate { BtnUtils.IsChecked = true; };
}
+ protected override void OnSourceInitialized(EventArgs e)
+ {
+ base.OnSourceInitialized(e);
+
+ Rect area = SystemParameters.WorkArea;
+
+ double rawWidth = area.Width * (area.Width <= 1600 ? 0.82 : 0.62);
+ Width = Math.Max(1150, Math.Min(rawWidth, 1500));
+
+ if (Width > area.Width)
+ {
+ Width = area.Width * 0.96;
+ }
+
+ Height = Math.Min(Width / 1.8, area.Height * 0.90);
+
+ Left = area.Left + (area.Width - Width) / 2;
+ Top = area.Top + (area.Height - Height) / 2;
+ }
private void AnimateSettings()
{
@@ -162,14 +181,6 @@ namespace GTweak.Windows
private async void Window_Loaded(object sender, RoutedEventArgs e)
{
- (double screenWidth, double screenHeight) = (SystemParameters.PrimaryScreenWidth, SystemParameters.PrimaryScreenHeight);
-
- Width = screenWidth * 0.61;
- Height = screenHeight * 0.60;
-
- Left = (screenWidth - Width) / 2;
- Top = (screenHeight - Height) / 2;
-
TypewriterAnimation.Create(TitleName.Text, TitleName, TimeSpan.FromSeconds(0.4));
if (SystemDataCollector.IsNeedUpdate && SettingsEngine.IsUpdateCheckRequired)
@@ -177,8 +188,13 @@ namespace GTweak.Windows
await Task.Delay(500);
UpdateBanner.Visibility = Visibility.Visible;
+
UpdateBanner.BeginAnimation(OpacityProperty, FactoryAnimation.CreateIn(0, 1, 0.3));
- (UpdateBanner.RenderTransform as TranslateTransform).BeginAnimation(TranslateTransform.YProperty, FactoryAnimation.CreateIn(-20, 0, 0.3, useCubicEase: true));
+
+ if (UpdateBanner.RenderTransform is TranslateTransform transform)
+ {
+ transform.BeginAnimation(TranslateTransform.YProperty, FactoryAnimation.CreateIn(-20, 0, 0.3, useCubicEase: true));
+ }
}
}
}
diff --git a/.Source/GTweak/app.manifest b/.Source/GTweak/app.manifest
index 52f9dd96..d4a4fce1 100644
--- a/.Source/GTweak/app.manifest
+++ b/.Source/GTweak/app.manifest
@@ -2,22 +2,16 @@
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
-
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
-
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
-
</requestedPrivileges>
</security>
-
</trustInfo>
-
- <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
- <application>
- <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
- <longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">true</longPathAware>
- </application>
- </compatibility>
-
+ <application xmlns="urn:schemas-microsoft-com:asm.v3">
+ <windowsSettings>
+ <dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness>
+ <longPathAware xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings"> rue</longPathAware>
+ </windowsSettings>
+ </application>
</assembly>