private void Knob_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { _startPos = e.GetPosition(Base); _prevAileron = _prevElevator = 0; canvasWidth = Base.ActualWidth - KnobBase.ActualWidth; canvasHeight = Base.ActualHeight - KnobBase.ActualHeight; Captured?.Invoke(this); Knob.CaptureMouse(); centerKnob.Stop(); }
private void Knob_MouseDown(object sender, MouseButtonEventArgs e) { // Checks if the joystick was pressed. if (e.ChangedButton == MouseButton.Left) { // Update control point. startlPoint = e.GetPosition(this); Captured?.Invoke(this); Knob.CaptureMouse(); centerknob.Stop(); } }
// Define the action when the mouse is down. private void Joystick_MouseDown(object sender, MouseButtonEventArgs e) { if (!mousePressed) { mousePressed = true; Knob.CaptureMouse(); // Initilaze the begining point. startX = e.GetPosition(this).X; startY = e.GetPosition(this).Y; centerKnob.Stop(); } }
// This function update the appropriate variables when the MouseDown. private void Knob_MouseDown(object sender, MouseButtonEventArgs e) { // If left button was clicked. if (e.ChangedButton == MouseButton.Left) { startPoint.X = e.GetPosition(this).X; startPoint.Y = e.GetPosition(this).Y; canvasWidth = BlackCircle.ActualWidth - KnobBase.ActualWidth / 2; canvasHeight = BlackCircle.ActualHeight - KnobBase.ActualHeight / 2; // Make sure that the KnobBase does not leave the Knob. Knob.CaptureMouse(); centerKnob.Stop(); } }
private void Knob_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { Knob.CaptureMouse(); double x = e.GetPosition(this).X - startPoint.X; double y = e.GetPosition(this).Y - startPoint.Y; if (Math.Sqrt(x * x + y * y) < ((Base.Width / 2) - (KnobBase.Width / 2))) { knobPosition.X = x; knobPosition.Y = y; Normal(); } } }
private void Knob_MouseDown(object sender, MouseButtonEventArgs e) { //check that the mouse pressed if (!MousePressed) { if (e.ChangedButton == MouseButton.Left) { //get the position of the knob firstPoint.X = e.GetPosition(this).X; firstPoint.Y = e.GetPosition(this).Y; Knob.CaptureMouse(); MousePressed = true; } } }
private void Knob_MouseDown(object sender, MouseButtonEventArgs e) { Rudder = 0; Elevator = 0; if (e.LeftButton == MouseButtonState.Pressed) { mouseDown = true; startPosition = e.GetPosition(Base); centerKnob.Stop(); Knob.CaptureMouse(); width = Base.ActualWidth - KnobBase.ActualWidth; height = Base.ActualHeight - KnobBase.ActualHeight; } }
// Holds the logic for what to do when the mouse is being moved. private void Knob_MouseMove(object sender, MouseEventArgs e) { if (e.LeftButton == MouseButtonState.Pressed) { Knob.CaptureMouse(); // The postitions of the mouse. double newX = e.GetPosition(this).X - firstPoint.X; double newY = e.GetPosition(this).Y - firstPoint.Y; // Check to make sure that we don't allow the knob to go out of its border. if (Math.Sqrt(newX * newX + newY * newY) < (Base.Width / 2 - KnobBase.Width / 2) + 2) { knobPosition.X = newX; knobPosition.Y = newY; } // Normalize the values. Normalize(); } }
private void Knob_MouseDown(object sender, System.Windows.Input.MouseButtonEventArgs e) { isPressed = true; Knob.CaptureMouse(); }
// on click event private void Knob_Clicked(object sender, MouseButtonEventArgs e) { // save the coords of the mouse when the knob was clicked _InitPos = e.GetPosition(this); Knob.CaptureMouse(); }
private void Knob_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { clickPoint = e.GetPosition(Base); Knob.CaptureMouse(); centerKnob.Stop(); }