コード例 #1
0
ファイル: DynamicControl.cs プロジェクト: mhusen/Eto
		internal override void SetLayout(DynamicLayout layout)
		{
			if (Control != null)
			{
				if (this.layout != null)
					this.layout.RemoveChild(Control);
				if (layout != null)
					layout.AddChild(Control);
			}
			this.layout = layout;
		}
コード例 #2
0
ファイル: DynamicControl.cs プロジェクト: mhusen/Eto
		/// <summary>
		/// Creates the content for this item
		/// </summary>
		/// <param name="layout">Top level layout the item is being created for</param>
		public override Control Create(DynamicLayout layout)
		{
			return Control;
		}
コード例 #3
0
        private void InitializeComponent()
        {
            this.label1           = new Label();
            this.label2           = new Label();
            this.XPixelLabel      = new Label();
            this.label4           = new Label();
            this.label5           = new Label();
            this.YPixelLabel      = new Label();
            this.XCoordinateLabel = new Label();
            this.YCoordinateLabel = new Label();
            this.formsPlot1       = new ScottPlot.Eto.PlotView();
            this.lblMouse         = new Label();
            this.SuspendLayout();

            var layout = new DynamicLayout();

            layout.AddRow(
                new DynamicLayout(new Label()
            {
                Text = "*", TextColor = BackgroundColor
            }, label2, label1),
                new DynamicLayout(label4, XPixelLabel, YPixelLabel),
                new DynamicLayout(label5, XCoordinateLabel, YCoordinateLabel),
                new DynamicLayout(lblMouse)
                );

            layout = new DynamicLayout();
            layout.AddRow(new Label()
            {
                Text = "*", TextColor = BackgroundColor
            }, label4, label5, lblMouse);
            layout.AddRow(label2, XPixelLabel, XCoordinateLabel);
            layout.AddRow(label1, YPixelLabel, YCoordinateLabel);

            layout.SetPaddingRecursive(4);

            this.Content = new DynamicLayout(layout, formsPlot1);

            //
            // label1
            //
            this.label1.Font = Fonts.Sans(12);
            this.label1.Size = new Size(20, 20);
            this.label1.Text = "Y";
            //
            // label2
            //
            this.label2.Font = Fonts.Sans(12);
            this.label2.Size = new Size(20, 20);
            this.label2.Text = "X";
            //
            // XPixelLabel
            //
            this.XPixelLabel.Font = Fonts.Monospace(12);
            this.XPixelLabel.Size = new Size(100, 19);
            this.XPixelLabel.Text = "?";
            //
            // label4
            //
            this.label4.Font = Fonts.Sans(12);
            this.label4.Size = new Size(41, 20);
            this.label4.Text = "Pixel";
            //
            // label5
            //
            this.label5.Font = Fonts.Sans(12);
            this.label5.Size = new Size(87, 20);
            this.label5.Text = "Coordinate";
            //
            // YPixelLabel
            //
            this.YPixelLabel.Font = Fonts.Monospace(12);
            this.YPixelLabel.Size = new Size(100, 19);
            this.YPixelLabel.Text = "?";
            //
            // XCoordinateLabel
            //
            this.XCoordinateLabel.Font = Fonts.Monospace(12);
            this.XCoordinateLabel.Size = new Size(120, 19);
            this.XCoordinateLabel.Text = "?";
            //
            // YCoordinateLabel
            //
            this.YCoordinateLabel.Font = Fonts.Monospace(12);
            this.YCoordinateLabel.Size = new Size(120, 19);
            this.YCoordinateLabel.Text = "?";
            //
            // formsPlot1
            //
            this.formsPlot1.BackgroundColor = Colors.Transparent;
            //
            // lblMouse
            //
            this.lblMouse.Font = Fonts.Sans(12);
            this.lblMouse.Size = new Size(149, 20);
            this.lblMouse.Text = "Waiting for mouse...";
            //
            // MouseTracker
            //
            this.ClientSize = new Size(736, 405);
            this.Title      = "MouseTracker";
            this.ResumeLayout();
        }
コード例 #4
0
        void Init()
        {
            string imgprefix = "DWSIM.UI.Desktop.Editors.Resources.Icons.";

            Icon = Eto.Drawing.Icon.FromResource(imgprefix + "DWSIM_ico.ico");

            Maximizable = false;
            Minimizable = false;
            WindowStyle = Eto.Forms.WindowStyle.Default;

            Title = "Error";

            var mystring  = SharedClasses.EncryptString.StringCipher.Decrypt("YEZeCozmw0l3XjOYI0EpOXHh1LK9as6Bi5Gwqr7pYZyXtcNYQyzayHXts6NjAJlpfixoim98NAwVHli/+h1fYk6g4W82ewXDxkLwzg5SFCCSS2W0K3TvGMgC0wQWuKfrut0QdnByVKZ4x+/svdQwwXsUkZdELOUtnWiOdeV6WIQ=", "dwsim000000");
            var mystring2 = SharedClasses.EncryptString.StringCipher.Decrypt("T+h/AQaXoM7xMDrov6dkD/82uHShQ6gX7MD+yyPG1ALdchPnpYsxHZWU8YcwP3jTPCZWRL9mmAWnQnWtp4ETyYh17Cgjt1EDYbEJJvh/PacWXami/6btnnbE0D5HBpnYrKamsf6qjjx9JbhQOZIvXJv6dIlJ7lMm5vWkhmLpNuc=", "dwsim000000");

            try
            {
                string     baseaddress = "https://github.com/DanWBR/dwsim5/blob/windows/";
                StackTrace st          = new StackTrace(exc, true);
                StackFrame frame       = st.GetFrame(0);
                string     path        = frame.GetFileName().Replace(mystring, baseaddress);
                path = path.Replace(mystring2, baseaddress);
                int line = frame.GetFileLineNumber();
                if (path.Contains(baseaddress))
                {
                    githublink = path + "#L" + line;
                }
            }
            catch (Exception)
            {
            }

            var container = new TableLayout()
            {
                Padding = new Padding(10), Spacing = new Size(5, 5)
            };

            container.Rows.Add(new TableRow(new Label {
                Text = "DWSIM generated an unhandled error/exception."
            }));

            var txt1 = new TextArea {
                Text = exc.Message.ToString(), ReadOnly = true
            };
            var txt2 = new TextArea {
                Text = exc.ToString(), ReadOnly = true
            };

            var t1 = new TableLayout(new TableRow(txt1));
            var t2 = new TableLayout(new TableRow(txt2));

            var tab1 = new TabPage {
                Content = t1, Text = "Error Message"
            };
            var tab2 = new TabPage {
                Content = t2, Text = "Details"
            };

            var tabc = new TabControl {
                Height = 300
            };

            tabc.Pages.Add(tab1);
            tabc.Pages.Add(tab2);

            container.Rows.Add(new TableRow(tabc));

            container.Rows.Add(new Label {
                Text = "Actions", Font = SystemFonts.Bold()
            });

            var dyn1 = new DynamicLayout {
                Padding = new Padding(0)
            };

            dyn1.CreateAndAddLabelAndButtonRow("Close this window.", "Continue", null, (sender, e) =>
            {
                this.Close();
            });
            container.Rows.Add(new TableRow(dyn1));

            var dyn2 = new DynamicLayout {
                Padding = new Padding(0)
            };

            dyn2.CreateAndAddLabelAndButtonRow("Kill current DWSIM process. Unsaved changes will be lost.", "Kill", null, (sender, e) =>
            {
                Process.GetCurrentProcess().Kill();
            });
            container.Rows.Add(new TableRow(dyn2));

            var dyn3 = new DynamicLayout {
                Padding = new Padding(0)
            };

            dyn3.CreateAndAddLabelAndButtonRow("Restart DWSIM", "Restart", null, (sender, e) =>
            {
                Application.Instance.Restart();
            });
            container.Rows.Add(new TableRow(dyn3));

            container.Rows.Add(new Label {
                Text = "Additional Support", Font = SystemFonts.Bold()
            });

            var dyn4 = new DynamicLayout {
                Padding = new Padding(0)
            };

            dyn4.CreateAndAddLabelAndButtonRow("Search DWSIM Forums for information about the current error.", "Search Forums", null, (sender, e) =>
            {
                var baseaddress = "https://sourceforge.net/p/dwsim/search/?q=";
                var searchtext  = exc.Message.ToString().Replace(" ", "+");
                Process.Start(baseaddress + searchtext);
            });
            container.Rows.Add(new TableRow(dyn4));

            var dyn5 = new DynamicLayout {
                Padding = new Padding(0)
            };

            dyn5.CreateAndAddLabelAndButtonRow("Search DWSIM's Website for information about the current error.", "Search Website", null, (sender, e) =>
            {
                var baseaddress = "http://dwsim.inforside.com.br/wiki/index.php?title=Special:Search&fulltext=Search&profile=all&redirs=1&search=";
                var searchtext  = exc.Message.ToString().Replace(" ", "+");
                Process.Start(baseaddress + searchtext);
            });
            container.Rows.Add(new TableRow(dyn5));

            if (githublink != "")
            {
                var dyn6 = new DynamicLayout {
                    Padding = new Padding(0)
                };
                dyn6.CreateAndAddLabelAndButtonRow("View the code line where this error was raised/generated on DWSIM's GitHub repository.", "View code @ GitHub", null, (sender, e) =>
                {
                    Process.Start(githublink);
                });
                container.Rows.Add(new TableRow(dyn6));
            }

            Content = container;
        }
コード例 #5
0
        public void Init()
        {
            loaded = false;

            Pages.Clear();

            // connections

            if (obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.MaterialStream &&
                obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.EnergyStream &&
                obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.OT_Adjust &&
                obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.Controller_PID &&
                obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.LevelGauge &&
                obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.AnalogGauge &&
                obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.DigitalGauge &&
                obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.Input &&
                obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.Switch &&
                obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.OT_Spec)
            {
                var tab1 = new DocumentPage {
                    Closable = false
                };
                tab1.Text = "Connections";

                var cont0 = UI.Shared.Common.GetDefaultContainer();

                UI.Shared.Common.CreateAndAddLabelRow(cont0, "Object Connections Editor".Localize());

                UI.Shared.Common.CreateAndAddDescriptionRow(cont0, "ConnectorsEditorDescription".Localize());
                new DWSIM.UI.Desktop.Editors.ConnectionsEditor(obj, cont0);

                cont0.Width = this.Width - 30;

                var scr1 = new Scrollable()
                {
                    Content = cont0
                };
                tab1.Content = scr1;

                Pages.Add(tab1);

                PageConnections = tab1;
            }

            // properties

            var tab2 = new DocumentPage {
                Closable = false
            };

            tab2.Text = "Properties";

            Pages.Add(tab2);

            var cont = UI.Shared.Common.GetDefaultContainer();

            cont.Width = this.Width - 30;

            if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.MaterialStream)
            {
                new DWSIM.UI.Desktop.Editors.MaterialStreamEditor(obj, cont);
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.DistillationColumn)
            {
                new DWSIM.UI.Desktop.Editors.DistillationColumnEditor(obj, cont);
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.AbsorptionColumn)
            {
                new DWSIM.UI.Desktop.Editors.AbsorptionColumnEditor(obj, cont);
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.OT_Adjust)
            {
                DWSIM.UI.Desktop.Editors.LogicalBlocks.AdjustEditor.Populate(obj, cont);
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.Controller_PID)
            {
                DWSIM.UI.Desktop.Editors.LogicalBlocks.PIDControllerEditor.Populate(obj, cont);
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.OT_Spec)
            {
                DWSIM.UI.Desktop.Editors.LogicalBlocks.SpecEditor.Populate(obj, cont);
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.OT_Recycle)
            {
                DWSIM.UI.Desktop.Editors.LogicalBlocks.RecycleEditor.Populate(obj, cont);
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.OT_EnergyRecycle)
            {
                DWSIM.UI.Desktop.Editors.LogicalBlocks.EnergyRecycleEditor.Populate(obj, cont);
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.LevelGauge)
            {
                DWSIM.UI.Desktop.Editors.LogicalBlocks.LevelGaugeEditor.Populate(obj, cont);
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.AnalogGauge)
            {
                DWSIM.UI.Desktop.Editors.LogicalBlocks.AnalogGaugeEditor.Populate(obj, cont);
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.DigitalGauge)
            {
                DWSIM.UI.Desktop.Editors.LogicalBlocks.DigitalGaugeEditor.Populate(obj, cont);
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.Switch)
            {
                DWSIM.UI.Desktop.Editors.LogicalBlocks.SwitchEditor.Populate(obj, cont);
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.Input)
            {
                DWSIM.UI.Desktop.Editors.LogicalBlocks.InputEditor.Populate(obj, cont);
            }
            else
            {
                new DWSIM.UI.Desktop.Editors.GeneralEditors(obj, cont);
            }

            tab2.Content = new Scrollable()
            {
                Content = cont, Width = this.Width - 30
            };

            if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.Pipe)
            {
                tab2.Text = "General";
                var cont2 = UI.Shared.Common.GetDefaultContainer();
                cont2.Tag   = "Hydraulic Profile";
                cont2.Width = this.Width - 30;
                new PipeHydraulicProfile(obj, cont2);
                Pages.Add(new DocumentPage(new Scrollable()
                {
                    Content = cont2, Width = this.Width - 30
                })
                {
                    Text = "Hydraulic Profile", Closable = false
                });
                var cont3 = UI.Shared.Common.GetDefaultContainer();
                cont3.Tag   = "Thermal Profile";
                cont3.Width = this.Width - 30;
                new PipeThermalProfile(obj, cont3);
                Pages.Add(new DocumentPage(new Scrollable()
                {
                    Content = cont3, Width = this.Width - 30
                })
                {
                    Text = "Thermal Profile", Closable = false
                });
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.CustomUO)
            {
                tab2.Text = "General";
                var cont2 = new TableLayout {
                    Padding = new Padding(10), Spacing = new Size(5, 5)
                };
                cont2.Tag   = "Python Script";
                cont2.Width = this.Width - 30;
                if (Application.Instance.Platform.IsWpf)
                {
                    var scripteditor = new Eto.Forms.Controls.Scintilla.Shared.ScintillaControl()
                    {
                        ScriptText = ((CustomUO)obj).ScriptText
                    };
                    var dyn1 = new DynamicLayout();
                    dyn1.CreateAndAddLabelAndButtonRow("Click to commit script changes", "Update", null, (sender, e) =>
                    {
                        ((CustomUO)obj).ScriptText = scripteditor.ScriptText;
                    });
                    dyn1.Width = this.Width - 30;
                    cont2.Rows.Add(new TableRow(dyn1));
                    cont2.Rows.Add(new TableRow(scripteditor));
                }
                else if (Application.Instance.Platform.IsMac || Application.Instance.Platform.IsGtk)
                {
                    var scripteditor = new Eto.Forms.Controls.Scintilla.Shared.ScintillaControl()
                    {
                        ScriptText = ((CustomUO)obj).ScriptText
                    };
                    scripteditor.SetKeywords(1, ((FlowsheetBase.FlowsheetBase)obj.GetFlowsheet()).ScriptKeywordsU);
                    var dyn1 = new DynamicLayout();
                    dyn1.CreateAndAddLabelAndButtonRow("Click to commit script changes", "Update", null, (sender, e) =>
                    {
                        ((CustomUO)obj).ScriptText = scripteditor.ScriptText;
                    });
                    dyn1.Width = this.Width - 30;
                    cont2.Rows.Add(new TableRow(dyn1));
                    cont2.Rows.Add(new TableRow(scripteditor));
                }
                Pages.Add(new DocumentPage(new Scrollable()
                {
                    Content = cont2, Width = this.Width - 30
                })
                {
                    Text = "Python Script", Closable = false
                });
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.HeatExchanger)
            {
                tab2.Text = "General";
                var dyn1 = new ShellAndTubePropertiesView(obj);
                dyn1.Width = this.Width - 30;
                Pages.Add(new DocumentPage(new Scrollable()
                {
                    Content = dyn1, Width = this.Width - 30
                })
                {
                    Text = "Shell and Tube Properties", Closable = false
                });
            }
            else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.AbsorptionColumn ||
                     obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.DistillationColumn)
            {
                tab2.Text = "General";
                var dyn2 = RigorousColumnShared.GetInitialEstimatesEditor((Column)obj);
                dyn2.Width = this.Width - 30;
                Pages.Add(new DocumentPage(new Scrollable()
                {
                    Content = dyn2, Width = this.Width - 30
                })
                {
                    Text = "Initial Estimates", Closable = false
                });
            }

            PageEditor = tab2;

            // dynamics

            if ((obj.SupportsDynamicMode && obj.HasPropertiesForDynamicMode) || obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.MaterialStream)
            {
                if (obj.ExtraPropertiesDescriptions.Count() > 0 || obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.MaterialStream)
                {
                    var tabd = new DocumentPage {
                        Closable = false
                    };
                    tabd.Text = "Dynamics";

                    var contd = UI.Shared.Common.GetDefaultContainer();

                    contd.Width = this.Width - 30;

                    new DynamicPropertiesEditor(obj, contd);

                    tabd.Content = new Scrollable()
                    {
                        Content = contd, Width = this.Width - 30
                    };

                    PageDynamics = tabd;

                    Pages.Add(tabd);
                }
            }

            // results

            var tabr = new DocumentPage {
                Closable = false
            };

            tabr.Text = "Results";

            var container = new TableLayout();

            new DWSIM.UI.Desktop.Editors.Results(obj, container);

            tabr.Content = new Scrollable()
            {
                Content = container, Width = this.Width - 30
            };

            PageResults = tabr;

            Pages.Add(tabr);

            if (obj.GraphicObject is ShapeGraphic)
            {
                var tabx = new DocumentPage {
                    Closable = false
                };
                tabx.Text = "Appearance";
                var editor = new ObjectAppearanceEditorView(obj.GetFlowsheet(), (ShapeGraphic)obj.GraphicObject);
                editor.Width = this.Width - 30;
                tabx.Content = new Scrollable()
                {
                    Content = editor, Width = this.Width - 30
                };

                Pages.Add(tabx);
            }

            if (SelectedPanel >= 0)
            {
                SelectedIndex = SelectedPanel;
            }

            loaded = true;
        }
コード例 #6
0
        public MyForm()
        {
            this.ClientSize = new Size(600, 400);
            this.Title      = "Dynamic Layout";

            // Using a DynamicLayout for a simple table is actually a lot easier to maintain than using a TableLayout
            // and having to specify the x/y co-ordinates for each control added.

            // 1. Create a new DynamicLayout object

            var layout = new DynamicLayout();

            // 2. Begin a horizontal row of controls

            layout.BeginHorizontal();

            // 3. Add controls for each column.  We are setting xscale to true to make each column use an equal portion
            // of the available space.

            layout.Add(new Label {
                Text = "First Column"
            }, xscale: true);
            layout.Add(new Label {
                Text = "Second Column"
            }, xscale: true);
            layout.Add(new Label {
                Text = "Third Column"
            }, xscale: true);

            // 4. End the horizontal section

            layout.EndHorizontal();

            // 5. To add a new row, begin another horizontal section and add more controls:

            layout.BeginHorizontal();
            layout.Add(new TextBox {
                Text = "Second Row, First Column"
            });
            layout.Add(new ComboBox {
                DataStore = new ListItemCollection {
                    new ListItem {
                        Text = "Second Row, Second Column"
                    }
                }
            });
            layout.Add(new CheckBox {
                Text = "Second Row, Third Column"
            });
            layout.EndHorizontal();

            // 6. By default, the last row & column of a table expands to fill the rest of the space.  We can add one
            // last row with nothing in it to make the space empty.  Since we are not in a horizontal group, calling
            // Add() adds a new row.

            layout.Add(null);

            // 7. Set the content of the form to use the layout

            Content = layout;

            CreateMenu();
        }
