Esempio n. 1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TickDragScroll(object sender, EventArgs e)
        {
            bool isDone = true;

            if (this.IsLoaded)
            {
                Rect  bounds = new Rect(RenderSize);
                Point p      = MouseUtilities.GetMousePosition(this);
                if (bounds.Contains(p))
                {
                    int dir = 0;

                    if (p.X < DragMargin)
                    {
                        dir   |= (int)DragDirection.Left;
                        isDone = false;
                    }
                    else if (p.X > RenderSize.Width - DragMargin)
                    {
                        dir   |= (int)DragDirection.Right;
                        isDone = false;
                    }

                    if (p.Y < DragMargin)
                    {
                        dir   |= (int)DragDirection.Up;
                        isDone = false;
                    }
                    else if (p.Y > RenderSize.Height - DragMargin)
                    {
                        dir   |= (int)DragDirection.Down;
                        isDone = false;
                    }

                    if (dir != 0)
                    {
                        DragScroll(dir);
                    }
                }
            }

            if (isDone)
            {
                CancelDrag();
            }
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="e"></param>
        public void DoMouseDown()
        {
            Point p = MouseUtilities.GetMousePosition(this);

            if ((p.Y < DragMargin) || (p.Y > RenderSize.Height - DragMargin) ||
                (p.X < DragMargin) || (p.X > RenderSize.Width - DragMargin))
            {
                if (_dragScrollTimer == null)
                {
                    _dragVelocity             = DragInitialVelocity;
                    _dragScrollTimer          = new DispatcherTimer();
                    _dragScrollTimer.Tick    += TickDragScroll;
                    _dragScrollTimer.Interval = new TimeSpan(0, 0, 0, 0, (int)DragInterval);
                    _dragScrollTimer.Start();
                }
            }
        }