Exemple #1
0
        public static IDockable Dock(this IDock dock, IDockableViewModel model, bool add = true)
        {
            IDockable currentTab = null;

            if (add)
            {
                if (model is IToolViewModel toolModel)
                {
                    currentTab = new AvalonStudioToolTab(toolModel);
                }
                else if (model is IDocumentTabViewModel documentModel)
                {
                    currentTab = new AvalonStudioDocumentTab(documentModel);
                }

                dock.Factory.AddDockable(dock, currentTab);
            }
            else
            {
                currentTab = dock.VisibleDockables.FirstOrDefault(v => v.Context == model);

                if (currentTab != null)
                {
                    dock.Factory.UpdateDockable(currentTab, currentTab.Owner);
                }
            }

            return(currentTab);
        }
Exemple #2
0
        private void NavigateTo(IDockable dockable, bool bSnapshot)
        {
            if (_dock.ActiveDockable is IDock previousDock)
            {
                previousDock.Close();
            }

            if (!(dockable is null) && _dock.ActiveDockable != dockable)
            {
                if (!(_dock.ActiveDockable is null) && bSnapshot == true)
                {
                    PushBack(_dock.ActiveDockable);
                }

                if (_dock.Factory is IFactory factory)
                {
                    factory.SetActiveDockable(dockable);
                }
                else
                {
                    _dock.ActiveDockable = dockable;
                }
            }

            if (dockable is IRootDock nextDock)
            {
                nextDock.ShowWindows();
            }
        }
Exemple #3
0
        /// <inheritdoc/>
        public bool ValidateDock(IDock sourceDock, IDockable targetDockable, DragAction action, DockOperation operation, bool bExecute)
        {
            switch (targetDockable)
            {
            case IRootDock _:
                return(DockDockableIntoWindow(sourceDock, targetDockable, operation, bExecute));

            case IToolDock toolDock:
                if (sourceDock == toolDock)
                {
                    return(false);
                }
                return(DockDockable(sourceDock, targetDockable, toolDock, action, operation, bExecute));

            case IDocumentDock documentDock:
                if (sourceDock == documentDock)
                {
                    return(false);
                }
                return(DockDockable(sourceDock, targetDockable, documentDock, action, operation, bExecute));

            default:
                return(false);
            }
        }
Exemple #4
0
        internal bool DockDockable(IDockable sourceDockable, IDock sourceDockableOwner, IDockable targetDockable, IDock targetDockableOwner, DragAction action, bool bExecute)
        {
            switch (action)
            {
            case DragAction.Copy:
                return(false);

            case DragAction.Move:
                if (bExecute)
                {
                    if (sourceDockableOwner.Factory is IFactory factory)
                    {
                        factory.MoveDockable(sourceDockableOwner, targetDockableOwner, sourceDockable, targetDockable);
                    }
                }
                return(true);

            case DragAction.Link:
                if (bExecute)
                {
                    if (sourceDockableOwner.Factory is IFactory factory)
                    {
                        factory.SwapDockable(sourceDockableOwner, targetDockableOwner, sourceDockable, targetDockable);
                    }
                }
                return(true);

            default:
                return(false);
            }
        }
Exemple #5
0
        ///<inheritdoc/>
        public virtual void UpdateDockable(IDockable dockable, IDockable?owner)
        {
            if (GetContext(dockable.Id) is object context)
            {
                dockable.Context = context;
            }

            dockable.Owner = owner;

            if (dockable is IDock dock)
            {
                dock.Factory = this;

                if (!(dock.VisibleDockables is null))
                {
                    foreach (var child in dock.VisibleDockables)
                    {
                        UpdateDockable(child, dockable);
                    }
                }
            }

            if (dockable is IRootDock rootDock)
            {
                if (!(rootDock.Window is null))
                {
                    foreach (var child in rootDock.Windows)
                    {
                        UpdateDockWindow(child, dockable);
                    }
                }
            }
        }
