/// <summary> /// Event handler for the "Add Action" context menu item "Click" event /// </summary> /// <param name = "sender">The sender.</param> /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param> private void AddActionClick(object sender, EventArgs e) { var parent = SelectedNode; if (parent is ProfileEventActionTreeNode) { parent = parent.Parent; } // Create a new action IAction action = ActionFactory.Create((sender as ToolStripMenuItem).Text, null, false); action.Description = string.Empty; // Get the form to display var form = ActionEditorFormFactory.CreateActionEditor(action); form.LoadAction(action); // Display the form if (form.ShowDialog(FindForm()) == DialogResult.OK) { // If we saved the result, add the node to the tree parent.Nodes.Add(new ProfileEventActionTreeNode(action, IMAGELIST_ICON_ACTION)); // Add the action to the collection EventType eventType = (parent as ProfileEventTreeNode).EventType; _profile.AssociateAction(eventType, action); _pendingChanges = true; } }
/// <summary> /// Event handler for the "Edit Action" context menu item "Click" event /// </summary> /// <param name = "sender">The sender.</param> /// <param name = "e">The <see cref = "System.EventArgs" /> instance containing the event data.</param> private void EditActionClick(object sender, EventArgs e) { if (SelectedNode is ProfileEventActionTreeNode) { var node = SelectedNode as ProfileEventActionTreeNode; var form = ActionEditorFormFactory.CreateActionEditor(node.Action); form.LoadAction(node.Action); form.ShowDialog(FindForm()); node.RefreshLabel(); _pendingChanges = true; } }