コード例 #1
0
ファイル: EtoExtensions.cs プロジェクト: nnunix/dwsim5
        public static TableRow CreateAndAddTextBoxAndThreeButtonsRow(this DynamicLayout container, String label, String buttonlabel, String imageResID, String buttonlabel2, String imageResID2, String buttonlabel3, String imageResID3, Action <TextBox, EventArgs> command0, Action <Button, EventArgs> command, Action <Button, EventArgs> command2, Action <Button, EventArgs> command3)
        {
            var txt = new TextBox {
                Width = 300, Text = label
            };

            txt.Font = new Font(SystemFont.Default, GetEditorFontSize());
            var btn = new Button {
                Width = 100, Text = buttonlabel
            };
            var btn2 = new Button {
                Width = 100, Text = buttonlabel2
            };
            var btn3 = new Button {
                Width = 100, Text = buttonlabel3
            };

            if (imageResID != null)
            {
                btn.Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imageResID), 22, 22, ImageInterpolation.Default);
            }
            if (imageResID2 != null)
            {
                btn2.Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imageResID2), 22, 22, ImageInterpolation.Default);
            }
            if (imageResID3 != null)
            {
                btn3.Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imageResID3), 22, 22, ImageInterpolation.Default);
            }

            if (command0 != null)
            {
                txt.TextChanged += (sender, e) => command0.Invoke((TextBox)sender, e);
            }
            if (command != null)
            {
                btn.Click += (sender, e) => command.Invoke((Button)sender, e);
            }
            if (command2 != null)
            {
                btn2.Click += (sender, e) => command2.Invoke((Button)sender, e);
            }
            if (command3 != null)
            {
                btn3.Click += (sender, e) => command3.Invoke((Button)sender, e);
            }

            var tr = new TableRow(txt, GetPlaceHolderLabel(), null, btn, GetPlaceHolderLabel(), btn2, GetPlaceHolderLabel(), btn3);

            if (Application.Instance.Platform.IsMac)
            {
                txt.Height = 28;
            }
            container.AddRow(tr);
            container.CreateAndAddEmptySpace();
            return(tr);
        }
コード例 #2
0
        public static Label CreateAndAddLabelRow(this DynamicLayout container, String text)
        {
            var label = new Label {
                Text = text, Font = SystemFonts.Bold(null, FontDecoration.None), Wrap = WrapMode.Word
            };

            container.AddRow(new TableRow(label));
            container.CreateAndAddEmptySpace();
            return(label);
        }
コード例 #3
0
        public static Label CreateAndAddLabelRow2(this DynamicLayout container, String text)
        {
            var lbl = new Label {
                Text = text, Wrap = WrapMode.Word
            };

            container.AddRow(new TableRow(lbl));
            container.CreateAndAddEmptySpace();
            return(lbl);
        }
コード例 #4
0
ファイル: EtoExtensions.cs プロジェクト: nnunix/dwsim5
        public static Label CreateAndAddLabelRow2(this DynamicLayout container, String text)
        {
            var lbl = new Label {
                Text = text, Wrap = WrapMode.Word
            };

            lbl.Font = new Font(SystemFont.Default, GetEditorFontSize());
            container.AddRow(new TableRow(lbl));
            container.CreateAndAddEmptySpace();
            return(lbl);
        }
コード例 #5
0
        public static void CreateAndAddLabelAndControlRow(this DynamicLayout container, String label, Control control)
        {
            var txt = new Label {
                Text = label, VerticalAlignment = VerticalAlignment.Center
            };

            control.Width = 200;

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

            container.AddRow(tr);
            container.CreateAndAddEmptySpace();
        }
