Esempio n. 1
0
        void Init()
        {
            Padding = new Padding(10);

            var    comps = flowsheet.SelectedCompounds.Values.Select((x) => x.Name).ToList();
            var    nf    = "N4";
            Double val;

            s.CreateAndAddLabelRow(this, "Interaction Parameters");

            switch (pp.ComponentName)
            {
            case "NRTL":
                var ppn = (NRTLPropertyPackage)pp;
                var ipn = ppn.m_uni.InteractionParameters;
                foreach (var c1 in comps)
                {
                    if (!ipn.ContainsKey(c1))
                    {
                        ipn.Add(c1, new Dictionary <string, NRTL_IPData>());
                    }
                    foreach (var c2 in comps)
                    {
                        if (c1 != c2)
                        {
                            if (!ipn[c1].ContainsKey(c2))
                            {
                                if (ipn.ContainsKey(c2) && !ipn[c2].ContainsKey(c1))
                                {
                                    ipn[c1].Add(c2, new NRTL_IPData());
                                }
                            }
                        }
                    }
                }

                foreach (var c1 in comps)
                {
                    foreach (var c2 in comps)
                    {
                        if (c1 != c2 && ipn[c1].ContainsKey(c2))
                        {
                            var ip = ipn[c1][c2];
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2 + " A12", ip.A12,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.A12         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2 + " A21", ip.A21,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.A21         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2 + " B12", ip.B12,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.B12         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2 + " B21", ip.B21,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.B21         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2 + " C12", ip.C12,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.C12         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2 + " C21", ip.C21,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.C21         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2 + " alpha12", ip.alpha12,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.alpha12     = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                        }
                    }
                }
                break;

            case "UNIQUAC":
                var ppu = (UNIQUACPropertyPackage)pp;
                var ipu = ppu.m_uni.InteractionParameters;
                foreach (var c1 in comps)
                {
                    if (!ipu.ContainsKey(c1))
                    {
                        ipu.Add(c1, new Dictionary <string, UNIQUAC_IPData>());
                    }
                    foreach (var c2 in comps)
                    {
                        if (c1 != c2)
                        {
                            if (!ipu[c1].ContainsKey(c2))
                            {
                                if (ipu.ContainsKey(c2) && !ipu[c2].ContainsKey(c1))
                                {
                                    ipu[c1].Add(c2, new UNIQUAC_IPData());
                                }
                            }
                        }
                    }
                }

                foreach (var c1 in comps)
                {
                    foreach (var c2 in comps)
                    {
                        if (c1 != c2 && ipu[c1].ContainsKey(c2))
                        {
                            var ip = ipu[c1][c2];
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2 + " A12", ip.A12,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.A12         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2 + " A21", ip.A21,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.A21         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2 + " B12", ip.B12,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.B12         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2 + " B21", ip.B21,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.B21         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2 + " C12", ip.C12,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.C12         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2 + " C21", ip.C21,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.C21         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                        }
                    }
                }
                break;

            case "Peng-Robinson (PR)":
                var ppr = (PengRobinsonPropertyPackage)pp;
                var ipc = ppr.m_pr.InteractionParameters;
                foreach (var c1 in comps)
                {
                    if (!ipc.ContainsKey(c1))
                    {
                        ipc.Add(c1, new Dictionary <string, PR_IPData>());
                    }
                    foreach (var c2 in comps)
                    {
                        if (c1 != c2)
                        {
                            if (!ipc[c1].ContainsKey(c2))
                            {
                                if (ipc.ContainsKey(c2) && !ipc[c2].ContainsKey(c1))
                                {
                                    ipc[c1].Add(c2, new PR_IPData());
                                }
                            }
                        }
                    }
                }

                foreach (var c1 in comps)
                {
                    foreach (var c2 in comps)
                    {
                        if (c1 != c2 && ipc[c1].ContainsKey(c2))
                        {
                            var ip = ipc[c1][c2];
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2, ip.kij,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.kij         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                        }
                    }
                }
                break;

            case "Soave-Redlich-Kwong (SRK)":
                var pps  = (SRKPropertyPackage)pp;
                var ipc2 = pps.m_pr.InteractionParameters;
                foreach (var c1 in comps)
                {
                    if (!ipc2.ContainsKey(c1))
                    {
                        ipc2.Add(c1, new Dictionary <string, PR_IPData>());
                    }
                    foreach (var c2 in comps)
                    {
                        if (c1 != c2)
                        {
                            if (!ipc2[c1].ContainsKey(c2))
                            {
                                if (ipc2.ContainsKey(c2) && !ipc2[c2].ContainsKey(c1))
                                {
                                    ipc2[c1].Add(c2, new PR_IPData());
                                }
                            }
                        }
                    }
                }

                foreach (var c1 in comps)
                {
                    foreach (var c2 in comps)
                    {
                        if (c1 != c2 && ipc2[c1].ContainsKey(c2))
                        {
                            var ip = ipc2[c1][c2];
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2, ip.kij,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.kij         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                        }
                    }
                }
                break;

            case "Lee-Kesler-Plöcker":
                var ppl = (LKPPropertyPackage)pp;
                var ipl = ppl.m_lk.InteractionParameters;
                foreach (var c1 in comps)
                {
                    if (!ipl.ContainsKey(c1))
                    {
                        ipl.Add(c1, new Dictionary <string, LKP_IPData>());
                    }
                    foreach (var c2 in comps)
                    {
                        if (c1 != c2)
                        {
                            if (!ipl[c1].ContainsKey(c2))
                            {
                                if (ipl.ContainsKey(c2) && !ipl[c2].ContainsKey(c1))
                                {
                                    ipl[c1].Add(c2, new LKP_IPData());
                                }
                            }
                        }
                    }
                }

                foreach (var c1 in comps)
                {
                    foreach (var c2 in comps)
                    {
                        if (c1 != c2 && ipl[c1].ContainsKey(c2))
                        {
                            var ip = ipl[c1][c2];
                            s.CreateAndAddTextBoxRow(this, nf, c1 + "/" + c2, ip.kij,
                                                     (arg3, arg2) =>
                            {
                                if (Double.TryParse(arg3.Text.ToString(), out val))
                                {
                                    arg3.TextColor = (Colors.White);
                                    ip.kij         = Double.Parse(arg3.Text);
                                }
                                else
                                {
                                    arg3.TextColor = (Colors.Red);
                                }
                            });
                        }
                    }
                }
                break;
            }

            s.CreateAndAddLabelRow(this, "Model Configuration");

            var parkeys = pp.Parameters.Keys.ToList();

            foreach (var par in parkeys)
            {
                s.CreateAndAddTextBoxRow(this, "R",
                                         flowsheet.GetTranslatedString(par), Double.Parse(pp.Parameters[par].ToString()),
                                         (arg3, arg2) =>
                {
                    if (Double.TryParse(arg3.Text.ToString(), out val))
                    {
                        arg3.TextColor     = (Colors.White);
                        pp.Parameters[par] = Double.Parse(arg3.Text);
                    }
                    else
                    {
                        arg3.TextColor = (Colors.Red);
                    }
                });
            }
        }
