Skip to content

Commit 6d6b651

Browse files
committed
ui: draw window border on windows
1 parent 8d15c27 commit 6d6b651

File tree

4 files changed

+40
-1
lines changed

4 files changed

+40
-1
lines changed

src/shared/Core/UI/Assets/Base.axaml

+2
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66
<Color x:Key="WindowBackgroundColor">#F6F6F6</Color>
77
<SolidColorBrush x:Key="WindowBackgroundBrush" Color="{StaticResource WindowBackgroundColor}"/>
88
<SolidColorBrush x:Key="DialogWindowCloseButtonBrush" Color="Black"/>
9+
<SolidColorBrush x:Key="DialogWindowBorderBrush" Color="#CCCEDB"/>
910
</ResourceDictionary>
1011

1112
<ResourceDictionary x:Key="Dark">
1213
<Color x:Key="WindowBackgroundColor">#282828</Color>
1314
<SolidColorBrush x:Key="WindowBackgroundBrush" Color="{StaticResource WindowBackgroundColor}"/>
1415
<SolidColorBrush x:Key="DialogWindowCloseButtonBrush" Color="White"/>
16+
<SolidColorBrush x:Key="DialogWindowBorderBrush" Color="#474747"/>
1517
</ResourceDictionary>
1618

1719
</ResourceDictionary.ThemeDictionaries>

src/shared/Core/UI/Controls/DialogWindow.axaml

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
<Design.DataContext>
1919
<vm:WindowViewModel/>
2020
</Design.DataContext>
21-
<Border>
21+
<Border BorderBrush="{DynamicResource DialogWindowBorderBrush}"
22+
BorderThickness="{Binding ShowCustomWindowBorder, Converter={x:Static converters:BoolConvertersEx.ToThickness}}">
2223
<DockPanel>
2324
<DockPanel DockPanel.Dock="Top" HorizontalAlignment="Stretch" Margin="0"
2425
IsVisible="{Binding ShowCustomChrome}">
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,42 @@
1+
using System;
2+
using System.Globalization;
13
using System.Linq;
4+
using Avalonia;
25
using Avalonia.Data.Converters;
36

47
namespace GitCredentialManager.UI.Converters
58
{
69
public static class BoolConvertersEx
710
{
11+
public static readonly IValueConverter ToThickness = new BoolToThicknessConverter();
12+
813
public static readonly IMultiValueConverter Or =
914
new FuncMultiValueConverter<bool,bool>(x => x.Aggregate(false, (a, b) => a || b));
1015

1116
public static readonly IMultiValueConverter And =
1217
new FuncMultiValueConverter<bool,bool>(x => x.Aggregate(true, (a, b) => a && b));
18+
19+
private class BoolToThicknessConverter : IValueConverter
20+
{
21+
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
22+
{
23+
if (value is not bool b)
24+
{
25+
return null;
26+
}
27+
28+
if (parameter is int i)
29+
{
30+
return b ? new Thickness(i) : new Thickness(0);
31+
}
32+
33+
return b ? new Thickness(1) : new Thickness(0);
34+
}
35+
36+
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
37+
{
38+
return null;
39+
}
40+
}
1341
}
1442
}

src/shared/Core/UI/ViewModels/WindowViewModel.cs

+8
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,20 @@ public bool ShowCustomChrome
3535
get => ShowCustomChromeOverride || (ExtendClientArea && !PlatformUtils.IsMacOS());
3636
}
3737

38+
public bool ShowCustomWindowBorder
39+
{
40+
// Draw the window border explicitly on Windows
41+
get => ShowCustomChrome && PlatformUtils.IsWindows();
42+
}
43+
3844
public bool ShowCustomChromeOverride
3945
{
4046
get => _showCustomChromeOverride;
4147
set
4248
{
4349
SetAndRaisePropertyChanged(ref _showCustomChromeOverride, value);
4450
RaisePropertyChanged(nameof(ShowCustomChrome));
51+
RaisePropertyChanged(nameof(ShowCustomWindowBorder));
4552
}
4653
}
4754

@@ -52,6 +59,7 @@ public bool ExtendClientArea
5259
{
5360
SetAndRaisePropertyChanged(ref _extendClientArea, value);
5461
RaisePropertyChanged(nameof(ShowCustomChrome));
62+
RaisePropertyChanged(nameof(ShowCustomWindowBorder));
5563
}
5664
}
5765

0 commit comments

Comments
 (0)