コード例 #7
0
ファイル: DistillationColumn.cs プロジェクト: Greg66/dwsim6
        void Initialize()
        {
            var su  = column.GetFlowsheet().FlowsheetOptions.SelectedUnitSystem;
            var nf  = column.GetFlowsheet().FlowsheetOptions.NumberFormat;
            var nff = column.GetFlowsheet().FlowsheetOptions.FractionNumberFormat;

            s.CreateAndAddLabelRow(container, "Distillation Column 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.");

            if ((Inspector.Host.Items.Where(x => x.Name.Contains(column.GraphicObject.Tag)).Count() > 0))
            {
                var ctn = new DynamicLayout();
                ctn.BackgroundColor = Colors.LightGrey;
                s.CreateAndAddLabelRow(ctn, "Inspector Reports");
                s.CreateAndAddLabelAndButtonRow(ctn, "An Inspector Report is ready for viewing.", "View Report", null, (btn, e) =>
                {
                    var f = s.GetDefaultEditorForm("Inspector Report for '" + column.GraphicObject.Tag + "'", 1024, 768, Inspector.Window2_Eto.GetInspectorWindow(column), false);
                    f.Show();
                });
                container.Add(ctn);
            }

            s.CreateAndAddLabelRow(container, "Column Details");

            s.CreateAndAddTwoLabelsRow(container, "Type", column.GetDisplayName());

            s.CreateAndAddTwoLabelsRow(container, "Status", column.GraphicObject.Active ? "Active" : "Inactive");

            s.CreateAndAddStringEditorRow(container, "Name", column.GraphicObject.Tag, (TextBox arg3, EventArgs ev) =>
            {
                column.GraphicObject.Tag = arg3.Text;
                column.GetFlowsheet().UpdateInterface();
            }, () =>
            {
                column.GetFlowsheet().UpdateOpenEditForms();
            });

            s.CreateAndAddLabelRow(container, "Property Package");

            var proppacks = column.GetFlowsheet().PropertyPackages.Values.Select((x) => x.Tag).ToList();

            if (proppacks.Count == 0)
            {
                column.GetFlowsheet().ShowMessage("Error: please add at least one Property Package before continuing.", IFlowsheet.MessageType.GeneralError);
            }
            else
            {
                var    pp         = column.PropertyPackage;
                string selectedpp = "";
                if (pp != null)
                {
                    selectedpp = pp.Tag;
                }
                s.CreateAndAddDropDownRow(container, "Property Package", proppacks, proppacks.IndexOf(selectedpp), (DropDown arg1, EventArgs ev) =>
                {
                    if (proppacks.Count > 0)
                    {
                        column.PropertyPackage = (IPropertyPackage)column.GetFlowsheet().PropertyPackages.Values.Where((x) => x.Tag == proppacks[arg1.SelectedIndex]).FirstOrDefault();
                    }
                }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                           {
                               ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke();
                           }
                    });
            }

            s.CreateAndAddLabelRow(container, "Object Properties");

            s.CreateAndAddButtonRow(container, "Define Number of Stages", null, (arg1, e) =>
            {
                var np                  = new Eto.Forms.NumericStepper();
                np.MinValue             = 3;
                np.MaxValue             = 100;
                np.MaximumDecimalPlaces = 0;
                np.Value                = column.NumberOfStages;
                np.ValueChanged        += (sender, e2) =>
                {
                    var refval            = (int)np.Value;
                    column.NumberOfStages = refval;
                    int ne, nep, dif, i;
                    ne  = refval;
                    nep = column.Stages.Count;
                    dif = ne - nep;
                    if (dif != 0)
                    {
                        if (dif < 0)
                        {
                            column.Stages.RemoveRange(ne - 1, -dif);
                        }
                        else if (dif > 0)
                        {
                            for (i = 0; i <= dif; i++)
                            {
                                column.Stages.Insert(column.Stages.Count - 1, new Stage(Guid.NewGuid().ToString())
                                {
                                    P = 101325, Efficiency = 1.0f
                                });
                                column.Stages[column.Stages.Count - 2].Name = "Stage " + (column.Stages.Count - 2).ToString();
                            }
                        }
                    }
                };

                s.CreateDialog(np, "Set Number of Stages").ShowModal(container);
            });

            s.CreateAndAddButtonRow(container, "Edit Stages", null, (arg1, e) =>
            {
                var sview = DWSIM.UI.Shared.Common.GetDefaultContainer();

                s.CreateAndAddLabelRow(sview, "Edit Stages");
                s.CreateAndAddLabelRow(sview, "Number / Name / Pressure");
                var tlist = new List <TextBox>();
                foreach (var stage in column.Stages)
                {
                    tlist.Add(s.CreateAndAddDoubleTextBoxRow(sview, nf, (column.Stages.IndexOf(stage) + 1).ToString(), stage.Name, cv.ConvertFromSI(su.pressure, stage.P),
                                                             (arg10, arg20) =>
                    {
                        stage.Name = arg10.Text;
                    }, (arg11, arg22) =>
                    {
                        if (s.IsValidDouble(arg11.Text))
                        {
                            stage.P = cv.ConvertToSI(su.pressure, Double.Parse(arg11.Text));
                            if (column.Stages.IndexOf(stage) == 0)
                            {
                                column.CondenserPressure = stage.P;
                            }
                            else if (column.Stages.IndexOf(stage) == column.Stages.Count - 1)
                            {
                                column.ReboilerPressure = stage.P;
                            }
                        }
                    }));
                }
                s.CreateAndAddLabelAndButtonRow(sview, "Interpolate Pressures", "Interpolate", null, (sender2, e2) =>
                {
                    var first = tlist[0].Text.ToDoubleFromCurrent();
                    var last  = tlist[tlist.Count - 1].Text.ToDoubleFromCurrent();
                    var n     = tlist.Count;
                    int i     = 1;
                    for (i = 1; i < n - 1; i++)
                    {
                        tlist[i].Text = (first + (last - first) * i / (n - 1)).ToString(nf);
                    }
                });
                s.CreateAndAddDescriptionRow(sview, "Calculate inner pressures using end stage defined values.");

                var scroll     = new Eto.Forms.Scrollable();
                scroll.Content = sview;

                s.CreateDialog(scroll, "Edit Stages", 600, 600).ShowModal(container);
            });

            var istrs   = column.GraphicObject.InputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Feed")).Select((x2) => x2.AttachedConnector.AttachedFrom.Name).ToList();
            var ostrs   = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Side")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList();
            var dist    = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Distillate")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList();
            var ov      = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Overhead")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList();
            var bottoms = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Bottoms")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList();
            var rduty   = column.GraphicObject.InputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Reboiler")).Select((x2) => x2.AttachedConnector.AttachedFrom.Name).ToList();
            var cduty   = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Condenser")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList();

            foreach (var id in istrs)
            {
                if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0)
                {
                    column.MaterialStreams.Add(id, new StreamInformation()
                    {
                        StreamID       = id,
                        ID             = id,
                        StreamType     = StreamInformation.Type.Material,
                        StreamBehavior = StreamInformation.Behavior.Feed
                    });
                }
            }
            foreach (var id in ostrs)
            {
                if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0)
                {
                    column.MaterialStreams.Add(id, new StreamInformation()
                    {
                        StreamID       = id,
                        ID             = id,
                        StreamType     = StreamInformation.Type.Material,
                        StreamBehavior = StreamInformation.Behavior.Sidedraw
                    });
                }
            }
            foreach (var id in dist)
            {
                if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0)
                {
                    column.MaterialStreams.Add(id, new StreamInformation()
                    {
                        StreamID       = id,
                        ID             = id,
                        StreamType     = StreamInformation.Type.Material,
                        StreamBehavior = StreamInformation.Behavior.Distillate
                    });
                }
            }
            foreach (var id in ov)
            {
                if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0)
                {
                    column.MaterialStreams.Add(id, new StreamInformation()
                    {
                        StreamID       = id,
                        ID             = id,
                        StreamType     = StreamInformation.Type.Material,
                        StreamBehavior = StreamInformation.Behavior.OverheadVapor
                    });
                }
            }
            foreach (var id in bottoms)
            {
                if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0)
                {
                    column.MaterialStreams.Add(id, new StreamInformation()
                    {
                        StreamID       = id,
                        ID             = id,
                        StreamType     = StreamInformation.Type.Material,
                        StreamBehavior = StreamInformation.Behavior.BottomsLiquid
                    });
                }
            }
            List <string> remove = new List <string>();

            foreach (var si in column.MaterialStreams.Values)
            {
                if (!istrs.Contains(si.StreamID) && !ostrs.Contains(si.StreamID) && !ov.Contains(si.StreamID) && !dist.Contains(si.StreamID) && !bottoms.Contains(si.StreamID))
                {
                    remove.Add(si.ID);
                }
                if (!column.GetFlowsheet().SimulationObjects.ContainsKey(si.StreamID))
                {
                    remove.Add(si.ID);
                }
            }
            foreach (var id in remove)
            {
                if (column.MaterialStreams.ContainsKey(id))
                {
                    column.MaterialStreams.Remove(id);
                }
            }

            foreach (var id in cduty)
            {
                if (column.EnergyStreams.Values.Where(x => x.StreamID == id).Count() == 0)
                {
                    column.EnergyStreams.Add(id, new StreamInformation()
                    {
                        StreamID       = id,
                        ID             = id,
                        StreamType     = StreamInformation.Type.Energy,
                        StreamBehavior = StreamInformation.Behavior.Distillate
                    });
                }
            }
            foreach (var id in rduty)
            {
                if (column.EnergyStreams.Values.Where(x => x.StreamID == id).Count() == 0)
                {
                    column.EnergyStreams.Add(id, new StreamInformation()
                    {
                        StreamID       = id,
                        ID             = id,
                        StreamType     = StreamInformation.Type.Energy,
                        StreamBehavior = StreamInformation.Behavior.BottomsLiquid
                    });
                }
            }
            List <string> remove2 = new List <string>();

            foreach (var si in column.EnergyStreams.Values)
            {
                if (!rduty.Contains(si.StreamID) && !cduty.Contains(si.StreamID))
                {
                    remove2.Add(si.ID);
                }
                if (!column.GetFlowsheet().SimulationObjects.ContainsKey(si.StreamID))
                {
                    remove2.Add(si.ID);
                }
            }
            foreach (var id in remove2)
            {
                if (column.EnergyStreams.ContainsKey(id))
                {
                    column.EnergyStreams.Remove(id);
                }
            }

            var stageNames = column.Stages.Select((x) => x.Name).ToList();

            stageNames.Insert(0, "");
            var stageIDs = column.Stages.Select((x) => x.ID).ToList();

            stageIDs.Insert(0, "");

            s.CreateAndAddLabelRow(container, "Streams");

            foreach (var si in column.MaterialStreams.Values)
            {
                if (si.StreamBehavior == StreamInformation.Behavior.Feed)
                {
                    s.CreateAndAddDropDownRow(container, "[FEED] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag,
                                              stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) =>
                    {
                        si.AssociatedStage = stageIDs[arg1.SelectedIndex];
                    });
                }
                else if (si.StreamBehavior == StreamInformation.Behavior.Sidedraw)
                {
                    s.CreateAndAddDropDownRow(container, "[SIDEDRAW] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag,
                                              stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) =>
                    {
                        si.AssociatedStage = stageIDs[arg1.SelectedIndex];
                    });
                }
                else if (si.StreamBehavior == StreamInformation.Behavior.OverheadVapor)
                {
                    s.CreateAndAddDropDownRow(container, "[OVH_VAPOR] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag,
                                              stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) =>
                    {
                        si.AssociatedStage = stageIDs[arg1.SelectedIndex];
                    });
                }
                else if (si.StreamBehavior == StreamInformation.Behavior.Distillate)
                {
                    s.CreateAndAddDropDownRow(container, "[DISTILLATE] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag,
                                              stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) =>
                    {
                        si.AssociatedStage = stageIDs[arg1.SelectedIndex];
                    });
                }
                else if (si.StreamBehavior == StreamInformation.Behavior.BottomsLiquid)
                {
                    s.CreateAndAddDropDownRow(container, "[BOTTOMS] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag,
                                              stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) =>
                    {
                        si.AssociatedStage = stageIDs[arg1.SelectedIndex];
                    });
                }
            }
            foreach (var si in column.EnergyStreams.Values)
            {
                if (si.StreamBehavior == StreamInformation.Behavior.Distillate)
                {
                    s.CreateAndAddDropDownRow(container, "[COND. DUTY] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag,
                                              stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) =>
                    {
                        si.AssociatedStage = stageIDs[arg1.SelectedIndex];
                    });
                }
                else if (si.StreamBehavior == StreamInformation.Behavior.BottomsLiquid)
                {
                    s.CreateAndAddDropDownRow(container, "[REB. DUTY] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag,
                                              stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) =>
                    {
                        si.AssociatedStage = stageIDs[arg1.SelectedIndex];
                    });
                }
            }

            s.CreateAndAddLabelRow(container, "Side Draw Specs");
            var sdphases = new List <string>()
            {
                "L", "V"
            };

            foreach (var si in column.MaterialStreams.Values)
            {
                string sp = "L";
                switch (si.StreamPhase)
                {
                case StreamInformation.Phase.L:
                    sp = "L";
                    break;

                case StreamInformation.Phase.V:
                    sp = "V";
                    break;

                case StreamInformation.Phase.B:
                case StreamInformation.Phase.None:
                    sp = "L";
                    break;
                }
                if (si.StreamBehavior == StreamInformation.Behavior.Sidedraw)
                {
                    s.CreateAndAddDropDownRow(container, column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag + " / Draw Phase",
                                              sdphases, sdphases.IndexOf(sp), (arg1, arg2) =>
                    {
                        switch (arg1.SelectedIndex)
                        {
                        case 0:
                            si.StreamPhase = StreamInformation.Phase.L;
                            break;

                        case 1:
                            si.StreamPhase = StreamInformation.Phase.V;
                            break;
                        }
                    });
                    s.CreateAndAddTextBoxRow(container, nf, column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag + " / Molar Flow (" + su.molarflow + ")",
                                             cv.ConvertFromSI(su.molarflow, si.FlowRate.Value), (arg1, arg2) =>
                    {
                        if (s.IsValidDouble(arg1.Text))
                        {
                            si.FlowRate.Value = cv.ConvertToSI(su.molarflow, Double.Parse(arg1.Text));
                        }
                    });
                }
            }

            var compounds = column.GetFlowsheet().SelectedCompounds.Keys.ToList();

            compounds.Insert(0, "");
            var specs = StringResources.columnspec();
            var units = su.GetUnitSet(Interfaces.Enums.UnitOfMeasure.molarflow);

            units.AddRange(su.GetUnitSet(Interfaces.Enums.UnitOfMeasure.massflow));
            units.AddRange(su.GetUnitSet(Interfaces.Enums.UnitOfMeasure.heatflow));
            units.AddRange(su.GetUnitSet(Interfaces.Enums.UnitOfMeasure.temperature));
            units.AddRange(new[] { "% M/M", "% W/W", "M", "We" });
            units.Insert(0, "");
            int cspec = 0, rspec = 0;

            switch (column.Specs["C"].SType)
            {
            case ColumnSpec.SpecType.Product_Molar_Flow_Rate:
                cspec = 0;
                break;

            case ColumnSpec.SpecType.Product_Mass_Flow_Rate:
                cspec = 1;
                break;

            case ColumnSpec.SpecType.Stream_Ratio:
                cspec = 2;
                break;

            case ColumnSpec.SpecType.Heat_Duty:
                cspec = 3;
                break;

            case ColumnSpec.SpecType.Component_Mass_Flow_Rate:
                cspec = 4;
                break;

            case ColumnSpec.SpecType.Component_Molar_Flow_Rate:
                cspec = 5;
                break;

            case ColumnSpec.SpecType.Component_Recovery:
                cspec = 6;
                break;

            case ColumnSpec.SpecType.Component_Fraction:
                cspec = 7;
                break;

            case ColumnSpec.SpecType.Temperature:
                cspec = 8;
                break;
            }

            switch (column.Specs["R"].SType)
            {
            case ColumnSpec.SpecType.Product_Molar_Flow_Rate:
                rspec = 0;
                break;

            case ColumnSpec.SpecType.Product_Mass_Flow_Rate:
                rspec = 1;
                break;

            case ColumnSpec.SpecType.Stream_Ratio:
                rspec = 2;
                break;

            case ColumnSpec.SpecType.Heat_Duty:
                rspec = 3;
                break;

            case ColumnSpec.SpecType.Component_Mass_Flow_Rate:
                rspec = 4;
                break;

            case ColumnSpec.SpecType.Component_Molar_Flow_Rate:
                rspec = 5;
                break;

            case ColumnSpec.SpecType.Component_Recovery:
                rspec = 6;
                break;

            case ColumnSpec.SpecType.Component_Fraction:
                rspec = 7;
                break;

            case ColumnSpec.SpecType.Temperature:
                rspec = 8;
                break;
            }

            s.CreateAndAddLabelRow(container, "Condenser Specification");
            s.CreateAndAddDropDownRow(container, "Specification", specs.ToList(), cspec, (arg1, arg2) =>
            {
                switch (arg1.SelectedIndex)
                {
                case 0:
                    column.Specs["C"].SType = ColumnSpec.SpecType.Product_Molar_Flow_Rate;
                    break;

                case 1:
                    column.Specs["C"].SType = ColumnSpec.SpecType.Product_Mass_Flow_Rate;
                    break;

                case 2:
                    column.Specs["C"].SType = ColumnSpec.SpecType.Stream_Ratio;
                    break;

                case 3:
                    column.Specs["C"].SType = ColumnSpec.SpecType.Heat_Duty;
                    break;

                case 4:
                    column.Specs["C"].SType = ColumnSpec.SpecType.Component_Mass_Flow_Rate;
                    break;

                case 5:
                    column.Specs["C"].SType = ColumnSpec.SpecType.Component_Molar_Flow_Rate;
                    break;

                case 6:
                    column.Specs["C"].SType = ColumnSpec.SpecType.Component_Recovery;
                    break;

                case 7:
                    column.Specs["C"].SType = ColumnSpec.SpecType.Component_Fraction;
                    break;

                case 8:
                    column.Specs["C"].SType = ColumnSpec.SpecType.Temperature;
                    break;
                }
            });
            var cid = 0;

            if (compounds.Contains(column.Specs["C"].ComponentID))
            {
                cid = compounds.IndexOf(column.Specs["C"].ComponentID);
            }
            s.CreateAndAddDropDownRow(container, "Compound", compounds, cid, (arg3, e) =>
            {
                column.Specs["C"].ComponentID = compounds[arg3.SelectedIndex];
            });
            s.CreateAndAddTextBoxRow(container, nf, "Value", column.Specs["C"].SpecValue, (arg1, arg2) =>
            {
                if (s.IsValidDouble(arg1.Text))
                {
                    column.Specs["C"].SpecValue = Double.Parse(arg1.Text);
                }
            }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                       {
                           ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke();
                       }
                });
            s.CreateAndAddDropDownRow(container, "Units", units, units.IndexOf(column.Specs["C"].SpecUnit),
                                      (arg1, arg2) =>
            {
                column.Specs["C"].SpecUnit = units[arg1.SelectedIndex];
            });

            s.CreateAndAddLabelRow(container, "Reboiler Specification");
            s.CreateAndAddDropDownRow(container, "Specification", specs.ToList(), rspec, (arg1, arg2) =>
            {
                switch (arg1.SelectedIndex)
                {
                case 0:
                    column.Specs["R"].SType = ColumnSpec.SpecType.Product_Molar_Flow_Rate;
                    break;

                case 1:
                    column.Specs["R"].SType = ColumnSpec.SpecType.Product_Mass_Flow_Rate;
                    break;

                case 2:
                    column.Specs["R"].SType = ColumnSpec.SpecType.Stream_Ratio;
                    break;

                case 3:
                    column.Specs["R"].SType = ColumnSpec.SpecType.Heat_Duty;
                    break;

                case 4:
                    column.Specs["R"].SType = ColumnSpec.SpecType.Component_Mass_Flow_Rate;
                    break;

                case 5:
                    column.Specs["R"].SType = ColumnSpec.SpecType.Component_Molar_Flow_Rate;
                    break;

                case 6:
                    column.Specs["R"].SType = ColumnSpec.SpecType.Component_Recovery;
                    break;

                case 7:
                    column.Specs["R"].SType = ColumnSpec.SpecType.Component_Fraction;
                    break;

                case 8:
                    column.Specs["R"].SType = ColumnSpec.SpecType.Temperature;
                    break;
                }
            });
            var cid2 = 0;

            if (compounds.Contains(column.Specs["R"].ComponentID))
            {
                cid2 = compounds.IndexOf(column.Specs["R"].ComponentID);
            }
            s.CreateAndAddDropDownRow(container, "Compound", compounds, cid2, (arg3, e) =>
            {
                column.Specs["R"].ComponentID = compounds[arg3.SelectedIndex];
            });
            s.CreateAndAddTextBoxRow(container, nf, "Value", column.Specs["R"].SpecValue, (arg1, arg2) =>
            {
                if (s.IsValidDouble(arg1.Text))
                {
                    column.Specs["R"].SpecValue = Double.Parse(arg1.Text);
                }
            }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                       {
                           ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke();
                       }
                });
            s.CreateAndAddDropDownRow(container, "Units", units, units.IndexOf(column.Specs["R"].SpecUnit),
                                      (arg1, arg2) =>
            {
                column.Specs["R"].SpecUnit = units[arg1.SelectedIndex];
            });

            s.CreateAndAddLabelRow(container, "Solver Settings");

            var methods = new string[] { "Wang-Henke (Bubble Point)", "Napthali-Sandholm (Simultaneous Correction)" };

            s.CreateAndAddDropDownRow(container, "Solving Method", methods.ToList(), methods.ToList().IndexOf(column.SolvingMethodName), (sender, e) =>
            {
                column.SolvingMethodName = sender.SelectedValue.ToString();
            });

            s.CreateAndAddTextBoxRow(container, "N0", "Maximum Iterations", column.MaxIterations,
                                     (sender, e) =>
            {
                if (sender.Text.IsValidDouble())
                {
                    column.MaxIterations = (int)sender.Text.ToDoubleFromCurrent();
                }
            }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                       {
                           ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke();
                       }
                });

            s.CreateAndAddTextBoxRow(container, nf, "Convergence Tolerance", column.ExternalLoopTolerance,
                                     (sender, e) =>
            {
                if (sender.Text.IsValidDouble())
                {
                    column.ExternalLoopTolerance = sender.Text.ToDoubleFromCurrent();
                    column.InternalLoopTolerance = sender.Text.ToDoubleFromCurrent();
                }
            }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                       {
                           ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke();
                       }
                });

            s.CreateAndAddEmptySpace(container);
            s.CreateAndAddEmptySpace(container);
            s.CreateAndAddEmptySpace(container);
        }
