diff --git a/src/Views/ConfirmDialog.xaml b/src/Views/ConfirmDialog.xaml
new file mode 100644
index 00000000..b660f616
--- /dev/null
+++ b/src/Views/ConfirmDialog.xaml
@@ -0,0 +1,80 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Views/ConfirmDialog.xaml.cs b/src/Views/ConfirmDialog.xaml.cs
new file mode 100644
index 00000000..f883e91f
--- /dev/null
+++ b/src/Views/ConfirmDialog.xaml.cs
@@ -0,0 +1,33 @@
+using System;
+using System.Windows;
+
+namespace SourceGit.Views {
+
+ ///
+ /// 通用的确认弹出框
+ ///
+ public partial class ConfirmDialog : Controls.Window {
+ private Action cbOK;
+ private Action cbCancel;
+
+ public ConfirmDialog(string title, string message, Action onOk, Action onCancel = null) {
+ InitializeComponent();
+
+ txtTitle.Text = title;
+ txtMessage.Text = message;
+
+ cbOK = onOk;
+ cbCancel = onCancel;
+ }
+
+ private void OnSure(object sender, RoutedEventArgs e) {
+ cbOK?.Invoke();
+ Close();
+ }
+
+ private void OnQuit(object sender, RoutedEventArgs e) {
+ cbCancel?.Invoke();
+ Close();
+ }
+ }
+}
diff --git a/src/Views/Widgets/Welcome.xaml b/src/Views/Widgets/Welcome.xaml
index cd9480d9..7065ca6f 100644
--- a/src/Views/Widgets/Welcome.xaml
+++ b/src/Views/Widgets/Welcome.xaml
@@ -4,7 +4,6 @@
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:controls="clr-namespace:SourceGit.Views.Controls"
- xmlns:widgets="clr-namespace:SourceGit.Views.Widgets"
xmlns:models="clr-namespace:SourceGit.Models"
xmlns:converters="clr-namespace:SourceGit.Views.Converters"
mc:Ignorable="d"
@@ -139,7 +138,7 @@
-
+
@@ -159,7 +158,6 @@
-
diff --git a/src/Views/Widgets/Welcome.xaml.cs b/src/Views/Widgets/Welcome.xaml.cs
index 490b9be2..39ef35c1 100644
--- a/src/Views/Widgets/Welcome.xaml.cs
+++ b/src/Views/Widgets/Welcome.xaml.cs
@@ -91,12 +91,15 @@ namespace SourceGit.Views.Widgets {
var repo = (sender as Button).DataContext as Models.Repository;
if (repo == null) return;
- var result = MessageBox.Show(App.Text("ConfirmRemoveRepo", repo.Path), App.Text("Apply.Warn"), MessageBoxButton.YesNo);
- if (result == MessageBoxResult.Yes) {
- Models.Preference.Instance.RemoveRepository(repo.Path);
- UpdateVisibles();
- }
-
+ var confirmDialog = new ConfirmDialog(
+ App.Text("Apply.Warn"),
+ App.Text("ConfirmRemoveRepo", repo.Path),
+ () => {
+ Models.Preference.Instance.RemoveRepository(repo.Path);
+ UpdateVisibles();
+ });
+ confirmDialog.Owner = App.Current.MainWindow;
+ confirmDialog.ShowDialog();
e.Handled = true;
}