Exemplo n.º 1
0
        private bool FindParentLayoutDocumentPane(ILayoutDocumentPane documentPane, out LayoutDocumentPaneGroup containerPaneGroup, out LayoutPanel containerPanel)
        {
            containerPaneGroup = null;
            containerPanel     = null;
            if (documentPane.Parent is LayoutPanel)
            {
                containerPaneGroup = null;
                containerPanel     = documentPane.Parent as LayoutPanel;
                return(true);
            }
            if (!(documentPane.Parent is LayoutDocumentPaneGroup))
            {
                return(false);
            }
            LayoutDocumentPaneGroup parent = documentPane.Parent as LayoutDocumentPaneGroup;

            do
            {
                if (parent.Parent is LayoutPanel)
                {
                    break;
                }
                parent = parent.Parent as LayoutDocumentPaneGroup;
            }while (parent != null);
            if (parent == null)
            {
                return(false);
            }
            containerPaneGroup = parent;
            containerPanel     = parent.Parent as LayoutPanel;
            return(true);
        }
        public override Geometry GetPreviewPath(OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel)
        {
            ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;

            if (targetModel != null)
            {
                var manager = targetModel.Root.Manager;

                //ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;
                LayoutDocumentPaneGroup parentGroup;
                LayoutPanel             parentGroupPanel;
                if (!FindParentLayoutDocumentPane(targetModel, out parentGroup, out parentGroupPanel))
                {
                    return(null);
                }
                var documentPaneControl =
                    manager.FindLogicalChildren <FrameworkElement>()
                    .OfType <ILayoutControl>()
                    .First(d => parentGroup != null ? Equals(d.Model, parentGroup) : Equals(d.Model, parentGroupPanel)) as
                    FrameworkElement;
                var targetScreenRect = documentPaneControl.GetScreenArea();

                switch (Type)
                {
                case DropTargetType.DocumentPaneDockAsAnchorableBottom:
                {
                    targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top);
                    targetScreenRect.Offset(0.0, targetScreenRect.Height - targetScreenRect.Height / 3.0);
                    targetScreenRect.Height /= 3.0;
                    return(new RectangleGeometry(targetScreenRect));
                }

                case DropTargetType.DocumentPaneDockAsAnchorableTop:
                {
                    targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top);
                    targetScreenRect.Height /= 3.0;
                    return(new RectangleGeometry(targetScreenRect));
                }

                case DropTargetType.DocumentPaneDockAsAnchorableRight:
                {
                    targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top);
                    targetScreenRect.Offset(targetScreenRect.Width - targetScreenRect.Width / 3.0, 0.0);
                    targetScreenRect.Width /= 3.0;
                    return(new RectangleGeometry(targetScreenRect));
                }

                case DropTargetType.DocumentPaneDockAsAnchorableLeft:
                {
                    targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top);
                    targetScreenRect.Width /= 3.0;
                    return(new RectangleGeometry(targetScreenRect));
                }
                }
            }

            return(null);
        }
Exemplo n.º 3
0
        public override Geometry GetPreviewPath(OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel)
        {
            LayoutDocumentPaneGroup layoutDocumentPaneGroup;
            LayoutPanel             layoutPanel;
            ILayoutDocumentPane     model   = this._targetPane.Model as ILayoutDocumentPane;
            DockingManager          manager = model.Root.Manager;

            if (!this.FindParentLayoutDocumentPane(model, out layoutDocumentPaneGroup, out layoutPanel))
            {
                return(null);
            }
            Rect screenArea = (manager.FindLogicalChildren <FrameworkElement>().OfType <ILayoutControl>().First <ILayoutControl>((ILayoutControl d) => {
                if (layoutDocumentPaneGroup == null)
                {
                    return(d.Model == layoutPanel);
                }
                return(d.Model == layoutDocumentPaneGroup);
            }) as FrameworkElement).GetScreenArea();

            switch (base.Type)
            {
            case DropTargetType.DocumentPaneDockAsAnchorableLeft:
            {
                screenArea.Offset(-overlayWindow.Left, -overlayWindow.Top);
                screenArea.Width = screenArea.Width / 3;
                return(new RectangleGeometry(screenArea));
            }

            case DropTargetType.DocumentPaneDockAsAnchorableTop:
            {
                screenArea.Offset(-overlayWindow.Left, -overlayWindow.Top);
                screenArea.Height = screenArea.Height / 3;
                return(new RectangleGeometry(screenArea));
            }

            case DropTargetType.DocumentPaneDockAsAnchorableRight:
            {
                screenArea.Offset(-overlayWindow.Left, -overlayWindow.Top);
                screenArea.Offset(screenArea.Width - screenArea.Width / 3, 0);
                screenArea.Width = screenArea.Width / 3;
                return(new RectangleGeometry(screenArea));
            }

            case DropTargetType.DocumentPaneDockAsAnchorableBottom:
            {
                screenArea.Offset(-overlayWindow.Left, -overlayWindow.Top);
                screenArea.Offset(0, screenArea.Height - screenArea.Height / 3);
                screenArea.Height = screenArea.Height / 3;
                return(new RectangleGeometry(screenArea));
            }
            }
            return(null);
        }
