From 0ca87e490fbfd2686d76d1b511d7dad7646ae7b8 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Sun, 30 Aug 2020 23:52:51 -0400 Subject: [PATCH] move to UWT ContainerLayout/Glade UI, add IcarusCommandPlay --- .../IcarusExpressionHelperDialog.glade | 82 +++++++++++++++++++ .../Icarus/IcarusScriptEditor.glade | 60 ++++++++++++++ ...lEditor.Content.PlatformIndependent.csproj | 2 + .../IcarusExpressionHelperDialog.Designer.cs | 54 ------------ .../Icarus/IcarusExpressionHelperDialog.cs | 41 +++++++--- .../Icarus/IcarusScriptEditor.Designer.cs | 55 ------------- .../Editors/Icarus/IcarusScriptEditor.cs | 22 ++++- ...Plugins.RavenSoftware.UserInterface.csproj | 2 - .../Icarus/Commands/IcarusCommandPlay.cs | 50 +++++++++++ .../UniversalEditor.Plugins.Icarus.csproj | 1 + 10 files changed, 245 insertions(+), 124 deletions(-) create mode 100644 Content/UniversalEditor.Content.PlatformIndependent/Editors/RavenSoftware/Icarus/Dialogs/IcarusExpressionHelperDialog.glade create mode 100644 Content/UniversalEditor.Content.PlatformIndependent/Editors/RavenSoftware/Icarus/IcarusScriptEditor.glade delete mode 100644 Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Dialogs/Icarus/IcarusExpressionHelperDialog.Designer.cs delete mode 100644 Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Editors/Icarus/IcarusScriptEditor.Designer.cs create mode 100644 Plugins/UniversalEditor.Plugins.Icarus/ObjectModels/Icarus/Commands/IcarusCommandPlay.cs diff --git a/Content/UniversalEditor.Content.PlatformIndependent/Editors/RavenSoftware/Icarus/Dialogs/IcarusExpressionHelperDialog.glade b/Content/UniversalEditor.Content.PlatformIndependent/Editors/RavenSoftware/Icarus/Dialogs/IcarusExpressionHelperDialog.glade new file mode 100644 index 00000000..802e1e63 --- /dev/null +++ b/Content/UniversalEditor.Content.PlatformIndependent/Editors/RavenSoftware/Icarus/Dialogs/IcarusExpressionHelperDialog.glade @@ -0,0 +1,82 @@ + + + + + + False + Expression Editor + dialog + + + + + + False + vertical + 2 + + + False + end + + + gtk-ok + True + True + True + True + + + + True + True + 0 + + + + + gtk-cancel + True + True + True + True + + + True + True + 1 + + + + + False + False + 0 + + + + + True + False + + + + + + + + + + + + True + True + 1 + + + + + + diff --git a/Content/UniversalEditor.Content.PlatformIndependent/Editors/RavenSoftware/Icarus/IcarusScriptEditor.glade b/Content/UniversalEditor.Content.PlatformIndependent/Editors/RavenSoftware/Icarus/IcarusScriptEditor.glade new file mode 100644 index 00000000..f0def8a2 --- /dev/null +++ b/Content/UniversalEditor.Content.PlatformIndependent/Editors/RavenSoftware/Icarus/IcarusScriptEditor.glade @@ -0,0 +1,60 @@ + + + + + + + + + + + + False + + + + + + True + False + vertical + + + True + True + in + + + True + True + tm + + + + + + True + Command + True + True + + + + 0 + + + + + + + + + True + True + 0 + + + + + + diff --git a/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj b/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj index b769e34a..47ddd581 100644 --- a/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj +++ b/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj @@ -304,6 +304,8 @@ + + diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Dialogs/Icarus/IcarusExpressionHelperDialog.Designer.cs b/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Dialogs/Icarus/IcarusExpressionHelperDialog.Designer.cs deleted file mode 100644 index f8e28efc..00000000 --- a/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Dialogs/Icarus/IcarusExpressionHelperDialog.Designer.cs +++ /dev/null @@ -1,54 +0,0 @@ -// -// IcarusExpressionHelperDialog.Designer.cs - UWT designer initialization for IcarusExpressionHelperDialog -// -// Author: -// Michael Becker -// -// Copyright (c) 2019-2020 Mike Becker's Software -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; - -using MBS.Framework.UserInterface; -using MBS.Framework.UserInterface.Controls; -using MBS.Framework.UserInterface.Layouts; - -namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Dialogs.Icarus -{ - partial class IcarusExpressionHelperDialog - { - /// - /// UWT designer initialization for . - /// - /// - /// UWT designer initialization in code is deprecated; continue improving the cross-platform Glade XML parser for ! - /// - private void InitializeComponent() - { - this.Buttons.Add(new Button(StockType.OK, cmdOK_Click)); - this.Buttons.Add(new Button(StockType.Cancel, DialogResult.Cancel)); - - this.Layout = new BoxLayout(Orientation.Horizontal); - - this.Name = "IcarusExpressionHelperDialog"; - this.Text = "Expression Helper"; - } - - protected override void OnCreating(EventArgs e) - { - base.OnCreating(e); - } - } -} \ No newline at end of file diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Dialogs/Icarus/IcarusExpressionHelperDialog.cs b/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Dialogs/Icarus/IcarusExpressionHelperDialog.cs index 23460ad4..c2512aa9 100644 --- a/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Dialogs/Icarus/IcarusExpressionHelperDialog.cs +++ b/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Dialogs/Icarus/IcarusExpressionHelperDialog.cs @@ -20,8 +20,11 @@ // along with this program. If not, see . using System; + using MBS.Framework.UserInterface; +using MBS.Framework.UserInterface.Controls; using MBS.Framework.UserInterface.Layouts; + using UniversalEditor.ObjectModels.Icarus; using UniversalEditor.ObjectModels.Icarus.Expressions; using UniversalEditor.Plugins.RavenSoftware.UserInterface.Controls.Icarus; @@ -31,11 +34,33 @@ namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Dialogs.Icarus /// /// Provides a UWT-based with controls for editing an expression in an Icarus script. /// + [ContainerLayout("~/Editors/RavenSoftware/Icarus/Dialogs/IcarusExpressionHelperDialog.glade")] public partial class IcarusExpressionHelperDialog : CustomDialog { - public IcarusExpressionHelperDialog() + private Button cmdOK; + private Button cmdCancel; + + private Container ct; + + protected override void OnCreated(EventArgs e) { - InitializeComponent(); + base.OnCreated(e); + + DefaultButton = cmdOK; + UpdateCommandParameters(); + } + + private void UpdateCommandParameters() + { + if (!IsCreated) return; + + ct.Controls.Clear(); + for (int i = 0; i < _Command.Parameters.Count; i++) + { + IcarusExpressionEditor ed = new IcarusExpressionEditor(); + ed.Parameter = _Command.Parameters[i]; + ct.Controls.Add(ed, new BoxLayout.Constraints(true, true)); + } } private IcarusCommand _Command = null; @@ -45,22 +70,16 @@ namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Dialogs.Icarus set { _Command = value; - - this.Controls.Clear(); - for (int i = 0; i < _Command.Parameters.Count; i++) - { - IcarusExpressionEditor ed = new IcarusExpressionEditor(); - ed.Parameter = _Command.Parameters[i]; - this.Controls.Add(ed, new BoxLayout.Constraints(true, true)); - } + UpdateCommandParameters(); } } + [EventHandler(nameof(cmdOK), "Click")] private void cmdOK_Click(object sender, EventArgs e) { for (int i = 0; i < _Command.Parameters.Count; i++) { - IcarusExpressionEditor ed = Controls[i] as IcarusExpressionEditor; + IcarusExpressionEditor ed = ct.Controls[i] as IcarusExpressionEditor; if (ed.cboExpressionType.SelectedItem == (ed.cboExpressionType.Model as DefaultTreeModel).Rows[0]) { // constant diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Editors/Icarus/IcarusScriptEditor.Designer.cs b/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Editors/Icarus/IcarusScriptEditor.Designer.cs deleted file mode 100644 index e0720ca4..00000000 --- a/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Editors/Icarus/IcarusScriptEditor.Designer.cs +++ /dev/null @@ -1,55 +0,0 @@ -// -// IcarusScriptEditor.Designer.cs - UWT designer initialization for IcarusScriptEditor -// -// Author: -// Michael Becker -// -// Copyright (c) 2019-2020 Mike Becker's Software -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU General Public License for more details. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . - -using System; -using MBS.Framework.UserInterface; -using MBS.Framework.UserInterface.Controls; -using MBS.Framework.UserInterface.Controls.ListView; -using MBS.Framework.UserInterface.Layouts; - -namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Editors.Icarus -{ - partial class IcarusScriptEditor - { - /// - /// UWT designer initialization for . - /// - /// - /// UWT designer initialization in code is deprecated; continue improving the cross-platform Glade XML parser for ! - /// - private void InitializeComponent() - { - this.Layout = new BoxLayout(Orientation.Vertical); - - this.tm = new DefaultTreeModel(new Type[] { typeof(string) }); - - this.tv = new ListViewControl(); - this.tv.ContextMenuCommandID = "Icarus_ContextMenu"; - this.tv.Model = this.tm; - this.tv.Columns.Add(new ListViewColumnText(this.tm.Columns[0], "Command")); - this.tv.RowActivated += new ListViewRowActivatedEventHandler(this.tv_RowActivated); - this.Controls.Add(this.tv, new BoxLayout.Constraints(true, true)); - } - - private DefaultTreeModel tm; - private ListViewControl tv; - } -} diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Editors/Icarus/IcarusScriptEditor.cs b/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Editors/Icarus/IcarusScriptEditor.cs index b92ce1c9..9d9f66ef 100644 --- a/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Editors/Icarus/IcarusScriptEditor.cs +++ b/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/Editors/Icarus/IcarusScriptEditor.cs @@ -42,8 +42,11 @@ namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Editors.Icarus /// /// Provides a UWT-based for an . /// - public partial class IcarusScriptEditor : Editor + [ContainerLayout("~/Editors/RavenSoftware/Icarus/IcarusScriptEditor.glade")] + public class IcarusScriptEditor : Editor { + private ListViewControl tv; + public static IcarusScriptEditorConfiguration IcarusConfiguration { get; } = new IcarusScriptEditorConfiguration(); private static EditorReference _er = null; @@ -58,11 +61,22 @@ namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Editors.Icarus return _er; } + protected override void OnCreated(EventArgs e) + { + base.OnCreated(e); + + tv.ContextMenuCommandID = "Icarus_ContextMenu"; + OnObjectModelChanged(EventArgs.Empty); + } + protected override void OnToolboxItemActivated(ToolboxItemEventArgs e) { base.OnToolboxItemActivated(e); IcarusScriptEditorCommand cmd = e.Item.GetExtraData("command"); + + BeginEdit(); RecursiveAddCommand(ScriptEditorCommandToOMCommand(cmd)); + EndEdit(); } private IcarusCommand ScriptEditorCommandToOMCommand(IcarusScriptEditorCommand cmd) @@ -200,7 +214,6 @@ namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Editors.Icarus public IcarusScriptEditor() { - InitializeComponent(); // mnuContextRun.Font = new Font(mnuContextRun.Font, FontStyle.Bold); // mnuContextRun.IsDefault = true; @@ -477,16 +490,20 @@ namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Editors.Icarus { base.OnObjectModelChanged(e); + if (!IsCreated) return; + tv.Model.Rows.Clear(); treeNodesForCommands.Clear(); IcarusScriptObjectModel script = (ObjectModel as IcarusScriptObjectModel); if (script == null) return; + BeginEdit(); foreach (IcarusCommand command in script.Commands) { RecursiveAddCommand(command); } + EndEdit(); } private void RecursiveAddCommand(IcarusCommand command, TreeModelRow parent = null) @@ -561,6 +578,7 @@ namespace UniversalEditor.Plugins.RavenSoftware.UserInterface.Editors.Icarus return sb.ToString(); } + [EventHandler(nameof(tv), "RowActivated")] private void tv_RowActivated(object sender, ListViewRowActivatedEventArgs e) { if (e.Row != null) diff --git a/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface.csproj b/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface.csproj index c98bd91f..5399dc9c 100644 --- a/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface.csproj +++ b/Plugins.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface/UniversalEditor.Plugins.RavenSoftware.UserInterface.csproj @@ -32,9 +32,7 @@ - - diff --git a/Plugins/UniversalEditor.Plugins.Icarus/ObjectModels/Icarus/Commands/IcarusCommandPlay.cs b/Plugins/UniversalEditor.Plugins.Icarus/ObjectModels/Icarus/Commands/IcarusCommandPlay.cs new file mode 100644 index 00000000..8a9ea60a --- /dev/null +++ b/Plugins/UniversalEditor.Plugins.Icarus/ObjectModels/Icarus/Commands/IcarusCommandPlay.cs @@ -0,0 +1,50 @@ +// +// IcarusCommandPlay.cs - represents the ICARUS 'play' command +// +// Author: +// Michael Becker +// +// Copyright (c) 2020 Mike Becker's Software +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . + +using UniversalEditor.ObjectModels.Icarus.Parameters; + +namespace UniversalEditor.ObjectModels.Icarus.Commands +{ + /// + /// Represents the ICARUS 'play' command. + /// + public class IcarusCommandPlay : IcarusPredefinedCommand + { + public IcarusCommandPlay() + { + Parameters.Add(new IcarusGenericParameter("Type")); + Parameters.Add(new IcarusGenericParameter("Target")); + } + + public override string Name => "play"; + + public IcarusExpression Type { get { return Parameters[0].Value; } set { Parameters[0].Value = value; } } + public IcarusExpression Target { get { return Parameters[1].Value; } set { Parameters[1].Value = value; } } + + public override object Clone() + { + IcarusCommandPlay clone = new IcarusCommandPlay(); + clone.Type = (Type.Clone() as IcarusExpression); + clone.Target = (Target.Clone() as IcarusExpression); + return clone; + } + } +} diff --git a/Plugins/UniversalEditor.Plugins.Icarus/UniversalEditor.Plugins.Icarus.csproj b/Plugins/UniversalEditor.Plugins.Icarus/UniversalEditor.Plugins.Icarus.csproj index b1a91b09..2f97a547 100644 --- a/Plugins/UniversalEditor.Plugins.Icarus/UniversalEditor.Plugins.Icarus.csproj +++ b/Plugins/UniversalEditor.Plugins.Icarus/UniversalEditor.Plugins.Icarus.csproj @@ -81,6 +81,7 @@ +