コード例 #6
0
ファイル: EtoExtensions.cs プロジェクト: nnunix/dwsim5
        public static TableRow CreateAndAddLabelAndTwoButtonsRow(this DynamicLayout container, String label, String buttonlabel, String imageResID, String buttonlabel2, String imageResID2, Action <Button, EventArgs> command, Action <Button, EventArgs> command2)
        {
            var txt = new Label {
                Text = label, VerticalAlignment = VerticalAlignment.Center
            };

            txt.Font = new Font(SystemFont.Default, GetEditorFontSize());
            var btn = new Button {
                Text = buttonlabel
            };
            var btn2 = new Button {
                Text = buttonlabel2
            };

            btn.Font = new Font(SystemFont.Default, GetEditorFontSize());
            if (GlobalSettings.Settings.EditorTextBoxFixedSize)
            {
                btn.Width = 100;
            }

            btn2.Font = new Font(SystemFont.Default, GetEditorFontSize());
            if (GlobalSettings.Settings.EditorTextBoxFixedSize)
            {
                btn2.Width = 100;
            }

            if (imageResID != null)
            {
                btn.Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imageResID), 22, 22, ImageInterpolation.Default);
            }
            if (imageResID2 != null)
            {
                btn.Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imageResID2), 22, 22, ImageInterpolation.Default);
            }

            if (command != null)
            {
                btn.Click += (sender, e) => command.Invoke((Button)sender, e);
            }
            if (command2 != null)
            {
                btn2.Click += (sender, e) => command2.Invoke((Button)sender, e);
            }

            var tr = new TableRow(txt, null, btn, GetPlaceHolderLabel(), btn2);

            container.AddRow(tr);
            container.CreateAndAddEmptySpace();
            return(tr);
        }
コード例 #7
0
        public static Label CreateAndAddTwoLabelsRow(this DynamicLayout container, String text1, String text2)
        {
            var txt = new Label {
                Text = text1, VerticalAlignment = VerticalAlignment.Center
            };
            var txt2 = new Label {
                Text = text2, Width = 200, VerticalAlignment = VerticalAlignment.Center
            };

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

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

            return(txt2);
        }
コード例 #8
0
        public static Label CreateAndAddTwoLabelsRow2(this DynamicLayout container, String text1, String text2)
        {
            var txt = new Label {
                Text = text1, VerticalAlignment = VerticalAlignment.Center, Font = SystemFonts.Bold(null, FontDecoration.None)
            };
            var txt2 = new Label {
                Text = text2, Width = 350, VerticalAlignment = VerticalAlignment.Center
            };

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

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

            return(txt2);
        }
コード例 #9
0
        public static CheckBox CreateAndAddCheckBoxRow(this DynamicLayout container, String text, bool value, Action <CheckBox, EventArgs> command)
        {
            var check = new CheckBox {
                Text = text, Checked = value
            };

            if (command != null)
            {
                check.CheckedChanged += (sender, e) => command.Invoke((CheckBox)sender, e);
            }

            container.AddRow(new TableRow(check));
            container.CreateAndAddEmptySpace();

            return(check);
        }
コード例 #10
0
ファイル: EtoExtensions.cs プロジェクト: nnunix/dwsim5
        public static void CreateAndAddLabelAndControlRow(this DynamicLayout container, String label, Control control)
        {
            var txt = new Label {
                Text = label, VerticalAlignment = VerticalAlignment.Center
            };

            txt.Font = new Font(SystemFont.Default, GetEditorFontSize());
            if (GlobalSettings.Settings.EditorTextBoxFixedSize)
            {
                control.Width = 140;
            }

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

            container.AddRow(tr);
            container.CreateAndAddEmptySpace();
        }
コード例 #11
0
        public static TextBox CreateAndAddFullTextBoxRow(this DynamicLayout container, String text, Action <TextBox, EventArgs> command)
        {
            var edittext = new TextBox {
                Text = text
            };

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

            var tr = new TableRow(edittext);

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

            return(edittext);
        }
