private void TraceCurrentMousePoint(MouseEventArgs e) { var currentPoint = LayerContainer.GetMousePosition(true); // 防止 currentPoint 不让其超出控件 renderSize 范围 var x = Math.Max(currentPoint.X, 0); var y = Math.Max(currentPoint.Y, 0); var startAutoScrollTimer = false; if (_autoScrollTimer == null || !_autoScrollTimer.IsEnabled) { startAutoScrollTimer = AutoScroll(); } if (startAutoScrollTimer) { _autoScrollTimer = new DispatcherTimer { Interval = TimeSpan.FromSeconds(0.3) }; _autoScrollTimer.Tick += delegate { if (e.LeftButton == MouseButtonState.Pressed && AutoScroll()) { SetCurrentMousePoint(e); MeasureDragingArea(_screenDataRowIndex); return; } LayerContainer.ReleaseMouseCapture(); _autoScrollTimer.Stop(); }; _autoScrollTimer.Start(); } _currentPoint = new Point(x, y); }
protected override void OnParentMouseUp(object sender, MouseButtonEventArgs e) { if (_isMouseMove || IsDraging) { //do nothing } //else if (ClickCount < 2) // don't remove 这会影响EditControlLayer double click 编辑弹出框 //{ SetCurrentMousePoint(e); if (LayerContainer.HeaderIsHitted()) // Column 全選 IsHeader(e.Source) { _screenDataRowIndex = 0; _startPoint = new Point(LayerContainer.GetMousePosition(true).X, 0); _currentPoint = new Point(_startPoint.X, GetItemsSourceCount() * Interval); SetInitalDrawLocation(); } MeasureDragingArea(_screenDataRowIndex); e.Handled = true; InvalidateVisual(); //} IsDraging = false; _isMouseMove = false; //xe.Handled = !AxisYConverter.IsInViewRagne(_currentPoint.Y); OnRangeSelected(); }
protected override void OnParentMouseDown(object sender, MouseButtonEventArgs e) { if (e.Source.IsNot <Rectangle>() && e.Source.IsNot <BlockGrid>()) { return; } _screenDataRowIndex = AxisPanel.GetScreenTopRowIndex(); if (Keyboard.Modifiers == ModifierKeys.Shift && _startPoint != _unsetPoint && _currentPoint != _unsetPoint) { //只有一个选中 //if (_startPoint == _currentPoint) //{ _currentPoint = LayerContainer.GetMousePosition(true); //} //else //已经选中多个 //{ //_startPoint = _currentPoint; //} } else { _startPoint = LayerContainer.GetMousePosition(true); _currentPoint = _startPoint; } //ClickCount = e.ClickCount; SetInitalDrawLocation(); }
private void SetCurrentMousePoint(MouseEventArgs e) { var currentPoint = LayerContainer.GetMousePosition(true); // 防止 currentPoint 不让其超出控件 renderSize 范围 var x = Math.Max(currentPoint.X, 0); var y = Math.Max(currentPoint.Y, 0); // 控制当mouse在边界外禁止响应x,y轴座标 if (currentPoint.X <= 0 || AxisPanel.ViewportRangeX.ViewMax < currentPoint.X) { y = _currentPoint.Y; } if (currentPoint.Y <= 0 || AxisPanel.ViewportRangeY.ViewMax < currentPoint.Y) { x = _currentPoint.X; } _currentPoint = new Point(x, y); }