private void saveToolStripMenuItem_Click(object sender, EventArgs e) { bool nameisgood; //prompt for name do { nameisgood = true; if (aPromtForm == null) { aPromtForm = new PromtForm("Palette Name", "", "Cancel", "Save Palette"); } aPromtForm.ShowDialog(this); if (aPromtForm.SafeData) { foreach (object palette in Global.ListOfPalettes) { if (((PaletteLayout)palette).Name.Trim() == aPromtForm.ReturnValue.Trim()) { nameisgood = false; MessageBox.Show("That name is already taken, try something else", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { break; } } while (!nameisgood); if (aPromtForm.SafeData) { string name = aPromtForm.ReturnValue; //make sure a palette with that name doesn't already exist Global.SavePalette(name, name, panelItemHolderPalette.PuzzleItems.ToList()); Global.LoadPalettes(); paletteLayoutComboBox.Items.Clear(); foreach (object palette in Global.ListOfPalettes) { paletteLayoutComboBox.Items.Add(((PaletteLayout)palette).Name); } paletteLayoutComboBox.Text = name; } }
private void saveToolStripMenuItem_Click(object sender, EventArgs e) { bool nameisgood; //prompt for name do { nameisgood = true; if (aPromtForm == null) aPromtForm = new PromtForm("Palette Name", "", "Cancel", "Save Palette"); aPromtForm.ShowDialog(this); if (aPromtForm.SafeData) { foreach (object palette in Global.ListOfPalettes) { if (((PaletteLayout)palette).Name.Trim() == aPromtForm.ReturnValue.Trim()) { nameisgood = false; MessageBox.Show("That name is already taken, try something else", "", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else break; } while (!nameisgood); if (aPromtForm.SafeData) { string name = aPromtForm.ReturnValue; //make sure a palette with that name doesn't already exist Global.SavePalette(name, name, panelItemHolderPalette.PuzzleItems.ToList()); Global.LoadPalettes(); paletteLayoutComboBox.Items.Clear(); foreach (object palette in Global.ListOfPalettes) { paletteLayoutComboBox.Items.Add(((PaletteLayout)palette).Name); } paletteLayoutComboBox.Text = name; } }