コード例 #12
0
ファイル: EtoExtensions.cs プロジェクト: nnunix/dwsim5
        public static DropDown CreateAndAddDropDownRow(this DynamicLayout container, String text, List <String> options, int position, Action <DropDown, EventArgs> command, Action keypress = null)
        {
            var txt = new Label {
                Text = text, VerticalAlignment = VerticalAlignment.Center
            };

            txt.Font = new Font(SystemFont.Default, GetEditorFontSize());
            var drop = new DropDown();

            drop.Font = new Font(SystemFont.Default, GetEditorFontSize());
            if (!Eto.Forms.Application.Instance.Platform.IsGtk)
            {
                if (GlobalSettings.Settings.EditorTextBoxFixedSize)
                {
                    drop.Width = 140;
                }
            }

            foreach (var item in options)
            {
                drop.Items.Add(new ListItem()
                {
                    Key = item, Text = item
                });
            }

            drop.SelectedIndex = position;

            if (command != null)
            {
                drop.SelectedIndexChanged += (sender, e) => command.Invoke((DropDown)sender, e);
            }
            if (keypress != null)
            {
                drop.SelectedIndexChanged += (sender, e) => keypress.Invoke();
            }

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

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

            return(drop);
        }
コード例 #13
0
        public static TextArea CreateAndAddMultilineTextBoxRow(this DynamicLayout container, String text, bool ro, bool autosized, Action <TextArea, EventArgs> command)
        {
            var edittext = new TextArea {
                Text = text, ReadOnly = ro
            };

            if (command != null)
            {
                edittext.TextChanged += (sender, e) => command.Invoke((TextArea)sender, e);
            }

            var tr = new TableRow(edittext);

            tr.ScaleHeight = autosized;
            container.AddRow(tr);
            container.CreateAndAddEmptySpace();

            return(edittext);
        }
コード例 #14
0
        public static TableRow CreateAndAddTextBoxAndTwoButtonsRow(this DynamicLayout container, String label, String buttonlabel, String imageResID, String buttonlabel2, String imageResID2, Action <TextBox, EventArgs> command0, Action <Button, EventArgs> command, Action <Button, EventArgs> command2)
        {
            var txt = new TextBox {
                Width = (int)(sf * 250), Text = label
            };

            txt.Font = new Font(SystemFont.Default, GetEditorFontSize());
            var btn = new Button {
                Width = (int)(sf * 100), Text = buttonlabel
            };
            var btn2 = new Button {
                Width = (int)(sf * 100), Text = buttonlabel2
            };

            if (imageResID != null)
            {
                btn.Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imageResID), (int)(sf * 22), (int)(sf * 22), ImageInterpolation.Default);
            }
            if (imageResID2 != null)
            {
                btn.Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imageResID2), (int)(sf * 22), (int)(sf * 22), ImageInterpolation.Default);
            }

            if (command0 != null)
            {
                txt.TextChanged += (sender, e) => command0.Invoke((TextBox)sender, e);
            }
            if (command != null)
            {
                btn.Click += (sender, e) => command.Invoke((Button)sender, e);
            }
            if (command2 != null)
            {
                btn2.Click += (sender, e) => command2.Invoke((Button)sender, e);
            }

            var tr = new TableRow(txt, GetPlaceHolderLabel(), null, btn, GetPlaceHolderLabel(), btn2);

            container.AddRow(tr);
            container.CreateAndAddEmptySpace();
            return(tr);
        }
コード例 #15
0
ファイル: EtoExtensions.cs プロジェクト: nnunix/dwsim5
        public static Label CreateAndAddTwoLabelsRow(this DynamicLayout container, String text1, String text2)
        {
            var txt = new Label {
                Text = text1, VerticalAlignment = VerticalAlignment.Center
            };

            txt.Font = new Font(SystemFont.Default, GetEditorFontSize());
            var txt2 = new Label {
                Text = text2, Width = 140, VerticalAlignment = VerticalAlignment.Center
            };

            txt2.Font = new Font(SystemFont.Default, GetEditorFontSize());

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

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

            return(txt2);
        }
コード例 #16
0
        public static TextArea CreateAndAddMultilineMonoSpaceTextBoxRow(this DynamicLayout container, String text, int height, bool ro, Action <TextArea, EventArgs> command)
        {
            var edittext = new TextArea {
                Text = text, ReadOnly = ro, Height = height
            };

            edittext.Font = Fonts.Monospace(GlobalSettings.Settings.ResultsReportFontSize);

            if (command != null)
            {
                edittext.TextChanged += (sender, e) => command.Invoke((TextArea)sender, e);
            }

            var tr = new TableRow(edittext);

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

            return(edittext);
        }