Exemple #6
0
        internal bool DockDockableIntoWindow(IDockable sourceDockable, IDockable targetDockable, DockOperation operation, bool bExecute)
        {
            switch (operation)
            {
            case DockOperation.Window:
                if (sourceDockable == targetDockable)
                {
                    return(false);
                }
                if (sourceDockable.Owner is IDock sourceDockableOwner)
                {
                    if (sourceDockableOwner.Factory is IFactory factory)
                    {
                        if (factory.FindRoot(sourceDockable) is IRootDock root && root.ActiveDockable is IDock targetWindowOwner)
                        {
                            if (bExecute)
                            {
                                factory.SplitToWindow(targetWindowOwner, sourceDockable, ScreenPosition.X, ScreenPosition.Y, 300, 400);
                            }
                            return(true);
                        }
                    }
                }
                return(false);

            default:
                return(false);
            }
        }
Exemple #7
0
 private void SetIsActive(IDockable dockable, bool active)
 {
     if (dockable is IDock dock)
     {
         dock.IsActive = active;
     }
 }
Exemple #8
0
 ///<inheritdoc/>
 public virtual void SetActiveDockable(IDockable dockable)
 {
     if (dockable.Owner is IDock dock)
     {
         dock.ActiveDockable = dockable;
     }
 }
Exemple #9
0
    public override void InitLayout(IDockable layout)
    {
        ContextLocator = new Dictionary <string, Func <object> >
        {
            ["Document1"] = () => new DemoDocument(),
            ["Document2"] = () => new DemoDocument(),
            ["Document3"] = () => new DemoDocument(),
            ["Tool1"]     = () => new Tool1(),
            ["Tool2"]     = () => new Tool2(),
            ["Tool3"]     = () => new Tool3(),
            ["Tool4"]     = () => new Tool4(),
            ["Tool5"]     = () => new Tool5(),
            ["Tool6"]     = () => new Tool6(),
            ["Tool7"]     = () => new Tool7(),
            ["Tool8"]     = () => new Tool8(),
            ["Dashboard"] = () => layout,
            ["Home"]      = () => _context
        };

        DockableLocator = new Dictionary <string, Func <IDockable?> >()
        {
            ["Root"]      = () => _rootDock,
            ["Documents"] = () => _documentDock
        };

        HostWindowLocator = new Dictionary <string, Func <IHostWindow> >
        {
            [nameof(IDockWindow)] = () => new HostWindow()
        };

        base.InitLayout(layout);
    }
Exemple #10
0
        public override void InitLayout(IDockable layout)
        {
            this.ContextLocator = new Dictionary <string, Func <object> >
            {
                [nameof(IRootDock)]         = () => layout,
                [nameof(IProportionalDock)] = () => layout,
                [nameof(IDocumentDock)]     = () => layout,
                [nameof(IToolDock)]         = () => layout,
                [nameof(ISplitterDock)]     = () => layout,
                [nameof(IDockWindow)]       = () => layout,
                [nameof(IDocument)]         = () => layout,
                [nameof(ITool)]             = () => layout,
                ["Document1"]    = () => new Document1(),
                ["Document2"]    = () => new Document2(),
                ["LeftTop1"]     = () => new LeftTopTool1(),
                ["LeftTop2"]     = () => new LeftTopTool2(),
                ["LeftBottom1"]  = () => new LeftBottomTool1(),
                ["LeftBottom2"]  = () => new LeftBottomTool2(),
                ["RightTop1"]    = () => new RightTopTool1(),
                ["RightTop2"]    = () => new RightTopTool2(),
                ["RightBottom1"] = () => new RightBottomTool1(),
                ["RightBottom2"] = () => new RightBottomTool2()
            };

            this.HostWindowLocator = new Dictionary <string, Func <IHostWindow> >
            {
                [nameof(IDockWindow)] = () => new HostWindow()
            };

            this.DockableLocator = new Dictionary <string, Func <IDockable> >
            {
            };

            base.InitLayout(layout);
        }