コード例 #8
0
        private void InitializeComponent()
        {
            this.cookbookButton              = new Button();
            this.label1                      = new Label();
            this.versionLabel                = new Label();
            this.label3                      = new Label();
            this.groupBox1                   = new GroupBox();
            this.groupBox2                   = new GroupBox();
            this.label16                     = new Label();
            this.MultiAxisLockButton         = new Button();
            this.richTextBox1                = new Label();
            this.label15                     = new Label();
            this.btnColormapViewer           = new Button();
            this.label14                     = new Label();
            this.AxisLimitsButton            = new Button();
            this.label13                     = new Label();
            this.ScrollViewerButton          = new Button();
            this.label12                     = new Label();
            this.RightClickMenuButton        = new Button();
            this.PlotViewerButton            = new Button();
            this.label11                     = new Label();
            this.label10                     = new Label();
            this.btnShowOnHover              = new Button();
            this.label9                      = new Label();
            this.label8                      = new Label();
            this.GrowingData                 = new Button();
            this.LiveData                    = new Button();
            this.label7                      = new Label();
            this.LinkedAxesButton            = new Button();
            this.label6                      = new Label();
            this.ConfigButton                = new Button();
            this.label5                      = new Label();
            this.ToggleVisibilityButton      = new Button();
            this.MouseTrackerButton          = new Button();
            this.label2                      = new Label();
            this.label4                      = new Label();
            this.TransparentBackgroundButton = new Button();
            this.StyleBrowserButton          = new Button();
            this.label17                     = new Label();
            this.groupBox1.SuspendLayout();
            this.groupBox2.SuspendLayout();
            this.SuspendLayout();

            var layout = new DynamicLayout {
                Rows = { label1, versionLabel, groupBox1, groupBox2 }, Spacing = Size.Empty + 4
            };

            this.Content = new Scrollable {
                Content = layout, Border = BorderType.None
            };

            this.groupBox1.Content = new DynamicLayout()
            {
                Rows = { new DynamicRow(cookbookButton, label3) }, Spacing = Size.Empty + 4
            };

            var layout2 = new DynamicLayout();

            layout2.BeginVertical(padding: 4);
            layout2.AddRow(richTextBox1);
            layout2.EndVertical();
            layout2.BeginVertical(spacing: Size.Empty + 4);
            layout2.AddRow(PlotViewerButton, label11);
            layout2.AddRow(MouseTrackerButton, label4);
            layout2.AddRow(ToggleVisibilityButton, label5);
            layout2.AddRow(ConfigButton, label6);
            layout2.AddRow(LinkedAxesButton, label7);
            layout2.AddRow(LiveData, label8);
            layout2.AddRow(GrowingData, label9);
            layout2.AddRow(btnShowOnHover, label10);
            layout2.AddRow(TransparentBackgroundButton, label2);
            layout2.AddRow(RightClickMenuButton, label12);
            layout2.AddRow(ScrollViewerButton, label13);
            layout2.AddRow(AxisLimitsButton, label14);
            layout2.AddRow(btnColormapViewer, label15);
            layout2.AddRow(MultiAxisLockButton, label16);
            layout2.AddRow(StyleBrowserButton, label17);
            layout2.EndVertical();
            this.groupBox2.Content = layout2;

            Helpers.SetPaddingRecursive(this, 5);

            //
            // cookbookButton
            //
            this.cookbookButton.BackgroundColor = Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(240)))), ((int)(((byte)(161)))));
            this.cookbookButton.Size            = new Size(75, 59);
            this.cookbookButton.Text            = "Launch ScottPlot Cookbook";
            //
            // label1
            //
            this.label1.Font = Fonts.Sans(16);
            this.label1.Size = new Size(160, 25);
            this.label1.Text = "ScottPlot Demo";
            //
            // versionLabel
            //
            this.versionLabel.Text = "version 9.9.99";
            //
            // label3
            //
            this.label3.Size = new Size(208, 59);
            this.label3.Text = "Simple examples that demonstrate the primary features of ScottPlot";
            this.label3.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label3.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // groupBox1
            //
            this.groupBox1.Text = "ScottPlot Cookbook";
            //
            // groupBox2
            //
            this.groupBox2.Text = "Eto.Forms Control Demos";
            //
            // label16
            //
            this.label16.Size = new Size(210, 47);
            this.label16.Text = "Selectively pan/zoom individual axes in multi-axis plots";
            this.label16.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label16.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // MultiAxisLockButton
            //
            this.MultiAxisLockButton.Size = new Size(75, 47);
            this.MultiAxisLockButton.Text = "Multi-Axis Lock";
            //
            // richTextBox1
            //
            this.richTextBox1.BackgroundColor = SystemColors.Control;
            this.richTextBox1.Size            = new Size(291, 111);
            this.richTextBox1.Text            = @"These examples demonstrate advanced functionality for the Eto.Forms ScottPlot control (PlotView).
Source code for these demos can be found on the ScottPlot Demo Website https://scottplot.net/demo/ along with additional information and advanced implementation recommendations.";
            //
            // label15
            //
            this.label15.Size = new Size(210, 47);
            this.label15.Text = "Show available colormaps";
            this.label15.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label15.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // btnColormapViewer
            //
            this.btnColormapViewer.Size = new Size(75, 47);
            this.btnColormapViewer.Text = "Colormap Viewer";
            //
            // label14
            //
            this.label14.Size = new Size(210, 47);
            this.label14.Text = "Demonstrate how axis boundaries can be used to constrain axis limits in interactive plots";
            this.label14.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label14.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // AxisLimitsButton
            //
            this.AxisLimitsButton.Size = new Size(75, 47);
            this.AxisLimitsButton.Text = "Axis Limits";
            //
            // label13
            //
            this.label13.Size = new Size(210, 47);
            this.label13.Text = "Display multiple plots in a scrolling control";
            this.label13.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label13.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // ScrollViewerButton
            //
            this.ScrollViewerButton.Size = new Size(75, 47);
            this.ScrollViewerButton.Text = "Plot in a Scroll Viewer";
            //
            // label12
            //
            this.label12.Size = new Size(210, 47);
            this.label12.Text = "Display a custom menu (or perform a different action) when the control is right-clicked";
            this.label12.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label12.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // RightClickMenuButton
            //
            this.RightClickMenuButton.Size = new Size(75, 47);
            this.RightClickMenuButton.Text = "Custom Right- Click Menu";
            //
            // PlotViewerButton
            //
            this.PlotViewerButton.Size = new Size(75, 47);
            this.PlotViewerButton.Text = "Plot Viewer";
            //
            // label11
            //
            this.label11.Size = new Size(210, 47);
            this.label11.Text = "Create a ScottPlot programmatically then display it in an interactive window";
            this.label11.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label11.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // label10
            //
            this.label10.Size = new Size(210, 47);
            this.label10.Text = "Display the value of the data point nearest the cursor";
            this.label10.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label10.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // btnShowOnHover
            //
            this.btnShowOnHover.Size = new Size(75, 47);
            this.btnShowOnHover.Text = "Show Value on Hover";
            //
            // label9
            //
            this.label9.Size = new Size(210, 47);
            this.label9.Text = "Display live data that grows with time";
            this.label9.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label9.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // label8
            //
            this.label8.Size = new Size(210, 47);
            this.label8.Text = "Display live data from a fixed-length array that continuously changes";
            this.label8.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label8.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // GrowingData
            //
            this.GrowingData.Size = new Size(75, 47);
            this.GrowingData.Text = "Growing Data";
            //
            // LiveData
            //
            this.LiveData.Size = new Size(75, 47);
            this.LiveData.Text = "Live Data";
            //
            // label7
            //
            this.label7.Size = new Size(210, 47);
            this.label7.Text = "Link the axes of two plots together so adjusting one changes the other";
            this.label7.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label7.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // LinkedAxesButton
            //
            this.LinkedAxesButton.Size = new Size(75, 47);
            this.LinkedAxesButton.Text = "Linked Axes";
            //
            // label6
            //
            this.label6.Size = new Size(210, 47);
            this.label6.Text = "Advanced styling and behavior customization";
            this.label6.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label6.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // ConfigButton
            //
            this.ConfigButton.Size = new Size(75, 47);
            this.ConfigButton.Text = "FormsPlot Config";
            //
            // label5
            //
            this.label5.Size = new Size(210, 47);
            this.label5.Text = "Checkboxes control visibility of individual plot objects";
            this.label5.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label5.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // ToggleVisibilityButton
            //
            this.ToggleVisibilityButton.Size = new Size(75, 47);
            this.ToggleVisibilityButton.Text = "Toggle Visibility";
            //
            // MouseTrackerButton
            //
            this.MouseTrackerButton.Size = new Size(75, 47);
            this.MouseTrackerButton.Text = "Mouse Tracker";
            //
            // label2
            //
            this.label2.Size = new Size(210, 47);
            this.label2.Text = "Demonstrate a control with a transparent background";
            this.label2.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label2.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // label4
            //
            this.label4.Size = new Size(210, 47);
            this.label4.Text = "Display the position under the mouse cursor";
            this.label4.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label4.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // TransparentBackgroundButton
            //
            this.TransparentBackgroundButton.Size = new Size(75, 47);
            this.TransparentBackgroundButton.Text = "Transparent Background";
            //
            // StyleBrowserButton
            //
            this.StyleBrowserButton.Size = new Size(75, 47);
            this.StyleBrowserButton.Text = "Style Browser";
            //
            // label17
            //
            this.label17.Size = new Size(210, 47);
            this.label17.Text = "View available predefined styles";
            this.label17.VerticalAlignment = global::Eto.Forms.VerticalAlignment.Center;
            this.label17.TextAlignment     = global::Eto.Forms.TextAlignment.Left;
            //
            // FormMain
            //
            this.Shown += (o, e) =>
            {
                this.Location = (Point)Screen.PrimaryScreen.WorkingArea.Center - this.Size / 2;
            };
            this.Width  = 400;
            this.Height = (int)Screen.PrimaryScreen.WorkingArea.Height * 3 / 4;
            this.Title  = "ScottPlot Demo (Eto.Forms)";
            this.groupBox1.ResumeLayout();
            this.groupBox2.ResumeLayout();
            this.ResumeLayout();
        }
コード例 #9
0
        private void InitializeComponent()
        {
            Title       = "New File";
            DisplayMode = DialogDisplayMode.Attached;
            Size        = new Size(370, 285);
            MinimumSize = new Size(370, 200);
            Resizable   = true;

            buttonCreate      = new Button();
            buttonCreate.Text = "Create";
            PositiveButtons.Add(buttonCreate);
            DefaultButton = buttonCreate;

            buttonCancel      = new Button();
            buttonCancel.Text = "Cancel";
            NegativeButtons.Add(buttonCancel);
            AbortButton = buttonCancel;

            layout1         = new DynamicLayout();
            layout1.Padding = new Padding(6);

            table1         = new TableLayout(2, 3);
            table1.Spacing = new Size(4, 4);

            labelName      = new Label();
            labelName.Text = "Name: ";
            labelName.VerticalAlignment = VerticalAlignment.Center;
            table1.Add(labelName, 0, 0, false, false);

            layout2 = new DynamicLayout();
            layout2.DefaultSpacing = new Size(4, 4);
            layout2.BeginHorizontal();

            textBox1 = new TextBox();
            layout2.Add(textBox1, true, true);

            labelExt      = new Label();
            labelExt.Text = " .spriteFont";
            labelExt.VerticalAlignment = VerticalAlignment.Center;
            labelExt.Width             = 80;
            layout2.Add(labelExt, false, true);

            table1.Add(layout2, 1, 0, true, false);

            labelType      = new Label();
            labelType.Text = "Type: ";
            labelType.VerticalAlignment = VerticalAlignment.Top;
            table1.Add(labelType, 0, 1, false, true);

            list1 = new ListBox();
            table1.Add(list1, 1, 1, true, true);

            layout1.Add(table1, true, true);

            labelError = new Label();
            labelError.TextAlignment = TextAlignment.Center;
            table1.Add(labelError, 1, 2, true, false);

            layout1.Add(labelError, true, false);

            Content = layout1;

            textBox1.TextChanged       += TextBox1_TextChanged;
            list1.SelectedIndexChanged += List1_SelectedIndexChanged;
            buttonCreate.Click         += ButtonCreate_Click;
            buttonCancel.Click         += ButtonCancel_Click;
        }
コード例 #10
0
        private DynamicLayout Init(out GridView gd)
        {
            var layout = new DynamicLayout();

            layout.DefaultPadding = new Padding(5);
            layout.DefaultSpacing = new Size(5, 5);


            var addNew = new Button {
                Text = "Add"
            };

            addNew.Command = _vm.AddCommand;

            var duplicate = new Button {
                Text = "Duplicate"
            };

            duplicate.Command = _vm.DuplicateCommand;

            var edit = new Button {
                Text = "Edit"
            };

            edit.Command = _vm.EditCommand;

            var remove = new Button {
                Text = "Remove"
            };

            remove.Command = _vm.RemoveCommand;

            layout.AddSeparateRow("Modifiers:", null, addNew, duplicate, edit, remove);

            // search bar
            var filter = new TextBox()
            {
                PlaceholderText = "Filter"
            };

            filter.TextBinding.Bind(_vm, _ => _.FilterKey);
            layout.AddSeparateRow(filter);

            gd = GenGridView();
            layout.AddSeparateRow(controls: new[] { gd }, xscale: true, yscale: true);

            // counts
            var counts = new Label();

            counts.TextBinding.Bind(_vm, _ => _.Counts);

            layout.AddSeparateRow(counts, null);

            var OKButton = new Button {
                Text = "OK"
            };

            OKButton.Click += (sender, e) => OkCommand.Execute(null);


            AbortButton = new Button {
                Text = "Cancel"
            };
            AbortButton.Click += (sender, e) => Close();
            layout.AddSeparateRow(null, OKButton, AbortButton, null);

            gd.CellDoubleClick += (s, e) => _vm.EditCommand.Execute(null);

            return(layout);
        }
コード例 #11
0
ファイル: FormBuilder.cs プロジェクト: fanzcsoft/bacstack
 public FormBuilder()
 {
     _layout = new DynamicLayout();
     _layout.DefaultPadding = new Eto.Drawing.Padding(5);
 }
