示例#1
0
 public void MouseWheel(UserCommandArgs userCommandArgs, KeyModifiers modifiers)
 {
     if (userCommandArgs is ScrollCommandArgs mouseWheelCommandArgs)
     {
         contentArea?.UpdateScaleAt(mouseWheelCommandArgs.Position, Math.Sign(mouseWheelCommandArgs.Delta) * ZoomAmplifier(modifiers));
     }
 }
示例#2
0
 public void MouseDragging(UserCommandArgs userCommandArgs)
 {
     if (userCommandArgs is PointerMoveCommandArgs mouseMoveCommandArgs)
     {
         contentArea?.UpdatePosition(mouseMoveCommandArgs.Delta);
     }
 }
示例#3
0
 private void MousePressedEvent(UserCommandArgs userCommandArgs, KeyModifiers keyModifiers)
 {
     if (userCommandArgs is PointerCommandArgs pointerCommandArgs)
     {
         SuppressDrawing = false;
         Point mouseDownPosition = pointerCommandArgs.Position;
         mouseActiveWindow = windows.LastOrDefault(w => w.Interactive && w.Borders.Contains(pointerCommandArgs.Position));
         if (modalWindow != null && mouseActiveWindow != modalWindow)
         {
             userCommandArgs.Handled = true;
         }
         else if (mouseActiveWindow != null)
         {
             userCommandArgs.Handled = true;
             if (mouseActiveWindow != windows.Last())
             {
                 List <WindowBase> updatedWindowList = windows.ToList();
                 if (updatedWindowList.Remove(mouseActiveWindow))
                 {
                     updatedWindowList.Add(mouseActiveWindow);
                     windows = updatedWindowList;
                 }
             }
         }
     }
 }
 private protected override void DirectionHandleCommand(UserCommandArgs commandArgs, GameTime gameTime)
 {
     if (commandArgs is UserCommandArgs <float> handleCommandArgs)
     {
         SteamLocomotive.SetCutoffPercent(handleCommandArgs.Value);
     }
     base.DirectionHandleCommand(commandArgs, gameTime);
 }
示例#5
0
 private void WindowScrollEvent(UserCommandArgs userCommandArgs, KeyModifiers keyModifiers)
 {
     if (modalWindow != null && modalWindow != mouseActiveWindow)
     {
         SuppressDrawing         = false;
         userCommandArgs.Handled = true;
     }
 }
示例#6
0
 private void MouseReleasedEvent(UserCommandArgs userCommandArgs, KeyModifiers keyModifiers)
 {
     if (userCommandArgs is PointerCommandArgs pointerCommandArgs)
     {
         mouseActiveWindow = VisibleWindows.LastOrDefault(w => w.Interactive && w.Location.Contains(pointerCommandArgs.Position));
         mouseActiveWindow?.MouseReleased(pointerCommandArgs.Position, keyModifiers);
     }
     mouseActiveWindow = null;
 }
示例#7
0
 private void MouseDraggingEvent(UserCommandArgs userCommandArgs, KeyModifiers keyModifiers)
 {
     if (userCommandArgs is PointerMoveCommandArgs moveCommandArgs)
     {
         if (null == mouseActiveWindow)
         {
             mouseActiveWindow = VisibleWindows.LastOrDefault(w => w.Interactive && w.Location.Contains(moveCommandArgs.Position));
         }
         mouseActiveWindow?.MouseDrag(moveCommandArgs.Position, moveCommandArgs.Delta, keyModifiers);
     }
 }
示例#8
0
 private void WindowScrollEvent(UserCommandArgs userCommandArgs, KeyModifiers keyModifiers)
 {
     if (userCommandArgs is ScrollCommandArgs scrollCommandArgs)
     {
         mouseActiveWindow = VisibleWindows.LastOrDefault(w => w.Interactive && w.Location.Contains(scrollCommandArgs.Position));
         if (mouseActiveWindow != null)
         {
             mouseActiveWindow.MouseScroll(scrollCommandArgs.Position, scrollCommandArgs.Delta, keyModifiers);
         }
     }
 }
示例#9
0
        private void MouseClickedEvent(UserCommandArgs userCommandArgs, KeyModifiers keyModifiers)
        {
            if (userCommandArgs is PointerCommandArgs pointerCommandArgs)
            {
                mouseDownPosition = pointerCommandArgs.Position;
                mouseActiveWindow = VisibleWindows.LastOrDefault(w => w.Interactive && w.Location.Contains(pointerCommandArgs.Position));
                if ((mouseActiveWindow != null) && (mouseActiveWindow != WindowsZOrder.Last()))
                {
                    BringWindowToTop(mouseActiveWindow);
                }

                mouseActiveWindow?.MousePressed(pointerCommandArgs.Position, keyModifiers);
            }
        }
