Exemplo n.º 1
0
        /// <summary>
        /// Clones <see cref="IToolDock"/> object.
        /// </summary>
        /// <param name="source">The source object.</param>
        /// <returns>TThe new instance or reference of the <see cref="IToolDock"/> class.</returns>
        public static IToolDock CloneToolDock(IToolDock source)
        {
            var toolDock = source.Factory.CreateToolDock();

            CloneDockProperties(source, toolDock);

            return(toolDock);
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Clone <see cref="IToolDock"/> object.
        /// </summary>
        /// <param name="source"></param>
        /// <returns>The new instance or reference <see cref="IToolDock"/> calss</returns>
        public static IToolDock?CloenToolDocck(IToolDock source)
        {
            var target = source.Factory?.CreateToolDock();

            if (!(target is null))
            {
                CloneDockProperties(source, target);
            }

            return(target);
        }
Exemplo n.º 4
0
 private void SplitToolDockable(IDockable sourceDockable, IDock sourceDockableOwner, IDock targetDock, DockOperation operation)
 {
     if (targetDock.Factory is { } factory)
     {
         IToolDock toolDock = factory.CreateToolDock();
         toolDock.Id               = nameof(IToolDock);
         toolDock.Title            = nameof(IToolDock);
         toolDock.VisibleDockables = factory.CreateList <IDockable>();
         factory.MoveDockable(sourceDockableOwner, toolDock, sourceDockable, null);
         factory.SplitToDock(targetDock, toolDock, operation);
     }
 }
Exemplo n.º 5
0
        /// <summary>
        /// Clones <see cref="IToolDock"/> object.
        /// </summary>
        /// <param name="source">The source object.</param>
        /// <returns>TThe new instance or reference of the <see cref="IToolDock"/> class.</returns>
        public static IToolDock?CloneToolDock(IToolDock source)
        {
            var target = source.Factory?.CreateToolDock();

            if (!(target is null))
            {
                target.Alignment  = source.Alignment;
                target.IsExpanded = source.IsExpanded;
                target.AutoHide   = source.AutoHide;

                CloneDockProperties(source, target);
            }

            return(target);
        }