# HG changeset patch
# User StephaneLenclud
# Date 1469790578 -7200
# Node ID 4a03cc6f41b0c4315328ef4544392e4b50132e94
# Parent 91763ba41c0c00621e5b3117df922a76cc61d90b
Adding action edit button.
diff -r 91763ba41c0c -r 4a03cc6f41b0 Server/FormEditAction.cs
--- a/Server/FormEditAction.cs Fri Jul 29 10:40:15 2016 +0200
+++ b/Server/FormEditAction.cs Fri Jul 29 13:09:38 2016 +0200
@@ -26,16 +26,37 @@
InitializeComponent();
}
+ ///
+ ///
+ ///
+ ///
+ ///
private void FormEditAction_Load(object sender, EventArgs e)
{
- //Populate registered actions
+ // Populate registered actions
foreach (string key in ManagerEventAction.Current.ActionTypes.Keys)
{
ItemActionType item = new ItemActionType(ManagerEventAction.Current.ActionTypes[key]);
comboBoxActionType.Items.Add(item);
}
- comboBoxActionType.SelectedIndex = 0;
+ if (Action == null)
+ {
+ // Creating new issue, select our first item
+ comboBoxActionType.SelectedIndex = 0;
+ }
+ else
+ {
+ // Editing existing issue
+ // Look up our item in our combobox
+ foreach (ItemActionType item in comboBoxActionType.Items)
+ {
+ if (item.Type == Action.GetType())
+ {
+ comboBoxActionType.SelectedItem = item;
+ }
+ }
+ }
}
private void buttonOk_Click(object sender, EventArgs e)
@@ -51,8 +72,13 @@
private void comboBoxActionType_SelectedIndexChanged(object sender, EventArgs e)
{
//Instantiate an action corresponding to our type
- Action = (SharpLib.Ear.Action)Activator.CreateInstance(((ItemActionType)comboBoxActionType.SelectedItem).Type);
-
+ Type actionType = ((ItemActionType) comboBoxActionType.SelectedItem).Type;
+ //Create another type of action only if needed
+ if (Action == null || Action.GetType() != actionType)
+ {
+ Action = (SharpLib.Ear.Action)Activator.CreateInstance(actionType);
+ }
+
//Create input fields
UpdateTableLayoutPanel(Action);
}
diff -r 91763ba41c0c -r 4a03cc6f41b0 Server/FormMain.Designer.cs
--- a/Server/FormMain.Designer.cs Fri Jul 29 10:40:15 2016 +0200
+++ b/Server/FormMain.Designer.cs Fri Jul 29 13:09:38 2016 +0200
@@ -110,11 +110,12 @@
this.labelHdmiPort = new System.Windows.Forms.Label();
this.comboBoxHdmiPort = new System.Windows.Forms.ComboBox();
this.tabPageEvent = new System.Windows.Forms.TabPage();
+ this.buttonActionEdit = new System.Windows.Forms.Button();
this.buttonActionMoveUp = new System.Windows.Forms.Button();
this.buttonActionMoveDown = new System.Windows.Forms.Button();
- this.buttonTestAction = new System.Windows.Forms.Button();
- this.buttonDeleteAction = new System.Windows.Forms.Button();
- this.buttonAddAction = new System.Windows.Forms.Button();
+ this.buttonActionTest = new System.Windows.Forms.Button();
+ this.buttonActionDelete = new System.Windows.Forms.Button();
+ this.buttonActionAdd = new System.Windows.Forms.Button();
this.iTreeViewEvents = new System.Windows.Forms.TreeView();
this.tabPageApp = new System.Windows.Forms.TabPage();
this.checkBoxStartMinimized = new System.Windows.Forms.CheckBox();
@@ -972,11 +973,12 @@
//
// tabPageEvent
//
+ this.tabPageEvent.Controls.Add(this.buttonActionEdit);
this.tabPageEvent.Controls.Add(this.buttonActionMoveUp);
this.tabPageEvent.Controls.Add(this.buttonActionMoveDown);
- this.tabPageEvent.Controls.Add(this.buttonTestAction);
- this.tabPageEvent.Controls.Add(this.buttonDeleteAction);
- this.tabPageEvent.Controls.Add(this.buttonAddAction);
+ this.tabPageEvent.Controls.Add(this.buttonActionTest);
+ this.tabPageEvent.Controls.Add(this.buttonActionDelete);
+ this.tabPageEvent.Controls.Add(this.buttonActionAdd);
this.tabPageEvent.Controls.Add(this.iTreeViewEvents);
this.tabPageEvent.Location = new System.Drawing.Point(4, 22);
this.tabPageEvent.Name = "tabPageEvent";
@@ -986,6 +988,17 @@
this.tabPageEvent.Text = "Events";
this.tabPageEvent.UseVisualStyleBackColor = true;
//
+ // buttonActionEdit
+ //
+ this.buttonActionEdit.Enabled = false;
+ this.buttonActionEdit.Location = new System.Drawing.Point(6, 35);
+ this.buttonActionEdit.Name = "buttonActionEdit";
+ this.buttonActionEdit.Size = new System.Drawing.Size(96, 23);
+ this.buttonActionEdit.TabIndex = 25;
+ this.buttonActionEdit.Text = "Edit Action";
+ this.buttonActionEdit.UseVisualStyleBackColor = true;
+ this.buttonActionEdit.Click += new System.EventHandler(this.buttonActionEdit_Click);
+ //
// buttonActionMoveUp
//
this.buttonActionMoveUp.Enabled = false;
@@ -1008,38 +1021,38 @@
this.buttonActionMoveDown.UseVisualStyleBackColor = true;
this.buttonActionMoveDown.Click += new System.EventHandler(this.buttonActionMoveDown_Click);
//
- // buttonTestAction
+ // buttonActionTest
//
- this.buttonTestAction.Enabled = false;
- this.buttonTestAction.Location = new System.Drawing.Point(6, 64);
- this.buttonTestAction.Name = "buttonTestAction";
- this.buttonTestAction.Size = new System.Drawing.Size(96, 23);
- this.buttonTestAction.TabIndex = 22;
- this.buttonTestAction.Text = "Test Action";
- this.buttonTestAction.UseVisualStyleBackColor = true;
- this.buttonTestAction.Click += new System.EventHandler(this.buttonTestAction_Click);
+ this.buttonActionTest.Enabled = false;
+ this.buttonActionTest.Location = new System.Drawing.Point(6, 93);
+ this.buttonActionTest.Name = "buttonActionTest";
+ this.buttonActionTest.Size = new System.Drawing.Size(96, 23);
+ this.buttonActionTest.TabIndex = 22;
+ this.buttonActionTest.Text = "Test Action";
+ this.buttonActionTest.UseVisualStyleBackColor = true;
+ this.buttonActionTest.Click += new System.EventHandler(this.buttonActionTest_Click);
//
- // buttonDeleteAction
+ // buttonActionDelete
//
- this.buttonDeleteAction.Enabled = false;
- this.buttonDeleteAction.Location = new System.Drawing.Point(6, 35);
- this.buttonDeleteAction.Name = "buttonDeleteAction";
- this.buttonDeleteAction.Size = new System.Drawing.Size(96, 23);
- this.buttonDeleteAction.TabIndex = 21;
- this.buttonDeleteAction.Text = "Delete Action";
- this.buttonDeleteAction.UseVisualStyleBackColor = true;
- this.buttonDeleteAction.Click += new System.EventHandler(this.buttonDeleteAction_Click);
+ this.buttonActionDelete.Enabled = false;
+ this.buttonActionDelete.Location = new System.Drawing.Point(6, 64);
+ this.buttonActionDelete.Name = "buttonActionDelete";
+ this.buttonActionDelete.Size = new System.Drawing.Size(96, 23);
+ this.buttonActionDelete.TabIndex = 21;
+ this.buttonActionDelete.Text = "Delete Action";
+ this.buttonActionDelete.UseVisualStyleBackColor = true;
+ this.buttonActionDelete.Click += new System.EventHandler(this.buttonActionDelete_Click);
//
- // buttonAddAction
+ // buttonActionAdd
//
- this.buttonAddAction.Enabled = false;
- this.buttonAddAction.Location = new System.Drawing.Point(6, 6);
- this.buttonAddAction.Name = "buttonAddAction";
- this.buttonAddAction.Size = new System.Drawing.Size(96, 23);
- this.buttonAddAction.TabIndex = 20;
- this.buttonAddAction.Text = "Add Action";
- this.buttonAddAction.UseVisualStyleBackColor = true;
- this.buttonAddAction.Click += new System.EventHandler(this.buttonAddAction_Click);
+ this.buttonActionAdd.Enabled = false;
+ this.buttonActionAdd.Location = new System.Drawing.Point(6, 6);
+ this.buttonActionAdd.Name = "buttonActionAdd";
+ this.buttonActionAdd.Size = new System.Drawing.Size(96, 23);
+ this.buttonActionAdd.TabIndex = 20;
+ this.buttonActionAdd.Text = "Add Action";
+ this.buttonActionAdd.UseVisualStyleBackColor = true;
+ this.buttonActionAdd.Click += new System.EventHandler(this.buttonActionAdd_Click);
//
// iTreeViewEvents
//
@@ -1311,11 +1324,12 @@
private System.Windows.Forms.CheckBox checkBoxCecLogNoPoll;
private System.Windows.Forms.TabPage tabPageEvent;
private System.Windows.Forms.TreeView iTreeViewEvents;
- private System.Windows.Forms.Button buttonDeleteAction;
- private System.Windows.Forms.Button buttonAddAction;
+ private System.Windows.Forms.Button buttonActionDelete;
+ private System.Windows.Forms.Button buttonActionAdd;
private System.Windows.Forms.Button buttonActionMoveUp;
private System.Windows.Forms.Button buttonActionMoveDown;
- private System.Windows.Forms.Button buttonTestAction;
+ private System.Windows.Forms.Button buttonActionTest;
+ private System.Windows.Forms.Button buttonActionEdit;
}
}
diff -r 91763ba41c0c -r 4a03cc6f41b0 Server/FormMain.cs
--- a/Server/FormMain.cs Fri Jul 29 10:40:15 2016 +0200
+++ b/Server/FormMain.cs Fri Jul 29 13:09:38 2016 +0200
@@ -316,8 +316,8 @@
private void PopulateEventsTreeView()
{
//Disable action buttons
- buttonAddAction.Enabled = false;
- buttonDeleteAction.Enabled = false;
+ buttonActionAdd.Enabled = false;
+ buttonActionDelete.Enabled = false;
Event currentEvent = CurrentEvent();
SharpLib.Ear.Action currentAction = CurrentAction();
@@ -2780,7 +2780,7 @@
///
///
///
- private void buttonAddAction_Click(object sender, EventArgs e)
+ private void buttonActionAdd_Click(object sender, EventArgs e)
{
Event selectedEvent = CurrentEvent();
if (selectedEvent == null)
@@ -2805,7 +2805,37 @@
///
///
///
- private void buttonDeleteAction_Click(object sender, EventArgs e)
+ private void buttonActionEdit_Click(object sender, EventArgs e)
+ {
+ Event selectedEvent = CurrentEvent();
+ SharpLib.Ear.Action selectedAction = CurrentAction();
+ if (selectedEvent == null || selectedAction == null)
+ {
+ //We did not find a corresponding event
+ return;
+ }
+
+ FormEditAction ea = new FormEditAction();
+ ea.Action = selectedAction;
+ int actionIndex = iTreeViewEvents.SelectedNode.Index;
+ DialogResult res = CodeProject.Dialog.DlgBox.ShowDialog(ea);
+ if (res == DialogResult.OK)
+ {
+ //Update our action
+ selectedEvent.Actions[actionIndex]=ea.Action;
+ //Save and rebuild our event tree view
+ Properties.Settings.Default.Actions = ManagerEventAction.Current;
+ Properties.Settings.Default.Save();
+ PopulateEventsTreeView();
+ }
+ }
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ private void buttonActionDelete_Click(object sender, EventArgs e)
{
SharpLib.Ear.Action action = CurrentAction();
@@ -2821,35 +2851,12 @@
PopulateEventsTreeView();
}
- private void iTreeViewEvents_AfterSelect(object sender, TreeViewEventArgs e)
- {
- //Enable buttons according to selected item
- buttonAddAction.Enabled = CurrentEvent() != null;
-
- SharpLib.Ear.Action currentAction = CurrentAction();
- //If an action is selected enable the following buttons
- buttonTestAction.Enabled =
- buttonDeleteAction.Enabled =
- buttonActionMoveUp.Enabled =
- buttonActionMoveDown.Enabled =
- currentAction != null;
-
- if (currentAction != null)
- {
- //If an action is selected enable move buttons if needed
- buttonActionMoveUp.Enabled = iTreeViewEvents.SelectedNode.Index != 0;
- buttonActionMoveDown.Enabled = iTreeViewEvents.SelectedNode.Index <
- iTreeViewEvents.SelectedNode.Parent.Nodes.Count - 1;
- }
-
- }
-
///
///
///
///
///
- private void buttonTestAction_Click(object sender, EventArgs e)
+ private void buttonActionTest_Click(object sender, EventArgs e)
{
SharpLib.Ear.Action a = CurrentAction();
if (a != null)
@@ -2918,5 +2925,36 @@
Properties.Settings.Default.Save();
PopulateEventsTreeView();
}
+
+
+ ///
+ /// Manages events and actions buttons according to selected item in event tree.
+ ///
+ ///
+ ///
+ private void iTreeViewEvents_AfterSelect(object sender, TreeViewEventArgs e)
+ {
+ //Enable buttons according to selected item
+ buttonActionAdd.Enabled = CurrentEvent() != null;
+
+ SharpLib.Ear.Action currentAction = CurrentAction();
+ //If an action is selected enable the following buttons
+ buttonActionTest.Enabled =
+ buttonActionDelete.Enabled =
+ buttonActionMoveUp.Enabled =
+ buttonActionMoveDown.Enabled =
+ buttonActionEdit.Enabled =
+ currentAction != null;
+
+ if (currentAction != null)
+ {
+ //If an action is selected enable move buttons if needed
+ buttonActionMoveUp.Enabled = iTreeViewEvents.SelectedNode.Index != 0;
+ buttonActionMoveDown.Enabled = iTreeViewEvents.SelectedNode.Index <
+ iTreeViewEvents.SelectedNode.Parent.Nodes.Count - 1;
+ }
+
+ }
+
}
}