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