Details of an event that is fired just before a page is reordered.
Inheritance: CancelEventArgs
        private void OnCheckButtonDragOffset(object sender, ButtonDragOffsetEventArgs e)
        {
            // Cast incoming reference to the actual button view
            INavCheckItem reorderItem = (INavCheckItem)sender;
            ViewBase reorderView = reorderItem.View;

            // Scan the collection of children
            bool foundReorderView = false;
            VisualOrientation orientation = ConvertButtonBorderBackOrientation();
            foreach (KryptonPage page in Navigator.Pages)
            {
                // If the mouse is over this button
                ViewBase childView = (ViewBase)_pageLookup[page];
                if (childView.ClientRectangle.Contains(e.PointOffset))
                {
                    // Only interested if mouse over a different check button
                    if (childView != reorderView)
                    {
                        Rectangle childRect = childView.ClientRectangle;

                        if (foundReorderView)
                        {
                            if ((orientation == VisualOrientation.Left) || (orientation == VisualOrientation.Right))
                            {
                                int shrink = childRect.Height - Math.Min(childRect.Height, reorderView.ClientHeight);
                                childRect.Y += shrink;
                                childRect.Height -= shrink;
                            }
                            else
                            {
                                int shrink = childRect.Width - Math.Min(childRect.Width, reorderView.ClientWidth);
                                childRect.X += shrink;
                                childRect.Width -= shrink;
                            }

                            // Ensure that when we are placed in the 'after' position the mouse is still over
                            // ourself as the moved button. Otherwise we just end up toggling back and forth.
                            if (childRect.Contains(e.PointOffset))
                            {
                                KryptonPage movePage = PageFromView(reorderView);
                                KryptonPage targetPage = PageFromView(childView);
                                PageReorderEventArgs reorder = new PageReorderEventArgs(movePage, targetPage, false);

                                // Give event handlers a chance to cancel this reorder
                                Navigator.OnBeforePageReorder(reorder);
                                if (!reorder.Cancel)
                                {
                                    Navigator.Pages.MoveAfter(movePage, targetPage);
                                    RecreateView();
                                    Navigator.PerformLayout();
                                    Navigator.Refresh();
                                    Navigator.OnTabMoved(new TabMovedEventArgs(movePage, Navigator.Pages.IndexOf(movePage)));
                                }
                            }
                        }
                        else
                        {
                            if ((orientation == VisualOrientation.Left) || (orientation == VisualOrientation.Right))
                                childRect.Height = Math.Min(childRect.Height, reorderView.ClientHeight);
                            else
                                childRect.Width = Math.Min(childRect.Width, reorderView.ClientWidth);

                            // Ensure that when we are placed in the 'before' position the mouse is still over
                            // ourself as the moved button. Otherwise we just end up toggling back and forth.
                            if (childRect.Contains(e.PointOffset))
                            {
                                KryptonPage movePage = PageFromView(reorderView);
                                KryptonPage targetPage = PageFromView(childView);
                                PageReorderEventArgs reorder = new PageReorderEventArgs(movePage, targetPage, true);

                                // Give event handlers a chance to cancel this reorder
                                Navigator.OnBeforePageReorder(reorder);
                                if (!reorder.Cancel)
                                {
                                    Navigator.Pages.MoveBefore(movePage, PageFromView(childView));
                                    RecreateView();
                                    Navigator.PerformLayout();
                                    Navigator.Refresh();
                                    Navigator.OnTabMoved(new TabMovedEventArgs(movePage, Navigator.Pages.IndexOf(movePage)));
                                }
                            }
                        }

                        break;
                    }
                }

                foundReorderView = (childView == reorderView);
            }
        }
示例#2
0
        private void OnCheckButtonDragOffset(object sender, ButtonDragOffsetEventArgs e)
        {
            // Cast incoming reference to the actual check button view
            ViewDrawNavCheckButtonStack reorderView = (ViewDrawNavCheckButtonStack)sender;

            // Scan the collection of children
            bool        foundReorderView = false;
            Orientation stackOrient      = Navigator.Stack.StackOrientation;

            foreach (KryptonPage page in Navigator.Pages)
            {
                // If the mouse is over this button
                ViewDrawNavCheckButtonStack childView = (ViewDrawNavCheckButtonStack)_pageLookup[page];
                if (childView.ClientRectangle.Contains(e.PointOffset))
                {
                    // Only interested if mouse over a different check button
                    if (childView != reorderView)
                    {
                        Rectangle childRect = childView.ClientRectangle;

                        if (foundReorderView)
                        {
                            if (stackOrient == Orientation.Vertical)
                            {
                                int shrink = childRect.Height - Math.Min(childRect.Height, reorderView.ClientHeight);
                                childRect.Y      += shrink;
                                childRect.Height -= shrink;
                            }
                            else
                            {
                                int shrink = childRect.Width - Math.Min(childRect.Width, reorderView.ClientWidth);
                                childRect.X     += shrink;
                                childRect.Width -= shrink;
                            }

                            // Ensure that when we are placed in the 'after' position the mouse is still over
                            // ourself as the moved button. Otherwise we just end up toggling back and forth.
                            if (childRect.Contains(e.PointOffset))
                            {
                                KryptonPage          movePage   = PageFromView(reorderView);
                                KryptonPage          targetPage = PageFromView(childView);
                                PageReorderEventArgs reorder    = new PageReorderEventArgs(movePage, targetPage, false);

                                // Give event handlers a chance to cancel this reorder
                                Navigator.OnBeforePageReorder(reorder);
                                if (!reorder.Cancel)
                                {
                                    Navigator.Pages.MoveAfter(movePage, PageFromView(childView));
                                    RecreateView();
                                    Navigator.PerformLayout();
                                    Navigator.Refresh();
                                    Navigator.OnTabMoved(new TabMovedEventArgs(movePage, Navigator.Pages.IndexOf(movePage)));
                                }
                            }
                        }
                        else
                        {
                            if (stackOrient == Orientation.Vertical)
                            {
                                childRect.Height = Math.Min(childRect.Height, reorderView.ClientHeight);
                            }
                            else
                            {
                                childRect.Width = Math.Min(childRect.Width, reorderView.ClientWidth);
                            }

                            // Ensure that when we are placed in the 'before' position the mouse is still over
                            // ourself as the moved button. Otherwise we just end up toggling back and forth.
                            if (childRect.Contains(e.PointOffset))
                            {
                                KryptonPage          movePage   = PageFromView(reorderView);
                                KryptonPage          targetPage = PageFromView(childView);
                                PageReorderEventArgs reorder    = new PageReorderEventArgs(movePage, targetPage, true);

                                // Give event handlers a chance to cancel this reorder
                                Navigator.OnBeforePageReorder(reorder);
                                if (!reorder.Cancel)
                                {
                                    Navigator.Pages.MoveBefore(movePage, PageFromView(childView));
                                    RecreateView();
                                    Navigator.PerformLayout();
                                    Navigator.Refresh();
                                    Navigator.OnTabMoved(new TabMovedEventArgs(movePage, Navigator.Pages.IndexOf(movePage)));
                                }
                            }
                        }

                        break;
                    }
                }

                foundReorderView = (childView == reorderView);
            }
        }
示例#3
0
 /// <summary>
 /// Raises the BeforePageReorder event.
 /// </summary>
 /// <param name="de">A PageDragCancelEventArgs containing event details.</param>
 protected internal virtual void OnBeforePageReorder(PageReorderEventArgs de)
 {
     if (BeforePageReorder != null)
         BeforePageReorder(this, de);
 }