コード例 #17
0
        public static TextBox CreateAndAddStringEditorRow2(this DynamicLayout container, String text, String placeholder, String currval, Action <TextBox, EventArgs> command)
        {
            var txt = new Label {
                Text = text, VerticalAlignment = VerticalAlignment.Center
            };
            var edittext = new TextBox {
                Text = currval, PlaceholderText = placeholder
            };

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

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

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

            return(edittext);
        }
コード例 #18
0
ファイル: EtoExtensions.cs プロジェクト: w8w8w8/dwsim5
        public static ColorPicker CreateAndAddColorPickerRow(this DynamicLayout container, String text, Color currval, Action <ColorPicker, EventArgs> command)
        {
            var txt = new Label {
                Text = text, VerticalAlignment = VerticalAlignment.Center
            };
            var editor = new ColorPicker {
                Width = 200, Value = currval
            };

            if (command != null)
            {
                editor.ValueChanged += (sender, e) => command.Invoke((ColorPicker)sender, e);
            }

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

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

            return(editor);
        }
コード例 #19
0
        public static TextBox CreateAndAddTextBoxRow2(this DynamicLayout container, String numberformat, String text, Double currval, Action <TextBox, EventArgs> command)
        {
            var txt = new Label {
                Text = text, VerticalAlignment = VerticalAlignment.Center
            };
            var edittext = new TextBox {
                Text = currval.ToString(numberformat), Width = 200, Style = "textbox-rightalign"
            };

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

            var tr = new TableRow(txt, edittext);

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

            return(edittext);
        }
コード例 #20
0
ファイル: EtoExtensions.cs プロジェクト: w8w8w8/dwsim5
        public static NumericStepper CreateAndAddNumericEditorRow(this DynamicLayout container, String text, double currval, double minval, double maxval, int decimalplaces, Action <NumericStepper, EventArgs> command)
        {
            var txt = new Label {
                Text = text, VerticalAlignment = VerticalAlignment.Center
            };
            var editor = new NumericStepper {
                Width = 200, Value = currval, DecimalPlaces = decimalplaces, MinValue = minval, MaxValue = maxval
            };

            if (command != null)
            {
                editor.ValueChanged += (sender, e) => command.Invoke((NumericStepper)sender, e);
            }

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

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

            return(editor);
        }
コード例 #21
0
ファイル: EtoExtensions.cs プロジェクト: nnunix/dwsim5
        public static CheckBox CreateAndAddCheckBoxRow(this DynamicLayout container, String text, bool value, Action <CheckBox, EventArgs> command, Action keypress = null)
        {
            var check = new CheckBox {
                Text = text, Checked = value
            };

            check.Font = new Font(SystemFont.Default, GetEditorFontSize());

            if (command != null)
            {
                check.CheckedChanged += (sender, e) => command.Invoke((CheckBox)sender, e);
            }
            if (keypress != null)
            {
                check.CheckedChanged += (sender, e) => keypress.Invoke();
            }

            container.AddRow(new TableRow(check));
            container.CreateAndAddEmptySpace();

            return(check);
        }
コード例 #22
0
ファイル: EtoExtensions.cs プロジェクト: nnunix/dwsim5
        public static TextBox CreateAndAddLabelAndTextBoxAndButtonRow(this DynamicLayout container, String label, String textboxvalue, String buttonlabel, String imageResID, Action <TextBox, EventArgs> txteditcommand, Action <Button, EventArgs> command)
        {
            var txt = new Label {
                Text = label, VerticalAlignment = VerticalAlignment.Center
            };

            txt.Font = new Font(SystemFont.Default, GetEditorFontSize());
            var tbox = new TextBox {
                Text = textboxvalue
            };

            tbox.Font = new Font(SystemFont.Default, GetEditorFontSize());
            var btn = new Button {
                Width = 80, Text = buttonlabel
            };

            if (imageResID != null)
            {
                btn.Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imageResID), 22, 22, ImageInterpolation.Default);
            }

            if (txteditcommand != null)
            {
                tbox.TextChanged += (sender, e) => txteditcommand.Invoke((TextBox)sender, e);
            }
            if (command != null)
            {
                btn.Click += (sender, e) => command.Invoke((Button)sender, e);
            }

            var tr = new TableRow(txt, GetPlaceHolderLabel(), tbox, GetPlaceHolderLabel(), btn);

            tr.Cells[2].ScaleWidth = true;

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

            return(tbox);
        }
