コード例 #1
0
ファイル: ColHeaderCell.cs プロジェクト: Daoting/dt
        void OnPointerMoved(object sender, PointerRoutedEventArgs e)
        {
            e.Handled = true;
            if (e.IsTouch())
            {
                // 触摸模式只支持列排序
                if (_pointerID == e.Pointer.PointerId)
                {
                    ReleasePointerCapture(e.Pointer);
                    _pointerID = null;
                }
                return;
            }

            // 鼠标未按下时的滑过
            if (!_isDragging && _resizingCol == null)
            {
                Point pt = e.GetCurrentPoint(this).Position;
                if (pt.X >= _resizePadding && Col.Width - pt.X >= _resizePadding)
                {
                    SetCursor(CoreCursorType.Arrow);
                    VisualStateManager.GoToState(this, "PointerOver", true);
                }
                else
                {
                    SetCursor(CoreCursorType.SizeWestEast);
                    VisualStateManager.GoToState(this, "Normal", true);
                }
                return;
            }

            // 调整列宽
            if (_resizingCol != null)
            {
                Point  cur   = e.GetCurrentPoint(null).Position;
                double width = _resizingCol.Width + cur.X - _ptLast.X;
                if (width > 35)
                {
                    // 最小宽度能显示一个字
                    _resizingCol.Width = width;
                    _owner.Lv.Cols.Invalidate();
                    _ptLast = cur;
                }
                return;
            }

            // 拖拽列
            _dragTgtCol = _owner.GetDragTargetCol(Col, e.GetCurrentPoint(_owner).Position.X);
        }