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>();
string EnglishTargetFile = "edustrings.resx";
bool ChangedFormData = false;
bool ChangedPuzzleData = false;
ToolTip myTooltip = new ToolTip();
@ -180,7 +181,7 @@ namespace EduNetworkBuilder
private void Save()
{
if (File.Exists(myNet.NetworkFilename))
if (ChangedPuzzleData && File.Exists(myNet.NetworkFilename))
{
myNet.Save();
//Console.WriteLine("Saved");
@ -206,6 +207,17 @@ namespace EduNetworkBuilder
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();
}
@ -243,7 +255,11 @@ namespace EduNetworkBuilder
string What = CodeFromLang(cb1Language.Text);
if (What != "")
{
myNet.NetMessage.ChangeText(What,tb1Message.Text);
if (tb1Message.Text != myNet.NetMessage.GetText(What))
{
ChangedPuzzleData = true;
myNet.NetMessage.ChangeText(What, tb1Message.Text);
}
}
RefreshContents();
}
@ -253,7 +269,11 @@ namespace EduNetworkBuilder
string What = CodeFromLang(cb2Language.Text);
if (What != "")
{
myNet.NetMessage.ChangeText(What, tb2Message.Text);
if (tb2Message.Text != myNet.NetMessage.GetText(What))
{
ChangedPuzzleData = true;
myNet.NetMessage.ChangeText(What, tb2Message.Text);
}
}
RefreshContents();
}
@ -305,7 +325,7 @@ namespace EduNetworkBuilder
#region Form Translation Stuff
//**********************************************************************//
//******************* Form Translation Things **************************//
//**********************************************************************//
@ -554,6 +574,7 @@ namespace EduNetworkBuilder
myTooltip.SetToolTip(cbFormFilter,tooltip);
}
}
#endregion
#region TranslationClasses
public class TranslationItem