Exemple #11
0
        private bool MoveDockable(IDockable sourceDockable, IDock sourceDockableOwner, IDock targetDock, bool bExecute)
        {
            if (sourceDockableOwner == targetDock)
            {
                if (targetDock.VisibleDockables?.Count == 1)
                {
                    return(false);
                }
            }
            var targetDockable = targetDock.ActiveDockable;

            if (targetDockable is null)
            {
                targetDockable = targetDock.VisibleDockables?.LastOrDefault();
                if (targetDockable is null)
                {
                    if (bExecute)
                    {
                        if (sourceDockableOwner.Factory is { } factory)
                        {
                            factory.MoveDockable(sourceDockableOwner, targetDock, sourceDockable, null);
                        }
                    }
                    return(true);
                }
            }
            if (bExecute)
            {
                if (sourceDockableOwner.Factory is { } factory)
                {
                    factory.MoveDockable(sourceDockableOwner, targetDock, sourceDockable, targetDockable);
                }
            }
            return(true);
        }
Exemple #12
0
        /// <inheritdoc/>
        public override void InitLayout(IDockable layout)
        {
            this.HostWindowLocator = new Dictionary <string, Func <IHostWindow> >
            {
                [nameof(IDockWindow)] = () => new HostWindow()
            };

            this.DockableLocator = new Dictionary <string, Func <IDockable> >
            {
                //[nameof(DebugCenterPane)] = () => DebugCenterPane,
                //[nameof(MainCenterPane)] = () => MainCenterPane,
            };

            this.UpdateDockable(layout, null);

            if (layout is IRootDock layoutWindowsHost)
            {
                layoutWindowsHost.ShowWindows();
                if (layout is IDock layoutViewsHost)
                {
                    layoutViewsHost.ActiveDockable = layoutViewsHost.DefaultDockable;
                    if (layoutViewsHost.ActiveDockable is IRootDock currentViewWindowsHost)
                    {
                        currentViewWindowsHost.ShowWindows();
                    }
                }
            }
        }
Exemple #13
0
        public override void UpdateDockable(IDockable view, IDockable parent)
        {
            view.Owner = parent;

            if (view is IDock dock)
            {
                dock.Factory = this;

                if (dock.VisibleDockables != null)
                {
                    foreach (var child in dock.VisibleDockables)
                    {
                        UpdateDockable(child, view);
                    }
                }
            }

            if (view is IRootDock rootDock)
            {
                if (rootDock.Windows != null)
                {
                    foreach (var child in rootDock.Windows)
                    {
                        UpdateDockWindow(child, view);
                    }
                }
            }
        }
Exemple #14
0
        ///<inheritdoc/>
        public bool ValidateTool(ITool sourceTool, IDockable targetDockable, DragAction action, DockOperation operation, bool bExecute)
        {
            switch (targetDockable)
            {
            case IRootDock _:
                return(DockDockableIntoWindow(sourceTool, targetDockable, operation, bExecute));

            case IToolDock toolDock:
                return(DockDockableIntoDock(sourceTool, toolDock, action, operation, bExecute));

            case IDocumentDock documentDock:
                return(DockDockableIntoDock(sourceTool, documentDock, action, operation, bExecute));

            case IPinDock pinDock:
                return(DockDockableIntoDock(sourceTool, pinDock, action, operation, bExecute));

            case ITool tool:
                return(DockDockableIntoDockable(sourceTool, tool, action, bExecute));

            case IDocument document:
                return(DockDockableIntoDockable(sourceTool, document, action, bExecute));

            default:
                return(false);
            }
        }
