Esempio n. 1
0
        private void buttonOK_Click(object sender, System.EventArgs e)
        {
            ErrorMessage error = this.system.SpecifyName(this.textBoxName.Text);

            if (error != null)
            {
                UI.ShowError(error);
            }
            this.Close();
        }
Esempio n. 2
0
 private void DetachStreamFromUnitOp(UnitOperation unitOp, ProcessStreamBase ps)
 {
     if (unitOp != null && ps != null)
     {
         ErrorMessage error = unitOp.DetachStream(ps);
         if (error != null)
         {
             UI.ShowError(error);
         }
     }
 }
Esempio n. 3
0
        private void SolvableNameTextBox_Validating(object sender, CancelEventArgs e)
        {
            TextBox tb = (TextBox)sender;

            if (tb.Text.Trim().Equals(""))
            {
                e.Cancel = true;
                string message = "Please specify a name!";
                MessageBox.Show(message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                ErrorMessage error = solvable.SpecifyName(this.Text);
                if (error != null)
                {
                    UI.ShowError(error);
                }
            }
        }
Esempio n. 4
0
        protected virtual void ValidatingHandler(object sender, System.ComponentModel.CancelEventArgs e)
        {
            Solvable solvable = this.solvableCtrl.Solvable;
            TextBox  tb       = (TextBox)sender;

            if (tb.Text.Trim().Equals(""))
            {
                e.Cancel = true;
                string message3 = "Please specify a name!";
                MessageBox.Show(message3, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            else
            {
                ErrorMessage error = solvable.SpecifyName(this.textBoxName.Text);
                if (error != null)
                {
                    UI.ShowError(error);
                }
            }
        }
Esempio n. 5
0
        /// <summary>
        ///  check the input value before start computing
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void ProcessVarObj_Validating(object sender, System.ComponentModel.CancelEventArgs e)
        {
            ErrorMessage error      = null;
            string       inputValue = sender.ToString();

            if (inputValue.Trim().Equals(""))
            {
                if (this.var.IsSpecified)
                {
                    if (this.var is ProcessVarDouble)
                    {
                        ProcessVarDouble varDouble = (ProcessVarDouble)this.var;
                        error = this.var.Owner.Specify(varDouble, Constants.NO_VALUE);
                    }
                    else if (this.var is ProcessVarInt)
                    {
                        ProcessVarInt varInt = (ProcessVarInt)this.var;
                        error = this.var.Owner.Specify(varInt, Constants.NO_VALUE_INT);
                    }
                    if (error != null)
                    {
                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                        UI.ShowError(error);
                    }
                }
            }
            else
            {
                try
                {
                    if (this.var is ProcessVarDouble)
                    {
                        ProcessVarDouble varDouble = (ProcessVarDouble)this.var;
                        double           val       = Double.Parse(inputValue);
                        double           val2      = 0.0;
                        try
                        {
                            if (this.var.IsSpecified)
                            {
                                val2  = UnitSystemService.GetInstance().ConvertToSIValue(this.var.Type, val);
                                error = this.var.Owner.Specify(varDouble, val2);
                                if (error != null)
                                {
                                    if (error.Type == ErrorType.SpecifiedValueCausingOtherVarsInappropriate)
                                    {
                                        ProcVarsInappropriateForm form = new ProcVarsInappropriateForm(this.iNumericFormat, this.var, val, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else if (error.Type == ErrorType.SpecifiedValueCausingOtherVarsOutOfRange &&
                                             error.ProcessVarsAndValues.ProcessVarList.Count == 1)
                                    {
                                        ProcVarsOnlyOneOutOfRangeForm form = new ProcVarsOnlyOneOutOfRangeForm(this.iNumericFormat, this.var.Owner, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else if (error.Type == ErrorType.SpecifiedValueCausingOtherVarsOutOfRange &&
                                             error.ProcessVarsAndValues.ProcessVarList.Count > 1)
                                    {
                                        ProcVarsMoreThenOneOutOfRangeForm form = new ProcVarsMoreThenOneOutOfRangeForm(this.iNumericFormat, this.var.Owner, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else if (error.Type == ErrorType.SpecifiedValueOutOfRange)
                                    {
                                        ProcVarOutOfRangeForm form = new ProcVarOutOfRangeForm(this.iNumericFormat, this.var, val, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else
                                    {
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                        UI.ShowError(error);
                                    }
                                }
                            }
                        }
                        catch (Exception ex1)
                        {
                            e.Cancel = true;
                            string message1 = ex1.ToString();
                            MessageBox.Show(message1, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                        }
                    }
                    else if (this.var is ProcessVarInt)
                    {
                        ProcessVarInt varInt = (ProcessVarInt)this.var;
                        int           val    = Int32.Parse(value);
                        try
                        {
                            if (this.var.IsSpecified)
                            {
                                error = this.var.Owner.Specify(varInt, val);
                                if (error != null)
                                {
                                    if (error.Type == ErrorType.SpecifiedValueCausingOtherVarsInappropriate)
                                    {
                                        ProcVarsInappropriateForm form = new ProcVarsInappropriateForm(this.iNumericFormat, this.var, val, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else if (error.Type == ErrorType.SpecifiedValueCausingOtherVarsOutOfRange &&
                                             error.ProcessVarsAndValues.ProcessVarList.Count == 1)
                                    {
                                        ProcVarsOnlyOneOutOfRangeForm form = new ProcVarsOnlyOneOutOfRangeForm(this.iNumericFormat, this.var.Owner, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else if (error.Type == ErrorType.SpecifiedValueCausingOtherVarsOutOfRange &&
                                             error.ProcessVarsAndValues.ProcessVarList.Count > 1)
                                    {
                                        ProcVarsMoreThenOneOutOfRangeForm form = new ProcVarsMoreThenOneOutOfRangeForm(this.iNumericFormat, this.var.Owner, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else if (error.Type == ErrorType.SpecifiedValueOutOfRange)
                                    {
                                        ProcVarOutOfRangeForm form = new ProcVarOutOfRangeForm(this.iNumericFormat, this.var, val, error);
                                        form.ShowDialog();
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                    }
                                    else
                                    {
                                        this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                                        UI.ShowError(error);
                                    }
                                }
                            }
                        }
                        catch (Exception ex1)
                        {
                            e.Cancel = true;
                            string message1 = ex1.ToString();
                            MessageBox.Show(message1, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                            this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                        }
                    }
                }
                catch (FormatException)
                {
                    e.Cancel = true;
                    string message2 = "Please enter a numeric value!";
                    MessageBox.Show(message2, "Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                    this.UpdateVariableValue(UnitSystemService.GetInstance().CurrentUnitSystem);
                }
            }
        }