示例#10
0
 private void MouseReleasedEvent(UserCommandArgs userCommandArgs, KeyModifiers keyModifiers)
 {
     if (userCommandArgs is PointerCommandArgs pointerCommandArgs)
     {
         SuppressDrawing = false;
         if (modalWindow != null && mouseActiveWindow != modalWindow)
         {
             userCommandArgs.Handled = true;
         }
         else if (mouseActiveWindow != null)
         {
             userCommandArgs.Handled = true;
             mouseActiveWindow.HandleMouseReleased(pointerCommandArgs.Position, keyModifiers);
         }
     }
 }
示例#11
0
        private static int ZoomAmplifier(UserCommandArgs commandArgs)
        {
            int amplifier = 3;

            if (commandArgs is ModifiableKeyCommandArgs modifiableKeyCommand)
            {
                if ((modifiableKeyCommand.AdditionalModifiers & KeyModifiers.Control) == KeyModifiers.Control)
                {
                    amplifier = 1;
                }
                else if ((modifiableKeyCommand.AdditionalModifiers & KeyModifiers.Shift) == KeyModifiers.Shift)
                {
                    amplifier = 5;
                }
            }
            return(amplifier);
        }
示例#12
0
        private static float MovementAmplifier(UserCommandArgs commandArgs)
        {
            float amplifier = 5;

            if (commandArgs is ModifiableKeyCommandArgs modifiableKeyCommand)
            {
                if ((modifiableKeyCommand.AdditionalModifiers & KeyModifiers.Control) == KeyModifiers.Control)
                {
                    amplifier = 1;
                }
                else if ((modifiableKeyCommand.AdditionalModifiers & KeyModifiers.Shift) == KeyModifiers.Shift)
                {
                    amplifier = 10;
                }
            }
            return(amplifier);
        }
示例#13
0
 private void MouseDraggingEvent(UserCommandArgs userCommandArgs, KeyModifiers keyModifiers)
 {
     if (userCommandArgs is PointerMoveCommandArgs moveCommandArgs)
     {
         SuppressDrawing = false;
         if (modalWindow != null && modalWindow != mouseActiveWindow)
         {
             userCommandArgs.Handled = true;
         }
         else if (mouseActiveWindow != null)
         {
             userCommandArgs.Handled = true;
             mouseActiveWindow.HandleMouseDrag(moveCommandArgs.Position, moveCommandArgs.Delta, keyModifiers);
         }
         else if (windows.LastOrDefault(w => w.Interactive && w.Borders.Contains(moveCommandArgs.Position)) != null)
         {
             userCommandArgs.Handled = true;
         }
     }
 }
 private static int ZoomAmplifier(UserCommandArgs commandArgs)
 {
     return(commandArgs is ModifiableKeyCommandArgs modifiableKeyCommand?ZoomAmplifier(modifiableKeyCommand.AdditionalModifiers) : zoomAmplifier);
 }
示例#15
0
 private void ZoomIn(UserCommandArgs commandArgs)
 {
     Zoom(ZoomAmplifier(commandArgs));
 }
示例#16
0
 private void ZoomOut(UserCommandArgs commandArgs)
 {
     Zoom(-ZoomAmplifier(commandArgs));
 }
示例#17
0
 private void MoveByKeyDown(UserCommandArgs commandArgs)
 {
     contentArea?.UpdatePosition(moveDown * MovementAmplifier(commandArgs));
 }
示例#18
0
 private void MouseDownEvent(UserCommandArgs userCommandArgs, KeyModifiers keyModifiers)
 {
 }
 /// <summary>
 /// Raises the <see cref="ReceivedUserCommandResponse"/> event.
 /// </summary>
 /// <param name="command">The code for the user command.</param>
 /// <param name="response">The code for the server's response.</param>
 /// <param name="buffer">Buffer containing the message from the server.</param>
 /// <param name="startIndex">Index into the buffer used to skip the header.</param>
 /// <param name="length">The length of the message in the buffer, including the header.</param>
 protected void OnReceivedUserCommandResponse(ServerCommand command, ServerResponse response, byte[] buffer, int startIndex, int length)
 {
     try
     {
         UserCommandArgs args = new UserCommandArgs(command, response, buffer, startIndex, length);
         ReceivedUserCommandResponse?.Invoke(this, args);
     }
     catch (Exception ex)
     {
         // We protect our code from consumer thrown exceptions
         OnProcessException(MessageLevel.Info, new InvalidOperationException($"Exception in consumer handler for UserCommandResponse event: {ex.Message}", ex), "ConsumerEventException");
     }
 }