feat: support full screen.
This commit is contained in:
@@ -39,12 +39,17 @@
|
||||
IsChecked="{Binding CanLightDismiss}"
|
||||
OffContent="No"
|
||||
OnContent="Yes" />
|
||||
<ToggleSwitch
|
||||
Content="FullScreen"
|
||||
IsChecked="{Binding FullScreen}"
|
||||
OffContent="No"
|
||||
OnContent="Yes" />
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Buttons" VerticalAlignment="Center" />
|
||||
<TextBlock VerticalAlignment="Center" Text="Buttons" />
|
||||
<u:EnumSelector EnumType="{x:Type u:DialogButton}" Value="{Binding SelectedButton}" />
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<TextBlock Text="Mode" VerticalAlignment="Center" />
|
||||
<TextBlock VerticalAlignment="Center" Text="Mode" />
|
||||
<u:EnumSelector EnumType="{x:Type u:DialogMode}" Value="{Binding SelectedMode}" />
|
||||
</StackPanel>
|
||||
<Button Command="{Binding ShowDialogCommand}" Content="Show Dialog" />
|
||||
@@ -83,6 +88,11 @@
|
||||
IsChecked="{Binding CanLightDismiss}"
|
||||
OffContent="No"
|
||||
OnContent="Yes" />
|
||||
<ToggleSwitch
|
||||
Content="FullScreen"
|
||||
IsChecked="{Binding FullScreen}"
|
||||
OffContent="No"
|
||||
OnContent="Yes" />
|
||||
<Button Command="{Binding ShowCustomDialogCommand}" Content="Show Dialog" />
|
||||
<TextBlock>
|
||||
<Run Text="Custom Result: " />
|
||||
|
||||
@@ -25,6 +25,7 @@ public partial class DialogDemoViewModel: ObservableObject
|
||||
[ObservableProperty] private DialogResult? _defaultResult;
|
||||
[ObservableProperty] private bool _result;
|
||||
[ObservableProperty] private DateTime? _date;
|
||||
[ObservableProperty] private bool _fullScreen;
|
||||
|
||||
public DialogDemoViewModel()
|
||||
{
|
||||
@@ -65,6 +66,7 @@ public partial class DialogDemoViewModel: ObservableObject
|
||||
HorizontalOffset = 50,
|
||||
VerticalAnchor = VerticalPosition.Top,
|
||||
VerticalOffset = 50,
|
||||
FullScreen = FullScreen,
|
||||
}
|
||||
);
|
||||
Date = vm.Date;
|
||||
@@ -80,6 +82,7 @@ public partial class DialogDemoViewModel: ObservableObject
|
||||
Mode = SelectedMode,
|
||||
Buttons = SelectedButton,
|
||||
CanLightDismiss = CanLightDismiss,
|
||||
FullScreen = FullScreen,
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -111,6 +114,7 @@ public partial class DialogDemoViewModel: ObservableObject
|
||||
vm, IsGlobal ? null : "LocalHost", options: new OverlayDialogOptions()
|
||||
{
|
||||
CanLightDismiss = CanLightDismiss,
|
||||
FullScreen = FullScreen,
|
||||
});
|
||||
Date = vm.Date;
|
||||
}
|
||||
@@ -118,7 +122,7 @@ public partial class DialogDemoViewModel: ObservableObject
|
||||
{
|
||||
OverlayDialog.ShowCustom<DialogWithAction, DialogWithActionViewModel>(new DialogWithActionViewModel(),
|
||||
IsGlobal ? null : "LocalHost",
|
||||
options: new OverlayDialogOptions{ CanLightDismiss = CanLightDismiss });
|
||||
options: new OverlayDialogOptions{ CanLightDismiss = CanLightDismiss, FullScreen = FullScreen});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:CustomDialogControl">
|
||||
<Border
|
||||
Margin="8"
|
||||
Name="PART_Border"
|
||||
Padding="0"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
@@ -52,8 +52,15 @@
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^[IsClosed=True]">
|
||||
<Setter Property="RenderTransform" Value="scale(0.95)"/>
|
||||
<Style Selector="^:full-screen">
|
||||
<Setter Property="CornerRadius" Value="0"/>
|
||||
<Style Selector="^ /template/ Border#PART_Border">
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="Theme" Value="{x:Null}"/>
|
||||
<Setter Property="Margin" Value="0"/>
|
||||
<Setter Property="Background" Value="{DynamicResource BorderCardBackground}"></Setter>
|
||||
</Style>
|
||||
</Style>
|
||||
<Style Selector="^ /template/ Panel#PART_TitleArea">
|
||||
<Setter Property="ContextFlyout">
|
||||
@@ -143,10 +150,10 @@
|
||||
<Setter Property="Template">
|
||||
<ControlTemplate TargetType="u:DefaultDialogControl">
|
||||
<Border
|
||||
Margin="10"
|
||||
Name="PART_Border"
|
||||
Padding="0"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
HorizontalAlignment="{TemplateBinding HorizontalAlignment}"
|
||||
VerticalAlignment="{TemplateBinding VerticalAlignment}"
|
||||
BoxShadow="0 0 8 0 #1A000000"
|
||||
Classes="Shadow"
|
||||
ClipToBounds="False"
|
||||
@@ -159,6 +166,8 @@
|
||||
<ContentPresenter
|
||||
Name="PART_ContentPresenter"
|
||||
Grid.Row="1"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalAlignment="Center"
|
||||
Margin="24,8"
|
||||
Content="{TemplateBinding Content}" />
|
||||
</ScrollViewer>
|
||||
@@ -228,8 +237,15 @@
|
||||
</Border>
|
||||
</ControlTemplate>
|
||||
</Setter>
|
||||
<Style Selector="^[IsClosed=True]">
|
||||
<Setter Property="RenderTransform" Value="scale(0.95)"/>
|
||||
<Style Selector="^:full-screen">
|
||||
<Setter Property="CornerRadius" Value="0"/>
|
||||
</Style>
|
||||
<Style Selector="^:full-screen /template/ Border#PART_Border">
|
||||
<Setter Property="HorizontalAlignment" Value="Stretch"/>
|
||||
<Setter Property="VerticalAlignment" Value="Stretch"/>
|
||||
<Setter Property="Theme" Value="{x:Null}"/>
|
||||
<Setter Property="Margin" Value="0"></Setter>
|
||||
<Setter Property="Background" Value="{DynamicResource BorderCardBackground}"></Setter>
|
||||
</Style>
|
||||
<Style Selector="^[Mode=None]">
|
||||
<Style Selector="^ /template/ PathIcon#PART_Icon">
|
||||
|
||||
@@ -14,12 +14,13 @@ namespace Ursa.Controls;
|
||||
|
||||
[TemplatePart(PART_CloseButton, typeof(Button))]
|
||||
[TemplatePart(PART_TitleArea, typeof(Panel))]
|
||||
[PseudoClasses(PC_Modal)]
|
||||
[PseudoClasses(PC_Modal, PC_FullScreen)]
|
||||
public abstract class DialogControlBase : OverlayFeedbackElement
|
||||
{
|
||||
public const string PART_CloseButton = "PART_CloseButton";
|
||||
public const string PART_TitleArea = "PART_TitleArea";
|
||||
public const string PC_Modal = ":modal";
|
||||
public const string PC_FullScreen = ":full-screen";
|
||||
|
||||
internal HorizontalPosition HorizontalAnchor { get; set; } = HorizontalPosition.Center;
|
||||
internal VerticalPosition VerticalAnchor { get; set; } = VerticalPosition.Center;
|
||||
@@ -31,6 +32,17 @@ public abstract class DialogControlBase : OverlayFeedbackElement
|
||||
internal double? VerticalOffsetRatio { get; set; }
|
||||
internal bool CanLightDismiss { get; set; }
|
||||
|
||||
private bool _isFullScreen;
|
||||
|
||||
public static readonly DirectProperty<DialogControlBase, bool> IsFullScreenProperty = AvaloniaProperty.RegisterDirect<DialogControlBase, bool>(
|
||||
nameof(IsFullScreen), o => o.IsFullScreen, (o, v) => o.IsFullScreen = v);
|
||||
|
||||
public bool IsFullScreen
|
||||
{
|
||||
get => _isFullScreen;
|
||||
set => SetAndRaise(IsFullScreenProperty, ref _isFullScreen, value);
|
||||
}
|
||||
|
||||
protected internal Button? _closeButton;
|
||||
private Panel? _titleArea;
|
||||
|
||||
@@ -133,6 +145,7 @@ public abstract class DialogControlBase : OverlayFeedbackElement
|
||||
{
|
||||
CanDragMoveProperty.Changed.AddClassHandler<InputElement, bool>(OnCanDragMoveChanged);
|
||||
CanCloseProperty.Changed.AddClassHandler<InputElement, bool>(OnCanCloseChanged);
|
||||
IsFullScreenProperty.AffectsPseudoClass<DialogControlBase>(PC_FullScreen);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ public enum VerticalPosition
|
||||
public class OverlayDialogOptions
|
||||
{
|
||||
internal static OverlayDialogOptions Default { get; } = new OverlayDialogOptions();
|
||||
public bool FullScreen { get; set; }
|
||||
public HorizontalPosition HorizontalAnchor { get; set; } = HorizontalPosition.Center;
|
||||
public VerticalPosition VerticalAnchor { get; set; } = VerticalPosition.Center;
|
||||
/// <summary>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Layout;
|
||||
using Ursa.Common;
|
||||
|
||||
namespace Ursa.Controls;
|
||||
@@ -181,6 +182,12 @@ public static class OverlayDialog
|
||||
private static void ConfigureCustomDialogControl(CustomDialogControl control, OverlayDialogOptions? options)
|
||||
{
|
||||
options ??= OverlayDialogOptions.Default;
|
||||
control.IsFullScreen = options.FullScreen;
|
||||
if (options.FullScreen)
|
||||
{
|
||||
control.HorizontalAlignment = HorizontalAlignment.Stretch;
|
||||
control.VerticalAlignment = VerticalAlignment.Stretch;
|
||||
}
|
||||
control.HorizontalAnchor = options.HorizontalAnchor;
|
||||
control.VerticalAnchor = options.VerticalAnchor;
|
||||
control.ActualHorizontalAnchor = options.HorizontalAnchor;
|
||||
@@ -197,6 +204,12 @@ public static class OverlayDialog
|
||||
private static void ConfigureDefaultDialogControl(DefaultDialogControl control, OverlayDialogOptions? options)
|
||||
{
|
||||
if (options is null) options = new OverlayDialogOptions();
|
||||
control.IsFullScreen = options.FullScreen;
|
||||
if (options.FullScreen)
|
||||
{
|
||||
control.HorizontalAlignment = HorizontalAlignment.Stretch;
|
||||
control.VerticalAlignment = VerticalAlignment.Stretch;
|
||||
}
|
||||
control.HorizontalAnchor = options.HorizontalAnchor;
|
||||
control.VerticalAnchor = options.VerticalAnchor;
|
||||
control.ActualHorizontalAnchor = options.HorizontalAnchor;
|
||||
|
||||
@@ -133,6 +133,11 @@ public partial class OverlayDialogHost
|
||||
ResetZIndices();
|
||||
this.Children.Add(mask);
|
||||
this.Children.Add(control);
|
||||
if (control.IsFullScreen)
|
||||
{
|
||||
control.Width = Bounds.Width;
|
||||
control.Height = Bounds.Height;
|
||||
}
|
||||
control.Measure(this.Bounds.Size);
|
||||
control.Arrange(new Rect(control.DesiredSize));
|
||||
SetToPosition(control);
|
||||
|
||||
Reference in New Issue
Block a user