Exemplo n.º 4
0
        protected override void Drop(LayoutDocumentFloatingWindow floatingWindow)
        {
            ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;

            switch (Type)
            {
            case DropTargetType.DocumentPaneDockBottom:
            {
                var newLayoutDocumentPane = new LayoutDocumentPane(floatingWindow.RootDocument);
                if (targetModel != null)
                {
                    if (!(targetModel.Parent is LayoutDocumentPaneGroup parentModel))
                    {
                        var parentContainer = targetModel.Parent;
                        var newParentModel  = new LayoutDocumentPaneGroup
                        {
                            Orientation = System.Windows.Controls.Orientation.Vertical
                        };
                        parentContainer.ReplaceChild(targetModel, newParentModel);
                        newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                        newParentModel.Children.Add(newLayoutDocumentPane);
                    }
                    else
                    {
                        var manager = parentModel.Root.Manager;
                        if (!manager.AllowMixedOrientation ||
                            parentModel.Orientation == System.Windows.Controls.Orientation.Vertical)
                        {
                            parentModel.Orientation = System.Windows.Controls.Orientation.Vertical;
                            int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                            parentModel.Children.Insert(targetPaneIndex + 1, newLayoutDocumentPane);
                        }
                        else
                        {
                            LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup
                            {
                                Orientation = System.Windows.Controls.Orientation.Vertical
                            };
                            parentModel.ReplaceChild(targetModel, newChildGroup);
                            newChildGroup.Children.Add(targetModel);
                            newChildGroup.Children.Add(newLayoutDocumentPane);
                        }
                    }
                }
            }
            break;
Exemplo n.º 5
0
        private bool FindParentLayoutDocumentPane(ILayoutDocumentPane documentPane,
                                                  out LayoutDocumentPaneGroup containerPaneGroup, out LayoutPanel containerPanel)
        {
            containerPaneGroup = null;
            containerPanel     = null;

            var panel = documentPane.Parent as LayoutPanel;

            if (panel != null)
            {
                containerPanel = panel;
                return(true);
            }
            if (!(documentPane.Parent is LayoutDocumentPaneGroup))
            {
                return(false);
            }
            var currentDocumentPaneGroup = (LayoutDocumentPaneGroup)documentPane.Parent;

            while (!(currentDocumentPaneGroup.Parent is LayoutPanel))
            {
                currentDocumentPaneGroup = currentDocumentPaneGroup.Parent as LayoutDocumentPaneGroup;

                if (currentDocumentPaneGroup == null)
                {
                    break;
                }
            }

            if (currentDocumentPaneGroup == null)
            {
                return(false);
            }

            containerPaneGroup = currentDocumentPaneGroup;
            containerPanel     = (LayoutPanel)currentDocumentPaneGroup.Parent;
            return(true);
        }
        private bool FindParentLayoutDocumentPane(ILayoutDocumentPane documentPane,
                                                  out LayoutDocumentPaneGroup containerPaneGroup, out LayoutPanel containerPanel)
        {
            containerPaneGroup = null;
            containerPanel     = null;

            if (documentPane.Parent is LayoutPanel)
            {
                containerPaneGroup = null;
                containerPanel     = documentPane.Parent as LayoutPanel;
                return(true);
            }

            if (documentPane.Parent is LayoutDocumentPaneGroup)
            {
                var currentDocumentPaneGroup = documentPane.Parent as LayoutDocumentPaneGroup;
                while (!(currentDocumentPaneGroup.Parent is LayoutPanel))
                {
                    currentDocumentPaneGroup = currentDocumentPaneGroup.Parent as LayoutDocumentPaneGroup;

                    if (currentDocumentPaneGroup is null)
                    {
                        break;
                    }
                }

                if (currentDocumentPaneGroup is null)
                {
                    return(false);
                }

                containerPaneGroup = currentDocumentPaneGroup;
                containerPanel     = currentDocumentPaneGroup.Parent as LayoutPanel;
                return(true);
            }

            return(false);
        }
Exemplo n.º 7
0
        /// <summary>
        /// Handles the NotifyCollectionChangedEventArgs event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The event.</param>
        /// <param name="region">The region.</param>
        /// <param name="regionTarget">The region target.</param>
        void OnViewsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e, IRegion region, DockingManager regionTarget)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                foreach (FrameworkElement item in e.NewItems)
                {
                    UIElement view = item as UIElement;

                    if (view != null)
                    {
                        //Create a new layout document to be included in the LayoutDocuemntPane (defined in xaml)
                        LayoutDocument newLayoutDocument = new LayoutDocument();
                        //Set the content of the LayoutDocument
                        newLayoutDocument.Content = item;

                        //Allows us to add an title and Icon to the Document

                        /*ViewModelBase viewModel = (ViewModelBase)item.DataContext;
                         *
                         * if (viewModel != null)
                         * {*/
                        //All my viewmodels have properties DisplayName and IconKey
                        newLayoutDocument.Title = "test";

                        /*
                         *  //GetImageUri is custom made method which gets the icon for the LayoutDocument
                         *  newLayoutDocument.IconSource = this.GetImageUri(viewModel.IconKey);
                         * }*/

                        //Store all LayoutDocuments already pertaining to the LayoutDocumentPane (defined in xaml)
                        List <LayoutDocument> oldLayoutDocuments = new List <LayoutDocument>();

                        //Get the current ILayoutDocumentPane ... Depending on the arrangement of the views this can be either
                        //a simple LayoutDocumentPane or a LayoutDocumentPaneGroup
                        ILayoutDocumentPane currentILayoutDocumentPane = (ILayoutDocumentPane)regionTarget.Layout.RootPanel.Children[0];

                        if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPaneGroup))
                        {
                            //If the current ILayoutDocumentPane turns out to be a group
                            //Get the children (LayoutDocuments) of the first pane
                            LayoutDocumentPane oldLayoutDocumentPane = (LayoutDocumentPane)currentILayoutDocumentPane.Children.ToList()[0];
                            foreach (LayoutDocument child in oldLayoutDocumentPane.Children)
                            {
                                oldLayoutDocuments.Insert(0, child);
                            }
                        }
                        else if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPane))
                        {
                            //If the current ILayoutDocumentPane turns out to be a simple pane
                            //Get the children (LayoutDocuments) of the single existing pane.
                            foreach (LayoutDocument child in currentILayoutDocumentPane.Children)
                            {
                                oldLayoutDocuments.Insert(0, child);
                            }
                        }

                        //Create a new LayoutDocumentPane and inserts your new LayoutDocument
                        LayoutDocumentPane newLayoutDocumentPane = new LayoutDocumentPane();
                        newLayoutDocumentPane.InsertChildAt(0, newLayoutDocument);

                        //Append to the new LayoutDocumentPane the old LayoutDocuments
                        foreach (LayoutDocument doc in oldLayoutDocuments)
                        {
                            newLayoutDocumentPane.InsertChildAt(0, doc);
                        }

                        //Traverse the visual tree of the xaml and replace the LayoutDocumentPane (or LayoutDocumentPaneGroup) in xaml
                        //with your new LayoutDocumentPane (or LayoutDocumentPaneGroup)
                        if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPane))
                        {
                            regionTarget.Layout.RootPanel.ReplaceChildAt(0, newLayoutDocumentPane);
                        }
                        else if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPaneGroup))
                        {
                            currentILayoutDocumentPane.ReplaceChild(currentILayoutDocumentPane.Children.ToList()[0], newLayoutDocumentPane);
                            regionTarget.Layout.RootPanel.ReplaceChildAt(0, currentILayoutDocumentPane);
                        }
                        newLayoutDocument.IsActive = true;
                    }
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Handles the NotifyCollectionChangedEventArgs event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The event.</param>
        /// <param name="region">The region.</param>
        /// <param name="regionTarget">The region target.</param>
        void OnViewsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e, IRegion region, DockingManager regionTarget)
        {
            if (e.Action == NotifyCollectionChangedAction.Remove)
            {
                foreach (var eOldItem in e.OldItems)
                {
                    var disposables = new[]
                    {
                        eOldItem as IDisposable,
                        (eOldItem as FrameworkElement)?.DataContext as IDisposable,
                        (eOldItem as ContentControl)?.Content as IDisposable,
                        ((eOldItem as ContentControl)?.Content as FrameworkElement)?.DataContext as IDisposable
                    };

                    foreach (var disposable in disposables)
                    {
                        disposable?.Dispose();
                    }
                }
            }

            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                foreach (FrameworkElement item in e.NewItems)
                {
                    UIElement view = item;

                    if (view != null)
                    {
                        //Create a new layout document to be included in the LayoutDocuemntPane (defined in xaml)
                        LayoutDocument newLayoutDocument = new LayoutDocument();
                        //Set the content of the LayoutDocument
                        newLayoutDocument.Content = item;
                        newLayoutDocument.Title   = (item.DataContext as ITitledItem)?.Title;

                        ServerMonitorModel viewModel = item.DataContext as ServerMonitorModel;
                        if (viewModel != null)
                        {
                            //All my viewmodels have properties DisplayName and IconKey
                            newLayoutDocument.Title = viewModel.CurrentServer.Name;
                            viewModel.OpenServer();
                            newLayoutDocument.Closed += (s, a) =>
                            {
                                Task.Factory.StartNew(() =>
                                {
                                    viewModel.CloseServer();
                                    viewModel.Cleanup();
                                });
                            };
                        }

                        //Store all LayoutDocuments already pertaining to the LayoutDocumentPane (defined in xaml)
                        List <LayoutDocument> oldLayoutDocuments = new List <LayoutDocument>();
                        //Get the current ILayoutDocumentPane ... Depending on the arrangement of the views this can be either
                        //a simple LayoutDocumentPane or a LayoutDocumentPaneGroup
                        ILayoutDocumentPane currentILayoutDocumentPane = (ILayoutDocumentPane)regionTarget.Layout.RootPanel.Children[0];

                        if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPaneGroup))
                        {
                            //If the current ILayoutDocumentPane turns out to be a group
                            //Get the children (LayoutDocuments) of the first pane
                            LayoutDocumentPane oldLayoutDocumentPane = (LayoutDocumentPane)currentILayoutDocumentPane.Children.ToList()[0];
                            foreach (LayoutDocument child in oldLayoutDocumentPane.Children)
                            {
                                oldLayoutDocuments.Insert(0, child);
                            }
                        }
                        else if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPane))
                        {
                            //If the current ILayoutDocumentPane turns out to be a simple pane
                            //Get the children (LayoutDocuments) of the single existing pane.
                            foreach (LayoutDocument child in currentILayoutDocumentPane.Children)
                            {
                                oldLayoutDocuments.Insert(0, child);
                            }
                        }

                        //Create a new LayoutDocumentPane and inserts your new LayoutDocument
                        LayoutDocumentPane newLayoutDocumentPane = new LayoutDocumentPane();
                        newLayoutDocumentPane.InsertChildAt(0, newLayoutDocument);

                        //Append to the new LayoutDocumentPane the old LayoutDocuments
                        foreach (LayoutDocument doc in oldLayoutDocuments)
                        {
                            newLayoutDocumentPane.InsertChildAt(0, doc);
                        }

                        //Traverse the visual tree of the xaml and replace the LayoutDocumentPane (or LayoutDocumentPaneGroup) in xaml
                        //with your new LayoutDocumentPane (or LayoutDocumentPaneGroup)
                        if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPane))
                        {
                            regionTarget.Layout.RootPanel.ReplaceChildAt(0, newLayoutDocumentPane);
                        }
                        else if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPaneGroup))
                        {
                            currentILayoutDocumentPane.ReplaceChild(currentILayoutDocumentPane.Children.ToList()[0], newLayoutDocumentPane);
                            regionTarget.Layout.RootPanel.ReplaceChildAt(0, currentILayoutDocumentPane);
                        }

                        newLayoutDocument.IsActive = true;
                    }
                }
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Method is invoked to complete a drag & drop operation with a (new) docking position
        /// by docking of the LayoutDocument <paramref name="floatingWindow"/> into this drop target.
        /// </summary>
        /// <param name="floatingWindow"></param>
        protected override void Drop(LayoutDocumentFloatingWindow floatingWindow)
        {
            ILayoutDocumentPane targetModel    = _targetPane.Model as ILayoutDocumentPane;
            LayoutDocument      documentActive = floatingWindow.Descendents().OfType <LayoutDocument>().FirstOrDefault();

            switch (Type)
            {
            case DropTargetType.DocumentPaneDockBottom:
                #region DropTargetType.DocumentPaneDockBottom
            {
                var parentModel           = targetModel.Parent as ILayoutGroup;
                var parentModelOrientable = targetModel.Parent as ILayoutOrientableGroup;
                int insertToIndex         = parentModel.IndexOfChild(targetModel);

                if (parentModelOrientable.Orientation != System.Windows.Controls.Orientation.Vertical &&
                    parentModel.ChildrenCount == 1)
                {
                    parentModelOrientable.Orientation = System.Windows.Controls.Orientation.Vertical;
                }

                if (parentModelOrientable.Orientation == System.Windows.Controls.Orientation.Vertical)
                {
                    var layoutDocumentPaneGroup = floatingWindow.RootPanel as LayoutDocumentPaneGroup;
                    if (layoutDocumentPaneGroup != null &&
                        (layoutDocumentPaneGroup.Children.Count == 1 ||
                         layoutDocumentPaneGroup.Orientation == System.Windows.Controls.Orientation.Vertical))
                    {
                        var documentsToMove = layoutDocumentPaneGroup.Children.ToArray();
                        for (int i = 0; i < documentsToMove.Length; i++)
                        {
                            parentModel.InsertChildAt(insertToIndex + 1 + i, documentsToMove[i]);
                        }
                    }
                    else
                    {
                        parentModel.InsertChildAt(insertToIndex + 1, floatingWindow.RootPanel);
                    }
                }
                else
                {
                    var targetModelAsPositionableElement = targetModel as ILayoutPositionableElement;
                    var newOrientedPanel = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Vertical,
                        DockWidth   = targetModelAsPositionableElement.DockWidth,
                        DockHeight  = targetModelAsPositionableElement.DockHeight,
                    };

                    parentModel.InsertChildAt(insertToIndex, newOrientedPanel);
                    newOrientedPanel.Children.Add(targetModel);
                    newOrientedPanel.Children.Add(floatingWindow.RootPanel);
                }
            }
            break;
                #endregion DropTargetType.DocumentPaneDockBottom

            case DropTargetType.DocumentPaneDockTop:
                #region DropTargetType.DocumentPaneDockTop
            {
                var parentModel           = targetModel.Parent as ILayoutGroup;
                var parentModelOrientable = targetModel.Parent as ILayoutOrientableGroup;
                int insertToIndex         = parentModel.IndexOfChild(targetModel);

                if (parentModelOrientable.Orientation != System.Windows.Controls.Orientation.Vertical &&
                    parentModel.ChildrenCount == 1)
                {
                    parentModelOrientable.Orientation = System.Windows.Controls.Orientation.Vertical;
                }

                if (parentModelOrientable.Orientation == System.Windows.Controls.Orientation.Vertical)
                {
                    var layoutDocumentPaneGroup = floatingWindow.RootPanel as LayoutDocumentPaneGroup;
                    if (layoutDocumentPaneGroup != null &&
                        (layoutDocumentPaneGroup.Children.Count == 1 ||
                         layoutDocumentPaneGroup.Orientation == System.Windows.Controls.Orientation.Vertical))
                    {
                        var documentsToMove = layoutDocumentPaneGroup.Children.ToArray();
                        for (int i = 0; i < documentsToMove.Length; i++)
                        {
                            parentModel.InsertChildAt(insertToIndex + i, documentsToMove[i]);
                        }
                    }
                    else
                    {
                        parentModel.InsertChildAt(insertToIndex, floatingWindow.RootPanel);
                    }
                }
                else
                {
                    var targetModelAsPositionableElement = targetModel as ILayoutPositionableElement;
                    var newOrientedPanel = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Vertical,
                        DockWidth   = targetModelAsPositionableElement.DockWidth,
                        DockHeight  = targetModelAsPositionableElement.DockHeight,
                    };

                    parentModel.InsertChildAt(insertToIndex, newOrientedPanel);
                    //the floating window must be added after the target modal as it could be raise a CollectGarbage call
                    newOrientedPanel.Children.Add(targetModel);
                    newOrientedPanel.Children.Insert(0, floatingWindow.RootPanel);
                }
            }
            break;
                #endregion DropTargetType.DocumentPaneDockTop

            case DropTargetType.DocumentPaneDockLeft:
                #region DropTargetType.DocumentPaneDockLeft
            {
                var parentModel           = targetModel.Parent as ILayoutGroup;
                var parentModelOrientable = targetModel.Parent as ILayoutOrientableGroup;
                int insertToIndex         = parentModel.IndexOfChild(targetModel);

                if (parentModelOrientable.Orientation != System.Windows.Controls.Orientation.Horizontal &&
                    parentModel.ChildrenCount == 1)
                {
                    parentModelOrientable.Orientation = System.Windows.Controls.Orientation.Horizontal;
                }

                if (parentModelOrientable.Orientation == System.Windows.Controls.Orientation.Horizontal)
                {
                    var layoutDocumentPaneGroup = floatingWindow.RootPanel as LayoutDocumentPaneGroup;
                    if (layoutDocumentPaneGroup != null &&
                        (layoutDocumentPaneGroup.Children.Count == 1 ||
                         layoutDocumentPaneGroup.Orientation == System.Windows.Controls.Orientation.Horizontal))
                    {
                        var documentsToMove = layoutDocumentPaneGroup.Children.ToArray();
                        for (int i = 0; i < documentsToMove.Length; i++)
                        {
                            parentModel.InsertChildAt(insertToIndex + i, documentsToMove[i]);
                        }
                    }
                    else
                    {
                        parentModel.InsertChildAt(insertToIndex, floatingWindow.RootPanel);
                    }
                }
                else
                {
                    var targetModelAsPositionableElement = targetModel as ILayoutPositionableElement;
                    var newOrientedPanel = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Horizontal,
                        DockWidth   = targetModelAsPositionableElement.DockWidth,
                        DockHeight  = targetModelAsPositionableElement.DockHeight,
                    };

                    parentModel.InsertChildAt(insertToIndex, newOrientedPanel);
                    //the floating window must be added after the target modal as it could be raise a CollectGarbage call
                    newOrientedPanel.Children.Add(targetModel);
                    newOrientedPanel.Children.Insert(0, floatingWindow.RootPanel);
                }
            }
            break;
                #endregion DropTargetType.DocumentPaneDockLeft

            case DropTargetType.DocumentPaneDockRight:
                #region DropTargetType.DocumentPaneDockRight
            {
                var parentModel           = targetModel.Parent as ILayoutGroup;
                var parentModelOrientable = targetModel.Parent as ILayoutOrientableGroup;
                int insertToIndex         = parentModel.IndexOfChild(targetModel);

                if (parentModelOrientable.Orientation != System.Windows.Controls.Orientation.Horizontal &&
                    parentModel.ChildrenCount == 1)
                {
                    parentModelOrientable.Orientation = System.Windows.Controls.Orientation.Horizontal;
                }

                if (parentModelOrientable.Orientation == System.Windows.Controls.Orientation.Horizontal)
                {
                    var layoutDocumentPaneGroup = floatingWindow.RootPanel as LayoutDocumentPaneGroup;
                    if (layoutDocumentPaneGroup != null &&
                        (layoutDocumentPaneGroup.Children.Count == 1 ||
                         layoutDocumentPaneGroup.Orientation == System.Windows.Controls.Orientation.Horizontal))
                    {
                        var documentToMove = layoutDocumentPaneGroup.Children.ToArray();
                        for (int i = 0; i < documentToMove.Length; i++)
                        {
                            parentModel.InsertChildAt(insertToIndex + 1 + i, documentToMove[i]);
                        }
                    }
                    else
                    {
                        parentModel.InsertChildAt(insertToIndex + 1, floatingWindow.RootPanel);
                    }
                }
                else
                {
                    var targetModelAsPositionableElement = targetModel as ILayoutPositionableElement;
                    var newOrientedPanel = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Horizontal,
                        DockWidth   = targetModelAsPositionableElement.DockWidth,
                        DockHeight  = targetModelAsPositionableElement.DockHeight,
                    };

                    parentModel.InsertChildAt(insertToIndex, newOrientedPanel);
                    newOrientedPanel.Children.Add(targetModel);
                    newOrientedPanel.Children.Add(floatingWindow.RootPanel);
                }
            }
            break;
                #endregion DropTargetType.DocumentPaneDockRight

            case DropTargetType.DocumentPaneDockInside:
                #region DropTargetType.DocumentPaneDockInside
            {
                var paneModel = targetModel as LayoutDocumentPane;
                var layoutDocumentPaneGroup = floatingWindow.RootPanel as LayoutDocumentPaneGroup;

                // A LayoutFloatingDocumentWindow can contain multiple instances of both Anchorables or Documents
                // and we should drop these back into the DocumentPane if they are available
                var allowedDropTypes = new[] { typeof(LayoutDocument), typeof(LayoutAnchorable) };

                int i = _tabIndex == -1 ? 0 : _tabIndex;
                foreach (var anchorableToImport in
                         layoutDocumentPaneGroup.Descendents().OfType <LayoutContent>()
                         .Where(item => allowedDropTypes.Contains(item.GetType())).ToArray())
                {
                    paneModel.Children.Insert(i, anchorableToImport);
                    i++;
                }
            }
            break;
                #endregion DropTargetType.DocumentPaneDockInside
            }

            if (documentActive != null)
            {
                documentActive.IsActive = true;
            }

            base.Drop(floatingWindow);
        }
