Пример #1
0
 /// <summary>
 /// Apply box action when it clicked.
 /// </summary>
 /// <param name="i_Sender">Sender.</param>
 /// <param name="i_EventArgs">Mouse event args.</param>
 internal virtual void FBBox_MouseClick(object i_Sender, MouseEventArgs i_EventArgs)
 {
     if (MouseClicked != null)
     {
         MouseClicked.Invoke(Index);
     }
 }
        private void ProcessEvents(Event e)
        {
            switch (e.type)
            {
            case EventType.MouseDown:
                if (e.button == 1)
                {
                    if (MouseClicked != null)
                    {
                        MouseClicked.Invoke(e.mousePosition);
                    }
                }
                break;

            case EventType.MouseDrag:
                if (e.button == 0)
                {
                    if (Drag != null)
                    {
                        Drag.Invoke(e.delta);
                    }
                    GUI.changed = true;
                }
                break;
            }
        }
Пример #3
0
        private void mouseClick(object sender, MouseEventArgs e)
        {
            if (_selection.Selecting)
            {
                return;
            }

            var hitInfo = CalcHitInfo(e.Location);

            if (e.Button == MouseButtons.Left)
            {
                if (hitInfo.IsSearchButton)
                {
                    handleSearchClick(hitInfo);
                }
                else if (hitInfo.IsSortButton)
                {
                    handleSortClick(hitInfo);
                }
                else if (hitInfo.AlignButtonDirection.HasValue)
                {
                    handleAlignClick(hitInfo);
                }
            }

            MouseClicked?.Invoke(this, hitInfo, e);
        }
        private void CheckButtonReleased(Func <MouseState, ButtonState> getButtonState, MouseButton button)
        {
            if ((getButtonState(_currentState) == ButtonState.Released) &&
                (getButtonState(_previousState) == ButtonState.Pressed))
            {
                var args = new MouseEventArgs(ViewportAdapter, _gameTime.TotalGameTime, _previousState, _currentState, button);

                if (_mouseDownArgs.Button == args.Button)
                {
                    var clickMovement = DistanceBetween(args.Position, _mouseDownArgs.Position);

                    // If the mouse hasn't moved much between mouse down and mouse up
                    if (clickMovement < DragThreshold)
                    {
                        if (!_hasDoubleClicked)
                        {
                            MouseClicked?.Invoke(this, args);
                        }
                    }
                    else // If the mouse has moved between mouse down and mouse up
                    {
                        MouseDragEnd?.Invoke(this, args);
                        _dragging = false;
                    }
                }

                MouseUp?.Invoke(this, args);

                _hasDoubleClicked  = false;
                _previousClickArgs = args;
            }
        }
Пример #5
0
 /// <summary>
 /// Apply box action when it clicked.
 /// </summary>
 /// <param name="i_Index">Box index.</param>
 private void m_instance_MouseClicked(int i_Index)
 {
     if (MouseClicked != null)
     {
         MouseClicked.Invoke(i_Index);
     }
 }
Пример #6
0
        /// <summary>
        /// Checks for collision with cursor and invokes events based on user actions.
        /// </summary>
        public virtual void Update()
        {
            Container.SetPosition(new Vector2(CollRectangle.X, CollRectangle.Y));
            Container.Color = CurrentColor;
            Rectangle mouse = InputSystem.GetMouseInUi();


            if (mouse.Intersects(CollRectangle))
            {
                MouseHover?.Invoke();

                if (InputSystem.IsLeftMousePressed())
                {
                    _wasPressed  = true;
                    _wasReleased = false;
                }
                if (InputSystem.IsLeftMouseReleased() && _wasPressed)
                {
                    _wasReleased = true;
                }
                if (_wasPressed && _wasReleased)
                {
                    MouseClicked?.Invoke(this);
                    _wasReleased = false;
                    _wasPressed  = false;
                }
            }
            else
            {
                MouseOut?.Invoke();
            }
        }
