done button working
This commit is contained in:
parent
201e42b370
commit
08b7dbd9a1
1
SpriteLibrary/SpriteEntryForm.Designer.cs
generated
1
SpriteLibrary/SpriteEntryForm.Designer.cs
generated
@ -163,6 +163,7 @@
|
||||
this.btnDone.TabIndex = 8;
|
||||
this.btnDone.Text = "Done";
|
||||
this.btnDone.UseVisualStyleBackColor = true;
|
||||
this.btnDone.Click += new System.EventHandler(this.btnDone_Click);
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
|
@ -476,13 +476,35 @@ namespace SpriteLibrary
|
||||
|
||||
}
|
||||
|
||||
void ApplyChanges()
|
||||
int IndexOfName(string spritname)
|
||||
{
|
||||
for(int i=0; i< SpriteInformation.Count; i++)
|
||||
{
|
||||
if (SpriteInformation[i].SpriteName == spritname)
|
||||
return i;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool VerifySpriteBeforeSaving()
|
||||
{
|
||||
if (tbSpriteName.Text == "")
|
||||
{
|
||||
MessageBox.Show("You cannot save a sprite that has no name.");
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
int index = IndexOfName(tbSpriteName.Text);
|
||||
if(index != CurrentSIIndex && index != -1)
|
||||
{
|
||||
MessageBox.Show("You cannot have two sprites with the same name.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void ApplyChanges()
|
||||
{
|
||||
if (!VerifySpriteBeforeSaving()) return;
|
||||
FormToSpriteInformation();
|
||||
if (CurrentSIIndex > 0 && CurrentSIIndex < SpriteInformation.Count)
|
||||
{
|
||||
@ -503,10 +525,9 @@ namespace SpriteLibrary
|
||||
/// <returns></returns>
|
||||
bool PromptToApplyChangesAndContinue()
|
||||
{
|
||||
if (tbSpriteName.Text == "")
|
||||
if (!VerifySpriteBeforeSaving())
|
||||
{
|
||||
MessageBox.Show("You cannot save a sprite that has no name.");
|
||||
return true;
|
||||
return true; //We could not verify, say we canceled out.
|
||||
}
|
||||
if (ValuesDifferFromData())
|
||||
{
|
||||
@ -712,5 +733,13 @@ namespace SpriteLibrary
|
||||
WeHaveNewItem();
|
||||
}
|
||||
}
|
||||
|
||||
private void btnDone_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (PromptToApplyChangesAndContinue())
|
||||
{
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user