public EndRoadLaneEdge( Factories.Factories factories, MovablePoint startPoint, MovablePoint endPoint, RoadLaneBlock parent )
     : base( factories, startPoint, endPoint, Styles.NormalStyle, parent )
 {
     this._parrent = parent;
     this._notMovableMouseHandler = factories.MouseHandlerFactory.CreateEmpty();
     this.Connector = new EndRoadLaneEdgeConnector( this );
 }
Пример #2
0
        /// <summary>
        /// Can we set such a DefaultMouseHandler?
        /// Prevents endless recursive loops.
        /// </summary>
        /// <param name="nextHandler">Canditate to test</param>
        /// <returns>true, if setting DefaultMouseHandler to nextHandler causes no recursion.</returns>
        public bool NextHandlerValid(IMouseHandler nextHandler)
        {
            // setting to null is perfectly fine
            // (turning off the redirection)
            if (nextHandler == null)
            {
                return true;
            }

            // setting to itself would cause
            // an infinite recursion
            if (nextHandler == this)
            {
                return false;
            }

            IMouseHandler current = nextHandler;
            while (current != null)
            {
                current = current.DefaultMouseHandler;
                if (current == this)
                {
                    return false;
                }
            }

            return true;
        }
Пример #3
0
 public WindowsInputHandler(IAutoBot bot, IKeyboardHandler keyboard, IMouseHandler mouse, ICollection <IDevice> devices) :
     base(bot, keyboard, mouse, devices)
 {
 }
Пример #4
0
 private void rotateButton_Click(object sender, EventArgs e)
 {
     _mouseHandler = new RotateFigureMouseHandler();
 }
