From 591fc03ca291316fe398ed1cad7638d6d1fe2c3c Mon Sep 17 00:00:00 2001 From: mschill Date: Wed, 9 Oct 2024 13:12:29 -0400 Subject: [PATCH] C2024-024 Simple Selection of Fields to add to Return Values and Menu Values --- .../Exe/RefObj/ROEditor/AssemblyInfo.cs | 6 +- .../Exe/RefObj/ROEditor/RODefFrm.cs | 152 +++++++++++++++--- 2 files changed, 130 insertions(+), 28 deletions(-) diff --git a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/AssemblyInfo.cs b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/AssemblyInfo.cs index 40c79565..893433cd 100644 --- a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/AssemblyInfo.cs +++ b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/AssemblyInfo.cs @@ -23,8 +23,8 @@ using System.Runtime.CompilerServices; // Build YYMM (two digit year, two digit month) // Revision DHH (day - no leading zero, two digit hour - military time // -[assembly: AssemblyVersion("2.3.2404.1611")] -[assembly: AssemblyFileVersion("2.3.2404.1611")] +[assembly: AssemblyVersion("2.3.2410.907")] +[assembly: AssemblyFileVersion("2.3.2410.907")] // // In order to sign your assembly you must specify a key to use. Refer to the @@ -91,6 +91,8 @@ using System.Runtime.CompilerServices; + + diff --git a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/RODefFrm.cs b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/RODefFrm.cs index f03ecda0..ebbc23eb 100644 --- a/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/RODefFrm.cs +++ b/PROMS/ReferencedObjects/Exe/RefObj/ROEditor/RODefFrm.cs @@ -151,7 +151,7 @@ namespace ROEditor private string origMenuItem; StringBuilder parseerror; private int hi, lo; - private Label lb_chkApplc; + private Label lb_chkApplc; private int dbtype; // C2021-026 returns true is Parent/Child info was passed into the RO Editor public bool PCApplicabilityEnabled @@ -188,33 +188,33 @@ namespace ROEditor lboxInUse.Visible = true; lb_chkApplc.Visible = false; } - if (editlevel==(uint)RecordType.GroupSchema)this.Text = "Subgroup Definition"; + if (editlevel == (uint)RecordType.GroupSchema) this.Text = "Subgroup Definition"; FillInData(grptxt); } /// /// Clean up any resources being used. /// - protected override void Dispose( bool disposing ) + protected override void Dispose(bool disposing) { - if( disposing ) + if (disposing) { - if(components != null) + if (components != null) { components.Dispose(); } } - base.Dispose( disposing ); + base.Dispose(disposing); } - + private void FillInAvailable() { ROField rof; - + // put the items in the AvailList box. - for (int i=0; i< AvailList.Count; i++) + for (int i = 0; i < AvailList.Count; i++) { - rof = (ROField) AvailList[i]; + rof = (ROField)AvailList[i]; if (rof.GetFieldname != null) // DO YET: Why null? this.lboxAvail.Items.Add(rof.GetFieldname); } @@ -277,7 +277,7 @@ namespace ROEditor _initializing = false; } - + private void DoValueTextBoxes() { string menuitm, retval; @@ -297,7 +297,7 @@ namespace ROEditor else parent = null; } - if (menuitm !="") + if (menuitm != "") this.tbMenuVal.Text = CvtFldToUserFld(menuitm); else this.tbMenuVal.Text = ""; @@ -310,21 +310,21 @@ namespace ROEditor this.lblRetVal.Visible = true; VlnXmlElement parent; parent = (VlnXmlElement) elem.ParentNode; - while (parent != null && (menuitm == "" || retval=="")) + while (parent != null && (menuitm == "" || retval == "")) { // walk up tree to get parent and check for data there if (menuitm == "") menuitm = parent.GetAttribute("MenuItem"); if (retval == "") retval = parent.GetAttribute("RetVal"); if (parent.Name != "RO_Root") - parent = (VlnXmlElement) parent.ParentNode; + parent = (VlnXmlElement)parent.ParentNode; else parent = null; } - if (menuitm!="") + if (menuitm != "") this.tbMenuVal.Text = CvtFldToUserFld(menuitm); else this.tbMenuVal.Text = ""; - if (retval!="") + if (retval != "") this.tbRetVal.Text = CvtFldToUserFld(retval); else this.tbRetVal.Text = ""; @@ -332,7 +332,7 @@ namespace ROEditor } private void FillInData(string grptxt) - { + { this.lblGroupText.Text = grptxt; DoValueTextBoxes(); SetUpListBoxes(); @@ -344,24 +344,27 @@ namespace ROEditor lboxAvail.GotFocus += new EventHandler(this.lboxAvail_GotFocus); + lboxInUse.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lboxInUse_MouseUp); + lboxInUseCB.MouseUp += new System.Windows.Forms.MouseEventHandler(this.lboxInUseCB_MouseUp); + // save copies of local data, so if there is a change, we know we must save them. - origRetVal=this.tbRetVal.Text; - origMenuItem=this.tbMenuVal.Text; - + origRetVal = this.tbRetVal.Text; + origMenuItem = this.tbMenuVal.Text; + // if this is a database level definition & it's a user defined database, // the okay button is disabled until a field is used. - if (elem.ParentNode.Name == "RO_Root" && dbtype==3) + if (elem.ParentNode.Name == "RO_Root" && dbtype == 3) { string attr; - if (editlevel==(uint)RecordType.Schema) + if (editlevel == (uint)RecordType.Schema) attr = elem.GetAttribute("FieldsInUse"); else attr = elem.GetAttribute("GroupFieldsInUse"); - if (attr==null || attr=="") btnOK.Enabled=false; + if (attr == null || attr == "") btnOK.Enabled = false; } - } + } - protected void lboxInUse_GotFocus (object sender, EventArgs e) + protected void lboxInUse_GotFocus(object sender, EventArgs e) { lboxAvail.ClearSelected(); this.btnRemove.Enabled = true; @@ -375,7 +378,7 @@ namespace ROEditor this.btnAdd.Enabled = false; this.btnEdit.Enabled = true; } - protected void lboxAvail_GotFocus (object sender, EventArgs e) + protected void lboxAvail_GotFocus(object sender, EventArgs e) { if (PCApplicabilityEnabled) lboxInUseCB.ClearSelected(); @@ -385,6 +388,103 @@ namespace ROEditor this.btnRemove.Enabled = false; this.btnEdit.Enabled = true; } + + //CSM C2024-024 + //Simple Selection of Fields to add to Return Values and Menu Values. + //Part of 2024 PROMS Upgrades + //Add Context Menu for In Use Listbox + //Will allow user to right click Selected Items + //and add then to the Return Value / Menu Value Text Boxes + //without re-typing them + protected void lboxInUse_MouseUp(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right && lboxInUse.SelectedItems.Count > 0) + { + ContextMenuStrip cn = new ContextMenuStrip(); + if (tbRetVal.Visible) + { + var AddToReturnItem = new ToolStripMenuItem("Add to Return Value"); + AddToReturnItem.Click += new EventHandler(lboxInUse_Click); + AddToReturnItem.Name = "Add to Return Value"; + cn.Items.Add(AddToReturnItem); + } + var AddToMenuItem = new ToolStripMenuItem("Add to Menu Value"); + AddToMenuItem.Click += new EventHandler(lboxInUse_Click); + AddToMenuItem.Name = "Add to Menu Value"; + cn.Items.Add(AddToMenuItem); + this.lboxInUse.ContextMenuStrip = cn; + cn.Show(Control.MousePosition.X, Control.MousePosition.Y); + } + } + private void lboxInUse_Click(object sender, EventArgs e) + { + switch (((ToolStripMenuItem)sender).Name) + { + case "Add to Return Value": + if (tbRetVal.Text == "") + tbRetVal.Text += $"<{lboxInUse.SelectedItem}>"; + else + tbRetVal.Text += $" - <{lboxInUse.SelectedItem}>"; + break; + case "Add to Menu Value": + if (tbMenuVal.Text == "") + tbMenuVal.Text += $"<{lboxInUse.SelectedItem}>"; + else + tbMenuVal.Text += $" - <{lboxInUse.SelectedItem}>"; + break; + + } + } + + //CSM C2024-024 + //Simple Selection of Fields to add to Return Values and Menu Values. + //Part of 2024 PROMS Upgrades + //Add Context Menu for In Use ComboBox + //(Replaces In Use Listbox when Applicability + //to allow for selection of items per Unit) + //Will allow user to right click Selected Items + //and add then to the Return Value / Menu Value Text Boxes + //without re-typing them + protected void lboxInUseCB_MouseUp(object sender, MouseEventArgs e) + { + if (e.Button == MouseButtons.Right && lboxInUseCB.SelectedItems.Count > 0) + { + ContextMenuStrip cn = new ContextMenuStrip(); + if (tbRetVal.Visible) + { + var AddToReturnItem = new ToolStripMenuItem("Add to Return Value"); + AddToReturnItem.Click += new EventHandler(lboxInUseCB_Click); + AddToReturnItem.Name = "Add to Return Value"; + cn.Items.Add(AddToReturnItem); + } + var AddToMenuItem = new ToolStripMenuItem("Add to Menu Value"); + AddToMenuItem.Click += new EventHandler(lboxInUseCB_Click); + AddToMenuItem.Name = "Add to Menu Value"; + cn.Items.Add(AddToMenuItem); + this.lboxInUseCB.ContextMenuStrip = cn; + cn.Show(Control.MousePosition.X, Control.MousePosition.Y); + } + } + private void lboxInUseCB_Click(object sender, EventArgs e) + { + switch (((ToolStripMenuItem)sender).Name) + { + case "Add to Return Value": + if (tbRetVal.Text == "") + tbRetVal.Text += $"<{lboxInUseCB.SelectedItem}>"; + else + tbRetVal.Text += $" - <{lboxInUseCB.SelectedItem}>"; + break; + case "Add to Menu Value": + if (tbMenuVal.Text == "") + tbMenuVal.Text += $"<{lboxInUseCB.SelectedItem}>"; + else + tbMenuVal.Text += $" - <{lboxInUseCB.SelectedItem}>"; + break; + + } + } + private void btnRemove_Click(object sender, System.EventArgs e) { //get item in lboxInUse (in use list) and remove it from there