Esempio n. 1
0
        private void InitTableLayout()
        {
            int    cnt = InitIniDictionary((IniCategory)ComboBoxCategory.SelectedIndex);
            string txt = string.Empty;

            if ((IniCategory)mycategory == IniCategory.APIKeys)
            {
                txt = "OpenAPI key for ";
            }

            for (int r = 0; r < _Ini_URL.Length - 1; r++)
            {
                if (r < cnt)
                {
                    TableLayoutPanel1.GetControlFromPosition(1, r).Text    = txt + dic.ElementAt(r).Key;
                    TableLayoutPanel1.GetControlFromPosition(2, r).Text    = dic.ElementAt(r).Value;
                    TableLayoutPanel1.GetControlFromPosition(2, r).Tag     = dic.ElementAt(r).Key;
                    TableLayoutPanel1.GetControlFromPosition(2, r).Enabled = b[r];
                    ButtonSave.Enabled = (ButtonSave.Enabled || b[r]);
                }
                else
                {
                    TableLayoutPanel1.Controls.Remove(TableLayoutPanel1.GetControlFromPosition(1, r));
                    TableLayoutPanel1.Controls.Remove(TableLayoutPanel1.GetControlFromPosition(2, r));
                }
            }
        }
Esempio n. 2
0
        private void SaveIni()
        {
            XmlDocument doc = new XmlDocument();

            doc.Load(path);
            for (int i = 0; i < dic.Count; i++)
            {
                XmlNode n  = default(XmlNode);
                XmlNode pn = default(XmlNode);
                string  v  = string.Empty;

                if (b[i])
                {
                    v = ((TextBox)TableLayoutPanel1.GetControlFromPosition(2, i)).Text; if (string.IsNullOrEmpty(v))
                    {
                        continue;
                    }
                    n = doc.SelectSingleNode("//Key[text() ='" + dic.ElementAt(i).Key + "']"); if (n == null)
                    {
                        continue;
                    }
                    pn = n.ParentNode;
                    n  = pn.SelectSingleNode("Value"); if (n == null)
                    {
                        n = doc.CreateElement("Value");
                    }
                    n.InnerText = v;
                }
            }
            doc.Save(path);
        }
Esempio n. 3
0
        private void lblBut_Click(System.Object sender, System.EventArgs e)
        {
            int    idx   = TableLayoutPanel1.GetRow((Control)sender);
            tParam param = paramList[idx];

            if (paramTableButtonClickedEvent != null)
            {
                paramTableButtonClickedEvent(param.paramName, param.value);
            }
        }
Esempio n. 4
0
        private void lblCheck_CheckedChanged(System.Object sender, System.Windows.Forms.MouseEventArgs e)
        {
            int    idx   = TableLayoutPanel1.GetRow((Control)sender);
            tParam param = paramList[idx];

            if (paramTableCheckedChangedEvent != null)
            {
                paramTableCheckedChangedEvent(param.paramName, ((CheckBox)sender).Checked);
            }
        }
Esempio n. 5
0
 public int get_ptyRowHeight(int index)
 {
     if (index < TableLayoutPanel1.RowCount)
     {
         int[] mHeights = TableLayoutPanel1.GetRowHeights();
         return(mHeights[index]);
     }
     else
     {
         return(0);
     }
 }
Esempio n. 6
0
 public int get_ptyColumnWidth(int index)
 {
     if (index < TableLayoutPanel1.ColumnCount)
     {
         int[] mWidths = TableLayoutPanel1.GetColumnWidths();
         return(mWidths[index]);
     }
     else
     {
         return(0);
     }
 }
Esempio n. 7
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();
        }
Esempio n. 8
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;
     }
 }
 private void EcrCours_Load(object sender, EventArgs e)
 {
     g = TableLayoutPanel1.CreateGraphics();
     //ecritureTbl = new XmlDocument();
     //ecritureTbl.Load(Application.StartupPath + @"\Ecriturre.xml");//RepLettres = ecritureTbl.GetElementsByTagName("Ecriture")[0].InnerText.Split(','); MessageBox.Show(ecritureTbl.GetElementsByTagName("Ecriture")[0].InnerText.Split(',')[6]);
 }
Esempio n. 10
0
        // Mouse events for selection and modification of parameters
        //Private Sub ParamTable_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
        private void Param_MouseEnter(System.Object sender, System.EventArgs e)
        {
            //Debug.Print("Param_MouseEnter")
            bool bDoFocus = true;
            int  iRow     = -1;

            // 29/07/2015 no pintar ni cambiar foco cuando estoy editando un valor
            if (curInputIndex >= 0)
            {
                // no cambiar focus para que no haga validating del tbEdit
                bDoFocus = false;
            }

            if (ReferenceEquals(((Control)sender).Parent, TableLayoutPanel1))
            {
                iRow = TableLayoutPanel1.GetRow((Control)sender);
                //Debug.Print("iRow=" & iRow.ToString & " - mouseOverIndex=" & mouseOverIndex.ToString)
                //If iRow < 0 Then Exit Sub
                if (iRow != mouseOverIndex)
                {
                    // set previous labels
                    if (mouseOverIndex >= 0)
                    {
                        paramList[mouseOverIndex].lblText.Font       = textFont;
                        paramList[mouseOverIndex].lblText.ForeColor  = textColor;
                        paramList[mouseOverIndex].lblText.BackColor  = Color.Transparent;
                        paramList[mouseOverIndex].lblValue.Font      = textFont;
                        paramList[mouseOverIndex].lblValue.ForeColor = textColor;
                        paramList[mouseOverIndex].lblValue.BackColor = Color.Transparent;
                        paramList[mouseOverIndex].lblValue.Cursor    = Cursors.Default;
                    }
                    paramList[iRow].lblText.Font       = textMouseOverFont;
                    paramList[iRow].lblText.ForeColor  = textMouseOverColor;
                    paramList[iRow].lblText.BackColor  = Color.Transparent;
                    paramList[iRow].lblValue.Font      = textMouseOverFont;
                    paramList[iRow].lblValue.ForeColor = textMouseOverColor;
                    paramList[iRow].lblValue.BackColor = Color.Transparent;
                    if (paramList[iRow].input == cInputType.SWITCH & paramList[iRow].enabled)
                    {
                        // set focus to get key events
                        if (bDoFocus)
                        {
                            paramList[iRow].lblValue.Focus();
                        }
                        if (bControlDown)
                        {
                            paramList[iRow].lblValue.Cursor = Configuration.cursor_switch_minus; // Cursors.PanSouth
                        }
                        else
                        {
                            paramList[iRow].lblValue.Cursor = Configuration.cursor_switch_plus; // Cursors.PanNorth
                        }
                    }
                    else if (paramList[iRow].input != cInputType.FIX & paramList[iRow].enabled)
                    {
                        if (bDoFocus)
                        {
                            paramList[iRow].lblValue.Focus();
                        }
                        paramList[iRow].lblValue.Cursor = Configuration.cursor_hand;
                    }
                    else
                    {
                        if (bDoFocus)
                        {
                            paramList[iRow].lblValue.Focus();
                        }
                        paramList[iRow].lblValue.Cursor = Cursors.Default;
                    }
                }
                mouseOverIndex = TableLayoutPanel1.GetRow((Control)sender);
            }
        }
Esempio n. 11
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);
        }