コード例 #23
0
ファイル: EtoExtensions.cs プロジェクト: nnunix/dwsim5
        public static TextBox CreateAndAddStringEditorRow(this DynamicLayout container, String text, String 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, Width = 140
            };

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

            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);
        }
コード例 #24
0
        public static Button CreateAndAddButtonRow(this DynamicLayout container, String buttonlabel, String imageResID, Action <Button, EventArgs> command)
        {
            var btn = new Button {
                Width = 200, Text = buttonlabel
            };

            if (imageResID != null)
            {
                btn.Image = new Bitmap(Eto.Drawing.Bitmap.FromResource(imageResID), 22, 22, ImageInterpolation.Default);
            }

            if (command != null)
            {
                btn.Click += (sender, e) => command.Invoke((Button)sender, e);
            }

            var tr = new TableRow(btn);

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

            return(btn);
        }
コード例 #25
0
        public static ListBox CreateAndAddListBoxRow(this DynamicLayout container, int height, String[] listitems, Action <ListBox, EventArgs> command)
        {
            var lbox = new ListBox {
                Height = height
            };

            foreach (var item in listitems)
            {
                lbox.Items.Add(item);
            }

            if (command != null)
            {
                lbox.SelectedIndexChanged += (sender, e) => command.Invoke((ListBox)sender, e);
            }

            var tr = new TableRow(lbox);

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

            return(lbox);
        }
