Details for an cancellable event that provides pages associated with a page dragging event.
Inheritance: CancelEventArgs
 /// <summary>
 /// Initialize a new instance of the CellDragCancelEventArgs class.
 /// </summary>
 /// <param name="e">Event to upgrade to this event.</param>
 /// <param name="cell">Workspace cell associated with pages.</param>
 public CellDragCancelEventArgs(PageDragCancelEventArgs e,
                                KryptonWorkspaceCell cell)
     : base(e.ScreenPoint, e.ElementOffset, e.Control, e.Pages)
 {
     _cell = cell;
 }
        private void PageDragStart(Point pt)
        {
            if (DragPageNotify != null)
            {
                // Create a page that will be dragged
                _dragPage = new KryptonPage();
                _dragPage.Text = _dragNode.Text;
                _dragPage.TextTitle = _dragNode.Text + " Title";
                _dragPage.TextDescription = _dragNode.Text + " Description";
                _dragPage.ImageSmall = ImageList.Images[int.Parse((string)_dragNode.Tag)];
                _dragPage.Tag = _dragNode.Tag;

                // Create a rich text box with some sample text inside
                KryptonRichTextBox rtb = new KryptonRichTextBox();
                rtb.Text = "This page (" + _dragPage.Text + ") contains a rich text box control as example content.";
                rtb.Dock = DockStyle.Fill;
                rtb.StateCommon.Border.Draw = InheritBool.False;

                // Add rich text box as the contents of the page
                _dragPage.Padding = new Padding(5);
                _dragPage.Controls.Add(rtb);

                // Give the notify interface a chance to reject the attempt to drag
                PageDragCancelEventArgs de = new PageDragCancelEventArgs(PointToScreen(pt), Point.Empty, this, new KryptonPage[] { _dragPage });
                DragPageNotify.PageDragStart(this, null, de);

                if (de.Cancel)
                {
                    // No longer need the temporary drag page
                    _dragPage.Dispose();
                    _dragPage = null;
                }
                else
                {
                    _dragging = true;
                    Capture = true;
                }
            }
        }
示例#3
0
        private void OnDockspaceBeforePageDrag(object sender, PageDragCancelEventArgs e)
        {
            // Validate the list of names to those that are still present in the dockspace
            List<KryptonPage> pages = new List<KryptonPage>();
            foreach (KryptonPage page in e.Pages)
                if (!(page is KryptonStorePage) && (DockspaceControl.CellForPage(page) != null))
                    pages.Add(page);

            // Only need to start docking dragging if we have some valid pages
            if (pages.Count != 0)
            {
                // Ask the docking manager for a IDragPageNotify implementation to handle the dragging operation
                KryptonDockingManager dockingManager = DockingManager;
                if (dockingManager != null)
                    dockingManager.DoDragDrop(e.ScreenPoint, e.ElementOffset, e.Control, e.Pages);
            }

            // Always take over docking
            e.Cancel = true;
        }
示例#4
0
 /// <summary>
 /// Raises the BeforePageDrag event.
 /// </summary>
 /// <param name="de">A PageDragCancelEventArgs containing event details.</param>
 protected virtual void OnBeforePageDrag(PageDragCancelEventArgs de)
 {
     if (BeforePageDrag != null)
         BeforePageDrag(this, de);
 }
