diff --git a/BallanceTasEditor/BallanceTasEditor/BallanceTasEditor.csproj b/BallanceTasEditor/BallanceTasEditor/BallanceTasEditor.csproj
index f14dc7d..a58e4f5 100644
--- a/BallanceTasEditor/BallanceTasEditor/BallanceTasEditor.csproj
+++ b/BallanceTasEditor/BallanceTasEditor/BallanceTasEditor.csproj
@@ -17,13 +17,11 @@
-
-
diff --git a/BallanceTasEditor/BallanceTasEditor/Frontend/Behaviors/ConfirmCloseBehavior.cs b/BallanceTasEditor/BallanceTasEditor/Frontend/Behaviors/ConfirmCloseBehavior.cs
deleted file mode 100644
index 674b2c5..0000000
--- a/BallanceTasEditor/BallanceTasEditor/Frontend/Behaviors/ConfirmCloseBehavior.cs
+++ /dev/null
@@ -1,49 +0,0 @@
-using Microsoft.Xaml.Behaviors;
-using System;
-using System.Collections.Generic;
-using System.ComponentModel;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Documents;
-using System.Windows.Input;
-using System.Windows.Media;
-using System.Windows.Media.Imaging;
-using System.Windows.Navigation;
-using System.Windows.Shapes;
-
-namespace BallanceTasEditor.Frontend.Behaviors {
- public class ConfirmCloseBehavior : Behavior {
-
- public ICommand ConfirmCommand {
- get { return (ICommand)GetValue(ConfirmCommandProperty); }
- set { SetValue(ConfirmCommandProperty, value); }
- }
-
- // Using a DependencyProperty as the backing store for ConfirmCommand. This enables animation, styling, binding, etc...
- public static readonly DependencyProperty ConfirmCommandProperty =
- DependencyProperty.Register("ConfirmCommand", typeof(ICommand), typeof(ConfirmCloseBehavior));
-
-
- protected override void OnAttached() {
- base.OnAttached();
- AssociatedObject.Closing += OnClosing;
- }
-
- protected override void OnDetaching() {
- AssociatedObject.Closing -= OnClosing;
- base.OnDetaching();
- }
-
- private void OnClosing(object? sender, CancelEventArgs e) {
- if (ConfirmCommand?.CanExecute(null) == true) {
- // 假设Command返回 bool 或通过回调/事件通知结果
- bool allowClose = (Func
diff --git a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/AboutDialog.xaml.cs b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/AboutDialog.xaml.cs
index 2dcb93d..cb26afc 100644
--- a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/AboutDialog.xaml.cs
+++ b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/AboutDialog.xaml.cs
@@ -19,6 +19,15 @@ namespace BallanceTasEditor.Frontend.Views {
public partial class AboutDialog : Window {
public AboutDialog() {
InitializeComponent();
+
+ var vm = new ViewModels.AboutDialog();
+ vm.RequestCloseDialog += ViewModel_RequestCloseDialog;
+ this.DataContext = vm;
+ }
+
+ private void ViewModel_RequestCloseDialog(Shared.RequestCloseDialogEventArgs e) {
+ this.DialogResult = e.Result;
+ this.Close();
}
}
}
diff --git a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/AddFrameDialog.xaml b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/AddFrameDialog.xaml
index ff01d53..4961901 100644
--- a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/AddFrameDialog.xaml
+++ b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/AddFrameDialog.xaml
@@ -4,6 +4,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BallanceTasEditor.Frontend.Views"
+ xmlns:vm="clr-namespace:BallanceTasEditor.Frontend.ViewModels"
+ d:DataContext="{d:DesignInstance vm:AddFrameDialog}"
mc:Ignorable="d" WindowStartupLocation="CenterOwner" ResizeMode="NoResize" ShowInTaskbar="False"
Title="Add Frame" Height="250" Width="400" Icon="/Frontend/Assets/AddFrame.ico">
@@ -51,8 +53,10 @@
-
-
+
+
diff --git a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/AddFrameDialog.xaml.cs b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/AddFrameDialog.xaml.cs
index 43d7470..dcb106a 100644
--- a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/AddFrameDialog.xaml.cs
+++ b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/AddFrameDialog.xaml.cs
@@ -19,6 +19,14 @@ namespace BallanceTasEditor.Frontend.Views {
public partial class AddFrameDialog : Window {
public AddFrameDialog() {
InitializeComponent();
+
+ var vm = new ViewModels.AddFrameDialog();
+ vm.RequestCloseDialog += ViewModel_RequestCloseDialog;
+ this.DataContext = vm;
+ }
+ private void ViewModel_RequestCloseDialog(Shared.RequestCloseDialogEventArgs e) {
+ this.DialogResult = e.Result;
+ this.Close();
}
}
}
diff --git a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/EditFpsDialog.xaml b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/EditFpsDialog.xaml
index 41c3875..c440824 100644
--- a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/EditFpsDialog.xaml
+++ b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/EditFpsDialog.xaml
@@ -4,6 +4,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BallanceTasEditor.Frontend.Views"
+ xmlns:vm="clr-namespace:BallanceTasEditor.Frontend.ViewModels"
+ d:DataContext="{d:DesignInstance vm:EditFpsDialog}"
mc:Ignorable="d" WindowStartupLocation="CenterOwner" ResizeMode="NoResize" ShowInTaskbar="False"
Title="Edit FPS" Height="220" Width="400" Icon="/Frontend/Assets/SetFps.ico">
@@ -46,8 +48,10 @@
-
-
+
+
diff --git a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/EditFpsDialog.xaml.cs b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/EditFpsDialog.xaml.cs
index 73d2ef2..d607f70 100644
--- a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/EditFpsDialog.xaml.cs
+++ b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/EditFpsDialog.xaml.cs
@@ -19,6 +19,15 @@ namespace BallanceTasEditor.Frontend.Views {
public partial class EditFpsDialog : Window {
public EditFpsDialog() {
InitializeComponent();
+
+ var vm = new ViewModels.EditFpsDialog();
+ vm.RequestCloseDialog += ViewModel_RequestCloseDialog;
+ this.DataContext = vm;
+ }
+
+ private void ViewModel_RequestCloseDialog(Shared.RequestCloseDialogEventArgs e) {
+ this.DialogResult = e.Result;
+ this.Close();
}
}
}
diff --git a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/GotoDialog.xaml b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/GotoDialog.xaml
index 32d5bdf..872ab38 100644
--- a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/GotoDialog.xaml
+++ b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/GotoDialog.xaml
@@ -4,6 +4,8 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BallanceTasEditor.Frontend.Views"
+ xmlns:vm="clr-namespace:BallanceTasEditor.Frontend.ViewModels"
+ d:DataContext="{d:DesignInstance vm:GotoDialog}"
mc:Ignorable="d" WindowStartupLocation="CenterOwner" ResizeMode="NoResize" ShowInTaskbar="False"
Title="Goto..." Height="180" Width="400" Icon="/Frontend/Assets/Goto.ico">
@@ -26,8 +28,10 @@
-
-
+
+
diff --git a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/GotoDialog.xaml.cs b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/GotoDialog.xaml.cs
index 59006e2..6c8a32e 100644
--- a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/GotoDialog.xaml.cs
+++ b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/GotoDialog.xaml.cs
@@ -19,6 +19,15 @@ namespace BallanceTasEditor.Frontend.Views {
public partial class GotoDialog : Window {
public GotoDialog() {
InitializeComponent();
+
+ var vm = new ViewModels.GotoDialog();
+ vm.RequestCloseDialog += ViewModel_RequestCloseDialog;
+ this.DataContext = vm;
+ }
+
+ private void ViewModel_RequestCloseDialog(Shared.RequestCloseDialogEventArgs e) {
+ this.DialogResult = e.Result;
+ this.Close();
}
}
}
diff --git a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/MainWindow.xaml b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/MainWindow.xaml
index 83bf885..4de0ad8 100644
--- a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/MainWindow.xaml
+++ b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/MainWindow.xaml
@@ -55,7 +55,7 @@
-
+
-
-
+
+
diff --git a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/MainWindow.xaml.cs b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/MainWindow.xaml.cs
index 2288607..318f832 100644
--- a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/MainWindow.xaml.cs
+++ b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/MainWindow.xaml.cs
@@ -20,9 +20,15 @@ namespace BallanceTasEditor.Frontend.Views {
public partial class MainWindow : Window {
public MainWindow() {
InitializeComponent();
- var dialogService = new DialogService(this);
- this.DataContext = new ViewModels.MainWindow(dialogService);
+
+ var dialogService = new Shared.DialogService(this);
+ var vm = new ViewModels.MainWindow(dialogService);
+ vm.RequestCloseWindow += ViewModel_RequestCloseWindow;
+ this.DataContext = vm;
}
+ private void ViewModel_RequestCloseWindow() {
+ this.Close();
+ }
}
}
diff --git a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/NewFileDialog.xaml.cs b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/NewFileDialog.xaml.cs
index c9c016f..f06e880 100644
--- a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/NewFileDialog.xaml.cs
+++ b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/NewFileDialog.xaml.cs
@@ -19,7 +19,15 @@ namespace BallanceTasEditor.Frontend.Views {
public partial class NewFileDialog : Window {
public NewFileDialog() {
InitializeComponent();
- this.DataContext = new ViewModels.NewFileDialog();
+
+ var vm = new ViewModels.NewFileDialog();
+ vm.RequestCloseDialog += ViewModel_RequestCloseDialog;
+ this.DataContext = vm;
+ }
+
+ private void ViewModel_RequestCloseDialog(Shared.RequestCloseDialogEventArgs e) {
+ this.DialogResult = e.Result;
+ this.Close();
}
}
}
diff --git a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/PreferenceDialog.xaml b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/PreferenceDialog.xaml
index 9e69b51..eaed061 100644
--- a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/PreferenceDialog.xaml
+++ b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/PreferenceDialog.xaml
@@ -4,7 +4,9 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:BallanceTasEditor.Frontend.Views"
+ xmlns:vm="clr-namespace:BallanceTasEditor.Frontend.ViewModels"
xmlns:styles="clr-namespace:BallanceTasEditor.Frontend.Styles"
+ d:DataContext="{d:DesignInstance vm:PreferenceDialog}"
mc:Ignorable="d" WindowStartupLocation="CenterOwner" ResizeMode="NoResize" ShowInTaskbar="False"
Title="Editor Preference" Height="450" Width="400" Icon="/Frontend/Assets/Preference.ico">
@@ -57,8 +59,10 @@
-
-
+
+
diff --git a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/PreferenceDialog.xaml.cs b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/PreferenceDialog.xaml.cs
index 8bf5b5d..54d6a40 100644
--- a/BallanceTasEditor/BallanceTasEditor/Frontend/Views/PreferenceDialog.xaml.cs
+++ b/BallanceTasEditor/BallanceTasEditor/Frontend/Views/PreferenceDialog.xaml.cs
@@ -19,6 +19,15 @@ namespace BallanceTasEditor.Frontend.Views {
public partial class PreferenceDialog : Window {
public PreferenceDialog() {
InitializeComponent();
+
+ var vm = new ViewModels.PreferenceDialog();
+ vm.RequestCloseDialog += ViewModel_RequestCloseDialog;
+ this.DataContext = vm;
+ }
+
+ private void ViewModel_RequestCloseDialog(Shared.RequestCloseDialogEventArgs e) {
+ this.DialogResult = e.Result;
+ this.Close();
}
}
}