ComponentFactory.Krypton.Docking.DragTargetControlEdge.PerformDrop C# (CSharp) Method

PerformDrop() public method

Perform the drop action associated with the target.
public PerformDrop ( Point screenPt, PageDragEndData data ) : bool
screenPt Point Position in screen coordinates.
data ComponentFactory.Krypton.Navigator.PageDragEndData Data to pass to the target to process drop.
return bool
        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;
        }