示例#5
0
        internal void InternalDragStart(DragStartEventCancelArgs e, KryptonPage page)
        {
            if (DesignMode)
                e.Cancel = true;
            else
            {
                // Should not already be dragging, but if we are then ensure correct sequence of calls
                if (_pageDragging)
                {
                    _pageDragging = false;
                    if (DragPageNotify != null)
                        DragPageNotify.PageDragQuit(this);
                }

                // Create a list of the pages being dragged
                if (page != null)
                    _dragPages = new KryptonPage[] { page };
                else
                {
                    // Providing 'null' means we want all the pages
                    List<KryptonPage> list = new List<KryptonPage>();
                    foreach (KryptonPage p in Pages)
                        list.Add(p);

                    _dragPages = list.ToArray();
                }

                // Do any of the dragging pages have a flag set saying they can be dragged?
                bool allowPageDrag = false;
                foreach(KryptonPage p in _dragPages)
                    if (p.AreFlagsSet(KryptonPageFlags.AllowPageDrag))
                    {
                        allowPageDrag = true;
                        break;
                    }

                // Generate event allowing the DragPageNotify setting to be updated before the
                // actual drag processing occurs. You can even cancel the drag entirely.
                PageDragCancelEventArgs de = new PageDragCancelEventArgs(e.Point, e.Offset, e.Control, _dragPages);
                de.Cancel = (!AllowPageDrag || !allowPageDrag);
                OnBeforePageDrag(de);
                if (!de.Cancel)
                {
                    // Update with any changes made by the event
                    List<KryptonPage> list = new List<KryptonPage>();
                    foreach (KryptonPage p in de.Pages)
                        list.Add(p);
                    _dragPages = list.ToArray();

                    if (DragPageNotify != null)
                    {
                        // Give the notify interface a chance to reject the attempt to drag
                        DragPageNotify.PageDragStart(this, this, de);
                        _pageDragging = !de.Cancel;
                    }
                }

                e.Cancel = de.Cancel;
            }
        }
示例#6
0
 /// <summary>
 /// Occurs when a page drag is about to begin and allows it to be cancelled.
 /// </summary>
 /// <param name="sender">Source of the page drag; can be null.</param>
 /// <param name="navigator">Navigator instance associated with source; can be null.</param>
 /// <param name="e">Event arguments indicating list of pages being dragged.</param>
 public virtual void PageDragStart(object sender, KryptonNavigator navigator, PageDragCancelEventArgs e)
 {
     e.Cancel = !DragStart(e.ScreenPoint, new PageDragEndData(sender, navigator, e.Pages));
 }
        private void OnFloatspaceBeforePageDrag(object sender, PageDragCancelEventArgs e)
        {
            // Validate the list of names to those that are still present in the floatspace
            List<KryptonPage> pages = new List<KryptonPage>();
            foreach (KryptonPage page in e.Pages)
                if (!(page is KryptonStorePage) && (FloatspaceControl.CellForPage(page) != null))
                    pages.Add(page);

            // Only need to start docking dragging if we have some valid pages
            if (pages.Count != 0)
            {
                KryptonDockingManager dockingManager = DockingManager;
                if (dockingManager != null)
                {
                    // If there is just a single visible cell
                    if (FloatspaceControl.CellVisibleCount == 1)
                    {
                        // And that visible cell has all the pages being dragged
                        KryptonWorkspaceCell cell = FloatspaceControl.FirstVisibleCell();
                        if (cell.Pages.VisibleCount == pages.Count)
                        {
                            // Get the owning floating window element
                            KryptonDockingFloatingWindow window = GetParentType(typeof(KryptonDockingFloatingWindow)) as KryptonDockingFloatingWindow;
                            if (window != null)
                            {
                                // Drag the entire floating window
                                dockingManager.DoDragDrop(e.ScreenPoint, e.ElementOffset, e.Control, window);

                                // Always take over docking
                                e.Cancel = true;
                                return;
                            }
                        }
                    }

                    // Add a placeholder for the cell that contains the dragged page, so the cell is not removed during dragging
                    KryptonWorkspaceCell firstCell = FloatspaceControl.CellForPage(e.Pages[0]);
                    if (firstCell != null)
                        firstCell.Pages.Add(new KryptonStorePage("TemporaryPage", "Floating"));

                    // Ask the docking manager for a IDragPageNotify implementation to handle the dragging operation
                    dockingManager.DoDragDrop(e.ScreenPoint, e.ElementOffset, e.Control, e.Pages);
                }
            }

            // Always take over docking
            e.Cancel = true;
        }
 /// <summary>
 /// Occurs when a page drag is about to begin and allows it to be cancelled.
 /// </summary>
 /// <param name="sender">Source of the page drag; should never be null.</param>
 /// <param name="navigator">Navigator instance associated with source; can be null.</param>
 /// <param name="e">Event arguments indicating list of pages being dragged.</param>
 public void PageDragStart(object sender, KryptonNavigator navigator, PageDragCancelEventArgs e)
 {
     _workspace.InternalPageDragStart(sender, navigator, e);
 }