예제 #1
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();
        }
예제 #2
0
        public static void Populate(ISimulationObject simobj, DynamicLayout container)
        {
            var su = simobj.GetFlowsheet().FlowsheetOptions.SelectedUnitSystem;
            var nf = simobj.GetFlowsheet().FlowsheetOptions.NumberFormat;

            var spec = (Spec)simobj;

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

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

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

            var objlist = spec.GetFlowsheet().SimulationObjects.Values.Select((x2) => x2.GraphicObject.Tag).ToList();

            objlist.Insert(0, "");
            List <string> proplist = new List <string>();

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

            DropDown spin1 = null, spin2 = null;
            Label    txtval1 = null, txtval2 = null;

            spin1 = s.CreateAndAddDropDownRow(container, "Source Object", objlist, 0, (sender, e) =>
            {
                if (sender.SelectedIndex > 0)
                {
                    if (spec.GetFlowsheet().SimulationObjects.ContainsKey(spec.SourceObjectData.ID))
                    {
                        var prevobj            = spec.GetFlowsheet().SimulationObjects[spec.SourceObjectData.ID];
                        prevobj.IsSpecAttached = false;
                        prevobj.AttachedSpecId = "";
                        prevobj.SpecVarType    = SpecVarType.None;
                    }

                    var obj = spec.GetFlowsheet().GetFlowsheetSimulationObject(objlist[sender.SelectedIndex]);
                    spec.SourceObjectData.ID = obj.Name;

                    obj.IsSpecAttached = true;
                    obj.AttachedSpecId = spec.Name;
                    obj.SpecVarType    = SpecVarType.Source;

                    spec.SourceObject = (DWSIM.SharedClasses.UnitOperations.BaseClass)obj;
                    ((SpecGraphic)spec.GraphicObject).ConnectedToSv = (GraphicObject)obj.GraphicObject;

                    proplist = obj.GetProperties(PropertyType.ALL).ToList();
                    proplist.Insert(0, "");

                    spin2.Items.Clear();
                    spin2.Items.AddRange(proplist.Select(x => new ListItem()
                    {
                        Text = spec.GetFlowsheet().GetTranslatedString(x)
                    }).ToList());

                    if (spec.SourceObjectData.PropertyName != "" && proplist.Contains(spec.SourceObjectData.PropertyName))
                    {
                        spin2.SelectedIndex = (proplist.IndexOf(spec.SourceObjectData.PropertyName));
                    }
                }
                else
                {
                    spin2.Items.Clear();
                }
            });

            spin2 = s.CreateAndAddDropDownRow(container, "Source Property", proplist, 0, (sender, e) =>
            {
                if (sender.SelectedIndex > 0)
                {
                    spec.SourceObjectData.PropertyName = proplist[sender.SelectedIndex];
                    var obj      = spec.GetFlowsheet().SimulationObjects[spec.SourceObjectData.ID];
                    var currval  = Convert.ToDouble(obj.GetPropertyValue(proplist[sender.SelectedIndex], su)).ToString(nf) + " " + obj.GetPropertyUnit(proplist[sender.SelectedIndex], su);
                    txtval1.Text = "Current Value: " + currval;
                }
            });

            txtval1 = container.CreateAndAddLabelRow2("Current Value: N/A");

            if (spec.SourceObjectData.ID != "" && spec.GetFlowsheet().SimulationObjects.ContainsKey(spec.SourceObjectData.ID))
            {
                spin1.SelectedIndex = (objlist.IndexOf(spec.GetFlowsheet().SimulationObjects[spec.SourceObjectData.ID].GraphicObject.Tag));
            }

            List <string> proplist2 = new List <string>();

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

            DropDown spin3 = null, spin4 = null;

            spin3 = s.CreateAndAddDropDownRow(container, "Target Object", objlist, 0, (sender, e) =>
            {
                if (sender.SelectedIndex > 0)
                {
                    if (spec.GetFlowsheet().SimulationObjects.ContainsKey(spec.TargetObjectData.ID))
                    {
                        var prevobj            = spec.GetFlowsheet().SimulationObjects[spec.TargetObjectData.ID];
                        prevobj.IsSpecAttached = false;
                        prevobj.AttachedSpecId = "";
                        prevobj.SpecVarType    = SpecVarType.None;
                    }

                    var obj = spec.GetFlowsheet().GetFlowsheetSimulationObject(objlist[sender.SelectedIndex]);
                    spec.TargetObjectData.ID = obj.Name;

                    obj.IsSpecAttached = true;
                    obj.AttachedSpecId = spec.Name;
                    obj.SpecVarType    = SpecVarType.Target;

                    spec.TargetObject = (DWSIM.SharedClasses.UnitOperations.BaseClass)spec.GetFlowsheet().SimulationObjects[spec.TargetObjectData.ID];
                    ((SpecGraphic)spec.GraphicObject).ConnectedToTv = (GraphicObject)spec.TargetObject.GraphicObject;

                    proplist2 = spec.GetFlowsheet().GetFlowsheetSimulationObject(objlist[sender.SelectedIndex]).GetProperties(PropertyType.WR).ToList();
                    proplist2.Insert(0, "");

                    spin4.Items.Clear();
                    spin4.Items.AddRange(proplist2.Select(x => new ListItem()
                    {
                        Text = spec.GetFlowsheet().GetTranslatedString(x)
                    }).ToList());

                    if (spec.TargetObjectData.PropertyName != "" && proplist2.Contains(spec.TargetObjectData.PropertyName))
                    {
                        spin4.SelectedIndex = (proplist2.IndexOf(spec.TargetObjectData.PropertyName));
                    }
                }
                else
                {
                    spin4.Items.Clear();
                }
            });


            spin4 = s.CreateAndAddDropDownRow(container, "Target Property", proplist2, 0, (sender, e) =>
            {
                if (sender.SelectedIndex > 0)
                {
                    spec.TargetObjectData.PropertyName = proplist2[sender.SelectedIndex];
                    var obj      = spec.GetFlowsheet().SimulationObjects[spec.TargetObjectData.ID];
                    var currval  = Convert.ToDouble(obj.GetPropertyValue(proplist2[sender.SelectedIndex], su)).ToString(nf) + " " + obj.GetPropertyUnit(proplist2[sender.SelectedIndex], su);
                    txtval2.Text = "Current Value: " + currval;
                }
            });

            txtval2 = container.CreateAndAddLabelRow2("Current Value: N/A");

            if (spec.TargetObjectData.ID != "" && spec.GetFlowsheet().SimulationObjects.ContainsKey(spec.TargetObjectData.ID))
            {
                spin3.SelectedIndex = (objlist.IndexOf(spec.GetFlowsheet().SimulationObjects[spec.TargetObjectData.ID].GraphicObject.Tag));
            }

            container.CreateAndAddLabelRow("Expression");

            container.CreateAndAddStringEditorRow2("Y = f(X) = ", "enter a math expression using X as the only variable", spec.Expression, (sender, e) => spec.Expression = sender.Text);
        }
