/// <summary> /// Creates new image display form. /// </summary> /// <param name="title">Window title.</param> public ImageForm(string title = "") { Title = title; ClientSize = new Size(640, 480); imageView = new ImageView { Image = bmp }; Content = new Scrollable { Content = imageView }; }
void LogEvents(Scrollable control) { control.Scroll += delegate(object sender, ScrollEventArgs e) { Log.Write(control, "Scroll, ScrollPosition: {0}", e.ScrollPosition); }; }
Control DefaultScrollable() { var scrollable = new Scrollable{ Size = new Size(100, 200) }; LogEvents (scrollable); var playout = new PixelLayout(scrollable); playout.Add (new LabelSection{ Size = new Size(400, 400)}, 0, 0); return playout.Container; }
Control LineScrollable() { var scrollable = new Scrollable{ Size = new Size(100, 200), Border = BorderType.Line }; LogEvents (scrollable); var playout = new PixelLayout(scrollable); playout.Add (new LabelSection{ Size = new Size(400, 400)}, 0, 0); return playout.Container; }
Control BezelScrollable() { var scrollable = new Scrollable { Size = new Size(100, 200), Border = BorderType.Bezel }; LogEvents(scrollable); var playout = new PixelLayout(); playout.Add(new LabelSection { Size = new Size(400, 400) }, 0, 0); scrollable.Content = playout; return scrollable; }
public DockLayoutExpansion() { var layout = new DynamicLayout(); defaultScrollable = new Scrollable(); layout.AddSeparateRow(null, ExpandContentWidth(), ExpandContentHeight(), null); layout.Add(Default(), yscale: true); layout.Add(ExpandedWidth(), yscale: true); layout.Add(ExpandedHeight(), yscale: true); Content = layout; }
public TableLayoutExpansion() { var layout = new DynamicLayout { DefaultSpacing = new Size(5, 5), Padding = new Padding(10) }; defaultScrollable = new Scrollable(); layout.AddSeparateRow(null, ExpandContentWidth(), ExpandContentHeight(), null); layout.Add(Default(), yscale: true); layout.Add(ExpandedWidth(), yscale: true); layout.Add(ExpandedHeight(), yscale: true); Content = layout; }
private void Construct() { Title = "My Eto Form"; ClientSize = new Size(400, 350); lblContent = new Label { Text = "Hello World!" }; prgBar = new ProgressBar(); // scrollable region as the main content Content = new Scrollable { // table with three rows Content = new TableLayout( null, // row with three columns new TableRow(null, lblContent, null), new TableRow(null, prgBar, null) ) }; // create a few commands that can be used for the menu and toolbar cmdButton = new Command { MenuText = "Click Me!", ToolBarText = "Click Me!" }; var quitCommand = new Command { MenuText = "Quit", Shortcut = Application.Instance.CommonModifier | Keys.Q }; quitCommand.Executed += (sender, e) => Application.Instance.Quit(); var aboutCommand = new Command { MenuText = "About..." }; aboutCommand.Executed += (sender, e) => MessageBox.Show(this, "About my app..."); // create menu Menu = new MenuBar { Items = { // File submenu new ButtonMenuItem { Text = "&File", Items = { cmdButton } }, // new ButtonMenuItem { Text = "&Edit", Items = { /* commands/items */ } }, // new ButtonMenuItem { Text = "&View", Items = { /* commands/items */ } }, }, ApplicationItems = { // application (OS X) or file menu (others) new ButtonMenuItem { Text = "&Preferences..." }, }, QuitItem = quitCommand, AboutItem = aboutCommand }; // create toolbar ToolBar = new ToolBar { Items = { cmdButton } }; }
public SystemColorSection() { var layout = new StackLayout { Spacing = 10, HorizontalContentAlignment = HorizontalAlignment.Stretch }; var type = typeof(SystemColors); var properties = type.GetRuntimeProperties(); var skip = new List<PropertyInfo>(); var colorProperties = properties.Where(r => r.PropertyType == typeof(Color)).OrderBy(r => r.Name).ToList(); foreach (var property in colorProperties) { if (skip.Contains(property)) continue; var color = (Color)property.GetValue(null); var label = new Label { Text = property.Name }; var panel = new Panel { Content = label, Padding = new Padding(10), }; bool isTextColor = property.Name.EndsWith("Text"); if (isTextColor) label.TextColor = color; else { panel.BackgroundColor = color; var textProp = colorProperties.FirstOrDefault(r => r.Name == property.Name + "Text"); if (textProp != null) { label.TextColor = (Color)textProp.GetValue(null); label.Text += " && " + textProp.Name; skip.Add(textProp); } else if (color.ToHSB().B < 0.5) label.TextColor = Colors.White; } layout.Items.Add(panel); } Content = new Scrollable { Content = TableLayout.AutoSized(layout, centered: true) }; }
Scrollable CreateScrollable() { var scrollable = new Scrollable { Size = new Size(100, 200) }; LogEvents(scrollable); var desc = new Label { Text = "Content", BackgroundColor = Colors.Green, Size = new Size(400, 400), TextAlignment = TextAlignment.Center, VerticalAlignment = VerticalAlignment.Center }; var content = new Panel { BackgroundColor = Colors.Red, // should not see red Content = desc }; scrollable.Content = content; return scrollable; }
void Initialize() { var su = column.GetFlowsheet().FlowsheetOptions.SelectedUnitSystem; var nf = column.GetFlowsheet().FlowsheetOptions.NumberFormat; var nff = column.GetFlowsheet().FlowsheetOptions.FractionNumberFormat; s.CreateAndAddLabelRow(container, "Object Details"); s.CreateAndAddTwoLabelsRow(container, "Type", column.GetDisplayName()); s.CreateAndAddTwoLabelsRow(container, "Status", column.GraphicObject.Active ? "Active" : "Inactive"); s.CreateAndAddStringEditorRow(container, "Name", column.GraphicObject.Tag, (TextBox arg3, EventArgs ev) => { column.GraphicObject.Tag = arg3.Text; }); s.CreateAndAddLabelRow(container, "Property Package"); var proppacks = column.GetFlowsheet().PropertyPackages.Values.Select((x) => x.Tag).ToList(); if (proppacks.Count == 0) { column.GetFlowsheet().ShowMessage("Error: please add at least one Property Package before continuing.", IFlowsheet.MessageType.GeneralError); } else { var pp = column.PropertyPackage; string selectedpp = ""; if (pp != null) { selectedpp = pp.Tag; } s.CreateAndAddDropDownRow(container, "Property Package", proppacks, proppacks.IndexOf(selectedpp), (DropDown arg1, EventArgs ev) => { column.PropertyPackage = (IPropertyPackage)column.GetFlowsheet().PropertyPackages.Values.Where((x) => x.Tag == proppacks[arg1.SelectedIndex]).FirstOrDefault(); }); } var flashalgos = column.GetFlowsheet().FlowsheetOptions.FlashAlgorithms.Select(x => x.Tag).ToList(); flashalgos.Insert(0, "Default"); var cbFlashAlg = s.CreateAndAddDropDownRow(container, "Flash Algorithm", flashalgos, 0, null); if (!string.IsNullOrEmpty(column.PreferredFlashAlgorithmTag)) { cbFlashAlg.SelectedIndex = Array.IndexOf(flashalgos.ToArray(), column.PreferredFlashAlgorithmTag); } else { cbFlashAlg.SelectedIndex = 0; } cbFlashAlg.SelectedIndexChanged += (sender, e) => { column.PreferredFlashAlgorithmTag = cbFlashAlg.SelectedValue.ToString(); }; s.CreateAndAddLabelRow(container, "Object Properties"); s.CreateAndAddDropDownRow(container, "Operating Mode", new List <string> { "Gas-Liquid Absorption", "Liquid-Liquid Extraction" }, (int)column.OperationMode, (arg1, e) => { switch (arg1.SelectedIndex) { case 0: column.OperationMode = AbsorptionColumn.OpMode.Absorber; break; case 1: column.OperationMode = AbsorptionColumn.OpMode.Extractor; break; } }); s.CreateAndAddButtonRow(container, "Define Number of Stages", null, (arg1, e) => { var np = new Eto.Forms.NumericStepper(); np.MinValue = 3; np.MaxValue = 100; np.MaximumDecimalPlaces = 0; np.Value = column.NumberOfStages; np.ValueChanged += (sender, e2) => { var refval = (int)np.Value; column.NumberOfStages = refval; int ne, nep, dif, i; ne = refval; nep = column.Stages.Count; dif = ne - nep; if (dif != 0) { if (dif < 0) { column.Stages.RemoveRange(ne - 1, -dif); } else if (dif > 0) { for (i = 0; i <= dif; i++) { column.Stages.Insert(column.Stages.Count - 1, new Stage(Guid.NewGuid().ToString()) { P = 101325, Efficiency = 1.0f }); column.Stages[column.Stages.Count - 2].Name = "Stage " + (column.Stages.Count - 2).ToString(); } } } }; s.CreateDialog(np, "Set Number of Stages").ShowModal(container); }); s.CreateAndAddButtonRow(container, "Edit Stages", null, (arg1, e) => { var sview = DWSIM.UI.Shared.Common.GetDefaultContainer(); s.CreateAndAddLabelRow(sview, "Edit Stages"); s.CreateAndAddLabelRow(sview, "Number / Name / Pressure"); foreach (var stage in column.Stages) { s.CreateAndAddDoubleTextBoxRow(sview, nf, (column.Stages.IndexOf(stage) + 1).ToString(), stage.Name, cv.ConvertFromSI(su.pressure, stage.P), (arg10, arg20) => { stage.Name = arg10.Text; }, (arg11, arg22) => { if (s.IsValidDouble(arg11.Text)) { stage.P = cv.ConvertToSI(su.pressure, Double.Parse(arg11.Text)); } }); } var scroll = new Eto.Forms.Scrollable(); scroll.Content = sview; s.CreateDialog(scroll, "Edit Stages", 300, 300).ShowModal(container); }); var istrs = column.GraphicObject.InputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Feed")).Select((x2) => x2.AttachedConnector.AttachedFrom.Name).ToList(); var ostrs = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Side")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); var dist = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Top Product")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); var bottoms = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Bottoms Product")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); foreach (var id in istrs) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.Feed }); } } foreach (var id in ostrs) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.Sidedraw }); } } foreach (var id in dist) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.Distillate }); } } foreach (var id in bottoms) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.BottomsLiquid }); } } List <string> remove = new List <string>(); foreach (var si in column.MaterialStreams.Values) { if (!istrs.Contains(si.StreamID) && !ostrs.Contains(si.StreamID) && !dist.Contains(si.StreamID) && !bottoms.Contains(si.StreamID)) { remove.Add(si.ID); } if (!column.GetFlowsheet().SimulationObjects.ContainsKey(si.StreamID)) { remove.Add(si.ID); } } foreach (var id in remove) { if (column.MaterialStreams.ContainsKey(id)) { column.MaterialStreams.Remove(id); } } var stageNames = column.Stages.Select((x) => x.Name).ToList(); stageNames.Insert(0, ""); var stageIDs = column.Stages.Select((x) => x.ID).ToList(); stageIDs.Insert(0, ""); s.CreateAndAddLabelRow(container, "Streams"); foreach (var si in column.MaterialStreams.Values) { if (si.StreamBehavior == StreamInformation.Behavior.Feed) { s.CreateAndAddDropDownRow(container, "[FEED] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.Sidedraw) { s.CreateAndAddDropDownRow(container, "[SIDEDRAW] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.Distillate || si.StreamBehavior == StreamInformation.Behavior.OverheadVapor) { s.CreateAndAddDropDownRow(container, "[TOP PRODUCT] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.BottomsLiquid) { s.CreateAndAddDropDownRow(container, "[BOTTOMS PRODUCT] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } } s.CreateAndAddLabelRow(container, "Side Draw Specs"); var sdphases = new List <string>() { "L", "V" }; foreach (var si in column.MaterialStreams.Values) { string sp = "L"; switch (si.StreamPhase) { case StreamInformation.Phase.L: sp = "L"; break; case StreamInformation.Phase.V: sp = "V"; break; } if (si.StreamBehavior == StreamInformation.Behavior.Sidedraw) { s.CreateAndAddDropDownRow(container, column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag + " / Draw Phase", sdphases, sdphases.IndexOf(sp), (arg1, arg2) => { switch (arg1.SelectedIndex) { case 0: si.StreamPhase = StreamInformation.Phase.L; break; case 1: si.StreamPhase = StreamInformation.Phase.V; break; } }); s.CreateAndAddTextBoxRow(container, nf, column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag + " / Molar Flow (" + su.molarflow + ")", cv.ConvertFromSI(su.molarflow, si.FlowRate.Value), (arg1, arg2) => { if (s.IsValidDouble(arg1.Text)) { si.FlowRate.Value = cv.ConvertToSI(su.molarflow, Double.Parse(arg1.Text)); } }); } } s.CreateAndAddLabelRow(container, "Column Solver Selection"); var methods = new string[] { "Wang-Henke (Bubble Point)", "Naphtali-Sandholm (Newton)", "Russell (Inside-Out)", "Burningham-Otto (Sum Rates) (Absorber Only)" }; var strategies = new string[] { "Direct Rigorous", "Ideal K first, then Rigorous", "Ideal H first, then Rigorous", "Ideal K+H first, then Rigorous" }; s.CreateAndAddDropDownRow(container, "Solving Method", methods.ToList(), (int)column.SolvingMethod, (sender, e) => { column.SolvingMethod = sender.SelectedIndex; }); s.CreateAndAddDropDownRow(container, "Solving Scheme", strategies.ToList(), (int)column.SolverScheme, (sender, e) => { column.SolverScheme = (UnitOperations.UnitOperations.Column.SolvingScheme)sender.SelectedIndex; }); s.CreateAndAddLabelRow(container, "Bubble Point Solver Settings"); s.CreateAndAddTextBoxRow(container, "N0", "Stop at iteration number", column.StopAtIterationNumber, (sender, e) => { if (sender.Text.IsValidDouble()) { column.StopAtIterationNumber = (int)sender.Text.ToDoubleFromCurrent(); } }); s.CreateAndAddLabelRow(container, "Newton Solver Settings"); var solvers = new List <string>() { "Limited Memory BGFS", "Truncated Newton", "Simplex", "IPOPT", "Particle Swarm", "Local Unimodal Sampling", "Gradient Descent", "Differential Evolution", "Particle Swarm Optimization", "Many Optimizing Liaisons", "Mesh" }; s.CreateAndAddDropDownRow(container, "Non-Linear Solver", solvers, (int)column.NS_Solver, (sender, e) => column.NS_Solver = (DWSIM.Interfaces.Enums.OptimizationMethod)sender.SelectedIndex); s.CreateAndAddTextBoxRow(container, nf, "Iteration Variables: Lower Bound", column.NS_LowerBound, (sender, e) => { if (sender.Text.IsValidDouble()) { column.NS_LowerBound = (int)sender.Text.ToDoubleFromCurrent(); } }); s.CreateAndAddTextBoxRow(container, nf, "Iteration Variables: Upper Bound", column.NS_UpperBound, (sender, e) => { if (sender.Text.IsValidDouble()) { column.NS_UpperBound = (int)sender.Text.ToDoubleFromCurrent(); } }); s.CreateAndAddTextBoxRow(container, nf, "Iteration Variables: Derivative Perturbation", column.SC_NumericalDerivativeStep, (sender, e) => { if (sender.Text.IsValidDouble()) { column.SC_NumericalDerivativeStep = (int)sender.Text.ToDoubleFromCurrent(); } }); s.CreateAndAddCheckBoxRow(container, "Iteration Variables: Simplex Preconditioning", column.NS_SimplexPreconditioning, (sender, e) => column.NS_SimplexPreconditioning = sender.Checked.GetValueOrDefault()); s.CreateAndAddLabelRow(container, "Inside-Out Solver Settings"); s.CreateAndAddDropDownRow(container, "Non-Linear Solver", solvers, (int)column.IO_Solver, (sender, e) => column.IO_Solver = (DWSIM.Interfaces.Enums.OptimizationMethod)sender.SelectedIndex); s.CreateAndAddTextBoxRow(container, nf, "Iteration Variables: Lower Bound", column.IO_LowerBound, (sender, e) => { if (sender.Text.IsValidDouble()) { column.IO_LowerBound = (int)sender.Text.ToDoubleFromCurrent(); } }); s.CreateAndAddTextBoxRow(container, nf, "Iteration Variables: Upper Bound", column.IO_UpperBound, (sender, e) => { if (sender.Text.IsValidDouble()) { column.IO_UpperBound = (int)sender.Text.ToDoubleFromCurrent(); } }); s.CreateAndAddTextBoxRow(container, nf, "Iteration Variables: Derivative Perturbation", column.IO_NumericalDerivativeStep, (sender, e) => { if (sender.Text.IsValidDouble()) { column.IO_NumericalDerivativeStep = (int)sender.Text.ToDoubleFromCurrent(); } }); s.CreateAndAddCheckBoxRow(container, "Adjust Sb Scaling Factor", column.AdjustSb, (sender, e) => column.AdjustSb = sender.Checked.GetValueOrDefault()); s.CreateAndAddCheckBoxRow(container, "Calculate Kb by Weighted Average", column.KbjWeightedAverage, (sender, e) => column.KbjWeightedAverage = sender.Checked.GetValueOrDefault()); s.CreateAndAddEmptySpace(container); s.CreateAndAddEmptySpace(container); s.CreateAndAddEmptySpace(container); }
/// <summary> /// Raises the scroll event. /// </summary> public void OnScroll(Scrollable widget, ScrollEventArgs e) { using (widget.Platform.Context) widget.OnScroll(e); }
void Initialize() { var su = column.GetFlowsheet().FlowsheetOptions.SelectedUnitSystem; var nf = column.GetFlowsheet().FlowsheetOptions.NumberFormat; var nff = column.GetFlowsheet().FlowsheetOptions.FractionNumberFormat; s.CreateAndAddLabelRow(container, "Distillation Column Editor"); s.CreateAndAddDescriptionRow(container, "Property values are updated/stored as they are changed/edited. There's no need to press ENTER to commit the changes."); if ((Inspector.Host.Items.Where(x => x.Name.Contains(column.GraphicObject.Tag)).Count() > 0)) { var ctn = new DynamicLayout(); ctn.BackgroundColor = Colors.LightGrey; s.CreateAndAddLabelRow(ctn, "Inspector Reports"); s.CreateAndAddLabelAndButtonRow(ctn, "An Inspector Report is ready for viewing.", "View Report", null, (btn, e) => { var f = s.GetDefaultEditorForm("Inspector Report for '" + column.GraphicObject.Tag + "'", 1024, 768, Inspector.Window2_Eto.GetInspectorWindow(column), false); f.Show(); }); container.Add(ctn); } s.CreateAndAddLabelRow(container, "Column Details"); s.CreateAndAddTwoLabelsRow(container, "Type", column.GetDisplayName()); s.CreateAndAddTwoLabelsRow(container, "Status", column.GraphicObject.Active ? "Active" : "Inactive"); s.CreateAndAddStringEditorRow(container, "Name", column.GraphicObject.Tag, (TextBox arg3, EventArgs ev) => { column.GraphicObject.Tag = arg3.Text; column.GetFlowsheet().UpdateInterface(); }, () => { column.GetFlowsheet().UpdateOpenEditForms(); }); s.CreateAndAddLabelRow(container, "Property Package"); var proppacks = column.GetFlowsheet().PropertyPackages.Values.Select((x) => x.Tag).ToList(); if (proppacks.Count == 0) { column.GetFlowsheet().ShowMessage("Error: please add at least one Property Package before continuing.", IFlowsheet.MessageType.GeneralError); } else { var pp = column.PropertyPackage; string selectedpp = ""; if (pp != null) { selectedpp = pp.Tag; } s.CreateAndAddDropDownRow(container, "Property Package", proppacks, proppacks.IndexOf(selectedpp), (DropDown arg1, EventArgs ev) => { if (proppacks.Count > 0) { column.PropertyPackage = (IPropertyPackage)column.GetFlowsheet().PropertyPackages.Values.Where((x) => x.Tag == proppacks[arg1.SelectedIndex]).FirstOrDefault(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); } s.CreateAndAddLabelRow(container, "Object Properties"); s.CreateAndAddButtonRow(container, "Define Number of Stages", null, (arg1, e) => { var np = new Eto.Forms.NumericStepper(); np.MinValue = 3; np.MaxValue = 100; np.MaximumDecimalPlaces = 0; np.Value = column.NumberOfStages; np.ValueChanged += (sender, e2) => { var refval = (int)np.Value; column.NumberOfStages = refval; int ne, nep, dif, i; ne = refval; nep = column.Stages.Count; dif = ne - nep; if (dif != 0) { if (dif < 0) { column.Stages.RemoveRange(ne - 1, -dif); } else if (dif > 0) { for (i = 0; i <= dif; i++) { column.Stages.Insert(column.Stages.Count - 1, new Stage(Guid.NewGuid().ToString()) { P = 101325, Efficiency = 1.0f }); column.Stages[column.Stages.Count - 2].Name = "Stage " + (column.Stages.Count - 2).ToString(); } } } }; s.CreateDialog(np, "Set Number of Stages").ShowModal(container); }); s.CreateAndAddButtonRow(container, "Edit Stages", null, (arg1, e) => { var sview = DWSIM.UI.Shared.Common.GetDefaultContainer(); s.CreateAndAddLabelRow(sview, "Edit Stages"); s.CreateAndAddLabelRow(sview, "Number / Name / Pressure"); var tlist = new List <TextBox>(); foreach (var stage in column.Stages) { tlist.Add(s.CreateAndAddDoubleTextBoxRow(sview, nf, (column.Stages.IndexOf(stage) + 1).ToString(), stage.Name, cv.ConvertFromSI(su.pressure, stage.P), (arg10, arg20) => { stage.Name = arg10.Text; }, (arg11, arg22) => { if (s.IsValidDouble(arg11.Text)) { stage.P = cv.ConvertToSI(su.pressure, Double.Parse(arg11.Text)); if (column.Stages.IndexOf(stage) == 0) { column.CondenserPressure = stage.P; } else if (column.Stages.IndexOf(stage) == column.Stages.Count - 1) { column.ReboilerPressure = stage.P; } } })); } s.CreateAndAddLabelAndButtonRow(sview, "Interpolate Pressures", "Interpolate", null, (sender2, e2) => { var first = tlist[0].Text.ToDoubleFromCurrent(); var last = tlist[tlist.Count - 1].Text.ToDoubleFromCurrent(); var n = tlist.Count; int i = 1; for (i = 1; i < n - 1; i++) { tlist[i].Text = (first + (last - first) * i / (n - 1)).ToString(nf); } }); s.CreateAndAddDescriptionRow(sview, "Calculate inner pressures using end stage defined values."); var scroll = new Eto.Forms.Scrollable(); scroll.Content = sview; s.CreateDialog(scroll, "Edit Stages", 600, 600).ShowModal(container); }); var istrs = column.GraphicObject.InputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Feed")).Select((x2) => x2.AttachedConnector.AttachedFrom.Name).ToList(); var ostrs = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Side")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); var dist = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Distillate")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); var ov = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Overhead")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); var bottoms = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Bottoms")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); var rduty = column.GraphicObject.InputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Reboiler")).Select((x2) => x2.AttachedConnector.AttachedFrom.Name).ToList(); var cduty = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Condenser")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); foreach (var id in istrs) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.Feed }); } } foreach (var id in ostrs) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.Sidedraw }); } } foreach (var id in dist) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.Distillate }); } } foreach (var id in ov) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.OverheadVapor }); } } foreach (var id in bottoms) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.BottomsLiquid }); } } List <string> remove = new List <string>(); foreach (var si in column.MaterialStreams.Values) { if (!istrs.Contains(si.StreamID) && !ostrs.Contains(si.StreamID) && !ov.Contains(si.StreamID) && !dist.Contains(si.StreamID) && !bottoms.Contains(si.StreamID)) { remove.Add(si.ID); } if (!column.GetFlowsheet().SimulationObjects.ContainsKey(si.StreamID)) { remove.Add(si.ID); } } foreach (var id in remove) { if (column.MaterialStreams.ContainsKey(id)) { column.MaterialStreams.Remove(id); } } foreach (var id in cduty) { if (column.EnergyStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.EnergyStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Energy, StreamBehavior = StreamInformation.Behavior.Distillate }); } } foreach (var id in rduty) { if (column.EnergyStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.EnergyStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Energy, StreamBehavior = StreamInformation.Behavior.BottomsLiquid }); } } List <string> remove2 = new List <string>(); foreach (var si in column.EnergyStreams.Values) { if (!rduty.Contains(si.StreamID) && !cduty.Contains(si.StreamID)) { remove2.Add(si.ID); } if (!column.GetFlowsheet().SimulationObjects.ContainsKey(si.StreamID)) { remove2.Add(si.ID); } } foreach (var id in remove2) { if (column.EnergyStreams.ContainsKey(id)) { column.EnergyStreams.Remove(id); } } var stageNames = column.Stages.Select((x) => x.Name).ToList(); stageNames.Insert(0, ""); var stageIDs = column.Stages.Select((x) => x.ID).ToList(); stageIDs.Insert(0, ""); s.CreateAndAddLabelRow(container, "Streams"); foreach (var si in column.MaterialStreams.Values) { if (si.StreamBehavior == StreamInformation.Behavior.Feed) { s.CreateAndAddDropDownRow(container, "[FEED] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.Sidedraw) { s.CreateAndAddDropDownRow(container, "[SIDEDRAW] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.OverheadVapor) { s.CreateAndAddDropDownRow(container, "[OVH_VAPOR] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.Distillate) { s.CreateAndAddDropDownRow(container, "[DISTILLATE] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.BottomsLiquid) { s.CreateAndAddDropDownRow(container, "[BOTTOMS] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } } foreach (var si in column.EnergyStreams.Values) { if (si.StreamBehavior == StreamInformation.Behavior.Distillate) { s.CreateAndAddDropDownRow(container, "[COND. DUTY] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.BottomsLiquid) { s.CreateAndAddDropDownRow(container, "[REB. DUTY] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } } s.CreateAndAddLabelRow(container, "Side Draw Specs"); var sdphases = new List <string>() { "L", "V" }; foreach (var si in column.MaterialStreams.Values) { string sp = "L"; switch (si.StreamPhase) { case StreamInformation.Phase.L: sp = "L"; break; case StreamInformation.Phase.V: sp = "V"; break; case StreamInformation.Phase.B: case StreamInformation.Phase.None: sp = "L"; break; } if (si.StreamBehavior == StreamInformation.Behavior.Sidedraw) { s.CreateAndAddDropDownRow(container, column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag + " / Draw Phase", sdphases, sdphases.IndexOf(sp), (arg1, arg2) => { switch (arg1.SelectedIndex) { case 0: si.StreamPhase = StreamInformation.Phase.L; break; case 1: si.StreamPhase = StreamInformation.Phase.V; break; } }); s.CreateAndAddTextBoxRow(container, nf, column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag + " / Molar Flow (" + su.molarflow + ")", cv.ConvertFromSI(su.molarflow, si.FlowRate.Value), (arg1, arg2) => { if (s.IsValidDouble(arg1.Text)) { si.FlowRate.Value = cv.ConvertToSI(su.molarflow, Double.Parse(arg1.Text)); } }); } } var compounds = column.GetFlowsheet().SelectedCompounds.Keys.ToList(); compounds.Insert(0, ""); var specs = StringResources.columnspec(); var units = su.GetUnitSet(Interfaces.Enums.UnitOfMeasure.molarflow); units.AddRange(su.GetUnitSet(Interfaces.Enums.UnitOfMeasure.massflow)); units.AddRange(su.GetUnitSet(Interfaces.Enums.UnitOfMeasure.heatflow)); units.AddRange(su.GetUnitSet(Interfaces.Enums.UnitOfMeasure.temperature)); units.AddRange(new[] { "% M/M", "% W/W", "M", "We" }); units.Insert(0, ""); int cspec = 0, rspec = 0; switch (column.Specs["C"].SType) { case ColumnSpec.SpecType.Product_Molar_Flow_Rate: cspec = 0; break; case ColumnSpec.SpecType.Product_Mass_Flow_Rate: cspec = 1; break; case ColumnSpec.SpecType.Stream_Ratio: cspec = 2; break; case ColumnSpec.SpecType.Heat_Duty: cspec = 3; break; case ColumnSpec.SpecType.Component_Mass_Flow_Rate: cspec = 4; break; case ColumnSpec.SpecType.Component_Molar_Flow_Rate: cspec = 5; break; case ColumnSpec.SpecType.Component_Recovery: cspec = 6; break; case ColumnSpec.SpecType.Component_Fraction: cspec = 7; break; case ColumnSpec.SpecType.Temperature: cspec = 8; break; } switch (column.Specs["R"].SType) { case ColumnSpec.SpecType.Product_Molar_Flow_Rate: rspec = 0; break; case ColumnSpec.SpecType.Product_Mass_Flow_Rate: rspec = 1; break; case ColumnSpec.SpecType.Stream_Ratio: rspec = 2; break; case ColumnSpec.SpecType.Heat_Duty: rspec = 3; break; case ColumnSpec.SpecType.Component_Mass_Flow_Rate: rspec = 4; break; case ColumnSpec.SpecType.Component_Molar_Flow_Rate: rspec = 5; break; case ColumnSpec.SpecType.Component_Recovery: rspec = 6; break; case ColumnSpec.SpecType.Component_Fraction: rspec = 7; break; case ColumnSpec.SpecType.Temperature: rspec = 8; break; } s.CreateAndAddLabelRow(container, "Condenser Specification"); s.CreateAndAddDropDownRow(container, "Specification", specs.ToList(), cspec, (arg1, arg2) => { switch (arg1.SelectedIndex) { case 0: column.Specs["C"].SType = ColumnSpec.SpecType.Product_Molar_Flow_Rate; break; case 1: column.Specs["C"].SType = ColumnSpec.SpecType.Product_Mass_Flow_Rate; break; case 2: column.Specs["C"].SType = ColumnSpec.SpecType.Stream_Ratio; break; case 3: column.Specs["C"].SType = ColumnSpec.SpecType.Heat_Duty; break; case 4: column.Specs["C"].SType = ColumnSpec.SpecType.Component_Mass_Flow_Rate; break; case 5: column.Specs["C"].SType = ColumnSpec.SpecType.Component_Molar_Flow_Rate; break; case 6: column.Specs["C"].SType = ColumnSpec.SpecType.Component_Recovery; break; case 7: column.Specs["C"].SType = ColumnSpec.SpecType.Component_Fraction; break; case 8: column.Specs["C"].SType = ColumnSpec.SpecType.Temperature; break; } }); var cid = 0; if (compounds.Contains(column.Specs["C"].ComponentID)) { cid = compounds.IndexOf(column.Specs["C"].ComponentID); } s.CreateAndAddDropDownRow(container, "Compound", compounds, cid, (arg3, e) => { column.Specs["C"].ComponentID = compounds[arg3.SelectedIndex]; }); s.CreateAndAddTextBoxRow(container, nf, "Value", column.Specs["C"].SpecValue, (arg1, arg2) => { if (s.IsValidDouble(arg1.Text)) { column.Specs["C"].SpecValue = Double.Parse(arg1.Text); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddDropDownRow(container, "Units", units, units.IndexOf(column.Specs["C"].SpecUnit), (arg1, arg2) => { column.Specs["C"].SpecUnit = units[arg1.SelectedIndex]; }); s.CreateAndAddLabelRow(container, "Reboiler Specification"); s.CreateAndAddDropDownRow(container, "Specification", specs.ToList(), rspec, (arg1, arg2) => { switch (arg1.SelectedIndex) { case 0: column.Specs["R"].SType = ColumnSpec.SpecType.Product_Molar_Flow_Rate; break; case 1: column.Specs["R"].SType = ColumnSpec.SpecType.Product_Mass_Flow_Rate; break; case 2: column.Specs["R"].SType = ColumnSpec.SpecType.Stream_Ratio; break; case 3: column.Specs["R"].SType = ColumnSpec.SpecType.Heat_Duty; break; case 4: column.Specs["R"].SType = ColumnSpec.SpecType.Component_Mass_Flow_Rate; break; case 5: column.Specs["R"].SType = ColumnSpec.SpecType.Component_Molar_Flow_Rate; break; case 6: column.Specs["R"].SType = ColumnSpec.SpecType.Component_Recovery; break; case 7: column.Specs["R"].SType = ColumnSpec.SpecType.Component_Fraction; break; case 8: column.Specs["R"].SType = ColumnSpec.SpecType.Temperature; break; } }); var cid2 = 0; if (compounds.Contains(column.Specs["R"].ComponentID)) { cid2 = compounds.IndexOf(column.Specs["R"].ComponentID); } s.CreateAndAddDropDownRow(container, "Compound", compounds, cid2, (arg3, e) => { column.Specs["R"].ComponentID = compounds[arg3.SelectedIndex]; }); s.CreateAndAddTextBoxRow(container, nf, "Value", column.Specs["R"].SpecValue, (arg1, arg2) => { if (s.IsValidDouble(arg1.Text)) { column.Specs["R"].SpecValue = Double.Parse(arg1.Text); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddDropDownRow(container, "Units", units, units.IndexOf(column.Specs["R"].SpecUnit), (arg1, arg2) => { column.Specs["R"].SpecUnit = units[arg1.SelectedIndex]; }); s.CreateAndAddLabelRow(container, "Solver Settings"); var methods = new string[] { "Wang-Henke (Bubble Point)", "Napthali-Sandholm (Simultaneous Correction)" }; s.CreateAndAddDropDownRow(container, "Solving Method", methods.ToList(), methods.ToList().IndexOf(column.SolvingMethodName), (sender, e) => { column.SolvingMethodName = sender.SelectedValue.ToString(); }); s.CreateAndAddTextBoxRow(container, "N0", "Maximum Iterations", column.MaxIterations, (sender, e) => { if (sender.Text.IsValidDouble()) { column.MaxIterations = (int)sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddTextBoxRow(container, nf, "Convergence Tolerance", column.ExternalLoopTolerance, (sender, e) => { if (sender.Text.IsValidDouble()) { column.ExternalLoopTolerance = sender.Text.ToDoubleFromCurrent(); column.InternalLoopTolerance = sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddEmptySpace(container); s.CreateAndAddEmptySpace(container); s.CreateAndAddEmptySpace(container); }
/// <summary> /// Raises the scroll event. /// </summary> public void OnScroll(Scrollable widget, ScrollEventArgs e) { widget.Platform.Invoke(() => widget.OnScroll(e)); }
public SendCoinsView() { Spacing = Utilities.Spacing3; DataContext = ViewModel; var buttonSendTransaction = Utilities.CreateButton(() => Desktop.Properties.Resources.TextSend, null, Utilities.LoadImage("Send"), SendTransaction ); buttonSendTransaction.BindDataContext<bool>("Enabled", "IsSendingEnabled"); Rows.Add( new TableLayout( new TableRow( new TableCell( Utilities.CreateLabel(ViewModel, o => o.BalanceSpendableText), true ), new TableCell( Utilities.CreateLabel(() => Desktop.Properties.Resources.SendCoinsEstimatedNewBalance + " " + Desktop.Properties.Resources.PunctuationQuestionMark ) ) ) ) { Spacing = Utilities.Spacing3 } ); TableLayoutRecipients = new TableLayout( new CoinSender(), new TableRow { ScaleHeight = true } ); ScrollableRecipientsContainer = new Scrollable { Content = TableLayoutRecipients, Padding = new Padding(Utilities.Padding4, 0), BackgroundColor = Colors.White }; Rows.Add( new TableRow(ScrollableRecipientsContainer) { ScaleHeight = true } ); Rows.Add( new TableLayout( new TableRow( new TableCell( Utilities.CreateLabel(() => Desktop.Properties.Resources.TextPaymentId) ), new TableCell( Utilities.CreateTextBox( ViewModel, o => o.PaymentId, () => Desktop.Properties.Resources.TextHintOptional ), true ) ) ) { Spacing = Utilities.Spacing3 } ); Rows.Add( new TableLayout( new TableRow( new TableCell( Utilities.CreateButton(() => Desktop.Properties.Resources.SendCoinsAddRecipient, null, Utilities.LoadImage("Add"), AddRecipient ) ), new TableCell( Utilities.CreateButton(() => Desktop.Properties.Resources.SendCoinsClearRecipients, null, Utilities.LoadImage("Delete"), Clear ) ), new TableCell { ScaleWidth = true }, new TableCell( Utilities.CreateLabel(() => Desktop.Properties.Resources.SendCoinsMixCount) ), new TableCell( Utilities.CreateNumericUpDown(ViewModel, o => o.MixCount, 0, 1, ushort.MaxValue) ), new TableCell( new Separator(SeparatorOrientation.Vertical) ), new TableCell( buttonSendTransaction ) ) ) { Spacing = Utilities.Spacing3 } ); }
void Initialize() { var su = column.GetFlowsheet().FlowsheetOptions.SelectedUnitSystem; var nf = column.GetFlowsheet().FlowsheetOptions.NumberFormat; var nff = column.GetFlowsheet().FlowsheetOptions.FractionNumberFormat; s.CreateAndAddLabelRow(container, "Absorption Column Editor"); s.CreateAndAddDescriptionRow(container, "Property values are updated/stored as they are changed/edited. There's no need to press ENTER to commit the changes."); if ((Inspector.Host.Items.Where(x => x.Name.Contains(column.GraphicObject.Tag)).Count() > 0)) { var ctn = new DynamicLayout(); ctn.BackgroundColor = Colors.LightGrey; s.CreateAndAddLabelRow(ctn, "Inspector Reports"); s.CreateAndAddLabelAndButtonRow(ctn, "An Inspector Report is ready for viewing.", "View Report", null, (btn, e) => { var f = s.GetDefaultEditorForm("Inspector Report for '" + column.GraphicObject.Tag + "'", 1024, 768, Inspector.Window2_Eto.GetInspectorWindow(column), false); f.Show(); }); container.Add(ctn); } s.CreateAndAddLabelRow(container, "Column Details"); s.CreateAndAddTwoLabelsRow(container, "Type", column.GetDisplayName()); s.CreateAndAddTwoLabelsRow(container, "Status", column.GraphicObject.Active ? "Active" : "Inactive"); s.CreateAndAddStringEditorRow(container, "Name", column.GraphicObject.Tag, (TextBox arg3, EventArgs ev) => { column.GraphicObject.Tag = arg3.Text; column.GetFlowsheet().UpdateInterface(); }, () => { column.GetFlowsheet().UpdateOpenEditForms(); }); s.CreateAndAddLabelRow(container, "Property Package"); var proppacks = column.GetFlowsheet().PropertyPackages.Values.Select((x) => x.Tag).ToList(); if (proppacks.Count == 0) { column.GetFlowsheet().ShowMessage("Error: please add at least one Property Package before continuing.", IFlowsheet.MessageType.GeneralError); } else { var pp = column.PropertyPackage; string selectedpp = ""; if (pp != null) { selectedpp = pp.Tag; } s.CreateAndAddDropDownRow(container, "Property Package", proppacks, proppacks.IndexOf(selectedpp), (DropDown arg1, EventArgs ev) => { if (proppacks.Count > 0) { column.PropertyPackage = (IPropertyPackage)column.GetFlowsheet().PropertyPackages.Values.Where((x) => x.Tag == proppacks[arg1.SelectedIndex]).FirstOrDefault(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); } s.CreateAndAddLabelRow(container, "Object Properties"); s.CreateAndAddDropDownRow(container, "Operating Mode", new List <string> { "Gas-Liquid Absorption", "Liquid-Liquid Extraction" }, (int)column.OperationMode, (arg1, e) => { switch (arg1.SelectedIndex) { case 0: column.OperationMode = AbsorptionColumn.OpMode.Absorber; break; case 1: column.OperationMode = AbsorptionColumn.OpMode.Extractor; break; } }); s.CreateAndAddButtonRow(container, "Define Number of Stages", null, (arg1, e) => { var np = new Eto.Forms.NumericStepper(); np.MinValue = 3; np.MaxValue = 100; np.MaximumDecimalPlaces = 0; np.Value = column.NumberOfStages; np.ValueChanged += (sender, e2) => { var refval = (int)np.Value; column.NumberOfStages = refval; int ne, nep, dif, i; ne = refval; nep = column.Stages.Count; dif = ne - nep; if (dif != 0) { if (dif < 0) { column.Stages.RemoveRange(ne - 1, -dif); } else if (dif > 0) { for (i = 0; i <= dif; i++) { column.Stages.Insert(column.Stages.Count - 1, new Stage(Guid.NewGuid().ToString()) { P = 101325, Efficiency = 1.0f }); column.Stages[column.Stages.Count - 2].Name = "Stage " + (column.Stages.Count - 2).ToString(); } } } }; s.CreateDialog(np, "Set Number of Stages").ShowModal(container); }); s.CreateAndAddButtonRow(container, "Edit Stages", null, (arg1, e) => { var sview = DWSIM.UI.Shared.Common.GetDefaultContainer(); s.CreateAndAddLabelRow(sview, "Edit Stages"); s.CreateAndAddLabelRow(sview, "Number / Name / Pressure"); var tlist = new List <TextBox>(); foreach (var stage in column.Stages) { tlist.Add(s.CreateAndAddDoubleTextBoxRow(sview, nf, (column.Stages.IndexOf(stage) + 1).ToString(), stage.Name, cv.ConvertFromSI(su.pressure, stage.P), (arg10, arg20) => { stage.Name = arg10.Text; }, (arg11, arg22) => { if (s.IsValidDouble(arg11.Text)) { stage.P = cv.ConvertToSI(su.pressure, Double.Parse(arg11.Text)); } })); } s.CreateAndAddLabelAndButtonRow(sview, "Interpolate Pressures", "Interpolate", null, (sender2, e2) => { var first = tlist[0].Text.ToDoubleFromCurrent(); var last = tlist[tlist.Count - 1].Text.ToDoubleFromCurrent(); var n = tlist.Count; int i = 1; for (i = 1; i < n - 1; i++) { tlist[i].Text = (first + (last - first) * i / (n - 1)).ToString(nf); } }); s.CreateAndAddDescriptionRow(sview, "Calculate inner pressures using end stage defined values."); var scroll = new Eto.Forms.Scrollable(); scroll.Content = sview; s.CreateDialog(scroll, "Edit Stages", 400, 600).ShowModal(container); }); var istrs = column.GraphicObject.InputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Feed")).Select((x2) => x2.AttachedConnector.AttachedFrom.Name).ToList(); var ostrs = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Side")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); var dist = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Top Product")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); var bottoms = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Bottoms Product")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); foreach (var id in istrs) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.Feed }); } } foreach (var id in ostrs) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.Sidedraw }); } } foreach (var id in dist) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.OverheadVapor }); } } foreach (var id in bottoms) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.BottomsLiquid }); } } List <string> remove = new List <string>(); foreach (var si in column.MaterialStreams.Values) { if (!istrs.Contains(si.StreamID) && !ostrs.Contains(si.StreamID) && !dist.Contains(si.StreamID) && !bottoms.Contains(si.StreamID)) { remove.Add(si.ID); } if (!column.GetFlowsheet().SimulationObjects.ContainsKey(si.StreamID)) { remove.Add(si.ID); } } foreach (var id in remove) { if (column.MaterialStreams.ContainsKey(id)) { column.MaterialStreams.Remove(id); } } var stageNames = column.Stages.Select((x) => x.Name).ToList(); stageNames.Insert(0, ""); var stageIDs = column.Stages.Select((x) => x.ID).ToList(); stageIDs.Insert(0, ""); s.CreateAndAddLabelRow(container, "Streams"); foreach (var si in column.MaterialStreams.Values) { if (si.StreamBehavior == StreamInformation.Behavior.Feed) { s.CreateAndAddDropDownRow(container, "[FEED] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.Sidedraw) { s.CreateAndAddDropDownRow(container, "[SIDEDRAW] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.Distillate || si.StreamBehavior == StreamInformation.Behavior.OverheadVapor) { s.CreateAndAddDropDownRow(container, "[TOP PRODUCT] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.BottomsLiquid) { s.CreateAndAddDropDownRow(container, "[BOTTOMS PRODUCT] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } } s.CreateAndAddLabelRow(container, "Side Draw Specs"); var sdphases = new List <string>() { "L", "V" }; foreach (var si in column.MaterialStreams.Values) { string sp = "L"; switch (si.StreamPhase) { case StreamInformation.Phase.L: sp = "L"; break; case StreamInformation.Phase.V: sp = "V"; break; } if (si.StreamBehavior == StreamInformation.Behavior.Sidedraw) { s.CreateAndAddDropDownRow(container, column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag + " / Draw Phase", sdphases, sdphases.IndexOf(sp), (arg1, arg2) => { switch (arg1.SelectedIndex) { case 0: si.StreamPhase = StreamInformation.Phase.L; break; case 1: si.StreamPhase = StreamInformation.Phase.V; break; } }); s.CreateAndAddTextBoxRow(container, nf, column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag + " / Molar Flow (" + su.molarflow + ")", cv.ConvertFromSI(su.molarflow, si.FlowRate.Value), (arg1, arg2) => { if (s.IsValidDouble(arg1.Text)) { si.FlowRate.Value = cv.ConvertToSI(su.molarflow, Double.Parse(arg1.Text)); } }); } } s.CreateAndAddTextBoxRow(container, "N0", "Maximum Iterations", column.MaxIterations, (sender, e) => { if (sender.Text.IsValidDouble()) { column.MaxIterations = (int)sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddTextBoxRow(container, nf, "Convergence Tolerance (External Loop)", column.ExternalLoopTolerance, (sender, e) => { if (sender.Text.IsValidDouble()) { column.ExternalLoopTolerance = sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddTextBoxRow(container, nf, "Convergence Tolerance (Internal Loop)", column.InternalLoopTolerance, (sender, e) => { if (sender.Text.IsValidDouble()) { column.InternalLoopTolerance = sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddEmptySpace(container); s.CreateAndAddEmptySpace(container); s.CreateAndAddEmptySpace(container); }
public override void OnLoadComplete(EventArgs e) { base.OnLoadComplete(e); scrollable = Widget.FindParent<Scrollable>(); }
void LogEvents(Scrollable control) { control.Scroll += (sender, e) => Log.Write(control, "Scroll, ScrollPosition: {0}", e.ScrollPosition); }
void Initialize() { var su = column.GetFlowsheet().FlowsheetOptions.SelectedUnitSystem; var nf = column.GetFlowsheet().FlowsheetOptions.NumberFormat; var nff = column.GetFlowsheet().FlowsheetOptions.FractionNumberFormat; s.CreateAndAddLabelRow(container, "Object Details"); s.CreateAndAddTwoLabelsRow(container, "Type", column.GetDisplayName()); s.CreateAndAddTwoLabelsRow(container, "Status", column.GraphicObject.Active ? "Active" : "Inactive"); s.CreateAndAddStringEditorRow(container, "Name", column.GraphicObject.Tag, (TextBox arg3, EventArgs ev) => { column.GraphicObject.Tag = arg3.Text; }, () => CallSolverIfNeeded()); s.CreateAndAddLabelRow(container, "Property Package"); var proppacks = column.GetFlowsheet().PropertyPackages.Values.Select((x) => x.Tag).ToList(); if (proppacks.Count == 0) { column.GetFlowsheet().ShowMessage("Error: please add at least one Property Package before continuing.", IFlowsheet.MessageType.GeneralError); } else { var pp = column.PropertyPackage; string selectedpp = ""; if (pp != null) { selectedpp = pp.Tag; } s.CreateAndAddDropDownRow(container, "Property Package", proppacks, proppacks.IndexOf(selectedpp), (DropDown arg1, EventArgs ev) => { column.PropertyPackage = (IPropertyPackage)column.GetFlowsheet().PropertyPackages.Values.Where((x) => x.Tag == proppacks[arg1.SelectedIndex]).FirstOrDefault(); }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); } var flashalgos = column.GetFlowsheet().FlowsheetOptions.FlashAlgorithms.Select(x => x.Tag).ToList(); flashalgos.Insert(0, "Default"); var cbFlashAlg = s.CreateAndAddDropDownRow(container, "Flash Algorithm", flashalgos, 0, null); if (!string.IsNullOrEmpty(column.PreferredFlashAlgorithmTag)) { cbFlashAlg.SelectedIndex = Array.IndexOf(flashalgos.ToArray(), column.PreferredFlashAlgorithmTag); } else { cbFlashAlg.SelectedIndex = 0; } cbFlashAlg.SelectedIndexChanged += (sender, e) => { column.PreferredFlashAlgorithmTag = cbFlashAlg.SelectedValue.ToString(); if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }; s.CreateAndAddLabelRow(container, "Object Properties"); s.CreateAndAddButtonRow(container, "Define Number of Stages", null, (arg1, e) => { var np = new Eto.Forms.NumericStepper(); np.MinValue = 3; np.MaxValue = 100; np.MaximumDecimalPlaces = 0; np.Value = column.NumberOfStages; np.ValueChanged += (sender, e2) => { var refval = (int)np.Value; column.NumberOfStages = refval; int ne, nep, dif, i; ne = refval; nep = column.Stages.Count; dif = ne - nep; if (dif != 0) { if (dif < 0) { column.Stages.RemoveRange(ne - 1, -dif); } else if (dif > 0) { for (i = 0; i <= dif; i++) { column.Stages.Insert(column.Stages.Count - 1, new Stage(Guid.NewGuid().ToString()) { P = 101325, Efficiency = 1.0f }); column.Stages[column.Stages.Count - 2].Name = "Stage " + (column.Stages.Count - 2).ToString(); } } } }; s.CreateDialog(np, "Set Number of Stages").ShowModal(container); }); s.CreateAndAddButtonRow(container, "Edit Stages", null, (arg1, e) => { var sview = DWSIM.UI.Shared.Common.GetDefaultContainer(); s.CreateAndAddLabelRow(sview, "Edit Stages"); s.CreateAndAddLabelRow(sview, "Number / Name / Pressure"); var tlist = new List <TextBox>(); foreach (var stage in column.Stages) { tlist.Add(s.CreateAndAddDoubleTextBoxRow(sview, nf, (column.Stages.IndexOf(stage) + 1).ToString(), stage.Name, cv.ConvertFromSI(su.pressure, stage.P), (arg10, arg20) => { stage.Name = arg10.Text; }, (arg11, arg22) => { if (s.IsValidDouble(arg11.Text)) { stage.P = cv.ConvertToSI(su.pressure, Double.Parse(arg11.Text)); } })); } s.CreateAndAddLabelAndButtonRow(sview, "Interpolate Pressures", "Interpolate", null, (sender2, e2) => { var first = tlist[0].Text.ToDoubleFromCurrent(); var last = tlist[tlist.Count - 1].Text.ToDoubleFromCurrent(); var n = tlist.Count; int i = 1; for (i = 1; i < n - 1; i++) { tlist[i].Text = (first + (last - first) * i / (n - 1)).ToString(nf); } }); s.CreateAndAddDescriptionRow(sview, "Calculate inner pressures using end stage defined values."); var scroll = new Eto.Forms.Scrollable(); scroll.Content = sview; s.CreateDialog(scroll, "Edit Stages", 400, 600).ShowModal(container); }); var istrs = column.GraphicObject.InputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Feed")).Select((x2) => x2.AttachedConnector.AttachedFrom.Name).ToList(); var ostrs = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Side")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); var dist = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Distillate")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); var ov = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Overhead")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); var bottoms = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Bottoms")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); var rduty = column.GraphicObject.InputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Reboiler")).Select((x2) => x2.AttachedConnector.AttachedFrom.Name).ToList(); var cduty = column.GraphicObject.OutputConnectors.Where((x) => x.IsAttached && x.ConnectorName.Contains("Condenser")).Select((x2) => x2.AttachedConnector.AttachedTo.Name).ToList(); foreach (var id in istrs) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.Feed }); } } foreach (var id in ostrs) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.Sidedraw }); } } foreach (var id in dist) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.Distillate }); } } foreach (var id in ov) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.OverheadVapor }); } } foreach (var id in bottoms) { if (column.MaterialStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.MaterialStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Material, StreamBehavior = StreamInformation.Behavior.BottomsLiquid }); } } List <string> remove = new List <string>(); foreach (var si in column.MaterialStreams.Values) { if (!istrs.Contains(si.StreamID) && !ostrs.Contains(si.StreamID) && !ov.Contains(si.StreamID) && !dist.Contains(si.StreamID) && !bottoms.Contains(si.StreamID)) { remove.Add(si.ID); } if (!column.GetFlowsheet().SimulationObjects.ContainsKey(si.StreamID)) { remove.Add(si.ID); } } foreach (var id in remove) { if (column.MaterialStreams.ContainsKey(id)) { column.MaterialStreams.Remove(id); } } foreach (var id in cduty) { if (column.EnergyStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.EnergyStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Energy, StreamBehavior = StreamInformation.Behavior.Distillate }); } } foreach (var id in rduty) { if (column.EnergyStreams.Values.Where(x => x.StreamID == id).Count() == 0) { column.EnergyStreams.Add(id, new StreamInformation() { StreamID = id, ID = id, StreamType = StreamInformation.Type.Energy, StreamBehavior = StreamInformation.Behavior.BottomsLiquid }); } } List <string> remove2 = new List <string>(); foreach (var si in column.EnergyStreams.Values) { if (!rduty.Contains(si.StreamID) && !cduty.Contains(si.StreamID)) { remove2.Add(si.ID); } if (!column.GetFlowsheet().SimulationObjects.ContainsKey(si.StreamID)) { remove2.Add(si.ID); } } foreach (var id in remove2) { if (column.EnergyStreams.ContainsKey(id)) { column.EnergyStreams.Remove(id); } } var stageNames = column.Stages.Select((x) => x.Name).ToList(); stageNames.Insert(0, ""); var stageIDs = column.Stages.Select((x) => x.ID).ToList(); stageIDs.Insert(0, ""); s.CreateAndAddLabelRow(container, "Streams"); foreach (var si in column.MaterialStreams.Values) { if (si.StreamBehavior == StreamInformation.Behavior.Feed) { s.CreateAndAddDropDownRow(container, "[FEED] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.Sidedraw) { s.CreateAndAddDropDownRow(container, "[SIDEDRAW] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.OverheadVapor) { s.CreateAndAddDropDownRow(container, "[OVH_VAPOR] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.Distillate) { s.CreateAndAddDropDownRow(container, "[DISTILLATE] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.BottomsLiquid) { s.CreateAndAddDropDownRow(container, "[BOTTOMS] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } } foreach (var si in column.EnergyStreams.Values) { if (si.StreamBehavior == StreamInformation.Behavior.Distillate) { s.CreateAndAddDropDownRow(container, "[COND. DUTY] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } else if (si.StreamBehavior == StreamInformation.Behavior.BottomsLiquid) { s.CreateAndAddDropDownRow(container, "[REB. DUTY] " + column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag, stageNames, stageIDs.IndexOf(si.AssociatedStage), (arg1, arg2) => { si.AssociatedStage = stageIDs[arg1.SelectedIndex]; }); } } s.CreateAndAddLabelRow(container, "Side Draw Specs"); var sdphases = new List <string>() { "L", "V" }; foreach (var si in column.MaterialStreams.Values) { string sp = "L"; switch (si.StreamPhase) { case StreamInformation.Phase.L: sp = "L"; break; case StreamInformation.Phase.V: sp = "V"; break; } if (si.StreamBehavior == StreamInformation.Behavior.Sidedraw) { s.CreateAndAddDropDownRow(container, column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag + " / Draw Phase", sdphases, sdphases.IndexOf(sp), (arg1, arg2) => { switch (arg1.SelectedIndex) { case 0: si.StreamPhase = StreamInformation.Phase.L; break; case 1: si.StreamPhase = StreamInformation.Phase.V; break; } }); s.CreateAndAddTextBoxRow(container, nf, column.GetFlowsheet().SimulationObjects[si.StreamID].GraphicObject.Tag + " / Molar Flow (" + su.molarflow + ")", cv.ConvertFromSI(su.molarflow, si.FlowRate.Value), (arg1, arg2) => { if (s.IsValidDouble(arg1.Text)) { si.FlowRate.Value = cv.ConvertToSI(su.molarflow, Double.Parse(arg1.Text)); } }); } } var compounds = column.GetFlowsheet().SelectedCompounds.Keys.ToList(); compounds.Insert(0, ""); var specs = StringResources.columnspec(); var units = su.GetUnitSet(Interfaces.Enums.UnitOfMeasure.molarflow); units.AddRange(su.GetUnitSet(Interfaces.Enums.UnitOfMeasure.massflow)); units.AddRange(su.GetUnitSet(Interfaces.Enums.UnitOfMeasure.heatflow)); units.AddRange(su.GetUnitSet(Interfaces.Enums.UnitOfMeasure.temperature)); units.AddRange(new[] { "% M/M", "% W/W", "M", "We" }); units.Insert(0, ""); int cspec = 0, rspec = 0; switch (column.Specs["C"].SType) { case ColumnSpec.SpecType.Product_Molar_Flow_Rate: cspec = 0; break; case ColumnSpec.SpecType.Product_Mass_Flow_Rate: cspec = 1; break; case ColumnSpec.SpecType.Stream_Ratio: cspec = 2; break; case ColumnSpec.SpecType.Heat_Duty: cspec = 3; break; case ColumnSpec.SpecType.Component_Mass_Flow_Rate: cspec = 4; break; case ColumnSpec.SpecType.Component_Molar_Flow_Rate: cspec = 5; break; case ColumnSpec.SpecType.Component_Recovery: cspec = 6; break; case ColumnSpec.SpecType.Component_Fraction: cspec = 7; break; case ColumnSpec.SpecType.Temperature: cspec = 8; break; } switch (column.Specs["R"].SType) { case ColumnSpec.SpecType.Product_Molar_Flow_Rate: rspec = 0; break; case ColumnSpec.SpecType.Product_Mass_Flow_Rate: rspec = 1; break; case ColumnSpec.SpecType.Stream_Ratio: rspec = 2; break; case ColumnSpec.SpecType.Heat_Duty: rspec = 3; break; case ColumnSpec.SpecType.Component_Mass_Flow_Rate: rspec = 4; break; case ColumnSpec.SpecType.Component_Molar_Flow_Rate: rspec = 5; break; case ColumnSpec.SpecType.Component_Recovery: rspec = 6; break; case ColumnSpec.SpecType.Component_Fraction: rspec = 7; break; case ColumnSpec.SpecType.Temperature: rspec = 8; break; } s.CreateAndAddLabelRow(container, "Condenser Specification"); s.CreateAndAddDropDownRow(container, "Specification", specs.ToList(), cspec, (arg1, arg2) => { switch (arg1.SelectedIndex) { case 0: column.Specs["C"].SType = ColumnSpec.SpecType.Product_Molar_Flow_Rate; break; case 1: column.Specs["C"].SType = ColumnSpec.SpecType.Product_Mass_Flow_Rate; break; case 2: column.Specs["C"].SType = ColumnSpec.SpecType.Stream_Ratio; break; case 3: column.Specs["C"].SType = ColumnSpec.SpecType.Heat_Duty; break; case 4: column.Specs["C"].SType = ColumnSpec.SpecType.Component_Mass_Flow_Rate; break; case 5: column.Specs["C"].SType = ColumnSpec.SpecType.Component_Molar_Flow_Rate; break; case 6: column.Specs["C"].SType = ColumnSpec.SpecType.Component_Recovery; break; case 7: column.Specs["C"].SType = ColumnSpec.SpecType.Component_Fraction; break; case 8: column.Specs["C"].SType = ColumnSpec.SpecType.Temperature; break; } }); var cid = 0; if (compounds.Contains(column.Specs["C"].ComponentID)) { cid = compounds.IndexOf(column.Specs["C"].ComponentID); } s.CreateAndAddDropDownRow(container, "Compound", compounds, cid, (arg3, e) => { column.Specs["C"].ComponentID = compounds[arg3.SelectedIndex]; }); s.CreateAndAddTextBoxRow(container, nf, "Value", column.Specs["C"].SpecValue, (arg1, arg2) => { if (s.IsValidDouble(arg1.Text)) { column.Specs["C"].SpecValue = Double.Parse(arg1.Text); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddDropDownRow(container, "Units", units, units.IndexOf(column.Specs["C"].SpecUnit), (arg1, arg2) => { column.Specs["C"].SpecUnit = units[arg1.SelectedIndex]; }); s.CreateAndAddLabelRow(container, "Reboiler Specification"); s.CreateAndAddDropDownRow(container, "Specification", specs.ToList(), rspec, (arg1, arg2) => { switch (arg1.SelectedIndex) { case 0: column.Specs["R"].SType = ColumnSpec.SpecType.Product_Molar_Flow_Rate; break; case 1: column.Specs["R"].SType = ColumnSpec.SpecType.Product_Mass_Flow_Rate; break; case 2: column.Specs["R"].SType = ColumnSpec.SpecType.Stream_Ratio; break; case 3: column.Specs["R"].SType = ColumnSpec.SpecType.Heat_Duty; break; case 4: column.Specs["R"].SType = ColumnSpec.SpecType.Component_Mass_Flow_Rate; break; case 5: column.Specs["R"].SType = ColumnSpec.SpecType.Component_Molar_Flow_Rate; break; case 6: column.Specs["R"].SType = ColumnSpec.SpecType.Component_Recovery; break; case 7: column.Specs["R"].SType = ColumnSpec.SpecType.Component_Fraction; break; case 8: column.Specs["R"].SType = ColumnSpec.SpecType.Temperature; break; } }); var cid2 = 0; if (compounds.Contains(column.Specs["R"].ComponentID)) { cid2 = compounds.IndexOf(column.Specs["R"].ComponentID); } s.CreateAndAddDropDownRow(container, "Compound", compounds, cid2, (arg3, e) => { column.Specs["R"].ComponentID = compounds[arg3.SelectedIndex]; }); s.CreateAndAddTextBoxRow(container, nf, "Value", column.Specs["R"].SpecValue, (arg1, arg2) => { if (s.IsValidDouble(arg1.Text)) { column.Specs["R"].SpecValue = Double.Parse(arg1.Text); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddDropDownRow(container, "Units", units, units.IndexOf(column.Specs["R"].SpecUnit), (arg1, arg2) => { column.Specs["R"].SpecUnit = units[arg1.SelectedIndex]; }); s.CreateAndAddLabelRow(container, "Column Solver Selection"); var methods = new string[] { "Wang-Henke (Bubble Point)", "Naphtali-Sandholm (Newton)", "Russell (Inside-Out)", "Burningham-Otto (Sum Rates) (Absorber Only)" }; var strategies = new string[] { "Ideal K first, then Rigorous", "Ideal H first, then Rigorous", "Ideal K+H first, then Rigorous", "Direct Rigorous" }; s.CreateAndAddDropDownRow(container, "Solving Method", methods.ToList(), (int)column.SolvingMethod, (sender, e) => { column.SolvingMethod = sender.SelectedIndex; }); s.CreateAndAddDropDownRow(container, "Solving Scheme", strategies.ToList(), (int)column.SolverScheme, (sender, e) => { column.SolverScheme = (UnitOperations.UnitOperations.Column.SolvingScheme)sender.SelectedIndex; }); s.CreateAndAddTextBoxRow(container, "N0", "Maximum Iterations", column.MaxIterations, (sender, e) => { if (sender.Text.IsValidDouble()) { column.MaxIterations = (int)sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddTextBoxRow(container, nf, "Convergence Tolerance (External Loop)", column.ExternalLoopTolerance, (sender, e) => { if (sender.Text.IsValidDouble()) { column.ExternalLoopTolerance = sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddTextBoxRow(container, nf, "Convergence Tolerance (Internal Loop)", column.InternalLoopTolerance, (sender, e) => { if (sender.Text.IsValidDouble()) { column.InternalLoopTolerance = sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddTextBoxRow(container, nf, "Maximum Temperature Change Step (" + su.deltaT + ")", cv.ConvertFromSI(su.deltaT, column.MaximumTemperatureStep), (sender, e) => { if (sender.Text.IsValidDouble()) { column.MaximumTemperatureStep = cv.ConvertToSI(su.deltaT, sender.Text.ToDoubleFromCurrent()); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddLabelRow(container, "Bubble Point Solver Settings"); s.CreateAndAddTextBoxRow(container, "N0", "Stop at iteration number", column.StopAtIterationNumber, (sender, e) => { if (sender.Text.IsValidDouble()) { column.StopAtIterationNumber = (int)sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddLabelRow(container, "Newton Solver Settings"); var solvers = new List <string>() { "Limited Memory BGFS", "Truncated Newton", "Simplex", "IPOPT", "Particle Swarm", "Local Unimodal Sampling", "Gradient Descent", "Differential Evolution", "Particle Swarm Optimization", "Many Optimizing Liaisons", "Mesh" }; s.CreateAndAddDropDownRow(container, "Non-Linear Solver", solvers, (int)column.NS_Solver, (sender, e) => column.NS_Solver = (DWSIM.Interfaces.Enums.OptimizationMethod)sender.SelectedIndex); s.CreateAndAddTextBoxRow(container, nf, "Iteration Variables: Lower Bound", column.NS_LowerBound, (sender, e) => { if (sender.Text.IsValidDouble()) { column.NS_LowerBound = (int)sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddTextBoxRow(container, nf, "Iteration Variables: Upper Bound", column.NS_UpperBound, (sender, e) => { if (sender.Text.IsValidDouble()) { column.NS_UpperBound = (int)sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddTextBoxRow(container, nf, "Iteration Variables: Derivative Perturbation", column.SC_NumericalDerivativeStep, (sender, e) => { if (sender.Text.IsValidDouble()) { column.SC_NumericalDerivativeStep = (int)sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddCheckBoxRow(container, "Iteration Variables: Simplex Preconditioning", column.NS_SimplexPreconditioning, (sender, e) => column.NS_SimplexPreconditioning = sender.Checked.GetValueOrDefault(), () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddLabelRow(container, "Inside-Out Solver Settings"); s.CreateAndAddDropDownRow(container, "Non-Linear Solver", solvers, (int)column.IO_Solver, (sender, e) => column.IO_Solver = (DWSIM.Interfaces.Enums.OptimizationMethod)sender.SelectedIndex); s.CreateAndAddTextBoxRow(container, nf, "Iteration Variables: Lower Bound", column.IO_LowerBound, (sender, e) => { if (sender.Text.IsValidDouble()) { column.IO_LowerBound = (int)sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddTextBoxRow(container, nf, "Iteration Variables: Upper Bound", column.IO_UpperBound, (sender, e) => { if (sender.Text.IsValidDouble()) { column.IO_UpperBound = (int)sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddTextBoxRow(container, nf, "Iteration Variables: Derivative Perturbation", column.IO_NumericalDerivativeStep, (sender, e) => { if (sender.Text.IsValidDouble()) { column.IO_NumericalDerivativeStep = (int)sender.Text.ToDoubleFromCurrent(); } }, () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddCheckBoxRow(container, "Adjust Sb Scaling Factor", column.AdjustSb, (sender, e) => column.AdjustSb = sender.Checked.GetValueOrDefault(), () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddCheckBoxRow(container, "Calculate Kb by Weighted Average", column.KbjWeightedAverage, (sender, e) => column.KbjWeightedAverage = sender.Checked.GetValueOrDefault(), () => { if (GlobalSettings.Settings.CallSolverOnEditorPropertyChanged) { ((Shared.Flowsheet)column.GetFlowsheet()).HighLevelSolve.Invoke(); } }); s.CreateAndAddEmptySpace(container); s.CreateAndAddEmptySpace(container); s.CreateAndAddEmptySpace(container); }