use prompt for saving when moving around

This commit is contained in:
Tim Young 2017-09-19 13:19:46 -05:00
parent 005c35761c
commit 6e2661a648
1 changed files with 63 additions and 34 deletions

View File

@ -410,6 +410,21 @@ namespace SpriteLibrary
UpdateMenu();
}
/// <summary>
/// Prompt to apply changes. We return true if we continue, or false if we canceled out.
/// </summary>
/// <returns></returns>
bool PromptToApplyChangesAndContinue()
{
if(ValuesDifferFromData())
{
DialogResult Answer = MessageBox.Show("You have unsaved Changes. Would you like to save them before proceeding?","Save?",MessageBoxButtons.YesNoCancel);
if (Answer == DialogResult.Yes) ApplyChanges();
if (Answer == DialogResult.Cancel) return false;
}
return true;
}
private void btnApply_Click(object sender, EventArgs e)
{
ApplyChanges();
@ -432,6 +447,8 @@ namespace SpriteLibrary
}
private void btnFwd_Click(object sender, EventArgs e)
{
if (PromptToApplyChangesAndContinue())
{
if (SpriteInformation.Count == 0) return; //nothing to do
CurrentSIIndex++;
@ -439,8 +456,11 @@ namespace SpriteLibrary
if (TempInformation == null) TempInformation = new SpriteInfo();
WeHaveNewItem();
}
}
private void btnBack_Click(object sender, EventArgs e)
{
if (PromptToApplyChangesAndContinue())
{
if (SpriteInformation.Count == 0) return; //nothing to do
CurrentSIIndex--;
@ -448,8 +468,11 @@ namespace SpriteLibrary
if (TempInformation == null) TempInformation = new SpriteInfo();
WeHaveNewItem();
}
}
private void btnNewSprite_Click(object sender, EventArgs e)
{
if (PromptToApplyChangesAndContinue())
{
TempInformation = null;
CurrentSIIndex = -1;
@ -458,20 +481,24 @@ namespace SpriteLibrary
SpriteInformationToForm();
UpdateMenu();
}
}
private void btnNewAnimation_Click(object sender, EventArgs e)
{
ApplyChanges();
if (PromptToApplyChangesAndContinue())
{
AnimationInfo AI = TempInformation.Animations[CurrentSIAnimation].Clone();
TempInformation.Animations.Add(AI);
CurrentSIAnimation++;
SpriteInformationToForm();
UpdateMenu();
}
}
private void btnAnimBack_Click(object sender, EventArgs e)
{
ApplyChanges();
if (PromptToApplyChangesAndContinue())
{
CurrentSIAnimation--;
if (CurrentSIAnimation < 0)
CurrentSIAnimation = TempInformation.Animations.Count - 1;
@ -479,17 +506,19 @@ namespace SpriteLibrary
SpriteInformationToForm();
UpdateMenu();
}
}
private void btnAnimFwd_Click(object sender, EventArgs e)
{
ApplyChanges();
if (PromptToApplyChangesAndContinue())
{
CurrentSIAnimation++;
if (CurrentSIAnimation >= TempInformation.Animations.Count)
CurrentSIAnimation = 0;
SpriteInformationToForm();
UpdateMenu();
}
}
private void btnPreview_Click(object sender, EventArgs e)