private void Solvable_NameChanged(object sender, string newName, string oldName) { this.flowsheet.ConnectionManager.SetOwner(this.NameControl.Text, newName); this.NameControl.Text = newName; UI.SetCtrlSize(this.NameControl); }
private void ProcessVarTextBox_Validating(object sender, System.ComponentModel.CancelEventArgs e) { ErrorMessage error = null; if (this.Text.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(this.Text); 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(this.Text); 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); } } }
private void Solvable_SolveComplete(object sender, SolveState solveState) { UI.SetStatusTextAndIcon(this.statusBarPanel, solveState); }