Пример #7
0
        private void _mouseListener_MouseClicked(object sender, MouseEventArgs e)
        {
            _scene?.FireMouseClick(e);
            MouseClicked?.Invoke(sender, e);
#if DEBUG
            Logger.Log("Mouse clicked.");
#endif
        }
Пример #8
0
 private void Body_PreviewMouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e)
 {
     if (readyToReactionOnMouseDown)
     {
         this.GetComponent <Hit>().IsHited = true;
         MouseClicked?.Invoke();
     }
 }
 public void MouseClickRelease(Vector2 position)
 {
     if (DateTime.Now - SecondMouseDownTime < TimeSpan.FromMilliseconds(150))
     {
         MouseDoubleClicked?.Invoke(this, position);
     }
     else if (DateTime.Now - FirstMouseDownTime < TimeSpan.FromMilliseconds(150))
     {
         MouseClicked?.Invoke(this, position);
     }
 }
Пример #10
0
        private IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            if (nCode >= 0)
            {
                MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT));
                if (MouseClicked != null)
                {
                    MouseClicked.Invoke(this, new InterceptMouseEventArgs((MouseMessages)wParam, new Point(hookStruct.pt.x, hookStruct.pt.y)));
                }
            }

            return(CallNextHookEx(_hookID, nCode, wParam, lParam));
        }
        public bool ProcessEvents(Event e)
        {
            switch (e.type)
            {
            case EventType.MouseDown:
                if (e.button == 0)
                {
                    if (BRect.Contains(e.mousePosition))
                    {
                        _isDragged  = true;
                        _isSelected = true;
                        GUI.changed = true;
                    }
                    else
                    {
                        _isSelected = false;
                        GUI.changed = true;
                    }
                }

                if (e.button == 1 && _isSelected && BRect.Contains(e.mousePosition))
                {
                    if (MouseClicked != null)
                    {
                        MouseClicked.Invoke(e.mousePosition);
                    }

                    e.Use();
                }

                break;

            case EventType.MouseUp:
                _isDragged = false;
                break;

            case EventType.MouseDrag:
                if (e.button == 0 && _isDragged)
                {
                    Drag(e.delta);
                    e.Use();
                    return(true);
                }
                break;
            }
            return(false);
        }
Пример #12
0
        private static void CheckForClick()
        {
            if (_lastMouseState.LeftButton != _currentMouseState.LeftButton)
            {
                if (_currentMouseState.LeftButton == ButtonState.Pressed)
                {
                    _waitingForMouseRelease = true;
                    MouseLastClickLocation  = new Point(_currentMouseState.X, _currentMouseState.Y);
                    return;
                }
            }
            if (!_waitingForMouseRelease || _currentMouseState.LeftButton != ButtonState.Released)
            {
                return;
            }
            _waitingForMouseRelease = false;
            var releaseMouseLocation = new Point(_currentMouseState.X, _currentMouseState.Y);

            MouseClicked?.Invoke(new MouseClickEventArguments(MouseLastClickLocation, releaseMouseLocation));
        }
Пример #13
0
        private void drain_MouseUp(object sender, MouseButtonEventArgs e)
        {
            Animate(path14.Fill, MouseEnterBrush, path14);

            if (!Mute)
            {
                Animate(path16.Fill, MouseEnterBrush, path16);
                Animate(path18.Fill, MouseEnterBrush, path18);
                Animate(path20.Fill, MouseEnterBrush, path20);
            }
            else
            {
                Animate(Cross.Fill, MouseEnterBrush, Cross);
            }

            if (mf)
            {
                mf = false;
                MouseClicked?.Invoke(this, e);
            }
        }