예제 #3
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.)");

            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();
        }
예제 #4
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();
        }
예제 #5
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];
                    UpdateEquation();
                }
            };

            container.CreateAndAddLabelRow("Reaction Balance");

            txtEquation = container.CreateAndAddLabelRow2("");

            container.CreateAndAddLabelRow("Temperature Limits");

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

            container.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);
                                                                                                                                                         }
                                             });
            container.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);
                                                                                                                                                         }
                                             });
            container.CreateAndAddTextBoxRow(nf, "Approach (" + su.temperature + ")", rx.Approach.ConvertFromSI(su.temperature), (sender, e) => { if (sender.Text.IsValidDouble())
                                                                                                                                                  {
                                                                                                                                                      rx.Approach = sender.Text.ToDoubleFromCurrent().ConvertToSI(su.temperature);
                                                                                                                                                  }
                                             });

            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("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;
                }
            };

            UpdateEquation();
        }
예제 #6
0
        public void UpdatePropertiesLayout()
        {
            Application.Instance.Invoke(() =>
            {
                try
                {
                    var pm = (PlotModel)Chart.PlotModel;

                    var pl = new DynamicLayout();

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

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

                    pl.CreateAndAddLabelRow("General");

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

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

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

                        var objlist = new List <String>();

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

                        string selobj = "";

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

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

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

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

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

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


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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    var i = 0;

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

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

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

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

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

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

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

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

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

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

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

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

                    Splitter.Panel2 = new Scrollable {
                        Content = pl
                    };
                    Splitter.Panel2.Width = 350;
                }
                catch (Exception ex)
                {
                    Flowsheet.ShowMessage("Error updating chart property list: " + ex.Message, Interfaces.IFlowsheet.MessageType.GeneralError);
                }
            });
        }