private void m_btnAdd_Click(object sender, EventArgs e) { TargetEditDialog dlg = new TargetEditDialog(m_defaultPortNumber,m_canEditPortNumber,m_protocols); while (dlg.ShowDialog(this) == DialogResult.OK) { Target t = dlg.GetTarget(); if (m_lstTargets.Items.ContainsKey(t.Name)) { MessageBox.Show(this, "Target name already exist".Localize()); continue; } else { m_lstTargets.Items.Add(CreateListViewItem(t)); m_Changed = true; break; } } }
private void m_btnAdd_Click(object sender, EventArgs e) { TargetEditDialog dlg = new TargetEditDialog(m_defaultPortNumber, m_canEditPortNumber, m_protocols); while (dlg.ShowDialog(this) == DialogResult.OK) { Target t = dlg.GetTarget(); if (m_lstTargets.Items.ContainsKey(t.Name)) { MessageBox.Show(this, "Target name already exist".Localize()); continue; } else { m_lstTargets.Items.Add(CreateListViewItem(t)); m_Changed = true; break; } } }
private void m_btnEdit_Click(object sender, EventArgs e) { // get selected item ListView.SelectedListViewItemCollection items = m_lstTargets.SelectedItems; Target selectedTarget = (items.Count > 0) ? (Target)items[0].Tag : null; if (selectedTarget == null) { MessageBox.Show(this, "Target not selected".Localize()); return; } TargetEditDialog dlg = new TargetEditDialog(selectedTarget, m_defaultPortNumber, m_canEditPortNumber, m_protocols); while (dlg.ShowDialog(this) == DialogResult.OK) { if (!dlg.Changed) { break; } if (selectedTarget.Name != items[0].Name) { if (m_lstTargets.Items.ContainsKey(selectedTarget.Name)) { MessageBox.Show(this, "Target name already exist".Localize()); continue; } items[0].Name = selectedTarget.Name; } items[0].Text = selectedTarget.ToString(); m_lstTargets.Update(); m_Changed = true; break; } }
private void m_btnEdit_Click(object sender, EventArgs e) { // get selected item ListView.SelectedListViewItemCollection items = m_lstTargets.SelectedItems; Target selectedTarget = (items.Count > 0) ? (Target)items[0].Tag : null; if (selectedTarget == null) { MessageBox.Show(this, "Target not selected".Localize()); return; } TargetEditDialog dlg = new TargetEditDialog(selectedTarget, m_defaultPortNumber, m_canEditPortNumber, m_protocols); while(dlg.ShowDialog(this) == DialogResult.OK) { if (!dlg.Changed) break; if (selectedTarget.Name != items[0].Name) { if (m_lstTargets.Items.ContainsKey(selectedTarget.Name)) { MessageBox.Show(this, "Target name already exist".Localize()); continue; } items[0].Name = selectedTarget.Name; } items[0].Text = selectedTarget.ToString(); m_lstTargets.Update(); m_Changed = true; break; } }