private void btnAdd_Click(object sender, EventArgs e) { int idx = 0; foreach (var p in PaletteManager.GetPaletteNames()) { if (p.ToLower().StartsWith("palette")) { string ns = p.Substring(7); int n; if (int.TryParse(ns, out n)) { idx = Math.Max(n, idx); } } } if (InputWindow.Show("팔레트이름을 입력해주세요", $"Palette{idx + 1}") == DialogResult.OK) { string name = InputWindow.Result.Trim(); if (name.Length > 0) { if (!CheckPalette(name)) { return; } AddPalette(name); } } }
private bool CheckPalette(string name) { foreach (var n in PaletteManager.GetPaletteNames()) { if (n.ToLower() == name.ToLower()) { MessageBox.Show("이미 존재하는 이름입니다", "ColorPicker", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } } return(true); }