mirror of
https://github.com/fadden/6502bench.git
synced 2024-12-29 08:29:52 +00:00
Add change discard confirmation to project properties editor
It's too easy to hit Escape after making a bunch of changes, so now we ask for confirmation. (Might make sense to make this strictly an Esc guard, and not pester the user if they actually hit the Cancel button or close box. I'm not convinced though; Esc+Enter isn't terrible.)
This commit is contained in:
parent
6411df7ff9
commit
6a8d6950e5
@ -25,7 +25,7 @@ limitations under the License.
|
||||
Title="Edit Project Properties"
|
||||
Width="640" Height="400" ResizeMode="NoResize"
|
||||
ShowInTaskbar="False" WindowStartupLocation="CenterOwner"
|
||||
Loaded="Window_Loaded">
|
||||
Loaded="Window_Loaded" Closing="Window_Closing">
|
||||
|
||||
<Window.Resources>
|
||||
<!-- don't center the column headers -->
|
||||
@ -33,6 +33,9 @@ limitations under the License.
|
||||
<Setter Property="HorizontalContentAlignment" Value="Left" />
|
||||
</Style>
|
||||
|
||||
<system:String x:Key="str_ConfirmDiscardChanges">Some changes have not been applied. Discard them?</system:String>
|
||||
<system:String x:Key="str_ConfirmDiscardChangesCaption">Discard Changes?</system:String>
|
||||
|
||||
<!-- strings for combo boxes -->
|
||||
<system:String x:Key="str_6502">MOS 6502</system:String>
|
||||
<system:String x:Key="str_65C02">WDC W65C02S</system:String>
|
||||
|
@ -149,6 +149,18 @@ namespace SourceGen.WpfGui {
|
||||
UpdateControls();
|
||||
}
|
||||
|
||||
private void Window_Closing(object sender, CancelEventArgs e) {
|
||||
if (IsDirty) {
|
||||
string msg = (string)FindResource("str_ConfirmDiscardChanges");
|
||||
string caption = (string)FindResource("str_ConfirmDiscardChangesCaption");
|
||||
MessageBoxResult result = MessageBox.Show(msg, caption, MessageBoxButton.OKCancel,
|
||||
MessageBoxImage.Question);
|
||||
if (result == MessageBoxResult.Cancel) {
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ApplyButton_Click(object sender, RoutedEventArgs e) {
|
||||
NewProps = new ProjectProperties(mWorkProps);
|
||||
IsDirty = false;
|
||||
@ -160,6 +172,7 @@ namespace SourceGen.WpfGui {
|
||||
// insufficient. Might be best to just let the UndoableChange stuff figure out
|
||||
// that nothing changed.
|
||||
NewProps = new ProjectProperties(mWorkProps);
|
||||
IsDirty = false;
|
||||
DialogResult = true;
|
||||
|
||||
//GridView view = (GridView)projectSymbolsListView.View;
|
||||
|
@ -341,7 +341,6 @@ namespace SourceGen.WpfGui {
|
||||
}
|
||||
if (!mMainCtrl.WindowClosing()) {
|
||||
e.Cancel = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user