Exemple #1
0
        private void myEditRow(int iRow)
        {
            tParam param = paramList[iRow];

            // if already editing, close previous edit
            if (curInputIndex >= 0)
            {
                myEditClose();
            }
            curInputIndex    = iRow;
            tbEdit.MaxLength = param.maxLengthValue;
            tbEdit.Size      = param.lblValue.Size;
            tbEdit.Margin    = param.lblValue.Margin;
            tbEdit.Text      = "";
            if (param.input == cInputType.NUMBER)
            {
                if (param.value == Configuration.noDataStr)
                {
                    tbEdit.Text = "";
                }
                else
                {
                    tbEdit.Text = param.value;
                }
            }
            else
            {
                if (param.value == Configuration.noDataStr)
                {
                    tbEdit.Text = "";
                }
                else
                {
                    tbEdit.Text = param.lblValue.Text;
                }
            }
            // send label to last row, first column
            param.lblValue.Visible = false;
            TableLayoutPanel1.SetCellPosition(param.lblValue, new TableLayoutPanelCellPosition(0, TableLayoutPanel1.RowCount - 1));
            // position edit control (in second column) in current row
            TableLayoutPanel1.SetRow(tbEdit, curInputIndex);
            //tbEdit.Text = tbEdit.Location.X.ToString & ";" & tbEdit.Location.Y.ToString & " " & _
            //              param.lblValue.Location.X.ToString & ";" & param.lblValue.Location.Y.ToString
            tbEdit.Visible = true;
            tbEdit.Focus();
            tbEdit.SelectionLength = tbEdit.TextLength;
            tbEdit.BringToFront();
        }
Exemple #2
0
 private void myEditClose()
 {
     if (curInputIndex != -1)
     {
         tParam param = paramList[curInputIndex];
         if (param.value != tbEdit.Text && !(param.value == Configuration.noDataStr && tbEdit.Text == ""))
         {
             setValue(param.paramName, tbEdit.Text);
             if (NewValueEvent != null)
             {
                 NewValueEvent(param.paramName, param.value);
             }
         }
         // send edit control to the last row (same second column)
         tbEdit.Visible = false;
         TableLayoutPanel1.SetRow(tbEdit, TableLayoutPanel1.RowCount - 1);
         // re-position label to the editin row, second column
         TableLayoutPanel1.SetCellPosition(param.lblValue, new TableLayoutPanelCellPosition(1, curInputIndex));
         param.lblValue.Visible = true;
         curInputIndex          = -1;
     }
 }
Exemple #3
0
        // Adds a param to the table
        public void addParam(string paramName, string text, cInputType input, string[] options, string[] optionsText, bool bShowCheckBox = false, int maxLength = 0)
        {
            // Creating a new tParam
            tParam param = new tParam();

            // Initializing it
            param.paramName = paramName;

            // param title
            param.lblText           = new Label();
            param.lblText.Name      = "lblName" + paramName;
            param.lblText.ForeColor = textColor;
            //param.lblText.AutoSize = True
            param.lblText.Text    = text;
            param.lblText.Margin  = new Padding(3, 3, 3, 0);
            param.lblText.Padding = new Padding(0);

            param.lblText.TextAlign   = ContentAlignment.TopLeft;              // MiddleLeft
            param.lblText.BorderStyle = System.Windows.Forms.BorderStyle.None; // Windows.Forms.BorderStyle.FixedSingle

            param.lblText.MouseEnter += Param_MouseEnter;
            param.lblText.MouseLeave += Param_MouseLeave;
            //AddHandler param.lblText.MouseUp, AddressOf ParamTable_MouseUp

            // param data
            //param.lblValue = New Label
            //param.lblValue.BorderStyle = Windows.Forms.BorderStyle.None ' Windows.Forms.BorderStyle.FixedSingle
            param.lblValue           = new Button();
            param.lblValue.Name      = "lblValue" + paramName;
            param.lblValue.FlatStyle = FlatStyle.Flat;
            param.lblValue.ForeColor = textColor;
            param.lblValue.Text      = Configuration.noDataStr;
            param.lblValue.Margin    = new Padding(0);
            param.lblValue.Padding   = new Padding(0);
            param.lblValue.Height    = 28;
            param.lblValue.TextAlign = ContentAlignment.TopRight; // MiddleRight

            param.dropList       = new ContextMenuStrip();
            param.maxLengthValue = maxLength;

            if (input == cInputType.BUTTON)
            {
                param.lblValue.FlatAppearance.BorderSize         = 0;
                param.lblValue.FlatAppearance.BorderColor        = Color.LightSteelBlue;
                param.lblValue.FlatAppearance.MouseDownBackColor = Color.LightSteelBlue;
                param.lblValue.FlatAppearance.MouseOverBackColor = Color.LightSteelBlue;
                param.lblValue.Cursor = Cursors.Hand;
                param.lblValue.Click += lblBut_Click;
            }
            else
            {
                param.lblValue.FlatAppearance.BorderSize         = 0;
                param.lblValue.FlatAppearance.MouseDownBackColor = Color.Transparent;
                param.lblValue.FlatAppearance.MouseOverBackColor = Color.Transparent;
                //param.lblValue.AutoSize = True
                param.lblValue.MouseEnter += Param_MouseEnter;
                param.lblValue.MouseLeave += Param_MouseLeave;
                param.lblValue.MouseUp    += ParamTable_MouseUp;
                param.lblValue.KeyDown    += ParamTable_KeyDown;
                param.lblValue.KeyUp      += ParamTable_KeyUp;
                if (input == cInputType.DROPLIST)
                {
                    param.dropList.Items.Clear();
                    foreach (string optionEl in optionsText)
                    {
                        param.dropList.Items.Add(optionEl);
                    }

                    param.dropList.ItemClicked += dropList_ItemClicked;
                }
            }

            // param checkbox
            if (bShowCheckBox)
            {
                param.lblCheck             = new CheckBox();
                param.lblCheck.Name        = "lblCheck" + paramName;
                param.lblCheck.Text        = "";
                param.lblCheck.MouseClick += lblCheck_CheckedChanged;
            }
            else
            {
                param.lblCheck = null;
            }

            // Setting the input
            param.input        = input;
            param.value        = Configuration.noDataStr;
            param.enabled      = true;
            param.optionsValue = options;
            param.optionsText  = optionsText;

            // Adding it to the list
            paramList.Add(param);

            // Adding the row
            TableLayoutPanel1.RowCount++;
            TableLayoutPanel1.SetRow(tbEdit, TableLayoutPanel1.RowCount - 1); // move edit control to the las row
            TableLayoutPanel1.Controls.Add(param.lblText, 0, TableLayoutPanel1.RowCount - 2);
            TableLayoutPanel1.Controls.Add(param.lblValue, 1, TableLayoutPanel1.RowCount - 2);
            if (param.lblCheck != null)
            {
                TableLayoutPanel1.Controls.Add(param.lblCheck, 2, TableLayoutPanel1.RowCount - 2);
            }
            TableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize));

            param.lblText.Width  = get_ptyColumnWidth(0);
            param.lblValue.Width = get_ptyColumnWidth(1);
        }