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

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

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,28 +124,70 @@ 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);
}
private void FieldStepRTB_Enter(object sender, EventArgs e)
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);
}
}
}
}
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<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;
}
}
}