コード例 #1
0
        private void AddShape(MouseButtonState state, Point mousePos)
        {
            int vertices = shapeDeclaration.VerticesPosition.Count;

            if (vertices == 1)
            {
                shapeDeclaration.VerticesPosition.Add(shapeDeclaration.VerticesPosition[0] + Vector2.One);
            }
            if (vertices != 0)
            {
                Shapes.Add(
                    new FixedBoundsShape(
                        shapeDeclaration.VerticesPosition,
                        shapeDeclaration.ViewportOffset.X,
                        shapeDeclaration.ViewportOffset.Y,
                        (int)ActualWidth,
                        (int)ActualHeight,
                        Color.Black,
                        graphicsDevice));
                ShapeAdded?.Invoke(this, EventArgs.Empty);
            }
            trackShape = InitializeShape;
            processedShape.Reset();
            GraphicsControl.Invalidate();
        }
コード例 #2
0
        private void OnGraphicsControlMouseMove(object sender, MouseEventArgs e)
        {
            var position = e.GetPosition(this);
            var delta    = new Vector2((float)(position.X - _previousPosition.X), (float)(position.Y - _previousPosition.Y));

            // If the left or right buttons are down, we adjust the yaw and pitch of the cube
            if (e.LeftButton == MouseButtonState.Pressed)
            {
                _yaw   += delta.X * .01f;
                _pitch += delta.Y * .01f;
                GraphicsControl.Invalidate();
            }

            if (e.RightButton == MouseButtonState.Pressed)
            {
                _cameraYaw   += delta.X * CameraRotSpeed;
                _cameraPitch += delta.Y * CameraRotSpeed;
            }

            if (e.MiddleButton == MouseButtonState.Pressed)
            {
                _cameraPosition += _camera.Left * CameraPanSpeed * delta.X;
                _cameraPosition += _camera.Up * CameraPanSpeed * delta.Y;
            }

            if (_lockCursor)
            {
                var scrPos = GraphicsControl.PointToScreen(_previousPosition);
                SetCursorPos((int)scrPos.X, (int)scrPos.Y);
            }
            else
            {
                _previousPosition = position;
            }
        }
コード例 #3
0
 private void InitializeShape(MouseButtonState state, Point mousePos)
 {
     if (state == MouseButtonState.Pressed)
     {
         shapeDeclaration = new ShapeDeclaration(new Vector2(mousePos.X, mousePos.Y));
         processedShape.AddVertex(shapeDeclaration.ViewportOffset);
         processedShape.AddVertex(shapeDeclaration.ViewportOffset);
         trackShape = CaptureMousePosition;
         GraphicsControl.Invalidate();
     }
 }
コード例 #4
0
ファイル: SceneView.xaml.cs プロジェクト: zhangf911/gemini
        // Invoked when the mouse moves over the second viewport
        private void OnGraphicsControlMouseMove(object sender, MouseEventArgs e)
        {
            var position = e.GetPosition(this);

            // If the left or right buttons are down, we adjust the yaw and pitch of the cube
            if (e.LeftButton == MouseButtonState.Pressed ||
                e.RightButton == MouseButtonState.Pressed)
            {
                _yaw   += (float)(position.X - _previousPosition.X) * .01f;
                _pitch += (float)(position.Y - _previousPosition.Y) * .01f;
                GraphicsControl.Invalidate();
            }

            _previousPosition = position;
        }
コード例 #5
0
 private void CaptureMousePosition(MouseButtonState state, Point mousePos)
 {
     if (state == MouseButtonState.Pressed)
     {
         var mousePosition = new Vector2(mousePos.X, mousePos.Y);
         if (shapeDeclaration.Capture(mousePosition))
         {
             processedShape.AddVertex(mousePosition);
             GraphicsControl.Invalidate();
         }
     }
     else
     {
         trackShape = AddShape;
     }
 }
コード例 #6
0
 public void Invalidate()
 {
     GraphicsControl.Invalidate();
 }
コード例 #7
0
 private void ReDraw()
 {
     GraphicsControl?.Invalidate();
 }