Prompt to save unsaved changes to translation stuff

This commit is contained in:
Tim Young 2017-11-01 16:09:06 -05:00
parent 4169aeb35e
commit 09c1fcafc3

View File

@ -27,6 +27,7 @@ namespace EduNetworkBuilder
List<TranslationFormData> FormData = new List<TranslationFormData>(); List<TranslationFormData> FormData = new List<TranslationFormData>();
string EnglishTargetFile = "edustrings.resx"; string EnglishTargetFile = "edustrings.resx";
bool ChangedFormData = false; bool ChangedFormData = false;
bool ChangedPuzzleData = false;
ToolTip myTooltip = new ToolTip(); ToolTip myTooltip = new ToolTip();
@ -180,7 +181,7 @@ namespace EduNetworkBuilder
private void Save() private void Save()
{ {
if (File.Exists(myNet.NetworkFilename)) if (ChangedPuzzleData && File.Exists(myNet.NetworkFilename))
{ {
myNet.Save(); myNet.Save();
//Console.WriteLine("Saved"); //Console.WriteLine("Saved");
@ -206,6 +207,17 @@ namespace EduNetworkBuilder
private void TranslationWindow_FormClosing(object sender, FormClosingEventArgs e) private void TranslationWindow_FormClosing(object sender, FormClosingEventArgs e)
{ {
if(ChangedFormData || ChangedPuzzleData)
{
DialogResult answer = MessageBox.Show("Save?", "Save?", MessageBoxButtons.YesNoCancel);
if(answer == DialogResult.Cancel)
{
e.Cancel = true;
return;
}
if (answer == DialogResult.Yes)
Save();
}
ClosingStuff(); ClosingStuff();
} }
@ -243,8 +255,12 @@ namespace EduNetworkBuilder
string What = CodeFromLang(cb1Language.Text); string What = CodeFromLang(cb1Language.Text);
if (What != "") if (What != "")
{ {
if (tb1Message.Text != myNet.NetMessage.GetText(What))
{
ChangedPuzzleData = true;
myNet.NetMessage.ChangeText(What, tb1Message.Text); myNet.NetMessage.ChangeText(What, tb1Message.Text);
} }
}
RefreshContents(); RefreshContents();
} }
@ -253,8 +269,12 @@ namespace EduNetworkBuilder
string What = CodeFromLang(cb2Language.Text); string What = CodeFromLang(cb2Language.Text);
if (What != "") if (What != "")
{ {
if (tb2Message.Text != myNet.NetMessage.GetText(What))
{
ChangedPuzzleData = true;
myNet.NetMessage.ChangeText(What, tb2Message.Text); myNet.NetMessage.ChangeText(What, tb2Message.Text);
} }
}
RefreshContents(); RefreshContents();
} }
@ -305,7 +325,7 @@ namespace EduNetworkBuilder
#region Form Translation Stuff
//**********************************************************************// //**********************************************************************//
//******************* Form Translation Things **************************// //******************* Form Translation Things **************************//
//**********************************************************************// //**********************************************************************//
@ -554,6 +574,7 @@ namespace EduNetworkBuilder
myTooltip.SetToolTip(cbFormFilter,tooltip); myTooltip.SetToolTip(cbFormFilter,tooltip);
} }
} }
#endregion
#region TranslationClasses #region TranslationClasses
public class TranslationItem public class TranslationItem