Example #1
0
        /// <summary>
        /// Occurs when a page is dropped on the control.
        /// </summary>
        /// <param name="sender">Source of the event.</param>
        /// <param name="e">A PageDropEventArgs containing the event data.</param>
        protected override void RaiseSpacePageDrop(object sender, PageDropEventArgs e)
        {
            // Use event to indicate the page is moving to a workspace and allow it to be cancelled
            KryptonDockingManager dockingManager = DockingManager;

            if (dockingManager != null)
            {
                CancelUniqueNameEventArgs args = new CancelUniqueNameEventArgs(e.Page.UniqueName, false);
                dockingManager.RaisePageWorkspaceRequest(args);

                // Pass back the result of the event
                e.Cancel = args.Cancel;
            }
        }
Example #2
0
        private void OnDockableNavigatorPageDrop(object sender, PageDropEventArgs e)
        {
            // Use event to indicate the page is moving to a navigator and allow it to be cancelled
            KryptonDockingManager dockingManager = DockingManager;

            if (dockingManager != null)
            {
                CancelUniqueNameEventArgs args = new CancelUniqueNameEventArgs(e.Page.UniqueName, false);
                dockingManager.RaisePageNavigatorRequest(args);

                // Pass back the result of the event
                e.Cancel = args.Cancel;
            }
        }
Example #3
0
        /// <summary>
        /// Perform the drop action associated with the target.
        /// </summary>
        /// <param name="screenPt">Position in screen coordinates.</param>
        /// <param name="data">Data to pass to the target to process drop.</param>
        /// <returns>Drop was performed and the source can perform any removal of pages as required.</returns>
        public override bool PerformDrop(Point screenPt, PageDragEndData data)
        {
            // Find our docking edge
            KryptonDockingEdge dockingEdge = null;

            switch (Edge)
            {
            case VisualOrientation.Left:
                dockingEdge = ControlElement["Left"] as KryptonDockingEdge;
                break;

            case VisualOrientation.Right:
                dockingEdge = ControlElement["Right"] as KryptonDockingEdge;
                break;

            case VisualOrientation.Top:
                dockingEdge = ControlElement["Top"] as KryptonDockingEdge;
                break;

            case VisualOrientation.Bottom:
                dockingEdge = ControlElement["Bottom"] as KryptonDockingEdge;
                break;
            }

            if (dockingEdge != null)
            {
                // Find the docked edge
                KryptonDockingEdgeDocked dockedEdge = dockingEdge["Docked"] as KryptonDockingEdgeDocked;
                if (dockingEdge != null)
                {
                    KryptonDockingManager manager = dockedEdge.DockingManager;
                    if (manager != null)
                    {
                        // Create a list of pages that are allowed to be transferred into the dockspace
                        List <KryptonPage> transferPages       = new List <KryptonPage>();
                        List <string>      transferUniqueNames = new List <string>();
                        foreach (KryptonPage page in data.Pages)
                        {
                            if (page.AreFlagsSet(KryptonPageFlags.DockingAllowDocked))
                            {
                                // Use event to indicate the page is becoming docked and allow it to be cancelled
                                CancelUniqueNameEventArgs args = new CancelUniqueNameEventArgs(page.UniqueName, false);
                                manager.RaisePageDockedRequest(args);

                                if (!args.Cancel)
                                {
                                    transferPages.Add(page);
                                    transferUniqueNames.Add(page.UniqueName);
                                }
                            }
                        }

                        // Transfer valid pages into the new dockspace
                        if (transferPages.Count > 0)
                        {
                            // Convert the incoming pages into store pages for restoring later
                            manager.PropogateAction(DockingPropogateAction.StorePages, transferUniqueNames.ToArray());

                            // Create a new dockspace at the start of the list so it is closest to the control edge
                            KryptonDockingDockspace dockspace = (_outsideEdge ? dockedEdge.InsertDockspace(0) : dockedEdge.AppendDockspace());

                            // Add pages into the target
                            dockspace.Append(transferPages.ToArray());

                            return(true);
                        }
                    }
                }
            }

            return(false);
        }