From e54e1d0739bb96c104a6a53cf12945da69148a4d Mon Sep 17 00:00:00 2001 From: alcexhim Date: Mon, 21 Jul 2014 15:54:41 -0400 Subject: [PATCH] Updated for enhancements to AwesomeControls PropertyGrid control --- .../Editors/Multimedia3D/Model/ModelEditor.cs | 46 +++++++++++++++++-- 1 file changed, 41 insertions(+), 5 deletions(-) diff --git a/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.Multimedia3D.UserInterface.WindowsForms/Editors/Multimedia3D/Model/ModelEditor.cs b/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.Multimedia3D.UserInterface.WindowsForms/Editors/Multimedia3D/Model/ModelEditor.cs index 560dd1bf..0d9d67db 100644 --- a/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.Multimedia3D.UserInterface.WindowsForms/Editors/Multimedia3D/Model/ModelEditor.cs +++ b/CSharp/Engines/WindowsForms/Plugins/UniversalEditor.Plugins.Multimedia3D.UserInterface.WindowsForms/Editors/Multimedia3D/Model/ModelEditor.cs @@ -26,11 +26,47 @@ namespace UniversalEditor.Plugins.Multimedia3D.UserInterface.WindowsForms.Editor // cboMaterialToon.SelectedIndex = 0; - PropertyGroup pgTorus_AU_IB = new PropertyGroup("Torus_AU_IB", "Torus"); - Property pTranslate = pgTorus_AU_IB.Properties.Add("Translate", "[-3.713, 0.000, 3.984]", true); - pTranslate.Properties.Add("X", "-3.713"); - pTranslate.Properties.Add("Y", "0.000"); - pTranslate.Properties.Add("Z", "3.984"); + PropertyDataType dtTorus = new PropertyDataType("Torus"); + + PropertyGroup pgTorus_AU_IB = new PropertyGroup("Torus_AU_IB", dtTorus); + + PropertyDataType dtVector3 = new PropertyDataType("Vector3"); + dtVector3.Properties.Add(new Property("X")); + dtVector3.Properties.Add(new Property("Y")); + dtVector3.Properties.Add(new Property("Z")); + dtVector3.PropertyValueRendering += delegate(object sender, PropertyValueRenderingEventArgs e) + { + StringBuilder sb = new StringBuilder(); + sb.Append("{ "); + sb.Append(e.Property.Properties["X"].Value.ToString()); + sb.Append(", "); + sb.Append(e.Property.Properties["Y"].Value.ToString()); + sb.Append(", "); + sb.Append(e.Property.Properties["Z"].Value.ToString()); + sb.Append(" }"); + e.DisplayString = sb.ToString(); + }; + dtVector3.PropertyValueParsing += delegate(object sender, PropertyValueParsingEventArgs e) + { + string w = e.DisplayString; + if (!w.StartsWith("{") && !w.EndsWith("}")) + { + e.Cancel = true; + return; + } + w = w.Substring(1, w.Length - 2).Trim(); + string[] x = w.Split(","); + if (x.Length != 3) + { + } + }; + + pgTorus_AU_IB.Properties.Add(new Property("Translate")); + pgTorus_AU_IB.Properties[pgTorus_AU_IB.Properties.Count - 1].DataType = dtVector3; + pgTorus_AU_IB.Properties[pgTorus_AU_IB.Properties.Count - 1].Properties["X"].Value = -3.713; + pgTorus_AU_IB.Properties[pgTorus_AU_IB.Properties.Count - 1].Properties["Y"].Value = 0.000; + pgTorus_AU_IB.Properties[pgTorus_AU_IB.Properties.Count - 1].Properties["Z"].Value = 3.984; + base.PropertyGroups.Add(pgTorus_AU_IB); }