diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/XmlDesignerGenerator.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/XmlDesignerGenerator.cs index c1c173ccac..037099cca7 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/XmlDesignerGenerator.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/XmlDesignerGenerator.cs @@ -75,7 +75,7 @@ namespace ICSharpCode.FormsDesigner return new object[] {}; } - public XmlElement GetElementFor(XmlDocument doc, object o) + public XmlElement GetElementFor(XmlDocument doc, object o, Hashtable visitedControls) { if (doc == null) { throw new ArgumentNullException("doc"); @@ -85,8 +85,11 @@ namespace ICSharpCode.FormsDesigner throw new ArgumentNullException("o"); } + visitedControls[o] = null; + try { - XmlElement el = doc.CreateElement(o.GetType().FullName); + XmlElement el = doc.CreateElement(XmlConvert.EncodeName(o.GetType().FullName)); + PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(o); Control ctrl = o as Control; @@ -128,7 +131,7 @@ namespace ICSharpCode.FormsDesigner childNodes.Insert(0, childEl); continue; } - childEl = doc.CreateElement(pd.Name); + childEl = doc.CreateElement(XmlConvert.EncodeName(pd.Name)); object propertyValue = null; try { @@ -141,8 +144,8 @@ namespace ICSharpCode.FormsDesigner // lists are other than normal properties if (propertyValue is IList && !(ctrl is PropertyGrid)) { foreach (object listObject in (IList)propertyValue) { - XmlElement newEl = GetElementFor(doc, listObject); - if (newEl != null) { + XmlElement newEl = GetElementFor(doc, listObject, visitedControls); + if (newEl != null && !newEl.Name.StartsWith("System.Windows.Forms.Design.")) { childEl.AppendChild(newEl); } } @@ -191,13 +194,14 @@ namespace ICSharpCode.FormsDesigner versionAttribute.InnerText = "1.0"; componentsElement.Attributes.Append(versionAttribute); + Hashtable visitedControls = new Hashtable(); // insert root element - componentsElement.AppendChild(GetElementFor(doc, host.RootComponent)); + componentsElement.AppendChild(GetElementFor(doc, host.RootComponent, visitedControls)); // insert any non gui (=tray components) foreach (IComponent component in host.Container.Components) { - if (!(component is Control)) { - componentsElement.AppendChild(GetElementFor(doc, component)); + if (!(component is Control) && !visitedControls.ContainsKey(component)) { + componentsElement.AppendChild(GetElementFor(doc, component, visitedControls)); } } diff --git a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs index 7136e7b8bc..a15504addc 100644 --- a/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs +++ b/src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs @@ -42,6 +42,7 @@ namespace ICSharpCode.FormsDesigner.Services DesignerAssemblies.Add(ProjectContentRegistry.MscorlibAssembly); DesignerAssemblies.Add(ProjectContentRegistry.SystemAssembly); DesignerAssemblies.Add(typeof(System.Drawing.Point).Assembly); + DesignerAssemblies.Add(typeof(System.Windows.Forms.Design.AnchorEditor).Assembly); } [System.Runtime.InteropServices.DllImport("kernel32.dll")] @@ -272,7 +273,7 @@ namespace ICSharpCode.FormsDesigner.Services if (type == null) { IProjectContent pc = this.CallingProject; if (pc != null) { - IClass foundClass = pc.GetClass(name); + IClass foundClass = pc.GetClass(name.Replace('+', '.')); if (foundClass != null) { Assembly assembly = LoadAssembly(foundClass.ProjectContent); if (assembly != null) { diff --git a/src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlLoader.cs b/src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlLoader.cs index ed25a2dd70..18e5c31221 100644 --- a/src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlLoader.cs +++ b/src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlLoader.cs @@ -128,7 +128,7 @@ namespace ICSharpCode.SharpDevelop.Gui.XmlForms el = (XmlElement)doc.DocumentElement.ChildNodes[0]; } - customizationObject = objectCreator.CreateObject(el.Name, el); + customizationObject = objectCreator.CreateObject(XmlConvert.DecodeName(el.Name), el); SetUpObject(customizationObject, el); return customizationObject; @@ -147,7 +147,7 @@ namespace ICSharpCode.SharpDevelop.Gui.XmlForms el = (XmlElement)doc.DocumentElement.ChildNodes[0]; } - customizationObject = objectCreator.CreateObject(el.Name, el); + customizationObject = objectCreator.CreateObject(XmlConvert.DecodeName(el.Name), el); SetUpObject(customizationObject, el); return customizationObject; @@ -363,7 +363,7 @@ namespace ICSharpCode.SharpDevelop.Gui.XmlForms foreach (XmlNode subNode in el.ChildNodes) { if (subNode is XmlElement){ XmlElement subElement = (XmlElement)subNode; - object collectionObject = objectCreator.CreateObject(subElement.Name, subElement); + object collectionObject = objectCreator.CreateObject(XmlConvert.DecodeName(subElement.Name), subElement); if (collectionObject == null) { continue; }