Exemplo n.º 10
0
        protected override void Drop(LayoutAnchorableFloatingWindow floatingWindow)
        {
            ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;

            switch (Type)
            {
            case DropTargetType.DocumentPaneDockBottom:
                #region DropTargetType.DocumentPaneDockBottom
            {
                var parentModel           = targetModel.Parent as LayoutDocumentPaneGroup;
                var newLayoutDocumentPane = new LayoutDocumentPane();

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Vertical
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                    newParentModel.Children.Add(newLayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Vertical)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Vertical;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex + 1, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(targetModel);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                    }
                }

                foreach (var cntToTransfer in floatingWindow.RootPanel.Descendents().OfType <LayoutAnchorable>().ToArray())
                {
                    newLayoutDocumentPane.Children.Add(cntToTransfer);
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockTop:
                #region DropTargetType.DocumentPaneDockTop
            {
                var parentModel           = targetModel.Parent as LayoutDocumentPaneGroup;
                var newLayoutDocumentPane = new LayoutDocumentPane();

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Vertical
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(newLayoutDocumentPane);
                    newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Vertical)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Vertical;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                        newChildGroup.Children.Add(targetModel);
                    }
                }

                foreach (var cntToTransfer in floatingWindow.RootPanel.Descendents().OfType <LayoutAnchorable>().ToArray())
                {
                    newLayoutDocumentPane.Children.Add(cntToTransfer);
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockLeft:
                #region DropTargetType.DocumentPaneDockLeft
            {
                var parentModel           = targetModel.Parent as LayoutDocumentPaneGroup;
                var newLayoutDocumentPane = new LayoutDocumentPane();

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Horizontal
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(newLayoutDocumentPane);
                    newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Horizontal)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                        newChildGroup.Children.Add(targetModel);
                    }
                }

                foreach (var cntToTransfer in floatingWindow.RootPanel.Descendents().OfType <LayoutAnchorable>().ToArray())
                {
                    newLayoutDocumentPane.Children.Add(cntToTransfer);
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockRight:
                #region DropTargetType.DocumentPaneDockRight
            {
                var parentModel           = targetModel.Parent as LayoutDocumentPaneGroup;
                var newLayoutDocumentPane = new LayoutDocumentPane();

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Horizontal
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                    newParentModel.Children.Add(newLayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Horizontal)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex + 1, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(targetModel);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                    }
                }

                foreach (var cntToTransfer in floatingWindow.RootPanel.Descendents().OfType <LayoutAnchorable>().ToArray())
                {
                    newLayoutDocumentPane.Children.Add(cntToTransfer);
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockInside:
                #region DropTargetType.DocumentPaneDockInside
            {
                var paneModel = targetModel as LayoutDocumentPane;
                var layoutAnchorablePaneGroup = floatingWindow.RootPanel as LayoutAnchorablePaneGroup;

                bool checkPreviousContainer = true;
                int  i = 0;
                if (_tabIndex != -1)
                {
                    i = _tabIndex;
                    checkPreviousContainer = false;
                }
                LayoutAnchorable anchorableToActivate = null;

                foreach (var anchorableToImport in layoutAnchorablePaneGroup.Descendents().OfType <LayoutAnchorable>().ToArray())
                {
                    if (checkPreviousContainer)
                    {
                        var previousContainer = (( ILayoutPreviousContainer )anchorableToImport).PreviousContainer;
                        if (object.ReferenceEquals(previousContainer, targetModel) && (anchorableToImport.PreviousContainerIndex != -1))
                        {
                            i = anchorableToImport.PreviousContainerIndex;
                        }
                        checkPreviousContainer = false;
                    }

                    if (anchorableToImport.CanClose)
                    {
                        anchorableToImport.SetCanCloseInternal(true);
                    }

                    paneModel.Children.Insert(Math.Min(i, paneModel.Children.Count), anchorableToImport);
                    i++;
                    anchorableToActivate = anchorableToImport;
                }

                anchorableToActivate.IsActive = true;
            }
            break;
                #endregion
            }

            base.Drop(floatingWindow);
        }
