diff --git a/SpriteLibrary/SpriteEntryForm.cs b/SpriteLibrary/SpriteEntryForm.cs index 8f306fe..41a2827 100644 --- a/SpriteLibrary/SpriteEntryForm.cs +++ b/SpriteLibrary/SpriteEntryForm.cs @@ -410,6 +410,21 @@ namespace SpriteLibrary UpdateMenu(); } + /// + /// Prompt to apply changes. We return true if we continue, or false if we canceled out. + /// + /// + 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)