コード例 #26
0
        void Initialize()
        {
            rxcontainer = new DynamicLayout();
            rscontainer = new DynamicLayout();

            if (flowsheet.ReactionSets.Count == 0)
            {
                flowsheet.ReactionSets.Add("DefaultSet", new ReactionSet("DefaultSet", "Default Set", ""));
            }

            container.CreateAndAddLabelRow("Reactions");

            CreateReactionsList();

            container.CreateAndAddControlRow(rxcontainer);

            container.CreateAndAddLabelRow("Add a Reaction");

            var btnAddConv = container.CreateAndAddLabelAndButtonRow("Add New Conversion Reaction", "New Conversion Reaction", null, (sender, e) =>
            {
                var _rx = new Reaction("NewConvReac", Guid.NewGuid().ToString(), "")
                {
                    ReactionType = Interfaces.Enums.ReactionType.Conversion
                };
                var myview = s.GetDefaultContainer();
                var cre    = new ConversionReaction(flowsheet, _rx, myview);
                Form alert = null;
                myview.CreateAndAddTwoButtonsRow("Cancel", null, "Add", null, (sender2, e2) => alert.Close(),
                                                 (sender2, e2) =>
                {
                    _rx = (Reaction)cre.rx;
                    flowsheet.Reactions.Add(_rx.ID, _rx);
                    flowsheet.ReactionSets["DefaultSet"].Reactions.Add(_rx.ID, new ReactionSetBase(_rx.ID, 0, true));
                    CreateReactionsList();
                    alert.Close();
                });
                alert        = s.GetDefaultEditorForm("Add Conversion Reaction", 500, 400, myview);
                alert.Shown += (s1, e1) =>
                {
                    myview.Invalidate();
                    alert.Height = myview.Height + 40;
                };
                alert.Topmost = true;
                alert.Show();
            });

            var btnAddEq = container.CreateAndAddLabelAndButtonRow("Add New Equilibrium Reaction", "New Equilibrium Reaction", null, (sender, e) =>
            {
                var _rx = new Reaction("NewEqReac", Guid.NewGuid().ToString(), "")
                {
                    ReactionType = Interfaces.Enums.ReactionType.Equilibrium
                };
                var myview = s.GetDefaultContainer();
                var cre    = new EquilibriumReaction(flowsheet, _rx, myview);
                Form alert = null;
                myview.CreateAndAddTwoButtonsRow("Cancel", null, "Add", null, (sender2, e2) => alert.Close(),
                                                 (sender2, e2) =>
                {
                    _rx = (Reaction)cre.rx;
                    flowsheet.Reactions.Add(_rx.ID, _rx);
                    flowsheet.ReactionSets["DefaultSet"].Reactions.Add(_rx.ID, new ReactionSetBase(_rx.ID, 0, true));
                    CreateReactionsList();
                    alert.Close();
                });
                alert        = s.GetDefaultEditorForm("Add Equilibrium Reaction", 500, 400, myview);
                alert.Shown += (s1, e1) =>
                {
                    myview.Invalidate();
                    alert.Height = myview.Height + 40;
                };
                alert.Topmost = true;
                alert.Show();
            });

            var btnAddKin = container.CreateAndAddLabelAndButtonRow("Add New Kinetic Reaction", "New Kinetic Reaction", null, (sender, e) =>
            {
                var _rx = new Reaction("NewKinReac", Guid.NewGuid().ToString(), "")
                {
                    ReactionType = Interfaces.Enums.ReactionType.Kinetic
                };
                var myview = s.GetDefaultContainer();
                var cre    = new KineticReaction(flowsheet, _rx, myview);
                Form alert = null;
                myview.CreateAndAddTwoButtonsRow("Cancel", null, "Add", null, (sender2, e2) => alert.Close(),
                                                 (sender2, e2) =>
                {
                    _rx = (Reaction)cre.rx;
                    flowsheet.Reactions.Add(_rx.ID, _rx);
                    flowsheet.ReactionSets["DefaultSet"].Reactions.Add(_rx.ID, new ReactionSetBase(_rx.ID, 0, true));
                    CreateReactionsList();
                    alert.Close();
                });
                alert        = s.GetDefaultEditorForm("Add Kinetic Reaction", 850, 760, myview);
                alert.Shown += (s1, e1) =>
                {
                    myview.Invalidate();
                    alert.Height = myview.Height + 40;
                };
                alert.Topmost = true;
                alert.Show();
            });

            var btnAddHC = container.CreateAndAddLabelAndButtonRow("Add New Heterogeneous Catalytic Reaction", "New HetCat Reaction", null, (sender, e) =>
            {
                var _rx = new Reaction("NewHetCatReac", Guid.NewGuid().ToString(), "")
                {
                    ReactionType = Interfaces.Enums.ReactionType.Heterogeneous_Catalytic
                };
                var myview = s.GetDefaultContainer();
                var cre    = new HetCatReaction(flowsheet, _rx, myview);
                Form alert = null;
                myview.CreateAndAddTwoButtonsRow("Cancel", null, "Add", null, (sender2, e2) => alert.Close(),
                                                 (sender2, e2) =>
                {
                    _rx = (Reaction)cre.rx;
                    flowsheet.Reactions.Add(_rx.ID, _rx);
                    flowsheet.ReactionSets["DefaultSet"].Reactions.Add(_rx.ID, new ReactionSetBase(_rx.ID, 0, true));
                    CreateReactionsList();
                    alert.Close();
                });
                alert        = s.GetDefaultEditorForm("Add Heterogeneous Catalytic Reaction", 850, 690, myview);
                alert.Shown += (s1, e1) =>
                {
                    myview.Invalidate();
                    alert.Height = myview.Height + 40;
                };
                alert.Topmost = true;
                alert.Show();
            });

            container.CreateAndAddEmptySpace();

            container.CreateAndAddLabelRow("Reaction Sets");

            container.CreateAndAddControlRow(rscontainer);

            container.CreateAndAddLabelRow("Add a Reaction Set");

            container.CreateAndAddLabelAndButtonRow("Add New Reaction Set", "New Reaction Set", null, (sender, e) =>
            {
                var rsid = Guid.NewGuid().ToString();
                flowsheet.ReactionSets.Add(rsid, new ReactionSet(rsid, "NewReactionSet", ""));
                flowsheet.UpdateEditorPanels.Invoke();
                CreateReactionSetsList();
            });

            CreateReactionSetsList();
        }
