From 11250d21eb11d7d1ae532052f0b3fdf78613df3e Mon Sep 17 00:00:00 2001 From: Michael Becker Date: Fri, 2 Aug 2019 14:24:20 -0400 Subject: [PATCH] Add Address Book UI plugin for Universal Editor --- .../ContactEditor.cs | 209 ++++++++++++++++++ .../Properties/AssemblyInfo.cs | 47 ++++ ...r.Plugins.AddressBook.UserInterface.csproj | 71 ++++++ CSharp/UniversalEditor.sln | 7 + 4 files changed, 334 insertions(+) create mode 100644 CSharp/Plugins.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface/ContactEditor.cs create mode 100644 CSharp/Plugins.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface/Properties/AssemblyInfo.cs create mode 100644 CSharp/Plugins.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface.csproj diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface/ContactEditor.cs b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface/ContactEditor.cs new file mode 100644 index 00000000..be5e1b36 --- /dev/null +++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface/ContactEditor.cs @@ -0,0 +1,209 @@ +// +// MyClass.cs +// +// Author: +// Mike Becker +// +// Copyright (c) 2019 Mike Becker +// +// 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 UniversalEditor.UserInterface; + +using UniversalEditor.ObjectModels.Contact; +using UniversalWidgetToolkit.Layouts; +using UniversalWidgetToolkit; +using UniversalWidgetToolkit.Controls; +using MBS.Framework.Drawing; +using System.Text; + +namespace UniversalEditor.Plugins.AddressBook.UserInterface +{ + public class ContactEditor : Editor + { + public ContactEditor () + { + InitializeComponent (); + } + + private DropDownButton btnName; + private Button btnPhoto; + + private TextBox txtGivenName; + private TextBox txtMiddleName; + private TextBox txtFamilyName; + + private void InitializeComponent() + { + this.Layout = new BoxLayout (Orientation.Vertical); + this.Padding = new Padding (26); + + Container ct = new Container (); + ct.Layout = new GridLayout (); + + btnPhoto = new Button (); + btnPhoto.Size = new Dimension2D (128, 128); + ct.Controls.Add (btnPhoto, new GridLayout.Constraints (0, 0, 1, 1, ExpandMode.None)); + + Container ctName = new Container (); + ctName.Layout = new GridLayout (); + + Label lblGivenName = new Label (); + lblGivenName.Text = "_Given"; + lblGivenName.Attributes.Add ("scale", 0.8); + txtGivenName = new TextBox (); + txtGivenName.SetExtraData ("PropertyObject", "Name"); + txtGivenName.SetExtraData ("PropertyName", "GivenName"); + txtGivenName.Changed += TextBox_Changed; + txtGivenName.LostFocus += TextBox_LostFocus; + ctName.Controls.Add (txtGivenName, new GridLayout.Constraints (0, 0, 1, 1, ExpandMode.Both)); + ctName.Controls.Add (lblGivenName, new GridLayout.Constraints (1, 0, 1, 1)); + + Label lblMiddleName = new Label (); + lblMiddleName.Text = "_Middle"; + lblMiddleName.Attributes.Add ("scale", 0.8); + txtMiddleName = new TextBox (); + txtMiddleName.SetExtraData ("PropertyObject", "Name"); + txtMiddleName.SetExtraData ("PropertyName", "MiddleName"); + txtMiddleName.Changed += TextBox_Changed; + txtMiddleName.LostFocus += TextBox_LostFocus; + ctName.Controls.Add (txtMiddleName, new GridLayout.Constraints (0, 1, 1, 1, ExpandMode.Both)); + ctName.Controls.Add (lblMiddleName, new GridLayout.Constraints (1, 1, 1, 1)); + + Label lblFamilyName = new Label (); + lblFamilyName.Text = "_Family"; + lblFamilyName.Attributes.Add ("scale", 0.8); + txtFamilyName = new TextBox (); + txtFamilyName.Changed += TextBox_Changed; + txtFamilyName.SetExtraData ("PropertyObject", "Name"); + txtFamilyName.SetExtraData ("PropertyName", "FamilyName"); + txtFamilyName.LostFocus += TextBox_LostFocus; + ctName.Controls.Add (txtFamilyName, new GridLayout.Constraints (0, 2, 1, 1, ExpandMode.Both)); + ctName.Controls.Add (lblFamilyName, new GridLayout.Constraints (1, 2, 1, 1)); + + TextBox txtJobTitle = new TextBox (); + txtJobTitle.Changed += TextBox_Changed; + txtJobTitle.SetExtraData ("PropertyObject", "Job"); + txtJobTitle.SetExtraData ("PropertyName", "JobTitle"); + txtJobTitle.LostFocus += TextBox_LostFocus; + Label lblJobTitle = new Label (); + lblJobTitle.Text = "_Job title"; + lblJobTitle.Attributes.Add ("scale", 0.8); + ctName.Controls.Add (txtJobTitle, new GridLayout.Constraints (2, 0, 1, 2, ExpandMode.Both)); + ctName.Controls.Add (lblJobTitle, new GridLayout.Constraints (3, 0, 1, 2, ExpandMode.Both)); + + TextBox txtCompany = new TextBox (); + txtCompany.Changed += TextBox_Changed; + txtCompany.SetExtraData ("PropertyObject", "Job"); + txtCompany.SetExtraData ("PropertyName", "Company"); + txtCompany.LostFocus += TextBox_LostFocus; + Label lblCompany = new Label (); + lblCompany.Text = "_Company"; + lblCompany.Attributes.Add ("scale", 0.8); + ctName.Controls.Add (txtCompany, new GridLayout.Constraints (2, 2, 1, 1, ExpandMode.Both)); + ctName.Controls.Add (lblCompany, new GridLayout.Constraints (3, 2, 1, 1, ExpandMode.Both)); + + ct.Controls.Add (ctName, new GridLayout.Constraints (0, 1, 2, 1, ExpandMode.None)); + + // for all details + + for (int iRow = 0; iRow < 4; iRow++) { + ComboBox cboDetail = new ComboBox (); + TextBox txtDetail = new TextBox (); + Button btnDelete = new Button (ButtonStockType.Delete); + ct.Controls.Add (cboDetail, new GridLayout.Constraints (iRow + 1, 0, 1, 1, ExpandMode.None)); + ct.Controls.Add (txtDetail, new GridLayout.Constraints (iRow + 1, 1, 1, 1, ExpandMode.Horizontal)); + ct.Controls.Add (btnDelete, new GridLayout.Constraints (iRow + 1, 2, 1, 1, ExpandMode.None)); + } + + this.Controls.Add (ct, new BoxLayout.Constraints(false, false)); + } + + private static EditorReference _er = null; + public override EditorReference MakeReference () + { + if (_er == null) { + _er = base.MakeReference (); + } + _er.SupportedObjectModels.Add (typeof(ContactObjectModel)); + return _er; + } + + protected override void OnObjectModelChanged (EventArgs e) + { + txtGivenName.Text = String.Empty; + txtMiddleName.Text = String.Empty; + txtFamilyName.Text = String.Empty; + + base.OnObjectModelChanged (e); + + ContactObjectModel contact = (ObjectModel as ContactObjectModel); + if (contact.Names.Count > 0) { + txtGivenName.Text = contact.Names [0].GivenName; + txtMiddleName.Text = contact.Names [0].MiddleName; + txtFamilyName.Text = contact.Names [0].FamilyName; + } + } + + /// + /// Raised when any of the text box fields on this Editor has changed. + /// + /// Sender. + /// E. + private void TextBox_Changed(object sender, EventArgs e) + { + } + + private void TextBox_LostFocus(object sender, EventArgs e) + { + // eeek! I dont' rememver how this works...... !!!a + TextBox txt = (sender as TextBox); + string propertyObject = txt.GetExtraData ("PropertyObject"); + string propertyName = txt.GetExtraData ("PropertyName"); + + ContactObjectModel contact = (ObjectModel as ContactObjectModel); + + switch (propertyObject) + { + case "Name": + { + if (contact.Names.Count == 0) { + contact.Names.Add (new ContactName ()); + } + BeginEdit (propertyName, txt.Text, contact.Names [0]); + EndEdit (); + break; + } + case "Job": + { + break; + } + } + } + + public override void Copy () + { + throw new NotImplementedException (); + } + public override void Paste () + { + throw new NotImplementedException (); + } + public override void Delete () + { + throw new NotImplementedException (); + } + } +} + diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface/Properties/AssemblyInfo.cs b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..337eeca4 --- /dev/null +++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface/Properties/AssemblyInfo.cs @@ -0,0 +1,47 @@ +// +// AssemblyInfo.cs +// +// Author: +// Mike Becker +// +// Copyright (c) 2019 Mike Becker +// +// 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.Reflection; +using System.Runtime.CompilerServices; + +// Information about this assembly is defined by the following attributes. +// Change them to the values specific to your project. + +[assembly: AssemblyTitle ("UniversalEditor.Plugins.AddressBook.UserInterface")] +[assembly: AssemblyDescription ("")] +[assembly: AssemblyConfiguration ("")] +[assembly: AssemblyCompany ("")] +[assembly: AssemblyProduct ("")] +[assembly: AssemblyCopyright ("Mike Becker")] +[assembly: AssemblyTrademark ("")] +[assembly: AssemblyCulture ("")] + +// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}". +// The form "{Major}.{Minor}.*" will automatically update the build and revision, +// and "{Major}.{Minor}.{Build}.*" will update just the revision. + +[assembly: AssemblyVersion ("1.0.*")] + +// The following attributes are used to specify the signing key for the assembly, +// if desired. See the Mono documentation for more information about signing. + +//[assembly: AssemblyDelaySign(false)] +//[assembly: AssemblyKeyFile("")] + diff --git a/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface.csproj b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface.csproj new file mode 100644 index 00000000..3c93985d --- /dev/null +++ b/CSharp/Plugins.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface/UniversalEditor.Plugins.AddressBook.UserInterface.csproj @@ -0,0 +1,71 @@ + + + + Debug + AnyCPU + {E94B6C34-660F-4280-AEEC-D28AC6A3F528} + Library + UniversalEditor.Plugins.AddressBook.UserInterface + UniversalEditor.Plugins.AddressBook.UserInterface + + + true + full + false + ..\..\Output\Debug\Plugins + DEBUG; + prompt + 4 + false + + + full + true + ..\..\Output\Release\Plugins + prompt + 4 + false + + + + + + + + + + + + {29E1C1BB-3EA5-4062-B62F-85EEC703FE07} + UniversalWidgetToolkit + + + {8622EBC4-8E20-476E-B284-33D472081F5C} + UniversalEditor.UserInterface + + + {30467E5C-05BC-4856-AADC-13906EF4CADD} + UniversalEditor.Essential + + + {2D4737E6-6D95-408A-90DB-8DFF38147E85} + UniversalEditor.Core + + + {3F664673-7E22-4486-9AD0-FC81861D0B78} + UniversalEditor.Compression + + + {0F7D5BD4-7970-412F-ABD7-0A098BB01ACE} + UniversalEditor.Checksum + + + {AC2E7D52-E3C0-4C5A-A13E-B77F6D41C46E} + UniversalEditor.Plugins.AddressBook + + + {23ACD09E-E096-4B05-A6CE-6853EDDC589A} + MBS.Framework + + + \ No newline at end of file diff --git a/CSharp/UniversalEditor.sln b/CSharp/UniversalEditor.sln index 9bde4dcc..45ce550e 100644 --- a/CSharp/UniversalEditor.sln +++ b/CSharp/UniversalEditor.sln @@ -125,6 +125,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.Mul EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.SoftwareDevelopment.UserInterface", "Plugins.UserInterface\UniversalEditor.Plugins.SoftwareDevelopment.UserInterface\UniversalEditor.Plugins.SoftwareDevelopment.UserInterface.csproj", "{5CC1FF25-44BF-4CD1-BD36-11E29EB21D19}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UniversalEditor.Plugins.AddressBook.UserInterface", "Plugins.UserInterface\UniversalEditor.Plugins.AddressBook.UserInterface\UniversalEditor.Plugins.AddressBook.UserInterface.csproj", "{E94B6C34-660F-4280-AEEC-D28AC6A3F528}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -339,6 +341,10 @@ Global {E6C9A73D-4556-4220-9BC7-302A7EE64C1A}.Debug|Any CPU.Build.0 = Debug|Any CPU {E6C9A73D-4556-4220-9BC7-302A7EE64C1A}.Release|Any CPU.ActiveCfg = Release|Any CPU {E6C9A73D-4556-4220-9BC7-302A7EE64C1A}.Release|Any CPU.Build.0 = Release|Any CPU + {E94B6C34-660F-4280-AEEC-D28AC6A3F528}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E94B6C34-660F-4280-AEEC-D28AC6A3F528}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E94B6C34-660F-4280-AEEC-D28AC6A3F528}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E94B6C34-660F-4280-AEEC-D28AC6A3F528}.Release|Any CPU.Build.0 = Release|Any CPU {EF886E1A-D553-43DA-857C-29DA0D6E0DAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {EF886E1A-D553-43DA-857C-29DA0D6E0DAE}.Debug|Any CPU.Build.0 = Debug|Any CPU {EF886E1A-D553-43DA-857C-29DA0D6E0DAE}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -419,6 +425,7 @@ Global {A127AC81-400A-4F3B-8C55-A8258CD6D3C6} = {7B535D74-5496-4802-B809-89ED88274A91} {D9D5AC3B-9AC0-4D4E-B295-2134FDCF166C} = {7B535D74-5496-4802-B809-89ED88274A91} {5CC1FF25-44BF-4CD1-BD36-11E29EB21D19} = {7B535D74-5496-4802-B809-89ED88274A91} + {E94B6C34-660F-4280-AEEC-D28AC6A3F528} = {7B535D74-5496-4802-B809-89ED88274A91} EndGlobalSection GlobalSection(MonoDevelopProperties) = preSolution Policies = $0