private void button_add_severity_Click(object sender, EventArgs e) { var f = new QualityMetricWeightsAppend(); f.textBox_name.Text = string.Empty; f.numericUpDown_weight.Value = 0; f.Text = PluginResources.Severity_Weight___Add; f.ShowDialog(); if (f.Saved) { if (f.textBox_name.Text.Trim() != string.Empty) { var found = listView_severities.Items.Cast <ListViewItem>().Any(item => string.Compare(item.Text, f.textBox_name.Text.Trim(), StringComparison.OrdinalIgnoreCase) == 0); if (found) { MessageBox.Show(PluginResources.Item_name_already_exists_in_the_list_); } else { var severity = new Severity(f.textBox_name.Text.Trim(), Convert.ToInt32(f.numericUpDown_weight.Value), -1); var item = listView_severities.Items.Add(severity.Name); item.SubItems.Add(severity.Value.ToString()); item.Tag = severity; } } } label_severity_item_count.Text = PluginResources.Items_ + listView_severities.Items.Count + @" "; }
private void button_edit_severity_Click(object sender, EventArgs e) { if (listView_severities.SelectedItems.Count > 0) { var itemSelected = listView_severities.SelectedItems[0]; var severity = (Severity)itemSelected.Tag; var f = new QualityMetricWeightsAppend { textBox_name = { Text = severity.Name }, numericUpDown_weight = { Value = Convert.ToInt32(severity.Value) }, Text = PluginResources.Severity_Weight___Edit }; f.ShowDialog(); if (f.Saved) { if (f.textBox_name.Text.Trim() != string.Empty) { var found = listView_severities.Items.Cast <ListViewItem>().Where(item => item.Index != itemSelected.Index).Any(item => string.Compare(item.Text, f.textBox_name.Text.Trim(), StringComparison.OrdinalIgnoreCase) == 0); if (found) { MessageBox.Show(PluginResources.Item_name_already_exists_in_the_list_); } else { severity.Name = f.textBox_name.Text; severity.Value = Convert.ToInt32(f.numericUpDown_weight.Value); itemSelected.Text = severity.Name; itemSelected.SubItems[1].Text = severity.Value.ToString(); itemSelected.Tag = severity; } } } } label_severity_item_count.Text = PluginResources.Items_ + listView_severities.Items.Count + @" "; }