1.1 --- a/Server/FormMain.cs Fri Jul 29 10:40:15 2016 +0200
1.2 +++ b/Server/FormMain.cs Fri Jul 29 13:09:38 2016 +0200
1.3 @@ -316,8 +316,8 @@
1.4 private void PopulateEventsTreeView()
1.5 {
1.6 //Disable action buttons
1.7 - buttonAddAction.Enabled = false;
1.8 - buttonDeleteAction.Enabled = false;
1.9 + buttonActionAdd.Enabled = false;
1.10 + buttonActionDelete.Enabled = false;
1.11
1.12 Event currentEvent = CurrentEvent();
1.13 SharpLib.Ear.Action currentAction = CurrentAction();
1.14 @@ -2780,7 +2780,7 @@
1.15 /// </summary>
1.16 /// <param name="sender"></param>
1.17 /// <param name="e"></param>
1.18 - private void buttonAddAction_Click(object sender, EventArgs e)
1.19 + private void buttonActionAdd_Click(object sender, EventArgs e)
1.20 {
1.21 Event selectedEvent = CurrentEvent();
1.22 if (selectedEvent == null)
1.23 @@ -2805,7 +2805,37 @@
1.24 /// </summary>
1.25 /// <param name="sender"></param>
1.26 /// <param name="e"></param>
1.27 - private void buttonDeleteAction_Click(object sender, EventArgs e)
1.28 + private void buttonActionEdit_Click(object sender, EventArgs e)
1.29 + {
1.30 + Event selectedEvent = CurrentEvent();
1.31 + SharpLib.Ear.Action selectedAction = CurrentAction();
1.32 + if (selectedEvent == null || selectedAction == null)
1.33 + {
1.34 + //We did not find a corresponding event
1.35 + return;
1.36 + }
1.37 +
1.38 + FormEditAction ea = new FormEditAction();
1.39 + ea.Action = selectedAction;
1.40 + int actionIndex = iTreeViewEvents.SelectedNode.Index;
1.41 + DialogResult res = CodeProject.Dialog.DlgBox.ShowDialog(ea);
1.42 + if (res == DialogResult.OK)
1.43 + {
1.44 + //Update our action
1.45 + selectedEvent.Actions[actionIndex]=ea.Action;
1.46 + //Save and rebuild our event tree view
1.47 + Properties.Settings.Default.Actions = ManagerEventAction.Current;
1.48 + Properties.Settings.Default.Save();
1.49 + PopulateEventsTreeView();
1.50 + }
1.51 + }
1.52 +
1.53 + /// <summary>
1.54 + ///
1.55 + /// </summary>
1.56 + /// <param name="sender"></param>
1.57 + /// <param name="e"></param>
1.58 + private void buttonActionDelete_Click(object sender, EventArgs e)
1.59 {
1.60
1.61 SharpLib.Ear.Action action = CurrentAction();
1.62 @@ -2821,35 +2851,12 @@
1.63 PopulateEventsTreeView();
1.64 }
1.65
1.66 - private void iTreeViewEvents_AfterSelect(object sender, TreeViewEventArgs e)
1.67 - {
1.68 - //Enable buttons according to selected item
1.69 - buttonAddAction.Enabled = CurrentEvent() != null;
1.70 -
1.71 - SharpLib.Ear.Action currentAction = CurrentAction();
1.72 - //If an action is selected enable the following buttons
1.73 - buttonTestAction.Enabled =
1.74 - buttonDeleteAction.Enabled =
1.75 - buttonActionMoveUp.Enabled =
1.76 - buttonActionMoveDown.Enabled =
1.77 - currentAction != null;
1.78 -
1.79 - if (currentAction != null)
1.80 - {
1.81 - //If an action is selected enable move buttons if needed
1.82 - buttonActionMoveUp.Enabled = iTreeViewEvents.SelectedNode.Index != 0;
1.83 - buttonActionMoveDown.Enabled = iTreeViewEvents.SelectedNode.Index <
1.84 - iTreeViewEvents.SelectedNode.Parent.Nodes.Count - 1;
1.85 - }
1.86 -
1.87 - }
1.88 -
1.89 /// <summary>
1.90 ///
1.91 /// </summary>
1.92 /// <param name="sender"></param>
1.93 /// <param name="e"></param>
1.94 - private void buttonTestAction_Click(object sender, EventArgs e)
1.95 + private void buttonActionTest_Click(object sender, EventArgs e)
1.96 {
1.97 SharpLib.Ear.Action a = CurrentAction();
1.98 if (a != null)
1.99 @@ -2918,5 +2925,36 @@
1.100 Properties.Settings.Default.Save();
1.101 PopulateEventsTreeView();
1.102 }
1.103 +
1.104 +
1.105 + /// <summary>
1.106 + /// Manages events and actions buttons according to selected item in event tree.
1.107 + /// </summary>
1.108 + /// <param name="sender"></param>
1.109 + /// <param name="e"></param>
1.110 + private void iTreeViewEvents_AfterSelect(object sender, TreeViewEventArgs e)
1.111 + {
1.112 + //Enable buttons according to selected item
1.113 + buttonActionAdd.Enabled = CurrentEvent() != null;
1.114 +
1.115 + SharpLib.Ear.Action currentAction = CurrentAction();
1.116 + //If an action is selected enable the following buttons
1.117 + buttonActionTest.Enabled =
1.118 + buttonActionDelete.Enabled =
1.119 + buttonActionMoveUp.Enabled =
1.120 + buttonActionMoveDown.Enabled =
1.121 + buttonActionEdit.Enabled =
1.122 + currentAction != null;
1.123 +
1.124 + if (currentAction != null)
1.125 + {
1.126 + //If an action is selected enable move buttons if needed
1.127 + buttonActionMoveUp.Enabled = iTreeViewEvents.SelectedNode.Index != 0;
1.128 + buttonActionMoveDown.Enabled = iTreeViewEvents.SelectedNode.Index <
1.129 + iTreeViewEvents.SelectedNode.Parent.Nodes.Count - 1;
1.130 + }
1.131 +
1.132 + }
1.133 +
1.134 }
1.135 }