private Vector2 GetRatio(MouseEvent mouse) { float k = 0.01f; int dpx = mouse.MouseAfterMoveP.X - mouse.MouseDowendP.X; int dpy = mouse.MouseAfterMoveP.Y - mouse.MouseDowendP.Y; bool strongX = Math.Abs(dpx) > Math.Abs(dpy); float dx, dy; if (KeyBoardEvent.GetInstance().IsShift) { dx = strongX ? dpx * k : dpy * k; dy = dx; } else if (KeyBoardEvent.GetInstance().IsCtrl) { dx = strongX ? dpx * k : 0; dy = strongX ? 0 : dpy * k; } else { dx = dpx * k; dy = dpy * k; } return(new Vector2(1.0f + dx, 1.0f + dy)); }
private float GetAngle(MouseEvent mouse) { float k = 0.01f; int dpx = mouse.MouseAfterMoveP.X - mouse.MouseDowendP.X; int dpy = mouse.MouseAfterMoveP.Y - mouse.MouseDowendP.Y; double result = Math.Sign(dpx) * Math.Pow((dpx * dpx + dpy * dpy), 0.5) * k; if (KeyBoardEvent.GetInstance().IsShift) { result *= 0.1; } if (KeyBoardEvent.GetInstance().IsCtrl) { result = ((int)(result * 4 / Math.PI)) * Math.PI / 4; } return((float)result); }
public void GetDrivingMode(MyGame sender, MouseEventArgs e) { Mode ret; //if (e.Button == MouseButtons.Middle || e.Button == MouseButtons.Right) ret = CameraMove.GetInstance(); if (sender.form.TabControll.SelectedIndex == 1) { ret = Nothing.GetInstance(); } else if (sender.form.IsScaleState) { ret = Scale.GetInstance(); } else if (sender.form.IsRotateState) { ret = Rotate.GetInstance(); } else if (KeyBoardEvent.GetInstance().OnKeys[(int)Keys.ShiftKey]) { ret = Add.GetInstance(); } else if (KeyBoardEvent.GetInstance().OnKeys[(int)Keys.ControlKey]) { ret = Remove.GetInstance(); } else if (sender.vS.GetNearSelected(sender.mypmx, sender.Camera, e.Location, 4) != -1) { ret = Move.GetInstance(); } else if (sender.vS.GetNearUsed(sender.mypmx, sender.Camera, e.Location, 4) != -1) { sender.vS.selectedVertexIndex = new int[] { sender.vS.GetNearUsed(sender.mypmx, sender.Camera, e.Location, 4) }; ret = Move.GetInstance(); } else { ret = Select.GetInstance(); } sender.drivingMode = ret; }