コード例 #27
0
        void Initialize()
        {
            container.CreateAndAddLabelRow("Reaction ID");

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

            container.CreateAndAddLabelRow("Compounds and Stoichiometry (Include / Name / Stoich. Coeff. / Direct Order Exponent / Reverse Order Exponent)");

            var compcontainer = new DynamicLayout();

            compcontainer.BackgroundColor = Colors.White;

            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 = 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 = 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 = 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;
                    }
                };

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

            container.CreateAndAddControlRow(compcontainer);
            container.CreateAndAddEmptySpace();

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

            comps.Insert(0, "");

            container.CreateAndAddLabelRow("Base Compound");

            var basecompselector = container.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];
                }
            };

            container.CreateAndAddLabelRow("Reaction Balance");

            txtEquation = container.CreateAndAddLabelRow2("");

            container.CreateAndAddLabelRow("Reaction Phase");

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

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

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

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

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

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

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

            container.CreateAndAddLabelRow("Reaction Basis");

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

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

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

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

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

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

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

            case Interfaces.Enums.ReactionBasis.PartialPress:
                rxphaseselector.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;
                }
            };

            container.CreateAndAddLabelRow("Kinetic Parameters");

            container.CreateAndAddLabelRow2("Direct and Reverse Reactions Velocity Constants (k = A*exp(-E/RT), E in J/mol and T in K)");

            container.CreateAndAddStringEditorRow2("Direct Reaction 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;
                }
            });

            container.CreateAndAddStringEditorRow2("Direct Reaction 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;
                }
            });

            container.CreateAndAddStringEditorRow2("Reverse Reaction 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;
                }
            });

            container.CreateAndAddStringEditorRow2("Reverse Reaction E", "", 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;
                }
            });

            container.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, "");

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

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

            UpdateEquation();
        }
コード例 #28
0
ファイル: Equilibrium.cs プロジェクト: AussieDawn/dwsim5
        void Initialize()
        {
            container.CreateAndAddLabelRow("Reaction ID");

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

            container.CreateAndAddLabelRow("Compounds and Stoichiometry (Include / Name / Stoich. Coeff.)");

            var compcontainer = new DynamicLayout();

            compcontainer.BackgroundColor = Colors.White;

            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 * 50), 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;
                    }
                };
                compcontainer.Add(new TableRow(chk, null, sc));
            }

            container.CreateAndAddControlRow(compcontainer);
            container.CreateAndAddEmptySpace();

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

            comps.Insert(0, "");

            container.CreateAndAddLabelRow("Base Compound");

            var basecompselector = container.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];
                }
            };

            container.CreateAndAddLabelRow("Reaction Balance");

            txtEquation = container.CreateAndAddLabelRow2("");

            container.CreateAndAddLabelRow("Reaction Phase");

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

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

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

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

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

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

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

            UpdateEquation();
        }
