/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AmendNetworkButton_Click(object sender, EventArgs e) { if (this.NetworksListView.SelectedItems.Count == 1) { ListViewItem SelectedItem = this.NetworksListView.SelectedItems[0]; WolHostNetwork SelectedNetwork = SelectedItem.Tag as WolHostNetwork; WolHostNetwork ClonedNetwork = SelectedNetwork.Clone(); if (SelectedNetwork != null) { using (AmendNetwork AmendNetworkForm = new AmendNetwork(ActionMode.Amend, ClonedNetwork)) { if (AmendNetworkForm.ShowDialog() == DialogResult.OK) { SelectedItem.SubItems[0].Text = ClonedNetwork.Name; SelectedItem.SubItems[1].Text = ClonedNetwork.Address; SelectedItem.Tag = ClonedNetwork; this.NetworksListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); } } } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void AddNetworkButton_Click(object sender, EventArgs e) { WolHostNetwork NewNetwork = new WolHostNetwork(); using (AmendNetwork AddNetworkForm = new AmendNetwork(ActionMode.Add, NewNetwork)) { if (AddNetworkForm.ShowDialog() == DialogResult.OK) { ListViewItem NewListItem = new ListViewItem(new string[] { NewNetwork.Name, NewNetwork.Address }); NewListItem.Tag = NewNetwork; this.NetworksListView.Items.Add(NewListItem); this.NetworksListView.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); } } }