Exemplo n.º 11
0
        protected override void Drop(LayoutDocumentFloatingWindow floatingWindow)
        {
            ILayoutDocumentPane model = this._targetPane.Model as ILayoutDocumentPane;

            switch (base.Type)
            {
            case DropTargetType.DocumentPaneDockLeft:
            {
                LayoutDocumentPane      layoutDocumentPane = new LayoutDocumentPane(floatingWindow.RootDocument);
                LayoutDocumentPaneGroup parent             = model.Parent as LayoutDocumentPaneGroup;
                if (parent == null)
                {
                    ILayoutContainer        layoutContainer         = model.Parent;
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    layoutContainer.ReplaceChild(model, layoutDocumentPaneGroup);
                    layoutDocumentPaneGroup.Children.Add(model);
                    layoutDocumentPaneGroup.Children.Insert(0, layoutDocumentPane);
                    break;
                }
                else if (!parent.Root.Manager.AllowMixedOrientation || parent.Orientation == Orientation.Horizontal)
                {
                    parent.Orientation = Orientation.Horizontal;
                    int num = parent.IndexOfChild(model);
                    parent.Children.Insert(num, layoutDocumentPane);
                    break;
                }
                else
                {
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup1 = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    parent.ReplaceChild(model, layoutDocumentPaneGroup1);
                    layoutDocumentPaneGroup1.Children.Add(layoutDocumentPane);
                    layoutDocumentPaneGroup1.Children.Add(model);
                    break;
                }
            }

            case DropTargetType.DocumentPaneDockTop:
            {
                LayoutDocumentPane      layoutDocumentPane1 = new LayoutDocumentPane(floatingWindow.RootDocument);
                LayoutDocumentPaneGroup parent1             = model.Parent as LayoutDocumentPaneGroup;
                if (parent1 == null)
                {
                    ILayoutContainer        layoutContainer1         = model.Parent;
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup2 = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Vertical
                    };
                    layoutContainer1.ReplaceChild(model, layoutDocumentPaneGroup2);
                    layoutDocumentPaneGroup2.Children.Add(model as LayoutDocumentPane);
                    layoutDocumentPaneGroup2.Children.Insert(0, layoutDocumentPane1);
                    break;
                }
                else if (!parent1.Root.Manager.AllowMixedOrientation || parent1.Orientation == Orientation.Vertical)
                {
                    parent1.Orientation = Orientation.Vertical;
                    int num1 = parent1.IndexOfChild(model);
                    parent1.Children.Insert(num1, layoutDocumentPane1);
                    break;
                }
                else
                {
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup3 = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Vertical
                    };
                    parent1.ReplaceChild(model, layoutDocumentPaneGroup3);
                    layoutDocumentPaneGroup3.Children.Add(layoutDocumentPane1);
                    layoutDocumentPaneGroup3.Children.Add(model);
                    break;
                }
            }

            case DropTargetType.DocumentPaneDockRight:
            {
                LayoutDocumentPane      layoutDocumentPane2 = new LayoutDocumentPane(floatingWindow.RootDocument);
                LayoutDocumentPaneGroup parent2             = model.Parent as LayoutDocumentPaneGroup;
                if (parent2 == null)
                {
                    ILayoutContainer        layoutContainer2         = model.Parent;
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup4 = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    layoutContainer2.ReplaceChild(model, layoutDocumentPaneGroup4);
                    layoutDocumentPaneGroup4.Children.Add(model as LayoutDocumentPane);
                    layoutDocumentPaneGroup4.Children.Add(layoutDocumentPane2);
                    break;
                }
                else if (!parent2.Root.Manager.AllowMixedOrientation || parent2.Orientation == Orientation.Horizontal)
                {
                    parent2.Orientation = Orientation.Horizontal;
                    int num2 = parent2.IndexOfChild(model);
                    parent2.Children.Insert(num2 + 1, layoutDocumentPane2);
                    break;
                }
                else
                {
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup5 = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    parent2.ReplaceChild(model, layoutDocumentPaneGroup5);
                    layoutDocumentPaneGroup5.Children.Add(model);
                    layoutDocumentPaneGroup5.Children.Add(layoutDocumentPane2);
                    break;
                }
            }

            case DropTargetType.DocumentPaneDockBottom:
            {
                LayoutDocumentPane      layoutDocumentPane3 = new LayoutDocumentPane(floatingWindow.RootDocument);
                LayoutDocumentPaneGroup parent3             = model.Parent as LayoutDocumentPaneGroup;
                if (parent3 == null)
                {
                    ILayoutContainer        layoutContainer3         = model.Parent;
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup6 = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Vertical
                    };
                    layoutContainer3.ReplaceChild(model, layoutDocumentPaneGroup6);
                    layoutDocumentPaneGroup6.Children.Add(model as LayoutDocumentPane);
                    layoutDocumentPaneGroup6.Children.Add(layoutDocumentPane3);
                    break;
                }
                else if (!parent3.Root.Manager.AllowMixedOrientation || parent3.Orientation == Orientation.Vertical)
                {
                    parent3.Orientation = Orientation.Vertical;
                    int num3 = parent3.IndexOfChild(model);
                    parent3.Children.Insert(num3 + 1, layoutDocumentPane3);
                    break;
                }
                else
                {
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup7 = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Vertical
                    };
                    parent3.ReplaceChild(model, layoutDocumentPaneGroup7);
                    layoutDocumentPaneGroup7.Children.Add(model);
                    layoutDocumentPaneGroup7.Children.Add(layoutDocumentPane3);
                    break;
                }
            }

            case DropTargetType.DocumentPaneDockInside:
            {
                LayoutDocumentPane layoutDocumentPane4 = model as LayoutDocumentPane;
                LayoutDocument     rootDocument        = floatingWindow.RootDocument;
                int previousContainerIndex             = 0;
                if (this._tabIndex != -1)
                {
                    previousContainerIndex = this._tabIndex;
                }
                else if (((ILayoutPreviousContainer)rootDocument).PreviousContainer == model && rootDocument.PreviousContainerIndex != -1)
                {
                    previousContainerIndex = rootDocument.PreviousContainerIndex;
                }
                rootDocument.IsActive = false;
                layoutDocumentPane4.Children.Insert(previousContainerIndex, rootDocument);
                rootDocument.IsActive = true;
                break;
            }
            }
            base.Drop(floatingWindow);
        }
        public override System.Windows.Media.Geometry GetPreviewPath(OverlayWindow overlayWindow, LayoutFloatingWindow floatingWindowModel)
        {
            Rect targetScreenRect;
            ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;
            var manager = targetModel.Root.Manager;

            //ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;
            LayoutDocumentPaneGroup parentGroup;
            LayoutPanel             parentGroupPanel;

            if (!FindParentLayoutDocumentPane(targetModel, out parentGroup, out parentGroupPanel))
            {
                return(null);
            }

            //if (targetModel.Parent is LayoutDocumentPaneGroup)
            //{
            //    var parentGroup = targetModel.Parent as LayoutDocumentPaneGroup;
            //    var documentPaneGroupControl = manager.FindLogicalChildren<LayoutDocumentPaneGroupControl>().First(d => d.Model == parentGroup);
            //    targetScreenRect = documentPaneGroupControl.GetScreenArea();
            //}
            //else
            //{
            //    var documentPaneControl = manager.FindLogicalChildren<LayoutDocumentPaneControl>().First(d => d.Model == targetModel);
            //    targetScreenRect = documentPaneControl.GetScreenArea();
            //}

            //var parentPanel = targetModel.FindParent<LayoutPanel>();
            var documentPaneControl = manager.FindLogicalChildren <FrameworkElement>().OfType <ILayoutControl>().First(d => parentGroup != null ? d.Model == parentGroup : d.Model == parentGroupPanel) as FrameworkElement;

            targetScreenRect = documentPaneControl.GetScreenArea();

            switch (Type)
            {
            case DropTargetType.DocumentPaneDockAsAnchorableBottom:
            {
                targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top);
                targetScreenRect.Offset(0.0, targetScreenRect.Height - targetScreenRect.Height / 3.0);
                targetScreenRect.Height /= 3.0;
                return(new RectangleGeometry(targetScreenRect));
            }

            case DropTargetType.DocumentPaneDockAsAnchorableTop:
            {
                targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top);
                targetScreenRect.Height /= 3.0;
                return(new RectangleGeometry(targetScreenRect));
            }

            case DropTargetType.DocumentPaneDockAsAnchorableRight:
            {
                targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top);
                targetScreenRect.Offset(targetScreenRect.Width - targetScreenRect.Width / 3.0, 0.0);
                targetScreenRect.Width /= 3.0;
                return(new RectangleGeometry(targetScreenRect));
            }

            case DropTargetType.DocumentPaneDockAsAnchorableLeft:
            {
                targetScreenRect.Offset(-overlayWindow.Left, -overlayWindow.Top);
                targetScreenRect.Width /= 3.0;
                return(new RectangleGeometry(targetScreenRect));
            }
            }

            return(null);
        }
        /// <summary>
        /// Method is invoked to complete a drag & drop operation with a (new) docking position
        /// by docking of the LayoutDocument <paramref name="floatingWindow"/> into this drop target.
        /// </summary>
        /// <param name="floatingWindow"></param>
        protected override void Drop(LayoutDocumentFloatingWindow floatingWindow)
        {
            ILayoutDocumentPane targetModel    = _targetPane.Model as ILayoutDocumentPane;
            LayoutDocument      documentActive = floatingWindow.Descendents().OfType <LayoutDocument>().FirstOrDefault();

            // ensure paneGroup
            var paneGroup = targetModel.Parent as LayoutDocumentPaneGroup;

            if (paneGroup == null)
            {
                var targetModelAsPositionableElement = targetModel as ILayoutPositionableElement;
                var layoutGroup = targetModel.Parent as ILayoutGroup;
                paneGroup = new LayoutDocumentPaneGroup()
                {
                    Orientation = System.Windows.Controls.Orientation.Vertical,
                    DockWidth   = targetModelAsPositionableElement.DockWidth,
                    DockHeight  = targetModelAsPositionableElement.DockHeight,
                };

                paneGroup.Children.Add(targetModel);
                layoutGroup.InsertChildAt(0, paneGroup);
            }
            var paneGroupOrientaion = paneGroup as ILayoutOrientableGroup;


            switch (Type)
            {
            case DropTargetType.DocumentPaneDockBottom:

                #region DropTargetType.DocumentPaneDockBottom

            {
                if (paneGroupOrientaion.Orientation != System.Windows.Controls.Orientation.Vertical)
                {
                    paneGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
                }

                var insertToIndex = paneGroup.IndexOfChild(targetModel);
                if (insertToIndex == (paneGroup.Children.Count - 1))
                {
                    insertToIndex = paneGroup.Children.Count;
                }
                var documentsToMove = floatingWindow.Children.ToArray();
                for (int i = 0; i < documentsToMove.Length; i++)
                {
                    var floatingChild = documentsToMove[i];
                    paneGroup.InsertChildAt(insertToIndex + i, floatingChild);
                }
            }
            break;

                #endregion DropTargetType.DocumentPaneDockBottom

            case DropTargetType.DocumentPaneDockTop:

                #region DropTargetType.DocumentPaneDockTop

            {
                if (paneGroupOrientaion.Orientation != System.Windows.Controls.Orientation.Vertical)
                {
                    paneGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
                }

                var insertToIndex = paneGroup.IndexOfChild(targetModel);
                if (insertToIndex < 0)
                {
                    insertToIndex = 0;
                }
                var documentsToMove = floatingWindow.Children.ToArray();
                for (int i = 0; i < documentsToMove.Length; i++)
                {
                    var floatingChild = documentsToMove[i];
                    paneGroup.InsertChildAt(insertToIndex + i, floatingChild);
                }
            }
            break;

                #endregion DropTargetType.DocumentPaneDockTop

            case DropTargetType.DocumentPaneDockLeft:

                #region DropTargetType.DocumentPaneDockLeft

            {
                if (paneGroupOrientaion.Orientation != System.Windows.Controls.Orientation.Horizontal)
                {
                    paneGroup.Orientation = System.Windows.Controls.Orientation.Horizontal;
                }

                var insertToIndex = paneGroup.IndexOfChild(targetModel);
                if (insertToIndex < 0)
                {
                    insertToIndex = 0;
                }
                var documentsToMove = floatingWindow.Children.ToArray();
                for (int i = 0; i < documentsToMove.Length; i++)
                {
                    var floatingChild = documentsToMove[i];
                    paneGroup.InsertChildAt(insertToIndex + i, floatingChild);
                }
            }
            break;

                #endregion DropTargetType.DocumentPaneDockLeft

            case DropTargetType.DocumentPaneDockRight:

                #region DropTargetType.DocumentPaneDockRight

            {
                if (paneGroupOrientaion.Orientation != System.Windows.Controls.Orientation.Horizontal)
                {
                    paneGroup.Orientation = System.Windows.Controls.Orientation.Horizontal;
                }

                var insertToIndex = paneGroup.IndexOfChild(targetModel);
                if (insertToIndex == (paneGroup.Children.Count - 1))
                {
                    insertToIndex = paneGroup.Children.Count;
                }
                var documentsToMove = floatingWindow.Children.ToArray();
                for (int i = 0; i < documentsToMove.Length; i++)
                {
                    var floatingChild = documentsToMove[i];
                    paneGroup.InsertChildAt(insertToIndex + i, floatingChild);
                }
            }
            break;

                #endregion DropTargetType.DocumentPaneDockRight

            case DropTargetType.DocumentPaneDockInside:

                #region DropTargetType.DocumentPaneDockInside

            {
                var paneModel = targetModel as LayoutDocumentPane;
                var layoutDocumentPaneGroup = floatingWindow.RootPanel as LayoutDocumentPaneGroup;

                // A LayoutFloatingDocumentWindow can contain multiple instances of both Anchorables or Documents
                // and we should drop these back into the DocumentPane if they are available
                var allowedDropTypes = new[] { typeof(LayoutDocument), typeof(LayoutAnchorable) };

                int i = _tabIndex == -1 ? 0 : _tabIndex;
                foreach (var anchorableToImport in
                         layoutDocumentPaneGroup.Descendents().OfType <LayoutContent>()
                         .Where(item => allowedDropTypes.Any(dropType => dropType.IsInstanceOfType(item))).ToArray())
                {
                    paneModel.Children.Insert(i, anchorableToImport);
                    i++;
                }
            }
            break;

                #endregion DropTargetType.DocumentPaneDockInside
            }

            if (documentActive != null)
            {
                documentActive.IsActive = true;
            }

            base.Drop(floatingWindow);
        }
