コード例 #1
0
        protected virtual void HandleEvent(MouseAction action)
        {
            //Trace.WriteLine("Route:HandleEvent:" + CurrentButtons.ToString());
            CurrentMousePosition = action.MouseEventArgs.GetPosition(canvas);
            // CurrentButtons = Control.MouseButtons;
            // Issue #39: Mouse Move event fires even for button press when mouse hasn't moved!
            IEnumerable <MouseRouter> routes = router.Where(r => (action.MouseEvent != MouseEvent.MouseMove && r.MouseEvent == action.MouseEvent) ||
                                                            ((action.MouseEvent == MouseEvent.MouseMove && r.MouseEvent == action.MouseEvent)));

            routes.ForEach(r =>
            {
                Trace.WriteLine("Route:Executing Route:" + r.RouteName.ToString() + "  " + CurrentMousePosition.ToString());
                r.Debug?.Invoke();

                // Test condition every time after executing a route handler, as the handler may change state for the next condition.
                if (r.Condition())
                {
                    Trace.WriteLine("Route:Executing Route:" + r.RouteName.ToString());
                    r.Action(action.MouseEventArgs);
                }
                else
                {
                    r.Else?.Invoke();
                }
            });
        }
コード例 #2
0
ファイル: InputManager.cs プロジェクト: rimij405/Asteroids
 /// <summary>
 /// Draw the debug information.
 /// </summary>
 /// <param name="shapeDrawer">Uses the shapedrawer to draw the debug string.</param>
 public static void DrawGUI(ShapeDrawer shapeDrawer)
 {
     if (initialized && Debug)
     {
         int h = (int)shapeDrawer.Font.MeasureString("A").Y;
         shapeDrawer.DrawString(10, 10, StateManager.DrawColor, "Mouse Position: " + CurrentMousePosition.ToString());
     }
 }