コード例 #12
0
        void Initialize()
        {
            var su  = MatStream.GetFlowsheet().FlowsheetOptions.SelectedUnitSystem;
            var nf  = MatStream.GetFlowsheet().FlowsheetOptions.NumberFormat;
            var nff = MatStream.GetFlowsheet().FlowsheetOptions.FractionNumberFormat;

            var container2 = new DynamicLayout();

            s.CreateAndAddLabelRow(container, "Material Stream Property Editor");

            s.CreateAndAddDescriptionRow(container, "Except for compound amounts, property values are updated/stored as they are changed/edited.");

            if ((Host.Items.Where(x => x.Name.Contains(MatStream.GraphicObject.Tag)).Count() > 0))
            {
                var ctn = new DynamicLayout();
                ctn.BackgroundColor = Colors.LightGrey;
                s.CreateAndAddLabelRow(ctn, "Inspector Reports");
                s.CreateAndAddLabelAndButtonRow(ctn, "An Inspector Report is ready for viewing.", "View Report", null, (btn, e) =>
                {
                    var f = s.GetDefaultEditorForm("Inspector Report for '" + MatStream.GraphicObject.Tag + "'", 1024, 768, Window2_Eto.GetInspectorWindow(MatStream), false);
                    f.Show();
                });
                container.Add(ctn);
            }

            s.CreateAndAddLabelRow(container, "Material Stream Details");

            s.CreateAndAddTwoLabelsRow(container, "Status", MatStream.GraphicObject.Active ? "Active" : "Inactive");

            s.CreateAndAddStringEditorRow(container, "Name", MatStream.GraphicObject.Tag, (TextBox arg3, EventArgs ev) =>
            {
                MatStream.GraphicObject.Tag = arg3.Text;
                MatStream.GetFlowsheet().UpdateInterface();
            }, () => {
                MatStream.GetFlowsheet().UpdateOpenEditForms();
            });

            s.CreateAndAddDropDownRow(container, "Compound Amount Basis",
                                      new List <string>()
            {
                "Molar Fractions", "Mass Fractions", "Volumetric Fractions", "Molar Flows", "Mass Flows", "Volumetric Flows", "Default"
            },
                                      (int)MatStream.FloatingTableAmountBasis, (sender, e) =>
            {
                MatStream.FloatingTableAmountBasis = (DWSIM.Interfaces.Enums.CompositionBasis)sender.SelectedIndex;
            });
            s.CreateAndAddDescriptionRow(container, "Select the basis to display compound amounts in floating tables, if enabled.");

            s.CreateAndAddLabelRow(container, "Property Package");

            var proppacks = MatStream.GetFlowsheet().PropertyPackages.Values.Select((x) => x.Tag).ToList();

            if (proppacks.Count == 0)
            {
                MatStream.GetFlowsheet().ShowMessage("Error: please add at least one Property Package before continuing.", IFlowsheet.MessageType.GeneralError);
            }
            else
            {
                var selectedpp = MatStream.PropertyPackage.Tag;
                s.CreateAndAddDropDownRow(container, "Property Package", proppacks, proppacks.IndexOf(selectedpp), (DropDown arg1, EventArgs ev) =>
                {
                    if (proppacks.Count > 0)
                    {
                        MatStream.PropertyPackage = (PropertyPackage)MatStream.GetFlowsheet().PropertyPackages.Values.Where((x) => x.Tag == proppacks[arg1.SelectedIndex]).FirstOrDefault();
                    }
                }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                           {
                               ((Shared.Flowsheet)MatStream.GetFlowsheet()).HighLevelSolve.Invoke();
                           }
                    });
            }

            var flashalgos = MatStream.GetFlowsheet().FlowsheetOptions.FlashAlgorithms.Select(x => x.Tag).ToList();

            flashalgos.Insert(0, "Default");

            var cbFlashAlg = s.CreateAndAddDropDownRow(container, "Flash Algorithm", flashalgos, 0, null);

            if (!string.IsNullOrEmpty(MatStream.PreferredFlashAlgorithmTag))
            {
                cbFlashAlg.SelectedIndex = Array.IndexOf(flashalgos.ToArray(), MatStream.PreferredFlashAlgorithmTag);
            }
            else
            {
                cbFlashAlg.SelectedIndex = 0;
            }

            cbFlashAlg.SelectedIndexChanged += (sender, e) =>
            {
                MatStream.PreferredFlashAlgorithmTag = cbFlashAlg.SelectedValue.ToString();
                if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                {
                    ((Shared.Flowsheet)MatStream.GetFlowsheet()).HighLevelSolve.Invoke();
                }
            };

            container.Add(container2);

            s.CreateAndAddLabelRow(container2, "State Specification");

            switch (MatStream.GraphicObject.ObjectType)
            {
            case ObjectType.MaterialStream:
                var    ms       = MatStream;
                int    position = 0;
                Double val;
                switch (ms.SpecType)
                {
                case StreamSpec.Temperature_and_Pressure:
                    position = 0;
                    break;

                case StreamSpec.Temperature_and_VaporFraction:
                    position = 1;
                    break;

                case StreamSpec.Pressure_and_VaporFraction:
                    position = 2;
                    break;

                case StreamSpec.Pressure_and_Enthalpy:
                    position = 3;
                    break;

                case StreamSpec.Pressure_and_Entropy:
                    position = 4;
                    break;
                }

                s.CreateAndAddDropDownRow(container2, "Specified Variables", StringResources.flash_spec().ToList(), position, (DropDown arg3, EventArgs ev) =>
                {
                    switch (arg3.SelectedIndex)
                    {
                    case 0:
                        ms.SpecType = StreamSpec.Temperature_and_Pressure;
                        break;

                    case 1:
                        ms.SpecType = StreamSpec.Temperature_and_VaporFraction;
                        break;

                    case 2:
                        ms.SpecType = StreamSpec.Pressure_and_VaporFraction;
                        break;

                    case 3:
                        ms.SpecType = StreamSpec.Pressure_and_Enthalpy;
                        break;

                    case 4:
                        ms.SpecType = StreamSpec.Pressure_and_Entropy;
                        break;
                    }
                });
                s.CreateAndAddDescriptionRow(container2, ms.GetPropertyDescription("Flash Specification"));
                s.CreateAndAddTextBoxRow(container2, nf, "Temperature (" + su.temperature + ")", cv.ConvertFromSI(su.temperature, ms.Phases[0].Properties.temperature.GetValueOrDefault()),
                                         (TextBox arg3, EventArgs ev) =>
                {
                    if (arg3.Text.IsValidDoubleExpression())
                    {
                        arg3.TextColor = (SystemColors.ControlText);
                        ms.Phases[0].Properties.temperature = cv.ConvertToSI(su.temperature, arg3.Text.ToString().ParseExpressionToDouble());
                    }
                    else
                    {
                        arg3.TextColor = (Colors.Red);
                    }
                }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                           {
                               ((Shared.Flowsheet)MatStream.GetFlowsheet()).HighLevelSolve.Invoke();
                           }
                    });
                s.CreateAndAddDescriptionRow(container2, ms.GetPropertyDescription("Temperature"));
                var txtP = s.CreateAndAddTextBoxRow(container2, nf, "Pressure (" + su.pressure + ")", cv.ConvertFromSI(su.pressure, ms.Phases[0].Properties.pressure.GetValueOrDefault()),
                                                    (TextBox arg3, EventArgs ev) =>
                {
                    if (arg3.Text.IsValidDoubleExpression())
                    {
                        arg3.TextColor = (SystemColors.ControlText);
                        ms.Phases[0].Properties.pressure = cv.ConvertToSI(su.pressure, arg3.Text.ToString().ParseExpressionToDouble());
                    }
                    else
                    {
                        arg3.TextColor = (Colors.Red);
                    }
                }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                           {
                               ((Shared.Flowsheet)MatStream.GetFlowsheet()).HighLevelSolve.Invoke();
                           }
                    });
                s.CreateAndAddDescriptionRow(container2, ms.GetPropertyDescription("Pressure"));
                s.CreateAndAddTextBoxRow(container2, nf, "Specific Enthalpy (" + su.enthalpy + ")", cv.ConvertFromSI(su.enthalpy, ms.Phases[0].Properties.enthalpy.GetValueOrDefault()),
                                         (TextBox arg3, EventArgs ev) =>
                {
                    if (arg3.Text.IsValidDoubleExpression())
                    {
                        arg3.TextColor = (SystemColors.ControlText);
                        ms.Phases[0].Properties.enthalpy = cv.ConvertToSI(su.enthalpy, arg3.Text.ToString().ParseExpressionToDouble());
                    }
                    else
                    {
                        arg3.TextColor = (Colors.Red);
                    }
                }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                           {
                               ((Shared.Flowsheet)MatStream.GetFlowsheet()).HighLevelSolve.Invoke();
                           }
                    });
                s.CreateAndAddDescriptionRow(container2, ms.GetPropertyDescription("Specific Enthalpy"));
                s.CreateAndAddTextBoxRow(container2, nf, "Specific Entropy (" + su.entropy + ")", cv.ConvertFromSI(su.entropy, ms.Phases[0].Properties.entropy.GetValueOrDefault()),
                                         (TextBox arg3, EventArgs ev) =>
                {
                    if (arg3.Text.IsValidDoubleExpression())
                    {
                        arg3.TextColor = (SystemColors.ControlText);
                        ms.Phases[0].Properties.entropy = cv.ConvertToSI(su.entropy, arg3.Text.ToString().ParseExpressionToDouble());
                    }
                    else
                    {
                        arg3.TextColor = (Colors.Red);
                    }
                }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                           {
                               ((Shared.Flowsheet)MatStream.GetFlowsheet()).HighLevelSolve.Invoke();
                           }
                    });
                s.CreateAndAddDescriptionRow(container2, ms.GetPropertyDescription("Specific Entropy"));

                s.CreateAndAddTextBoxRow(container2, nf, "Vapor Phase Mole Fraction (spec)", ms.Phases[2].Properties.molarfraction.GetValueOrDefault(),
                                         (TextBox arg3, EventArgs ev) =>
                {
                    if (arg3.Text.IsValidDoubleExpression())
                    {
                        arg3.TextColor = (SystemColors.ControlText);
                        ms.Phases[2].Properties.molarfraction = arg3.Text.ToString().ParseExpressionToDouble();
                    }
                    else
                    {
                        arg3.TextColor = (Colors.Red);
                    }
                }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                           {
                               ((Shared.Flowsheet)MatStream.GetFlowsheet()).HighLevelSolve.Invoke();
                           }
                    });

                s.CreateAndAddDescriptionRow(container2, ms.GetPropertyDescription("Vapor Phase Mole Fraction (spec)"));

                s.CreateAndAddLabelRow(container2, "Flow Specification");

                var txtW = s.CreateAndAddTextBoxRow(container2, nf, "Mass Flow (" + su.massflow + ")", cv.ConvertFromSI(su.massflow, ms.Phases[0].Properties.massflow.GetValueOrDefault()),
                                                    (TextBox arg3, EventArgs ev) =>
                {
                    if (arg3.Text.IsValidDoubleExpression())
                    {
                        arg3.TextColor = (SystemColors.ControlText);
                        ms.Phases[0].Properties.volumetric_flow = null;
                        ms.Phases[0].Properties.molarflow       = null;
                        ms.Phases[0].Properties.massflow        = cv.ConvertToSI(su.massflow, arg3.Text.ToString().ParseExpressionToDouble());
                    }
                    else
                    {
                        arg3.TextColor = (Colors.Red);
                    }
                }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                           {
                               ((Shared.Flowsheet)MatStream.GetFlowsheet()).HighLevelSolve.Invoke();
                           }
                    });
                s.CreateAndAddDescriptionRow(container2, ms.GetPropertyDescription("Mass Flow"));
                var txtQ = s.CreateAndAddTextBoxRow(container2, nf, "Molar Flow (" + su.molarflow + ")", cv.ConvertFromSI(su.molarflow, ms.Phases[0].Properties.molarflow.GetValueOrDefault()),
                                                    (TextBox arg3, EventArgs ev) =>
                {
                    if (arg3.Text.IsValidDoubleExpression())
                    {
                        arg3.TextColor = (SystemColors.ControlText);
                        ms.Phases[0].Properties.massflow        = null;
                        ms.Phases[0].Properties.volumetric_flow = null;
                        ms.Phases[0].Properties.molarflow       = cv.ConvertToSI(su.molarflow, arg3.Text.ToString().ParseExpressionToDouble());
                    }
                    else
                    {
                        arg3.TextColor = (Colors.Red);
                    }
                }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                           {
                               ((Shared.Flowsheet)MatStream.GetFlowsheet()).HighLevelSolve.Invoke();
                           }
                    });
                s.CreateAndAddDescriptionRow(container2, ms.GetPropertyDescription("Molar Flow"));
                var txtV = s.CreateAndAddTextBoxRow(container2, nf, "Volumetric Flow (" + su.volumetricFlow + ")", cv.ConvertFromSI(su.volumetricFlow, ms.Phases[0].Properties.volumetric_flow.GetValueOrDefault()),
                                                    (TextBox arg3, EventArgs ev) =>
                {
                    if (arg3.Text.IsValidDoubleExpression())
                    {
                        arg3.TextColor = (SystemColors.ControlText);
                        ms.Phases[0].Properties.massflow        = null;
                        ms.Phases[0].Properties.molarflow       = null;
                        ms.Phases[0].Properties.volumetric_flow = cv.ConvertToSI(su.volumetricFlow, arg3.Text.ToString().ParseExpressionToDouble());
                    }
                    else
                    {
                        arg3.TextColor = (Colors.Red);
                    }
                }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                           {
                               ((Shared.Flowsheet)MatStream.GetFlowsheet()).HighLevelSolve.Invoke();
                           }
                    });
                s.CreateAndAddDescriptionRow(container2, ms.GetPropertyDescription("Volumetric Flow"));

                s.CreateAndAddLabelRow(container2, "Mixture Composition");

                s.CreateAndAddDescriptionRow(container2, "Composition changes will only be committed after clicking on the 'Accept' button.");

                DropDown spinner1 = s.CreateAndAddDropDownRow(container2, "Amount Basis", StringResources.mscompinputtype().ToList(), 0, null);

                var tblist = new List <TextBox>();

                foreach (var comp0 in ms.GetFlowsheet().SelectedCompounds.Values)
                {
                    var comp = ms.Phases[0].Compounds[comp0.Name];
                    var tbox = s.CreateAndAddTextBoxRow(container2, nf, comp.Name, comp.MoleFraction.GetValueOrDefault(),
                                                        (TextBox arg3, EventArgs ev) => { });
                    tbox.Tag = comp.Name;
                    tblist.Add(tbox);
                }

                spinner1.SelectedIndexChanged += (sender, e) =>
                {
                    var W = ms.Phases[0].Properties.massflow.GetValueOrDefault();
                    var Q = ms.Phases[0].Properties.molarflow.GetValueOrDefault();
                    switch (spinner1.SelectedIndex)
                    {
                    case 0:
                        foreach (var etext in tblist)
                        {
                            etext.Text = ms.Phases[0].Compounds[(String)etext.Tag].MoleFraction.GetValueOrDefault().ToString(nff);
                        }
                        break;

                    case 1:
                        foreach (var etext in tblist)
                        {
                            etext.Text = ms.Phases[0].Compounds[(String)etext.Tag].MassFraction.GetValueOrDefault().ToString(nff);
                        }
                        break;

                    case 2:
                        foreach (var etext in tblist)
                        {
                            etext.Text = (ms.Phases[0].Compounds[(String)etext.Tag].MoleFraction.GetValueOrDefault() * Q).ConvertFromSI(su.molarflow).ToString(nff);
                        }
                        break;

                    case 3:
                        foreach (var etext in tblist)
                        {
                            etext.Text = (ms.Phases[0].Compounds[(String)etext.Tag].MassFraction.GetValueOrDefault() * W).ConvertFromSI(su.massflow).ToString(nff);
                        }
                        break;
                    }
                };

                Double total = 0.0f;

                var btnNormalize = new Button {
                    Text = "Normalize"
                };
                btnNormalize.Font = new Font(SystemFont.Default, s.GetEditorFontSize());

                btnNormalize.Click += (sender, e) =>
                {
                    total = 0.0f;
                    foreach (var etext in tblist)
                    {
                        if (Double.TryParse(etext.Text.ToString(), out val))
                        {
                            etext.TextColor = (SystemColors.ControlText);
                            total          += Double.Parse(etext.Text.ToString());
                        }
                        else
                        {
                            etext.TextColor = (Colors.Red);
                            //Toast.MakeText(this.Context, "Error parsing '" + etext.Text + "' for " + (String)etext.Tag + ", not a valid number. Please input a valid number and try again.", ToastLength.Short).Show();
                        }
                    }
                    foreach (var etext in tblist)
                    {
                        if (Double.TryParse(etext.Text.ToString(), out val))
                        {
                            etext.Text = (Double.Parse(etext.Text.ToString()) / total).ToString(nff);
                        }
                    }
                };

                var btnEqualize = new Button {
                    Text = "Equalize"
                };
                btnEqualize.Font = new Font(SystemFont.Default, s.GetEditorFontSize());

                btnEqualize.Click += (sender, e) =>
                {
                    foreach (var etext in tblist)
                    {
                        etext.Text = (1.0 / tblist.Count).ToString(nff);
                    }
                };

                var btnClear = new Button {
                    Text = "Clear"
                };
                btnClear.Font = new Font(SystemFont.Default, s.GetEditorFontSize());

                btnClear.Click += (sender, e) =>
                {
                    foreach (var etext in tblist)
                    {
                        etext.Text = 0.0f.ToString(nff);
                    }
                };

                var btnAccept = new Button {
                    Text = "Accept/Update"
                };
                btnAccept.Font = new Font(SystemFont.Default, s.GetEditorFontSize());

                btnAccept.Click += (sender, e) =>
                {
                    Double W, Q, mtotal = 0.0f, mmtotal = 0.0f;

                    total = 0.0f;

                    switch (spinner1.SelectedIndex)
                    {
                    case 0:

                        btnNormalize.PerformClick();
                        foreach (var etext in tblist)
                        {
                            if (Double.TryParse(etext.Text.ToString(), out val))
                            {
                                MatStream.Phases[0].Compounds[(String)etext.Tag].MoleFraction = Double.Parse(etext.Text.ToString());
                            }
                            else
                            {
                                //Toast.MakeText(this.Context, "Error parsing '" + etext.Text + "' for " + (String)etext.Tag + ", not a valid number. Please input a valid number and try again.", ToastLength.Short).Show();
                            }
                        }

                        foreach (var comp in MatStream.Phases[0].Compounds.Values)
                        {
                            mtotal += comp.MoleFraction.GetValueOrDefault() * comp.ConstantProperties.Molar_Weight;
                        }

                        foreach (var comp in MatStream.Phases[0].Compounds.Values)
                        {
                            comp.MassFraction = comp.MoleFraction.GetValueOrDefault() * comp.ConstantProperties.Molar_Weight / mtotal;
                        }

                        break;

                    case 1:

                        btnNormalize.PerformClick();
                        foreach (var etext in tblist)
                        {
                            if (Double.TryParse(etext.Text.ToString(), out val))
                            {
                                MatStream.Phases[0].Compounds[(String)etext.Tag].MassFraction = Double.Parse(etext.Text.ToString());
                            }
                            else
                            {
                                //Toast.MakeText(this.Context, "Error parsing '" + etext.Text + "' for " + (String)etext.Tag + ", not a valid number. Please input a valid number and try again.", ToastLength.Short).Show();
                            }
                        }

                        foreach (var comp in MatStream.Phases[0].Compounds.Values)
                        {
                            mmtotal += comp.MassFraction.GetValueOrDefault() / comp.ConstantProperties.Molar_Weight;
                        }

                        foreach (var comp in MatStream.Phases[0].Compounds.Values)
                        {
                            comp.MoleFraction = comp.MassFraction.GetValueOrDefault() / comp.ConstantProperties.Molar_Weight / mmtotal;
                        }

                        break;

                    case 2:

                        total = 0;
                        foreach (var etext in tblist)
                        {
                            if (Double.TryParse(etext.Text.ToString(), out val))
                            {
                                total += Double.Parse(etext.Text.ToString());
                            }
                            else
                            {
                                //Toast.MakeText(this.Context, "Error parsing '" + etext.Text + "' for " + (String)etext.Tag + ", not a valid number. Please input a valid number and try again.", ToastLength.Short).Show();
                            }
                        }

                        Q = cv.ConvertToSI(su.molarflow, total);
                        foreach (var etext in tblist)
                        {
                            MatStream.Phases[0].Compounds[(String)etext.Tag].MoleFraction = Double.Parse(etext.Text.ToString()) / total;
                        }

                        foreach (var comp in MatStream.Phases[0].Compounds.Values)
                        {
                            mtotal += comp.MoleFraction.GetValueOrDefault() * comp.ConstantProperties.Molar_Weight;
                        }

                        W = 0;
                        foreach (var comp in MatStream.Phases[0].Compounds.Values)
                        {
                            comp.MassFraction = comp.MoleFraction.GetValueOrDefault() * comp.ConstantProperties.Molar_Weight / mtotal;
                            W += comp.MoleFraction.GetValueOrDefault() * comp.ConstantProperties.Molar_Weight / 1000 * Q;
                        }

                        MatStream.Phases[0].Properties.molarflow = Q;
                        MatStream.Phases[0].Properties.massflow  = W;

                        txtQ.Text = cv.ConvertFromSI(su.molarflow, Q).ToString(nf);

                        break;

                    case 3:

                        total = 0;
                        foreach (var etext in tblist)
                        {
                            if (Double.TryParse(etext.Text.ToString(), out val))
                            {
                                total += Double.Parse(etext.Text.ToString());
                            }
                            else
                            {
                                //Toast.MakeText(this.Context, "Error parsing '" + etext.Text + "' for " + (String)etext.Tag + ", not a valid number. Please input a valid number and try again.", ToastLength.Short).Show();
                            }
                        }

                        W = cv.ConvertToSI(su.massflow, total);
                        foreach (var etext in tblist)
                        {
                            MatStream.Phases[0].Compounds[(String)etext.Tag].MassFraction = Double.Parse(etext.Text.ToString()) / total;
                        }

                        foreach (var comp in MatStream.Phases[0].Compounds.Values)
                        {
                            mmtotal += comp.MassFraction.GetValueOrDefault() / comp.ConstantProperties.Molar_Weight;
                        }

                        Q = 0;
                        foreach (var comp in MatStream.Phases[0].Compounds.Values)
                        {
                            comp.MoleFraction = comp.MassFraction.GetValueOrDefault() / comp.ConstantProperties.Molar_Weight / mmtotal;
                            Q += comp.MassFraction.GetValueOrDefault() * W / comp.ConstantProperties.Molar_Weight * 1000;
                        }

                        MatStream.Phases[0].Properties.molarflow = Q;
                        MatStream.Phases[0].Properties.massflow  = W;

                        txtW.Text = cv.ConvertFromSI(su.massflow, W).ToString(nf);

                        break;
                    }

                    if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                    {
                        ((Shared.Flowsheet)MatStream.GetFlowsheet()).HighLevelSolve.Invoke();
                    }
                };

                s.CreateAndAddLabelAndTwoButtonsRow(container2, "Copy/Paste", "Copy Data", null, "Paste Data", null,
                                                    (btn1, e1) =>
                {
                    string data = "";
                    foreach (var tb in tblist)
                    {
                        data += tb.Tag.ToString() + "\t" + tb.Text + "\n";
                    }
                    Clipboard.Instance.Text = data;
                },
                                                    (btn2, e2) =>
                {
                    if (Clipboard.Instance.ContainsText)
                    {
                        var textdata = Clipboard.Instance.Text;
                        var data     = textdata.Split(new[] { '\n', '\t', ' ' });
                        int i        = 0;
                        foreach (var line in data)
                        {
                            if (line != " " && line != "\t" && line != "\n" && i < tblist.Count)
                            {
                                tblist[i].Text = line.Trim();
                                i += 1;
                            }
                        }
                    }
                });

                s.CreateAndAddControlRow(container2, btnAccept);
                s.CreateAndAddControlRow(container2, btnNormalize);
                s.CreateAndAddControlRow(container2, btnEqualize);
                s.CreateAndAddControlRow(container2, btnClear);

                s.CreateAndAddEmptySpace(container2);
                s.CreateAndAddEmptySpace(container2);
                s.CreateAndAddEmptySpace(container2);
                s.CreateAndAddEmptySpace(container2);

                if (ms.GraphicObject.InputConnectors[0].IsAttached &&
                    ms.GraphicObject.InputConnectors[0].AttachedConnector.AttachedFrom.ObjectType != ObjectType.OT_Recycle)
                {
                    if (!ms.GetFlowsheet().DynamicMode)
                    {
                        container2.Enabled = false;
                    }
                }
                break;
            }
        }