Esempio n. 2
0
        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;
                }
            };
        }
Esempio n. 3
0
        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;
                }
                else
                {
                    tbr.ReadOnly         = true;
                    tbtc.ReadOnly        = true;
                    tbr.BackgroundColor  = Eto.Drawing.Colors.LightGrey;
                    tbtc.BackgroundColor = Eto.Drawing.Colors.LightGrey;
                }
            };
        }
Esempio n. 4
0
        public void UpdateList()
        {
            Data = new List <List <string> >();

            var su = Flowsheet.FlowsheetOptions.SelectedUnitSystem;
            var nf = Flowsheet.FlowsheetOptions.NumberFormat;

            string[] props = null, units = null;
            string   value = null;
            List <ISimulationObject> mslist;

            mslist = Flowsheet.SimulationObjects.Values.Where((x) => x is MaterialStream).ToList();
            //mslist.Reverse();

            foreach (var ms in mslist)
            {
                props = ms.GetProperties(Interfaces.Enums.PropertyType.ALL);
                units = (string[])props.Clone();
                break;
            }

            if (props == null)
            {
                return;
            }

            foreach (var item in props)
            {
                var list = new List <string>();
                foreach (var ms in mslist)
                {
                    list.Add("");
                }
                Data.Add(list);
            }


            int    i = 0, j = 0;
            double d = 0;

            foreach (string prop in props)
            {
                j = 0;
                foreach (var ms in mslist)
                {
                    var data = ms.GetPropertyValue(prop, su);
                    if (data != null)
                    {
                        value = data.ToString();
                    }
                    else
                    {
                        value = "";
                    }
                    units[i] = ms.GetPropertyUnit(prop, su);
                    if (double.TryParse(value, out d))
                    {
                        if (double.IsNaN(d))
                        {
                            Data[i][j] = "N/A";
                        }
                        else
                        {
                            Data[i][j] = double.Parse(value).ToString(nf);
                        }
                    }
                    else
                    {
                        Data[i][j] = value;
                    }
                    j += 1;
                }
                i += 1;
            }

            var maxlength = props.Select((x) => Flowsheet.GetTranslatedString(x)).Select((x) => x.Length).Max();

            string textlist = "Property / Material Stream".PadRight(maxlength + 10);

            foreach (var ms in mslist)
            {
                textlist += ms.GraphicObject.Tag.PadLeft(PadSize);
            }
            textlist += Environment.NewLine;

            i = 0;
            foreach (var list in Data)
            {
                if (units[i] != "")
                {
                    textlist += (Flowsheet.GetTranslatedString(props[i]) + " (" + units[i] + ")").PadRight(maxlength + 10);
                }
                else
                {
                    textlist += Flowsheet.GetTranslatedString(props[i]).PadRight(maxlength + 10);
                }
                foreach (var list2 in list)
                {
                    textlist += list2.PadLeft(PadSize);
                }
                textlist += Environment.NewLine;
                i        += 1;
            }

            txtView.Text = textlist;
            txtView.Font = GlobalSettings.Settings.RunningPlatform() == GlobalSettings.Settings.Platform.Mac ? new Font("Menlo", Common.GetEditorFontSize()) : Fonts.Monospace(Common.GetEditorFontSize());

            lblLastUpdate.Text = "Updated on: " + DateTime.Now.ToString();
        }