From 33b349e333107c20aedd994fc877af46d656d18d Mon Sep 17 00:00:00 2001 From: Milan Hanajik Date: Tue, 28 Feb 2017 22:04:07 +0100 Subject: [PATCH] ComponentsManagerDlg : Up and down button implemented. --- .../ComponentsManagerDlg.Designer.cs | 114 +++++++++--------- TestBenchFramework/ComponentsManagerDlg.cs | 62 +++++++++- TestBenchFramework/ComponentsManagerDlg.resx | 4 +- 3 files changed, 117 insertions(+), 63 deletions(-) diff --git a/TestBenchFramework/ComponentsManagerDlg.Designer.cs b/TestBenchFramework/ComponentsManagerDlg.Designer.cs index 89c048d4c..5fa4e9240 100644 --- a/TestBenchFramework/ComponentsManagerDlg.Designer.cs +++ b/TestBenchFramework/ComponentsManagerDlg.Designer.cs @@ -31,62 +31,64 @@ namespace TBF /// private void InitializeComponent() { - System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ComponentsManagerDlg)); - this.splitContainer = new System.Windows.Forms.SplitContainer(); - this.listViewEx = new Results.Forms.ListViewEx(); - this.sharedButtons = new TBF.UiControls.SharedButtons(); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); - this.splitContainer.Panel1.SuspendLayout(); - this.splitContainer.Panel2.SuspendLayout(); - this.splitContainer.SuspendLayout(); - this.SuspendLayout(); - // - // splitContainer - // - resources.ApplyResources(this.splitContainer, "splitContainer"); - this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; - this.splitContainer.Name = "splitContainer"; - // - // splitContainer.Panel1 - // - this.splitContainer.Panel1.Controls.Add(this.listViewEx); - // - // splitContainer.Panel2 - // - this.splitContainer.Panel2.Controls.Add(this.sharedButtons); - // - // listViewEx - // - this.listViewEx.AllowColumnReorder = true; - resources.ApplyResources(this.listViewEx, "listViewEx"); - this.listViewEx.DoubleClickActivation = false; - this.listViewEx.FullRowSelect = true; - this.listViewEx.GridLines = true; - this.listViewEx.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; - this.listViewEx.Name = "listViewEx"; - this.listViewEx.UseCompatibleStateImageBehavior = false; - this.listViewEx.View = System.Windows.Forms.View.Details; - this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.componentsListView_SelectedIndexChanged); - this.listViewEx.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listViewEx_MouseDoubleClick); - // - // sharedButtons - // - resources.ApplyResources(this.sharedButtons, "sharedButtons"); - this.sharedButtons.Name = "sharedButtons"; - // - // ComponentsManagerDlg - // - resources.ApplyResources(this, "$this"); - this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; - this.Controls.Add(this.splitContainer); - this.Name = "ComponentsManagerDlg"; - this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ComponentsManagerDlg_FormClosing); - this.Load += new System.EventHandler(this.ComponentsManagerDlg_Load); - this.splitContainer.Panel1.ResumeLayout(false); - this.splitContainer.Panel2.ResumeLayout(false); - ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit(); - this.splitContainer.ResumeLayout(false); - this.ResumeLayout(false); + System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ComponentsManagerDlg)); + this.splitContainer = new System.Windows.Forms.SplitContainer(); + this.listViewEx = new Results.Forms.ListViewEx(); + this.sharedButtons = new TBF.UiControls.SharedButtons(); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); + this.splitContainer.Panel1.SuspendLayout(); + this.splitContainer.Panel2.SuspendLayout(); + this.splitContainer.SuspendLayout(); + this.SuspendLayout(); + // + // splitContainer + // + resources.ApplyResources(this.splitContainer, "splitContainer"); + this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2; + this.splitContainer.Name = "splitContainer"; + // + // splitContainer.Panel1 + // + this.splitContainer.Panel1.Controls.Add(this.listViewEx); + // + // splitContainer.Panel2 + // + this.splitContainer.Panel2.Controls.Add(this.sharedButtons); + // + // listViewEx + // + this.listViewEx.AllowColumnReorder = true; + resources.ApplyResources(this.listViewEx, "listViewEx"); + this.listViewEx.DoubleClickActivation = false; + this.listViewEx.FullRowSelect = true; + this.listViewEx.GridLines = true; + this.listViewEx.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.Nonclickable; + this.listViewEx.HideSelection = false; + this.listViewEx.MultiSelect = false; + this.listViewEx.Name = "listViewEx"; + this.listViewEx.UseCompatibleStateImageBehavior = false; + this.listViewEx.View = System.Windows.Forms.View.Details; + this.listViewEx.SelectedIndexChanged += new System.EventHandler(this.componentsListView_SelectedIndexChanged); + this.listViewEx.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.listViewEx_MouseDoubleClick); + // + // sharedButtons + // + resources.ApplyResources(this.sharedButtons, "sharedButtons"); + this.sharedButtons.Name = "sharedButtons"; + // + // ComponentsManagerDlg + // + resources.ApplyResources(this, "$this"); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.Controls.Add(this.splitContainer); + this.Name = "ComponentsManagerDlg"; + this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.ComponentsManagerDlg_FormClosing); + this.Load += new System.EventHandler(this.ComponentsManagerDlg_Load); + this.splitContainer.Panel1.ResumeLayout(false); + this.splitContainer.Panel2.ResumeLayout(false); + ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit(); + this.splitContainer.ResumeLayout(false); + this.ResumeLayout(false); } diff --git a/TestBenchFramework/ComponentsManagerDlg.cs b/TestBenchFramework/ComponentsManagerDlg.cs index 63d608e52..1d7ec076e 100644 --- a/TestBenchFramework/ComponentsManagerDlg.cs +++ b/TestBenchFramework/ComponentsManagerDlg.cs @@ -1,5 +1,5 @@ /// -/// Copyright (c) 2013-2015 Sensus Metering Systems +/// Copyright (c) 2013-2017 Sensus Metering Systems /// Author: Milan Hanajík /// using System; @@ -65,16 +65,16 @@ namespace TBF sharedButtons.RequiredGroupMembership = Config.Grp.GID.Metrologists; sharedButtons.OptionalButtons = SharedButtons.Buttons.Add | SharedButtons.Buttons.Remove | - //SharedButtons.Buttons.Up | - //SharedButtons.Buttons.Down | + SharedButtons.Buttons.Up | + SharedButtons.Buttons.Down | SharedButtons.Buttons.Edit; sharedButtons.Unlocked += Unlocked; sharedButtons.OKClicked += okButton_Click; sharedButtons.CancelClicked += cancelButton_Click; sharedButtons.AddClicked += addButton_Click; sharedButtons.RemoveClicked += removeButton_Click; - //sharedButtons.UpClicked += upButton_Click; - //sharedButtons.DownClicked += downButton_Click; + sharedButtons.UpClicked += upButton_Click; + sharedButtons.DownClicked += downButton_Click; sharedButtons.EditClicked += editButton_Click; } @@ -162,6 +162,14 @@ namespace TBF private void Unlocked(object sender, EventArgs e) { unlocked = true; + + if (listViewEx.SelectedItems.Count == 1) + { + int ix = listViewEx.SelectedIndices[0]; + Focus(); + listViewEx.Items[ix].Selected = true; + listViewEx.Items[ix].EnsureVisible(); + } } void RedrawAll() @@ -360,6 +368,50 @@ namespace TBF RedrawAll(); } + private void upButton_Click(object sender, EventArgs e) + { + if (listViewEx.SelectedIndices.Count != 1) return; + int ix = listViewEx.SelectedIndices[0]; + if (ix < 1) return; + + Component item1 = (Component)(listViewEx.Items[ix - 1].Tag); + Component item2 = (Component)(listViewEx.Items[ix].Tag); + (item1 as IHasItemNr).ItemNr++; + (item2 as IHasItemNr).ItemNr--; + cmpntEntities.RemoveAt(ix); + cmpntEntities.Insert(ix - 1, item2); + + flags |= CfgUpdateFlags.AnyChange; + + RedrawAll(); + + Focus(); + listViewEx.Items[ix - 1].Selected = true; + listViewEx.Items[ix - 1].EnsureVisible(); + } + + private void downButton_Click(object sender, EventArgs e) + { + if (listViewEx.SelectedIndices.Count != 1) return; + int ix = listViewEx.SelectedIndices[0]; + if (ix >= listViewEx.Items.Count - 1) return; + + Component item1 = (Component)(listViewEx.Items[ix].Tag); + Component item2 = (Component)(listViewEx.Items[ix + 1].Tag); + (item1 as IHasItemNr).ItemNr++; + (item2 as IHasItemNr).ItemNr--; + cmpntEntities.RemoveAt(ix + 1); + cmpntEntities.Insert(ix, item2); + + flags |= CfgUpdateFlags.AnyChange; + + RedrawAll(); + + Focus(); + listViewEx.Items[ix + 1].Selected = true; + listViewEx.Items[ix + 1].EnsureVisible(); + } + private void componentsListView_SelectedIndexChanged(object sender, EventArgs e) { if (listViewEx.SelectedIndices.Count == 1) diff --git a/TestBenchFramework/ComponentsManagerDlg.resx b/TestBenchFramework/ComponentsManagerDlg.resx index dddcf84b2..7aeeb31c6 100644 --- a/TestBenchFramework/ComponentsManagerDlg.resx +++ b/TestBenchFramework/ComponentsManagerDlg.resx @@ -145,7 +145,7 @@ listViewEx - Results.Forms.ListViewEx, Results, Version=2.12.394.0, Culture=neutral, PublicKeyToken=null + Results.Forms.ListViewEx, Results, Version=2.12.475.0, Culture=neutral, PublicKeyToken=null splitContainer.Panel1 @@ -178,7 +178,7 @@ sharedButtons - TBF.UiControls.SharedButtons, TBF, Version=2.12.395.1, Culture=neutral, PublicKeyToken=null + TBF.UiControls.SharedButtons, TBF, Version=2.12.481.1, Culture=neutral, PublicKeyToken=null splitContainer.Panel2