コード例 #13
0
ファイル: CacheDialog.cs プロジェクト: tflynt91/evtc
        public CacheDialog(ManagerForm managerForm)
        {
            Title      = "Log cache - arcdps Log Manager";
            ClientSize = new Size(500, -1);
            var formLayout = new DynamicLayout();

            var item = new Button {
                Text = "Close"
            };

            item.Click += (sender, args) => Close();
            PositiveButtons.Add(item);

            var deleteButton = new Button
            {
                Text = "Delete the cache",
            };

            var pruneButton = new Button
            {
                Text = "Prune missing logs",
            };

            var countLabel = new Label {
                Text = "Not loaded"
            };
            var unloadedCountLabel = new Label {
                Text = "Not loaded"
            };
            var sizeLabel = new Label {
                Text = "No file"
            };

            formLayout.BeginVertical(new Padding(10), new Size(0, 0));
            {
                formLayout.AddRow(new Label
                {
                    Text = "The processed contents of logs are saved in a cache file to save time. " +
                           "You can delete the cached results here to process the logs again or prune " +
                           "results for logs that are not in the scanned directory anymore.",
                    Wrap = WrapMode.Word
                });
            }
            formLayout.EndVertical();
            formLayout.BeginVertical(new Padding(10), new Size(5, 5));
            {
                UpdateLabelTexts(managerForm, countLabel, unloadedCountLabel, sizeLabel);
                formLayout.AddRow(new Label {
                    Text = "Total cached logs:"
                }, countLabel);
                formLayout.AddRow(new Label {
                    Text = "Unloaded cached logs:"
                }, unloadedCountLabel);
                formLayout.AddRow(new Label {
                    Text = "Cache file size:"
                }, sizeLabel);
            }
            formLayout.EndVertical();
            formLayout.BeginVertical(new Padding(10), new Size(5, 5));
            {
                formLayout.AddRow(pruneButton);
                formLayout.AddRow(deleteButton);
            }
            formLayout.EndVertical();

            pruneButton.Click += (sender, args) =>
            {
                int unloadedLogs = managerForm.LogCache?.GetUnloadedLogCount(managerForm.LoadedLogs) ?? 0;
                if (MessageBox.Show(
                        $"Prune the cache? {unloadedLogs} results of currently unloaded logs will be forgotten. " +
                        "If the logs are added back in the future, they will have to be processed again.",
                        MessageBoxButtons.OKCancel) == DialogResult.Ok)
                {
                    int pruned = managerForm.LogCache?.Prune(managerForm.LoadedLogs) ?? 0;
                    MessageBox.Show($"Cache pruned, {pruned} results forgotten.");
                    managerForm.LogCache?.SaveToFile();
                    UpdateLabelTexts(managerForm, countLabel, unloadedCountLabel, sizeLabel);
                    managerForm.ReloadLogs();
                }
            };

            deleteButton.Click += (sender, args) =>
            {
                int logCount = managerForm.LogCache?.LogCount ?? 0;
                if (MessageBox.Show(
                        $"Delete the cache? The results of all {logCount} cached logs will be forgotten. " +
                        "All logs will have to be processed again.",
                        MessageBoxButtons.OKCancel) == DialogResult.Ok)
                {
                    managerForm.LogCache?.Clear();
                    managerForm.LogCache?.SaveToFile();
                    MessageBox.Show($"Cache deleted, {logCount} results forgotten.");
                    UpdateLabelTexts(managerForm, countLabel, unloadedCountLabel, sizeLabel);
                    managerForm.ReloadLogs();
                }
            };

            UpdateLabelTexts(managerForm, countLabel, unloadedCountLabel, sizeLabel);

            Content = formLayout;
        }
コード例 #14
0
        private GroupBox GenUserDataPanel()
        {
            var vm = this._vm;

            var layout = new DynamicLayout();

            layout.Bind((t) => t.Enabled, vm, v => v.UserData.IsPanelEnabled);

            layout.DefaultSpacing = new Size(4, 4);
            layout.DefaultPadding = new Padding(4);

            var add = new Button()
            {
                Text = "Add"
            };
            var edit = new Button()
            {
                Text = "Edit"
            };
            var remove = new Button()
            {
                Text = "Remove"
            };

            layout.AddSeparateRow(null, add, edit, remove);

            var gd = new GridView();

            gd.Width  = 350;
            gd.Height = 360;
            gd.Bind(_ => _.DataStore, _vm, _ => _.UserData.GridViewDataCollection);
            gd.SelectedItemsChanged += (s, e) =>
            {
                _vm.UserData.SelectedItem = gd.SelectedItem as UserDataItem;
            };

            gd.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Delegate <UserDataItem, string>(r => r.Key)
                },
                HeaderText = "Key",
                Width      = 100
            });
            gd.Columns.Add(new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Delegate <UserDataItem, string>(r => r.Value)
                },
                HeaderText = "Value",
                Width      = 250
            });

            layout.AddRow(gd);
            layout.AddRow(null);

            add.Bind(_ => _.Command, vm, _ => _.UserData.AddDataCommand);
            edit.Bind(_ => _.Command, vm, _ => _.UserData.EditDataCommand);
            remove.Bind(_ => _.Command, vm, _ => _.UserData.RemoveDataCommand);

            var ltnByProgram = new CheckBox()
            {
                Text = ReservedText.NoUserData
            };

            ltnByProgram.CheckedBinding.Bind(vm, _ => _.UserData.IsCheckboxChecked);

            var gp = new GroupBox()
            {
                Text = "User Data", Height = 470
            };

            gp.Content = new StackLayout(ltnByProgram, layout)
            {
                Spacing = 4, Padding = new Padding(4)
            };

            return(gp);
        }
コード例 #15
0
        private GroupBox GenVentPanel()
        {
            var vm = this._vm;

            var layout = new DynamicLayout();

            layout.Bind((t) => t.Enabled, vm, v => v.VentilationOpening.IsPanelEnabled);
            //layout.Bind((t) => t.Visible, vm, v => v.VentilationOpening.IsPanelEnabled);

            // double fractionAreaOperable = 0.5, double fractionHeightOperable = 1, double dischargeCoefficient = 0.45,
            // bool windCrossVent = false, double flowCoefficientClosed = 0, double flowExponentClosed = 0.65, double twoWayThreshold = 0.0001

            layout.DefaultSpacing = new Size(4, 4);
            layout.DefaultPadding = new Padding(4);

            var wPerArea = new DoubleText();

            wPerArea.Width        = 250;
            wPerArea.ReservedText = ReservedText.Varies;
            wPerArea.SetDefault(_vm.VentilationOpening.Default.FractionAreaOperable);
            wPerArea.TextBinding.Bind(vm, _ => _.VentilationOpening.FractionAreaOperable.NumberText);
            layout.AddRow("Fraction Area Operable:");
            layout.AddRow(wPerArea);

            var radFraction = new DoubleText();

            radFraction.ReservedText = ReservedText.Varies;
            radFraction.SetDefault(_vm.VentilationOpening.Default.FractionHeightOperable);
            radFraction.TextBinding.Bind(vm, _ => _.VentilationOpening.FractionHeightOperable.NumberText);
            layout.AddRow("Fraction Height Operable:");
            layout.AddRow(radFraction);

            var visFraction = new DoubleText();

            visFraction.ReservedText = ReservedText.Varies;
            visFraction.SetDefault(_vm.VentilationOpening.Default.DischargeCoefficient);
            visFraction.TextBinding.Bind(vm, _ => _.VentilationOpening.DischargeCoefficient.NumberText);
            layout.AddRow("Discharge Coefficient:");
            layout.AddRow(visFraction);

            var autosize = new CheckBox()
            {
                Text = "WindCrossVent"
            };

            autosize.CheckedBinding.Bind(_vm, _ => _.VentilationOpening.WindCrossVent.IsChecked);
            layout.AddRow(autosize);

            var airFraction = new DoubleText();

            airFraction.ReservedText = ReservedText.Varies;
            airFraction.SetDefault(_vm.VentilationOpening.Default.FlowCoefficientClosed);
            airFraction.TextBinding.Bind(vm, _ => _.VentilationOpening.FlowCoefficientClosed.NumberText);
            layout.AddRow("Flow Coefficient Closed:");
            layout.AddRow(airFraction);

            var delta = new DoubleText();

            delta.ReservedText = ReservedText.Varies;
            delta.SetDefault(_vm.VentilationOpening.Default.FlowExponentClosed);
            delta.TextBinding.Bind(vm, _ => _.VentilationOpening.FlowExponentClosed.NumberText);
            layout.AddRow("Flow Exponent Closed:");
            layout.AddRow(delta);

            var twoWay = new DoubleText();

            twoWay.ReservedText = ReservedText.Varies;
            twoWay.SetDefault(_vm.VentilationOpening.Default.TwoWayThreshold);
            twoWay.TextBinding.Bind(vm, _ => _.VentilationOpening.TwoWayThreshold.NumberText);
            layout.AddRow("Two Way Threshold:");
            layout.AddRow(twoWay);

            layout.AddRow(null);


            var ltnByProgram = new CheckBox()
            {
                Text = ReservedText.NoControl
            };

            ltnByProgram.CheckedBinding.Bind(vm, _ => _.VentilationOpening.IsCheckboxChecked);

            var gp = new GroupBox()
            {
                Text = "Ventilation Opening", Height = 470
            };

            gp.Content = new StackLayout(ltnByProgram, layout)
            {
                Spacing = 4, Padding = new Padding(4)
            };

            return(gp);
        }
コード例 #16
0
        private GroupBox GenEnergyPanel()
        {
            var gp = new GroupBox()
            {
                Text = "Energy"
            };

            var layout = new DynamicLayout();

            layout.DefaultSpacing = new Size(4, 4);
            layout.DefaultPadding = new Padding(4);


            var c = new Button();

            c.Width = 250;
            c.Bind(_ => _.Enabled, _vm, v => v.Construction.IsBtnEnabled);
            c.TextBinding.Bind(_vm, _ => _.Construction.BtnName);
            c.Command = this._vm.ConstructionCommand;
            var cByRoom = new CheckBox()
            {
                Text = ReservedText.ByGlobalSetting
            };

            cByRoom.CheckedBinding.Bind(_vm, _ => _.Construction.IsCheckboxChecked);

            layout.AddRow("Construction:", cByRoom);
            layout.AddRow(null, c);


            // boundary condition
            var bcText = new TextBox();

            bcText.TextBinding.Bind(_vm, _ => _.BoundaryConditionText);

            var bcDP = new DropDown()
            {
                Height = 24, DataStore = _vm.BoundaryConditionTexts
            };

            bcDP.SelectedValueBinding.Bind(_vm, _ => _.BoundaryConditionText);
            bcDP.Visible      = false;
            bcText.MouseDown += (s, e) => {
                bcText.Visible = false;
                bcDP.Visible   = true;
            };
            bcDP.LostFocus += (s, e) => {
                bcText.Visible = true;
                bcDP.Visible   = false;
            };

            var typeDp = new DynamicLayout();

            typeDp.AddRow(bcText);
            typeDp.AddRow(bcDP);
            layout.AddRow("Boundary Condition:", typeDp);


            // outdoor bc
            var outdoorBc = CreateOutdoorLayout();

            layout.AddRow(null, outdoorBc);
            var surfaceBc = CreateSurfaceLayout();

            layout.AddRow(null, surfaceBc);

            gp.Content = layout;
            return(gp);
        }
コード例 #17
0
        private void InitializeComponent()
        {
            SuspendLayout();

            lblTitle                   = new Label();
            lblTitle.Text              = "lblTitle";
            lblTitle.TextAlignment     = TextAlignment.Left;
            lblTitle.VerticalAlignment = VerticalAlignment.Center;

            Shape1 = new Scrollable();
            Shape1.BackgroundColor = Colors.White;
            Shape1.Border          = BorderType.Line;
            Shape1.Height          = 50;
            Shape1.Content         = new DefStackLayout(Orientation.Horizontal)
            {
                Items = { lblTitle }
            };

            Image1      = new Eto.Forms.ImageView();
            Image1.Size = new Size(41, 43);

            var imgLayout = new DefStackLayout(Orientation.Vertical);

            imgLayout.HorizontalContentAlignment = HorizontalAlignment.Center;
            imgLayout.VerticalContentAlignment   = VerticalAlignment.Top;
            imgLayout.Items.Add(Image1);

            Shape2 = new Scrollable();
            Shape2.BackgroundColor = Colors.Gray;
            Shape2.Border          = BorderType.Line;
            Shape2.Width           = 100;
            Shape2.Content         = imgLayout;

            txtTip                   = new Label();
            txtTip.Wrap              = WrapMode.Word;
            txtTip.TextAlignment     = TextAlignment.Left;
            txtTip.VerticalAlignment = VerticalAlignment.Top;

            Shape3 = new Scrollable();
            Shape3.BackgroundColor = Colors.White;
            Shape3.Border          = BorderType.Line;
            Shape3.Height          = 204;
            Shape3.Content         = new DefTableLayout()
            {
                Rows = { new TableRow(txtTip)
                         {
                             ScaleHeight = true
                         } }
            };

            var panel1 = new DynamicLayout();

            panel1.BeginHorizontal();
            panel1.Add(Shape2);
            panel1.BeginVertical();
            panel1.Add(Shape1);
            panel1.Add(Shape3);
            panel1.EndVertical();
            panel1.EndHorizontal();

            chkShow         = new CheckBox();
            chkShow.Checked = true;
            chkShow.Text    = "chkShow";

            btnNextTip        = new Button();
            btnNextTip.Size   = new Size(130, 26);
            btnNextTip.Text   = "btnNextTip";
            btnNextTip.Click += btnNextTip_Click;

            btnClose = new Button();
            btnClose.ImagePosition = ButtonImagePosition.Left;
            btnClose.Size          = new Size(130, 26);
            btnClose.Text          = "btnClose";
            btnClose.Click        += CancelClickHandler;

            Content = new DefTableLayout {
                Rows =
                {
                    new TableRow {
                        ScaleHeight = true,
                        Cells       = { panel1 }
                    },
                    UIHelper.MakeDialogFooter(chkShow, null, btnNextTip, btnClose)
                }
            };

            AbortButton = btnClose;
            Title       = " ";
            Topmost     = true;

            SetPredefProperties(550, 310);
            lblTitle.Font = new Font("Arial", 16F, FontStyle.Bold);

            ResumeLayout();
        }
コード例 #18
0
            public SettingsDialog(bool inGame)
            {
                Title         = Program.name + " Settings";
                ShowInTaskbar = true;

                //Size = new Eto.Drawing.Size(640, 320);
                Topmost = true;

                TableLayout layout = new TableLayout()
                {
                    Padding = new Eto.Drawing.Padding(5),
                };

                layout.Rows.Add(new TableRow
                                (
                                    new Panel()
                {
                    Content = new TabControl()
                    {
                        Pages =
                        {
                            new TabPage()
                            {
                                Text    = "tab1",
                                Content = new Button()
                                {
                                    Text = "tabbutton1",
                                },
                                //Content
                            },

                            new TabPage()
                            {
                                Text = "tab2",
                                //Content
                            },
                        },
                    },
                    Size = new Eto.Drawing.Size(640, 320)
                }
                                ));

                DynamicLayout buttonLayout = new DynamicLayout()
                {
                    Padding = new Eto.Drawing.Padding(5),
                    Spacing = new Eto.Drawing.Size(5, 5),
                };

                buttonLayout.BeginHorizontal();

                buttonLayout.Add(new Label {
                    Text = Program.versionDisplay.ToString()
                });
                buttonLayout.Add(null);
                buttonLayout.Add(AddButton(inGame ? "OK" : "Start", OnOkClick));
                buttonLayout.Add(AddButton(inGame ? "Cancel" : "Exit", OnCancelClick));
                buttonLayout.Add(AddButton("Apply", OnApplyClick));
                buttonLayout.EndHorizontal();

                layout.Rows.Add(buttonLayout);
                //layout.SetRowScale(layout.Rows.Count-1, false);

                Content = layout;
            }
コード例 #19
0
ファイル: DistillationColumn.cs プロジェクト: Greg66/dwsim6
 public DistillationColumnEditor(ISimulationObject selectedobject, DynamicLayout layout)
 {
     column    = (DistillationColumn)selectedobject;
     container = layout;
     Initialize();
 }
コード例 #20
0
        private void InitContent()
        {
            var fileLabel = new Label {
                Text = DefaultInputFileLabel + MissingFileNameLabel, Width = Size.Width, Wrap = WrapMode.None
            };
            var openFileButton = new Button {
                Height = 40, Text = OpenFileButtonLabel
            };
            var openFileDialog = new OpenFileDialog();
            var folderLabel    = new Label {
                Text = DefaultInputFolderLabel + MissingFolderNameLabel, Width = Size.Width, Wrap = WrapMode.None
            };
            var openFolderButton = new Button {
                Height = 40, Width = 100, Text = OpenFolderButtonLabel
            };
            var openFolderDialog = new SelectFolderDialog();
            var checkBox         = new CheckBox {
                Height = 50, Text = EnableInPlaceSplittingDesc
            };
            var startSplittingButton = new Button {
                Enabled = false, Height = 10, Text = StartWorkButtonLabel
            };

            openFileButton.Click += (sender, e) =>
            {
                try
                {
                    openFileDialog.ShowDialog(openFileButton);
                    _inputFile = openFileDialog.FileName;
                }
                catch (NullReferenceException)
                {
                    _inputFile = null;
                }

                startSplittingButton.Enabled = _inputFile != null;
                fileLabel.Text = DefaultInputFileLabel + (_inputFile ?? MissingFileNameLabel);
            };

            openFolderButton.Click += (sender, e) =>
            {
                try
                {
                    openFolderDialog.ShowDialog(openFolderButton);
                    _outputFolder = openFolderDialog.Directory;
                }
                catch (NullReferenceException)
                {
                    _outputFolder = null;
                }

                folderLabel.Text = DefaultInputFolderLabel + (_outputFolder ?? MissingFolderNameLabel);
            };

            checkBox.CheckedChanged += (sender, e) =>
            {
                _inPlace = checkBox.Checked ?? false;
            };

            startSplittingButton.Click += ProgressAsync;

            var layout = new DynamicLayout
                         (
                new TableLayout
                (
                    fileLabel,
                    openFileButton,
                    folderLabel,
                    openFolderButton
                )
            {
                Padding = 3
            }
                         );

            layout.AddSeparateRow
            (
                new TableLayout
                (
                    new TableRow(checkBox, startSplittingButton)
                )
            {
                Padding = 3
            }
            );

            Content = layout;
        }
