コード例 #1
0
ファイル: TrackBall.cs プロジェクト: charlierix/AsteroidMiner
        private void EventSource_MouseUp(object sender, MouseEventArgs e)
        {
            if (!_isActive)
            {
                return;
            }

            Mouse.Capture(_eventSource, CaptureMode.None);
            _orbitRadius = null;

            #region Detect Autoscroll

            if (_currentAutoscrollAction != null)
            {
                // Autoscroll is currently running.  See if it should be turned off
                if (GetAction(e) != _currentAutoscrollAction)
                {
                    _autoscroll.StopAutoScroll();
                    _currentAutoscrollAction = null;
                }
            }

            #endregion
        }
コード例 #2
0
ファイル: TrackBall.cs プロジェクト: charlierix/AsteroidMiner
        private void EventSource_MouseDown(object sender, MouseEventArgs e)
        {
            if (!_isActive)
            {
                return;
            }

            // By capturing the mouse, mouse events will still come in even when they are moving the mouse
            // outside the element/form
            Mouse.Capture(_eventSource, CaptureMode.SubTree);		// I had a case where I used the grid as the event source.  If they clicked one of the 3D objects, the scene would jerk.  But by saying subtree, I still get the event

            _previousPosition2D = e.GetPosition(_eventSource);
            _previousPosition3D = ProjectToTrackball(_eventSource.ActualWidth, _eventSource.ActualHeight, _previousPosition2D);

            #region Detect Autoscroll

            if (_currentAutoscrollAction == null)
            {
                CameraMovement? action = GetAction(e);
                if (action != null && IsAutoScroll(action.Value))
                {
                    _autoscroll.StartAutoScroll(_previousPosition2D, UtilityWPF.TransformToScreen(_previousPosition2D, _eventSource));
                    _currentAutoscrollAction = action;
                }
            }

            #endregion
        }