mirror of
https://github.com/fadden/6502bench.git
synced 2024-11-29 10:50:28 +00:00
Upgrade "discard changes" dialog
Was a yes/no MessageBox, now it's a three-way with the option to save your changes before continuing.
This commit is contained in:
parent
5b1dde290a
commit
a7e6b101c4
119
SourceGen/AppForms/DiscardChanges.Designer.cs
generated
Normal file
119
SourceGen/AppForms/DiscardChanges.Designer.cs
generated
Normal file
@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright 2018 faddenSoft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
namespace SourceGen.AppForms {
|
||||
partial class DiscardChanges {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.cancelButton = new System.Windows.Forms.Button();
|
||||
this.dontSaveButton = new System.Windows.Forms.Button();
|
||||
this.saveButton = new System.Windows.Forms.Button();
|
||||
this.warningLabel = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// cancelButton
|
||||
//
|
||||
this.cancelButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.cancelButton.Location = new System.Drawing.Point(243, 74);
|
||||
this.cancelButton.Name = "cancelButton";
|
||||
this.cancelButton.Size = new System.Drawing.Size(110, 23);
|
||||
this.cancelButton.TabIndex = 3;
|
||||
this.cancelButton.Text = "Cancel";
|
||||
this.cancelButton.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// dontSaveButton
|
||||
//
|
||||
this.dontSaveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dontSaveButton.Location = new System.Drawing.Point(127, 74);
|
||||
this.dontSaveButton.Name = "dontSaveButton";
|
||||
this.dontSaveButton.Size = new System.Drawing.Size(110, 23);
|
||||
this.dontSaveButton.TabIndex = 2;
|
||||
this.dontSaveButton.Text = "&Discard && Continue";
|
||||
this.dontSaveButton.UseVisualStyleBackColor = true;
|
||||
this.dontSaveButton.Click += new System.EventHandler(this.dontSaveButton_Click);
|
||||
//
|
||||
// saveButton
|
||||
//
|
||||
this.saveButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.saveButton.Location = new System.Drawing.Point(11, 74);
|
||||
this.saveButton.Name = "saveButton";
|
||||
this.saveButton.Size = new System.Drawing.Size(110, 23);
|
||||
this.saveButton.TabIndex = 1;
|
||||
this.saveButton.Text = "&Save && Continue";
|
||||
this.saveButton.UseVisualStyleBackColor = true;
|
||||
this.saveButton.Click += new System.EventHandler(this.saveButton_Click);
|
||||
//
|
||||
// warningLabel
|
||||
//
|
||||
this.warningLabel.AutoSize = true;
|
||||
this.warningLabel.Location = new System.Drawing.Point(13, 13);
|
||||
this.warningLabel.Name = "warningLabel";
|
||||
this.warningLabel.Size = new System.Drawing.Size(288, 39);
|
||||
this.warningLabel.TabIndex = 0;
|
||||
this.warningLabel.Text = "You have unsaved changes that will be lost if you continue.\r\n\r\nHow do you wish to" +
|
||||
" proceed?";
|
||||
//
|
||||
// DiscardChanges
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.CancelButton = this.cancelButton;
|
||||
this.ClientSize = new System.Drawing.Size(365, 109);
|
||||
this.Controls.Add(this.warningLabel);
|
||||
this.Controls.Add(this.saveButton);
|
||||
this.Controls.Add(this.dontSaveButton);
|
||||
this.Controls.Add(this.cancelButton);
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "DiscardChanges";
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "Discard Changes?";
|
||||
this.Load += new System.EventHandler(this.DiscardChanges_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button cancelButton;
|
||||
private System.Windows.Forms.Button dontSaveButton;
|
||||
private System.Windows.Forms.Button saveButton;
|
||||
private System.Windows.Forms.Label warningLabel;
|
||||
}
|
||||
}
|
48
SourceGen/AppForms/DiscardChanges.cs
Normal file
48
SourceGen/AppForms/DiscardChanges.cs
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright 2018 faddenSoft
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace SourceGen.AppForms {
|
||||
/// <summary>
|
||||
/// Prompt the user before discarding changes.
|
||||
///
|
||||
/// Dialog result will be:
|
||||
/// DialogResult.Yes: save before continuing
|
||||
/// DialogResult.No: don't save before continuing
|
||||
/// DialogResult.Cancel: don't continue
|
||||
/// </summary>
|
||||
public partial class DiscardChanges : Form {
|
||||
public DiscardChanges() {
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private void DiscardChanges_Load(object sender, EventArgs e) {
|
||||
// Make this the default.
|
||||
cancelButton.Select();
|
||||
}
|
||||
|
||||
private void saveButton_Click(object sender, EventArgs e) {
|
||||
DialogResult = DialogResult.Yes;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void dontSaveButton_Click(object sender, EventArgs e) {
|
||||
DialogResult = DialogResult.No;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
120
SourceGen/AppForms/DiscardChanges.resx
Normal file
120
SourceGen/AppForms/DiscardChanges.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -1495,20 +1495,18 @@ namespace SourceGen.AppForms {
|
||||
}
|
||||
|
||||
// File > Save (Ctrl+S)
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||
if (string.IsNullOrEmpty(mProjectPathName)) {
|
||||
saveAsToolStripMenuItem_Click(sender, e);
|
||||
return;
|
||||
}
|
||||
|
||||
DoSave(mProjectPathName);
|
||||
}
|
||||
private void saveToolStripButton_Click(object sender, EventArgs e) {
|
||||
saveToolStripMenuItem_Click(sender, e);
|
||||
}
|
||||
|
||||
private void saveToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||
DoSave();
|
||||
}
|
||||
// File > Save As...
|
||||
private void saveAsToolStripMenuItem_Click(object sender, EventArgs e) {
|
||||
DoSaveAs();
|
||||
}
|
||||
|
||||
private bool DoSaveAs() {
|
||||
SaveFileDialog fileDlg = new SaveFileDialog() {
|
||||
Filter = ProjectFile.FILENAME_FILTER + "|" + Properties.Resources.FILE_FILTER_ALL,
|
||||
FilterIndex = 1,
|
||||
@ -1525,8 +1523,18 @@ namespace SourceGen.AppForms {
|
||||
|
||||
// add it to the title bar
|
||||
UpdateMenuItemsAndTitle();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Save the project. If it hasn't been saved before, use save-as behavior instead.
|
||||
private bool DoSave() {
|
||||
if (string.IsNullOrEmpty(mProjectPathName)) {
|
||||
return DoSaveAs();
|
||||
}
|
||||
return DoSave(mProjectPathName);
|
||||
}
|
||||
|
||||
private bool DoSave(string pathName) {
|
||||
@ -1588,11 +1596,14 @@ namespace SourceGen.AppForms {
|
||||
Debug.WriteLine("ProjectView.DoClose() - dirty=" +
|
||||
(mProject == null ? "N/A" : mProject.IsDirty.ToString()));
|
||||
if (mProject != null && mProject.IsDirty) {
|
||||
DialogResult result = MessageBox.Show(this, Properties.Resources.UNSAVED_CHANGES,
|
||||
Properties.Resources.UNSAVED_CHANGES_CAPTION, MessageBoxButtons.OKCancel,
|
||||
MessageBoxIcon.Warning, MessageBoxDefaultButton.Button2);
|
||||
DiscardChanges dlg = new DiscardChanges();
|
||||
DialogResult result = dlg.ShowDialog(this);
|
||||
if (result == DialogResult.Cancel) {
|
||||
return false;
|
||||
} else if (result == DialogResult.Yes) {
|
||||
if (!DoSave()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
18
SourceGen/Properties/Resources.Designer.cs
generated
18
SourceGen/Properties/Resources.Designer.cs
generated
@ -996,24 +996,6 @@ namespace SourceGen.Properties {
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to The current project has unsaved changes that will be lost. Are you sure you wish to continue?.
|
||||
/// </summary>
|
||||
internal static string UNSAVED_CHANGES {
|
||||
get {
|
||||
return ResourceManager.GetString("UNSAVED_CHANGES", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to Unsaved Changes.
|
||||
/// </summary>
|
||||
internal static string UNSAVED_CHANGES_CAPTION {
|
||||
get {
|
||||
return ResourceManager.GetString("UNSAVED_CHANGES_CAPTION", resourceCulture);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Looks up a localized string similar to [unset].
|
||||
/// </summary>
|
||||
|
@ -429,12 +429,6 @@
|
||||
<data name="TITLE_NEW_PROJECT" xml:space="preserve">
|
||||
<value>[new project]</value>
|
||||
</data>
|
||||
<data name="UNSAVED_CHANGES" xml:space="preserve">
|
||||
<value>The current project has unsaved changes that will be lost. Are you sure you wish to continue?</value>
|
||||
</data>
|
||||
<data name="UNSAVED_CHANGES_CAPTION" xml:space="preserve">
|
||||
<value>Unsaved Changes</value>
|
||||
</data>
|
||||
<data name="UNSET" xml:space="preserve">
|
||||
<value>[unset]</value>
|
||||
</data>
|
||||
|
@ -71,6 +71,12 @@
|
||||
<Compile Include="AppForms\AboutBox.Designer.cs">
|
||||
<DependentUpon>AboutBox.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="AppForms\DiscardChanges.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="AppForms\DiscardChanges.Designer.cs">
|
||||
<DependentUpon>DiscardChanges.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="AppForms\EditAppSettings.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
@ -269,6 +275,9 @@
|
||||
<EmbeddedResource Include="AppForms\AboutBox.resx">
|
||||
<DependentUpon>AboutBox.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="AppForms\DiscardChanges.resx">
|
||||
<DependentUpon>DiscardChanges.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="AppForms\EditAppSettings.resx">
|
||||
<DependentUpon>EditAppSettings.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
|
Loading…
Reference in New Issue
Block a user