コード例 #21
0
ファイル: Kinetic.cs プロジェクト: simonmb/dwsim6
        void Initialize()
        {
            container.CreateAndAddLabelRow("Reaction ID");

            container.CreateAndAddStringEditorRow2("Name", "", rx.Name, (sender, e) => { rx.Name = sender.Text; });

            DynamicLayout p1, p2;

            TableLayout t1;

            p1 = UI.Shared.Common.GetDefaultContainer();
            p2 = UI.Shared.Common.GetDefaultContainer();

            p1.Width = 420;

            t1 = new TableLayout();
            t1.Rows.Add(new TableRow(p1, p2));

            p1.CreateAndAddLabelRow("Compounds and Stoichiometry (Include / Name / Heat of Formation (kJ/kg) / Stoich. Coeff. / Direct Order Exponent / Reverse Order Exponent)");

            var compcontainer = new DynamicLayout();

            Double val;

            foreach (ICompoundConstantProperties comp in flowsheet.SelectedCompounds.Values)
            {
                var chk = new CheckBox()
                {
                    Text = comp.Name, Checked = (rx.Components.ContainsKey(comp.Name) ? true : false)
                };
                chk.CheckedChanged += (sender, e) =>
                {
                    if (!rx.Components.ContainsKey(comp.Name))
                    {
                        rx.Components.Add(comp.Name, new DWSIM.Thermodynamics.BaseClasses.ReactionStoichBase(comp.Name, 0, false, 0, 0));
                    }
                    else
                    {
                        rx.Components.Remove(comp.Name);
                    }
                    UpdateEquation();
                };

                var sc = new TextBox()
                {
                    Width = (int)(sf * 30), Text = (rx.Components.ContainsKey(comp.Name) ? rx.Components[comp.Name].StoichCoeff.ToString() : 0.0f.ToString())
                };

                sc.TextChanged += (sender, e) =>
                {
                    if (Double.TryParse(sc.Text.ToString(), out val))
                    {
                        sc.TextColor = SystemColors.ControlText;
                        if (!rx.Components.ContainsKey(comp.Name))
                        {
                            rx.Components.Add(comp.Name, new DWSIM.Thermodynamics.BaseClasses.ReactionStoichBase(comp.Name, Double.Parse(sc.Text), false, 0, 0));
                        }
                        else
                        {
                            rx.Components[comp.Name].StoichCoeff = double.Parse(sc.Text);
                        }
                        UpdateEquation();
                    }
                    else
                    {
                        sc.TextColor = Colors.Red;
                    }
                };

                var txtdo = new TextBox()
                {
                    Width = (int)(sf * 30), Text = (rx.Components.ContainsKey(comp.Name) ? rx.Components[comp.Name].DirectOrder.ToString() : 0.0f.ToString())
                };

                txtdo.TextChanged += (sender, e) =>
                {
                    if (Double.TryParse(txtdo.Text.ToString(), out val))
                    {
                        txtdo.TextColor = SystemColors.ControlText;
                        if (!rx.Components.ContainsKey(comp.Name))
                        {
                            rx.Components.Add(comp.Name, new DWSIM.Thermodynamics.BaseClasses.ReactionStoichBase(comp.Name, 0, false, Double.Parse(txtdo.Text), 0));
                        }
                        else
                        {
                            rx.Components[comp.Name].DirectOrder = double.Parse(txtdo.Text);
                        }
                        UpdateEquation();
                    }
                    else
                    {
                        txtdo.TextColor = Colors.Red;
                    }
                };

                var txtro = new TextBox()
                {
                    Width = (int)(sf * 30), Text = (rx.Components.ContainsKey(comp.Name) ? rx.Components[comp.Name].ReverseOrder.ToString() : 0.0f.ToString())
                };

                txtro.TextChanged += (sender, e) =>
                {
                    if (Double.TryParse(txtro.Text.ToString(), out val))
                    {
                        txtro.TextColor = SystemColors.ControlText;
                        if (!rx.Components.ContainsKey(comp.Name))
                        {
                            rx.Components.Add(comp.Name, new DWSIM.Thermodynamics.BaseClasses.ReactionStoichBase(comp.Name, 0, false, 0, Double.Parse(txtro.Text)));
                        }
                        else
                        {
                            rx.Components[comp.Name].ReverseOrder = double.Parse(txtro.Text);
                        }
                        UpdateEquation();
                    }
                    else
                    {
                        txtro.TextColor = Colors.Red;
                    }
                };

                var hf = new TextBox()
                {
                    Enabled = false, Width = (int)(sf * 100), Text = comp.IG_Enthalpy_of_Formation_25C.ToString("N2")
                };

                compcontainer.Add(new TableRow(chk, null, hf, sc, txtdo, txtro));
            }

            p1.CreateAndAddControlRow(compcontainer);
            p1.CreateAndAddEmptySpace();

            var comps = flowsheet.SelectedCompounds.Values.Select((x) => x.Name).ToList();

            comps.Insert(0, "");

            p1.CreateAndAddLabelRow("Base Compound");

            var basecompselector = p1.CreateAndAddDropDownRow("Base Compound", comps, 0, null);

            var basecomp = rx.Components.Values.Where((x) => x.IsBaseReactant).FirstOrDefault();

            if (basecomp != null)
            {
                basecompselector.SelectedIndex = comps.IndexOf(basecomp.CompName);
            }
            else
            {
                basecompselector.SelectedIndex = 0;
            }

            basecompselector.SelectedIndexChanged += (sender, e) =>
            {
                if (rx.Components.ContainsKey(comps[basecompselector.SelectedIndex]))
                {
                    foreach (var rxc in rx.Components.Values)
                    {
                        rxc.IsBaseReactant = false;
                    }
                    rx.Components[comps[basecompselector.SelectedIndex]].IsBaseReactant = true;
                    rx.BaseReactant = comps[basecompselector.SelectedIndex];
                    UpdateEquation();
                }
            };

            p1.CreateAndAddLabelRow("Reaction Balance");

            txtEquation = p1.CreateAndAddLabelRow2("");

            p1.CreateAndAddLabelRow("Reaction Phase");

            var rxphaseselector = p1.CreateAndAddDropDownRow("Reaction Phase", Shared.StringArrays.reactionphase().ToList(), 0, null);

            switch (rx.ReactionPhase)
            {
            case Interfaces.Enums.PhaseName.Mixture:
                rxphaseselector.SelectedIndex = (0);
                break;

            case Interfaces.Enums.PhaseName.Vapor:
                rxphaseselector.SelectedIndex = (1);
                break;

            case Interfaces.Enums.PhaseName.Liquid:
                rxphaseselector.SelectedIndex = (2);
                break;
            }

            rxphaseselector.SelectedIndexChanged += (sender, e) =>
            {
                switch (rxphaseselector.SelectedIndex)
                {
                case 0:
                    rx.ReactionPhase = Interfaces.Enums.PhaseName.Mixture;
                    break;

                case 1:
                    rx.ReactionPhase = Interfaces.Enums.PhaseName.Vapor;
                    break;

                case 2:
                    rx.ReactionPhase = Interfaces.Enums.PhaseName.Liquid;
                    break;
                }
            };

            p1.CreateAndAddLabelRow("Reaction Basis");

            var rxbasisselector = p1.CreateAndAddDropDownRow("Reaction Basis", Shared.StringArrays.reactionbasis().ToList(), 0, null);

            switch (rx.ReactionBasis)
            {
            case Interfaces.Enums.ReactionBasis.Activity:
                rxbasisselector.SelectedIndex = (0);
                break;

            case Interfaces.Enums.ReactionBasis.Fugacity:
                rxbasisselector.SelectedIndex = (1);
                break;

            case Interfaces.Enums.ReactionBasis.MassConc:
                rxbasisselector.SelectedIndex = (2);
                break;

            case Interfaces.Enums.ReactionBasis.MassFrac:
                rxbasisselector.SelectedIndex = (3);
                break;

            case Interfaces.Enums.ReactionBasis.MolarConc:
                rxbasisselector.SelectedIndex = (4);
                break;

            case Interfaces.Enums.ReactionBasis.MolarFrac:
                rxbasisselector.SelectedIndex = (5);
                break;

            case Interfaces.Enums.ReactionBasis.PartialPress:
                rxbasisselector.SelectedIndex = (6);
                break;
            }

            rxbasisselector.SelectedIndexChanged += (sender, e) =>
            {
                switch (rxbasisselector.SelectedIndex)
                {
                case 0:
                    rx.ReactionBasis = Interfaces.Enums.ReactionBasis.Activity;
                    break;

                case 1:
                    rx.ReactionBasis = Interfaces.Enums.ReactionBasis.Fugacity;
                    break;

                case 2:
                    rx.ReactionBasis = Interfaces.Enums.ReactionBasis.MassConc;
                    break;

                case 3:
                    rx.ReactionBasis = Interfaces.Enums.ReactionBasis.MassFrac;
                    break;

                case 4:
                    rx.ReactionBasis = Interfaces.Enums.ReactionBasis.MolarConc;
                    break;

                case 5:
                    rx.ReactionBasis = Interfaces.Enums.ReactionBasis.MolarFrac;
                    break;

                case 6:
                    rx.ReactionBasis = Interfaces.Enums.ReactionBasis.PartialPress;
                    break;
                }
            };

            p1.CreateAndAddLabelRow("Temperature Limits");

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

            p1.CreateAndAddTextBoxRow(nf, "Minimum Temperature (" + su.temperature + ")", rx.Tmin.ConvertFromSI(su.temperature), (sender, e) => { if (sender.Text.IsValidDouble())
                                                                                                                                                  {
                                                                                                                                                      rx.Tmin = sender.Text.ToDoubleFromCurrent().ConvertToSI(su.temperature);
                                                                                                                                                  }
                                      });
            p1.CreateAndAddTextBoxRow(nf, "Maximum Temperature (" + su.temperature + ")", rx.Tmax.ConvertFromSI(su.temperature), (sender, e) => { if (sender.Text.IsValidDouble())
                                                                                                                                                  {
                                                                                                                                                      rx.Tmax = sender.Text.ToDoubleFromCurrent().ConvertToSI(su.temperature);
                                                                                                                                                  }
                                      });

            p2.CreateAndAddLabelRow("Velocity Constant for Forward Reactions");

            p2.CreateAndAddDropDownRow("Equation Type for Forward Reactions", new List <string>()
            {
                "Arrhenius (k = A*exp(-E/RT))", "User-Defined Expression"
            }, (int)rx.ReactionKinFwdType, (sender, e) =>
            {
                switch (sender.SelectedIndex)
                {
                case 0:
                    rx.ReactionKinFwdType = Interfaces.Enums.ReactionKineticType.Arrhenius;
                    break;

                case 1:
                    rx.ReactionKinFwdType = Interfaces.Enums.ReactionKineticType.UserDefined;
                    break;
                }
            });

            p2.CreateAndAddStringEditorRow2("A", "", rx.A_Forward.ToString(), (sender, e) =>
            {
                if (Double.TryParse(sender.Text.ToString(), out val))
                {
                    sender.TextColor = SystemColors.ControlText;
                    rx.A_Forward     = double.Parse(sender.Text);
                }
                else
                {
                    sender.TextColor = Colors.Red;
                }
            });

            p2.CreateAndAddStringEditorRow2("E", "", rx.E_Forward.ToString(), (sender, e) =>
            {
                if (Double.TryParse(sender.Text.ToString(), out val))
                {
                    sender.TextColor = SystemColors.ControlText;
                    rx.E_Forward     = double.Parse(sender.Text);
                }
                else
                {
                    sender.TextColor = Colors.Red;
                }
            });

            p2.CreateAndAddStringEditorRow2("User Expression - f(T), T in K", "", rx.ReactionKinFwdExpression, (sender, e) =>
            {
                rx.ReactionKinFwdExpression = sender.Text;
            });

            p2.CreateAndAddLabelRow("Velocity Constant for Reverse Reactions");

            p2.CreateAndAddDropDownRow("Equation Type for Reverse Reactions", new List <string>()
            {
                "Arrhenius (k = A*exp(-E/RT))", "User-Defined Expression"
            }, (int)rx.ReactionKinRevType, (sender, e) =>
            {
                switch (sender.SelectedIndex)
                {
                case 0:
                    rx.ReactionKinRevType = Interfaces.Enums.ReactionKineticType.Arrhenius;
                    break;

                case 1:
                    rx.ReactionKinRevType = Interfaces.Enums.ReactionKineticType.UserDefined;
                    break;
                }
            });

            p2.CreateAndAddStringEditorRow2("A", "", rx.A_Reverse.ToString(), (sender, e) =>
            {
                if (Double.TryParse(sender.Text.ToString(), out val))
                {
                    sender.TextColor = SystemColors.ControlText;
                    rx.A_Reverse     = double.Parse(sender.Text);
                }
                else
                {
                    sender.TextColor = Colors.Red;
                }
            });

            p2.CreateAndAddStringEditorRow2("E (J/mol)", "", rx.E_Reverse.ToString(), (sender, e) =>
            {
                if (Double.TryParse(sender.Text.ToString(), out val))
                {
                    sender.TextColor = SystemColors.ControlText;
                    rx.E_Reverse     = double.Parse(sender.Text);
                }
                else
                {
                    sender.TextColor = Colors.Red;
                }
            });

            p2.CreateAndAddStringEditorRow2("User Expression - f(T), T in K", "", rx.ReactionKinRevExpression, (sender, e) =>
            {
                rx.ReactionKinRevExpression = sender.Text;
            });

            p2.CreateAndAddLabelRow("Units");

            var us    = new DWSIM.SharedClasses.SystemsOfUnits.Units();
            var units = us.GetUnitSet(Interfaces.Enums.UnitOfMeasure.molar_conc);

            units.AddRange(us.GetUnitSet(Interfaces.Enums.UnitOfMeasure.mass_conc));
            units.AddRange(us.GetUnitSet(Interfaces.Enums.UnitOfMeasure.pressure));
            units.Insert(0, "");

            p2.CreateAndAddDropDownRow("Basis Units (Base Compound)", units, units.IndexOf(rx.ConcUnit), (sender, e) => rx.ConcUnit = sender.SelectedValue.ToString());

            var units2 = us.GetUnitSet(Interfaces.Enums.UnitOfMeasure.reac_rate);

            units2.Insert(0, "");

            p2.CreateAndAddDropDownRow("Velocity Units", units2, units2.IndexOf(rx.VelUnit), (sender, e) => rx.VelUnit = sender.SelectedValue.ToString());

            var units3 = us.GetUnitSet(Interfaces.Enums.UnitOfMeasure.molar_enthalpy);

            units3.Insert(0, "");

            p2.CreateAndAddDropDownRow("E (Forward)", units3, units3.IndexOf(rx.E_Forward_Unit), (sender, e) => rx.E_Forward_Unit = sender.SelectedValue.ToString());

            p2.CreateAndAddDropDownRow("E (Reverse)", units3, units3.IndexOf(rx.E_Reverse_Unit), (sender, e) => rx.E_Reverse_Unit = sender.SelectedValue.ToString());

            UpdateEquation();

            container.Add(t1);
        }
コード例 #22
0
        public ProjectWizardPageView(ProjectWizardPageModel model)
        {
            var radioSpacing = Platform.IsGtk ? Size.Empty : new Size(2, 2);

            var content = new DynamicLayout
            {
                Spacing = new Size(10, 10)
            };

            if (model.SupportsAppName)
            {
                var nameBox = new TextBox();
                nameBox.TextBinding.BindDataContext((ProjectWizardPageModel m) => m.AppName);
                Application.Instance.AsyncInvoke(nameBox.Focus);

                var nameValid = new Label {
                    TextColor = Global.Theme.ErrorForeground
                };
                nameValid.BindDataContext(c => c.Visible, (ProjectWizardPageModel m) => m.AppNameInvalid);
                nameValid.BindDataContext(c => c.Text, (ProjectWizardPageModel m) => m.AppNameValidationText);


                content.BeginHorizontal();
                content.Add(HeadingLabel((model.IsLibrary ? "Library" : "App") + " Name:"));
                content.AddColumn(nameBox, nameValid);
                content.EndHorizontal();
            }
            else if (!string.IsNullOrEmpty(model.AppName))
            {
                var label = new Label {
                    Text = model.AppName, VerticalAlignment = VerticalAlignment.Center
                };
                content.AddRow(HeadingLabel((model.IsLibrary ? "Library" : "App") + " Name:"), label);
            }

            if (model.SupportsCombined)
            {
                var platformTypeList = new RadioButtonList
                {
                    Orientation = Orientation.Vertical,
                    Spacing     = radioSpacing,
                    Items       =
                    {
                        new ListItem {
                            Text = "Separate projects for each platform", Key = "separate"
                        },
                        new ListItem {
                            Text = "Single Windows, Linux, and Mac desktop project", Key = "combined"
                        }
                    }
                };
                platformTypeList.BindDataContext(c => c.Enabled, (ProjectWizardPageModel m) => m.AllowCombined);
                platformTypeList.SelectedKeyBinding
                .Convert(v => v == "combined", v => v ? "combined" : "separate")
                .BindDataContext((ProjectWizardPageModel m) => m.Combined);
                content.AddRow(HeadingLabel("Launcher:"), platformTypeList);
            }

            if (model.SupportsXamMac)
            {
                var cb = new CheckBox
                {
                    Text    = "Include Xamarin.Mac project",
                    ToolTip = "This enables you to bundle mono with your app so your users don't have to install it separately.  You can only compile this on a Mac"
                };
                cb.CheckedBinding.BindDataContext((ProjectWizardPageModel m) => m.IncludeXamMac);
                content.AddRow(HeadingLabel(string.Empty), cb);
            }

            /*
             * eventually select platforms to include?
             *
             * var platformCheckBoxes = new DynamicLayout();
             * platformCheckBoxes.BeginHorizontal();
             * platformCheckBoxes.Add(new CheckBox { Text = "Gtk2" });
             * platformCheckBoxes.Add(new CheckBox { Text = "Gtk3" });
             * platformCheckBoxes.EndBeginHorizontal();
             * platformCheckBoxes.Add(new CheckBox { Text = "WinForms" });
             * platformCheckBoxes.Add(new CheckBox { Text = "Wpf" });
             * platformCheckBoxes.Add(new CheckBox { Text = "Direct2D" });
             * platformCheckBoxes.EndBeginHorizontal();
             * platformCheckBoxes.Add(new CheckBox { Text = "Mac" });
             * platformCheckBoxes.Add(new CheckBox { Text = "XamMac" });
             * platformCheckBoxes.Add(new CheckBox { Text = "XamMac2" });
             * platformCheckBoxes.EndHorizontal();
             *
             * content.Rows.Add(new TableRow(new Label { Text = "Platforms:", TextAlignment = TextAlignment.Right }, platformCheckBoxes));
             * /**/

            if (model.SupportsFramework)
            {
                var frameworkCheckBoxes = new CheckBoxList();
                frameworkCheckBoxes.BindDataContext(c => c.DataStore, (ProjectWizardPageModel m) => m.SupportedFrameworks);
                frameworkCheckBoxes.ItemTextBinding = Binding.Property((ProjectWizardPageModel.FrameworkInfo i) => i.Text);
                frameworkCheckBoxes.ItemKeyBinding  = Binding.Property((ProjectWizardPageModel.FrameworkInfo i) => i.Value);
                frameworkCheckBoxes.SelectedValuesBinding.BindDataContext((ProjectWizardPageModel m) => m.SelectedFrameworks);

                content.AddRow(HeadingLabel("Framework:"), frameworkCheckBoxes);
            }

            if (model.SupportsProjectType)
            {
                var sharedCodeList = new RadioButtonList
                {
                    Orientation = Orientation.Vertical,
                    Spacing     = radioSpacing,
                };
                if (model.SupportsPCL)
                {
                    sharedCodeList.Items.Add(new ListItem {
                        Text = "Portable Class Library", Key = "pcl"
                    });
                    sharedCodeList.SelectedKeyBinding.Convert(v => v == "pcl", v => v ? "pcl" : sharedCodeList.SelectedKey).BindDataContext((ProjectWizardPageModel m) => m.UsePCL);
                }
                if (model.SupportsNetStandard)
                {
                    sharedCodeList.Items.Add(new ListItem {
                        Text = ".NET Standard", Key = "netstandard"
                    });
                    sharedCodeList.SelectedKeyBinding.Convert(v => v == "netstandard", v => v ? "netstandard" : sharedCodeList.SelectedKey).BindDataContext((ProjectWizardPageModel m) => m.UseNetStandard);
                }
                if (model.SupportsSAL)
                {
                    sharedCodeList.Items.Add(new ListItem {
                        Text = "Shared Project", Key = "sal"
                    });
                    sharedCodeList.SelectedKeyBinding.Convert(v => v == "sal", v => v ? "sal" : sharedCodeList.SelectedKey).BindDataContext((ProjectWizardPageModel m) => m.UseSAL);
                }

                sharedCodeList.Items.Add(new ListItem {
                    Text = "Full .NET", Key = "net"
                });
                sharedCodeList.SelectedKeyBinding.Convert(v => v == "net", v => v ? "net" : sharedCodeList.SelectedKey).BindDataContext((ProjectWizardPageModel m) => m.UseNET);

                content.AddRow(new Label {
                    Text = model.IsLibrary ? "Type:" : "Shared Code:", TextAlignment = TextAlignment.Right
                }, sharedCodeList);
            }

            if (model.SupportsPanelType)
            {
                var panelTypeList = new RadioButtonList
                {
                    Orientation = Orientation.Horizontal,
                    Spacing     = radioSpacing,
                };

                panelTypeList.Items.Add(new ListItem {
                    Text = "Code", Key = "code"
                });
                panelTypeList.SelectedKeyBinding.BindDataContext((ProjectWizardPageModel m) => m.Mode);

                if (model.SupportsXeto)
                {
                    panelTypeList.Items.Add(new ListItem {
                        Text = "Xaml", Key = "xaml"
                    });
                }
                if (model.SupportsJeto)
                {
                    panelTypeList.Items.Add(new ListItem {
                        Text = "Json", Key = "json"
                    });
                }
                if (model.SupportsCodePreview)
                {
                    panelTypeList.Items.Add(new ListItem {
                        Text = "Code Preview", Key = "preview"
                    });
                }

                content.AddRow(HeadingLabel("Form:"), panelTypeList);
            }

            if (model.SupportsBase)
            {
                var baseTypeList = new RadioButtonList
                {
                    Orientation = Orientation.Horizontal,
                    Spacing     = radioSpacing,
                };

                baseTypeList.Items.Add(new ListItem {
                    Text = "Panel", Key = "Panel"
                });
                baseTypeList.Items.Add(new ListItem {
                    Text = "Dialog", Key = "Dialog"
                });
                baseTypeList.Items.Add(new ListItem {
                    Text = "Form", Key = "Form"
                });
                baseTypeList.SelectedKeyBinding.BindDataContext((ProjectWizardPageModel m) => m.Base);

                content.AddRow(HeadingLabel("Base:"), baseTypeList);
            }

#if DEBUG
            var showColorsButton = new Button {
                Text = "Show all themed colors"
            };
            showColorsButton.Click += (sender, e) => new ThemedColorsDialog().ShowModal(this);
            content.AddRow(new Panel(), showColorsButton);
#endif

            var informationLabel = new Label();
            informationLabel.TextBinding.BindDataContext((ProjectWizardPageModel m) => m.Information);
            Information = informationLabel;

            Content     = content;
            DataContext = model;
        }
