Details for an event that provides a button drag offset value.
Inheritance: System.EventArgs
Ejemplo n.º 1
0
 /// <summary>
 /// Raises the ButtonDragOffset event.
 /// </summary>
 /// <param name="e">An ButtonDragOffsetEventArgs containing the event args.</param>
 protected virtual void OnButtonDragOffset(ButtonDragOffsetEventArgs e)
 {
     if (ButtonDragOffset != null)
     {
         ButtonDragOffset(this, e);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Mouse has moved inside the view.
        /// </summary>
        /// <param name="c">Reference to the source control instance.</param>
        /// <param name="pt">Mouse position relative to control.</param>
        public virtual void MouseMove(Control c, Point pt)
        {
            // Is the controller allowed to track/click
            if (IsOperating)
            {
                // Track the mouse point
                _mousePoint = pt;

                // Update the visual state
                UpdateTargetState(pt);

                // If captured then we might want to handle dragging
                if (Captured)
                {
                    if (AllowDragging)
                    {
                        if (_dragging)
                        {
                            OnDragMove(_mousePoint);
                        }
                        else if (!_dragRect.IsEmpty && !_dragRect.Contains(_mousePoint))
                        {
                            if (!_draggingAttempt)
                            {
                                _draggingAttempt = true;
                                Point targetOrigin = _target.ClientLocation;
                                Point offset       = new Point(_mousePoint.X - targetOrigin.X, _mousePoint.Y - targetOrigin.Y);
                                OnDragStart(_mousePoint, offset, c);
                            }
                        }
                    }

                    if (!_dragging && !_dragRect.IsEmpty && _preDragOffset)
                    {
                        ButtonDragOffsetEventArgs args = new ButtonDragOffsetEventArgs(pt);
                        OnButtonDragOffset(args);
                    }
                }
            }
        }
        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);
            }
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Raises the ButtonDragOffset event.
 /// </summary>
 /// <param name="e">An ButtonDragOffsetEventArgs containing the event args.</param>
 protected virtual void OnButtonDragOffset(ButtonDragOffsetEventArgs e)
 {
     ButtonDragOffset?.Invoke(this, e);
 }
 private void OnButtonDragOffset(object sender, ButtonDragOffsetEventArgs e)
 {
     if (ButtonDragOffset != null)
         ButtonDragOffset(this, e);
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Raises the ButtonDragOffset event.
 /// </summary>
 /// <param name="e">An ButtonDragOffsetEventArgs containing the event args.</param>
 protected virtual void OnButtonDragOffset(ButtonDragOffsetEventArgs e)
 {
     if (ButtonDragOffset != null)
         ButtonDragOffset(this, e);
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Mouse has moved inside the view.
        /// </summary>
        /// <param name="c">Reference to the source control instance.</param>
        /// <param name="pt">Mouse position relative to control.</param>
        public virtual void MouseMove(Control c, Point pt)
        {
            // Is the controller allowed to track/click
            if (IsOperating)
            {
                // Track the mouse point
                _mousePoint = pt;

                // Update the visual state
                UpdateTargetState(pt);

                // If captured then we might want to handle dragging
                if (Captured)
                {
                    if (AllowDragging)
                    {
                        if (_dragging)
                            OnDragMove(_mousePoint);
                        else if (!_dragRect.IsEmpty && !_dragRect.Contains(_mousePoint))
                        {
                            if (!_draggingAttempt)
                            {
                                _draggingAttempt = true;
                                Point targetOrigin = _target.ClientLocation;
                                Point offset = new Point(_mousePoint.X - targetOrigin.X, _mousePoint.Y - targetOrigin.Y);
                                OnDragStart(_mousePoint, offset, c);
                            }
                        }
                    }

                    if (!_dragging && !_dragRect.IsEmpty && _preDragOffset)
                    {
                        ButtonDragOffsetEventArgs args = new ButtonDragOffsetEventArgs(pt);
                        OnButtonDragOffset(args);
                    }
                }
            }
        }