public void Init() { loaded = false; Pages.Clear(); // connections if (obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.MaterialStream && obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.EnergyStream && obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.OT_Adjust && obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.Controller_PID && obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.LevelGauge && obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.AnalogGauge && obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.DigitalGauge && obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.Input && obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.Switch && obj.GraphicObject.ObjectType != Interfaces.Enums.GraphicObjects.ObjectType.OT_Spec) { var tab1 = new DocumentPage { Closable = false }; tab1.Text = "Connections"; var cont0 = UI.Shared.Common.GetDefaultContainer(); UI.Shared.Common.CreateAndAddLabelRow(cont0, "Object Connections Editor".Localize()); UI.Shared.Common.CreateAndAddDescriptionRow(cont0, "ConnectorsEditorDescription".Localize()); new DWSIM.UI.Desktop.Editors.ConnectionsEditor(obj, cont0); cont0.Width = this.Width - 30; var scr1 = new Scrollable() { Content = cont0 }; tab1.Content = scr1; Pages.Add(tab1); PageConnections = tab1; } // properties var tab2 = new DocumentPage { Closable = false }; tab2.Text = "Properties"; Pages.Add(tab2); var cont = UI.Shared.Common.GetDefaultContainer(); cont.Width = this.Width - 30; if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.MaterialStream) { new DWSIM.UI.Desktop.Editors.MaterialStreamEditor(obj, cont); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.DistillationColumn) { new DWSIM.UI.Desktop.Editors.DistillationColumnEditor(obj, cont); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.AbsorptionColumn) { new DWSIM.UI.Desktop.Editors.AbsorptionColumnEditor(obj, cont); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.OT_Adjust) { DWSIM.UI.Desktop.Editors.LogicalBlocks.AdjustEditor.Populate(obj, cont); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.Controller_PID) { DWSIM.UI.Desktop.Editors.LogicalBlocks.PIDControllerEditor.Populate(obj, cont); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.OT_Spec) { DWSIM.UI.Desktop.Editors.LogicalBlocks.SpecEditor.Populate(obj, cont); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.OT_Recycle) { DWSIM.UI.Desktop.Editors.LogicalBlocks.RecycleEditor.Populate(obj, cont); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.OT_EnergyRecycle) { DWSIM.UI.Desktop.Editors.LogicalBlocks.EnergyRecycleEditor.Populate(obj, cont); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.LevelGauge) { DWSIM.UI.Desktop.Editors.LogicalBlocks.LevelGaugeEditor.Populate(obj, cont); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.AnalogGauge) { DWSIM.UI.Desktop.Editors.LogicalBlocks.AnalogGaugeEditor.Populate(obj, cont); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.DigitalGauge) { DWSIM.UI.Desktop.Editors.LogicalBlocks.DigitalGaugeEditor.Populate(obj, cont); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.Switch) { DWSIM.UI.Desktop.Editors.LogicalBlocks.SwitchEditor.Populate(obj, cont); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.Input) { DWSIM.UI.Desktop.Editors.LogicalBlocks.InputEditor.Populate(obj, cont); } else { new DWSIM.UI.Desktop.Editors.GeneralEditors(obj, cont); } tab2.Content = new Scrollable() { Content = cont, Width = this.Width - 30 }; if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.Pipe) { tab2.Text = "General"; var cont2 = UI.Shared.Common.GetDefaultContainer(); cont2.Tag = "Hydraulic Profile"; cont2.Width = this.Width - 30; new PipeHydraulicProfile(obj, cont2); Pages.Add(new DocumentPage(new Scrollable() { Content = cont2, Width = this.Width - 30 }) { Text = "Hydraulic Profile", Closable = false }); var cont3 = UI.Shared.Common.GetDefaultContainer(); cont3.Tag = "Thermal Profile"; cont3.Width = this.Width - 30; new PipeThermalProfile(obj, ((Pipe)obj).ThermalProfile, cont3); Pages.Add(new DocumentPage(new Scrollable() { Content = cont3, Width = this.Width - 30 }) { Text = "Thermal Profile", Closable = false }); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.CustomUO) { tab2.Text = "General"; var cont2 = new TableLayout { Padding = new Padding(10), Spacing = new Size(5, 5) }; cont2.Tag = "Python Script"; cont2.Width = this.Width - 30; if (Application.Instance.Platform.IsWpf) { var scripteditor = new Eto.Forms.Controls.Scintilla.Shared.ScintillaControl() { ScriptText = ((CustomUO)obj).ScriptText }; var dyn1 = new DynamicLayout(); dyn1.CreateAndAddLabelAndButtonRow("Click to commit script changes", "Update", null, (sender, e) => { ((CustomUO)obj).ScriptText = scripteditor.ScriptText; }); dyn1.Width = this.Width - 30; cont2.Rows.Add(new TableRow(dyn1)); cont2.Rows.Add(new TableRow(scripteditor)); } else if (Application.Instance.Platform.IsMac || Application.Instance.Platform.IsGtk) { var scripteditor = new Eto.Forms.Controls.Scintilla.Shared.ScintillaControl() { ScriptText = ((CustomUO)obj).ScriptText }; scripteditor.SetKeywords(1, ((FlowsheetBase.FlowsheetBase)obj.GetFlowsheet()).ScriptKeywordsU); var dyn1 = new DynamicLayout(); dyn1.CreateAndAddLabelAndButtonRow("Click to commit script changes", "Update", null, (sender, e) => { ((CustomUO)obj).ScriptText = scripteditor.ScriptText; }); dyn1.Width = this.Width - 30; cont2.Rows.Add(new TableRow(dyn1)); cont2.Rows.Add(new TableRow(scripteditor)); } Pages.Add(new DocumentPage(new Scrollable() { Content = cont2, Width = this.Width - 30 }) { Text = "Python Script", Closable = false }); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.HeatExchanger) { tab2.Text = "General"; var dyn1 = new ShellAndTubePropertiesView(obj); dyn1.Width = this.Width - 30; Pages.Add(new DocumentPage(new Scrollable() { Content = dyn1, Width = this.Width - 30 }) { Text = "Shell and Tube Properties", Closable = false }); } else if (obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.AbsorptionColumn || obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.DistillationColumn) { tab2.Text = "General"; var dyn2 = RigorousColumnShared.GetInitialEstimatesEditor((Column)obj); dyn2.Width = this.Width - 30; Pages.Add(new DocumentPage(new Scrollable() { Content = dyn2, Width = this.Width - 30 }) { Text = "Initial Estimates", Closable = false }); } PageEditor = tab2; // dynamics if ((obj.SupportsDynamicMode && obj.HasPropertiesForDynamicMode) || obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.MaterialStream) { if (obj.ExtraPropertiesDescriptions.Count() > 0 || obj.GraphicObject.ObjectType == Interfaces.Enums.GraphicObjects.ObjectType.MaterialStream) { var tabd = new DocumentPage { Closable = false }; tabd.Text = "Dynamics"; var contd = UI.Shared.Common.GetDefaultContainer(); contd.Width = this.Width - 30; new DynamicPropertiesEditor(obj, contd); tabd.Content = new Scrollable() { Content = contd, Width = this.Width - 30 }; PageDynamics = tabd; Pages.Add(tabd); } } // results var tabr = new DocumentPage { Closable = false }; tabr.Text = "Results"; var container = new TableLayout(); new DWSIM.UI.Desktop.Editors.Results(obj, container); tabr.Content = new Scrollable() { Content = container, Width = this.Width - 30 }; PageResults = tabr; Pages.Add(tabr); if (obj.GraphicObject is ShapeGraphic) { var tabx = new DocumentPage { Closable = false }; tabx.Text = "Appearance"; var editor = new ObjectAppearanceEditorView(obj.GetFlowsheet(), (ShapeGraphic)obj.GraphicObject); editor.Width = this.Width - 30; tabx.Content = new Scrollable() { Content = editor, Width = this.Width - 30 }; Pages.Add(tabx); } if (SelectedPanel >= 0) { SelectedIndex = SelectedPanel; } loaded = true; }
void Init() { chkLink = new CheckBox { Text = "Link Script", Height = 22 }; chkLink.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); var lbl1 = new Label { Text = "Object", VerticalAlignment = VerticalAlignment.Center }; var lbl2 = new Label { Text = "Event", VerticalAlignment = VerticalAlignment.Center }; var lbl3 = new Label { Text = "Python Interpreter", VerticalAlignment = VerticalAlignment.Center }; lbl1.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); lbl2.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); lbl3.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); cbLinkedObject = new DropDown(); cbLinkedEvent = new DropDown(); cbPythonInt = new DropDown(); cbLinkedObject.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); cbLinkedEvent.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); cbPythonInt.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); cbLinkedEvent.Items.AddRange(new String[] { "Simulation Opened", "Simulation Saved", "Simulation Closed", "1 min. Timer", "5 min. Timer", "15 min. Timer", "30 min. Timer", "60 min. Timer" }.Select((x) => new ListItem { Key = x, Text = x })); cbPythonInt.Items.AddRange(new String[] { "IronPython", "Python.NET" }.Select((x) => new ListItem { Key = x, Text = x })); var tr1 = new TableRow(chkLink, lbl1, cbLinkedObject, lbl2, cbLinkedEvent, null, lbl3, cbPythonInt); var tb1 = new TableLayout { Spacing = new Size(5, 5), Padding = new Padding(0, 0, 0, 10) }; tb1.Rows.Add(tr1); tb1.Height = 34; cbLinkedObject.SelectedIndexChanged += (sender, e) => { if (cbLinkedObject.SelectedIndex < 0) { return; } switch (cbLinkedObject.SelectedIndex) { case 0: cbLinkedEvent.Items.Clear(); cbLinkedEvent.Items.AddRange(new string[] { "Simulation Opened", "Simulation Saved", "Simulation Closed", "1 min. Timer", "5 min. Timer", "15 min. Timer", "30 min. Timer", "60 min. Timer" }.Select((x) => new ListItem { Key = x, Text = x })); break; case 1: cbLinkedEvent.Items.Clear(); cbLinkedEvent.Items.AddRange(new string[] { "Solver Started", "Solver Finished", "Recycle Loop" }.Select((x) => new ListItem { Key = x, Text = x })); break; default: cbLinkedEvent.Items.Clear(); cbLinkedEvent.Items.AddRange(new string[] { "Object Calculation Started", "Object Calculation Finished", "Object Calculation Error" }.Select((x) => new ListItem { Key = x, Text = x })); break; } cbLinkedEvent.SelectedIndex = 0; }; Rows.Add(new TableRow(tb1)); if (!(Application.Instance.Platform.IsGtk && Settings.RunningPlatform() == Settings.Platform.Mac)) { txtScript = new Eto.Forms.Controls.Scintilla.Shared.ScintillaControl(); txtScript.SetKeywords(1, flowsheet.ScriptKeywordsF); var tr3 = new TableRow((Eto.Forms.Controls.Scintilla.Shared.ScintillaControl)txtScript); var tb3 = new TableLayout { Spacing = new Size(5, 5) }; tb3.Rows.Add(tr3); Rows.Add(new TableRow(tb3)); } }
void Init() { var script = flowsheet.Scripts[scriptID]; txtScript = new Eto.Forms.Controls.Scintilla.Shared.ScintillaControl(); txtScript.SetKeywords(1, flowsheet.ScriptKeywordsF); chkLink = new CheckBox { Text = "Link Script" }; chkLink.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); var lbl1 = new Label { Text = "Object", VerticalAlignment = VerticalAlignment.Center }; var lbl2 = new Label { Text = "Event", VerticalAlignment = VerticalAlignment.Center }; var lbl3 = new Label { Text = "Python Interpreter", VerticalAlignment = VerticalAlignment.Center }; lbl1.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); lbl2.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); lbl3.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); var btn1 = new Button { Text = "Update Script" }; var btn2 = new Button { Text = "Update and Run" }; var btn3 = new Button { Text = "Update and Run (Async)" }; btn1.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); btn2.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); btn3.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); btn1.Click += (sender, e) => { flowsheet.Scripts[scriptID].ScriptText = txtScript.ScriptText; }; btn2.Click += (sender, e) => { flowsheet.Scripts[scriptID].ScriptText = txtScript.ScriptText; flowsheet.ShowMessage("Running script '" + script.Title + "'...", IFlowsheet.MessageType.Information); flowsheet.RunScript(scriptID); }; btn3.Click += (sender, e) => { flowsheet.Scripts[scriptID].ScriptText = txtScript.ScriptText; flowsheet.ShowMessage("Running script '" + script.Title + "' asynchronously...", IFlowsheet.MessageType.Information); flowsheet.RunScriptAsync(scriptID); }; var lbl4 = new Label { Text = "Script Name", VerticalAlignment = VerticalAlignment.Center }; lbl4.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); txtName = new TextBox { Text = "Script Name" }; txtName.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); cbLinkedObject = new DropDown(); cbLinkedEvent = new DropDown(); cbPythonInt = new DropDown(); cbLinkedObject.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); cbLinkedEvent.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); cbPythonInt.Font = new Font(SystemFont.Default, DWSIM.UI.Shared.Common.GetEditorFontSize()); cbLinkedEvent.Items.AddRange(new String[] { "Simulation Opened", "Simulation Saved", "Simulation Closed", "1 min. Timer", "5 min. Timer", "15 min. Timer", "30 min. Timer", "60 min. Timer" }.Select((x) => new ListItem { Key = x, Text = x })); cbPythonInt.Items.AddRange(new String[] { "IronPython", "Python.NET" }.Select((x) => new ListItem { Key = x, Text = x })); var tr1 = new TableRow(btn1, btn2, btn3, lbl4, txtName, chkLink, lbl1, cbLinkedObject, lbl2, cbLinkedEvent, lbl3, cbPythonInt); tr1.Cells[4].ScaleWidth = true; var tb1 = new TableLayout { Spacing = new Size(5, 5), Padding = new Padding(0, 0, 0, 10) }; tb1.Rows.Add(tr1); cbLinkedObject.SelectedIndexChanged += (sender, e) => { if (cbLinkedObject.SelectedIndex < 0) { return; } switch (cbLinkedObject.SelectedIndex) { case 0: cbLinkedEvent.Items.Clear(); cbLinkedEvent.Items.AddRange(new string[] { "Simulation Opened", "Simulation Saved", "Simulation Closed", "1 min. Timer", "5 min. Timer", "15 min. Timer", "30 min. Timer", "60 min. Timer" }.Select((x) => new ListItem { Key = x, Text = x })); break; case 1: cbLinkedEvent.Items.Clear(); cbLinkedEvent.Items.AddRange(new string[] { "Solver Started", "Solver Finished", "Recycle Loop" }.Select((x) => new ListItem { Key = x, Text = x })); break; default: cbLinkedEvent.Items.Clear(); cbLinkedEvent.Items.AddRange(new string[] { "Object Calculation Started", "Object Calculation Finished", "Object Calculation Error" }.Select((x) => new ListItem { Key = x, Text = x })); break; } cbLinkedEvent.SelectedIndex = 0; }; var tr3 = new TableRow(txtScript); var tb3 = new TableLayout { Spacing = new Size(5, 5) }; tb3.Rows.Add(tr3); Rows.Add(new TableRow(tb1)); Rows.Add(new TableRow(tb3)); cbLinkedObject.Items.Clear(); cbLinkedObject.Items.Add(new ListItem { Text = "Simulation", Key = "Simulation" }); cbLinkedObject.Items.Add(new ListItem { Text = "Solver", Key = "Solver" }); foreach (var obj in flowsheet.SimulationObjects.Values) { cbLinkedObject.Items.Add(new ListItem { Text = obj.GraphicObject.Tag, Key = obj.Name }); } txtName.Text = script.Title; txtScript.ScriptText = script.ScriptText; chkLink.Checked = script.Linked; if (!string.IsNullOrEmpty(script.LinkedObjectName)) { if (flowsheet.SimulationObjects.ContainsKey(script.LinkedObjectName)) { cbLinkedObject.SelectedKey = script.LinkedObjectName; } } else { switch (script.LinkedObjectType) { case Scripts.ObjectType.Simulation: cbLinkedObject.SelectedIndex = 0; break; case Scripts.ObjectType.Solver: cbLinkedObject.SelectedIndex = 1; break; } } switch (script.LinkedEventType) { case Scripts.EventType.ObjectCalculationStarted: cbLinkedEvent.SelectedIndex = 0; break; case Scripts.EventType.ObjectCalculationFinished: cbLinkedEvent.SelectedIndex = 1; break; case Scripts.EventType.ObjectCalculationError: cbLinkedEvent.SelectedIndex = 2; break; case Scripts.EventType.SimulationOpened: cbLinkedEvent.SelectedIndex = 0; break; case Scripts.EventType.SimulationSaved: cbLinkedEvent.SelectedIndex = 1; break; case Scripts.EventType.SimulationClosed: cbLinkedEvent.SelectedIndex = 2; break; case Scripts.EventType.SolverStarted: cbLinkedEvent.SelectedIndex = 0; break; case Scripts.EventType.SolverFinished: cbLinkedEvent.SelectedIndex = 1; break; case Scripts.EventType.SolverRecycleLoop: cbLinkedEvent.SelectedIndex = 2; break; case Scripts.EventType.SimulationTimer1: cbLinkedEvent.SelectedIndex = 3; break; case Scripts.EventType.SimulationTimer5: cbLinkedEvent.SelectedIndex = 4; break; case Scripts.EventType.SimulationTimer15: cbLinkedEvent.SelectedIndex = 5; break; case Scripts.EventType.SimulationTimer30: cbLinkedEvent.SelectedIndex = 6; break; case Scripts.EventType.SimulationTimer60: cbLinkedEvent.SelectedIndex = 7; break; } cbPythonInt.SelectedIndex = (int)script.PythonInterpreter; cbPythonInt.SelectedIndexChanged += (sender, e) => { script.PythonInterpreter = (DWSIM.Interfaces.Enums.Scripts.Interpreter)cbPythonInt.SelectedIndex; }; chkLink.CheckedChanged += (sender, e) => { flowsheet.Scripts[scriptID].Linked = chkLink.Checked.GetValueOrDefault(); }; txtName.TextChanged += (sender, e) => { script.Title = txtName.Text; if (ChangeNameCallback != null) { ChangeNameCallback.Invoke(txtName.Text); } }; cbLinkedObject.SelectedIndexChanged += cbLinkedObject_SelectedIndexChanged; cbLinkedEvent.SelectedIndexChanged += cbLinkedObject_SelectedIndexChanged; }