feat: add a property to show if there is modal dialog available in a host.
This commit is contained in:
@@ -16,8 +16,16 @@
|
|||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
<vm:MainViewViewModel />
|
<vm:MainViewViewModel />
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
|
<Panel>
|
||||||
<Grid ColumnDefinitions="Auto, *" RowDefinitions="Auto, *">
|
<Grid
|
||||||
|
Classes.Blur="{Binding #host.HasModal}"
|
||||||
|
ColumnDefinitions="Auto, *"
|
||||||
|
RowDefinitions="Auto, *">
|
||||||
|
<Grid.Styles>
|
||||||
|
<Style Selector="Grid.Blur">
|
||||||
|
<Setter Property="Effect" Value="blur(20)" />
|
||||||
|
</Style>
|
||||||
|
</Grid.Styles>
|
||||||
<Border
|
<Border
|
||||||
Grid.RowSpan="2"
|
Grid.RowSpan="2"
|
||||||
Padding="8,4"
|
Padding="8,4"
|
||||||
@@ -80,7 +88,7 @@
|
|||||||
<u:ThemeToggleButton
|
<u:ThemeToggleButton
|
||||||
Grid.Row="0"
|
Grid.Row="0"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
HorizontalAlignment="Right"/>
|
HorizontalAlignment="Right" />
|
||||||
<ContentControl
|
<ContentControl
|
||||||
Grid.Row="1"
|
Grid.Row="1"
|
||||||
Grid.Column="1"
|
Grid.Column="1"
|
||||||
@@ -90,7 +98,7 @@
|
|||||||
<converters:ViewLocator />
|
<converters:ViewLocator />
|
||||||
</ContentControl.ContentTemplate>
|
</ContentControl.ContentTemplate>
|
||||||
</ContentControl>
|
</ContentControl>
|
||||||
<u:OverlayDialogHost Grid.Row="0" Grid.Column="0" Grid.RowSpan="2" Grid.ColumnSpan="2" SnapThickness="20"/>
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
<u:OverlayDialogHost Name="host" SnapThickness="20" />
|
||||||
|
</Panel>
|
||||||
</UserControl>
|
</UserControl>
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ public partial class OverlayDialogHost
|
|||||||
Children.Add(mask);
|
Children.Add(mask);
|
||||||
}
|
}
|
||||||
this.Children.Add(control);
|
this.Children.Add(control);
|
||||||
_layers.Add(new DialogPair(mask, control));
|
_layers.Add(new DialogPair(mask, control, false));
|
||||||
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);
|
||||||
@@ -118,6 +118,11 @@ public partial class OverlayDialogHost
|
|||||||
{
|
{
|
||||||
await _maskDisappearAnimation.RunAsync(layer.Mask);
|
await _maskDisappearAnimation.RunAsync(layer.Mask);
|
||||||
Children.Remove(layer.Mask);
|
Children.Remove(layer.Mask);
|
||||||
|
if (layer.Modal)
|
||||||
|
{
|
||||||
|
_modalCount--;
|
||||||
|
HasModal = _modalCount > 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ResetZIndices();
|
ResetZIndices();
|
||||||
@@ -142,6 +147,8 @@ public partial class OverlayDialogHost
|
|||||||
control.AddHandler(OverlayFeedbackElement.ClosedEvent, OnDialogControlClosing);
|
control.AddHandler(OverlayFeedbackElement.ClosedEvent, OnDialogControlClosing);
|
||||||
control.AddHandler(DialogControlBase.LayerChangedEvent, OnDialogLayerChanged);
|
control.AddHandler(DialogControlBase.LayerChangedEvent, OnDialogLayerChanged);
|
||||||
_maskAppearAnimation.RunAsync(mask);
|
_maskAppearAnimation.RunAsync(mask);
|
||||||
|
_modalCount++;
|
||||||
|
HasModal = _modalCount > 0;
|
||||||
control.IsClosed = false;
|
control.IsClosed = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,14 +24,29 @@ public partial class OverlayDialogHost: Canvas
|
|||||||
{
|
{
|
||||||
internal PureRectangle? Mask;
|
internal PureRectangle? Mask;
|
||||||
internal OverlayFeedbackElement Element;
|
internal OverlayFeedbackElement Element;
|
||||||
|
internal bool Modal;
|
||||||
|
|
||||||
public DialogPair(PureRectangle? mask, OverlayFeedbackElement element)
|
public DialogPair(PureRectangle? mask, OverlayFeedbackElement element, bool modal = true)
|
||||||
{
|
{
|
||||||
Mask = mask;
|
Mask = mask;
|
||||||
Element = element;
|
Element = element;
|
||||||
|
Modal = modal;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int _modalCount = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static readonly DirectProperty<OverlayDialogHost, bool> HasModalProperty = AvaloniaProperty.RegisterDirect<OverlayDialogHost, bool>(
|
||||||
|
nameof(HasModal), o => o.HasModal);
|
||||||
|
private bool _hasModal;
|
||||||
|
public bool HasModal
|
||||||
|
{
|
||||||
|
get => _hasModal;
|
||||||
|
private set => SetAndRaise(HasModalProperty, ref _hasModal, value);
|
||||||
|
}
|
||||||
|
|
||||||
static OverlayDialogHost()
|
static OverlayDialogHost()
|
||||||
{
|
{
|
||||||
ClipToBoundsProperty.OverrideDefaultValue<OverlayDialogHost>(true);
|
ClipToBoundsProperty.OverrideDefaultValue<OverlayDialogHost>(true);
|
||||||
|
|||||||
Reference in New Issue
Block a user