public void SetDuhringLinesCache(DryingMaterialCache dryingMaterialCache, INumericFormat iNumericFormat) { this.iNumericFormat = iNumericFormat; this.baseIndex = 0; this.panel.Click += new EventHandler(panel_Click); this.SetUnits(UnitSystemService.GetInstance().CurrentUnitSystem); UnitSystemService.GetInstance().CurrentUnitSystemChanged += new CurrentUnitSystemChangedEventHandler(DuhringLinesControl_CurrentUnitSystemChanged); this.duhringLinesCache = new DuhringLinesCache(dryingMaterialCache); this.UpdateTheUI(iNumericFormat, this.duhringLinesCache); this.duhringLinesCache.DuhringLinesChanged += new DuhringLinesChangedEventHandler(duhringLinesCache_DuhringLinesChanged); }
public override string ToPrint() { UnitSystem us = UnitSystemService.GetInstance().CurrentUnitSystem; string nfs = this.flowsheet.ApplicationPrefs.NumericFormatString; StringBuilder sb = new StringBuilder(); sb.Append("Tee: "); sb.Append(this.Tee.Name); sb.Append("\r\n"); sb.Append(UI.UNDERLINE); sb.Append("\r\n"); return(sb.ToString()); }
public static string GetUnitName(ProcessVar var, UnitSystem unitSystem) { string unit = UnitSystemService.GetInstance().GetUnitAsString(var.Type); if (unit != null && !unit.Trim().Equals("")) { return(unit); } else { return(null); } //return unit; }
public override string ToPrint() { UnitSystem us = UnitSystemService.GetInstance().CurrentUnitSystem; string nfs = this.flowsheet.ApplicationPrefs.NumericFormatString; StringBuilder sb = new StringBuilder(); sb.Append("Wet Scrubber: "); sb.Append(this.WetScrubber.Name); sb.Append("\r\n"); sb.Append(UI.UNDERLINE); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.WetScrubber.GasPressureDrop, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.WetScrubber.GasPressureDrop, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.WetScrubber.CollectionEfficiency, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.WetScrubber.CollectionEfficiency, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.WetScrubber.InletParticleLoading, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.WetScrubber.InletParticleLoading, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.WetScrubber.OutletParticleLoading, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.WetScrubber.OutletParticleLoading, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.WetScrubber.ParticleCollectionRate, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.WetScrubber.ParticleCollectionRate, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.WetScrubber.MassFlowRateOfParticleLostToGasOutlet, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.WetScrubber.MassFlowRateOfParticleLostToGasOutlet, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.WetScrubber.LiquidToGasRatio, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.WetScrubber.LiquidToGasRatio, us, nfs)); sb.Append("\r\n"); return(sb.ToString()); }
public override string ToPrint() { UnitSystem us = UnitSystemService.GetInstance().CurrentUnitSystem; string nfs = this.flowsheet.ApplicationPrefs.NumericFormatString; StringBuilder sb = new StringBuilder(); sb.Append("Process Stream: "); sb.Append(this.ProcessStream.Name); sb.Append("\r\n"); sb.Append(UI.UNDERLINE); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.ProcessStream.MassFlowRate, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.ProcessStream.MassFlowRate, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.ProcessStream.VolumeFlowRate, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.ProcessStream.VolumeFlowRate, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.ProcessStream.Pressure, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.ProcessStream.Pressure, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.ProcessStream.Temperature, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.ProcessStream.Temperature, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.ProcessStream.SpecificEnthalpy, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.ProcessStream.SpecificEnthalpy, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.ProcessStream.SpecificHeat, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.ProcessStream.SpecificHeat, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.ProcessStream.Density, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.ProcessStream.Density, us, nfs)); sb.Append("\r\n"); return(sb.ToString()); }
public void SetDuhringLinesCache(DryingMaterialCache dryingMaterialCache) { // TODO: from where to get the numeric format? this.iNumericFormat = new MainNumericFormat(); this.baseIndex = 0; this.panel.Click += new EventHandler(panel_Click); this.SetUnits(UnitSystemService.GetInstance().CurrentUnitSystem); UnitSystemService.GetInstance().CurrentUnitSystemChanged += new CurrentUnitSystemChangedEventHandler(DuhringLinesControl_CurrentUnitSystemChanged); this.duhringLinesCache = new DuhringLinesCache(dryingMaterialCache); this.UpdateTheUI(iNumericFormat, this.duhringLinesCache); this.duhringLinesCache.DuhringLinesChanged += new DuhringLinesChangedEventHandler(duhringLinesCache_DuhringLinesChanged); }
public static string GetVariableName(ProcessVar var, UnitSystem unitSystem) { string name = null; string unit = UnitSystemService.GetInstance().GetUnitAsString(var.Type); if (unit != null && !unit.Trim().Equals("")) { name = var.VarTypeName + " (" + unit + ")"; } else { name = var.VarTypeName; } return(name); }
public void InitializeCurrentUnitSystem() { UnitSystemCatalog catalog = UnitSystemService.GetInstance().GetUnitSystemCatalog(); UnitSystem us = catalog.Get(this.currentUnitSystemName); if (us != null) { UnitSystemService.GetInstance().CurrentUnitSystem = us; } else { UnitSystem us2 = catalog.Get("SI-2"); UnitSystemService.GetInstance().CurrentUnitSystem = us2; } }
public override string ToPrint() { UnitSystem us = UnitSystemService.GetInstance().CurrentUnitSystem; string nfs = this.flowsheet.NumericFormatString; StringBuilder sb = new StringBuilder(); sb.Append(UI.GetVariableName(this.FabricFilter.GasPressureDrop, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.FabricFilter.GasPressureDrop, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.FabricFilter.CollectionEfficiency, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.FabricFilter.CollectionEfficiency, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.FabricFilter.InletParticleLoading, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.FabricFilter.InletParticleLoading, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.FabricFilter.OutletParticleLoading, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.FabricFilter.OutletParticleLoading, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.FabricFilter.ParticleCollectionRate, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.FabricFilter.ParticleCollectionRate, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.FabricFilter.MassFlowRateOfParticleLostToGasOutlet, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.FabricFilter.MassFlowRateOfParticleLostToGasOutlet, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.FabricFilter.GasToClothRatio, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.FabricFilter.GasToClothRatio, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.FabricFilter.TotalFilteringArea, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.FabricFilter.TotalFilteringArea, us, nfs)); sb.Append("\r\n"); return(sb.ToString()); }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { UnitSystemCatalog unitSystemCatalog = UnitSystemService.GetInstance().GetUnitSystemCatalog(); unitSystemCatalog.UnitSystemAdded -= new UnitSystemAddedEventHandler(unitSystemCatalog_UnitSystemAdded); unitSystemCatalog.UnitSystemDeleted -= new UnitSystemDeletedEventHandler(unitSystemCatalog_UnitSystemDeleted); unitSystemCatalog.UnitSystemChanged -= new UnitSystemChangedEventHandler(unitSystemCatalog_UnitSystemChanged); if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); }
private object GetNewValue() { object newVal = null; if (this.textBoxNewValue.Text.Trim().Equals("")) { if (this.var is ProcessVarDouble) { newVal = Constants.NO_VALUE; } else if (this.var is ProcessVarInt) { newVal = Constants.NO_VALUE_INT; } } else { if (this.var is ProcessVarDouble) { try { ProcessVarDouble varDouble = (ProcessVarDouble)this.var; double val = Double.Parse(this.textBoxNewValue.Text); double val2 = UnitSystemService.GetInstance().ConvertToSIValue(this.var.Type, val); newVal = val2; } catch (FormatException) { newVal = Constants.NO_VALUE; } } else if (this.var is ProcessVarInt) { try { ProcessVarInt varInt = (ProcessVarInt)this.var; int val = Int32.Parse(this.textBoxNewValue.Text); newVal = val; } catch (FormatException) { newVal = Constants.NO_VALUE_INT; } } } return(newVal); }
private void SetPlotInfo(Plot2D p2d) { this.inConstruction = true; this.domainUpDownParamValues.Enabled = true; this.textBoxParamMax.Enabled = true; this.textBoxParamMin.Enabled = true; this.textBoxXMax.Enabled = true; this.textBoxXMin.Enabled = true; this.textBoxYMax.Enabled = true; this.textBoxYMin.Enabled = true; this.checkBoxDetails.Enabled = true; // TODO convert from SI PhysicalQuantity pq = p2d.PlotVariableX.Variable.Type; double newVal = UnitSystemService.GetInstance().ConvertToSIValue(pq, p2d.PlotVariableX.Max); this.textBoxXMax.Text = newVal.ToString(); newVal = UnitSystemService.GetInstance().ConvertToSIValue(pq, p2d.PlotVariableX.Min); this.textBoxXMin.Text = newVal.ToString(); pq = p2d.PlotVariableY.Variable.Type; newVal = UnitSystemService.GetInstance().ConvertToSIValue(pq, p2d.PlotVariableY.Max); this.textBoxYMax.Text = newVal.ToString(); newVal = UnitSystemService.GetInstance().ConvertToSIValue(pq, p2d.PlotVariableY.Min); this.textBoxYMin.Text = newVal.ToString(); if (p2d.IncludePlotParameter) { this.groupBoxParam.Visible = true; this.domainUpDownParamValues.SelectedItem = p2d.PlotParameter.NumberOfValues.ToString(); // TODO convert from SI pq = p2d.PlotParameter.Variable.Type; newVal = UnitSystemService.GetInstance().ConvertToSIValue(pq, p2d.PlotParameter.Max); this.textBoxParamMax.Text = newVal.ToString(); newVal = UnitSystemService.GetInstance().ConvertToSIValue(pq, p2d.PlotParameter.Min); this.textBoxParamMin.Text = newVal.ToString(); } else { this.groupBoxParam.Visible = false; } this.inConstruction = false; }
public bool UnpersistUnitSystemCatalog(string fileName, string bakFileName) { bool ok = true; Stream stream = null; try { if (File.Exists(fileName) || File.Exists(bakFileName)) { if (File.Exists(fileName)) { stream = new FileStream(fileName, FileMode.Open); } else if (File.Exists(bakFileName)) { stream = new FileStream(bakFileName, FileMode.Open); } SoapFormatter serializer = new SoapFormatter(); // BinaryFormatter serializer = new BinaryFormatter(); // serializer.AssemblyFormat = FormatterAssemblyStyle.Simple; UnitSystemCatalog unitSystemCatalog = UnitSystemService.GetInstance().GetUnitSystemCatalog(); ArrayList customUnitSystems = (ArrayList)serializer.Deserialize(stream); IEnumerator e = customUnitSystems.GetEnumerator(); while (e.MoveNext()) { UnitSystem us = (UnitSystem)e.Current; us.SetObjectData(us.SerializationInfo, us.StreamingContext); unitSystemCatalog.Add(us); } } } catch (Exception e) { ok = false; string message = e.ToString(); MessageBox.Show(message, "Error Retrieving Unit System Catalog", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { if (stream != null) { stream.Close(); } } return(ok); }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { UnitSystemService.GetInstance().CurrentUnitSystemChanged -= new CurrentUnitSystemChangedEventHandler(DuhringLinesControl_CurrentUnitSystemChanged); if (this.duhringLinesCache != null) { this.duhringLinesCache.DuhringLinesChanged -= new DuhringLinesChangedEventHandler(duhringLinesCache_DuhringLinesChanged); } if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); }
public override string ToPrint() { UnitSystem us = UnitSystemService.GetInstance().CurrentUnitSystem; string nfs = this.flowsheet.ApplicationPrefs.NumericFormatString; StringBuilder sb = new StringBuilder(); sb.Append("Heat Exchanger: "); sb.Append(this.HeatExchanger.Name); sb.Append("\r\n"); sb.Append(UI.UNDERLINE); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.HeatExchanger.TotalHeatTransfer, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.HeatExchanger.TotalHeatTransfer, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.HeatExchanger.ColdSidePressureDrop, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.HeatExchanger.ColdSidePressureDrop, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.HeatExchanger.HotSidePressureDrop, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.HeatExchanger.HotSidePressureDrop, us, nfs)); sb.Append("\r\n"); if (this.HeatExchanger.CurrentRatingModel != null) { if (this.HeatExchanger.CurrentRatingModel is HXRatingModelSimpleGeneric) { sb.Append(this.ToPrintSimpleGenericRating()); } else if (this.HeatExchanger.CurrentRatingModel is HXRatingModelShellAndTube) { sb.Append(this.ToPrintShellAndTubeRating()); } else if (this.HeatExchanger.CurrentRatingModel is HXRatingModelPlateAndFrame) { sb.Append(this.ToPrintPlateAndFrameRating()); } } return(sb.ToString()); }
public RecommProcVarElementControl(INumericFormat iNumericFormat, ProcessVar var, object recommValue) { // This call is required by the Windows.Forms Form Designer. InitializeComponent(); this.var = var; this.labelName.InitializeVariable(var); this.textBoxExistingValue.InitializeVariable(iNumericFormat, var); // note: the recommended value is not converted to the current unit system, // and it also needs formating if (var is ProcessVarDouble) { double val = (double)recommValue; double val2 = 0.0; val2 = UnitSystemService.GetInstance().ConvertFromSIValue(var.Type, val); if (val2 == Constants.NO_VALUE) { this.textBoxRecommendedValue.Text = ""; } else { this.textBoxRecommendedValue.Text = val2.ToString(iNumericFormat.NumericFormatString); } } else if (var is ProcessVarInt) { int val = (int)recommValue; if (val == Constants.NO_VALUE_INT) { this.textBoxRecommendedValue.Text = ""; } else { this.textBoxRecommendedValue.Text = val.ToString(UI.DECIMAL); } } this.textBoxExistingValue.BackColor = Color.Gainsboro; this.textBoxRecommendedValue.BackColor = Color.Gainsboro; // as convenience, initialize the new value with the recommended value this.textBoxNewValue.Text = this.textBoxRecommendedValue.Text; }
public static CurveFamily[] ConvertCurveFamilies(CurveFamilyF[] oldFamilies, PhysicalQuantity xPhysicalQuantity, PhysicalQuantity yPhysicalQuantity) { // Note: this also converts the values from model's default Unit System to the current Unit System CurveFamily[] newFamilies = new CurveFamily[oldFamilies.Length]; int k = 0; foreach (CurveFamilyF curveFamily in oldFamilies) { CurveFamily cf = new CurveFamily(); cf.Name = curveFamily.Name; PhysicalQuantity pq = curveFamily.PhysicalQuantity; cf.Unit = UnitSystemService.GetInstance().GetUnitAsString(pq); Curve[] newCurves = new Curve[curveFamily.Curves.Length]; int j = 0; foreach (CurveF curve in curveFamily.Curves) { Curve c = new Curve(); c.Name = curve.Name; c.Unit = UnitSystemService.GetInstance().GetUnitAsString(pq); c.Value = (float)UnitSystemService.GetInstance().ConvertFromSIValue(pq, curve.Value); PointF[] newData = new PointF[curve.Data.Length]; int i = 0; foreach (PointF point in curve.Data) { float newX = (float)UnitSystemService.GetInstance().ConvertFromSIValue(xPhysicalQuantity, point.X); float newY = (float)UnitSystemService.GetInstance().ConvertFromSIValue(yPhysicalQuantity, point.Y); PointF p = new PointF(newX, newY); newData[i++] = p; } c.Data = newData; // the new curve is built, so add it to the array of curves newCurves[j++] = c; } cf.Curves = newCurves; // the new family is built, so add it to the array of families newFamilies[k++] = cf; } return(newFamilies); }
public override string ToPrintToolTip() { UnitSystem us = UnitSystemService.GetInstance().CurrentUnitSystem; string nfs = this.flowsheet.ApplicationPrefs.NumericFormatString; StringBuilder sb = new StringBuilder(); sb.Append("Drying Gas Stream: "); sb.Append(this.GasStream.Name); sb.Append("\r\n"); sb.Append(UI.UNDERLINE); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.GasStream.MassFlowRate, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.GasStream.MassFlowRate, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.GasStream.VolumeFlowRate, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.GasStream.VolumeFlowRate, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.GasStream.Pressure, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.GasStream.Pressure, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.GasStream.Temperature, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.GasStream.Temperature, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.GasStream.Humidity, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.GasStream.Humidity, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.GasStream.RelativeHumidity, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.GasStream.RelativeHumidity, us, nfs)); sb.Append("\r\n"); return(sb.ToString()); }
public override string ToPrint() { UnitSystem us = UnitSystemService.GetInstance().CurrentUnitSystem; string nfs = this.flowsheet.NumericFormatString; StringBuilder sb = new StringBuilder(); sb.Append("Cyclone: "); sb.Append(this.Cyclone.Name); sb.Append("\r\n"); sb.Append(UI.UNDERLINE); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.Cyclone.GasPressureDrop, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.Cyclone.GasPressureDrop, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.Cyclone.CollectionEfficiency, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.Cyclone.CollectionEfficiency, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.Cyclone.InletParticleLoading, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.Cyclone.InletParticleLoading, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.Cyclone.OutletParticleLoading, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.Cyclone.OutletParticleLoading, us, nfs)); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.Cyclone.MassFlowRateOfParticleLostToGasOutlet, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.Cyclone.MassFlowRateOfParticleLostToGasOutlet, us, nfs)); sb.Append("\r\n"); if (this.Cyclone.CurrentRatingModel != null) { sb.Append(this.ToPrintRating()); } return(sb.ToString()); }
public override string ToPrint() { UnitSystem us = UnitSystemService.GetInstance().CurrentUnitSystem; string nfs = this.flowsheet.NumericFormatString; StringBuilder sb = new StringBuilder(); sb.Append("Valve: "); sb.Append(this.Valve.Name); sb.Append("\r\n"); sb.Append(UI.UNDERLINE); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.Valve.PressureDrop, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.Valve.PressureDrop, us, nfs)); sb.Append("\r\n"); return(sb.ToString()); }
public void PersistUnitSystemCatalog(string fileName, string bakFileName) { FileStream fs = null; try { if (File.Exists(fileName)) { File.Copy(fileName, bakFileName, true); File.Delete(fileName); } fs = new FileStream(fileName, FileMode.Create); ArrayList customUnitSystems = new ArrayList(); IEnumerator e = UnitSystemService.GetInstance().GetUnitSystemCatalog().GetList().GetEnumerator(); while (e.MoveNext()) { UnitSystem us = (UnitSystem)e.Current; if (!us.IsReadOnly) { customUnitSystems.Add(us); } } SoapFormatter serializer = new SoapFormatter(); // BinaryFormatter serializer = new BinaryFormatter(); // serializer.AssemblyFormat = FormatterAssemblyStyle.Simple; serializer.Serialize(fs, customUnitSystems); } catch (Exception e) { string message = e.ToString(); MessageBox.Show(message, "Error Saving Unit System Catalog", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } finally { if (fs != null) { fs.Flush(); fs.Close(); } } }
public void InitializeVariable(ProcessVar var) { string unitName; this.var = var; this.Clear(); this.SelectedText = var.VarTypeName; unitName = UI.GetUnitName(this.var, UnitSystemService.GetInstance().CurrentUnitSystem); if (unitName != null) { this.SelectionCharOffset = UI.SUB_CHAR_OFFSET; //superscript this.SelectedText = (" (" + unitName + ")"); //this.AppendText(" (" + unitName + ")"); } // this.Text = UI.GetVariableName(this.var, UnitSystemService.GetInstance().CurrentUnitSystem); this.var.NameChanged += new NameChangedEventHandler(var_NameChanged); UnitSystemService.GetInstance().CurrentUnitSystemChanged += new CurrentUnitSystemChangedEventHandler(ProcessVarLabel_CurrentUnitSystemChanged); }
public override string ToPrint() { UnitSystem us = UnitSystemService.GetInstance().CurrentUnitSystem; string nfs = this.flowsheet.ApplicationPrefs.NumericFormatString; StringBuilder sb = new StringBuilder(); sb.Append("Bag Filter: "); sb.Append(this.BagFilter.Name); sb.Append("\r\n"); sb.Append(UI.UNDERLINE); sb.Append("\r\n"); sb.Append(base.ToPrint()); sb.Append(UI.GetVariableName(this.BagFilter.BagDiameter, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.BagFilter.BagDiameter, us, nfs)); if (this.BagFilter.BagDiameter.IsSpecified) { sb.Append(" * "); } sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.BagFilter.BagLength, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.BagFilter.BagLength, us, nfs)); if (this.BagFilter.BagLength.IsSpecified) { sb.Append(" * "); } sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.BagFilter.NumberOfBags, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.BagFilter.NumberOfBags, us, nfs)); if (this.BagFilter.NumberOfBags.IsSpecified) { sb.Append(" * "); } sb.Append("\r\n"); return(sb.ToString()); }
public ApplicationPreferencesForm(MainForm mainForm, ApplicationPreferences appPrefs) { InitializeComponent(); this.mainForm = mainForm; this.appPrefs = appPrefs; // unitSystemsCtrl = new UnitSystemsControl(); this.tabPageUnits.Controls.Add(unitSystemsCtrl); unitSystemsCtrl.Location = new Point(0, 0); UnitSystem unitSystem = unitSystemsCtrl.GetSelectedUnitSystem(); int selIdx = unitSystemsCtrl.GetSelectedIndex(); this.buttonCurrentUnitSys.Enabled = false; if (selIdx >= 0) { if (unitSystem != null) { this.buttonCurrentUnitSys.Enabled = true; } } UnitSystem currentUnitSystem = UnitSystemService.GetInstance().CurrentUnitSystem; this.labelCurrent.Text = this.CURRENT_UNIT_SYS + currentUnitSystem.Name; unitSystemsCtrl.SelectedUnitSystemChanged += new SelectedUnitSystemChangedEventHandler(unitSystemsCtrl_SelectedUnitSystemChanged); // this.domainUpDownDecPlaces.SelectedItem = this.appPrefs.DecimalPlaces; if (this.appPrefs.NumericFormat.Equals(NumericFormat.FixedPoint)) { this.radioButtonFixedPoint.Checked = true; } else if (this.appPrefs.NumericFormat.Equals(NumericFormat.Scientific)) { this.radioButtonScientific.Checked = true; } this.ResizeEnd += new EventHandler(ApplicationPreferencesForm_ResizeEnd); }
/// <summary> /// Clean up any resources being used. /// </summary> protected override void Dispose(bool disposing) { UnitSystemService.GetInstance().CurrentUnitSystemChanged -= new CurrentUnitSystemChangedEventHandler(Flowsheet_CurrentUnitSystemChanged); if (this.evapAndDryingSystem != null) { this.evapAndDryingSystem.SystemChanged -= new SystemChangedEventHandler(evapAndDryingSystem_SystemChanged); this.evapAndDryingSystem.CalculationStarted -= new CalculationStartedEventHandler(evapAndDryingSystem_CalculationStarted); this.evapAndDryingSystem.CalculationEnded -= new CalculationEndedEventHandler(evapAndDryingSystem_CalculationEnded); } if (disposing) { if (components != null) { components.Dispose(); } } base.Dispose(disposing); }
public override string ToPrint() { UnitSystem us = UnitSystemService.GetInstance().CurrentUnitSystem; string nfs = this.flowsheet.ApplicationPrefs.NumericFormatString; StringBuilder sb = new StringBuilder(); sb.Append("Ejector: "); sb.Append(this.Ejector.Name); sb.Append("\r\n"); sb.Append(UI.UNDERLINE); sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.Ejector.EntrainmentRatio, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.Ejector.EntrainmentRatio, us, nfs)); if (this.Ejector.EntrainmentRatio.IsSpecified) { sb.Append(" * "); } sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.Ejector.CompressionRatio, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.Ejector.CompressionRatio, us, nfs)); if (this.Ejector.CompressionRatio.IsSpecified) { sb.Append(" * "); } sb.Append("\r\n"); sb.Append(UI.GetVariableName(this.Ejector.SuctionMotivePressureRatio, us)); sb.Append(" = "); sb.Append(UI.GetVariableValue(this.Ejector.SuctionMotivePressureRatio, us, nfs)); if (this.Ejector.SuctionMotivePressureRatio.IsSpecified) { sb.Append(" * "); } sb.Append("\r\n"); return(sb.ToString()); }
public override string ToPrint() { UnitSystem us = UnitSystemService.GetInstance().CurrentUnitSystem; string nfs = this.flowsheet.ApplicationPrefs.NumericFormatString; StringBuilder sb = new StringBuilder(); sb.Append("Cooler: "); sb.Append(this.Cooler.Name); sb.Append("\r\n"); sb.Append(UI.UNDERLINE); sb.Append("\r\n"); sb.Append(GetVariableName(this.Cooler.PressureDrop, us)); sb.Append(" = "); sb.Append(GetVariableValue(this.Cooler.PressureDrop, us, nfs)); if (this.Cooler.PressureDrop.IsSpecified) { sb.Append(" * "); } sb.Append("\r\n"); sb.Append(GetVariableName(this.Cooler.HeatLoss, us)); sb.Append(" = "); sb.Append(GetVariableValue(this.Cooler.HeatLoss, us, nfs)); if (this.Cooler.HeatLoss.IsSpecified) { sb.Append(" * "); } sb.Append("\r\n"); sb.Append(GetVariableName(this.Cooler.HeatInput, us)); sb.Append(" = "); sb.Append(GetVariableValue(this.Cooler.HeatInput, us, nfs)); if (this.Cooler.HeatInput.IsSpecified) { sb.Append(" * "); } sb.Append("\r\n"); return(sb.ToString()); }
public override string ToPrint() { UnitSystem us = UnitSystemService.GetInstance().CurrentUnitSystem; string nfs = this.flowsheet.ApplicationPrefs.NumericFormatString; StringBuilder sb = new StringBuilder(); sb.Append("Dryer: "); sb.Append(this.Dryer.Name); sb.Append("\r\n"); sb.Append(UI.UNDERLINE); sb.Append("\r\n"); sb.Append(ToPrintVarList()); if (this.Dryer.ScopingModel != null) { sb.Append(this.ToPrintScoping()); } return(sb.ToString()); }
private void textBoxParamMax_Validating(object sender, System.ComponentModel.CancelEventArgs e) { if (!this.inConstruction) { TextBox tb = (TextBox)sender; if (UI.HasNumericValue(tb)) { double newVal = UI.GetNumericValueAsDouble(tb, e); if (newVal != this.p2d.PlotParameter.Max) { PhysicalQuantity pq = this.p2d.PlotParameter.Variable.Type; double convertedVal = UnitSystemService.GetInstance().ConvertToSIValue(pq, (double)newVal); this.p2d.SetParameterMax((double)convertedVal); } } else { e.Cancel = true; } } }
protected override void Dispose(bool disposing) { if (this.var != null && this.var.Owner != null) { if (this.var.Owner is Solvable) { Solvable solvable = this.var.Owner as Solvable; solvable.SolveComplete -= new SolveCompleteEventHandler(solvable_SolveComplete); } else { this.var.Owner.ProcessVarValueCommitted -= new ProcessVarValueCommittedEventHandler(Owner_ProcessVarValueCommitted); } } UnitSystemService.GetInstance().CurrentUnitSystemChanged -= new CurrentUnitSystemChangedEventHandler(ProcessVarNonEditableTextBox_CurrentUnitSystemChanged); if (this.iNumericFormat != null) { this.iNumericFormat.NumericFormatStringChanged -= new NumericFormatStringChangedEventHandler(iNumericFormat_NumericFormatStringChanged); } base.Dispose(disposing); }