C2025-023 - Electronic Procedures - Modifications to PROMS - checkin #2

This commit is contained in:
Matthew Schill 2025-04-09 15:22:36 -04:00
parent 6fd84e2f2a
commit 389b9e382b
2 changed files with 99 additions and 24 deletions

View File

@ -316,10 +316,10 @@ namespace VEPROMS.CSLA.Library
}
//return a list of items based on the ROsource specified in the EPFormat File
public Dictionary<int, string> getROList(AnnotationInfo currAnn)
public List<ROListItem> getROList(AnnotationInfo currAnn, bool includeblank)
{
if (string.IsNullOrEmpty(rosource))
return new Dictionary<int, string>();
return new List<ROListItem>();
try
{
@ -329,8 +329,11 @@ namespace VEPROMS.CSLA.Library
string roid = FormatRoidKey(rosource, false);
rochild[] children = lookup.GetRoChildrenByRoid(roid);
List<ROListItem> mylist = children.Select(x => new ROListItem(x.title, x.ID)).ToList();
if (includeblank)
mylist.Insert(0, new ROListItem("", -1));
return children.Select(x => new { x.ID, x.title }).ToDictionary(t => t.ID, t => t.title);
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
}

View File

@ -24,6 +24,9 @@ namespace Volian.Controls.Library
private Dictionary<string, CheckBox> _DicCheckBox;
private Dictionary<string, ComboBox> _DicComboBox;
private Dictionary<string, ComboBox> _DicSingleRO;
private Dictionary<string, ListBox> _DicMultiRO;
private string multiseparator = ",";
public frmEPAnnotationDetails(AnnotationInfo currAnn)
{
@ -32,6 +35,7 @@ namespace Volian.Controls.Library
_DicCheckBox = new Dictionary<string, CheckBox>();
_DicComboBox = new Dictionary<string, ComboBox>();
_DicSingleRO = new Dictionary<string, ComboBox>();
_DicMultiRO = new Dictionary<string, ListBox>();
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,24 +124,66 @@ namespace Volian.Controls.Library
{
ComboBox cmb = new ComboBox();
cmb.Visible = true;
cmb.DisplayMember = "Value";
cmb.ValueMember = "Key";
Dictionary<int, string> 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<ROListItem> 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<ROListItem> 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);
}
void Form1Load_setDefaults(object sender, EventArgs e)
{
foreach (KeyValuePair<string, ComboBox> 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<string, ListBox> 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<ROListItem>)pair.Value.DataSource).First(x => x.Value == n).Text;
pair.Value.SetSelected(pair.Value.FindString(text), true);
}
}
}
}
@ -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<ROListItem>().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;
}
}
}