// Invoked when the mouse moves over the second viewport private void xnaControl_MouseMove(object sender, HwndMouseEventArgs e) { }
private void xnaControl_HwndRButtonUp(object sender, HwndMouseEventArgs e) { if (CameraManager.Instance.CurrentCamera != null) { EditorCamera cam = CameraManager.Instance.GetCurrentCamera() as EditorCamera; if (cam != null) { cam.Active = false; MouseDevice.Instance.ResetMouseAfterUpdate = false; NativeMethods.ShowCursor(true); } } }
private void xnaControl_HwndRButtonDown(object sender, HwndMouseEventArgs e) { if (SelectedObject != null) { // set actor to isn't picked. if (SelectedObject is Actor) { if (((Actor)SelectedObject).Properties.ContainsKey(ActorPropertyType.PICKABLE)) ((PickableProperty)((Actor)SelectedObject).Properties[ActorPropertyType.PICKABLE]).IsPicked = true; } propertyGrid.SelectedObject = null; shaderPropertyGrid.SelectedObject = null; SelectedObject = null; } if (CameraManager.Instance.CurrentCamera != null) { EditorCamera cam = CameraManager.Instance.GetCurrentCamera() as EditorCamera; if (cam != null) { cam.Active = true; MouseDevice.Instance.ResetMouseAfterUpdate = true; NativeMethods.ShowCursor(false); } } }
private void xnaControl_HwndLButtonUp(object sender, HwndMouseEventArgs e) { // xnaControl.ReleaseMouseCapture(); }
// We use the left mouse button to do exclusive capture of the mouse so we can drag and drag // to rotate the cube without ever leaving the control private void xnaControl_HwndLButtonDown(object sender, HwndMouseEventArgs e) { float x = (float)e.Position.X; float y = (float)e.Position.Y; Output.AddToOutput("Mouse Position: " + e.Position.ToString()); Output.AddToOutput("Mouse Position different: X: " + Mouse.GetState().X + " Y: " + Mouse.GetState().Y); //xnaControl.CaptureMouse(); /* if (CameraManager.Instance.CurrentCamera != null) { if (SelectedObject == null) { foreach (Actor actor in WorldManager.Instance.GetActors().Values) { if (actor.Properties.ContainsKey(ActorPropertyType.PICKABLE)) { Camera cam = CameraManager.Instance.GetCurrentCamera(); float x = (float)e.Position.X; float y = (float)e.Position.Y; //new Vector2(x, y) if (cam.GetMouseRay(new Vector2(x, y)).Intersects(Utils.TransformBoundingSphere(actor.BoundingSphere, actor.AbsoluteTransform)) != null) { Output.AddToOutput("Object : " + actor.ID + " has been picked!"); if (actor is MeshObject) { propertyGrid.SelectedObject = (MeshObject)actor; shaderPropertyGrid.Enabled = true; shaderPropertyGrid.SelectedObject = ((MeshObject)actor).Material; } else { propertyGrid.SelectedObject = actor; } SelectedObject = actor; ((PickableProperty)actor.Properties[ActorPropertyType.PICKABLE]).IsPicked = true; } else { Output.AddToOutput("ray didn't hit any object"); } } } } }*/ }
public void ResetMouseState() { // We need to invoke events for any buttons that were pressed bool fireL = mouseState.LeftButton == MouseButtonState.Pressed; bool fireM = mouseState.MiddleButton == MouseButtonState.Pressed; bool fireR = mouseState.RightButton == MouseButtonState.Pressed; bool fireX1 = mouseState.X1Button == MouseButtonState.Pressed; bool fireX2 = mouseState.X2Button == MouseButtonState.Pressed; // Update the state of all of the buttons mouseState.LeftButton = MouseButtonState.Released; mouseState.MiddleButton = MouseButtonState.Released; mouseState.RightButton = MouseButtonState.Released; mouseState.X1Button = MouseButtonState.Released; mouseState.X2Button = MouseButtonState.Released; // Fire any events HwndMouseEventArgs args = new HwndMouseEventArgs(mouseState); if (fireL && HwndLButtonUp != null) HwndLButtonUp(this, args); if (fireM && HwndMButtonUp != null) HwndMButtonUp(this, args); if (fireR && HwndRButtonUp != null) HwndRButtonUp(this, args); if (fireX1 && HwndX1ButtonUp != null) HwndX1ButtonUp(this, args); if (fireX2 && HwndX2ButtonUp != null) HwndX2ButtonUp(this, args); // The mouse is no longer considered to be in our window mouseInWindow = false; }