Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/UniGetUI/Controls/CustomNavViewItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace UniGetUI.Controls;

internal sealed partial class CustomNavViewItem : NavigationViewItem
{
int _iconSize = 28;
int _iconSize = 24;
public IconType LocalIcon
{
set => base.Icon = new LocalIcon(value);
Expand Down Expand Up @@ -62,15 +62,15 @@ public string Text

public CustomNavViewItem()
{
Height = 60;
Height = 54;
Resources["NavigationViewItemOnLeftIconBoxHeight"] = _iconSize;
Resources["NavigationViewItemContentPresenterMargin"] = new Thickness(0);

var grid = new Grid { Height = 50 };
var grid = new Grid { Height = 44 };

_progressRing = new ProgressRing
{
Margin = new Thickness(-46, 0, 0, 0),
Margin = new Thickness(-42, 0, 0, 0),
HorizontalAlignment = HorizontalAlignment.Left,
VerticalAlignment = VerticalAlignment.Center,
IsIndeterminate = true,
Expand Down
53 changes: 44 additions & 9 deletions src/UniGetUI/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -748,6 +748,27 @@ public IntPtr GetWindowHandle()
return WinRT.Interop.WindowNative.GetWindowHandle(this);
}

private double GetWindowRasterizationScale()
{
uint dpi = NativeHelpers.GetDpiForWindow(GetWindowHandle());
if (dpi > 0)
{
return dpi / 96.0;
}

return MainContentGrid.XamlRoot?.RasterizationScale ?? 1.0;
}

private int ConvertPhysicalPixelsToDips(int physicalPixels)
{
return (int)Math.Round(physicalPixels / Math.Max(GetWindowRasterizationScale(), 0.01));
}

private int ConvertDipsToPhysicalPixels(int dips)
{
return Math.Max(1, (int)Math.Round(dips * GetWindowRasterizationScale()));
}

public async Task HandleMissingDependencies(IReadOnlyList<ManagerDependency> dependencies)
{
int current = 1;
Expand Down Expand Up @@ -803,7 +824,7 @@ private async Task SaveGeometry(bool Force = false)
}

string geometry =
$"{AppWindow.Position.X},{AppWindow.Position.Y},{AppWindow.Size.Width},{AppWindow.Size.Height},{windowState}";
$"v2,{AppWindow.Position.X},{AppWindow.Position.Y},{ConvertPhysicalPixelsToDips(AppWindow.Size.Width)},{ConvertPhysicalPixelsToDips(AppWindow.Size.Height)},{windowState}";

Logger.Debug($"Saving window geometry {geometry}");
Settings.SetValue(Settings.K.WindowGeometry, geometry);
Expand All @@ -818,10 +839,10 @@ private void RestoreGeometry()
{
string geometry = Settings.GetValue(Settings.K.WindowGeometry);
string[] items = geometry.Split(",");
if (items.Length != 5)
if (items.Length is not (5 or 6))
{
Logger.Warn(
$"The restored geometry did not have exactly 5 items (found length was {items.Length})"
$"The restored geometry did not have a supported item count (found length was {items.Length})"
);
return;
}
Expand All @@ -833,11 +854,22 @@ private void RestoreGeometry()
State;
try
{
X = int.Parse(items[0]);
Y = int.Parse(items[1]);
Width = int.Parse(items[2]);
Height = int.Parse(items[3]);
State = int.Parse(items[4]);
if (items.Length == 6 && items[0] == "v2")
{
X = int.Parse(items[1]);
Y = int.Parse(items[2]);
Width = ConvertDipsToPhysicalPixels(int.Parse(items[3]));
Height = ConvertDipsToPhysicalPixels(int.Parse(items[4]));
State = int.Parse(items[5]);
}
else
{
X = int.Parse(items[0]);
Y = int.Parse(items[1]);
Width = int.Parse(items[2]);
Height = int.Parse(items[3]);
State = int.Parse(items[4]);
}
}
catch (Exception ex)
{
Expand Down Expand Up @@ -936,7 +968,7 @@ private void TitleBar_PaneToggleRequested(TitleBar sender, object args)
if (NavigationPage is null)
return;

if (this.AppWindow.Size.Width >= 1600)
if (MainContentGrid.ActualWidth >= 1600)
{
Settings.Set(
Settings.K.CollapseNavMenuOnWideScreen,
Expand Down Expand Up @@ -1005,6 +1037,9 @@ public static class NativeHelpers
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool SetForegroundWindow(IntPtr hWnd);

[DllImport("user32.dll")]
public static extern uint GetDpiForWindow(IntPtr hWnd);

public const int MONITORINFOF_PRIMARY = 0x00000001;

[StructLayout(LayoutKind.Sequential)]
Expand Down
12 changes: 6 additions & 6 deletions src/UniGetUI/Pages/DialogPages/PackageDetailsPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,13 @@
</Grid.ColumnDefinitions>
<Border
Grid.Column="0"
Width="128"
Height="128"
Width="112"
Height="112"
Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
BorderThickness="10"
CornerRadius="24"
BorderThickness="8"
CornerRadius="20"
>
<Image Name="PackageIcon" Width="80" Height="80" Margin="8" />
<Image Name="PackageIcon" Width="72" Height="72" Margin="8" />
</Border>

<TextBlock
Expand All @@ -54,7 +54,7 @@
HorizontalAlignment="Left"
VerticalAlignment="Center"
FontFamily="Segoe UI Variable Display"
FontSize="50"
FontSize="40"
FontWeight="Bold"
TextWrapping="Wrap"
/>
Expand Down
2 changes: 1 addition & 1 deletion src/UniGetUI/Pages/DialogPages/PackageDetailsPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ public void PackageDetailsPage_SizeChanged(
SizeChangedEventArgs? e = null
)
{
if (MainApp.Instance.MainWindow.AppWindow.Size.Width < 950)
if (ActualWidth < 950)
{
if (__layout_mode != LayoutMode.Normal)
{
Expand Down
6 changes: 3 additions & 3 deletions src/UniGetUI/Pages/SettingsPages/SettingsBasePage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@
</Grid.ColumnDefinitions>
<Button
Name="BackButton"
Width="40"
Height="40"
Width="36"
Height="36"
Padding="6"
VerticalAlignment="Center"
Background="Transparent"
Expand All @@ -65,7 +65,7 @@
Grid.Column="1"
HorizontalAlignment="Stretch"
VerticalAlignment="Center"
FontSize="30"
FontSize="24"
FontWeight="Bold"
Text=""
TextWrapping="Wrap"
Expand Down
28 changes: 14 additions & 14 deletions src/UniGetUI/Pages/SoftwarePages/AbstractPackagesPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -509,21 +509,21 @@
x:Name="HeaderIcon"
Grid.Row="0"
Grid.Column="0"
Width="60"
MinHeight="60"
Margin="0,0,-8,0"
FontSize="50"
Width="52"
MinHeight="52"
Margin="0,0,-6,0"
FontSize="40"
FontWeight="Normal"
/>

<StackPanel Grid.Column="1" VerticalAlignment="Center" Orientation="Vertical" Spacing="0">
<TextBlock
x:Name="MainTitle"
MaxHeight="70"
MaxHeight="60"
HorizontalAlignment="Left"
x:FieldModifier="protected"
FontFamily="Segoe UI Variable Display"
FontSize="30"
FontSize="24"
FontWeight="Bold"
TextWrapping="Wrap"
/>
Expand All @@ -532,7 +532,7 @@
MaxHeight="40"
HorizontalAlignment="Left"
x:FieldModifier="protected"
FontSize="11"
FontSize="12"
FontWeight="Normal"
Foreground="{ThemeResource AppBarItemDisabledForegroundThemeBrush}"
TextWrapping="Wrap"
Expand Down Expand Up @@ -1228,31 +1228,31 @@
>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="80" />
<RowDefinition Height="64" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="8*" MaxWidth="800" />
<ColumnDefinition Width="80" />
<ColumnDefinition Width="8*" MaxWidth="720" />
<ColumnDefinition Width="64" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<TextBox
x:Name="MegaQueryBlock"
Grid.Row="1"
Grid.Column="1"
Padding="20,11,10,11"
Padding="16,8,10,8"
x:FieldModifier="protected"
CornerRadius="8,0,0,8"
FontSize="40"
FontSize="28"
FontWeight="SemiBold"
/>
<Button
x:Name="MegaFindButton"
Grid.Row="1"
Grid.Column="2"
Width="80"
Height="80"
Width="64"
Height="64"
Padding="12"
x:FieldModifier="protected"
AutomationProperties.HelpText="Search"
Expand Down
4 changes: 2 additions & 2 deletions src/UniGetUI/Pages/SoftwarePages/AbstractPackagesPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1680,14 +1680,14 @@ private void ABSTRACT_PAGE_SizeChanged(object sender, SizeChangedEventArgs e)
if (_pageIsWide != false)
{
_pageIsWide = false;
MainTitle.FontSize = 20;
MainTitle.FontSize = 18;
}
}
else
{
if (_pageIsWide != true)
{
MainTitle.FontSize = 30;
MainTitle.FontSize = 24;
_pageIsWide = true;
}
}
Expand Down
Loading