Revert custom window border on Windows
This commit is contained in:
parent
b34970bd47
commit
f84bb753e9
@ -89,61 +89,13 @@
|
|||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style Selector="dialogs|DialogWindow">
|
<Style Selector="dialogs|DialogWindow">
|
||||||
<Style Selector="^[UseCustomTitleBar=false]">
|
<Setter Property="SystemDecorations" Value="Full"/>
|
||||||
<Setter Property="SystemDecorations" Value="Full"/>
|
<Setter Property="Template">
|
||||||
<Setter Property="Template">
|
<ControlTemplate>
|
||||||
<ControlTemplate>
|
<ContentPresenter Background="{DynamicResource SystemRegionColor}" Content="{TemplateBinding Content}" />
|
||||||
<ContentPresenter Background="{DynamicResource SystemRegionColor}" Content="{TemplateBinding Content}" />
|
</ControlTemplate>
|
||||||
</ControlTemplate>
|
</Setter>
|
||||||
</Setter>
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^[UseCustomTitleBar=true]">
|
|
||||||
<Style Selector="^[CanResize=false] Border#DialogWindowFormBorder">
|
|
||||||
<Setter Property="BorderThickness" Value="2" />
|
|
||||||
</Style>
|
|
||||||
<Setter Property="SystemDecorations" Value="BorderOnly"/>
|
|
||||||
<Setter Property="Template">
|
|
||||||
<ControlTemplate>
|
|
||||||
<Border Name="DialogWindowFormBorder" BorderBrush="{DynamicResource SystemBaseMediumLowColor}" Background="{DynamicResource SystemRegionColor}">
|
|
||||||
<Grid RowDefinitions="30,*">
|
|
||||||
<Border Name="DialogWindowTitleBorder" Margin="5,0" Background="{DynamicResource SystemAltMediumColor}">
|
|
||||||
<Border.Styles>
|
|
||||||
<Style Selector="Button#DialogCloseButton">
|
|
||||||
<Style Selector="^:pointerover">
|
|
||||||
<Style Selector="^ /template/ ContentPresenter#PART_ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="Red" />
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^ Path">
|
|
||||||
<Setter Property="Fill" Value="{DynamicResource IconFill}" />
|
|
||||||
</Style>
|
|
||||||
</Style>
|
|
||||||
<Style Selector="^:not(:pointerover) /template/ ContentPresenter#PART_ContentPresenter">
|
|
||||||
<Setter Property="Background" Value="Transparent" />
|
|
||||||
<Setter Property="BorderBrush" Value="Transparent" />
|
|
||||||
</Style>
|
|
||||||
</Style>
|
|
||||||
</Border.Styles>
|
|
||||||
|
|
||||||
<Grid ColumnDefinitions="Auto,*,Auto">
|
|
||||||
|
|
||||||
<Path Name="DialogWindowTitleIcon" Margin="3,5,0,5" Fill="{DynamicResource IconFill}" Stretch="Uniform" Data="{StaticResource LibationGlassIcon}"/>
|
|
||||||
|
|
||||||
<TextBlock Name="DialogWindowTitleTextBlock" Margin="8,0,0,0" VerticalAlignment="Center" FontWeight="DemiBold" FontSize="12" Grid.Column="1" Text="{TemplateBinding Title}" />
|
|
||||||
|
|
||||||
<Button Name="DialogCloseButton" Grid.Column="2">
|
|
||||||
<Path Fill="{DynamicResource SystemControlBackgroundBaseLowBrush}" VerticalAlignment="Center" Stretch="Uniform" RenderTransform="{StaticResource Rotate45Transform}" Data="{StaticResource CancelButtonIcon}" />
|
|
||||||
</Button>
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
<Path Stroke="{DynamicResource SystemBaseMediumLowColor}" StrokeThickness="1" VerticalAlignment="Bottom" Stretch="Fill" Data="M0,0 L1,0" />
|
|
||||||
<ContentPresenter Grid.Row="1" Content="{TemplateBinding Content}" />
|
|
||||||
</Grid>
|
|
||||||
</Border>
|
|
||||||
</ControlTemplate>
|
|
||||||
</Setter>
|
|
||||||
</Style>
|
|
||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
</Application.Styles>
|
</Application.Styles>
|
||||||
|
|
||||||
<NativeMenu.Menu>
|
<NativeMenu.Menu>
|
||||||
|
|||||||
@ -12,98 +12,34 @@ namespace LibationAvalonia.Dialogs
|
|||||||
{
|
{
|
||||||
protected bool CancelOnEscape { get; set; } = true;
|
protected bool CancelOnEscape { get; set; } = true;
|
||||||
protected bool SaveOnEnter { get; set; } = true;
|
protected bool SaveOnEnter { get; set; } = true;
|
||||||
public bool SaveAndRestorePosition { get; set; } = true;
|
public bool SaveAndRestorePosition { get; set; }
|
||||||
public Control ControlToFocusOnShow { get; set; }
|
public Control ControlToFocusOnShow { get; set; }
|
||||||
protected override Type StyleKeyOverride => typeof(DialogWindow);
|
protected override Type StyleKeyOverride => typeof(DialogWindow);
|
||||||
|
|
||||||
public static readonly StyledProperty<bool> UseCustomTitleBarProperty =
|
public DialogWindow(bool saveAndRestorePosition = true)
|
||||||
AvaloniaProperty.Register<DialogWindow, bool>(nameof(UseCustomTitleBar));
|
|
||||||
|
|
||||||
public bool UseCustomTitleBar
|
|
||||||
{
|
|
||||||
get { return GetValue(UseCustomTitleBarProperty); }
|
|
||||||
set { SetValue(UseCustomTitleBarProperty, value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
public DialogWindow()
|
|
||||||
{
|
{
|
||||||
|
SaveAndRestorePosition = saveAndRestorePosition;
|
||||||
KeyDown += DialogWindow_KeyDown;
|
KeyDown += DialogWindow_KeyDown;
|
||||||
Initialized += DialogWindow_Initialized;
|
Initialized += DialogWindow_Initialized;
|
||||||
Opened += DialogWindow_Opened;
|
Opened += DialogWindow_Opened;
|
||||||
Closing += DialogWindow_Closing;
|
Closing += DialogWindow_Closing;
|
||||||
|
|
||||||
UseCustomTitleBar = Configuration.IsWindows;
|
|
||||||
|
|
||||||
if (Design.IsDesignMode)
|
if (Design.IsDesignMode)
|
||||||
RequestedThemeVariant = ThemeVariant.Dark;
|
RequestedThemeVariant = ThemeVariant.Dark;
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool fixedMinHeight = false;
|
|
||||||
private bool fixedMaxHeight = false;
|
|
||||||
private bool fixedHeight = false;
|
|
||||||
|
|
||||||
protected override void OnPropertyChanged(AvaloniaPropertyChangedEventArgs change)
|
|
||||||
{
|
|
||||||
const int customTitleBarHeight = 30;
|
|
||||||
if (UseCustomTitleBar)
|
|
||||||
{
|
|
||||||
if (change.Property == MinHeightProperty && !fixedMinHeight)
|
|
||||||
{
|
|
||||||
fixedMinHeight = true;
|
|
||||||
MinHeight += customTitleBarHeight;
|
|
||||||
fixedMinHeight = false;
|
|
||||||
}
|
|
||||||
if (change.Property == MaxHeightProperty && !fixedMaxHeight)
|
|
||||||
{
|
|
||||||
fixedMaxHeight = true;
|
|
||||||
MaxHeight += customTitleBarHeight;
|
|
||||||
fixedMaxHeight = false;
|
|
||||||
}
|
|
||||||
if (change.Property == HeightProperty && !fixedHeight)
|
|
||||||
{
|
|
||||||
fixedHeight = true;
|
|
||||||
Height += customTitleBarHeight;
|
|
||||||
fixedHeight = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
base.OnPropertyChanged(change);
|
|
||||||
}
|
|
||||||
|
|
||||||
public DialogWindow(bool saveAndRestorePosition) : this()
|
|
||||||
{
|
|
||||||
SaveAndRestorePosition = saveAndRestorePosition;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
|
||||||
{
|
{
|
||||||
base.OnApplyTemplate(e);
|
base.OnApplyTemplate(e);
|
||||||
|
|
||||||
if (!UseCustomTitleBar)
|
|
||||||
return;
|
|
||||||
|
|
||||||
var closeButton = e.NameScope.Find<Button>("DialogCloseButton");
|
|
||||||
var border = e.NameScope.Get<Border>("DialogWindowTitleBorder");
|
|
||||||
var titleBlock = e.NameScope.Get<TextBlock>("DialogWindowTitleTextBlock");
|
|
||||||
var icon = e.NameScope.Get<Avalonia.Controls.Shapes.Path>("DialogWindowTitleIcon");
|
|
||||||
|
|
||||||
closeButton.Click += CloseButton_Click;
|
|
||||||
border.PointerPressed += Border_PointerPressed;
|
|
||||||
icon.IsVisible = Icon != null;
|
|
||||||
|
|
||||||
if (MinHeight == MaxHeight && MinWidth == MaxWidth)
|
if (MinHeight == MaxHeight && MinWidth == MaxWidth)
|
||||||
{
|
{
|
||||||
CanResize = false;
|
CanResize = false;
|
||||||
border.Margin = new Thickness(0);
|
Height = MinHeight;
|
||||||
icon.Margin = new Thickness(8, 5, 0, 5);
|
Width = MinWidth;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Border_PointerPressed(object sender, Avalonia.Input.PointerPressedEventArgs e)
|
|
||||||
{
|
|
||||||
if (e.GetCurrentPoint(null).Properties.IsLeftButtonPressed)
|
|
||||||
BeginMoveDrag(e);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void CloseButton_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
private void CloseButton_Click(object sender, Avalonia.Interactivity.RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
CancelAndClose();
|
CancelAndClose();
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
mc:Ignorable="d" d:DesignWidth="265" d:DesignHeight="110"
|
mc:Ignorable="d" d:DesignWidth="265" d:DesignHeight="110"
|
||||||
MinWidth="265" MinHeight="110"
|
MinWidth="265" MinHeight="110"
|
||||||
x:Class="LibationAvalonia.Dialogs.MessageBoxWindow"
|
x:Class="LibationAvalonia.Dialogs.MessageBoxWindow"
|
||||||
Title="{Binding Caption}" ShowInTaskbar="True"
|
Title="{Binding Caption}" ShowInTaskbar="True">
|
||||||
Icon="/Assets/1x1.png">
|
|
||||||
<Grid ColumnDefinitions="*" RowDefinitions="*,Auto">
|
<Grid ColumnDefinitions="*" RowDefinitions="*,Auto">
|
||||||
|
|
||||||
<DockPanel Margin="5,10,10,20" Grid.Row="0">
|
<DockPanel Margin="5,10,10,20" Grid.Row="0">
|
||||||
|
|||||||
@ -16,7 +16,7 @@ public partial class ThemePickerDialog : DialogWindow
|
|||||||
protected DataGridCollectionView ThemeColors { get; }
|
protected DataGridCollectionView ThemeColors { get; }
|
||||||
private ChardonnayTheme ExistingTheme { get; } = ChardonnayTheme.GetLiveTheme();
|
private ChardonnayTheme ExistingTheme { get; } = ChardonnayTheme.GetLiveTheme();
|
||||||
|
|
||||||
public ThemePickerDialog() : base(saveAndRestorePosition: false)
|
public ThemePickerDialog()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
CancelOnEscape = false;
|
CancelOnEscape = false;
|
||||||
|
|||||||
@ -128,7 +128,6 @@ public class ChardonnayTheme : IUpdatable, ICloneable
|
|||||||
|
|
||||||
App.Current.Styles.Add(newFluent);
|
App.Current.Styles.Add(newFluent);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary> Get the currently-active theme colors. </summary>
|
/// <summary> Get the currently-active theme colors. </summary>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user