Пример #5
0
 public static void RemoveMouseListener(IMouseHandler Handler)
 {
     _MouseHandlers.Remove(Handler);
 }
        /// <summary>
        /// Updates all the little components of mouse controller.
        /// </summary>
        private void Update()
        {
            IMouseHandler handler              = mouseHandlers[(int)currentMode];
            Vector3       mousePos             = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            bool          mouseButton0Up       = Input.GetMouseButtonUp(0);
            bool          mouseButton1Up       = Input.GetMouseButtonUp(1);
            bool          mouseButton2Up       = Input.GetMouseButtonUp(2);
            bool          performDragThisFrame = false;

            CurrentFramePosition = new Vector3(mousePos.x, mousePos.y, WorldController.Instance.CameraController.CurrentLayer);

            // The mode is enabled
            if (statusOfModes[(int)currentMode])
            {
                if ((handler.CallbacksEnabled & MouseHandlerCallbacks.HANDLE_PLACING_POSITION) == MouseHandlerCallbacks.HANDLE_PLACING_POSITION)
                {
                    CurrentPlacingPosition = handler.HandlePlacingPosition(CurrentFramePosition);
                }
                else
                {
                    CurrentPlacingPosition = CurrentFramePosition;
                }

                if ((mouseButton0Up || mouseButton1Up) && IsDragging)
                {
                    if (IsPanning == false)
                    {
                        uiTooltip          = null;
                        mouseCursor.UIMode = false;
                    }

                    IsDragging = false;
                    Selection  = null;

                    if (mouseButton0Up)
                    {
                        // If we are over a UI element then don't perform the drag this frame
                        // Also only perform the drag if we are actually ending the drag with left click
                        // else its a cancel drag action
                        performDragThisFrame = !EventSystem.current.IsPointerOverGameObject();
                    }
                }
                else if (IsDragging == false && Input.GetMouseButtonDown(0))
                {
                    IsDragging        = true;
                    dragStartPosition = CurrentPlacingPosition;
                }
            }

            mouseCursor.UpdateCursor(statusOfModes[(int)currentMode]);

            // HANDLE DRAG
            // Clear all the drag objects
            for (int i = 0; i < DragPreviewGameObjects.Count; i++)
            {
                SimplePool.Despawn(DragPreviewGameObjects[i]);
            }

            DragPreviewGameObjects.Clear();

            if (statusOfModes[(int)currentMode])
            {
                // If callback for handling drag is enabled then handle the drag
                bool dragEnabled       = (handler.CallbacksEnabled & MouseHandlerCallbacks.HANDLE_DRAG_FINISHED) == MouseHandlerCallbacks.HANDLE_DRAG_FINISHED;
                bool dragVisualEnabled = (handler.CallbacksEnabled & MouseHandlerCallbacks.HANDLE_DRAG_VISUAL) == MouseHandlerCallbacks.HANDLE_DRAG_VISUAL;

                if (dragEnabled || dragVisualEnabled)
                {
                    DragParameters dragParams = handler.DisableDragging || (IsDragging == false && performDragThisFrame == false) ? new DragParameters(CurrentPlacingPosition) : new DragParameters(dragStartPosition, CurrentPlacingPosition);

                    if (dragVisualEnabled)
                    {
                        // HANDLE VISUAL
                        DragPreviewGameObjects = handler.HandleDragVisual(dragParams, mouseCursor.CursorCanvasGameObject.transform);
                    }

                    // If we have dragEnabled and we are to perform it on our next frame (which is this frame) perform it
                    if (dragEnabled && performDragThisFrame)
                    {
                        // HANDLE DRAG
                        handler.HandleDragFinished(dragParams);
                    }
                }
            }

            UpdateCameraMovement();

            if (statusOfModes[(int)currentMode])
            {
                // Tooltip handling
                if ((handler.CallbacksEnabled & MouseHandlerCallbacks.HANDLE_TOOLTIP) == MouseHandlerCallbacks.HANDLE_TOOLTIP)
                {
                    handler.HandleTooltip(CurrentFramePosition, mouseCursor, IsDragging);
                }

                // Could include drag clicks
                // Should handle any 'building' that requires dragging in the HandleDrag callback
                if ((handler.CallbacksEnabled & MouseHandlerCallbacks.HANDLE_CLICK) == MouseHandlerCallbacks.HANDLE_CLICK && EventSystem.current.IsPointerOverGameObject() == false)
                {
                    if (mouseButton0Up)
                    {
                        handler.HandleClick(CurrentFramePosition, 0);
                    }

                    if (mouseButton1Up)
                    {
                        handler.HandleClick(CurrentFramePosition, 1);
                    }

                    if (mouseButton2Up)
                    {
                        handler.HandleClick(CurrentFramePosition, 2);
                    }
                }
            }

            // Save the mouse position from this frame.
            // We don't use currentFramePosition because we may have moved the camera.
            mousePos            = Camera.main.ScreenToWorldPoint(Input.mousePosition);
            lastFramePosition.x = mousePos.x;
            lastFramePosition.y = mousePos.y;
            lastFramePosition.z = WorldController.Instance.CameraController.CurrentLayer;
        }
Пример #7
0
 private void Scale_Click(object sender, EventArgs e)
 {
     _mouseHandler = new ScaleOfFigureMouseHandler();
 }
Пример #8
0
 /// <summary>
 /// Creates a handler which runs both given handlers in parallel.
 /// As soon as one of them is finished the other one will be returned.
 /// </summary>
 public static IMouseHandler InParallelWith(this IMouseHandler left, IMouseHandler right)
 {
     return(new ParallelMouseHandler(left, right));
 }
Пример #9
0
 public ParallelMouseHandler(IMouseHandler left, IMouseHandler right)
 {
     Left  = left;
     Right = right;
 }
Пример #10
0
 private void ButtonRectangleClass_Click(object sender, EventArgs e)
 {
     _crntMH = new MouseHandlerOnDrawRectangle(new RectangleClassFactory());
 }
Пример #11
0
 private void Press_E()
 {
     _crntMH = new MouseHandlerOnSelection();
 }
Пример #12
0
 private void ButtonSelect_Click(object sender, EventArgs e)
 {
     _crntMH = new MouseHandlerOnSelection();
 }
