public IDockable?DeserializeDockable(SerializedDock serializedDock) { switch (serializedDock.DockableType) { case SerializedDockableType.ProportionalDock: // simplify if need if (serializedDock.Children.Count == 1 && serializedDock.Children[0].DockableType == SerializedDockableType.ProportionalDock) { return(DeserializeDockable(serializedDock.Children[0])); } IProportionalDock proportionalDock = dockFactory.CreateProportionalDock(); proportionalDock.Orientation = serializedDock.Horizontal ? Orientation.Horizontal : Orientation.Vertical; proportionalDock.Proportion = serializedDock.Proportion; DeserializeChildren(proportionalDock, serializedDock); return(proportionalDock); case SerializedDockableType.DocumentDock: IDocumentDock documentDock = dockFactory.CreateDocumentDock(); documentDock.Proportion = serializedDock.Proportion; documentDock.IsCollapsable = serializedDock.IsCollapsable; return(documentDock); case SerializedDockableType.Splitter: return(dockFactory.CreateProportionalDockSplitter()); case SerializedDockableType.ToolDock: if (serializedDock.Children.Count == 0) { return(null); } IToolDock toolDock = dockFactory.CreateToolDock(); toolDock.Proportion = serializedDock.Proportion; DeserializeChildren(toolDock, serializedDock); return(toolDock); case SerializedDockableType.Tool: var tool = layoutViewModelResolver.ResolveTool(serializedDock.UniqueId); return(tool); case SerializedDockableType.RootDock: IRootDock rootDock = dockFactory.CreateRootDock(); rootDock.Proportion = serializedDock.Proportion; DeserializeChildren(rootDock, serializedDock); if (rootDock.VisibleDockables?.Count > 0) { rootDock.ActiveDockable = rootDock.VisibleDockables[0]; rootDock.DefaultDockable = rootDock.VisibleDockables[0]; } return(rootDock); default: throw new ArgumentOutOfRangeException(); } }
/// <summary> /// Clones <see cref="IProportionalDock"/> object. /// </summary> /// <param name="source">The source object.</param> /// <returns>TThe new instance or reference of the <see cref="IProportionalDock"/> class.</returns> public static IProportionalDock CloneProportionalDock(IProportionalDock source) { var proportionalDock = source.Factory.CreateProportionalDock(); CloneDockProperties(source, proportionalDock); proportionalDock.Orientation = source.Orientation; return(proportionalDock); }
/// <summary> /// Clone <see cref="IProportionalDock"/> object. /// </summary> /// <param name="source">The source object</param> /// <returns>The new instance or reference <see cref="IProportionalDock"/> calss</returns> public static IProportionalDock?CloneProportionalDock(IProportionalDock source) { var target = source.Factory?.CreateProportionalDock(); if (!(target is null)) { CloneDockProperties(source, target); CloneProportionalDockProperties(source, target); } return(target); }
/// <summary> /// Clone proportional dock properties. /// </summary> /// <param name="source">The source proportional Dock</param> /// <param name="target">The target proportional Dock</param> public static void CloneProportionalDockProperties(IProportionalDock source, IProportionalDock target) { target.Orientation = source.Orientation; }