コード例 #23
0
        public void Init()
        {
            int w = (int)(sf * 640);
            int h = (int)(sf * 480);

            var center = Screen.PrimaryScreen.WorkingArea.Center;

            center.X -= w / 2;
            center.Y -= h / 2;

            Location = new Point(center);

            ClientSize = new Size(w, h);

            Maximizable = false;

            Minimizable = false;

            Resizable = false;

            ShowInTaskbar = false;

            AddComponentInfo();

            string imgprefix = "DWSIM.UI.Forms.Resources.Icons.";

            Title = "AboutDWSIM".Localize();

            Icon = Eto.Drawing.Icon.FromResource(imgprefix + "DWSIM_ico.ico");

            var layout = new PixelLayout();

            string vtext = "Version".Localize() + " " + Assembly.GetExecutingAssembly().GetName().Version.Major.ToString() + "." + Assembly.GetExecutingAssembly().GetName().Version.Minor.ToString();

            vtext += " (" + Assembly.GetExecutingAssembly().GetName().Version.ToString() + ")";

            var updfile = AppDomain.CurrentDomain.BaseDirectory + Path.DirectorySeparatorChar + "version.info";

            if (File.Exists(updfile))
            {
                int vinfo = 0;
                int.TryParse(File.ReadAllText(updfile), out vinfo);
                if (vinfo > 0)
                {
                    vtext += " Update " + vinfo;
                }
            }

            string crtext = Shared.AssemblyCopyright;

            layout.Add(new ImageView {
                Size = new Size((int)(sf * 100), (int)(sf * 100)), Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imgprefix + "DWSIM_ico.png"))
            }, 0, 0);
            layout.Add(new Label {
                Text = "DWSIM Simulator (Cross-Platform User Interface)", TextAlignment = TextAlignment.Left, Font = SystemFonts.Bold(null, FontDecoration.None)
            }, (int)(sf * 110), 0);
            layout.Add(new Label {
                Text = vtext, TextAlignment = TextAlignment.Left
            }, (int)(sf * 110), (int)(sf * 20));
            layout.Add(new Label {
                Text = crtext, TextAlignment = TextAlignment.Left
            }, (int)(sf * 110), (int)(sf * 40));

            string osinfo = "", clrinfo = "", meminfo = "";

            if (Application.Instance.Platform.IsMac)
            {
                var osversion = Environment.OSVersion.Version.ToString();
                switch (osversion)
                {
                case "11.0.0.0": osinfo = "Mac OS X Lion (v10.7.0)"; break;

                case "11.4.2.0": osinfo = "Mac OS X Lion (v10.7.5)"; break;

                case "12.0.0.0": osinfo = "OS X Mountain Lion (v10.8.0)"; break;

                case "13.0.0.0": osinfo = "OS X Mavericks (v10.9.0)"; break;

                case "13.4.0.0": osinfo = "OS X Mavericks (v10.9.5)"; break;

                case "14.0.0.0": osinfo = "OS X Yosemite (v10.10.0)"; break;

                case "14.5.0.0": osinfo = "OS X Yosemite (v10.10.5)"; break;

                case "15.0.0.0": osinfo = "OS X El Captain (v10.11.0)"; break;

                case "15.6.0.0": osinfo = "OS X El Captain (v10.11.6)"; break;

                case "16.0.0.0": osinfo = "macOS Sierra (v10.12.0)"; break;

                case "16.1.0.0": osinfo = "macOS Sierra (v10.12.1)"; break;

                case "16.3.0.0": osinfo = "macOS Sierra (v10.12.2)"; break;

                case "16.4.0.0": osinfo = "macOS Sierra (v10.12.3)"; break;

                case "16.5.0.0": osinfo = "macOS Sierra (v10.12.4)"; break;

                case "16.6.0.0": osinfo = "macOS Sierra (v10.12.5)"; break;

                case "16.7.0.0": osinfo = "macOS Sierra (v10.12.6)"; break;

                case "17.0.0.0": osinfo = "macOS High Sierra (v10.13.0)"; break;

                case "17.4.0.0": osinfo = "macOS High Sierra (v10.13.3)"; break;

                case "18.0.0.0": osinfo = "macOS Mojave (v10.14.0)"; break;

                default: osinfo = "macOS (v" + osversion + ")"; break;
                }
            }
            else
            {
                osinfo = Environment.OSVersion.ToString();
            }

            clrinfo = SharedClasses.Utility.GetRuntimeVersion();

            meminfo = (GC.GetTotalMemory(false) / 1024 / 1024).ToString("#") + " MB managed, " + (Environment.WorkingSet / 1024 / 1024).ToString("#") + " MB total";

            var container1 = new DynamicLayout()
            {
                Padding = new Padding(10)
            };

            container1.CreateAndAddTwoLabelsRow2("Main Developer:", "Daniel Medeiros ([email protected])");
            container1.CreateAndAddTwoLabelsRow2("Contributors:", "Gregor Reichert, Gustavo León and others");
            container1.CreateAndAddTwoLabelsRow2("Splash Screen Design:", "Wendel Marcus (www.behance.net/wendelmarcus)");
            container1.CreateAndAddTwoLabelsRow2("OS Info:", osinfo);
            container1.CreateAndAddTwoLabelsRow2("CLR Info:", clrinfo);
            container1.CreateAndAddTwoLabelsRow2("Memory Usage:", meminfo);
            container1.CreateAndAddLabelRow("DWSIM is released under the terms of the GNU General Public License (GPL) version 3.");

            var listcontainer = new GridView {
                DataStore = components, RowHeight = (int)(sf * 20)
            };

            var col1 = new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <ComponentInfo, string>(r => r.Name)
                },
                HeaderText = "Name"
            };

            col1.AutoSize = true;
            listcontainer.Columns.Add(col1);
            var col1a = new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <ComponentInfo, string>(r => r.Version)
                },
                HeaderText = "Version"
            };

            col1a.AutoSize = true;
            listcontainer.Columns.Add(col1a);
            var col1b = new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <ComponentInfo, string>(r => r.Year)
                },
                HeaderText = "Year"
            };

            col1b.AutoSize = true;
            listcontainer.Columns.Add(col1b);
            var col1c = new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <ComponentInfo, string>(r => r.Copyright)
                },
                HeaderText = "Copyright"
            };

            col1c.AutoSize = true;
            listcontainer.Columns.Add(col1c);
            var col1d = new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <ComponentInfo, string>(r => r.Website)
                },
                HeaderText = "Website"
            };

            col1d.AutoSize = true;
            listcontainer.Columns.Add(col1d);
            var col1e = new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <ComponentInfo, string>(r => r.License)
                },
                HeaderText = "License"
            };

            col1e.AutoSize = true;
            listcontainer.Columns.Add(col1e);
            var col1f = new GridColumn
            {
                DataCell = new TextBoxCell {
                    Binding = Binding.Property <ComponentInfo, string>(r => r.LicenseText)
                },
                HeaderText = "License Text"
            };

            col1f.AutoSize = true;
            listcontainer.Columns.Add(col1f);

            string gpltext;

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("DWSIM.UI.Forms.Resources.TextFiles.gpl-3.0.txt"))
                using (StreamReader reader = new StreamReader(stream))
                {
                    gpltext = reader.ReadToEnd();
                }

            var txt1 = new TextArea {
                Text = gpltext, ReadOnly = true
            };

            var t1 = new TableLayout(new TableRow(txt1));

            var tab1 = new TabPage {
                Content = container1, Text = "General Information"
            };
            var tab2 = new TabPage {
                Content = new Scrollable {
                    Content = t1
                }, Text = "DWSIM License"
            };
            var tab3 = new TabPage {
                Content = new Scrollable {
                    Content = listcontainer
                }, Text = "External Components"
            };

            var tabc = new TabControl();

            tabc.Pages.Add(tab1);
            tabc.Pages.Add(tab2);
            tabc.Pages.Add(tab3);

            var tablecontainer = new TableLayout {
                Padding = new Padding(10), Spacing = new Size(5, 5)
            };

            tablecontainer.Rows.Add(new TableRow(layout));
            tablecontainer.Rows.Add(new TableRow(tabc));

            Content = tablecontainer;
        }
コード例 #24
0
ファイル: WebView2Handler.cs プロジェクト: philstopford/Eto
        public ManualInstallDialog()
        {
            WebView2Loader.CenterDialog(this);
            string Loc(string str) => Application.Instance.Localize(typeof(WebView2Loader), str);

            Title = Loc("Install WebView2 Runtime");

            MinimumSize = new Size(300, 200);

            // controls

            var installButton = new Button {
                Text = Loc("Download && Install Now")
            };

            installButton.Click += OnInstall;

            var downloadButton = new LinkButton {
                Text = Loc("Open the WebView2 download page to install manually")
            };

            downloadButton.Click += OnDownload;

            var cancelButton = new Button {
                Text = Loc("Fallback to IE")
            };

            cancelButton.Click += OnCancel;

            var description = new Label
            {
                TextAlignment = TextAlignment.Center,
                Text          = Loc("This application requires the Microsoft Edge WebView2 Runtime.\nPlease install it to continue.")
            };

            // layout

            var layout = new DynamicLayout {
                Padding = 10, DefaultSpacing = new Size(5, 5)
            };

            layout.AddSpace();
            layout.Add(description);
            layout.AddSpace();

            layout.AddSeparateRow(null, downloadButton);

            Content = layout;

            DefaultButton = installButton;
            PositiveButtons.Add(installButton);
            NegativeButtons.Add(cancelButton);

            Shown += (sender, e) => installButton.Focus();

            timer = new UITimer {
                Interval = 1.0
            };
            timer.Elapsed += timer_Elapsed;
            timer.Start();
        }
コード例 #25
0
 public MaterialStreamEditor(ISimulationObject selectedobject, DynamicLayout layout)
 {
     MatStream = (MaterialStream)selectedobject;
     container = layout;
     Initialize();
 }
コード例 #26
0
ファイル: AbsorptionColumn.cs プロジェクト: jmptrader/dwsim6
        void Initialize()
        {
            var su  = column.GetFlowsheet().FlowsheetOptions.SelectedUnitSystem;
            var nf  = column.GetFlowsheet().FlowsheetOptions.NumberFormat;
            var nff = column.GetFlowsheet().FlowsheetOptions.FractionNumberFormat;

            s.CreateAndAddLabelRow(container, "Absorption Column 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.");

            if ((Inspector.Host.Items.Where(x => x.Name.Contains(column.GraphicObject.Tag)).Count() > 0))
            {
                var ctn = new DynamicLayout();
                ctn.BackgroundColor = Colors.LightGrey;
                s.CreateAndAddLabelRow(ctn, "Inspector Reports");
                s.CreateAndAddLabelAndButtonRow(ctn, "An Inspector Report is ready for viewing.", "View Report", null, (btn, e) => {
                    var f = s.GetDefaultEditorForm("Inspector Report for '" + column.GraphicObject.Tag + "'", 1024, 768, Inspector.Window2_Eto.GetInspectorWindow(column), false);
                    f.Show();
                });
                container.Add(ctn);
            }

            s.CreateAndAddLabelRow(container, "Column Details");

            s.CreateAndAddTwoLabelsRow(container, "Type", column.GetDisplayName());

            s.CreateAndAddTwoLabelsRow(container, "Status", column.GraphicObject.Active ? "Active" : "Inactive");

            s.CreateAndAddStringEditorRow(container, "Name", column.GraphicObject.Tag, (TextBox arg3, EventArgs ev) =>
            {
                column.GraphicObject.Tag = arg3.Text;
                column.GetFlowsheet().UpdateInterface();
            }, () => {
                column.GetFlowsheet().UpdateOpenEditForms();
            });

            s.CreateAndAddLabelRow(container, "Property Package");

            var proppacks = column.GetFlowsheet().PropertyPackages.Values.Select((x) => x.Tag).ToList();

            if (proppacks.Count == 0)
            {
                column.GetFlowsheet().ShowMessage("Error: please add at least one Property Package before continuing.", IFlowsheet.MessageType.GeneralError);
            }
            else
            {
                var    pp         = column.PropertyPackage;
                string selectedpp = "";
                if (pp != null)
                {
                    selectedpp = pp.Tag;
                }
                s.CreateAndAddDropDownRow(container, "Property Package", proppacks, proppacks.IndexOf(selectedpp), (DropDown arg1, EventArgs ev) =>
                {
                    if (proppacks.Count > 0)
                    {
                        column.PropertyPackage = (IPropertyPackage)column.GetFlowsheet().PropertyPackages.Values.Where((x) => x.Tag == proppacks[arg1.SelectedIndex]).FirstOrDefault();
                    }
                }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                           {
                               ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke();
                           }
                    });
            }

            s.CreateAndAddLabelRow(container, "Object Properties");

            s.CreateAndAddDropDownRow(container, "Operating Mode", new List <string> {
                "Gas-Liquid Absorption", "Liquid-Liquid Extraction"
            }, (int)column.OperationMode, (arg1, e) => {
                switch (arg1.SelectedIndex)
                {
                case 0:
                    column.OperationMode = AbsorptionColumn.OpMode.Absorber;
                    break;

                case 1:
                    column.OperationMode = AbsorptionColumn.OpMode.Extractor;
                    break;
                }
            });

            s.CreateAndAddButtonRow(container, "Define Number of Stages", null, (arg1, e) =>
            {
                var np                  = new Eto.Forms.NumericStepper();
                np.MinValue             = 3;
                np.MaxValue             = 100;
                np.MaximumDecimalPlaces = 0;
                np.Value                = column.NumberOfStages;
                np.ValueChanged        += (sender, e2) =>
                {
                    var refval            = (int)np.Value;
                    column.NumberOfStages = refval;
                    int ne, nep, dif, i;
                    ne  = refval;
                    nep = column.Stages.Count;
                    dif = ne - nep;
                    if (dif != 0)
                    {
                        if (dif < 0)
                        {
                            column.Stages.RemoveRange(ne - 1, -dif);
                        }
                        else if (dif > 0)
                        {
                            for (i = 0; i <= dif; i++)
                            {
                                column.Stages.Insert(column.Stages.Count - 1, new Stage(Guid.NewGuid().ToString())
                                {
                                    P = 101325, Efficiency = 1.0f
                                });
                                column.Stages[column.Stages.Count - 2].Name = "Stage " + (column.Stages.Count - 2).ToString();
                            }
                        }
                    }
                };

                s.CreateDialog(np, "Set Number of Stages").ShowModal(container);
            });

            s.CreateAndAddButtonRow(container, "Edit Stages", null, (arg1, e) =>
            {
                var sview = DWSIM.UI.Shared.Common.GetDefaultContainer();

                s.CreateAndAddLabelRow(sview, "Edit Stages");
                s.CreateAndAddLabelRow(sview, "Number / Name / Pressure");
                var tlist = new List <TextBox>();
                foreach (var stage in column.Stages)
                {
                    tlist.Add(s.CreateAndAddDoubleTextBoxRow(sview, nf, (column.Stages.IndexOf(stage) + 1).ToString(), stage.Name, cv.ConvertFromSI(su.pressure, stage.P),
                                                             (arg10, arg20) =>
                    {
                        stage.Name = arg10.Text;
                    }, (arg11, arg22) =>
                    {
                        if (s.IsValidDouble(arg11.Text))
                        {
                            stage.P = cv.ConvertToSI(su.pressure, Double.Parse(arg11.Text));
                            if (column.Stages.IndexOf(stage) == 0)
                            {
                                column.CondenserPressure = stage.P;
                            }
                            else if (column.Stages.IndexOf(stage) == column.Stages.Count - 1)
                            {
                                column.ReboilerPressure = stage.P;
                            }
                        }
                    }));
                }
                s.CreateAndAddLabelAndButtonRow(sview, "Interpolate Pressures", "Interpolate", null, (sender2, e2) =>
                {
                    var first = tlist[0].Text.ToDoubleFromCurrent();
                    var last  = tlist[tlist.Count - 1].Text.ToDoubleFromCurrent();
                    var n     = tlist.Count;
                    int i     = 1;
                    for (i = 1; i < n - 1; i++)
                    {
                        tlist[i].Text = (first + (last - first) * i / (n - 1)).ToString(nf);
                    }
                });
                s.CreateAndAddDescriptionRow(sview, "Calculate inner pressures using end stage defined values.");

                var scroll     = new Eto.Forms.Scrollable();
                scroll.Content = sview;

                s.CreateDialog(scroll, "Edit Stages", 600, 600).ShowModal(container);
            });

            var istrs   = column.GraphicObject.InputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Feed")).Select((x2) => x2.AttachedConnector.AttachedFrom.Name).ToList();
            var ostrs   = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Side")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList();
            var dist    = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Top Product")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList();
            var bottoms = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Bottoms Product")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList();

            foreach (var id in istrs)
            {
                if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0)
                {
                    column.MaterialStreams.Add(id, new StreamInformation()
                    {
                        StreamID       = id,
                        ID             = id,
                        StreamType     = StreamInformation.Type.Material,
                        StreamBehavior = StreamInformation.Behavior.Feed
                    });
                }
            }
            foreach (var id in ostrs)
            {
                if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0)
                {
                    column.MaterialStreams.Add(id, new StreamInformation()
                    {
                        StreamID       = id,
                        ID             = id,
                        StreamType     = StreamInformation.Type.Material,
                        StreamBehavior = StreamInformation.Behavior.Sidedraw
                    });
                }
            }
            foreach (var id in dist)
            {
                if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0)
                {
                    column.MaterialStreams.Add(id, new StreamInformation()
                    {
                        StreamID       = id,
                        ID             = id,
                        StreamType     = StreamInformation.Type.Material,
                        StreamBehavior = StreamInformation.Behavior.OverheadVapor
                    });
                }
            }
            foreach (var id in bottoms)
            {
                if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0)
                {
                    column.MaterialStreams.Add(id, new StreamInformation()
                    {
                        StreamID       = id,
                        ID             = id,
                        StreamType     = StreamInformation.Type.Material,
                        StreamBehavior = StreamInformation.Behavior.BottomsLiquid
                    });
                }
            }
            List <string> remove = new List <string>();

            foreach (var si in column.MaterialStreams.Values)
            {
                if (!istrs.Contains(si.StreamID) && !ostrs.Contains(si.StreamID) && !dist.Contains(si.StreamID) && !bottoms.Contains(si.StreamID))
                {
                    remove.Add(si.ID);
                }
                if (!column.GetFlowsheet().SimulationObjects.ContainsKey(si.StreamID))
                {
                    remove.Add(si.ID);
                }
            }
            foreach (var id in remove)
            {
                if (column.MaterialStreams.ContainsKey(id))
                {
                    column.MaterialStreams.Remove(id);
                }
            }

            var stageNames = column.Stages.Select((x) => x.Name).ToList();

            stageNames.Insert(0, "");
            var stageIDs = column.Stages.Select((x) => x.ID).ToList();

            stageIDs.Insert(0, "");

            s.CreateAndAddLabelRow(container, "Streams");

            foreach (var si in column.MaterialStreams.Values)
            {
                if (si.StreamBehavior == StreamInformation.Behavior.Feed)
                {
                    s.CreateAndAddDropDownRow(container, "[FEED] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag,
                                              stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) =>
                    {
                        si.AssociatedStage = stageIDs[arg1.SelectedIndex];
                    });
                }
                else if (si.StreamBehavior == StreamInformation.Behavior.Sidedraw)
                {
                    s.CreateAndAddDropDownRow(container, "[SIDEDRAW] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag,
                                              stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) =>
                    {
                        si.AssociatedStage = stageIDs[arg1.SelectedIndex];
                    });
                }
                else if (si.StreamBehavior == StreamInformation.Behavior.Distillate || si.StreamBehavior == StreamInformation.Behavior.OverheadVapor)
                {
                    s.CreateAndAddDropDownRow(container, "[TOP PRODUCT] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag,
                                              stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) =>
                    {
                        si.AssociatedStage = stageIDs[arg1.SelectedIndex];
                    });
                }
                else if (si.StreamBehavior == StreamInformation.Behavior.BottomsLiquid)
                {
                    s.CreateAndAddDropDownRow(container, "[BOTTOMS PRODUCT] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag,
                                              stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) =>
                    {
                        si.AssociatedStage = stageIDs[arg1.SelectedIndex];
                    });
                }
            }

            s.CreateAndAddLabelRow(container, "Side Draw Specs");
            var sdphases = new List <string>()
            {
                "L", "V"
            };

            foreach (var si in column.MaterialStreams.Values)
            {
                string sp = "L";
                switch (si.StreamPhase)
                {
                case StreamInformation.Phase.L:
                    sp = "L";
                    break;

                case StreamInformation.Phase.V:
                    sp = "V";
                    break;
                }
                if (si.StreamBehavior == StreamInformation.Behavior.Sidedraw)
                {
                    s.CreateAndAddDropDownRow(container, column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag + " / Draw Phase",
                                              sdphases, sdphases.IndexOf(sp), (arg1, arg2) =>
                    {
                        switch (arg1.SelectedIndex)
                        {
                        case 0:
                            si.StreamPhase = StreamInformation.Phase.L;
                            break;

                        case 1:
                            si.StreamPhase = StreamInformation.Phase.V;
                            break;
                        }
                    });
                    s.CreateAndAddTextBoxRow(container, nf, column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag + " / Molar Flow (" + su.molarflow + ")",
                                             cv.ConvertFromSI(su.molarflow, si.FlowRate.Value), (arg1, arg2) =>
                    {
                        if (s.IsValidDouble(arg1.Text))
                        {
                            si.FlowRate.Value = cv.ConvertToSI(su.molarflow, Double.Parse(arg1.Text));
                        }
                    });
                }
            }

            s.CreateAndAddTextBoxRow(container, "N0", "Maximum Iterations", column.MaxIterations,
                                     (sender, e) =>
            {
                if (sender.Text.IsValidDouble())
                {
                    column.MaxIterations = (int)sender.Text.ToDoubleFromCurrent();
                }
            }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                       {
                           ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke();
                       }
                });

            s.CreateAndAddTextBoxRow(container, nf, "Convergence Tolerance (External Loop)", column.ExternalLoopTolerance,
                                     (sender, e) =>
            {
                if (sender.Text.IsValidDouble())
                {
                    column.ExternalLoopTolerance = sender.Text.ToDoubleFromCurrent();
                }
            }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                       {
                           ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke();
                       }
                });

            s.CreateAndAddTextBoxRow(container, nf, "Convergence Tolerance (Internal Loop)", column.InternalLoopTolerance,
                                     (sender, e) =>
            {
                if (sender.Text.IsValidDouble())
                {
                    column.InternalLoopTolerance = sender.Text.ToDoubleFromCurrent();
                }
            }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged)
                       {
                           ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke();
                       }
                });

            s.CreateAndAddEmptySpace(container);
            s.CreateAndAddEmptySpace(container);
            s.CreateAndAddEmptySpace(container);
        }
