Dispenser/DispenserUI/Views/Windows/ConfirmDialogWindow.axaml.cs

71 lines
1.9 KiB
C#
Raw Normal View History

2024-08-16 07:20:09 +00:00
using Avalonia;
using Avalonia.Controls;
using Avalonia.Interactivity;
namespace DispenserUI.Views.Windows;
/// <summary>
/// 确认弹窗
/// </summary>
public partial class ConfirmDialogWindow : Window
{
public static readonly StyledProperty<bool> ShowCancelProperty =
AvaloniaProperty.Register<ConfirmDialogWindow, bool>(nameof(ShowCancel), true);
public static readonly StyledProperty<bool> ShowConfirmProperty =
AvaloniaProperty.Register<ConfirmDialogWindow, bool>(nameof(ShowConfirm), true);
public static readonly StyledProperty<string> ContentProperty =
AvaloniaProperty.Register<ConfirmDialogWindow, string>(nameof(Content), "");
public static readonly StyledProperty<string> CancelTextProperty =
AvaloniaProperty.Register<ConfirmDialogWindow, string>(nameof(CancelText), "取消");
public static readonly StyledProperty<string> ConfirmTextProperty =
AvaloniaProperty.Register<ConfirmDialogWindow, string>(nameof(ConfirmText), "确认");
public string Content
{
get => GetValue(ContentProperty);
set => SetValue(ContentProperty, value);
}
public bool ShowCancel
{
get => GetValue(ShowCancelProperty);
set => SetValue(ShowCancelProperty, value);
}
public bool ShowConfirm
{
get => GetValue(ShowConfirmProperty);
set => SetValue(ShowConfirmProperty, value);
}
public string ConfirmText
{
get => GetValue(ConfirmTextProperty);
set => SetValue(ConfirmTextProperty, value);
}
public string CancelText
{
get => GetValue(CancelTextProperty);
set => SetValue(CancelTextProperty, value);
}
public ConfirmDialogWindow()
{
InitializeComponent();
}
private void Cancel(object? sender, RoutedEventArgs e)
{
Close(false);
}
private void Confirm(object? sender, RoutedEventArgs e)
{
Close(true);
}
}