コード例 #1
0
        public DefaultLayoutFactory()
        {
            _documents = new ObservableCollection <IView>();

            _documentDock = new DocumentDock
            {
                Id            = "DocumentsPane",
                Proportion    = double.NaN,
                Title         = "DocumentsPane",
                CurrentView   = null,
                IsCollapsable = false,
                Views         = _documents
            };

            _centerPane = new LayoutDock
            {
                Id          = $"CenterPane",
                Proportion  = double.NaN,
                Orientation = Orientation.Vertical,
                Title       = $"CenterPane",
                CurrentView = null,
                Views       = CreateList <IView>
                              (
                    _documentDock
                              )
            };
        }
コード例 #2
0
        /// <summary>
        /// Clones <see cref="IDocumentDock"/> object.
        /// </summary>
        /// <param name="source">The source object.</param>
        /// <returns>TThe new instance or reference of the <see cref="IDocumentDock"/> class.</returns>
        public static IDocumentDock CloneDocumentDock(IDocumentDock source)
        {
            var documentDock = source.Factory.CreateDocumentDock();

            CloneDockProperties(source, documentDock);

            return(documentDock);
        }
コード例 #3
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();
            }
        }
コード例 #4
0
        /// <summary>
        /// Clone <see cref="IDocumentDock"/> object.
        /// </summary>
        /// <param name="source">The source object.</param>
        /// <returns>The new instance or reference </returns>
        public static IDocumentDock?ClooneDocumentDock(IDocumentDock source)
        {
            var target = source.Factory?.CreateDocumentDock();

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

            return(target);
        }
コード例 #5
0
 private void SplitDocumentDockable(IDockable sourceDockable, IDock sourceDockableOwner, IDock targetDock, DockOperation operation)
 {
     if (targetDock.Factory is { } factory)
     {
         IDocumentDock documentDock = factory.CreateDocumentDock();
         documentDock.Id               = nameof(IDocumentDock);
         documentDock.Title            = nameof(IDocumentDock);
         documentDock.VisibleDockables = factory.CreateList <IDockable>();
         if (sourceDockableOwner is IDocumentDock sourceDocumentDock)
         {
             documentDock.CanCreateDocument = sourceDocumentDock.CanCreateDocument;
         }
         factory.MoveDockable(sourceDockableOwner, documentDock, sourceDockable, null);
         factory.SplitToDock(targetDock, documentDock, operation);
     }
 }
コード例 #6
0
        public AvalonStudioPerspective(IView root, ILayoutDock centerPane, IDocumentDock documentDock)
        {
            DocumentDock = documentDock;
            CenterPane   = centerPane;
            Root         = root;
            _tools       = new List <IToolViewModel>();
            _tabTools    = new Dictionary <IToolViewModel, IView>();

            CenterPane.WhenAnyValue(l => l.FocusedView).Subscribe(focused =>
            {
                if (focused?.Context is IToolViewModel tool)
                {
                    SelectedTool = tool;
                }
                else
                {
                    SelectedTool = null;
                }
            });
        }