Пример #13
0
 private void ButtonAssociation_Click(object sender, EventArgs e)
 {
     _crntMH = new MouseHandlerOnDrawArrows(new AssociationArrowFactory());
 }
Пример #14
0
 private void ButtonInheritance_Click(object sender, EventArgs e)
 {
     _crntMH = new MouseHandlerOnDrawArrows(new InheritanceArrowFactory());
 }
Пример #15
0
        /// <summary>
        /// Update all screens and handle handlers
        /// </summary>
        public override void Update(GameTime gameTime)
        {
            _screensToUpdate = new List <GameScreen>(Screens);

            while (_screensToUpdate.Count > 0)
            {
                GameScreen currentScreen = _screensToUpdate[_screensToUpdate.Count - 1];

                _screensToUpdate.RemoveAt(_screensToUpdate.Count - 1);

                // Verifies if we have to delete the screen
                if (currentScreen.IsExiting == true)
                {
                    Screens.Remove(currentScreen);
                    continue;
                }

                // handles mouse input for the screen
                if (currentScreen is IMouseHandler)
                {
                    IMouseHandler handlerScreen     = (IMouseHandler)currentScreen;
                    MouseState    currentMouseState = Mouse.GetState();

                    if (currentMouseState.LeftButton == ButtonState.Pressed && _oldMouseState.LeftButton == ButtonState.Released)
                    {
                        handlerScreen.MouseLeftPressed(currentMouseState);
                    }

                    if (currentMouseState.LeftButton == ButtonState.Released && _oldMouseState.LeftButton == ButtonState.Pressed)
                    {
                        handlerScreen.MouseLeftReleased(currentMouseState);
                    }

                    if (currentMouseState.RightButton == ButtonState.Pressed && _oldMouseState.RightButton == ButtonState.Released)
                    {
                        handlerScreen.MouseRightPressed(currentMouseState);
                    }

                    if (currentMouseState.RightButton == ButtonState.Released && _oldMouseState.RightButton == ButtonState.Pressed)
                    {
                        handlerScreen.MouseRightReleased(currentMouseState);
                    }

                    _oldMouseState = currentMouseState;
                }

                // handles keyboard input for the screen
                if (currentScreen is IKeyboardHandler)
                {
                    IKeyboardHandler handlerScreen        = (IKeyboardHandler)currentScreen;
                    KeyboardState    currentKeyboardState = Keyboard.GetState();

                    Keys[] pressedKeys = currentKeyboardState.GetPressedKeys();

                    handlerScreen.KeysPressed(pressedKeys);
                }

                // handles socket connection for the screen
                if (currentScreen is ISocketHandler)
                {
                    ISocketHandler handlerScreen = (ISocketHandler)currentScreen;
                    var            status        = currentScreen.Socket.Connection.Status;

                    // check for no status
                    if (status != null)
                    {
                        if (status == ConnStatus.Disconnected)
                        {
                            handlerScreen.OnDisconnect(_statusBefore, gameTime);
                        }

                        if (status == ConnStatus.Connecting)
                        {
                            handlerScreen.OnConnecting(_statusBefore, gameTime);
                        }

                        if (status == ConnStatus.Connected)
                        {
                            handlerScreen.OnConnected(_statusBefore, gameTime);
                        }

                        _statusBefore = status;
                    }
                }

                // handles socket datas
                if (currentScreen is ISocketDataHandler)
                {
                    ISocketDataHandler handlerScreen = (ISocketDataHandler)currentScreen;
                    handlerScreen.Receive(ReceiveData);
                    // Select just data that can't be deleted
                    ReceiveData = new List <SocketData>(from d in ReceiveData
                                                        where d.IsDeleting == false
                                                        select d);
                }

                currentScreen.Update(gameTime);
            }
        }
Пример #16
0
 public MouseHandlerAdapter(IMouseHandler handler)
 {
     FHandler = handler;
 }
