From 389b9e382b02856d4946525961f6dd5d50b85a24 Mon Sep 17 00:00:00 2001 From: mschill Date: Wed, 9 Apr 2025 15:22:36 -0400 Subject: [PATCH] C2025-023 - Electronic Procedures - Modifications to PROMS - checkin #2 --- .../Format/EPFormatFile.cs | 24 ++++- .../frmEPAnnotationDetails.cs | 99 +++++++++++++++---- 2 files changed, 99 insertions(+), 24 deletions(-) diff --git a/PROMS/VEPROMS.CSLA.Library/Format/EPFormatFile.cs b/PROMS/VEPROMS.CSLA.Library/Format/EPFormatFile.cs index df6b3a42..83d70871 100644 --- a/PROMS/VEPROMS.CSLA.Library/Format/EPFormatFile.cs +++ b/PROMS/VEPROMS.CSLA.Library/Format/EPFormatFile.cs @@ -316,10 +316,10 @@ namespace VEPROMS.CSLA.Library } //return a list of items based on the ROsource specified in the EPFormat File - public Dictionary getROList(AnnotationInfo currAnn) + public List getROList(AnnotationInfo currAnn, bool includeblank) { if (string.IsNullOrEmpty(rosource)) - return new Dictionary(); + return new List(); try { @@ -329,8 +329,11 @@ namespace VEPROMS.CSLA.Library string roid = FormatRoidKey(rosource, false); rochild[] children = lookup.GetRoChildrenByRoid(roid); - - return children.Select(x => new { x.ID, x.title }).ToDictionary(t => t.ID, t => t.title); + List mylist = children.Select(x => new ROListItem(x.title, x.ID)).ToList(); + if (includeblank) + mylist.Insert(0, new ROListItem("", -1)); + + return mylist; } catch (Exception Ex) { @@ -339,5 +342,18 @@ namespace VEPROMS.CSLA.Library } } #endregion + //C2025-023 - Electronic Procedures - Modifications to PROMS + // class to handle return of RO Lists + #region EPFormatFiles + public class ROListItem + { + public string Text { get; private set; } + public int Value { get; private set; } + public ROListItem(string _text, int _value) + { + Text = _text; Value = _value; + } + } + #endregion } diff --git a/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs b/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs index 630bd961..0f260f1a 100644 --- a/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs +++ b/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs @@ -24,6 +24,9 @@ namespace Volian.Controls.Library private Dictionary _DicCheckBox; private Dictionary _DicComboBox; private Dictionary _DicSingleRO; + private Dictionary _DicMultiRO; + + private string multiseparator = ","; public frmEPAnnotationDetails(AnnotationInfo currAnn) { @@ -32,6 +35,7 @@ namespace Volian.Controls.Library _DicCheckBox = new Dictionary(); _DicComboBox = new Dictionary(); _DicSingleRO = new Dictionary(); + _DicMultiRO = new Dictionary(); InitializeSpecificControls(currAnn); _MyStepTabRibbon = new StepTabRibbon(); } @@ -108,9 +112,11 @@ namespace Volian.Controls.Library cmb.Visible = true; string tmp = EP.text; string[] tmps = tmp.Split(",".ToCharArray()); - foreach (string t in tmps) cmb.Items.Add(t); + foreach (string t in tmps) cmb.Items.Add(t.Trim()); string val = MyConfig.GetValue("EP", EP.name); if (val != null && val != "") cmb.SelectedItem = val; + cmb.DropDownWidth = TextRenderer.MeasureText(tmps.OrderByDescending(x => x.Length).First(), cmb.Font).Width + SystemInformation.VerticalScrollBarWidth; + cmb.Width = cmb.DropDownWidth; _DicComboBox.Add(EP.name, cmb); panelEP.Controls.Add(cmb, 1, panelEP.RowCount - 1); } @@ -118,28 +124,70 @@ namespace Volian.Controls.Library { ComboBox cmb = new ComboBox(); cmb.Visible = true; - cmb.DisplayMember = "Value"; - cmb.ValueMember = "Key"; - Dictionary tmps = EP.getROList(currAnn); - //foreach (var t in tmps) - // cmb.Items.Add(t); - tmps.Add(-1, ""); - cmb.DataSource = new BindingSource(tmps, null); - string val = MyConfig.GetValue("EP", EP.name); - if (val != null && val != "" && int.TryParse(val, out int n)) - cmb.SelectedValue = n; - else - cmb.SelectedValue = -1; - //cmb.SelectedItem = null; + List tmps = EP.getROList(currAnn, true); + cmb.DisplayMember = "Text"; + cmb.ValueMember = "Value"; + cmb.DataSource = tmps; + cmb.DropDownStyle = ComboBoxStyle.DropDownList; + cmb.DropDownWidth = TextRenderer.MeasureText(tmps.OrderByDescending(x => x.Text.Length).First().Text, cmb.Font).Width + SystemInformation.VerticalScrollBarWidth; + cmb.Width = cmb.DropDownWidth; _DicSingleRO.Add(EP.name, cmb); panelEP.Controls.Add(cmb, 1, panelEP.RowCount - 1); } + if (EP.type.ToLower() == "romulti") + { + ListBox lb = new ListBox(); + lb.Visible = true; + + List tmps = EP.getROList(currAnn, false); + lb.DisplayMember = "Text"; + lb.ValueMember = "Value"; + + lb.Width = TextRenderer.MeasureText(tmps.OrderByDescending(x => x.Text.Length).First().Text, lb.Font).Width + SystemInformation.VerticalScrollBarWidth; + lb.SelectionMode = SelectionMode.MultiSimple; + //lb.IsSynchronizedWithCurrentItem = false; + + lb.DataSource = tmps; + _DicMultiRO.Add(EP.name, lb); + panelEP.Controls.Add(lb, 1, panelEP.RowCount - 1); + + } } + + Load += new EventHandler(Form1Load_setDefaults); } - private void FieldStepRTB_Enter(object sender, EventArgs e) + void Form1Load_setDefaults(object sender, EventArgs e) + { + foreach (KeyValuePair pair in _DicSingleRO) + { + string val = MyConfig.GetValue("EP", pair.Key); + if (val != null && val != "" && int.TryParse(val, out int n)) + pair.Value.SelectedValue = n; + else + pair.Value.SelectedValue = -1; + } + + foreach (KeyValuePair pair in _DicMultiRO) + { + pair.Value.ClearSelected(); + string val = MyConfig.GetValue("EP", pair.Key); + if (val != null && val != "") + { + var selectedvalues = val.Split(multiseparator.ToCharArray()); + foreach (string item in selectedvalues) + if (int.TryParse(item, out int n)) + { + string text = ((List)pair.Value.DataSource).First(x => x.Value == n).Text; + pair.Value.SetSelected(pair.Value.FindString(text), true); + } + } + } + } + + private void FieldStepRTB_Enter(object sender, EventArgs e) { _MyStepTabRibbon.MyStepRTB = (StepRTB)sender; } @@ -154,8 +202,7 @@ namespace Volian.Controls.Library { StepRTB cur = _DicStepRtb[EP.name]; string rtf = cur.Rtf; - string newval = DisplayText.StaticStripRtfCommands(rtf, false); // C2020-001: added 'false' - // compare to original and if different, save in proc config. + string newval = DisplayText.StaticStripRtfCommands(rtf, false); string oldval = MyConfig.GetValue("EP", EP.name); if (oldval != newval) { @@ -190,12 +237,24 @@ namespace Volian.Controls.Library ComboBox cmbcur = _DicSingleRO[EP.name]; string newval = cmbcur.SelectedValue.ToString(); string oldval = MyConfig.GetValue("EP", EP.name); + if (newval == "-1") newval = ""; if (newval != oldval) { isDirty = true; MyConfig.SetValue("EP", EP.name, newval); } } + else if (EP.type.ToLower() == "romulti") + { + ListBox lbcur = _DicMultiRO[EP.name]; + string newvalues = String.Join(multiseparator, lbcur.SelectedItems.OfType().Select(item => item.Value)); + string oldvalues = MyConfig.GetValue("EP", EP.name); + if (newvalues != oldvalues) + { + isDirty = true; + MyConfig.SetValue("EP", EP.name, newvalues); + } + } } if (isDirty) { @@ -209,8 +268,6 @@ namespace Volian.Controls.Library annotation.Save(); } } - - } DialogResult = DialogResult.OK; Close(); @@ -229,6 +286,8 @@ namespace Volian.Controls.Library { tb.Enter -= FieldStepRTB_Enter; } - } + + Load -= Form1Load_setDefaults; + } } } \ No newline at end of file