private void editServiceGroupMenuItem_Click(object sender, EventArgs e) { var selectedNode = treeView.SelectedNode; if (selectedNode != null) { var group = selectedNode.Tag as ServiceGroup; using (var f = new EditServiceGroupForm(null, group.Id)) { f.Saved += (s, eventArgs) => { selectedNode.Text = f.ServiceGroup.ToString(); f.Close(); }; f.ShowDialog(); } } }
private void addGroupMenuItem_Click(object sender, EventArgs e) { Guid? parentGroupId = null; var selectedNode = treeView.SelectedNode; if (selectedNode != null) { parentGroupId = (selectedNode.Tag as ServiceGroup).Id; } using (var f = new EditServiceGroupForm(parentGroupId)) { TreeNode treeNode = null; f.Saved += (s, eventArgs) => { if (treeNode == null) { treeNode = new TreeNode(); treeNode.Tag = f.ServiceGroup; treeNode.Checked = f.ServiceGroup.IsActive; if (selectedNode != null) { selectedNode.Nodes.Add(treeNode); selectedNode.Expand(); } else { treeView.Nodes.Add(treeNode); } treeView.SelectedNode = treeNode; } treeNode.Text = f.ServiceGroup.ToString(); f.Close(); }; f.ShowDialog(); ServiceGroup serviceGroup = f.ServiceGroup; } }