예제 #1
0
        private int?GetSeriesIndexOnPosition(double position, int headerSize, SeriesSizes series, int firstVisible)
        {
            if (position <= headerSize)
            {
                return(null);
            }
            int frozenSize = series.FrozenSize;

            if (position <= headerSize + frozenSize)
            {
                return(series.GetFrozenIndexOnPosition((int)Math.Round(position - headerSize)));
            }
            return(series.GetScrollIndexOnPosition(
                       (int)Math.Round(position - headerSize - frozenSize) + series.GetPositionByScrollIndex(firstVisible)
                       ) + series.FrozenCount);
        }
예제 #2
0
        public int?GetResizingColumn(Point pt)
        {
            if (pt.Y > HeaderHeight)
            {
                return(null);
            }

            int frozenWidth = FrozenWidth;

            if ((int)pt.X - HeaderWidth <= frozenWidth + ColumnResizeTheresold)
            {
                if ((int)pt.X - HeaderWidth >= frozenWidth - ColumnResizeTheresold && (int)pt.X - HeaderWidth <= FrozenWidth - ColumnResizeTheresold)
                {
                    return(_columnSizes.FrozenCount - 1);
                }
                int index = _columnSizes.GetFrozenIndexOnPosition((int)pt.X - HeaderWidth);
                int begin = _columnSizes.GetPositionByRealIndex(index) + HeaderWidth;
                int end   = begin + _columnSizes.GetSizeByRealIndex(index);
                if (pt.X >= begin - ColumnResizeTheresold && pt.X <= begin + ColumnResizeTheresold)
                {
                    return(index - 1);
                }
                if (pt.X >= end - ColumnResizeTheresold && pt.X <= end + ColumnResizeTheresold)
                {
                    return(index);
                }
            }
            else
            {
                int scrollXStart = _columnSizes.GetPositionByScrollIndex(FirstVisibleColumnScrollIndex);
                int index        = _columnSizes.GetScrollIndexOnPosition((int)pt.X - HeaderWidth - frozenWidth + scrollXStart);
                int begin        = _columnSizes.GetPositionByScrollIndex(index) + HeaderWidth + frozenWidth - scrollXStart;
                int end          = begin + _columnSizes.GetSizeByScrollIndex(index);
                if (pt.X >= begin - ColumnResizeTheresold && pt.X <= begin + ColumnResizeTheresold)
                {
                    return(index - 1 + _columnSizes.FrozenCount);
                }
                if (pt.X >= end - ColumnResizeTheresold && pt.X <= end + ColumnResizeTheresold)
                {
                    return(index + _columnSizes.FrozenCount);
                }
            }
            return(null);
        }