public StatusItemWindow(ColorDefinition definition, ColorSource source, NewOrEdit neworedit) { colorDefinition = definition; newOrEdit = neworedit; InitializeComponent(); this.Title = newOrEdit.ToString() + " " + source.ToString() + " Item"; groupBox.Header = source.ToString(); textBoxName.Text = colorDefinition.ParameterValue; buttonColor.Background = colorDefinition.BackgroundColor; }
private void buttonOK_Click(object sender, RoutedEventArgs e) { try { if (!string.IsNullOrEmpty(textBoxName.Text)) { if (!definitionNames.Contains(textBoxName.Text)) { colorDefinition.ParameterValue = textBoxName.Text; this.DialogResult = true; } else { MessageBox.Show(textBoxName.Text + " already exist in " + colorSource.ToString() + " items.", "Name Already Exist", MessageBoxButton.OK, MessageBoxImage.Information); } } } catch (Exception ex) { MessageBox.Show("Failed to add or edit item.\n" + ex.Message, this.Title, MessageBoxButton.OK, MessageBoxImage.Warning); } }