C2025-023 - Electronic Procedures - Modifications to PROMS

Working on Adding functionality for EP input for tables
This commit is contained in:
Matthew Schill 2025-04-23 07:42:28 -04:00
parent 8ef08c53b3
commit 6db9567eb9
6 changed files with 489 additions and 0 deletions

Binary file not shown.

View File

@ -0,0 +1,146 @@

namespace Volian.Controls.Library
{
partial class TablePropertiesControl
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Component Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.lbl_Rows = new System.Windows.Forms.Label();
this.lbl_Cols = new System.Windows.Forms.Label();
this.NumRows = new System.Windows.Forms.NumericUpDown();
this.NumCols = new System.Windows.Forms.NumericUpDown();
this.dataview = new System.Windows.Forms.DataGridView();
this.lbltitle = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.NumRows)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.NumCols)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.dataview)).BeginInit();
this.SuspendLayout();
//
// lbl_Rows
//
this.lbl_Rows.AutoSize = true;
this.lbl_Rows.Location = new System.Drawing.Point(0, 34);
this.lbl_Rows.Name = "lbl_Rows";
this.lbl_Rows.Size = new System.Drawing.Size(89, 13);
this.lbl_Rows.TabIndex = 0;
this.lbl_Rows.Text = "Number of Rows:";
//
// lbl_Cols
//
this.lbl_Cols.AutoSize = true;
this.lbl_Cols.Location = new System.Drawing.Point(0, 56);
this.lbl_Cols.Name = "lbl_Cols";
this.lbl_Cols.Size = new System.Drawing.Size(102, 13);
this.lbl_Cols.TabIndex = 1;
this.lbl_Cols.Text = "Number of Columns:";
//
// NumRows
//
this.NumRows.Location = new System.Drawing.Point(114, 32);
this.NumRows.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.NumRows.Name = "NumRows";
this.NumRows.Size = new System.Drawing.Size(47, 20);
this.NumRows.TabIndex = 3;
this.NumRows.Value = new decimal(new int[] {
1,
0,
0,
0});
this.NumRows.ValueChanged += new System.EventHandler(this.NumRows_ValueChanged);
//
// NumCols
//
this.NumCols.Location = new System.Drawing.Point(114, 54);
this.NumCols.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.NumCols.Name = "NumCols";
this.NumCols.Size = new System.Drawing.Size(47, 20);
this.NumCols.TabIndex = 4;
this.NumCols.Value = new decimal(new int[] {
1,
0,
0,
0});
this.NumCols.ValueChanged += new System.EventHandler(this.NumCols_ValueChanged);
//
// dataview
//
this.dataview.AllowUserToAddRows = false;
this.dataview.AllowUserToDeleteRows = false;
this.dataview.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataview.ColumnHeadersVisible = false;
this.dataview.Location = new System.Drawing.Point(3, 73);
this.dataview.Name = "dataview";
this.dataview.Size = new System.Drawing.Size(240, 150);
this.dataview.TabIndex = 5;
//
// lbltitle
//
this.lbltitle.AutoSize = true;
this.lbltitle.Font = new System.Drawing.Font("Microsoft Sans Serif", 10F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lbltitle.Location = new System.Drawing.Point(3, 4);
this.lbltitle.Name = "lbltitle";
this.lbltitle.Size = new System.Drawing.Size(0, 17);
this.lbltitle.TabIndex = 6;
//
// TablePropertiesControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.lbltitle);
this.Controls.Add(this.dataview);
this.Controls.Add(this.NumCols);
this.Controls.Add(this.NumRows);
this.Controls.Add(this.lbl_Cols);
this.Controls.Add(this.lbl_Rows);
this.Name = "TablePropertiesControl";
this.Size = new System.Drawing.Size(319, 252);
((System.ComponentModel.ISupportInitialize)(this.NumRows)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.NumCols)).EndInit();
((System.ComponentModel.ISupportInitialize)(this.dataview)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label lbl_Rows;
private System.Windows.Forms.Label lbl_Cols;
private System.Windows.Forms.NumericUpDown NumRows;
private System.Windows.Forms.NumericUpDown NumCols;
private System.Windows.Forms.DataGridView dataview;
private System.Windows.Forms.Label lbltitle;
}
}

View File

