feat: implement layer change.

This commit is contained in:
rabbitism
2024-01-23 23:29:58 +08:00
parent c8540feeb3
commit b8d258c02a
5 changed files with 103 additions and 18 deletions

View File

@@ -15,10 +15,12 @@ public class DialogControl: ContentControl
public const string PART_CloseButton = "PART_CloseButton";
public const string PART_TitleArea = "PART_TitleArea";
public const string PC_ExtendClientArea = ":extend";
public const string PC_Modal = ":modal";
private Button? _closeButton;
private Panel? _titleArea;
public event EventHandler<object?>? OnClose;
public event EventHandler<DialogLayerChangeEventArgs>? OnLayerChange;
public static readonly StyledProperty<string?> TitleProperty = AvaloniaProperty.Register<DialogControl, string?>(
nameof(Title));
@@ -93,7 +95,7 @@ public class DialogControl: ContentControl
public Task<T> ShowAsync<T>()
{
var tcs = new TaskCompletionSource<T>();
PseudoClasses.Set(PC_Modal, true);
void OnCloseHandler(object sender, object? args)
{
if (args is T result)
@@ -124,4 +126,24 @@ public class DialogControl: ContentControl
OnClose?.Invoke(this, null);
}
}
public void BringForward()
{
OnLayerChange?.Invoke(this, new DialogLayerChangeEventArgs(DialogLayerChangeType.BringForward));
}
public void SendBackward()
{
OnLayerChange?.Invoke(this, new DialogLayerChangeEventArgs(DialogLayerChangeType.SendBackward));
}
public void BringToFront()
{
OnLayerChange?.Invoke(this, new DialogLayerChangeEventArgs(DialogLayerChangeType.BringToFront));
}
public void SendToBack()
{
OnLayerChange?.Invoke(this, new DialogLayerChangeEventArgs(DialogLayerChangeType.SendToBack));
}
}