コード例 #27
0
ファイル: Compounds.cs プロジェクト: gowthamdada/dwsim5
        void Initialize()
        {
            var complist = flowsheet.AvailableCompounds.Values.ToList().OrderBy(x => x.Name).ToList();

            var newlist   = new List <ICompoundConstantProperties>();
            var listitems = new List <CheckBox>();

            container.Padding = 10;

            container.Spacing = new Size(10, 10);

            container.Rows.Add(new TableRow(new Label {
                Text = "Simulation Compounds", Font = new Font(SystemFont.Bold, DWSIM.UI.Shared.Common.GetEditorFontSize())
            }));

            container.Rows.Add(new TableRow(new Label {
                Text = "Check compounds to add them to the simulation, uncheck to remove.", Font = SystemFonts.Label(DWSIM.UI.Shared.Common.GetEditorFontSize() - 2.0f)
            }));
            if (Application.Instance.Platform.IsWpf)
            {
                container.Rows.Add(new TableRow(new Label {
                    Text = "To commit the changes, select another table cell or press ENTER after checking/unchecking the compound. You may have to double-click on the checkbox in order to change its state (checked/unchecked).", Font = SystemFonts.Label(DWSIM.UI.Shared.Common.GetEditorFontSize() - 2.0f)
                }));
            }
            container.Rows.Add(new TableRow(new Label {
                Text = "Number of compounds available: " + complist.Count().ToString(), Font = SystemFonts.Label(DWSIM.UI.Shared.Common.GetEditorFontSize() - 2.0f)
            }));

            var searchcontainer = new DynamicLayout();

            var txtsearch = new Label {
                Text = "Search  ", VerticalAlignment = VerticalAlignment.Center
            };

            txtsearch.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize());
            var edittext = new TextBox {
                Text = "", PlaceholderText = "Search by Name, Formula, CAS ID or Database (press ENTER to search)"
            };

            edittext.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize());

            var tr = new TableRow(txtsearch, edittext);

            searchcontainer.AddRow(tr);

            edittext.KeyDown += (sender, e) =>
            {
                if (e.Key == Keys.Enter)
                {
                    newlist = complist.Where((x) => x.Name.ToLower().Contains(edittext.Text.ToLower()) ||
                                             x.Formula.ToLower().Contains(edittext.Text.ToLower()) ||
                                             x.CAS_Number.ToLower().Contains(edittext.Text.ToLower()) ||
                                             x.CurrentDB.ToLower().Contains(edittext.Text.ToLower()))
                              .ToList().OrderBy((x) => x.Name.Length).ToList();
                    Application.Instance.AsyncInvoke(() => UpdateList(newlist));
                }
            };

            container.Rows.Add(new TableRow(searchcontainer));

            var txt = new Label {
                Text = "Click to view properties of the selected compound", VerticalAlignment = VerticalAlignment.Center
            };

            txt.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize());
            var btn = new Button {
                Width = 200, Height = 26, Text = "View Properties"
            };

            btn.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize());

            btn.Click += (sender, e) =>
            {
                if (listcontainer.SelectedItem == null)
                {
                    return;
                }
                var compound = ((CompoundItem)listcontainer.SelectedItem);
                var form     = s.GetDefaultEditorForm("Compound Properties: " + compound.Text, 800, 600, new CompoundViewer(flowsheet, flowsheet.AvailableCompounds[compound.Text]), false);
                form.Show();
            };

            var cont = new DynamicLayout();

            cont.AddRow(new TableRow(txt, null, btn));

            container.Rows.Add(cont);

            var txt2 = new Label {
                Text = "Load and add compounds to the simulation from JSON files", VerticalAlignment = VerticalAlignment.Center
            };

            txt2.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize());
            var btn2 = new Button {
                Width = 200, Height = 26, Text = "Load from JSON"
            };

            btn2.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize());

            btn2.Click += (sender, e) =>
            {
                Application.Instance.Invoke(() => {
                    ImportFromJSON();
                });
            };

            var cont2 = new DynamicLayout();

            cont2.AddRow(new TableRow(txt2, null, btn2));

            container.Rows.Add(cont2);

            UpdateList(complist);
        }
コード例 #28
0
        } = null;                                                // TODO: Add support

        public MakerForm()
        {
            Title      = "Scratch HTML log maker";
            ClientSize = new Size(800, 600);
            var formLayout = new DynamicLayout();

            Content = formLayout;

            var openFileDialog = new OpenFileDialog {
                MultiSelect = true
            };

            openFileDialog.Filters.Add(new FileFilter("EVTC logs", ".evtc", ".evtc.zip", ".zevtc"));

            var openFilesButton = new Button {
                Text = "Select EVTC logs"
            };
            var processButton = new Button {
                Text = "Create HTML logs"
            };

            var notDoneListBox = new ListBox();
            var doneListBox    = new ListBox();

            doneListBox.DataStore = finishedFileNames.ToArray();

            var splitter = new Splitter {
                Panel1 = notDoneListBox, Panel2 = doneListBox, Position = 400
            };

            formLayout.BeginVertical(spacing: new Size(10, 10));
            formLayout.AddRow(openFilesButton, processButton);
            formLayout.EndVertical();
            formLayout.BeginVertical();
            formLayout.Add(splitter);
            formLayout.EndVertical();

            openFilesButton.Click += (sender, args) =>
            {
                if (openFileDialog.ShowDialog((Control)sender) == DialogResult.Ok)
                {
                    foreach (var file in openFileDialog.Filenames)
                    {
                        notFinishedFileNames.Enqueue(file);
                    }

                    notDoneListBox.DataStore = notFinishedFileNames.Select(Path.GetFileName).ToArray();
                }
            };

            processButton.Click += (sender, args) =>
            {
                Task.Run(() =>
                {
                    var times = new List <(string taskName, double milliseconds)>();
                    var totalTimeStopwatch = Stopwatch.StartNew();

                    var parser    = new EVTCParser();
                    var processor = new LogProcessor();
                    var analysis  = new LogAnalyser();
                    var generator = new HtmlGenerator(ApiData);

                    int finishedTaskCount = 0;
                    while (notFinishedFileNames.Count > 0)
                    {
                        var taskStopwatch = Stopwatch.StartNew();
                        string filename   = "";
                        filename          = notFinishedFileNames.Dequeue();

                        var fileDirectory = Path.GetDirectoryName(filename);
                        var newName       = Path.GetFileNameWithoutExtension(filename);
                        if (newName.EndsWith(".evtc"))
                        {
                            newName = newName.Substring(0, newName.Length - 5);
                        }
                        var resultFilename = Path.Combine(fileDirectory, ResultFilePrefix + newName + ".html");

                        try
                        {
                            var lastElapsed = taskStopwatch.Elapsed;

                            var parsedLog = parser.ParseLog(filename);
                            times.Add(("parsing", (taskStopwatch.Elapsed - lastElapsed).TotalMilliseconds));
                            lastElapsed = taskStopwatch.Elapsed;

                            var processedLog = processor.GetProcessedLog(parsedLog);
                            times.Add(("processing", (taskStopwatch.Elapsed - lastElapsed).TotalMilliseconds));
                            lastElapsed = taskStopwatch.Elapsed;

                            var stats = analysis.GetStatistics(processedLog, ApiData);

                            times.Add(("stats", (taskStopwatch.Elapsed - lastElapsed).TotalMilliseconds));
                            lastElapsed = taskStopwatch.Elapsed;

                            using (var htmlStringWriter = new StreamWriter(resultFilename))
                            {
                                generator.WriteHtml(htmlStringWriter, stats);
                            }

                            times.Add(("html", (taskStopwatch.Elapsed - lastElapsed).TotalMilliseconds));
                            lastElapsed = taskStopwatch.Elapsed;

                            finishedFileNames.Add(resultFilename);
                            Application.Instance.Invoke(() =>
                            {
                                notDoneListBox.DataStore = notFinishedFileNames.Select(Path.GetFileName).ToArray();
                                doneListBox.DataStore    = finishedFileNames.Select(Path.GetFileName).ToArray();
                            });
                        }
                        catch (Exception e)
                        {
                            finishedFileNames.Add($"FAILED: {resultFilename} ({e.Message})");
                            Application.Instance.Invoke(() =>
                            {
                                notDoneListBox.DataStore = notFinishedFileNames.Select(Path.GetFileName).ToArray();
                                doneListBox.DataStore    = finishedFileNames.Select(Path.GetFileName).ToArray();
                            });
                        }
                        Console.WriteLine($"{newName} done, time {taskStopwatch.Elapsed}");
                        finishedTaskCount++;
                    }

                    Console.WriteLine($"All done, total time {totalTimeStopwatch.Elapsed}");

                    foreach ((string taskName, double totalMs) in times.GroupBy(x => x.taskName).Select(x => (x.Key, x.Sum(y => y.milliseconds))).OrderByDescending(x => x.Item2))
                    {
                        Console.WriteLine($"{taskName}, total {totalMs}ms, average {totalMs/Math.Max(finishedTaskCount, 1)}ms");
                    }
                });
            };
        }
コード例 #29
0
ファイル: TextDrawer.cs プロジェクト: andyci/ShowcaseView
        public void Draw(Canvas canvas, bool hasPositionChanged)
        {
            if (ShouldDrawText())
            {
                float[] textPosition = GetBestTextPosition();

                if (!TextUtils.IsEmpty(mTitle))
                {
                    canvas.Save();
                    if (hasPositionChanged)
                    {
                        mDynamicTitleLayout = new DynamicLayout(mTitle, mPaintTitle, (int) textPosition[2], Layout.Alignment.AlignNormal, 1.0f, 1.0f, true);
                    }

                    canvas.Translate(textPosition[0], textPosition[1]);
                    mDynamicTitleLayout.Draw(canvas);
                    canvas.Restore();
                }

                if (!TextUtils.IsEmpty(mDetails))
                {
                    canvas.Save();
                    if (hasPositionChanged)
                    {
                        mDynamicDetailLayout = new DynamicLayout(mDetails, mPaintDetail, (int) textPosition[2], Layout.Alignment.AlignNormal, 1.2f, 1.0f, true);
                    }

                    canvas.Translate(textPosition[0], textPosition[1] + mDynamicTitleLayout.Height);
                    mDynamicDetailLayout.Draw(canvas);
                    canvas.Restore();
                }
            }
        }
コード例 #30
0
ファイル: EtoExtensions.cs プロジェクト: AussieDawn/dwsim5
        public static TextBox CreateAndAddTextBoxRow(this DynamicLayout container, String numberformat, String text, Double currval, Action <TextBox, EventArgs> command, Action keypress = null)
        {
            var txt = new Label {
                Text = text, VerticalAlignment = VerticalAlignment.Center
            };

            txt.Font = new Font(SystemFont.Default, GetEditorFontSize());
            var edittext = new TextBox {
                Text = currval.ToString(numberformat), Style = "textbox-rightalign"
            };

            edittext.Font = new Font(SystemFont.Default, GetEditorFontSize());
            if (GlobalSettings.Settings.EditorTextBoxFixedSize)
            {
                edittext.Width = (int)(sf * 140);
            }

            if (text.Contains("(") && text.Contains(")"))
            {
                var    si             = new SharedClasses.SystemsOfUnits.SI();
                string extractedunits = text.Split('(', ')')[1];
                var    unittype       = si.GetUnitType(extractedunits);
                if (unittype != Interfaces.Enums.UnitOfMeasure.none)
                {
                    var ctxmenu = new ContextMenu();
                    foreach (var item in si.GetUnitSet(unittype))
                    {
                        var mi = new ButtonMenuItem {
                            Text = item
                        };
                        mi.Click += (sender, e) => { edittext.Text = SharedClasses.SystemsOfUnits.Converter.Convert(item, extractedunits, edittext.Text.ParseExpressionToDouble()).ToString(); };
                        ctxmenu.Items.Add(mi);
                    }
                    edittext.KeyUp += (sender, e) => {
                        if (e.Key == Keys.Space)
                        {
                            edittext.Text = edittext.Text.Replace(" ", "");
                            ctxmenu.Show(edittext);
                        }
                    };
                }
            }

            if (command != null)
            {
                edittext.TextChanged += (sender, e) => command.Invoke((TextBox)sender, e);
            }
            if (keypress != null)
            {
                edittext.KeyUp += (sender, e) => { if (e.Key == Keys.Enter)
                                                   {
                                                       keypress.Invoke();
                                                   }
                }
            }
            ;

            var tr = new TableRow(txt, null, edittext);

            container.AddRow(tr);
            container.CreateAndAddEmptySpace();

            return(edittext);
        }
コード例 #31
0
        public CursorSection()
        {
            var layout = new DynamicLayout();

            layout.BeginCentered(spacing: new Size(10, 10), yscale: true);

            var drawable = new CursorDrawable();

            var rect = new Rectangle(0, 0, 100, 50);

            layout.Add("Label");
            layout.BeginVertical(spacing: new Size(20, 20));
            layout.BeginHorizontal();
            int count = 0;

            foreach (var type in GetCursors())
            {
                var cursor = type.cursor;
                var text   = type.name;
                drawable.Rects.Add(new CursorRect {
                    Rectangle = rect, Cursor = cursor, Text = text
                });
                rect.X += rect.Width + 20;

                var label = new Label
                {
                    Size = new Size(100, 50),
                    Text = text,
                    VerticalAlignment = VerticalAlignment.Center,
                    TextAlignment     = TextAlignment.Center,
                    BackgroundColor   = Colors.Silver
                };
                if (cursor == null)
                {
                    label.Cursor = null;
                }
                else
                {
                    label.Cursor = cursor;
                }
                layout.Add(label);

                if (count++ > 3)
                {
                    count   = 0;
                    rect.X  = 0;
                    rect.Y += rect.Height + 20;
                    layout.EndBeginHorizontal();
                }
            }
            layout.EndHorizontal();
            layout.EndVertical();

            layout.Add("Drawable with MouseMove");
            layout.Add(drawable);
            layout.EndCentered();

            drawable.Size = new Size(340, rect.Y + rect.Height + 20);

            Content = layout;
        }
コード例 #32
0
        Control MainContent()
        {
            contentContainer = new Panel();

            // set focus when the form is shown
            Shown += delegate
            {
                SectionList.Focus();
            };
            SectionList.SelectedItemChanged += (sender, e) =>
            {
                try
                {
                    var     item    = SectionList.SelectedItem;
                    Control content = item != null?item.CreateContent() : null;

                    if (navigation != null)
                    {
                        if (content != null)
                        {
                            navigation.Push(content, item != null ? item.Text : null);
                        }
                    }
                    else
                    {
                        contentContainer.Content = content;
                    }
                }
                catch (Exception ex)
                {
                    Log.Write(this, "Error loading section: {0}", ex.GetBaseException());
                    contentContainer.Content = null;
                }

                                #if DEBUG
                GC.Collect();
                GC.WaitForPendingFinalizers();
                                #endif
            };

            if (Splitter.IsSupported())
            {
                var splitter = new Splitter
                {
                    Position   = 200,
                    FixedPanel = SplitterFixedPanel.Panel1,
                    Panel1     = SectionList.Control,
#if MOBILE
                    // for now, don't show log in mobile
                    Panel2 = contentContainer
#else
                    Panel2 = RightPane()
#endif
                };
                return(splitter);
            }
            if (Navigation.IsSupported())
            {
                navigation = new Navigation(SectionList.Control, "Eto.Test");
                return(navigation);
            }
            throw new EtoException("Platform must support splitter or navigation");
        }

        Control RightPane()
        {
            return(new Splitter
            {
                Orientation = SplitterOrientation.Vertical,
                FixedPanel = SplitterFixedPanel.Panel2,
                Panel1 = contentContainer,
                Panel2 = EventLogSection()
            });
        }

        Control EventLogSection()
        {
            var layout = new DynamicLayout {
                Size = new Size(100, 120)
            };

            layout.BeginHorizontal();
            layout.Add(EventLog, true);

            layout.BeginVertical();
            layout.Add(ClearButton());
            layout.Add(null);
            layout.EndVertical();
            layout.EndHorizontal();
            return(layout);
        }

        Control ClearButton()
        {
            var control = new Button
            {
                Text = "Clear"
            };

            control.Click += (sender, e) => EventLog.Text = string.Empty;
            return(control);
        }

        void GenerateMenuToolBar()
        {
            var about = new Actions.About();
            var quit  = new Actions.Quit();

#if DESKTOP
            var menu = new MenuBar();
            // create standard system menu (e.g. for OS X)
            Application.Instance.CreateStandardMenu(menu.Items);

            // add our own items to the menu

            var file = menu.Items.GetSubmenu("&File", 100);
            menu.Items.GetSubmenu("&Edit", 200);
            menu.Items.GetSubmenu("&Window", 900);
            var help = menu.Items.GetSubmenu("&Help", 1000);

            if (Generator.IsMac)
            {
                // have a nice OS X style menu
                var main = menu.Items.GetSubmenu(Application.Instance.Name, 0);
                main.Items.Add(about, 0);
                main.Items.Add(quit, 1000);
            }
            else
            {
                // windows/gtk style window
                file.Items.Add(quit);
                help.Items.Add(about);
            }

            // optional, removes empty submenus and duplicate separators
            menu.Items.Trim();

            Menu = menu;
#endif

            // generate and set the toolbar
            var toolBar = new ToolBar();
            toolBar.Items.Add(quit);
            toolBar.Items.Add(new ButtonToolItem(about));

            ToolBar = toolBar;
        }