2022-11-10 23:54:34 -08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Windows;
|
|
|
|
|
|
|
|
|
|
namespace SourceGit.Views {
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 通用的确认弹出框
|
|
|
|
|
/// </summary>
|
|
|
|
|
public partial class ConfirmDialog : Controls.Window {
|
|
|
|
|
private Action cbOK;
|
|
|
|
|
private Action cbCancel;
|
|
|
|
|
|
2023-08-24 01:20:38 -07:00
|
|
|
|
public ConfirmDialog(string title, string message) {
|
|
|
|
|
Owner = App.Current.MainWindow;
|
|
|
|
|
|
|
|
|
|
cbOK = null;
|
|
|
|
|
cbCancel = null;
|
|
|
|
|
|
2022-11-10 23:54:34 -08:00
|
|
|
|
InitializeComponent();
|
2023-08-24 01:20:38 -07:00
|
|
|
|
|
2022-11-10 23:54:34 -08:00
|
|
|
|
txtTitle.Text = title;
|
|
|
|
|
txtMessage.Text = message;
|
2023-08-24 01:20:38 -07:00
|
|
|
|
btnCancel.Visibility = Visibility.Collapsed;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public ConfirmDialog(string title, string message, Action onOk, Action onCancel = null) {
|
|
|
|
|
Owner = App.Current.MainWindow;
|
2022-11-10 23:54:34 -08:00
|
|
|
|
|
|
|
|
|
cbOK = onOk;
|
|
|
|
|
cbCancel = onCancel;
|
2023-08-24 01:20:38 -07:00
|
|
|
|
|
|
|
|
|
InitializeComponent();
|
|
|
|
|
|
|
|
|
|
txtTitle.Text = title;
|
|
|
|
|
txtMessage.Text = message;
|
|
|
|
|
btnCancel.Visibility = Visibility.Visible;
|
2022-11-10 23:54:34 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnSure(object sender, RoutedEventArgs e) {
|
|
|
|
|
cbOK?.Invoke();
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnQuit(object sender, RoutedEventArgs e) {
|
|
|
|
|
cbCancel?.Invoke();
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|