コード例 #7
0
        public override IRootDock CreateLayout()
        {
            var document1 = new TestDocumentViewModel
            {
                Id    = "Document1",
                Title = "Document1"
            };

            var document2 = new TestDocumentViewModel
            {
                Id    = "Document2",
                Title = "Document2"
            };

            var leftTopTool1 = new LeftTopTool1ViewModel
            {
                Id    = "LeftTop1",
                Title = "LeftTop1"
            };

            var leftTopTool2 = new LeftTopTool2ViewModel
            {
                Id    = "LeftTop2",
                Title = "LeftTop2"
            };

            var leftBottomTool1 = new LeftBottomTool1ViewModel
            {
                Id    = "LeftBottom1",
                Title = "LeftBottom1"
            };

            var leftBottomTool2 = new LeftBottomTool2ViewModel
            {
                Id    = "LeftBottom2",
                Title = "LeftBottom2"
            };

            var rightTopTool1 = new RightTopTool1ViewModel
            {
                Id    = "RightTop1",
                Title = "RightTop1"
            };

            var rightTopTool2 = new RightTopTool2ViewModel
            {
                Id    = "RightTop2",
                Title = "RightTop2"
            };

            var rightBottomTool1 = new RightBottomTool1ViewModel
            {
                Id    = "RightBottom1",
                Title = "RightBottom1"
            };

            var rightBottomTool2 = new RightBottomTool2ViewModel
            {
                Id    = "RightBottom2",
                Title = "RightBottom2"
            };

            var documentDock = new DocumentDock
            {
                Id               = "DocumentsPane",
                Title            = "DocumentsPane",
                Proportion       = double.NaN,
                ActiveDockable   = document1,
                VisibleDockables = CreateList <IDockable>
                                   (
                    document1,
                    document2
                                   )
            };

            documentDock.CanCreateDocument = true;
            documentDock.CreateDocument    = ReactiveCommand.Create(() =>
            {
                var index    = documentDock.VisibleDockables?.Count + 1;
                var document = new TestDocumentViewModel {
                    Id = $"Document{index}", Title = $"Document{index}"
                };
                this.AddDockable(documentDock, document);
                this.SetActiveDockable(document);
                this.SetFocusedDockable(documentDock, document);
            });

            var mainLayout = new ProportionalDock
            {
                Id               = "MainLayout",
                Title            = "MainLayout",
                Proportion       = double.NaN,
                Orientation      = Orientation.Horizontal,
                ActiveDockable   = null,
                VisibleDockables = CreateList <IDockable>
                                   (
                    new ProportionalDock
                {
                    Id               = "LeftPane",
                    Title            = "LeftPane",
                    Proportion       = double.NaN,
                    Orientation      = Orientation.Vertical,
                    ActiveDockable   = null,
                    VisibleDockables = CreateList <IDockable>
                                       (
                        new ToolDock
                    {
                        Id               = "LeftPaneTop",
                        Title            = "LeftPaneTop",
                        Proportion       = double.NaN,
                        ActiveDockable   = leftTopTool1,
                        VisibleDockables = CreateList <IDockable>
                                           (
                            leftTopTool1,
                            leftTopTool2
                                           ),
                        Alignment = Alignment.Left,
                        GripMode  = GripMode.Visible
                    },
                        new SplitterDockable()
                    {
                        Id    = "LeftPaneTopSplitter",
                        Title = "LeftPaneTopSplitter"
                    },
                        new ToolDock
                    {
                        Id               = "LeftPaneBottom",
                        Title            = "LeftPaneBottom",
                        Proportion       = double.NaN,
                        ActiveDockable   = leftBottomTool1,
                        VisibleDockables = CreateList <IDockable>
                                           (
                            leftBottomTool1,
                            leftBottomTool2
                                           ),
                        Alignment = Alignment.Left,
                        GripMode  = GripMode.Visible
                    }
                                       )
                },
                    new SplitterDockable()
                {
                    Id    = "LeftSplitter",
                    Title = "LeftSplitter"
                },
                    documentDock,
                    new SplitterDockable()
                {
                    Id    = "RightSplitter",
                    Title = "RightSplitter"
                },
                    new ProportionalDock
                {
                    Id               = "RightPane",
                    Title            = "RightPane",
                    Proportion       = double.NaN,
                    Orientation      = Orientation.Vertical,
                    ActiveDockable   = null,
                    VisibleDockables = CreateList <IDockable>
                                       (
                        new ToolDock
                    {
                        Id               = "RightPaneTop",
                        Title            = "RightPaneTop",
                        Proportion       = double.NaN,
                        ActiveDockable   = rightTopTool1,
                        VisibleDockables = CreateList <IDockable>
                                           (
                            rightTopTool1,
                            rightTopTool2
                                           ),
                        Alignment = Alignment.Right,
                        GripMode  = GripMode.Visible
                    },
                        new SplitterDockable()
                    {
                        Id    = "RightPaneTopSplitter",
                        Title = "RightPaneTopSplitter"
                    },
                        new ToolDock
                    {
                        Id               = "RightPaneBottom",
                        Title            = "RightPaneBottom",
                        Proportion       = double.NaN,
                        ActiveDockable   = rightBottomTool1,
                        VisibleDockables = CreateList <IDockable>
                                           (
                            rightBottomTool1,
                            rightBottomTool2
                                           ),
                        Alignment = Alignment.Right,
                        GripMode  = GripMode.Visible
                    }
                                       )
                }
                                   )
            };

            var mainView = new MainViewModel
            {
                Id               = "Main",
                Title            = "Main",
                ActiveDockable   = mainLayout,
                VisibleDockables = CreateList <IDockable>(mainLayout)
            };

            var root = CreateRootDock();

            root.Id               = "Root";
            root.Title            = "Root";
            root.ActiveDockable   = mainView;
            root.DefaultDockable  = mainView;
            root.VisibleDockables = CreateList <IDockable>(mainView);

            _documentDock = documentDock;

            return(root);
        }