Exemplo n.º 14
0
        protected override void Drop(LayoutDocumentFloatingWindow floatingWindow)
        {
            ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;

            switch (Type)
            {
            case DropTargetType.DocumentPaneDockBottom:
                #region DropTargetType.DocumentPaneDockBottom
            {
                var newLayoutDocumentPane = new LayoutDocumentPane(floatingWindow.RootDocument);
                var targetPane            = targetModel as ILayoutPositionableElement;
                if (targetPane != null)
                {
                    // Set the DockWidth of the targetPane and the newLayoutDocumentPane so they both use the same size.
                    if (targetPane.DockHeight.IsStar)
                    {
                        targetPane.DockHeight            = new GridLength(targetPane.DockHeight.Value / 2d, GridUnitType.Star);
                        newLayoutDocumentPane.DockHeight = targetPane.DockHeight;
                    }
                }
                var parentModel = targetModel.Parent as LayoutDocumentPaneGroup;

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Vertical
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                    newParentModel.Children.Add(newLayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Vertical)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Vertical;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex + 1, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(targetModel);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                    }
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockTop:
                #region DropTargetType.DocumentPaneDockTop
            {
                var newLayoutDocumentPane = new LayoutDocumentPane(floatingWindow.RootDocument);
                var targetPane            = targetModel as ILayoutPositionableElement;
                if (targetPane != null)
                {
                    // Set the DockWidth of the targetPane and the newLayoutDocumentPane so they both use the same size.
                    if (targetPane.DockHeight.IsStar)
                    {
                        targetPane.DockHeight            = new GridLength(targetPane.DockHeight.Value / 2d, GridUnitType.Star);
                        newLayoutDocumentPane.DockHeight = targetPane.DockHeight;
                    }
                }
                var parentModel = targetModel.Parent as LayoutDocumentPaneGroup;

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Vertical
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                    newParentModel.Children.Insert(0, newLayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Vertical)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Vertical;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                        newChildGroup.Children.Add(targetModel);
                    }
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockLeft:
                #region DropTargetType.DocumentPaneDockLeft
            {
                var newLayoutDocumentPane = new LayoutDocumentPane(floatingWindow.RootDocument);
                var targetPane            = targetModel as ILayoutPositionableElement;
                if (targetPane != null)
                {
                    // Set the DockWidth of the targetPane and the newLayoutDocumentPane so they both use the same size.
                    if (targetPane.DockWidth.IsStar)
                    {
                        targetPane.DockWidth            = new GridLength(targetPane.DockWidth.Value / 2d, GridUnitType.Star);
                        newLayoutDocumentPane.DockWidth = targetPane.DockWidth;
                    }
                }
                var parentModel = targetModel.Parent as LayoutDocumentPaneGroup;

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Horizontal
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(targetModel);
                    newParentModel.Children.Insert(0, newLayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Horizontal)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                        newChildGroup.Children.Add(targetModel);
                    }
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockRight:
                #region DropTargetType.DocumentPaneDockRight
            {
                var newLayoutDocumentPane = new LayoutDocumentPane(floatingWindow.RootDocument);
                var targetPane            = targetModel as ILayoutPositionableElement;
                if (targetPane != null)
                {
                    // Set the DockWidth of the targetPane and the newLayoutDocumentPane so they both use the same size.
                    if (targetPane.DockWidth.IsStar)
                    {
                        targetPane.DockWidth            = new GridLength(targetPane.DockWidth.Value / 2d, GridUnitType.Star);
                        newLayoutDocumentPane.DockWidth = targetPane.DockWidth;
                    }
                }
                var parentModel = targetModel.Parent as LayoutDocumentPaneGroup;

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Horizontal
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                    newParentModel.Children.Add(newLayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Horizontal)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex + 1, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(targetModel);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                    }
                }
            }
            break;
                #endregion

            case DropTargetType.DocumentPaneDockInside:
                #region DropTargetType.DocumentPaneDockInside
            {
                var paneModel   = targetModel as LayoutDocumentPane;
                var sourceModel = floatingWindow.RootDocument;

                int i = 0;
                if (_tabIndex != -1)
                {
                    i = _tabIndex;
                }
                else
                {
                    var previousIndex     = 0;
                    var previousContainer = (( ILayoutPreviousContainer )sourceModel).PreviousContainer;
                    if (object.ReferenceEquals(previousContainer, targetModel) && (sourceModel.PreviousContainerIndex != -1))
                    {
                        previousIndex = sourceModel.PreviousContainerIndex;
                    }

                    i = previousIndex;
                }
                sourceModel.IsActive = false;
                paneModel.Children.Insert(Math.Min(i, paneModel.Children.Count), sourceModel);
                sourceModel.IsActive = true;
            }
            break;
                #endregion
            }

            base.Drop(floatingWindow);
        }