Пример #14
0
 private void Pb_MouseDown(object sender, MouseEventArgs e)
 {
     if (!tsbttnSpectrum.Checked)
     {
         Point loc = TranslateZoomMousePosition(e.Location, pb.Image);
         Point cur = new Point(imageStartIndex.X + loc.X, imageStartIndex.Y + loc.Y);
         if (e.Button == MouseButtons.Left)
         {
             MouseClicked?.Invoke(this, new Tuple <int, int, int>(cur.X, cur.Y, gimda.Ncols));
         }
         if (e.Button == MouseButtons.Right)
         {
             MouseClicked?.Invoke(this, new Tuple <int, int, int>(cur.X, cur.Y, -gimda.Ncols));
         }
         startx            = e.X;
         starty            = e.Y;
         drawRectangleBool = true;
     }
     else  // if spectrum button is checked
     {
         Point loc = TranslateZoomMousePosition(e.Location, pb.Image);
         Point cur = new Point(imageStartIndex.X + loc.X, imageStartIndex.Y + loc.Y);
         if (((cur.X < 0) || (cur.Y < 0)) || ((cur.X > gimda.Ncols - 1) || (cur.Y > gimda.Nrows - 1)))
         {
             return;
         }
         Int32 bytePos = width * cur.Y + cur.X;
         spec = new Point[gimda.Nbands];
         createSpectrum(bytePos);
         spectrum.displaySpectrum(spec, gimda.Wavelength);
         if (e.Button == MouseButtons.Left)
         {
             spectrum.showSpectrumAsTable(spec, gimda.Wavelength);
         }
         this.Focus();
         drawRectangleBool = false;
     }
 }
Пример #15
0
 private void OnMouseClick(List <Sprite> sprites, Controler controler, Vector2 clickPosition)
 {
     MouseClicked?.Invoke(this, controler.MousePointer, controler, clickPosition);
 }
Пример #16
0
 public void Click()
 {
     MouseClicked?.Invoke();
 }
Пример #17
0
 protected virtual void OnMouseClicked()
 {
     MouseClicked?.Invoke();
 }
Пример #18
0
 private void Grid_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
 {
     MouseClicked?.Invoke(this, null);
 }
Пример #19
0
        public void Start()
        {
            if (isRunning)
            {
                return;
            }

            Prepare();
            isRunning = true;

            IntPtr handleIn = GetStdHandle(STD_INPUT_HANDLE);

            thread = new Thread(
                () =>
            {
                while (true)
                {
                    uint numRead          = 0;
                    INPUT_RECORD[] record = new INPUT_RECORD[1];
                    record[0]             = new INPUT_RECORD();
                    ReadConsoleInput(handleIn, record, 1, ref numRead);
                    if (isRunning)
                    {
                        switch (record[0].EventType)
                        {
                        case INPUT_RECORD.MOUSE_EVENT:
                            var mouseEvent = record[0].MouseEvent;
                            if (mouseEvent.dwButtonState == dwButtonStates.FROM_LEFT_1ST_BUTTON_PRESSED)
                            {
                                MouseClicked?.Invoke(this, CreateEventArgs(mouseEvent));
                            }
                            if (mouseEvent.dwEventFlags == dwEventFlags.DOUBLE_CLICK)
                            {
                                MouseDoubleClicked?.Invoke(this, CreateEventArgs(mouseEvent));
                            }
                            else if (mouseEvent.dwEventFlags == dwEventFlags.MOUSE_MOVED)
                            {
                                MouseMoved?.Invoke(this, CreateEventArgs(mouseEvent));
                            }
                            else if (mouseEvent.dwEventFlags == dwEventFlags.MOUSE_HWHEELED || mouseEvent.dwEventFlags == dwEventFlags.MOUSE_WHEELED)
                            {
                                MouseWheelChanged?.Invoke(this, CreateEventArgs(mouseEvent));
                            }

                            break;

                        case INPUT_RECORD.KEY_EVENT:
                            var keyEvent = record[0].KeyEvent;

                            if (keyEvent.bKeyDown)
                            {
                                KeyDown?.Invoke(this, CreateEventArgs(keyEvent));
                            }

                            break;

                        case INPUT_RECORD.WINDOW_BUFFER_SIZE_EVENT:
                            WindowBufferSizeEvent?.Invoke(record[0].WindowBufferSizeEvent);
                            break;
                        }
                    }
                    else
                    {
                        uint numWritten = 0;
                        WriteConsoleInput(handleIn, record, 1, ref numWritten);
                        return;
                    }
                }
            });

            thread.Start();
        }
