Ejemplo n.º 1
0
        void Initialize()
        {
            s.CreateAndAddLabelRow(container, "Custom Properties Editor");

            s.CreateAndAddDescriptionRow(container, "Property values are updated/stored as they are changed/edited. There's no need to press ENTER to commit the changes.");

            var col1 = (IDictionary <string, object>)SimObject.ExtraProperties;
            var col2 = (IDictionary <string, object>)SimObject.ExtraPropertiesDescriptions;
            var col3 = (IDictionary <string, object>)SimObject.ExtraPropertiesUnitTypes;

            foreach (var p in col1)
            {
                if (!col2.ContainsKey(p.Key) && !col3.ContainsKey(p.Key))
                {
                    container.CreateAndAddStringEditorRow(p.Key,
                                                          p.Value.ToString(),
                                                          (tb, e) =>
                    {
                        try
                        {
                            col1[p.Key]  = tb.Text;
                            tb.TextColor = Colors.Blue;
                        }
                        catch
                        {
                            tb.TextColor = Colors.Red;
                        }
                    });
                    container.CreateAndAddEmptySpace();
                }
            }

            s.CreateAndAddEmptySpace(container);
            s.CreateAndAddEmptySpace(container);
        }
Ejemplo 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.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;
                }
            };
        }
Ejemplo n.º 3
0
        public void UpdatePropertiesLayout()
        {
            Application.Instance.Invoke(() =>
            {
                try
                {
                    var pm = (PlotModel)Chart.PlotModel;

                    var pl = new DynamicLayout();

                    pl.Padding = new Eto.Drawing.Padding(10);

                    pl.CreateAndAddButtonRow("Update Chart Data", null, (btn, e) =>
                    {
                        Application.Instance.Invoke(() =>
                        {
                            UpdatePlotModelData();
                            UpdatePropertiesLayout();
                        });
                    });

                    pl.CreateAndAddLabelRow("General");

                    pl.CreateAndAddStringEditorRow("Chart Name", Chart.DisplayName, (t, e) =>
                    {
                        Chart.DisplayName = t.Text;
                    }, () => Application.Instance.Invoke(() => ((DocumentPage)Parent).Text = Chart.DisplayName));

                    pl.CreateAndAddDropDownRow("Data Source", Chart.ChartSource.GetEnumNames(), (int)Chart.ChartSource, (dd, e) =>
                    {
                        Chart.ChartSource = (ChartSource)dd.SelectedIndex;
                        UpdatePropertiesLayout();
                    });

                    if (Chart.ChartSource == ChartSource.FlowsheetObject)
                    {
                        pl.CreateAndAddLabelRow("Data Source");

                        var objlist = new List <String>();

                        objlist = Flowsheet.SimulationObjects.Values.Select((x) => x.GraphicObject.Tag).ToList();
                        objlist.Insert(0, "");

                        string selobj = "";

                        if (Flowsheet.SimulationObjects.ContainsKey(Chart.ChartSourceObjectID))
                        {
                            selobj = Flowsheet.SimulationObjects[Chart.ChartSourceObjectID].GraphicObject.Tag;
                        }

                        pl.CreateAndAddDropDownRow("Source Object", objlist, objlist.IndexOf(selobj), (dd, e) =>
                        {
                            var obj = Flowsheet.GetFlowsheetSimulationObject(dd.SelectedValue.ToString());
                            if (obj != null)
                            {
                                Chart.ChartSourceObjectID = obj.Name;
                            }
                            UpdatePropertiesLayout();
                        });

                        if (Flowsheet.SimulationObjects.ContainsKey(Chart.ChartSourceObjectID))
                        {
                            var obj        = Flowsheet.GetFlowsheetSimulationObject(selobj);
                            var chartnames = obj.GetChartModelNames();
                            var cindex     = 0;

                            if (Chart.ChartSourceObjectChartID != "")
                            {
                                if (chartnames.Contains(Chart.ChartSourceObjectChartID))
                                {
                                    cindex = chartnames.IndexOf(Chart.ChartSourceObjectChartID);
                                }
                            }

                            pl.CreateAndAddDropDownRow("Source Object Chart Type", chartnames, cindex, (dd, e) =>
                            {
                                Chart.ChartSourceObjectChartID = chartnames[dd.SelectedIndex];
                                Application.Instance.Invoke(() =>
                                {
                                    UpdatePlotModelData();
                                    UpdatePropertiesLayout();
                                });
                            });

                            pl.CreateAndAddCheckBoxRow("Auto Update Chart from Object", Chart.ChartSourceObjectAutoUpdate,
                                                       (chk, e) => { Chart.ChartSourceObjectAutoUpdate = chk.Checked.GetValueOrDefault(); });
                        }
                    }
                    else
                    {
                        pl.CreateAndAddLabelRow2("X Axis Data Sources");
                        var ml1 = pl.CreateAndAddMultilineTextBoxRow(String.Join(Environment.NewLine, Chart.SpreadsheetDataSourcesX), false, true, (txt, e) =>
                        {
                        });
                        pl.CreateAndAddButtonRow("Update Data", null, (btn, e) =>
                        {
                            try
                            {
                                Chart.SpreadsheetDataSourcesX.Clear();
                                foreach (var line in ml1.Text.Split('\n'))
                                {
                                    Chart.SpreadsheetDataSourcesX.Add(line.Trim());
                                }
                                Application.Instance.Invoke(() =>
                                {
                                    UpdatePlotModelData();
                                });
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Error updating chart data: " + ex.Message, "DWSIM", MessageBoxType.Error);
                            }
                        });


                        pl.CreateAndAddLabelRow2("Y Axis Data Sources");
                        var ml2 = pl.CreateAndAddMultilineTextBoxRow(String.Join(Environment.NewLine, Chart.SpreadsheetDataSourcesY), false, true, (txt, e) =>
                        {
                        });
                        pl.CreateAndAddButtonRow("Update Data", null, (btn, e) =>
                        {
                            try
                            {
                                Chart.SpreadsheetDataSourcesY.Clear();
                                foreach (var line in ml2.Text.Split('\n'))
                                {
                                    Chart.SpreadsheetDataSourcesY.Add(line.Trim());
                                }
                                Application.Instance.Invoke(() =>
                                {
                                    UpdatePlotModelData();
                                });
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show("Error updating chart data: " + ex.Message, "DWSIM", MessageBoxType.Error);
                            }
                        });
                    }

                    if (pm != null)
                    {
                        pl.CreateAndAddLabelRow("Plot");

                        pl.CreateAndAddStringEditorRow("Title", pm.Title, (txt, e) =>
                        {
                            Application.Instance.Invoke(() =>
                            {
                                pm.Title = txt.Text;
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });

                        pl.CreateAndAddDropDownRow("Title Position", pm.TitleHorizontalAlignment.GetEnumNames(),
                                                   (int)pm.TitleHorizontalAlignment, (dd, e) =>
                        {
                            pm.TitleHorizontalAlignment = dd.SelectedIndex.ToEnum <TitleHorizontalAlignment>();
                            Application.Instance.Invoke(() =>
                            {
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });

                        pl.CreateAndAddNumericEditorRow("Title Font Size", pm.TitleFontSize, 4.0, 30, 1, (ns, e) =>
                        {
                            pm.TitleFontSize = ns.Value;
                            Application.Instance.Invoke(() =>
                            {
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });

                        pl.CreateAndAddStringEditorRow("Subtitle", pm.Subtitle, (txt, e) =>
                        {
                            pm.Subtitle = txt.Text;
                            Application.Instance.Invoke(() =>
                            {
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });

                        pl.CreateAndAddNumericEditorRow("Subtitle Font Size", pm.SubtitleFontSize, 4.0, 30, 1, (ns, e) =>
                        {
                            pm.SubtitleFontSize = ns.Value;
                            Application.Instance.Invoke(() =>
                            {
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });

                        pl.CreateAndAddCheckBoxRow("Display Legend", pm.IsLegendVisible,
                                                   (chk, e) =>
                        {
                            pm.IsLegendVisible = chk.Checked.GetValueOrDefault();
                            Application.Instance.Invoke(() =>
                            {
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });

                        if (pm.IsLegendVisible)
                        {
                            pl.CreateAndAddDropDownRow("Legend Position", pm.LegendPosition.GetEnumNames(),
                                                       (int)pm.LegendPosition, (dd, e) =>
                            {
                                pm.LegendPosition = dd.SelectedIndex.ToEnum <LegendPosition>();
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });

                            pl.CreateAndAddDropDownRow("Legend Placement", pm.LegendPlacement.GetEnumNames(),
                                                       (int)pm.LegendPlacement, (dd, e) =>
                            {
                                pm.LegendPlacement = dd.SelectedIndex.ToEnum <LegendPlacement>();
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });

                            pl.CreateAndAddDropDownRow("Legend Orientation", pm.LegendOrientation.GetEnumNames(),
                                                       (int)pm.LegendOrientation, (dd, e) =>
                            {
                                pm.LegendOrientation = dd.SelectedIndex.ToEnum <LegendOrientation>();
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });

                            pl.CreateAndAddStringEditorRow("Legend Title", pm.LegendTitle, (txt, e) =>
                            {
                                pm.LegendTitle = txt.Text;
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });

                            pl.CreateAndAddNumericEditorRow("Legend Title Font Size", pm.LegendTitleFontSize, 4.0, 30, 1, (ns, e) =>
                            {
                                pm.LegendTitleFontSize = ns.Value;
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });

                            pl.CreateAndAddDropDownRow("Legend Item Alignment", pm.LegendItemAlignment.GetEnumNames(),
                                                       (int)pm.LegendItemAlignment, (dd, e) =>
                            {
                                pm.LegendItemAlignment = dd.SelectedIndex.ToEnum <OxyPlot.HorizontalAlignment>();
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });

                            pl.CreateAndAddDropDownRow("Legend Item Order", pm.LegendItemOrder.GetEnumNames(),
                                                       (int)pm.LegendItemOrder, (dd, e) =>
                            {
                                pm.LegendItemOrder = dd.SelectedIndex.ToEnum <OxyPlot.LegendItemOrder>();
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });

                            pl.CreateAndAddNumericEditorRow("Legend Item Spacing", pm.LegendItemSpacing, 0.1, 5, 1, (ns, e) =>
                            {
                                pm.LegendItemSpacing = ns.Value;
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });

                            pl.CreateAndAddNumericEditorRow("Legend Line Spacing", pm.LegendLineSpacing, 0.1, 5, 1, (ns, e) =>
                            {
                                pm.LegendLineSpacing = ns.Value;
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });
                        }

                        if (pm.Axes.Count >= 1)
                        {
                            pl.CreateAndAddLabelRow("X Axis");

                            pl.CreateAndAddStringEditorRow("Title", pm.Axes[0].Title, (txt, e) =>
                            {
                                pm.Axes[0].Title = txt.Text;
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });

                            pl.CreateAndAddNumericEditorRow("Font Size", pm.Axes[0].FontSize, 4.0, 30, 1, (ns, e) =>
                            {
                                pm.Axes[0].FontSize = ns.Value;
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });

                            pl.CreateAndAddNumericEditorRow("Title Font Size", pm.Axes[0].TitleFontSize, 4.0, 30, 1, (ns, e) =>
                            {
                                pm.Axes[0].TitleFontSize = ns.Value;
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });

                            pl.CreateAndAddNumericEditorRow("Title Position", pm.Axes[0].TitlePosition, 0.0, 1.0, 2, (ns, e) =>
                            {
                                pm.Axes[0].TitlePosition = ns.Value;
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });
                        }

                        if (pm.Axes.Count >= 2)
                        {
                            pl.CreateAndAddLabelRow("Y Axis");

                            pl.CreateAndAddStringEditorRow("Title", pm.Axes[1].Title, (txt, e) =>
                            {
                                pm.Axes[1].Title = txt.Text;
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });

                            pl.CreateAndAddNumericEditorRow("Font Size", pm.Axes[1].FontSize, 4.0, 30, 1, (ns, e) =>
                            {
                                pm.Axes[1].FontSize = ns.Value;
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });

                            pl.CreateAndAddNumericEditorRow("Title Font Size", pm.Axes[1].TitleFontSize, 4.0, 30, 1, (ns, e) =>
                            {
                                pm.Axes[1].TitleFontSize = ns.Value;
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });

                            pl.CreateAndAddNumericEditorRow("Title Position", pm.Axes[1].TitlePosition, 0.0, 1.0, 2, (ns, e) =>
                            {
                                pm.Axes[1].TitlePosition = ns.Value;
                                Application.Instance.Invoke(() =>
                                {
                                    ChartView.Model.InvalidatePlot(true);
                                    ChartView.Invalidate();
                                });
                            });
                        }
                    }

                    var i = 0;

                    foreach (LineSeries series in pm.Series)
                    {
                        pl.CreateAndAddLabelRow(String.Format("Line Series #{0}", i));

                        pl.CreateAndAddStringEditorRow("Title", series.Title, (txt, e) =>
                        {
                            series.Title = txt.Text;
                            Application.Instance.Invoke(() =>
                            {
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });

                        pl.CreateAndAddDropDownRow("Line Type", series.LineStyle.GetEnumNames(),
                                                   (int)series.LineStyle, (dd, e) =>
                        {
                            series.LineStyle = dd.SelectedIndex.ToEnum <LineStyle>();
                            Application.Instance.Invoke(() =>
                            {
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });

                        var cchoices = new List <string>(ColorChoices);
                        cchoices.Insert(0, series.Color.ToString());

                        pl.CreateAndAddDropDownRow("Line Color", cchoices, 0, (dd, e) =>
                        {
                            if (dd.SelectedIndex > 0)
                            {
                                series.Color = (OxyColor)typeof(OxyColors).GetField(dd.SelectedValue.ToString()).GetValue(null);
                            }
                            Application.Instance.Invoke(() =>
                            {
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });

                        pl.CreateAndAddNumericEditorRow("Line Width", series.StrokeThickness, 0.1, 10.0, 1, (ns, e) =>
                        {
                            series.StrokeThickness = ns.Value;
                            Application.Instance.Invoke(() =>
                            {
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });

                        pl.CreateAndAddDropDownRow("Marker Type", series.MarkerType.GetEnumNames(),
                                                   (int)series.MarkerType, (dd, e) =>
                        {
                            series.MarkerType = dd.SelectedIndex.ToEnum <MarkerType>();
                            Application.Instance.Invoke(() =>
                            {
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });

                        cchoices = new List <string>(ColorChoices);
                        cchoices.Insert(0, series.Color.ToString());

                        pl.CreateAndAddNumericEditorRow("Marker Size", series.MarkerSize, 0.1, 10.0, 1, (ns, e) =>
                        {
                            series.MarkerSize = ns.Value;
                            Application.Instance.Invoke(() =>
                            {
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });

                        pl.CreateAndAddDropDownRow("Marker Fill Color", cchoices, 0, (dd, e) =>
                        {
                            if (dd.SelectedIndex > 0)
                            {
                                series.MarkerFill = (OxyColor)typeof(OxyColors).GetField(dd.SelectedValue.ToString()).GetValue(null);
                            }
                            Application.Instance.Invoke(() =>
                            {
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });

                        pl.CreateAndAddNumericEditorRow("Marker Stroke Size", series.MarkerStrokeThickness, 0.1, 10.0, 1, (ns, e) =>
                        {
                            series.MarkerStrokeThickness = ns.Value;
                            Application.Instance.Invoke(() =>
                            {
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });

                        pl.CreateAndAddDropDownRow("Marker Stroke Color", cchoices, 0, (dd, e) =>
                        {
                            if (dd.SelectedIndex > 0)
                            {
                                series.MarkerStroke = (OxyColor)typeof(OxyColors).GetField(dd.SelectedValue.ToString()).GetValue(null);
                            }
                            Application.Instance.Invoke(() =>
                            {
                                ChartView.Model.InvalidatePlot(true);
                                ChartView.Invalidate();
                            });
                        });
                    }

                    Splitter.Panel2 = new Scrollable {
                        Content = pl
                    };
                    Splitter.Panel2.Width = 350;
                }
                catch (Exception ex)
                {
                    Flowsheet.ShowMessage("Error updating chart property list: " + ex.Message, Interfaces.IFlowsheet.MessageType.GeneralError);
                }
            });
        }
Ejemplo n.º 4
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;
                }
            };
        }