Пример #17
0
 /// <summary>
 /// Creates a handler which will return the second handler once the first one is finished.
 /// </summary>
 public static IMouseHandler ContinueWith(this IMouseHandler handler, IMouseHandler nextHandler)
 {
     return(handler.ContinueWith(_ => nextHandler));
 }
Пример #18
0
 private void Press_W()
 {
     _crntMH = new MouseHandlerOnMove();
 }
Пример #19
0
 /// <summary>
 /// Creates a handler which will call and return the handler of the given continuation once the first handler is finished.
 /// </summary>
 public static IMouseHandler ContinueWith(this IMouseHandler handler, Func <MouseNotification, IMouseHandler> continuation)
 {
     return(new ContinuationMouseHandler(handler, continuation));
 }
Пример #20
0
 private void Press_Q()
 {
     _crntMH = new MouseHandlerOnTransform();
 }
Пример #21
0
 /// <summary>
 /// Creates a handler which runs both given handlers in parallel.
 /// As soon as one of them changes, the changed one will be returned. left has priority of both change on the same event.
 /// Is any of the handlers finishes, the other is returned.
 /// </summary>
 public static IMouseHandler InSyncWith(this IMouseHandler left, IMouseHandler right)
 {
     return(new SyncMouseHandler(left, right));
 }
Пример #22
0
 /// <summary>
 /// Derived classes can execute addition mouse handler attachment operations by overriding this method.
 /// The default implementation does nothing.
 /// </summary>
 protected virtual void OnMouseHandlerAttachedEx_i(IMouseHandler handler)
 {
 }
 /// <summary>
 /// Register a handler for a mouse mode.
 /// </summary>
 /// <param name="mouseMode"> The mouse mode to register for. </param>
 /// <param name="handler"> The handler to register to the mouse mode. </param>
 public void RegisterModeHandler(MouseMode mouseMode, IMouseHandler handler)
 {
     mouseHandlers[(int)mouseMode] = handler;
 }
Пример #24
0
 /// <see cref="RCMapDisplay.OnMouseHandlerAttached"/>
 protected sealed override void OnMouseHandlerAttached(IMouseHandler handler)
 {
     this.extendedControl.AttachMouseHandler(handler);
     base.OnMouseHandlerAttached(handler);
     this.OnMouseHandlerAttachedEx_i(handler);
 }
Пример #25
0
 private void MoveVertex_Click(object sender, EventArgs e)
 {
     _mouseHandler = new MoveVertexMouseHandler();
 }
Пример #26
0
 public SyncMouseHandler(IMouseHandler left, IMouseHandler right)
     : base(left, right)
 {
     OrigLeft  = left;
     OrigRight = right;
 }
Пример #27
0
 private void FillFigure_Click(object sender, EventArgs e)
 {
     _mouseHandler = new FillFigureMouseHandler();
 }
Пример #28
0
 private void buttonMove_Click(object sender, EventArgs e)
 {
     _pictureBoxMouseMove = new MoveFiguresMouseMove();
     _figuresControls.ForEach(i => i.Enabled = false);
     checkBoxClockwise.Enabled = false;
 }
Пример #29
0
 public static void ListenForMouse(IMouseHandler Handler)
 {
     _MouseHandlers.Add(Handler);
 }
Пример #30
0
 /// <summary>
 /// Calls the given action once the handler is finished.
 /// </summary>
 public static IMouseHandler EndWith(this IMouseHandler handler, Action <MouseNotification> action)
 {
     return(handler.ContinueWith(arg => { action(arg); return null; }));
 }
Пример #31
0
 public ContinuationMouseHandler(IMouseHandler handler, Func <MouseNotification, IMouseHandler> continuation)
 {
     Handler           = handler;
     this.continuation = continuation;
 }
Пример #32
0
 private void buttonScale_Click(object sender, EventArgs e)
 {
     _pictureBoxMouseMove = new PictureBoxMouseMoveScale(sender, e, _canvas);
     _figuresControls.ForEach(i => i.Enabled = false);
     checkBoxClockwise.Enabled = false;
 }