@ -0,0 +1,207 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Volian.Controls.Library
{
public partial class TablePropertiesControl : UserControl
{
private DataTable values;
private BindingSource bindingSource = null;
private int totalrows = 1;
private int totalcols = 1;
//initialization / data will be:
// totalnumrows,totalnumcols;(row,col):value|(row,col):value...
public TablePropertiesControl(string title, string initialvalues)
{
InitializeComponent();
lbltitle.Text = title;
initializevalues(initialvalues);
bindingSource = new BindingSource();
bindingSource.DataSource = values;
dataview.DataSource = bindingSource;
dataview.AutoGenerateColumns = false;
Load += new EventHandler(FormLoad_setDefaults);
}
//initialization / data will be:
// totalnumrows,totalnumcols;(row,col):value|(row,col):value...
private void initializevalues(string initialvalues)
{
values = new DataTable();
if (!string.IsNullOrEmpty(initialvalues))
{
string[] grp = initialvalues.Split(';');
string[] total = grp[0].Split(',');
initializedt(int.Parse(total[0]), int.Parse(total[1]));
string[] ivs = grp[1].Split('|');
//pair will be of format:
//(row,col):value
foreach (string pair in ivs)
{
Match m = Regex.Match(pair, @"\(([\d]),([\d])\):([\w])");
if (m.Success)
{
int row = int.Parse(m.Groups[1].Value);
int col = int.Parse(m.Groups[2].Value);
string v = m.Groups[3].Value;
values.Rows[row][col] = v;
}
}
}
else
{
initializedt(1, 1);
}
}
//initialize the blank datatable
private void initializedt(int numrows, int numcols)
{
totalrows = numrows;
totalcols = numcols;
BindingSource bindingSourceDropDown = new BindingSource();
bindingSourceDropDown.DataSource = Enum.GetNames(typeof(EPinputtype));
var cName = new DataGridViewComboBoxColumn();
cName.DataSource = bindingSourceDropDown;
//foreach (string n in Enum.GetNames(typeof(EPinputtype))) cName.Items.Add(n);
cName.DefaultCellStyle.NullValue = "none";
for (int c = 0; c < totalcols; c++)
{
dataview.Columns.Add(cName);
values.Columns.Add();
//dataview.Columns[c].CellTemplate = new DataGridViewComboBoxCell() { DataSource = bindingSourceDropDown };
}
//values.Columns.Add(new DataColumn() { DefaultValue = "none" });
for (int rw = 0; rw < totalrows; rw++)
{
values.Rows.Add();
}
}
void FormLoad_setDefaults(object sender, EventArgs e)
{
BindingSource bindingSourceDropDown = new BindingSource();
bindingSourceDropDown.DataSource = Enum.GetNames(typeof(EPinputtype));
var cName = new DataGridViewComboBoxColumn();
cName.DataSource = bindingSourceDropDown;
cName.DefaultCellStyle.NullValue = "none";
for (int c = 0; c < totalcols; c++)
{
dataview.Columns.RemoveAt(c);
dataview.Columns.Insert(c, cName);
}
}
//Get storage string for storing table values in db
// data will be:
// totalnumrows,totalnumcols;(row,col):value|(row,col):value...
public string GetStorageValue()
{
StringBuilder bldr = new StringBuilder();
bldr.Append($"{totalrows},{totalcols}");
List<string> points = new List<string>();
for (int rw = 0; rw < values.Rows.Count; rw++)
{
for (int col = 0; col < values.Columns.Count; col++)
{
if ((string) values.Rows[rw][col] != "none")
points.Add($"({rw},{col}):{values.Rows[rw][col]}");
}
}
if (points.Count > 0)
{
bldr.Append(";");
bldr.Append(string.Join("|", points));
}
return bldr.ToString();
}
private void NumRows_ValueChanged(object sender, EventArgs e)
{
int endNumRows = (int)NumRows.Value;
int curNumRows = totalrows;
//remove rows till equal
while (curNumRows > endNumRows)
{
values.Rows.RemoveAt(curNumRows - 1);
curNumRows--;
}
//add rows till equal
while (curNumRows < endNumRows)
{
values.Rows.Add();
curNumRows++;
}
totalrows = endNumRows;
}
private void NumCols_ValueChanged(object sender, EventArgs e)
{
int endNumCols = (int)NumCols.Value;
int curNumCols = totalcols;
BindingSource bindingSourceDropDown = new BindingSource();
bindingSourceDropDown.DataSource = Enum.GetNames(typeof(EPinputtype));
var cName = new DataGridViewComboBoxColumn();
cName.DataSource = bindingSourceDropDown;
cName.DefaultCellStyle.NullValue = "none";
//remove cols till equal
while (curNumCols > endNumCols)
{
values.Columns.RemoveAt(curNumCols - 1);
dataview.Columns.RemoveAt(curNumCols - 1);
curNumCols--;
}
//add cols till equal
while (curNumCols < endNumCols)
{
values.Columns.Add(new DataColumn() { DefaultValue = "none"});
if (dataview.Columns.Count > curNumCols) dataview.Columns.RemoveAt(curNumCols);
dataview.Columns.Add(cName);
curNumCols++;
}
totalcols = endNumCols;
}
public enum EPinputtype
{
none,
textbox,
checkbox
};
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -383,6 +383,12 @@
</Compile> </Compile>
<Compile Include="RomanNumeral.cs" /> <Compile Include="RomanNumeral.cs" />
<Compile Include="RTBAPI.cs" /> <Compile Include="RTBAPI.cs" />
<Compile Include="TablePropertiesControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="TablePropertiesControl.Designer.cs">
<DependentUpon>TablePropertiesControl.cs</DependentUpon>
</Compile>
<Compile Include="TransPanel.cs"> <Compile Include="TransPanel.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
@ -528,6 +534,9 @@
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="TablePropertiesControl.resx">
<DependentUpon>TablePropertiesControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="vlnExpander.resx"> <EmbeddedResource Include="vlnExpander.resx">
<DependentUpon>vlnExpander.cs</DependentUpon> <DependentUpon>vlnExpander.cs</DependentUpon>
<SubType>Designer</SubType> <SubType>Designer</SubType>

View File

@ -150,6 +150,13 @@ namespace Volian.Controls.Library
panelEP.Controls.Add(lb, 1, panelEP.RowCount - 1); panelEP.Controls.Add(lb, 1, panelEP.RowCount - 1);
} }
if (EP.type.ToLower() == "tableinput")
{
TablePropertiesControl tp = new TablePropertiesControl(EP.text, null);
panelEP.Controls.Add(tp, 1, panelEP.RowCount - 1);
}
} }
Load += new EventHandler(Form1Load_setDefaults); Load += new EventHandler(Form1Load_setDefaults);