Exemple #15
0
        ///<inheritdoc/>
        public bool ValidateDockable(IDockable sourceDockable, IDockable targetDockable, DragAction action, DockOperation operation, bool bExecute)
        {
            switch (sourceDockable)
            {
            case IToolDock toolDock:
                return(ValidateDock(toolDock, targetDockable, action, operation, bExecute));

            case IDocumentDock documentDock:
                return(ValidateDock(documentDock, targetDockable, action, operation, bExecute));

            case IPinDock pinDock:
                return(ValidateDock(pinDock, targetDockable, action, operation, bExecute));

            case IProportionalDock proportionalDock:
                return(ValidateDock(proportionalDock, targetDockable, action, operation, bExecute));

            case ITool tool:
                return(ValidateTool(tool, targetDockable, action, operation, bExecute));

            case IDocument document:
                return(ValidateDocument(document, targetDockable, action, operation, bExecute));

            default:
                return(false);
            }
        }
        public override void InitLayout(IDockable layout)
        {
            this.ContextLocator = new Dictionary <string, Func <object> >
            {
                [nameof(IRootDock)]         = () => _context,
                [nameof(IProportionalDock)] = () => _context,
                [nameof(IDocumentDock)]     = () => _context,
                [nameof(IToolDock)]         = () => _context,
                [nameof(ISplitterDockable)] = () => _context,
                [nameof(IDockWindow)]       = () => _context,
                [nameof(IDocument)]         = () => _context,
                [nameof(ITool)]             = () => _context,
                ["Document1"]            = () => new TestDocument(),
                ["Document2"]            = () => new TestDocument(),
                ["LeftTop1"]             = () => new LeftTopTool1(),
                ["LeftTop2"]             = () => new LeftTopTool2(),
                ["LeftBottom1"]          = () => new LeftBottomTool1(),
                ["LeftBottom2"]          = () => new LeftBottomTool2(),
                ["RightTop1"]            = () => new RightTopTool1(),
                ["RightTop2"]            = () => new RightTopTool2(),
                ["RightBottom1"]         = () => new RightBottomTool1(),
                ["RightBottom2"]         = () => new RightBottomTool2(),
                ["LeftPane"]             = () => _context,
                ["LeftPaneTop"]          = () => _context,
                ["LeftPaneTopSplitter"]  = () => _context,
                ["LeftPaneBottom"]       = () => _context,
                ["RightPane"]            = () => _context,
                ["RightPaneTop"]         = () => _context,
                ["RightPaneTopSplitter"] = () => _context,
                ["RightPaneBottom"]      = () => _context,
                ["DocumentsPane"]        = () => _context,
                ["MainLayout"]           = () => _context,
                ["LeftSplitter"]         = () => _context,
                ["RightSplitter"]        = () => _context,
                ["MainLayout"]           = () => _context,
                ["Main"] = () => _context,
            };

            this.HostWindowLocator = new Dictionary <string, Func <IHostWindow> >
            {
                [nameof(IDockWindow)] = () =>
                {
                    var hostWindow = new HostWindow()
                    {
                        [!HostWindow.TitleProperty] = new Binding("ActiveDockable.Title")
                    };
                    return(hostWindow);
                }
            };

            this.DockableLocator = new Dictionary <string, Func <IDockable> >
            {
            };

            base.InitLayout(layout);

            this.SetActiveDockable(_documentDock);
            this.SetFocusedDockable(_documentDock, _documentDock.VisibleDockables?.FirstOrDefault());
        }
Exemple #17
0
 internal bool DockDockableIntoDock(IDockable sourceDockable, IDock targetDock, DragAction action, DockOperation operation, bool bExecute)
 {
     if (sourceDockable.Owner is IDock sourceDockableOwner)
     {
         return(DockDockableIntoDock(sourceDockable, sourceDockableOwner, targetDock, action, operation, bExecute));
     }
     return(false);
 }
Exemple #18
0
 private void PushBack(IDockable dockable)
 {
     if (_forward.Count > 0)
     {
         _forward.Clear();
     }
     _back.Push(dockable);
 }
