Add Address Book UI plugin for Universal Editor

This commit is contained in:
Michael Becker 2019-08-02 14:24:20 -04:00
parent aa0b43c0a2
commit 11250d21eb
4 changed files with 334 additions and 0 deletions

View File

@ -0,0 +1,209 @@
//
// MyClass.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
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<string> ("PropertyObject", "Name");
txtGivenName.SetExtraData<string> ("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<string> ("PropertyObject", "Name");
txtMiddleName.SetExtraData<string> ("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<string> ("PropertyObject", "Name");
txtFamilyName.SetExtraData<string> ("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<string> ("PropertyObject", "Job");
txtJobTitle.SetExtraData<string> ("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<string> ("PropertyObject", "Job");
txtCompany.SetExtraData<string> ("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;
}
}
/// <summary>
/// Raised when any of the text box fields on this Editor has changed.
/// </summary>
/// <param name="sender">Sender.</param>
/// <param name="e">E.</param>
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<string> ("PropertyObject");
string propertyName = txt.GetExtraData<string> ("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 ();
}
}
}

View File

@ -0,0 +1,47 @@
//
// AssemblyInfo.cs
//
// Author:
// Mike Becker <alcexhim@gmail.com>
//
// 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 <http://www.gnu.org/licenses/>.
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("")]

View File

@ -0,0 +1,71 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E94B6C34-660F-4280-AEEC-D28AC6A3F528}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>UniversalEditor.Plugins.AddressBook.UserInterface</RootNamespace>
<AssemblyName>UniversalEditor.Plugins.AddressBook.UserInterface</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\Output\Debug\Plugins</OutputPath>
<DefineConstants>DEBUG;</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>full</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\Output\Release\Plugins</OutputPath>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<ConsolePause>false</ConsolePause>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ContactEditor.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\..\..\..\UniversalWidgetToolkit\Libraries\UniversalWidgetToolkit\UniversalWidgetToolkit.csproj">
<Project>{29E1C1BB-3EA5-4062-B62F-85EEC703FE07}</Project>
<Name>UniversalWidgetToolkit</Name>
</ProjectReference>
<ProjectReference Include="..\..\Libraries\UniversalEditor.UserInterface\UniversalEditor.UserInterface.csproj">
<Project>{8622EBC4-8E20-476E-B284-33D472081F5C}</Project>
<Name>UniversalEditor.UserInterface</Name>
</ProjectReference>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Essential\UniversalEditor.Essential.csproj">
<Project>{30467E5C-05BC-4856-AADC-13906EF4CADD}</Project>
<Name>UniversalEditor.Essential</Name>
</ProjectReference>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Core\UniversalEditor.Core.csproj">
<Project>{2D4737E6-6D95-408A-90DB-8DFF38147E85}</Project>
<Name>UniversalEditor.Core</Name>
</ProjectReference>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Compression\UniversalEditor.Compression.csproj">
<Project>{3F664673-7E22-4486-9AD0-FC81861D0B78}</Project>
<Name>UniversalEditor.Compression</Name>
</ProjectReference>
<ProjectReference Include="..\..\Libraries\UniversalEditor.Checksum\UniversalEditor.Checksum.csproj">
<Project>{0F7D5BD4-7970-412F-ABD7-0A098BB01ACE}</Project>
<Name>UniversalEditor.Checksum</Name>
</ProjectReference>
<ProjectReference Include="..\..\Plugins\UniversalEditor.Plugins.AddressBook\UniversalEditor.Plugins.AddressBook.csproj">
<Project>{AC2E7D52-E3C0-4C5A-A13E-B77F6D41C46E}</Project>
<Name>UniversalEditor.Plugins.AddressBook</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\..\MBS.Framework\MBS.Framework\MBS.Framework.csproj">
<Project>{23ACD09E-E096-4B05-A6CE-6853EDDC589A}</Project>
<Name>MBS.Framework</Name>
</ProjectReference>
</ItemGroup>
</Project>

View File

@ -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