Exemplo n.º 15
0
        /// <summary>
        /// Handles the NotifyCollectionChangedEventArgs event.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The event.</param>
        /// <param name="region">The region.</param>
        /// <param name="regionTarget">The region target.</param>
        void OnViewsCollectionChanged(object sender, NotifyCollectionChangedEventArgs e, IRegion region, DockingManager regionTarget)
        {
            if (e.Action == NotifyCollectionChangedAction.Add)
            {
                foreach (FrameworkElement item in e.NewItems)
                {
                    UIElement view = item as UIElement;

                    if (view != null)
                    {
                        //Create a new layout document to be included in the LayoutDocuemntPane (defined in xaml)
                        LayoutDocument newLayoutDocument = new LayoutDocument();
                        //Set the content of the LayoutDocument
                        newLayoutDocument.Content = item;

                        /*IDecompileViewModel viewModel = item.DataContext as IDecompileViewModel;
                         *
                         * if (viewModel != null)
                         * {
                         *  Binding binding = new Binding("Title") { Source = viewModel,Mode=BindingMode.OneWay };
                         *  BindingOperations.SetBinding(newLayoutDocument, LayoutDocument.TitleProperty, binding);
                         * }*/

                        //Store all LayoutDocuments already pertaining to the LayoutDocumentPane (defined in xaml)
                        List <LayoutDocument> oldLayoutDocuments = new List <LayoutDocument>();
                        //Get the current ILayoutDocumentPane ... Depending on the arrangement of the views this can be either
                        //a simple LayoutDocumentPane or a LayoutDocumentPaneGroup
                        ILayoutDocumentPane currentILayoutDocumentPane = (ILayoutDocumentPane)regionTarget.Layout.RootPanel.Children[0];

                        if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPaneGroup))
                        {
                            //If the current ILayoutDocumentPane turns out to be a group
                            //Get the children (LayoutDocuments) of the first pane

                            LayoutDocumentPane oldLayoutDocumentPane = (LayoutDocumentPane)currentILayoutDocumentPane.Children.ToList()[0];
                            foreach (LayoutDocument child in oldLayoutDocumentPane.Children)
                            {
                                oldLayoutDocuments.Insert(0, child);
                            }
                        }
                        else if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPane))
                        {
                            //If the current ILayoutDocumentPane turns out to be a simple pane
                            //Get the children (LayoutDocuments) of the single existing pane.
                            foreach (LayoutDocument child in currentILayoutDocumentPane.Children)
                            {
                                oldLayoutDocuments.Insert(0, child);
                            }
                        }

                        //Create a new LayoutDocumentPane and inserts your new LayoutDocument
                        LayoutDocumentPane newLayoutDocumentPane = new LayoutDocumentPane();
                        newLayoutDocumentPane.InsertChildAt(0, newLayoutDocument);

                        //Append to the new LayoutDocumentPane the old LayoutDocuments
                        foreach (LayoutDocument doc in oldLayoutDocuments)
                        {
                            newLayoutDocumentPane.InsertChildAt(0, doc);
                        }

                        //Traverse the visual tree of the xaml and replace the LayoutDocumentPane (or LayoutDocumentPaneGroup) in xaml
                        //with your new LayoutDocumentPane (or LayoutDocumentPaneGroup)
                        if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPane))
                        {
                            regionTarget.Layout.RootPanel.ReplaceChildAt(0, newLayoutDocumentPane);
                        }
                        else if (currentILayoutDocumentPane.GetType() == typeof(LayoutDocumentPaneGroup))
                        {
                            currentILayoutDocumentPane.ReplaceChild(currentILayoutDocumentPane.Children.ToList()[0], newLayoutDocumentPane);
                            regionTarget.Layout.RootPanel.ReplaceChildAt(0, currentILayoutDocumentPane);
                        }
                        newLayoutDocument.IsActive = true;
                    }
                }
            }
        }
Exemplo n.º 16
0
        protected override void Drop(LayoutAnchorableFloatingWindow floatingWindow)
        {
            ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;

            switch (Type)
            {
            case DropTargetType.DocumentPaneDockBottom:
                #region DropTargetType.DocumentPaneDockBottom
            {
                var parentModel           = targetModel.Parent as LayoutDocumentPaneGroup;
                var newLayoutDocumentPane = new LayoutDocumentPane();

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Vertical
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                    newParentModel.Children.Add(newLayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Vertical)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Vertical;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex + 1, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(targetModel);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                    }
                }

                foreach (var cntToTransfer in floatingWindow.RootPanel.Descendents().OfType <LayoutAnchorable>().ToArray())
                {
                    newLayoutDocumentPane.Children.Add(cntToTransfer);
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockTop:
                #region DropTargetType.DocumentPaneDockTop
            {
                var parentModel           = targetModel.Parent as LayoutDocumentPaneGroup;
                var newLayoutDocumentPane = new LayoutDocumentPane();

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Vertical
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(newLayoutDocumentPane);
                    newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Vertical)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Vertical;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                        newChildGroup.Children.Add(targetModel);
                    }
                }

                foreach (var cntToTransfer in floatingWindow.RootPanel.Descendents().OfType <LayoutAnchorable>().ToArray())
                {
                    newLayoutDocumentPane.Children.Add(cntToTransfer);
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockLeft:
                #region DropTargetType.DocumentPaneDockLeft
            {
                var parentModel           = targetModel.Parent as LayoutDocumentPaneGroup;
                var newLayoutDocumentPane = new LayoutDocumentPane();

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Horizontal
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(newLayoutDocumentPane);
                    newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Horizontal)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                        newChildGroup.Children.Add(targetModel);
                    }
                }

                foreach (var cntToTransfer in floatingWindow.RootPanel.Descendents().OfType <LayoutAnchorable>().ToArray())
                {
                    newLayoutDocumentPane.Children.Add(cntToTransfer);
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockRight:
                #region DropTargetType.DocumentPaneDockRight
            {
                var parentModel           = targetModel.Parent as LayoutDocumentPaneGroup;
                var newLayoutDocumentPane = new LayoutDocumentPane();

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Horizontal
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                    newParentModel.Children.Add(newLayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Horizontal)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex + 1, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(targetModel);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                    }
                }

                foreach (var cntToTransfer in floatingWindow.RootPanel.Descendents().OfType <LayoutAnchorable>().ToArray())
                {
                    newLayoutDocumentPane.Children.Add(cntToTransfer);
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockInside:
                #region DropTargetType.DocumentPaneDockInside
            {
                var paneModel = targetModel as LayoutDocumentPane;
                var layoutAnchorablePaneGroup = floatingWindow.RootPanel as LayoutAnchorablePaneGroup;

                int i = _tabIndex == -1 ? 0 : _tabIndex;
                LayoutAnchorable anchorableToActivate = null;
                foreach (var anchorableToImport in layoutAnchorablePaneGroup.Descendents().OfType <LayoutAnchorable>().ToArray())
                {
                    paneModel.Children.Insert(i, anchorableToImport);
                    i++;
                    anchorableToActivate = anchorableToImport;
                }

                anchorableToActivate.IsActive = true;
            }
            break;
                #endregion
            }

            base.Drop(floatingWindow);
        }
Exemplo n.º 17
0
        protected override void Drop(LayoutDocumentFloatingWindow floatingWindow)
        {
            ILayoutDocumentPane targetModel = _targetPane.Model as ILayoutDocumentPane;

            switch (Type)
            {
            case DropTargetType.DocumentPaneDockBottom:
                #region DropTargetType.DocumentPaneDockBottom
            {
                var newLayoutDocumentPane = new LayoutDocumentPane(floatingWindow.RootDocument);
                var parentModel           = targetModel.Parent as LayoutDocumentPaneGroup;

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Vertical
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                    newParentModel.Children.Add(newLayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Vertical)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Vertical;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex + 1, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(targetModel);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                    }
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockTop:
                #region DropTargetType.DocumentPaneDockTop
            {
                var newLayoutDocumentPane = new LayoutDocumentPane(floatingWindow.RootDocument);
                var parentModel           = targetModel.Parent as LayoutDocumentPaneGroup;

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Vertical
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                    newParentModel.Children.Insert(0, newLayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Vertical)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Vertical;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Vertical;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                        newChildGroup.Children.Add(targetModel);
                    }
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockLeft:
                #region DropTargetType.DocumentPaneDockLeft
            {
                var newLayoutDocumentPane = new LayoutDocumentPane(floatingWindow.RootDocument);
                var parentModel           = targetModel.Parent as LayoutDocumentPaneGroup;

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Horizontal
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(targetModel);
                    newParentModel.Children.Insert(0, newLayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Horizontal)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                        newChildGroup.Children.Add(targetModel);
                    }
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockRight:
                #region DropTargetType.DocumentPaneDockRight
            {
                var newLayoutDocumentPane = new LayoutDocumentPane(floatingWindow.RootDocument);
                var parentModel           = targetModel.Parent as LayoutDocumentPaneGroup;

                if (parentModel == null)
                {
                    var parentContainer = targetModel.Parent as ILayoutContainer;
                    var newParentModel  = new LayoutDocumentPaneGroup()
                    {
                        Orientation = System.Windows.Controls.Orientation.Horizontal
                    };
                    parentContainer.ReplaceChild(targetModel, newParentModel);
                    newParentModel.Children.Add(targetModel as LayoutDocumentPane);
                    newParentModel.Children.Add(newLayoutDocumentPane);
                }
                else
                {
                    var manager = parentModel.Root.Manager;
                    if (!manager.AllowMixedOrientation || parentModel.Orientation == System.Windows.Controls.Orientation.Horizontal)
                    {
                        parentModel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        int targetPaneIndex = parentModel.IndexOfChild(targetModel);
                        parentModel.Children.Insert(targetPaneIndex + 1, newLayoutDocumentPane);
                    }
                    else
                    {
                        LayoutDocumentPaneGroup newChildGroup = new LayoutDocumentPaneGroup();
                        newChildGroup.Orientation = System.Windows.Controls.Orientation.Horizontal;
                        parentModel.ReplaceChild(targetModel, newChildGroup);
                        newChildGroup.Children.Add(targetModel);
                        newChildGroup.Children.Add(newLayoutDocumentPane);
                    }
                }
            }
            break;
                #endregion

            case DropTargetType.DocumentPaneDockInside:
                #region DropTargetType.DocumentPaneDockInside
            {
                var paneModel   = targetModel as LayoutDocumentPane;
                var sourceModel = floatingWindow.RootDocument;

                int i = _tabIndex == -1 ? 0 : _tabIndex;
                sourceModel.IsActive = false;
                paneModel.Children.Insert(i, sourceModel);
                sourceModel.IsActive = true;
            }
            break;
                #endregion
            }

            base.Drop(floatingWindow);
        }
