Server/MainForm.cs
changeset 214 4961ede27e0a
parent 212 1a0791daa243
child 215 5de8f8eaaa54
     1.1 --- a/Server/MainForm.cs	Sun Jul 24 14:22:56 2016 +0200
     1.2 +++ b/Server/MainForm.cs	Sun Jul 24 20:36:07 2016 +0200
     1.3 @@ -315,12 +315,16 @@
     1.4                  eventNode.Nodes.Add(key + ".Description", e.Description);
     1.5                  TreeNode actionsNodes = eventNode.Nodes.Add(key + ".Actions", "Actions");
     1.6  
     1.7 +                // Add our actions for that event
     1.8                  foreach (SharpLib.Ear.Action a in e.Actions)
     1.9                  {
    1.10 -                    actionsNodes.Nodes.Add(a.Name);
    1.11 +                    TreeNode actionNode = actionsNodes.Nodes.Add(a.Name);
    1.12 +                    actionNode.Tag = a;
    1.13                  }
    1.14              }
    1.15  
    1.16 +            iTreeViewEvents.ExpandAll();
    1.17 +
    1.18          }
    1.19  
    1.20  		/// <summary>
    1.21 @@ -2666,7 +2670,8 @@
    1.22  
    1.23          private void buttonAddAction_Click(object sender, EventArgs e)
    1.24          {
    1.25 -            if (iTreeViewEvents.SelectedNode==null)
    1.26 +            if (iTreeViewEvents.SelectedNode==null
    1.27 +                || !(iTreeViewEvents.SelectedNode.Tag is Event))
    1.28              {
    1.29                  return;
    1.30              }
    1.31 @@ -2688,5 +2693,26 @@
    1.32                  SetupEvents();
    1.33              }
    1.34          }
    1.35 +
    1.36 +        private void buttonDeleteAction_Click(object sender, EventArgs e)
    1.37 +        {
    1.38 +            if (iTreeViewEvents.SelectedNode == null
    1.39 +                || !(iTreeViewEvents.SelectedNode.Tag is SharpLib.Ear.Action))
    1.40 +            {
    1.41 +                return;
    1.42 +            }
    1.43 +
    1.44 +            SharpLib.Ear.Action action = (SharpLib.Ear.Action)iTreeViewEvents.SelectedNode.Tag;
    1.45 +            if (action == null)
    1.46 +            {
    1.47 +                //Must select action node
    1.48 +                return;
    1.49 +            }
    1.50 +
    1.51 +            ManagerEventAction.Current.RemoveAction(action);
    1.52 +            Properties.Settings.Default.Actions = ManagerEventAction.Current;
    1.53 +            Properties.Settings.Default.Save();
    1.54 +            SetupEvents();
    1.55 +        }
    1.56      }
    1.57  }