Пример #1
0
        public bool AppliesOnMouseDown(MouseEventArgs e, DataGridView.HitTestInfo hit)
        {
            if (!ShouldChangeCursor(hit, _tableState, e.X))
            {
                return(false);
            }

            bool leftedge = (e.X - hit.ColumnX) < (_tableState.ColumnWidth / 2);

            if (leftedge && hit.ColumnIndex == _tableState.GetFirstVisibleDataColumnIndex())
            {
                return(false);
            }

            _operationStarted = false;
            _orgMouseX        = Cursor.Position.X;
            _orgeX            = e.X;
            _orgWidth         = _tableState.ColumnWidth;
            _orgScroll        = _tableState.GetCurrentScroll();
            _orgNColumns      = _tableState.CountVisibleDataColumns(hit.ColumnIndex, !leftedge);
            _orgSColumns      = _orgScroll / _orgWidth;
            _orgSPixels       = _orgScroll % _orgWidth;
            _lefthalf         = _tableState.GetNormalizedXCoordinate(e.X) < 0.5;


            return(true);
        }
Пример #2
0
        public static bool ShouldChangeCursor(DataGridView.HitTestInfo hit, TableState state, int x)
        {
            if (state.ScalingMode == ScalingMode.ResizeQuad)
            {
                float f = state.GetNormalizedXCoordinate(x);

                if (!((f > 0 && f < 0.25) || (f > 0.75 && f < 1)))
                {
                    return(false);
                }

                if (hit.Type != DataGridViewHitTestType.ColumnHeader && hit.Type != DataGridViewHitTestType.Cell)
                {
                    return(false);
                }
            }
            else if (state.ScalingMode == ScalingMode.ResizeHalf)
            {
                if (hit.Type != DataGridViewHitTestType.ColumnHeader)
                {
                    return(false);
                }

                float f = state.GetNormalizedXCoordinate(x);
                if (!(f > 0 && f < 1))
                {
                    return(false);
                }
            }
            else
            {
                if (hit.Type != DataGridViewHitTestType.ColumnHeader)
                {
                    return(false);
                }
                if (Math.Abs(x - hit.ColumnX) > _maxDistanceFromDivider && Math.Abs(x - hit.ColumnX - state.ColumnWidth) > _maxDistanceFromDivider)
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #3
0
        public bool AppliesOnMouseDown(MouseEventArgs e, DataGridView.HitTestInfo hit)
        {
            if (e.Button != MouseButtons.Left)
            {
                return(false);
            }
            if (_state.ScalingMode == ScalingMode.ResizeQuad)
            {
                float f = _state.GetNormalizedXCoordinate(e.X);
                if (f <= 0.25 || f >= 0.75)
                {
                    return(false);
                }
            }
            else if (_state.ScalingMode == ScalingMode.ResizeHalf)
            {
                if (hit.Type != DataGridViewHitTestType.Cell)
                {
                    return(false);
                }
            }
            else
            {
                if (hit.RowIndex == -1)
                {
                    return(false);
                }
                if (hit.ColumnIndex < VisualizerTable.DataColumnOffset && hit.ColumnIndex != VisualizerTable.PhantomColumnIndex)
                {
                    return(false);
                }
            }

            _lastX            = Cursor.Position.X;
            _thresholdReached = false;
            return(true);
        }