Browse Source

Fixed SD2-771: Adding MenuStrip to Xml Form

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/2.0@1327 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
d85d8966b3
  1. 20
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/XmlDesignerGenerator.cs
  2. 3
      src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs
  3. 6
      src/Main/Base/Project/Src/Gui/XmlForms/Lib/XmlLoader.cs

20
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/DesignerGenerator/XmlDesignerGenerator.cs

@ -75,7 +75,7 @@ namespace ICSharpCode.FormsDesigner
return new object[] {}; return new object[] {};
} }
public XmlElement GetElementFor(XmlDocument doc, object o) public XmlElement GetElementFor(XmlDocument doc, object o, Hashtable visitedControls)
{ {
if (doc == null) { if (doc == null) {
throw new ArgumentNullException("doc"); throw new ArgumentNullException("doc");
@ -85,8 +85,11 @@ namespace ICSharpCode.FormsDesigner
throw new ArgumentNullException("o"); throw new ArgumentNullException("o");
} }
visitedControls[o] = null;
try { try {
XmlElement el = doc.CreateElement(o.GetType().FullName); XmlElement el = doc.CreateElement(XmlConvert.EncodeName(o.GetType().FullName));
PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(o); PropertyDescriptorCollection properties = TypeDescriptor.GetProperties(o);
Control ctrl = o as Control; Control ctrl = o as Control;
@ -128,7 +131,7 @@ namespace ICSharpCode.FormsDesigner
childNodes.Insert(0, childEl); childNodes.Insert(0, childEl);
continue; continue;
} }
childEl = doc.CreateElement(pd.Name); childEl = doc.CreateElement(XmlConvert.EncodeName(pd.Name));
object propertyValue = null; object propertyValue = null;
try { try {
@ -141,8 +144,8 @@ namespace ICSharpCode.FormsDesigner
// lists are other than normal properties // lists are other than normal properties
if (propertyValue is IList && !(ctrl is PropertyGrid)) { if (propertyValue is IList && !(ctrl is PropertyGrid)) {
foreach (object listObject in (IList)propertyValue) { foreach (object listObject in (IList)propertyValue) {
XmlElement newEl = GetElementFor(doc, listObject); XmlElement newEl = GetElementFor(doc, listObject, visitedControls);
if (newEl != null) { if (newEl != null && !newEl.Name.StartsWith("System.Windows.Forms.Design.")) {
childEl.AppendChild(newEl); childEl.AppendChild(newEl);
} }
} }
@ -191,13 +194,14 @@ namespace ICSharpCode.FormsDesigner
versionAttribute.InnerText = "1.0"; versionAttribute.InnerText = "1.0";
componentsElement.Attributes.Append(versionAttribute); componentsElement.Attributes.Append(versionAttribute);
Hashtable visitedControls = new Hashtable();
// insert root element // insert root element
componentsElement.AppendChild(GetElementFor(doc, host.RootComponent)); componentsElement.AppendChild(GetElementFor(doc, host.RootComponent, visitedControls));
// insert any non gui (=tray components) // insert any non gui (=tray components)
foreach (IComponent component in host.Container.Components) { foreach (IComponent component in host.Container.Components) {
if (!(component is Control)) { if (!(component is Control) && !visitedControls.ContainsKey(component)) {
componentsElement.AppendChild(GetElementFor(doc, component)); componentsElement.AppendChild(GetElementFor(doc, component, visitedControls));
} }
} }

3
src/AddIns/DisplayBindings/FormsDesigner/Project/Src/Services/TypeResolutionService.cs

@ -42,6 +42,7 @@ namespace ICSharpCode.FormsDesigner.Services
DesignerAssemblies.Add(ProjectContentRegistry.MscorlibAssembly); DesignerAssemblies.Add(ProjectContentRegistry.MscorlibAssembly);
DesignerAssemblies.Add(ProjectContentRegistry.SystemAssembly); DesignerAssemblies.Add(ProjectContentRegistry.SystemAssembly);
DesignerAssemblies.Add(typeof(System.Drawing.Point).Assembly); DesignerAssemblies.Add(typeof(System.Drawing.Point).Assembly);
DesignerAssemblies.Add(typeof(System.Windows.Forms.Design.AnchorEditor).Assembly);
} }
[System.Runtime.InteropServices.DllImport("kernel32.dll")] [System.Runtime.InteropServices.DllImport("kernel32.dll")]
@ -272,7 +273,7 @@ namespace ICSharpCode.FormsDesigner.Services
if (type == null) { if (type == null) {
IProjectContent pc = this.CallingProject; IProjectContent pc = this.CallingProject;
if (pc != null) { if (pc != null) {
IClass foundClass = pc.GetClass(name); IClass foundClass = pc.GetClass(name.Replace('+', '.'));
if (foundClass != null) { if (foundClass != null) {
Assembly assembly = LoadAssembly(foundClass.ProjectContent); Assembly assembly = LoadAssembly(foundClass.ProjectContent);
if (assembly != null) { if (assembly != null) {

6
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]; el = (XmlElement)doc.DocumentElement.ChildNodes[0];
} }
customizationObject = objectCreator.CreateObject(el.Name, el); customizationObject = objectCreator.CreateObject(XmlConvert.DecodeName(el.Name), el);
SetUpObject(customizationObject, el); SetUpObject(customizationObject, el);
return customizationObject; return customizationObject;
@ -147,7 +147,7 @@ namespace ICSharpCode.SharpDevelop.Gui.XmlForms
el = (XmlElement)doc.DocumentElement.ChildNodes[0]; el = (XmlElement)doc.DocumentElement.ChildNodes[0];
} }
customizationObject = objectCreator.CreateObject(el.Name, el); customizationObject = objectCreator.CreateObject(XmlConvert.DecodeName(el.Name), el);
SetUpObject(customizationObject, el); SetUpObject(customizationObject, el);
return customizationObject; return customizationObject;
@ -363,7 +363,7 @@ namespace ICSharpCode.SharpDevelop.Gui.XmlForms
foreach (XmlNode subNode in el.ChildNodes) { foreach (XmlNode subNode in el.ChildNodes) {
if (subNode is XmlElement){ if (subNode is XmlElement){
XmlElement subElement = (XmlElement)subNode; XmlElement subElement = (XmlElement)subNode;
object collectionObject = objectCreator.CreateObject(subElement.Name, subElement); object collectionObject = objectCreator.CreateObject(XmlConvert.DecodeName(subElement.Name), subElement);
if (collectionObject == null) { if (collectionObject == null) {
continue; continue;
} }

Loading…
Cancel
Save