Exemple #19
0
    public override void InitLayout(IDockable layout)
    {
        ContextLocator = new Dictionary <string, Func <object> >
        {
            // Documents
            ["PageDocument"]     = () => _projectEditor,
            ["PageDocumentDock"] = () => _projectEditor,
            // Explorers
            ["ProjectExplorer"] = () => _projectEditor,
            ["ObjectBrowser"]   = () => _projectEditor,
            // Properties
            ["PageProperties"]  = () => _projectEditor,
            ["ShapeProperties"] = () => _projectEditor,
            ["StyleProperties"] = () => _projectEditor,
            ["DataProperties"]  = () => _projectEditor,
            ["StateProperties"] = () => _projectEditor,
            // Libraries
            ["StyleLibrary"]    = () => _projectEditor,
            ["GroupLibrary"]    = () => _projectEditor,
            ["DatabaseLibrary"] = () => _projectEditor,
            ["TemplateLibrary"] = () => _projectEditor,
            ["ScriptLibrary"]   = () => _projectEditor,
            // Options
            ["ProjectOptions"]  = () => _projectEditor,
            ["RendererOptions"] = () => _projectEditor,
            ["ZoomOptions"]     = () => _projectEditor,
            ["ImageOptions"]    = () => _projectEditor,
            // Home
            ["HomeMenuView"]      = () => _projectEditor,
            ["HomeView"]          = () => _projectEditor,
            ["HomeDock"]          = () => _projectEditor,
            ["HomeStatusBarView"] = () => _projectEditor,
            ["HomeDockDock"]      = () => _projectEditor,
            // Dashboard
            ["DashboardMenuView"] = () => _projectEditor,
            ["DashboardView"]     = () => _projectEditor,
            ["DashboardDock"]     = () => _projectEditor,
            ["DashboardDockDock"] = () => _projectEditor,
            // Root
            ["Dashboard"] = () => _projectEditor,
            ["Home"]      = () => _projectEditor,
            ["Root"]      = () => _projectEditor
        };

        DockableLocator = new Dictionary <string, Func <IDockable?> >
        {
            ["Root"]  = () => _rootDock,
            ["Pages"] = () => _pagesDock,
            ["Home"]  = () => _homeDock,
        };

        HostWindowLocator = new Dictionary <string, Func <IHostWindow> >
        {
            [nameof(IDockWindow)] = () => new HostWindow()
        };

        base.InitLayout(layout);
    }
Exemple #20
0
 ///<inheritdoc/>
 public virtual void AddDockable(IDock dock, IDockable dockable)
 {
     UpdateDockable(dockable, dock);
     if (dock.VisibleDockables is null)
     {
         dock.VisibleDockables = CreateList <IDockable>();
     }
     dock.VisibleDockables.Add(dockable);
 }
Exemple #21
0
 public static void ShowWindows(IDockable dockable)
 {
     if (dockable.Owner is IDock dock && dock.Factory is IFactory factory)
     {
         if (factory.FindRoot(dock, (x) => true) is IRootDock root && root.ActiveDockable is IRootDock avtiveRootDockable)
         {
             avtiveRootDockable.ShowWindows();
         }
     }
 }
Exemple #22
0
        public override void InitLayout(IDockable layout)
        {
            this.ContextLocator = new Dictionary <string, Func <object> >
            {
                [nameof(IRootDock)]         = () => m_Context,
                [nameof(IPinDock)]          = () => m_Context,
                [nameof(IProportionalDock)] = () => m_Context,
                [nameof(IDocumentDock)]     = () => m_Context,
                [nameof(IToolDock)]         = () => m_Context,
                [nameof(ISplitterDock)]     = () => m_Context,
                [nameof(IDockWindow)]       = () => m_Context,
                [nameof(IDocument)]         = () => m_Context,
                [nameof(ITool)]             = () => m_Context,
                ["Document1"]            = () => m_Context,
                ["Layers"]               = () => m_Context,
                ["EditLayer"]            = () => m_Context,
                ["AddGeometry"]          = () => m_Context,
                ["LeftPane"]             = () => m_Context,
                ["LeftPaneTop"]          = () => m_Context,
                ["LeftPaneTopSplitter"]  = () => m_Context,
                ["LeftPaneBottom"]       = () => m_Context,
                ["CenterPane"]           = () => m_Context,
                ["CenterPaneSplitter"]   = () => m_Context,
                ["CenterPaneBottom"]     = () => m_Context,
                ["RightPane"]            = () => m_Context,
                ["RightPaneTop"]         = () => m_Context,
                ["RightPaneTopSplitter"] = () => m_Context,
                ["RightPaneBottom"]      = () => m_Context,
                ["DocumentsPane"]        = () => m_Context,
                ["MainLayout"]           = () => m_Context,
                ["LeftSplitter"]         = () => m_Context,
                ["RightSplitter"]        = () => m_Context,
                ["MainLayout"]           = () => m_Context,
                ["Main"] = () => m_Context,
            };

            this.HostWindowLocator = new Dictionary <string, Func <IHostWindow> >
            {
                [nameof(IDockWindow)] = () =>
                {
                    var hostWindow = new HostWindow()
                    {
                        [!HostWindow.TitleProperty] = new Binding("ActiveDockable.Title")
                    };
                    return(hostWindow);
                }
            };

            this.DockableLocator = new Dictionary <string, Func <IDockable> >
            {
            };

            base.InitLayout(layout);
        }
