Ejemplo n.º 1
0
        public void InitializeVarValuesControl(SolvableControl sovableCtrl)
        {
            ArrayList         varList = sovableCtrl.Solvable.VarList;
            ProcessVarTextBox varTextBox;

            varTextBoxeList = new ArrayList();
            this.SuspendLayout();
            for (int i = 0; i < varList.Count; i++)
            {
                varTextBox = new ProcessVarTextBox();
                varTextBoxeList.Add(varTextBox);
                varTextBox.Location  = new System.Drawing.Point(0, i * 20);
                varTextBox.Size      = new System.Drawing.Size(80, 20);
                varTextBox.TabIndex  = 110 + i;
                varTextBox.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
                varTextBox.KeyUp    += new System.Windows.Forms.KeyEventHandler(this.KeyUpHandler);
                this.Controls.Add(varTextBox);
                varTextBox.InitializeVariable(sovableCtrl.Flowsheet.ApplicationPrefs, ((ProcessVar)varList[i]));
            }

            this.Size = new System.Drawing.Size(80, varTextBoxeList.Count * 20);
            this.ResumeLayout(false);
            this.PerformLayout();
        }
Ejemplo n.º 2
0
        protected int initializeGrid(SolvableControl ctrl, int columnIndex, Boolean bValueOnly, string ctrlType)
        {
            ProcessVar        var;
            ProcessVarLabel   label;
            ProcessVarTextBox valueTextBox;
            ArrayList         varList;
            Label             typeLabel, nameLabel;
            int counter, extraRowCount;

            varList = ctrl.Solvable.VarList;
            if (ctrlType.Length != 0)
            {
                typeLabel           = new Label();
                typeLabel.Size      = new System.Drawing.Size(192, 20);
                typeLabel.Dock      = DockStyle.Fill;
                typeLabel.Anchor    = AnchorStyles.Left;
                typeLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                typeLabel.Text      = ctrlType;
                typeLabel.BackColor = Color.DarkGray;

                nameLabel           = new Label();
                nameLabel.Size      = new System.Drawing.Size(80, 20);
                nameLabel.Dock      = DockStyle.Fill;
                nameLabel.Anchor    = AnchorStyles.Left;
                nameLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
                nameLabel.Text      = ctrl.Solvable.ToString();
                nameLabel.BackColor = Color.DarkGray;
                if (bValueOnly)
                {
                    this.tableLayoutPanel.ColumnCount = columnIndex + 1;
                    this.tableLayoutPanel.Controls.Add(nameLabel, columnIndex, 0);
                }
                else
                {
                    this.tableLayoutPanel.ColumnCount = columnIndex + 2;
                    this.tableLayoutPanel.Controls.Add(typeLabel, columnIndex, 0);
                    this.tableLayoutPanel.Controls.Add(nameLabel, columnIndex + 1, 0);
                }
                extraRowCount = 1;
            }
            else
            {
                extraRowCount = 0;
            }
            // set the property names and values
            for (counter = 0; counter < varList.Count; counter++)
            {
                var = varList[counter] as ProcessVar;
                if (var == null)
                {
                    continue;
                }

                valueTextBox      = new ProcessVarTextBox();
                valueTextBox.Size = new System.Drawing.Size(80, 20);

                valueTextBox.Dock   = DockStyle.Fill;
                valueTextBox.Anchor = AnchorStyles.Left & AnchorStyles.Right & AnchorStyles.Top & AnchorStyles.Bottom;
                valueTextBox.InitializeVariable(solvableCtrl.Flowsheet.ApplicationPrefs, var);

                if (bValueOnly)
                {
                    this.tableLayoutPanel.Controls.Add(valueTextBox, columnIndex, counter + extraRowCount);
                }
                else
                {
                    label          = new ProcessVarLabel();
                    label.Anchor   = System.Windows.Forms.AnchorStyles.Left;
                    label.Size     = new System.Drawing.Size(192, 20);
                    label.AutoSize = false;
                    //label.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
                    label.Dock = DockStyle.Fill;
                    label.Text = var.VarTypeName;
                    label.InitializeVariable(var);

                    this.tableLayoutPanel.Controls.Add(label, columnIndex, counter + extraRowCount);
                    this.tableLayoutPanel.Controls.Add(valueTextBox, columnIndex + 1, counter + extraRowCount);
                }
                this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 24F));
            }
            if (this.tableLayoutPanel.RowCount < counter + extraRowCount)
            {
                this.tableLayoutPanel.RowCount = counter + extraRowCount;
            }
            return(counter + extraRowCount);
        }