From 255e61deb34464d108153abe09f11d3b55f23f33 Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Sun, 3 May 2020 19:26:37 -0400 Subject: [PATCH] finish implementing the PropertyListEditor as a UWT ContainerLayout-based control --- .../PropertyList/PropertyListEditor.glade | 59 +++++++++++++ ...lEditor.Content.PlatformIndependent.csproj | 1 + .../PropertyListEditor.Designer.cs | 40 --------- .../PropertyList/PropertyListEditor.cs | 82 +++++++++++++++++-- .../UniversalEditor.UserInterface.csproj | 1 - 5 files changed, 135 insertions(+), 48 deletions(-) create mode 100644 Content/UniversalEditor.Content.PlatformIndependent/Editors/PropertyList/PropertyListEditor.glade delete mode 100644 Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListEditor.Designer.cs diff --git a/Content/UniversalEditor.Content.PlatformIndependent/Editors/PropertyList/PropertyListEditor.glade b/Content/UniversalEditor.Content.PlatformIndependent/Editors/PropertyList/PropertyListEditor.glade new file mode 100644 index 00000000..ee10ea38 --- /dev/null +++ b/Content/UniversalEditor.Content.PlatformIndependent/Editors/PropertyList/PropertyListEditor.glade @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + False + + + + + + True + True + tm + + + + + + True + Name + True + True + 0 + + + + 0 + + + + + + + True + Value + True + True + 1 + + + + 1 + + + + + + + + diff --git a/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj b/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj index dec5c4b8..6fde6864 100644 --- a/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj +++ b/Content/UniversalEditor.Content.PlatformIndependent/UniversalEditor.Content.PlatformIndependent.csproj @@ -719,6 +719,7 @@ + diff --git a/Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListEditor.Designer.cs b/Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListEditor.Designer.cs deleted file mode 100644 index 46f0c50e..00000000 --- a/Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListEditor.Designer.cs +++ /dev/null @@ -1,40 +0,0 @@ -// -// PropertyListEditor.Designer.cs -// -// Author: -// Michael Becker -// -// Copyright (c) 2019 -// -// 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.Editors.PropertyList -{ - partial class PropertyListEditor - { - private ListView tv = null; - - private void InitializeComponent() - { - this.Layout = new BoxLayout(Orientation.Vertical); - - this.tv = new ListView(); - this.Controls.Add(tv, new BoxLayout.Constraints(true, true)); - } - } -} diff --git a/Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListEditor.cs b/Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListEditor.cs index 77046813..a167babf 100644 --- a/Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListEditor.cs +++ b/Libraries/UniversalEditor.UserInterface/Editors/PropertyList/PropertyListEditor.cs @@ -1,10 +1,10 @@ // -// PropertyListEditor.cs +// PropertyListEditor.cs - cross-platform (UWT) property list editor for Universal Editor // // Author: // Michael Becker // -// Copyright (c) 2019 +// 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 @@ -18,17 +18,22 @@ // // 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 UniversalEditor.ObjectModels.PropertyList; using UniversalEditor.UserInterface; + namespace UniversalEditor.Editors.PropertyList { - public partial class PropertyListEditor : Editor + [ContainerLayout("~/Editors/PropertyList/PropertyListEditor.glade")] + public class PropertyListEditor : Editor { - public PropertyListEditor() - { - this.InitializeComponent(); - } + private ListView tv = null; + private DefaultTreeModel tm = null; private static EditorReference _er = null; public override EditorReference MakeReference() @@ -50,9 +55,72 @@ namespace UniversalEditor.Editors.PropertyList throw new NotImplementedException(); } + protected override void OnCreated(EventArgs e) + { + base.OnCreated(e); + OnObjectModelChanged(EventArgs.Empty); + } + protected override void OnObjectModelChanged(EventArgs e) { base.OnObjectModelChanged(e); + + if (!IsCreated) return; + + PropertyListObjectModel plom = (ObjectModel as PropertyListObjectModel); + for (int i = 0; i < plom.Properties.Count; i++) + { + RecursiveAddProperty(plom.Properties[i], null); + } + for (int i = 0; i < plom.Groups.Count; i++) + { + RecursiveAddGroup(plom.Groups[i], null); + } + } + + private void RecursiveAddProperty(Property p, TreeModelRow parent = null) + { + TreeModelRow row = new TreeModelRow(new TreeModelRowColumn[] + { + new TreeModelRowColumn(tm.Columns[0], p.Name), + new TreeModelRowColumn(tm.Columns[1], p.Value) + }); + + if (parent == null) + { + tm.Rows.Add(row); + } + else + { + parent.Rows.Add(row); + } + row.SetExtraData("property", p); + } + private void RecursiveAddGroup(Group g, TreeModelRow parent = null) + { + TreeModelRow row = new TreeModelRow(new TreeModelRowColumn[] + { + new TreeModelRowColumn(tm.Columns[0], g.Name) + }); + + if (parent == null) + { + tm.Rows.Add(row); + } + else + { + parent.Rows.Add(row); + } + + for (int i = 0; i < g.Properties.Count; i++) + { + RecursiveAddProperty(g.Properties[i], row); + } + for (int i = 0; i < g.Groups.Count; i++) + { + RecursiveAddGroup(g.Groups[i], row); + } + row.SetExtraData("group", g); } } } diff --git a/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj b/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj index 394c80e2..a4f28197 100644 --- a/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj +++ b/Libraries/UniversalEditor.UserInterface/UniversalEditor.UserInterface.csproj @@ -98,7 +98,6 @@ -