//-/////////////////////////////////////////////////////////////////////// //-/////////////////////////////////////////////////////////////////////// private void text(V2 pos, string text) { if (_graphics == null) { return; } Matrix oldTransform = _graphics.Transform; _graphics.Transform = identityMatrix; V2 screenPos = Misc.TransformPoint(oldTransform, pos); _graphics.DrawString(text, SystemFonts.DefaultFont, _drawBrush, screenPos.AsPointF()); _graphics.Transform = oldTransform; }
//-/////////////////////////////////////////////////////////////////////// //-/////////////////////////////////////////////////////////////////////// private void HandleMouseMove(object sender, MouseEventArgs e) { //_mouseState = new MouseState(e.Location, GetScenePosForLocation(e.Location), e.Button); switch (_dragState) { case DragState.None: { switch (e.Button) { case MouseButtons.None: { V2 scenePos = GetScenePosForLocation(e.Location); foreach (Handle handle in _handles) { handle.HandleMouseEvent(sender, e, scenePos); } } break; case MouseButtons.Left: { V2 scenePos = GetScenePosForLocation(e.Location); foreach (Handle handle in _handles) { if (handle.HandleMouseEvent(sender, e, scenePos)) { _dragState = DragState.Handle; _dragHandle = handle; break; } } } break; case MouseButtons.Middle: { _dragControlPos = e.Location; _dragScenePos = GetScenePosForLocation(e.Location); if ((Control.ModifierKeys & Keys.Alt) != 0) { _dragState = DragState.Translate; } else if ((Control.ModifierKeys & Keys.Control) != 0) { _dragState = DragState.Rotate; } } break; } } break; case DragState.Rotate: { if ((e.Button & MouseButtons.Middle) != 0) { float theta = (float)((e.Location.X - _dragControlPos.X) / 10.0 * Math.PI); _matrix.RotateAt(theta, _dragScenePos.AsPointF()); _dragControlPos = e.Location; Invalidate(); } else { _dragState = DragState.None; } } break; case DragState.Translate: { if ((e.Button & MouseButtons.Middle) != 0) { _matrix.Translate(e.Location.X - _dragControlPos.X, e.Location.Y - _dragControlPos.Y, MatrixOrder.Append); _dragControlPos = e.Location; Invalidate(); } else { _dragState = DragState.None; } } break; case DragState.Handle: { _dragHandle.HandleMouseEvent(sender, e, GetScenePosForLocation(e.Location)); if ((e.Button & MouseButtons.Left) == 0) { _dragHandle = null; _dragState = DragState.None; } } break; } }