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

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();
@ -433,63 +448,77 @@ namespace SpriteLibrary
private void btnFwd_Click(object sender, EventArgs e)
{
if (SpriteInformation.Count == 0) return; //nothing to do
CurrentSIIndex++;
if (CurrentSIIndex >= SpriteInformation.Count) CurrentSIIndex = 0;
if (TempInformation == null) TempInformation = new SpriteInfo();
WeHaveNewItem();
if (PromptToApplyChangesAndContinue())
{
if (SpriteInformation.Count == 0) return; //nothing to do
CurrentSIIndex++;
if (CurrentSIIndex >= SpriteInformation.Count) CurrentSIIndex = 0;
if (TempInformation == null) TempInformation = new SpriteInfo();
WeHaveNewItem();
}
}
private void btnBack_Click(object sender, EventArgs e)
{
if (SpriteInformation.Count == 0) return; //nothing to do
CurrentSIIndex--;
if (CurrentSIIndex < 0) CurrentSIIndex = SpriteInformation.Count - 1;
if (TempInformation == null) TempInformation = new SpriteInfo();
WeHaveNewItem();
if (PromptToApplyChangesAndContinue())
{
if (SpriteInformation.Count == 0) return; //nothing to do
CurrentSIIndex--;
if (CurrentSIIndex < 0) CurrentSIIndex = SpriteInformation.Count - 1;
if (TempInformation == null) TempInformation = new SpriteInfo();
WeHaveNewItem();
}
}
private void btnNewSprite_Click(object sender, EventArgs e)
{
TempInformation = null;
CurrentSIIndex = -1;
if (PromptToApplyChangesAndContinue())
{
TempInformation = null;
CurrentSIIndex = -1;
SetUpEmptyInfo();
SpriteInformationToForm();
UpdateMenu();
SetUpEmptyInfo();
SpriteInformationToForm();
UpdateMenu();
}
}
private void btnNewAnimation_Click(object sender, EventArgs e)
{
ApplyChanges();
AnimationInfo AI = TempInformation.Animations[CurrentSIAnimation].Clone();
TempInformation.Animations.Add(AI);
CurrentSIAnimation++;
SpriteInformationToForm();
UpdateMenu();
if (PromptToApplyChangesAndContinue())
{
AnimationInfo AI = TempInformation.Animations[CurrentSIAnimation].Clone();
TempInformation.Animations.Add(AI);
CurrentSIAnimation++;
SpriteInformationToForm();
UpdateMenu();
}
}
private void btnAnimBack_Click(object sender, EventArgs e)
{
ApplyChanges();
CurrentSIAnimation--;
if (CurrentSIAnimation < 0)
CurrentSIAnimation = TempInformation.Animations.Count - 1;
if (PromptToApplyChangesAndContinue())
{
CurrentSIAnimation--;
if (CurrentSIAnimation < 0)
CurrentSIAnimation = TempInformation.Animations.Count - 1;
SpriteInformationToForm();
UpdateMenu();
SpriteInformationToForm();
UpdateMenu();
}
}
private void btnAnimFwd_Click(object sender, EventArgs e)
{
ApplyChanges();
CurrentSIAnimation++;
if (CurrentSIAnimation >=TempInformation.Animations.Count)
CurrentSIAnimation = 0;
SpriteInformationToForm();
UpdateMenu();
if (PromptToApplyChangesAndContinue())
{
CurrentSIAnimation++;
if (CurrentSIAnimation >= TempInformation.Animations.Count)
CurrentSIAnimation = 0;
SpriteInformationToForm();
UpdateMenu();
}
}
private void btnPreview_Click(object sender, EventArgs e)