Пример #20
0
    public void OnPointerClick(PointerEventData eventData)
    {
        //Debug.Log("Click");

        MouseClicked?.Invoke();
    }
Пример #21
0
 protected virtual void OnMouseClicked(MouseEventArgs e)
 {
     MouseClicked?.Invoke(this, e);
 }
 public void OnPointerClick(PointerEventData eventData)
 {
     MouseClicked?.Invoke();
 }
Пример #23
0
        /// <summary>
        /// Mouse click handler.
        /// </summary>
        /// <param name="canvas">Canvas.</param>
        /// <param name="mouseButton">Mouse button number.</param>
        /// <param name="down">Specifies if the button is down.</param>
        /// <returns>True if handled.</returns>
        public bool OnMouseClicked(Base canvas, int mouseButton, bool down)
        {
            // If we click on a control that isn't a menu we want to close
            // all the open menus. Menus are children of the canvas.
            if (down && (null == HoveredControl || !HoveredControl.IsMenuComponent))
            {
                canvas.CloseMenus();
            }

            if (null == HoveredControl)
            {
                return(false);
            }
            if (HoveredControl.GetCanvas() != canvas)
            {
                return(false);
            }
            if (!HoveredControl.IsVisible)
            {
                return(false);
            }
            if (HoveredControl == canvas)
            {
                return(false);
            }

            if (mouseButton > MaxMouseButtons)
            {
                return(false);
            }

            if (mouseButton == 0)
            {
                m_KeyData.LeftMouseDown = down;
            }
            else if (mouseButton == 1)
            {
                m_KeyData.RightMouseDown = down;
            }

            // Double click.
            // Todo: Shouldn't double click if mouse has moved significantly
            bool isDoubleClick = false;

            if (down &&
                m_LastClickPos.X == MousePosition.X &&
                m_LastClickPos.Y == MousePosition.Y &&
                (Platform.Neutral.GetTimeInSeconds() - m_LastClickTime[mouseButton]) < DoubleClickSpeed)
            {
                isDoubleClick = true;
            }

            if (down && !isDoubleClick)
            {
                m_LastClickTime[mouseButton] = Platform.Neutral.GetTimeInSeconds();
                m_LastClickPos = MousePosition;
            }

            if (down)
            {
                FindKeyboardFocus(HoveredControl);
            }

            HoveredControl.UpdateCursor();

            // This tells the child it has been touched, which
            // in turn tells its parents, who tell their parents.
            // This is basically so that Windows can pop themselves
            // to the top when one of their children have been clicked.
            if (down)
            {
                HoveredControl.Touch();
            }

            if (MouseClicked != null)
            {
                MouseClicked.Invoke(this, new EventArgs());
            }

#if GWEN_HOOKSYSTEM
            if (bDown)
            {
                if (Hook::CallHook(&Hook::BaseHook::OnControlClicked, HoveredControl, MousePosition.x,
                                   MousePosition.y))
                {
                    return(true);
                }
            }
#endif

            switch (mouseButton)
            {
            case 0:
            {
                if (DragAndDrop.OnMouseButton(HoveredControl, MousePosition.X, MousePosition.Y, down))
                {
                    return(true);
                }

                if (isDoubleClick)
                {
                    HoveredControl.InputMouseDoubleClickedLeft(MousePosition.X, MousePosition.Y);
                }
                else
                {
                    HoveredControl.InputMouseClickedLeft(MousePosition.X, MousePosition.Y, down);
                }
                return(true);
            }

            case 1:
            {
                if (isDoubleClick)
                {
                    HoveredControl.InputMouseDoubleClickedRight(MousePosition.X, MousePosition.Y);
                }
                else
                {
                    HoveredControl.InputMouseClickedRight(MousePosition.X, MousePosition.Y, down);
                }
                return(true);
            }
            }

            return(false);
        }