diff --git a/PROMS/Formats/epall/EPFormatTST1.xml b/PROMS/Formats/epall/EPFormatTST1.xml index c0d3ce52..eb2888d1 100644 Binary files a/PROMS/Formats/epall/EPFormatTST1.xml and b/PROMS/Formats/epall/EPFormatTST1.xml differ diff --git a/PROMS/Volian.Controls.Library/TablePropertiesControl.Designer.cs b/PROMS/Volian.Controls.Library/TablePropertiesControl.Designer.cs new file mode 100644 index 00000000..89653836 --- /dev/null +++ b/PROMS/Volian.Controls.Library/TablePropertiesControl.Designer.cs @@ -0,0 +1,146 @@ + +namespace Volian.Controls.Library +{ + partial class TablePropertiesControl + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Component Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + 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; + } +} diff --git a/PROMS/Volian.Controls.Library/TablePropertiesControl.cs b/PROMS/Volian.Controls.Library/TablePropertiesControl.cs new file mode 100644 index 00000000..9e02019a --- /dev/null +++ b/PROMS/Volian.Controls.Library/TablePropertiesControl.cs @@ -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 points = new List(); + 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 + }; + + } + +} \ No newline at end of file diff --git a/PROMS/Volian.Controls.Library/TablePropertiesControl.resx b/PROMS/Volian.Controls.Library/TablePropertiesControl.resx new file mode 100644 index 00000000..1af7de15 --- /dev/null +++ b/PROMS/Volian.Controls.Library/TablePropertiesControl.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/PROMS/Volian.Controls.Library/Volian.Controls.Library.csproj b/PROMS/Volian.Controls.Library/Volian.Controls.Library.csproj index 87305e39..ae6f5783 100644 --- a/PROMS/Volian.Controls.Library/Volian.Controls.Library.csproj +++ b/PROMS/Volian.Controls.Library/Volian.Controls.Library.csproj @@ -383,6 +383,12 @@ + + UserControl + + + TablePropertiesControl.cs + Component @@ -528,6 +534,9 @@ ResXFileCodeGenerator Resources.Designer.cs + + TablePropertiesControl.cs + vlnExpander.cs Designer diff --git a/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs b/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs index 03901008..80cf79f5 100644 --- a/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs +++ b/PROMS/Volian.Controls.Library/frmEPAnnotationDetails.cs @@ -150,6 +150,13 @@ namespace Volian.Controls.Library 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);