Exemple #1
0
        public ProcVarsMoreThenOneOutOfRangeForm(INumericFormat iNumericFormat, IProcessVarOwner solvable, ErrorMessage error)
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            this.solvable = solvable;
            this.Text     = error.Title;

            // display the message
            this.labelMessage.Text = error.Message;

            IEnumerator en = error.ProcessVarsAndValues.ProcessVarList.GetEnumerator();

            while (en.MoveNext())
            {
                ProcessVar pv                    = (ProcessVar)en.Current;
                object     minMaxVals            = error.ProcessVarsAndValues.GetVarRange(pv);
                MinMaxProcVarElementControl ctrl = new MinMaxProcVarElementControl(iNumericFormat, pv, minMaxVals);
                ctrl.Dock = DockStyle.Top;
                this.panelCenter.Controls.Add(ctrl);
                ctrl.BringToFront();
            }
        }
Exemple #2
0
        private void buttonOk_Click(object sender, System.EventArgs e)
        {
            bool numericFormatOk = true;

            IEnumerator en = this.panelCenter.Controls.GetEnumerator();

            while (en.MoveNext())
            {
                Control ctrl = (Control)en.Current;
                if (ctrl is MinMaxProcVarElementControl)
                {
                    MinMaxProcVarElementControl pveCtrl = ctrl as MinMaxProcVarElementControl;
                    if (!pveCtrl.IsNewValueValid)
                    {
                        numericFormatOk = false;
                        break;
                    }
                }
            }

            if (numericFormatOk)
            {
                // build the hashtable with procVars and values
                Hashtable hashtable = new Hashtable();

                IEnumerator en2 = this.panelCenter.Controls.GetEnumerator();
                while (en2.MoveNext())
                {
                    Control ctrl = (Control)en2.Current;
                    if (ctrl is MinMaxProcVarElementControl)
                    {
                        MinMaxProcVarElementControl pveCtrl = ctrl as MinMaxProcVarElementControl;
                        hashtable.Add(pveCtrl.Variable, pveCtrl.NewValue);
                    }
                }

                ErrorMessage error = this.solvable.Specify(hashtable);
                if (error != null)
                {
                    UI.ShowError(error);
                }
                this.Close();
            }
            else
            {
                string message = "Please enter numeric values!";
                MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }