Esempio n. 1
0
        /// <summary>
        /// Move the scrollbars to the direction specified by the point specified.
        /// Method used by the Mouse multi selection (MouseSelection.cs).
        /// Scroll the grid only if the specified location is outside the visible area.
        /// </summary>
        /// <param name="mousePoint"></param>
        public void ScrollOnPoint(Point mousePoint)
        {
            //Scroll if necesary
            Rectangle scrollRect = m_Grid.GetScrollableArea();

            //[email protected] : In the below if condition, adding DragOffset value also
            // to resolve a defect (when grid is the control which fits into the entire area of screen
            // and the form which holds the grid is maximised, Autoscrolling to one or more sides is not possible)
            //This reduces the scrollable area and when inside the grid at that time also autoscrolling will be triggered.
            if (m_Grid.IsCustomAreaAutoScrollEnabled && !m_Grid.DragSizeRectangle.Contains(mousePoint))
            {
                scrollRect = new Rectangle(scrollRect.X + m_Grid.DragOffset,
                                           scrollRect.Y + m_Grid.DragOffset,
                                           scrollRect.Width - 2 * m_Grid.DragOffset,
                                           scrollRect.Height - 2 * m_Grid.DragOffset);
            }

            int?last = LastVisibleScrollableColumn;

            if (mousePoint.X > scrollRect.Right && (!last.HasValue ||
                                                    last.Value < m_Grid.Columns.Count - 1 || m_Grid.Columns.GetRight(last.Value) > scrollRect.Right))
            {
                CustomScrollLineRight();
            }
            last = LastVisibleScrollableRow;
            if (mousePoint.Y > scrollRect.Bottom && (!last.HasValue ||
                                                     last.Value < m_Grid.Rows.Count - 1 || m_Grid.Rows.GetBottom(last.Value) > scrollRect.Bottom))
            {
                CustomScrollLineDown();
            }
            if (mousePoint.X < scrollRect.Left)
            {
                m_Grid.CustomScrollLineLeft();
            }
            if (mousePoint.Y < scrollRect.Top)
            {
                m_Grid.CustomScrollLineUp();
            }
        }