コード例 #29
0
        void Initialize()
        {
            container.CreateAndAddLabelRow("Reaction ID");

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

            container.CreateAndAddLabelRow("Compounds and Stoichiometry (Include / Name / Heat of Formation (kJ/kg) / Stoich. Coeff.)");

            var compcontainer = new DynamicLayout();
            //compcontainer.BackgroundColor = Colors.White;

            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 * 50), 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 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));
            }

            container.CreateAndAddControlRow(compcontainer);
            container.CreateAndAddEmptySpace();

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

            comps.Insert(0, "");

            container.CreateAndAddLabelRow("Base Compound");

            var basecompselector = container.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];
                }
            };

            container.CreateAndAddLabelRow("Reaction Balance");

            txtEquation = container.CreateAndAddLabelRow2("");

            container.CreateAndAddLabelRow("Reaction Phase");

            var rxphaseselector = container.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;
                }
            };

            container.CreateAndAddLabelRow("Reaction Basis");

            var rxbasisselector = container.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;
                }
            };

            container.CreateAndAddLabelRow("Rate Expressions");

            container.CreateAndAddLabelRow2("Reaction Rate Numerator Expression:");

            container.CreateAndAddMultilineTextBoxRow(rx.RateEquationNumerator, false, false, (sender, e) => rx.RateEquationNumerator = sender.Text);

            container.CreateAndAddLabelRow2("Reaction Rate Denominator Expression:");

            container.CreateAndAddMultilineTextBoxRow(rx.RateEquationDenominator, false, false, (sender, e) => rx.RateEquationDenominator = sender.Text);

            container.CreateAndAddDescriptionRow("Reaction Rate (r) = f(T, Ri, Pi) = Numerator / Denominator");

            container.CreateAndAddDescriptionRow("Expression Variables: Temperature (T) in K, reactant amounts (R1, R2, ..., Rn) and product amounts (P1, P2, ..., Pn in the selected amount units, Reaction Rate (r) in the selected velocity units.");

            container.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, "");

            container.CreateAndAddDropDownRow("Amount Units", units, units.IndexOf(rx.ConcUnit), (sender, e) => rx.ConcUnit = sender.SelectedValue.ToString());

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

            units2.Insert(0, "");

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

            UpdateEquation();
        }
コード例 #30
0
ファイル: ReactionSet.cs プロジェクト: up2038292/dwsim6
        void Initialize()
        {
            container.CreateAndAddLabelRow("Reaction Set Details");

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

            txt1.Enabled = (rset.ID != "DefaultSet");

            var txt2 = container.CreateAndAddStringEditorRow2("Description", "", rset.Description, (sender, e) => { rset.Description = sender.Text; });

            txt2.Enabled = (rset.ID != "DefaultSet");

            container.CreateAndAddLabelRow("Reaction Active in Set / Reaction Name / Sequence #)");

            var compcontainer = new DynamicLayout();
            //compcontainer.BackgroundColor = Colors.White;

            Double val;

            foreach (IReaction item in flowsheet.Reactions.Values)
            {
                var chk = new CheckBox()
                {
                    Text = item.Name, Checked = (rset.Reactions.ContainsKey(item.ID) ? rset.Reactions[item.ID].IsActive : false)
                };
                chk.CheckedChanged += (sender, e) =>
                {
                    if (!rset.Reactions.ContainsKey(item.ID))
                    {
                        rset.Reactions.Add(item.ID, new DWSIM.Thermodynamics.BaseClasses.ReactionSetBase(item.ID, 0, chk.Checked.GetValueOrDefault()));
                    }
                    else
                    {
                        rset.Reactions[item.ID].IsActive = chk.Checked.GetValueOrDefault();
                    }
                };

                var sc = new TextBox()
                {
                    Width = 50, Text = (rset.Reactions.ContainsKey(item.ID) ? (rset.Reactions[item.ID].Rank.ToString()) : 0.0f.ToString())
                };

                sc.TextChanged += (sender, e) =>
                {
                    if (Double.TryParse(sc.Text.ToString(), out val))
                    {
                        sc.TextColor = SystemColors.ControlText;
                        if (!rset.Reactions.ContainsKey(item.ID))
                        {
                            rset.Reactions.Add(item.ID, new DWSIM.Thermodynamics.BaseClasses.ReactionSetBase(item.ID, int.Parse(sc.Text), true));
                        }
                        else
                        {
                            rset.Reactions[item.ID].Rank = int.Parse(sc.Text);
                        }
                    }
                    else
                    {
                        sc.TextColor = Colors.Red;
                    }
                };
                compcontainer.Add(new TableRow(chk, null, sc));
            }

            container.CreateAndAddControlRow(compcontainer);
            container.CreateAndAddEmptySpace();
        }