C2025-027-Develop-a-way-to-filter-annotations-so-the-user-can-view-only-the-types-they-want-to-see-EP #544
@@ -98,12 +98,15 @@ namespace Volian.Controls.Library
 | 
			
		||||
            // 
 | 
			
		||||
            this.dataview.AllowUserToAddRows = false;
 | 
			
		||||
            this.dataview.AllowUserToDeleteRows = false;
 | 
			
		||||
            this.dataview.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
 | 
			
		||||
            | System.Windows.Forms.AnchorStyles.Right)));
 | 
			
		||||
            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.Size = new System.Drawing.Size(316, 150);
 | 
			
		||||
            this.dataview.TabIndex = 5;
 | 
			
		||||
            this.dataview.CellEndEdit += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataview_CellEndEdit);
 | 
			
		||||
            // 
 | 
			
		||||
            // lbltitle
 | 
			
		||||
            // 
 | 
			
		||||
 
 | 
			
		||||
@@ -11,34 +11,48 @@ using System.Windows.Forms;
 | 
			
		||||
 | 
			
		||||
namespace Volian.Controls.Library
 | 
			
		||||
{
 | 
			
		||||
    //C2025-023 Electronic Procedures
 | 
			
		||||
    //Control for designating which cells in a table require EP input 
 | 
			
		||||
    public partial class TablePropertiesControl : UserControl
 | 
			
		||||
    {
 | 
			
		||||
        //defines the type of possible inputs from an EP viewer
 | 
			
		||||
        public enum EPinputtype
 | 
			
		||||
        {
 | 
			
		||||
            none,
 | 
			
		||||
            textbox,
 | 
			
		||||
            checkbox
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        private DataTable values;
 | 
			
		||||
        private BindingSource bindingSource = null;
 | 
			
		||||
        private int totalrows = 1;
 | 
			
		||||
        private int totalcols = 1;
 | 
			
		||||
        public readonly string epname;
 | 
			
		||||
        private bool IsInitializing;
 | 
			
		||||
 | 
			
		||||
        //initialization / data will be:
 | 
			
		||||
        //initialization / data will be in the format:
 | 
			
		||||
        // totalnumrows,totalnumcols;(row,col):value|(row,col):value...
 | 
			
		||||
        public TablePropertiesControl(string title, string initialvalues)
 | 
			
		||||
        public TablePropertiesControl(string name, string title, string initialvalues)
 | 
			
		||||
        {
 | 
			
		||||
            InitializeComponent();
 | 
			
		||||
 | 
			
		||||
            IsInitializing = true;
 | 
			
		||||
 | 
			
		||||
            epname = name;
 | 
			
		||||
            lbltitle.Text = title;
 | 
			
		||||
            initializevalues(initialvalues);
 | 
			
		||||
            bindingSource = new BindingSource();
 | 
			
		||||
            bindingSource.DataSource = values;
 | 
			
		||||
            bindingSource = new BindingSource(values, "");
 | 
			
		||||
            dataview.DataSource = bindingSource;
 | 
			
		||||
            dataview.AutoGenerateColumns = false;
 | 
			
		||||
 | 
			
		||||
            Load += new EventHandler(FormLoad_setDefaults);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //initialization / data will be:
 | 
			
		||||
        //initialization / data will be in the format:
 | 
			
		||||
        // totalnumrows,totalnumcols;(row,col):value|(row,col):value...
 | 
			
		||||
        private void initializevalues(string initialvalues)
 | 
			
		||||
        {
 | 
			
		||||
            values = new DataTable();
 | 
			
		||||
            values = new DataTable("values");
 | 
			
		||||
 | 
			
		||||
            if (!string.IsNullOrEmpty(initialvalues))
 | 
			
		||||
            {
 | 
			
		||||
@@ -51,7 +65,7 @@ namespace Volian.Controls.Library
 | 
			
		||||
                //(row,col):value
 | 
			
		||||
                foreach (string pair in ivs)
 | 
			
		||||
                {
 | 
			
		||||
                    Match m = Regex.Match(pair, @"\(([\d]),([\d])\):([\w])");
 | 
			
		||||
                    Match m = Regex.Match(pair, @"\(([\d]),([\d])\):([\w]+)");
 | 
			
		||||
                    if (m.Success)
 | 
			
		||||
                    {
 | 
			
		||||
                        int row = int.Parse(m.Groups[1].Value);
 | 
			
		||||
@@ -61,6 +75,8 @@ namespace Volian.Controls.Library
 | 
			
		||||
                    }
 | 
			
		||||
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                values.AcceptChanges();
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
@@ -74,23 +90,11 @@ namespace Volian.Controls.Library
 | 
			
		||||
            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($"Column{c}") { DefaultValue = "none" });
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            //values.Columns.Add(new DataColumn() { DefaultValue = "none" });
 | 
			
		||||
            for (int rw = 0; rw < totalrows; rw++)
 | 
			
		||||
            {
 | 
			
		||||
                values.Rows.Add();
 | 
			
		||||
@@ -103,22 +107,50 @@ namespace Volian.Controls.Library
 | 
			
		||||
            BindingSource bindingSourceDropDown = new BindingSource();
 | 
			
		||||
            bindingSourceDropDown.DataSource = Enum.GetNames(typeof(EPinputtype));
 | 
			
		||||
 | 
			
		||||
            var cName = new DataGridViewComboBoxColumn();
 | 
			
		||||
            cName.DataSource = bindingSourceDropDown;
 | 
			
		||||
            cName.DefaultCellStyle.NullValue = "none";
 | 
			
		||||
 | 
			
		||||
            //in order to achieve a dropdown of possible values need
 | 
			
		||||
            //to remove the auto-inserted columns
 | 
			
		||||
            //that were auto-generated of type type text
 | 
			
		||||
            //when values was bound to the datagrid
 | 
			
		||||
            for (int c = 0; c < totalcols; c++)
 | 
			
		||||
            {
 | 
			
		||||
                dataview.Columns.RemoveAt(c);
 | 
			
		||||
                var cName = new DataGridViewComboBoxColumn();
 | 
			
		||||
                cName.DataSource = bindingSourceDropDown;
 | 
			
		||||
                cName.DefaultCellStyle.NullValue = "none";
 | 
			
		||||
                dataview.Columns.Insert(c, cName);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            NumRows.Value = totalrows;
 | 
			
		||||
            NumCols.Value = totalcols;
 | 
			
		||||
            IsInitializing = false;
 | 
			
		||||
            setDataViewtoValues();
 | 
			
		||||
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //set the display cells to match the values in the datatable for initialization
 | 
			
		||||
        //and resize of the dataviewgrid
 | 
			
		||||
        void setDataViewtoValues()
 | 
			
		||||
        {
 | 
			
		||||
            if (!IsInitializing)
 | 
			
		||||
            {
 | 
			
		||||
                for (int c = 0; c < totalcols; c++)
 | 
			
		||||
                {
 | 
			
		||||
                    for (int rw = 0; rw < totalrows; rw++)
 | 
			
		||||
                    {
 | 
			
		||||
                        dataview.Rows[rw].Cells[c].Value = values.Rows[rw][c];
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        //Get storage string for storing table values in db
 | 
			
		||||
        // data will be:
 | 
			
		||||
        // data will be returned in the format:
 | 
			
		||||
        // totalnumrows,totalnumcols;(row,col):value|(row,col):value...
 | 
			
		||||
        public string GetStorageValue()
 | 
			
		||||
        {
 | 
			
		||||
            //force any in progress editing to commit.
 | 
			
		||||
            ((BindingSource)dataview.DataSource).EndEdit();
 | 
			
		||||
 | 
			
		||||
            StringBuilder bldr = new StringBuilder();
 | 
			
		||||
            bldr.Append($"{totalrows},{totalcols}");
 | 
			
		||||
            List<string> points = new List<string>();
 | 
			
		||||
@@ -160,6 +192,7 @@ namespace Volian.Controls.Library
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            totalrows = endNumRows;
 | 
			
		||||
            setDataViewtoValues();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        private void NumCols_ValueChanged(object sender, EventArgs e)
 | 
			
		||||
@@ -170,10 +203,6 @@ namespace Volian.Controls.Library
 | 
			
		||||
            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)
 | 
			
		||||
            {
 | 
			
		||||
@@ -184,24 +213,28 @@ namespace Volian.Controls.Library
 | 
			
		||||
            //add cols till equal
 | 
			
		||||
            while (curNumCols < endNumCols)
 | 
			
		||||
            {
 | 
			
		||||
                values.Columns.Add(new DataColumn() { DefaultValue = "none"});
 | 
			
		||||
                values.Columns.Add(new DataColumn($"Column{curNumCols + 1}") { DefaultValue = "none"});
 | 
			
		||||
                if (dataview.Columns.Count > curNumCols) dataview.Columns.RemoveAt(curNumCols);
 | 
			
		||||
                var cName = new DataGridViewComboBoxColumn();
 | 
			
		||||
                cName.DataSource = bindingSourceDropDown;
 | 
			
		||||
                cName.DefaultCellStyle.NullValue = "none";
 | 
			
		||||
                dataview.Columns.Add(cName);
 | 
			
		||||
 | 
			
		||||
                curNumCols++;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            totalcols = endNumCols;
 | 
			
		||||
 | 
			
		||||
            setDataViewtoValues();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        public enum EPinputtype
 | 
			
		||||
        //set the datatable value to match the changed datagridview value
 | 
			
		||||
        //for some reason despite being bound, does not automatically update 
 | 
			
		||||
        // (it may be that datatable as a bindingsource does not implement INotifyProperty
 | 
			
		||||
        //  and thus needs manually set like this)
 | 
			
		||||
        private void dataview_CellEndEdit(object sender, DataGridViewCellEventArgs e)
 | 
			
		||||
        {
 | 
			
		||||
            none,
 | 
			
		||||
            textbox,
 | 
			
		||||
            checkbox
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
            values.Rows[e.RowIndex][e.ColumnIndex] = (string) dataview.Rows[e.RowIndex].Cells[e.ColumnIndex].Value;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
@@ -25,6 +25,7 @@ namespace Volian.Controls.Library
 | 
			
		||||
		private Dictionary<string, ComboBox> _DicComboBox;
 | 
			
		||||
		private Dictionary<string, ComboBox> _DicSingleRO;
 | 
			
		||||
		private Dictionary<string, ListBoxMulti> _DicMultiRO;
 | 
			
		||||
		private TablePropertiesControl _TablePropControl;
 | 
			
		||||
 | 
			
		||||
		private string multiseparator = ",";
 | 
			
		||||
 | 
			
		||||
@@ -150,10 +151,13 @@ namespace Volian.Controls.Library
 | 
			
		||||
					panelEP.Controls.Add(lb, 1, panelEP.RowCount - 1);
 | 
			
		||||
 | 
			
		||||
				}
 | 
			
		||||
				if (EP.type.ToLower() == "tableinput")
 | 
			
		||||
				//note will allow only 1 tableproperties control since it is a 1:1 match with the table that is in the step
 | 
			
		||||
				if (EP.type.ToLower() == "tableinput" && _TablePropControl == null)
 | 
			
		||||
				{
 | 
			
		||||
					TablePropertiesControl tp = new TablePropertiesControl(EP.text, null);
 | 
			
		||||
					panelEP.Controls.Add(tp, 1, panelEP.RowCount - 1);
 | 
			
		||||
					string val = MyConfig.GetValue("EP", EP.name);
 | 
			
		||||
					_TablePropControl = new TablePropertiesControl(EP.name, EP.text, val);
 | 
			
		||||
					_TablePropControl.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top;
 | 
			
		||||
					panelEP.Controls.Add(_TablePropControl, 1, panelEP.RowCount - 1);
 | 
			
		||||
 | 
			
		||||
				}
 | 
			
		||||
 | 
			
		||||
@@ -265,6 +269,16 @@ namespace Volian.Controls.Library
 | 
			
		||||
						MyConfig.SetValue("EP", EP.name, newvalues);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				else if (EP.type.ToLower() == "tableinput" && EP.name == _TablePropControl.epname)
 | 
			
		||||
				{
 | 
			
		||||
					string newvalues = _TablePropControl.GetStorageValue();
 | 
			
		||||
					string oldvalues = MyConfig.GetValue("EP", EP.name);
 | 
			
		||||
					if (newvalues != oldvalues)
 | 
			
		||||
					{
 | 
			
		||||
						isDirty = true;
 | 
			
		||||
						MyConfig.SetValue("EP", EP.name, newvalues);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			if (isDirty)
 | 
			
		||||
			{
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user