Пример #1
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();
            }
        }
Пример #2
0
 ///<inheritdoc/>
 public virtual void AddWindow(IRootDock rootDock, IDockWindow window)
 {
     if (rootDock.Window is null)
     {
         rootDock.Windows = CreateList <IDockWindow>();
     }
     rootDock.Windows.Add(window);
     UpdateDockWindow(window, rootDock);
 }
Пример #3
0
    protected DockableCollection(IFactory factory, IRootDock rootDock, Func <Type, object> dockableFactory, Func <T, IDock> dockLocator, ObservableCollection <T> list)
        : base(factory, rootDock, list)
    {
        this.dockableFactory = dockableFactory ?? throw new ArgumentNullException(nameof(dockableFactory));
        this.dockLocator     = dockLocator ?? throw new ArgumentNullException(nameof(dockLocator));

        ReactiveFactory.DockableClosed.Select(e => (e.EventArgs.Dockable !)).OfType <T>().Subscribe(dockable =>
        {
            Remove(dockable);
        }).DisposeWith(Disposables);
    }
Пример #4
0
        /// <summary>
        /// Clone <see cref="IRootDock"/>
        /// </summary>
        /// <param name="source">The source object</param>
        /// <returns>The new instance or reference <see cref="IRootDock"/> calss</returns>
        public static IRootDock?CloneRootDock(IRootDock source)
        {
            var target = source.Factory?.CreateRootDock();

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

            return(target);
        }
Пример #5
0
        /// <summary>
        /// Clones <see cref="IRootDock"/> object.
        /// </summary>
        /// <param name="source">The source object.</param>
        /// <returns>TThe new instance or reference of the <see cref="IRootDock"/> class.</returns>
        public static IRootDock CloneRootDock(IRootDock source)
        {
            var rootDock = source.Factory.CreateRootDock();

            CloneDockProperties(source, rootDock);

            rootDock.Window = null;
            rootDock.Top    = (IPinDock)source.Top?.Clone();
            rootDock.Bottom = (IPinDock)source.Bottom?.Clone();
            rootDock.Left   = (IPinDock)source.Left?.Clone();
            rootDock.Right  = (IPinDock)source.Right?.Clone();

            return(rootDock);
        }
Пример #6
0
        private IPinDock PinClosestPinDock(IRootDock root, IDockable dockable)
        {
            /// TODO: Find closest pin dock to the dockable(Top,Bottom,Left or Right).

            if (root.Left is null)
            {
                root.Left            = CreatePinDock();
                root.Left.Alignment  = Alignment.Left;
                root.Left.IsExpanded = false;
                root.Left.AutoHide   = true;
            }

            return(root.Left);
        }
Пример #7
0
    private static void LoadLayout(ProjectEditorViewModel editor, IRootDock layout)
    {
        if (editor.DockFactory is IFactory dockFactory)
        {
            editor.RootDock = layout;

            if (editor.RootDock is IDock dock)
            {
                dockFactory.InitLayout(dock);

                editor.NavigateTo = id => dock.Navigate.Execute(id);

                dock.Navigate.Execute("Dashboard");
            }
        }
    }
Пример #8
0
    protected DockableCollectionBase(IFactory factory, IRootDock rootDock, ObservableCollection <T> list)
        : base(list)
    {
        this.ReactiveFactory = new ReactiveDockFactory(factory ?? throw new ArgumentNullException(nameof(factory)));
        this.RootDock        = rootDock ?? throw new ArgumentNullException(nameof(rootDock));
        this.List            = list ?? throw new ArgumentNullException(nameof(list));
        Disposables          = new CompositeDisposable();

        var activated = this.ReactiveFactory.FocusedDockableChanged.Select(e => e.EventArgs.Dockable !)
                        .Merge(this.ReactiveFactory.ActiveDockableChanged.Select(e => e.EventArgs.Dockable !))
                        .OfType <T>()
                        .DistinctUntilChanged();

        var active = new ReadOnlyBehavourSubject <T?>(default(T));

        activated.Subscribe(active).DisposeWith(Disposables);
        Active = active;
    }
Пример #9
0
        public AvalonStudioPerspective(IRootDock root)
        {
            Root      = root;
            _tools    = new List <IToolViewModel>();
            _tabTools = new Dictionary <IToolViewModel, IDockable>();

            //CenterPane.WhenAnyValue(l => l.FocusedDockable).Subscribe(focused =>
            //{
            //    if (focused?.Context is IToolViewModel tool)
            //    {
            //        SelectedTool = tool;
            //    }
            //    else
            //    {
            //        SelectedTool = null;
            //    }
            //});
        }
Пример #10
0
        /// <summary>
        /// Clone root Dock properties
        /// </summary>
        /// <param name="source">The source root dock</param>
        /// <param name="target">The target root dock</param>
        public static void CloneRootDockProperties(IRootDock source, IRootDock target)
        {
            target.Window = null;

            if (!(source.Top is null))
            {
                target.Top = (IPinDock?)source.Top.Clone();
            }

            if (!(source.Bottom is null))
            {
                target.Bottom = (IPinDock?)source.Bottom.Clone();
            }

            if (!(source.Right is null))
            {
                target.Right = (IPinDock?)source.Right.Clone();
            }

            if (!(source.Left is null))
            {
                target.Left = (IPinDock?)source.Left.Clone();
            }


            if (!(source.Windows is null))
            {
                target.Windows = source.Factory?.CreateList <IDockWindow>();
                if (!(target.Windows is null))
                {
                    foreach (var window in source.Windows)
                    {
                        var clone = window.Clone();
                        if (!(clone is null))
                        {
                            target.Windows.Add(clone);
                        }
                    }
                }
            }
        }
Пример #11
0
        /// <summary>
        /// Clones root dock properties.
        /// </summary>
        /// <param name="source">The source root dock.</param>
        /// <param name="target">The target root dock.</param>
        public static void CloneRootDockProperties(IRootDock source, IRootDock target)
        {
            target.IsFocusableRoot = source.IsFocusableRoot;

            target.Window = null;

            if (!(source.Windows is null))
            {
                target.Windows = source.Factory?.CreateList <IDockWindow>();
                if (!(target.Windows is null))
                {
                    foreach (var window in source.Windows)
                    {
                        var clone = window.Clone();
                        if (!(clone is null))
                        {
                            target.Windows.Add(clone);
                        }
                    }
                }
            }
        }
Пример #12
0
        internal bool ValidateRoot(IRootDock sourceRoot, IView targetView, DragAction action, DockOperation operation, bool bExecute)
        {
            switch (targetView)
            {
            case IRootDock targetRoot:
            {
                return(false);
            }

            case IToolTab sourceToolTab:
            {
                return(false);
            }

            case IDocumentTab sourceDocumentTab:
            {
                return(false);
            }

            case ILayoutDock targetLayout:
            {
                return(false);
            }

            case ITabDock targetTab:
            {
                return(false);
            }

            default:
            {
#if DEBUG
                Console.WriteLine($"Not supported type {targetView.GetType()}: {sourceRoot} -> {targetView}");
#endif
                return(false);
            }
            }
        }
Пример #13
0
 public DockableCollection(IFactory factory, IRootDock rootDock, Func <Type, object> dockableFactory, Func <T, IDock> dockLocator)
     : this(factory, rootDock, dockableFactory, dockLocator, new ObservableCollection <T>())
 {
 }