Exemplo n.º 18
0
        protected override void Drop(LayoutAnchorableFloatingWindow floatingWindow)
        {
            LayoutDocumentPaneGroup layoutDocumentPaneGroup;
            LayoutPanel             layoutPanel;
            ILayoutElement          layoutElement;
            ILayoutPanelElement     layoutPanelElement;
            ILayoutElement          layoutElement1;
            ILayoutElement          layoutElement2;
            ILayoutPanelElement     layoutPanelElement1;
            ILayoutElement          layoutElement3;
            ILayoutElement          layoutElement4;
            ILayoutPanelElement     layoutPanelElement2;
            ILayoutElement          layoutElement5;
            ILayoutElement          layoutElement6;
            ILayoutPanelElement     layoutPanelElement3;
            ILayoutElement          layoutElement7;
            ILayoutDocumentPane     model = this._targetPane.Model as ILayoutDocumentPane;

            this.FindParentLayoutDocumentPane(model, out layoutDocumentPaneGroup, out layoutPanel);
            switch (base.Type)
            {
            case DropTargetType.DocumentPaneDockAsAnchorableLeft:
            {
                if (layoutPanel != null && layoutPanel.ChildrenCount == 1)
                {
                    layoutPanel.Orientation = Orientation.Horizontal;
                }
                if (layoutPanel == null || layoutPanel.Orientation != Orientation.Horizontal)
                {
                    if (layoutPanel == null)
                    {
                        throw new NotImplementedException();
                    }
                    LayoutPanel layoutPanel1 = new LayoutPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    LayoutPanel layoutPanel2 = layoutPanel;
                    if (layoutDocumentPaneGroup != null)
                    {
                        layoutElement = layoutDocumentPaneGroup;
                    }
                    else
                    {
                        layoutElement = model;
                    }
                    layoutPanel2.ReplaceChild(layoutElement, layoutPanel1);
                    ObservableCollection <ILayoutPanelElement> children = layoutPanel1.Children;
                    if (layoutDocumentPaneGroup != null)
                    {
                        layoutPanelElement = layoutDocumentPaneGroup;
                    }
                    else
                    {
                        layoutPanelElement = model;
                    }
                    children.Add(layoutPanelElement);
                    layoutPanel1.Children.Insert(0, floatingWindow.RootPanel);
                    break;
                }
                else
                {
                    ObservableCollection <ILayoutPanelElement> observableCollection = layoutPanel.Children;
                    LayoutPanel layoutPanel3 = layoutPanel;
                    if (layoutDocumentPaneGroup != null)
                    {
                        layoutElement1 = layoutDocumentPaneGroup;
                    }
                    else
                    {
                        layoutElement1 = model;
                    }
                    observableCollection.Insert(layoutPanel3.IndexOfChild(layoutElement1), floatingWindow.RootPanel);
                    break;
                }
            }

            case DropTargetType.DocumentPaneDockAsAnchorableTop:
            {
                if (layoutPanel != null && layoutPanel.ChildrenCount == 1)
                {
                    layoutPanel.Orientation = Orientation.Vertical;
                }
                if (layoutPanel == null || layoutPanel.Orientation != Orientation.Vertical)
                {
                    if (layoutPanel == null)
                    {
                        throw new NotImplementedException();
                    }
                    LayoutPanel layoutPanel4 = new LayoutPanel()
                    {
                        Orientation = Orientation.Vertical
                    };
                    LayoutPanel layoutPanel5 = layoutPanel;
                    if (layoutDocumentPaneGroup != null)
                    {
                        layoutElement2 = layoutDocumentPaneGroup;
                    }
                    else
                    {
                        layoutElement2 = model;
                    }
                    layoutPanel5.ReplaceChild(layoutElement2, layoutPanel4);
                    ObservableCollection <ILayoutPanelElement> children1 = layoutPanel4.Children;
                    if (layoutDocumentPaneGroup != null)
                    {
                        layoutPanelElement1 = layoutDocumentPaneGroup;
                    }
                    else
                    {
                        layoutPanelElement1 = model;
                    }
                    children1.Add(layoutPanelElement1);
                    layoutPanel4.Children.Insert(0, floatingWindow.RootPanel);
                    break;
                }
                else
                {
                    ObservableCollection <ILayoutPanelElement> observableCollection1 = layoutPanel.Children;
                    LayoutPanel layoutPanel6 = layoutPanel;
                    if (layoutDocumentPaneGroup != null)
                    {
                        layoutElement3 = layoutDocumentPaneGroup;
                    }
                    else
                    {
                        layoutElement3 = model;
                    }
                    observableCollection1.Insert(layoutPanel6.IndexOfChild(layoutElement3), floatingWindow.RootPanel);
                    break;
                }
            }

            case DropTargetType.DocumentPaneDockAsAnchorableRight:
            {
                if (layoutPanel != null && layoutPanel.ChildrenCount == 1)
                {
                    layoutPanel.Orientation = Orientation.Horizontal;
                }
                if (layoutPanel == null || layoutPanel.Orientation != Orientation.Horizontal)
                {
                    if (layoutPanel == null)
                    {
                        throw new NotImplementedException();
                    }
                    LayoutPanel layoutPanel7 = new LayoutPanel()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    LayoutPanel layoutPanel8 = layoutPanel;
                    if (layoutDocumentPaneGroup != null)
                    {
                        layoutElement4 = layoutDocumentPaneGroup;
                    }
                    else
                    {
                        layoutElement4 = model;
                    }
                    layoutPanel8.ReplaceChild(layoutElement4, layoutPanel7);
                    ObservableCollection <ILayoutPanelElement> children2 = layoutPanel7.Children;
                    if (layoutDocumentPaneGroup != null)
                    {
                        layoutPanelElement2 = layoutDocumentPaneGroup;
                    }
                    else
                    {
                        layoutPanelElement2 = model;
                    }
                    children2.Add(layoutPanelElement2);
                    layoutPanel7.Children.Add(floatingWindow.RootPanel);
                    break;
                }
                else
                {
                    ObservableCollection <ILayoutPanelElement> observableCollection2 = layoutPanel.Children;
                    LayoutPanel layoutPanel9 = layoutPanel;
                    if (layoutDocumentPaneGroup != null)
                    {
                        layoutElement5 = layoutDocumentPaneGroup;
                    }
                    else
                    {
                        layoutElement5 = model;
                    }
                    observableCollection2.Insert(layoutPanel9.IndexOfChild(layoutElement5) + 1, floatingWindow.RootPanel);
                    break;
                }
            }

            case DropTargetType.DocumentPaneDockAsAnchorableBottom:
            {
                if (layoutPanel != null && layoutPanel.ChildrenCount == 1)
                {
                    layoutPanel.Orientation = Orientation.Vertical;
                }
                if (layoutPanel == null || layoutPanel.Orientation != Orientation.Vertical)
                {
                    if (layoutPanel == null)
                    {
                        throw new NotImplementedException();
                    }
                    LayoutPanel layoutPanel10 = new LayoutPanel()
                    {
                        Orientation = Orientation.Vertical
                    };
                    LayoutPanel layoutPanel11 = layoutPanel;
                    if (layoutDocumentPaneGroup != null)
                    {
                        layoutElement6 = layoutDocumentPaneGroup;
                    }
                    else
                    {
                        layoutElement6 = model;
                    }
                    layoutPanel11.ReplaceChild(layoutElement6, layoutPanel10);
                    ObservableCollection <ILayoutPanelElement> children3 = layoutPanel10.Children;
                    if (layoutDocumentPaneGroup != null)
                    {
                        layoutPanelElement3 = layoutDocumentPaneGroup;
                    }
                    else
                    {
                        layoutPanelElement3 = model;
                    }
                    children3.Add(layoutPanelElement3);
                    layoutPanel10.Children.Add(floatingWindow.RootPanel);
                    break;
                }
                else
                {
                    ObservableCollection <ILayoutPanelElement> observableCollection3 = layoutPanel.Children;
                    LayoutPanel layoutPanel12 = layoutPanel;
                    if (layoutDocumentPaneGroup != null)
                    {
                        layoutElement7 = layoutDocumentPaneGroup;
                    }
                    else
                    {
                        layoutElement7 = model;
                    }
                    observableCollection3.Insert(layoutPanel12.IndexOfChild(layoutElement7) + 1, floatingWindow.RootPanel);
                    break;
                }
            }
            }
            base.Drop(floatingWindow);
        }
        protected override void Drop(LayoutAnchorableFloatingWindow floatingWindow)
        {
            ILayoutDocumentPane     targetModel = _targetPane.Model as ILayoutDocumentPane;
            LayoutDocumentPaneGroup parentGroup;
            LayoutPanel             parentGroupPanel;

            FindParentLayoutDocumentPane(targetModel, out parentGroup, out parentGroupPanel);

            switch (Type)
            {
            case DropTargetType.DocumentPaneDockAsAnchorableBottom:
                #region DropTargetType.DocumentPaneDockAsAnchorableBottom
            {
                if (parentGroupPanel != null &&
                    parentGroupPanel.ChildrenCount == 1)
                {
                    parentGroupPanel.Orientation = System.Windows.Controls.Orientation.Vertical;
                }

                if (parentGroupPanel != null &&
                    parentGroupPanel.Orientation == System.Windows.Controls.Orientation.Vertical)
                {
                    parentGroupPanel.Children.Insert(
                        parentGroupPanel.IndexOfChild(parentGroup != null ? parentGroup : targetModel) + 1,
                        floatingWindow.RootPanel);
                }
                else if (parentGroupPanel != null)
                {
                    var newParentPanel = new LayoutPanel()
                    {
                        Orientation = System.Windows.Controls.Orientation.Vertical
                    };
                    parentGroupPanel.ReplaceChild(parentGroup != null ? parentGroup : targetModel, newParentPanel);
                    newParentPanel.Children.Add(parentGroup != null ? parentGroup : targetModel);
                    newParentPanel.Children.Add(floatingWindow.RootPanel);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockAsAnchorableTop:
                #region DropTargetType.DocumentPaneDockAsAnchorableTop
            {
                if (parentGroupPanel != null &&
                    parentGroupPanel.ChildrenCount == 1)
                {
                    parentGroupPanel.Orientation = System.Windows.Controls.Orientation.Vertical;
                }

                if (parentGroupPanel != null &&
                    parentGroupPanel.Orientation == System.Windows.Controls.Orientation.Vertical)
                {
                    parentGroupPanel.Children.Insert(
                        parentGroupPanel.IndexOfChild(parentGroup != null ? parentGroup : targetModel),
                        floatingWindow.RootPanel);
                }
                else if (parentGroupPanel != null)
                {
                    var newParentPanel = new LayoutPanel()
                    {
                        Orientation = System.Windows.Controls.Orientation.Vertical
                    };
                    parentGroupPanel.ReplaceChild(parentGroup != null ? parentGroup : targetModel, newParentPanel);
                    newParentPanel.Children.Add(parentGroup != null ? parentGroup : targetModel);
                    newParentPanel.Children.Insert(0, floatingWindow.RootPanel);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockAsAnchorableLeft:
                #region DropTargetType.DocumentPaneDockAsAnchorableLeft
            {
                if (parentGroupPanel != null &&
                    parentGroupPanel.ChildrenCount == 1)
                {
                    parentGroupPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                }

                if (parentGroupPanel != null &&
                    parentGroupPanel.Orientation == System.Windows.Controls.Orientation.Horizontal)
                {
                    parentGroupPanel.Children.Insert(
                        parentGroupPanel.IndexOfChild(parentGroup != null ? parentGroup : targetModel),
                        floatingWindow.RootPanel);
                }
                else if (parentGroupPanel != null)
                {
                    var newParentPanel = new LayoutPanel()
                    {
                        Orientation = System.Windows.Controls.Orientation.Horizontal
                    };
                    parentGroupPanel.ReplaceChild(parentGroup != null ? parentGroup : targetModel, newParentPanel);
                    newParentPanel.Children.Add(parentGroup != null ? parentGroup : targetModel);
                    newParentPanel.Children.Insert(0, floatingWindow.RootPanel);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            break;

                #endregion
            case DropTargetType.DocumentPaneDockAsAnchorableRight:
                #region DropTargetType.DocumentPaneDockAsAnchorableRight
            {
                if (parentGroupPanel != null &&
                    parentGroupPanel.ChildrenCount == 1)
                {
                    parentGroupPanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
                }

                if (parentGroupPanel != null &&
                    parentGroupPanel.Orientation == System.Windows.Controls.Orientation.Horizontal)
                {
                    parentGroupPanel.Children.Insert(
                        parentGroupPanel.IndexOfChild(parentGroup != null ? parentGroup : targetModel) + 1,
                        floatingWindow.RootPanel);
                }
                else if (parentGroupPanel != null)
                {
                    var newParentPanel = new LayoutPanel()
                    {
                        Orientation = System.Windows.Controls.Orientation.Horizontal
                    };
                    parentGroupPanel.ReplaceChild(parentGroup != null ? parentGroup : targetModel, newParentPanel);
                    newParentPanel.Children.Add(parentGroup != null ? parentGroup : targetModel);
                    newParentPanel.Children.Add(floatingWindow.RootPanel);
                }
                else
                {
                    throw new NotImplementedException();
                }
            }
            break;
                #endregion
            }

            base.Drop(floatingWindow);
        }
Exemplo n.º 20
0
        protected override void Drop(LayoutAnchorableFloatingWindow floatingWindow)
        {
            LayoutAnchorable[] array;
            int i;
            ILayoutDocumentPane model = this._targetPane.Model as ILayoutDocumentPane;

            switch (base.Type)
            {
            case DropTargetType.DocumentPaneDockLeft:
            {
                LayoutDocumentPaneGroup parent             = model.Parent as LayoutDocumentPaneGroup;
                LayoutDocumentPane      layoutDocumentPane = new LayoutDocumentPane();
                if (parent == null)
                {
                    ILayoutContainer        layoutContainer         = model.Parent;
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    layoutContainer.ReplaceChild(model, layoutDocumentPaneGroup);
                    layoutDocumentPaneGroup.Children.Add(layoutDocumentPane);
                    layoutDocumentPaneGroup.Children.Add(model as LayoutDocumentPane);
                }
                else if (!parent.Root.Manager.AllowMixedOrientation || parent.Orientation == Orientation.Horizontal)
                {
                    parent.Orientation = Orientation.Horizontal;
                    int num = parent.IndexOfChild(model);
                    parent.Children.Insert(num, layoutDocumentPane);
                }
                else
                {
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup1 = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    parent.ReplaceChild(model, layoutDocumentPaneGroup1);
                    layoutDocumentPaneGroup1.Children.Add(layoutDocumentPane);
                    layoutDocumentPaneGroup1.Children.Add(model);
                }
                array = floatingWindow.RootPanel.Descendents().OfType <LayoutAnchorable>().ToArray <LayoutAnchorable>();
                for (i = 0; i < (int)array.Length; i++)
                {
                    LayoutAnchorable layoutAnchorable = array[i];
                    layoutDocumentPane.Children.Add(layoutAnchorable);
                }
                break;
            }

            case DropTargetType.DocumentPaneDockTop:
            {
                LayoutDocumentPaneGroup parent1             = model.Parent as LayoutDocumentPaneGroup;
                LayoutDocumentPane      layoutDocumentPane1 = new LayoutDocumentPane();
                if (parent1 == null)
                {
                    ILayoutContainer        layoutContainer1         = model.Parent;
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup2 = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Vertical
                    };
                    layoutContainer1.ReplaceChild(model, layoutDocumentPaneGroup2);
                    layoutDocumentPaneGroup2.Children.Add(layoutDocumentPane1);
                    layoutDocumentPaneGroup2.Children.Add(model as LayoutDocumentPane);
                }
                else if (!parent1.Root.Manager.AllowMixedOrientation || parent1.Orientation == Orientation.Vertical)
                {
                    parent1.Orientation = Orientation.Vertical;
                    int num1 = parent1.IndexOfChild(model);
                    parent1.Children.Insert(num1, layoutDocumentPane1);
                }
                else
                {
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup3 = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Vertical
                    };
                    parent1.ReplaceChild(model, layoutDocumentPaneGroup3);
                    layoutDocumentPaneGroup3.Children.Add(layoutDocumentPane1);
                    layoutDocumentPaneGroup3.Children.Add(model);
                }
                array = floatingWindow.RootPanel.Descendents().OfType <LayoutAnchorable>().ToArray <LayoutAnchorable>();
                for (i = 0; i < (int)array.Length; i++)
                {
                    LayoutAnchorable layoutAnchorable1 = array[i];
                    layoutDocumentPane1.Children.Add(layoutAnchorable1);
                }
                break;
            }

            case DropTargetType.DocumentPaneDockRight:
            {
                LayoutDocumentPaneGroup parent2             = model.Parent as LayoutDocumentPaneGroup;
                LayoutDocumentPane      layoutDocumentPane2 = new LayoutDocumentPane();
                if (parent2 == null)
                {
                    ILayoutContainer        layoutContainer2         = model.Parent;
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup4 = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    layoutContainer2.ReplaceChild(model, layoutDocumentPaneGroup4);
                    layoutDocumentPaneGroup4.Children.Add(model as LayoutDocumentPane);
                    layoutDocumentPaneGroup4.Children.Add(layoutDocumentPane2);
                }
                else if (!parent2.Root.Manager.AllowMixedOrientation || parent2.Orientation == Orientation.Horizontal)
                {
                    parent2.Orientation = Orientation.Horizontal;
                    int num2 = parent2.IndexOfChild(model);
                    parent2.Children.Insert(num2 + 1, layoutDocumentPane2);
                }
                else
                {
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup5 = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Horizontal
                    };
                    parent2.ReplaceChild(model, layoutDocumentPaneGroup5);
                    layoutDocumentPaneGroup5.Children.Add(model);
                    layoutDocumentPaneGroup5.Children.Add(layoutDocumentPane2);
                }
                array = floatingWindow.RootPanel.Descendents().OfType <LayoutAnchorable>().ToArray <LayoutAnchorable>();
                for (i = 0; i < (int)array.Length; i++)
                {
                    LayoutAnchorable layoutAnchorable2 = array[i];
                    layoutDocumentPane2.Children.Add(layoutAnchorable2);
                }
                break;
            }

            case DropTargetType.DocumentPaneDockBottom:
            {
                LayoutDocumentPaneGroup parent3             = model.Parent as LayoutDocumentPaneGroup;
                LayoutDocumentPane      layoutDocumentPane3 = new LayoutDocumentPane();
                if (parent3 == null)
                {
                    ILayoutContainer        layoutContainer3         = model.Parent;
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup6 = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Vertical
                    };
                    layoutContainer3.ReplaceChild(model, layoutDocumentPaneGroup6);
                    layoutDocumentPaneGroup6.Children.Add(model as LayoutDocumentPane);
                    layoutDocumentPaneGroup6.Children.Add(layoutDocumentPane3);
                }
                else if (!parent3.Root.Manager.AllowMixedOrientation || parent3.Orientation == Orientation.Vertical)
                {
                    parent3.Orientation = Orientation.Vertical;
                    int num3 = parent3.IndexOfChild(model);
                    parent3.Children.Insert(num3 + 1, layoutDocumentPane3);
                }
                else
                {
                    LayoutDocumentPaneGroup layoutDocumentPaneGroup7 = new LayoutDocumentPaneGroup()
                    {
                        Orientation = Orientation.Vertical
                    };
                    parent3.ReplaceChild(model, layoutDocumentPaneGroup7);
                    layoutDocumentPaneGroup7.Children.Add(model);
                    layoutDocumentPaneGroup7.Children.Add(layoutDocumentPane3);
                }
                array = floatingWindow.RootPanel.Descendents().OfType <LayoutAnchorable>().ToArray <LayoutAnchorable>();
                for (i = 0; i < (int)array.Length; i++)
                {
                    LayoutAnchorable layoutAnchorable3 = array[i];
                    layoutDocumentPane3.Children.Add(layoutAnchorable3);
                }
                break;
            }

            case DropTargetType.DocumentPaneDockInside:
            {
                LayoutDocumentPane        layoutDocumentPane4 = model as LayoutDocumentPane;
                LayoutAnchorablePaneGroup rootPanel           = floatingWindow.RootPanel;
                bool flag = true;
                int  previousContainerIndex = 0;
                if (this._tabIndex != -1)
                {
                    previousContainerIndex = this._tabIndex;
                    flag = false;
                }
                LayoutAnchorable layoutAnchorable4 = null;
                array = rootPanel.Descendents().OfType <LayoutAnchorable>().ToArray <LayoutAnchorable>();
                for (i = 0; i < (int)array.Length; i++)
                {
                    LayoutAnchorable layoutAnchorable5 = array[i];
                    if (flag)
                    {
                        if (((ILayoutPreviousContainer)layoutAnchorable5).PreviousContainer == model && layoutAnchorable5.PreviousContainerIndex != -1)
                        {
                            previousContainerIndex = layoutAnchorable5.PreviousContainerIndex;
                        }
                        flag = false;
                    }
                    layoutDocumentPane4.Children.Insert(previousContainerIndex, layoutAnchorable5);
                    previousContainerIndex++;
                    layoutAnchorable4 = layoutAnchorable5;
                }
                layoutAnchorable4.IsActive = true;
                break;
            }
            }
            base.Drop(floatingWindow);
        }