void Initialize() { double dummy = 0.0f; var su = flowsheet.FlowsheetOptions.SelectedUnitSystem; var nf = flowsheet.FlowsheetOptions.NumberFormat; if (section.TipoSegmento == "Tubulaosimples") { section.TipoSegmento = "Straight Tube Section"; } var lblseg = container.CreateAndAddTwoLabelsRow("Segment", section.Indice.ToString()); container.CreateAndAddDropDownRow("Type", sectypes, Array.IndexOf(sectypes.ToArray(), section.TipoSegmento), (sender, e) => section.TipoSegmento = sectypes[sender.SelectedIndex]); container.CreateAndAddDropDownRow("Material", materials, Array.IndexOf(materials.ToArray(), section.Material), (sender, e) => section.Material = materials[sender.SelectedIndex]); container.CreateAndAddTextBoxRow("N0", "Increments", section.Incrementos, (sender, e) => { if (double.TryParse(sender.Text.ToString(), out dummy)) { section.Incrementos = int.Parse(sender.Text.ToString()); } }); container.CreateAndAddTextBoxRow("N0", "Quantity", section.Quantidade, (sender, e) => { if (double.TryParse(sender.Text.ToString(), out dummy)) { section.Quantidade = int.Parse(sender.Text.ToString()); } }); container.CreateAndAddTextBoxRow(nf, "Length" + " (" + su.distance + ")", cv.ConvertFromSI(su.distance, section.Comprimento), (sender, e) => { if (double.TryParse(sender.Text.ToString(), out dummy)) { section.Comprimento = cv.ConvertToSI(su.distance, double.Parse(sender.Text.ToString())); } }); container.CreateAndAddTextBoxRow(nf, "Elevation" + " (" + su.distance + ")", cv.ConvertFromSI(su.distance, section.Elevacao), (sender, e) => { if (double.TryParse(sender.Text.ToString(), out dummy)) { section.Elevacao = cv.ConvertToSI(su.distance, double.Parse(sender.Text.ToString())); } }); container.CreateAndAddTextBoxRow(nf, "External Diameter" + " (" + su.diameter + ")", cv.Convert("in", su.diameter, section.DE), (sender, e) => { if (double.TryParse(sender.Text.ToString(), out dummy)) { section.DE = cv.Convert(su.diameter, "in", double.Parse(sender.Text.ToString())); } }); container.CreateAndAddTextBoxRow(nf, "Internal Diameter" + " (" + su.diameter + ")", cv.Convert("in", su.diameter, section.DI), (sender, e) => { if (double.TryParse(sender.Text.ToString(), out dummy)) { section.DI = cv.Convert(su.diameter, "in", double.Parse(sender.Text.ToString())); } }); }
void Initialize() { var su = flowsheet.FlowsheetOptions.SelectedUnitSystem; var nf = flowsheet.FlowsheetOptions.NumberFormat; if (section.TipoSegmento == "Tubulaosimples") { section.TipoSegmento = "Straight Tube Section"; } var lblseg = container.CreateAndAddTwoLabelsRow("Segment", section.Indice.ToString()); container.CreateAndAddDropDownRow("Type", sectypes, Array.IndexOf(sectypes.ToArray(), section.TipoSegmento), (sender, e) => section.TipoSegmento = sectypes[sender.SelectedIndex]); var cbm = container.CreateAndAddDropDownRow("Material", materials, Array.IndexOf(materials.ToArray(), section.Material), (sender, e) => section.Material = materials[sender.SelectedIndex]); var tbr = container.CreateAndAddTextBoxRow("G8", "Rugosity " + " (" + su.distance + ") *", cv.ConvertFromSI(su.distance, section.PipeWallRugosity), (sender, e) => { if (sender.Text.IsValidDoubleExpression()) { section.PipeWallRugosity = cv.ConvertToSI(su.distance, sender.Text.ParseExpressionToDouble()); } }); var tbtc = container.CreateAndAddStringEditorRow("Thermal Conductivity " + " (" + su.thermalConductivity + ") *", section.PipeWallThermalConductivityExpression, (sender, e) => { section.PipeWallThermalConductivityExpression = sender.Text.ToString(); }); container.CreateAndAddTextBoxRow("N0", "Increments", section.Incrementos, (sender, e) => { if (sender.Text.IsValidDoubleExpression()) { section.Incrementos = int.Parse(sender.Text.ToString()); } }); container.CreateAndAddTextBoxRow("N0", "Quantity", section.Quantidade, (sender, e) => { if (sender.Text.IsValidDoubleExpression()) { section.Quantidade = int.Parse(sender.Text.ToString()); } }); container.CreateAndAddTextBoxRow(nf, "Length" + " (" + su.distance + ")", cv.ConvertFromSI(su.distance, section.Comprimento), (sender, e) => { if (sender.Text.IsValidDoubleExpression()) { section.Comprimento = cv.ConvertToSI(su.distance, sender.Text.ParseExpressionToDouble()); } }); container.CreateAndAddTextBoxRow(nf, "Elevation" + " (" + su.distance + ")", cv.ConvertFromSI(su.distance, section.Elevacao), (sender, e) => { if (sender.Text.IsValidDoubleExpression()) { section.Elevacao = cv.ConvertToSI(su.distance, sender.Text.ParseExpressionToDouble()); } }); container.CreateAndAddTextBoxRow(nf, "External Diameter" + " (" + su.diameter + ")", cv.Convert("in", su.diameter, section.DE), (sender, e) => { if (sender.Text.IsValidDoubleExpression()) { section.DE = cv.Convert(su.diameter, "in", sender.Text.ParseExpressionToDouble()); } }); container.CreateAndAddTextBoxRow(nf, "Internal Diameter" + " (" + su.diameter + ")", cv.Convert("in", su.diameter, section.DI), (sender, e) => { if (sender.Text.IsValidDoubleExpression()) { section.DI = cv.Convert(su.diameter, "in", sender.Text.ParseExpressionToDouble()); } }); container.CreateAndAddDescriptionRow("* Fields required/used only for User-Defined materials"); tbr.ReadOnly = section.Material != flowsheet.GetTranslatedString("UserDefined"); tbtc.ReadOnly = tbr.ReadOnly; if (tbr.ReadOnly) { tbr.BackgroundColor = Eto.Drawing.Colors.LightGrey; tbtc.BackgroundColor = Eto.Drawing.Colors.LightGrey; } else { tbr.BackgroundColor = Eto.Drawing.SystemColors.ControlBackground; tbtc.BackgroundColor = Eto.Drawing.SystemColors.ControlBackground; } cbm.SelectedValueChanged += (sender, e) => { if (cbm.SelectedValue.ToString() == flowsheet.GetTranslatedString("UserDefined")) { tbr.ReadOnly = false; tbtc.ReadOnly = false; tbr.BackgroundColor = Eto.Drawing.SystemColors.ControlBackground; tbtc.BackgroundColor = Eto.Drawing.SystemColors.ControlBackground; tbr.Text = section.PipeWallRugosity.ConvertFromSI(su.distance).ToString(nf); tbtc.Text = section.PipeWallThermalConductivityExpression; tbtc.TextAlignment = TextAlignment.Left; } else { tbr.ReadOnly = true; tbtc.ReadOnly = true; tbr.BackgroundColor = Eto.Drawing.Colors.LightGrey; tbtc.BackgroundColor = Eto.Drawing.Colors.LightGrey; tbr.Text = pipe.rugosidade(cbm.SelectedValue.ToString(), section).ConvertFromSI(su.distance).ToString(nf); if (pipe.GraphicObject.InputConnectors[0].IsAttached) { var stream = (MaterialStream)flowsheet.SimulationObjects[pipe.GraphicObject.InputConnectors[0].AttachedConnector.AttachedFrom.Name]; tbtc.Text = pipe.k_parede(cbm.SelectedValue.ToString(), stream.GetTemperature(), section).ConvertFromSI(su.thermalConductivity).ToString(nf); } else { tbtc.Text = pipe.k_parede(cbm.SelectedValue.ToString(), 298.15, section).ConvertFromSI(su.thermalConductivity).ToString(nf); } tbtc.TextAlignment = TextAlignment.Right; } }; }
private void AddProperties(DynamicLayout container) { var su = flowsheet.FlowsheetOptions.SelectedUnitSystem; var nf = flowsheet.FlowsheetOptions.NumberFormat; container.CreateAndAddLabelRow("Constant Properties"); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("Database"), compound.OriginalDB); container.CreateAndAddTwoLabelsRow("ID", compound.ID.ToString()); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("CASNumber"), compound.CAS_Number); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("Massamolar") + " (" + su.molecularWeight + ")", compound.Molar_Weight.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("TemperaturaCrtica") + " (" + su.temperature + ")", cv.ConvertFromSI(su.temperature, compound.Critical_Temperature).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("PressoCrtica") + " (" + su.pressure + ")", cv.ConvertFromSI(su.pressure, compound.Critical_Pressure).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("VolumeCrtico") + " (" + su.molar_volume + ")", cv.ConvertFromSI(su.molar_volume, compound.Critical_Volume).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("CompressibilidadeCrt"), compound.Critical_Compressibility.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("FatorAcntrico"), compound.Acentric_Factor.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("EntalpiadeFormaodoGs") + " (" + su.enthalpy + ")", cv.ConvertFromSI(su.enthalpy, compound.IG_Enthalpy_of_Formation_25C).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("EnergyFlowdeGibbsdeForm2") + " (" + su.enthalpy + ")", cv.ConvertFromSI(su.entropy, compound.IG_Gibbs_Energy_of_Formation_25C).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("PontoNormaldeEbulio") + " (" + su.temperature + ")", cv.ConvertFromSI(su.temperature, compound.Normal_Boiling_Point).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("TemperatureOfFusion") + " (" + su.temperature + ")", cv.ConvertFromSI(su.temperature, compound.TemperatureOfFusion).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("EnthalpyOfFusionAtTf") + " (kJ/mol)", compound.EnthalpyOfFusionAtTf.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("ChaoSeaderAcentricFactor"), compound.Chao_Seader_Acentricity.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("ChaoSeaderSolubilityParameter"), compound.Chao_Seader_Solubility_Parameter.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("ChaoSeaderLiquidMolarVolume") + " (mL/mol)", compound.Chao_Seader_Liquid_Molar_Volume.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("RackettCompressibility"), compound.Z_Rackett.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("PengRobinsonVolumeTranslationCoefficient"), compound.PR_Volume_Translation_Coefficient.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("SRKVolumeTranslationCoefficient"), compound.SRK_Volume_Translation_Coefficient.ToString(nf)); container.CreateAndAddTwoLabelsRow("UNIQUAC R", compound.UNIQUAC_R.ToString(nf)); container.CreateAndAddTwoLabelsRow("UNIQUAC Q", compound.UNIQUAC_Q.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("Charge"), compound.Charge.ToString("#;-#")); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("HydrationNumber"), compound.HydrationNumber.ToString()); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("PositiveIon"), compound.PositiveIon); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("NegativeIon"), compound.NegativeIon); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("TemperatureOfSolidDensity_Ts") + " (" + su.temperature + ")", cv.ConvertFromSI(su.temperature, compound.SolidTs).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("SolidDensityAtTs") + " (" + su.density + ")", cv.ConvertFromSI(su.density, compound.SolidDensityAtTs).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("Electrolyte_DelGF") + " (" + su.enthalpy + ")", cv.ConvertFromSI(su.enthalpy, compound.Electrolyte_DelGF).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("Electrolyte_DelHF") + " (" + su.enthalpy + ")", cv.ConvertFromSI(su.enthalpy, compound.Electrolyte_DelHF).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("Electrolyte_Cp0") + " (kJ/[mol.K])", compound.Electrolyte_Cp0.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("Electrolyte_StdStateMolVol") + " (cm3/mol)", compound.StandardStateMolarVolume.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("BlackOil_SGG"), compound.BO_SGG.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("BlackOil_SGO"), compound.BO_SGO.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("BlackOil_GOR") + " (" + su.gor + ")", cv.ConvertFromSI(su.gor, compound.BO_GOR).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("BlackOil_BSW"), compound.BO_BSW.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("BlackOil_V1") + " (" + su.cinematic_viscosity + ")", cv.ConvertFromSI(su.cinematic_viscosity, compound.BO_OilVisc1).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("BlackOil_T1") + " (" + su.temperature + ")", cv.ConvertFromSI(su.temperature, compound.BO_OilViscTemp1).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("BlackOil_V2") + " (" + su.cinematic_viscosity + ")", cv.ConvertFromSI(su.cinematic_viscosity, compound.BO_OilVisc2).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("BlackOil_T2") + " (" + su.temperature + ")", cv.ConvertFromSI(su.temperature, compound.BO_OilViscTemp2).ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("BlackOil_PNA_P"), compound.BO_PNA_P.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("BlackOil_PNA_N"), compound.BO_PNA_N.ToString(nf)); container.CreateAndAddTwoLabelsRow(flowsheet.GetTranslatedString("BlackOil_PNA_A"), compound.BO_PNA_A.ToString(nf)); }
void Initialize() { var su = flowsheet.FlowsheetOptions.SelectedUnitSystem; var nf = flowsheet.FlowsheetOptions.NumberFormat; if (section.TipoSegmento == "Tubulaosimples") { section.TipoSegmento = "Straight Tube Section"; } var lblseg = container.CreateAndAddTwoLabelsRow("Segment", section.Indice.ToString()); container.CreateAndAddDropDownRow("Type", sectypes, Array.IndexOf(sectypes.ToArray(), section.TipoSegmento), (sender, e) => section.TipoSegmento = sectypes[sender.SelectedIndex]); var cbm = container.CreateAndAddDropDownRow("Material", materials, Array.IndexOf(materials.ToArray(), section.Material), (sender, e) => section.Material = materials[sender.SelectedIndex]); var tbr = container.CreateAndAddTextBoxRow("G8", "Rugosity " + " (" + su.distance + ") *", cv.ConvertFromSI(su.distance, section.PipeWallRugosity), (sender, e) => { if (sender.Text.IsValidDoubleExpression()) { section.PipeWallRugosity = cv.ConvertToSI(su.distance, sender.Text.ParseExpressionToDouble()); } }); var tbtc = container.CreateAndAddStringEditorRow("Thermal Conductivity " + " (" + su.thermalConductivity + ") *", section.PipeWallThermalConductivityExpression, (sender, e) => { section.PipeWallThermalConductivityExpression = sender.Text.ToString(); }); container.CreateAndAddDescriptionRow("* Fields required/used only for User-Defined materials"); container.CreateAndAddTextBoxRow("N0", "Increments", section.Incrementos, (sender, e) => { if (sender.Text.IsValidDoubleExpression()) { section.Incrementos = int.Parse(sender.Text.ToString()); } }); container.CreateAndAddTextBoxRow("N0", "Quantity", section.Quantidade, (sender, e) => { if (sender.Text.IsValidDoubleExpression()) { section.Quantidade = int.Parse(sender.Text.ToString()); } }); container.CreateAndAddTextBoxRow(nf, "Length" + " (" + su.distance + ")", cv.ConvertFromSI(su.distance, section.Comprimento), (sender, e) => { if (sender.Text.IsValidDoubleExpression()) { section.Comprimento = cv.ConvertToSI(su.distance, sender.Text.ParseExpressionToDouble()); } }); container.CreateAndAddTextBoxRow(nf, "Elevation" + " (" + su.distance + ")", cv.ConvertFromSI(su.distance, section.Elevacao), (sender, e) => { if (sender.Text.IsValidDoubleExpression()) { section.Elevacao = cv.ConvertToSI(su.distance, sender.Text.ParseExpressionToDouble()); } }); var edtb = container.CreateAndAddTextBoxRow(nf, "External Diameter" + " (" + su.diameter + ")", cv.Convert("in", su.diameter, section.DE), (sender, e) => { if (sender.Text.IsValidDoubleExpression()) { section.DE = cv.Convert(su.diameter, "in", sender.Text.ParseExpressionToDouble()); } }); var idtb = container.CreateAndAddTextBoxRow(nf, "Internal Diameter" + " (" + su.diameter + ")", cv.Convert("in", su.diameter, section.DI), (sender, e) => { if (sender.Text.IsValidDoubleExpression()) { section.DI = cv.Convert(su.diameter, "in", sender.Text.ParseExpressionToDouble()); } }); var ssizes = Pipe.GetStandardPipeSizes(); var cmenussizes = new ContextMenu(); foreach (var key in ssizes.Keys) { var mi = new ButtonMenuItem { Text = key }; foreach (var item in ssizes[key]) { var mi2 = new ButtonMenuItem { Text = item.StandardSizeDescription + " (OD = " + item.ExternalDiameter_Inches + " in., ID = " + item.InternalDiameter_Inches + " in.)" }; mi2.Click += (s, e) => { flowsheet.RunCodeOnUIThread(() => { edtb.Text = item.ExternalDiameter_Inches.ConvertUnits("in", su.diameter).ToString(nf); idtb.Text = item.InternalDiameter_Inches.ConvertUnits("in", su.diameter).ToString(nf); }); }; mi.Items.Add(mi2); } cmenussizes.Items.Add(mi); } container.CreateAndAddButtonRow("Standard Pipe Sizes...", null, (btn, ev) => { cmenussizes.Show(btn); }); tbr.ReadOnly = section.Material != flowsheet.GetTranslatedString("UserDefined"); tbtc.ReadOnly = tbr.ReadOnly; if (tbr.ReadOnly) { tbr.BackgroundColor = Eto.Drawing.Colors.LightGrey; tbtc.BackgroundColor = Eto.Drawing.Colors.LightGrey; } else { tbr.BackgroundColor = Eto.Drawing.SystemColors.ControlBackground; tbtc.BackgroundColor = Eto.Drawing.SystemColors.ControlBackground; } cbm.SelectedValueChanged += (sender, e) => { if (cbm.SelectedValue.ToString() == flowsheet.GetTranslatedString("UserDefined")) { tbr.ReadOnly = false; tbtc.ReadOnly = false; tbr.BackgroundColor = Eto.Drawing.SystemColors.ControlBackground; tbtc.BackgroundColor = Eto.Drawing.SystemColors.ControlBackground; tbr.Text = section.PipeWallRugosity.ConvertFromSI(su.distance).ToString(nf); tbtc.Text = section.PipeWallThermalConductivityExpression; tbtc.TextAlignment = TextAlignment.Left; } else { tbr.ReadOnly = true; tbtc.ReadOnly = true; tbr.BackgroundColor = Eto.Drawing.Colors.LightGrey; tbtc.BackgroundColor = Eto.Drawing.Colors.LightGrey; tbr.Text = pipe.GetRugosity(cbm.SelectedValue.ToString(), section).ConvertFromSI(su.distance).ToString(nf); if (pipe.GraphicObject != null && pipe.GraphicObject.InputConnectors[0].IsAttached) { var stream = (MaterialStream)flowsheet.SimulationObjects[pipe.GraphicObject.InputConnectors[0].AttachedConnector.AttachedFrom.Name]; tbtc.Text = pipe.k_parede(cbm.SelectedValue.ToString(), stream.GetTemperature(), section).ConvertFromSI(su.thermalConductivity).ToString(nf); } else { tbtc.Text = pipe.k_parede(cbm.SelectedValue.ToString(), 298.15, section).ConvertFromSI(su.thermalConductivity).ToString(nf); } tbtc.TextAlignment = TextAlignment.Right; } }; }