/// <summary> /// Flushes all changes to the designer. /// </summary> /// <param name="serializationManager">An <see cref="T:System.ComponentModel.Design.Serialization.IDesignerSerializationManager"/> to use for persisting the state of loaded designers.</param> protected override void PerformFlush(IDesignerSerializationManager serializationManager) { bool success = true; ArrayList errors = new ArrayList(); IDesignerHost idh = (IDesignerHost)this.Host.GetService(typeof(IDesignerHost)); Controls.ISerializableControl serializable = (LoaderHost.RootComponent as Controls.ISerializableControl); if (serializable == null) { throw new ApplicationException("Invalid root control type in designer."); } Serialization.SerializationObject serializationObject = this.GetSerializationObject(); try { this.Buffer = this.SerializeFrameXml(serializationObject); } catch (Exception exception) { Debug.WriteLine(exception); success = false; errors.Add(exception); } IDesignerLoaderHost host = this.LoaderHost; host.EndLoad(FrameXmlDesignerLoader.hostedBaseClassName, success, errors); Trace.WriteLine("PerformFlush"); }
/// <summary> /// Retrieves the serialization object hierarchy from the controls /// </summary> /// <returns></returns> private static SerializationObject GetSerializationObject(Controls.ISerializableControl serializableControl) { SerializationObject serializableObject = serializableControl.SerializationObject; serializableObject.Controls.Clear(); Controls.IFrameControl parentFrame = serializableControl as Controls.IFrameControl; if (parentFrame != null) { if (parentFrame.Frames.Count <Controls.IFrameControl>() > 0) { FrameTypeFrames frames = new FrameTypeFrames(); serializableObject.Controls.Add(frames); foreach (var childFrame in parentFrame.Frames) { SerializationObject childObject = GetSerializationObject(childFrame); frames.Controls.Add(childObject); } } Serialization.FrameType frameType = serializableObject as Serialization.FrameType; if (frameType != null) { Dictionary <DRAWLAYER, FrameTypeLayersLayer> layerDictionary = new Dictionary <DRAWLAYER, FrameTypeLayersLayer>(); foreach (Controls.ILayerable layerable in parentFrame.Layerables) { if (!layerDictionary.ContainsKey(layerable.LayerLevel)) { layerDictionary.Add(layerable.LayerLevel, new FrameTypeLayersLayer()); } FrameTypeLayersLayer layer = layerDictionary[layerable.LayerLevel]; layer.level = layerable.LayerLevel; layer.Layerables.Add(layerable.SerializationObject); } frameType.LayersList.Clear(); if (layerDictionary.Count > 0) { FrameTypeLayers layers = new FrameTypeLayers(); layers.Layer.AddRange(layerDictionary.Values); frameType.LayersList.Add(layers); } } } return(serializableObject); }