Exemple #23
0
 ///<inheritdoc/>
 public virtual void InsertDockable(IDock dock, IDockable dockable, int index)
 {
     if (index >= 0)
     {
         UpdateDockable(dockable, dock);
         if (dock.VisibleDockables is null)
         {
             dock.VisibleDockables = CreateList <IDockable>();
         }
     }
 }
Exemple #24
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);
     }
 }
Exemple #25
0
        ///<inheritdoc/>
        public virtual void PinDockable(IDockable dockable)
        {
            // TODO: Implement dockable pinning.

            if (FindRoot(dockable) is IRootDock root)
            {
                if (PinClosestPinDock(root, dockable) is IPinDock pinDock)
                {
                    PinDockable(pinDock, dockable);
                }
            }
        }
Exemple #26
0
        private void PinDockable(IPinDock pinDock, IDockable dockable)
        {
            RemoveDockable(dockable, true);

            if (pinDock.VisibleDockables is null)
            {
                pinDock.VisibleDockables = CreateList <IDockable>();
            }

            pinDock.VisibleDockables.Add(dockable);
            pinDock.ActiveDockable = dockable;
        }
Exemple #27
0
 ///<inheritdoc/>
 public virtual IRootDock?FindRoot(IDockable dockable)
 {
     if (dockable.Owner is null)
     {
         return(null);
     }
     if (dockable.Owner is IRootDock rootDock)
     {
         return(rootDock);
     }
     return(FindRoot(dockable.Owner));
 }
Exemple #28
0
 /// <inheritdoc/>
 public virtual void InitLayout(IDockable layout)
 {
     UpdateDockable(layout, null);
     if (layout is IDock root)
     {
         if (root.DefaultDockable != null)
         {
             root.ActiveDockable = root.DefaultDockable;
         }
         root.ShowWindows();
     }
 }
Exemple #29
0
 internal void SplitDocumentDockable(IDockable sourceDockable, IDock sourceDockableOwner, IDock targetDock, DockOperation operation)
 {
     if (targetDock.Factory is IFactory factory)
     {
         IDock documentDock = factory.CreateDocumentDock();
         documentDock.Id               = nameof(IDocumentDock);
         documentDock.Title            = nameof(IDocumentDock);
         documentDock.VisibleDockables = factory.CreateList <IDockable>();
         factory.MoveDockable(sourceDockableOwner, documentDock, sourceDockable, null);
         factory.SplitToDock(targetDock, documentDock, operation);
     }
 }
Exemple #30
0
 /// <inheritdoc/>
 public virtual IRootDock?FindRoot(IDockable dockable, Func <IRootDock, bool> predicate)
 {
     if (dockable.Owner is null)
     {
         return(null);
     }
     if (dockable.Owner is IRootDock rootDock && predicate(rootDock) == true)
     {
         return(rootDock);
     }
     return(FindRoot(dockable.Owner, predicate));
 }
Exemple #31
0
 public void DockAt(IDockable Dockable)
 {
     DockAt(() => Dockable);
 }