コード例 #1
0
        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);
        }