Esempio n. 1
0
        //actions for commands
        private async void GoToItemAsync(object obj)
        {
            if (Items == null || Items?.Count == 0)
            {
                return;
            }
            var list = (ListView)obj;                       //take the list

            string[] typeOfItems = new string[Items.Count]; //make an array that will contain the options
            //get all the items type that user have
            for (int i = 0; i < Items.Count; i++)
            {
                typeOfItems[i] = Items[i].Key;
            }
            string itemToGo = await PageService.DisplayActionSheet("Select item you wanna go to", "Cancel", typeOfItems);

            if (itemToGo is null || itemToGo == "Cancel")
            {
                return;
            }
            var item = Items.Where(s => s.Key == itemToGo).FirstOrDefault().FirstOrDefault();

            if (item is null)
            {
                return;
            }
            OnScroll?.Invoke(item, list);
        }
Esempio n. 2
0
 internal virtual void DoScroll()
 {
     if (MouseEnabled)
     {
         OnScroll?.Invoke();
     }
 }
Esempio n. 3
0
        internal static void Init()
        {
            PreUpdate();
            LastPosition = Position;

            App.platform.OnMouseButtonDown += id =>
            {
                down[id]    = true;
                pressed[id] = true;
                OnPress?.Invoke((MouseButton)id);
            };

            App.platform.OnMouseButtonUp += id =>
            {
                down[id]     = false;
                released[id] = true;
                OnRelease?.Invoke((MouseButton)id);
            };

            App.platform.OnMouseScroll += (x, y) =>
            {
                Scroll += new Point2((int)(x / Screen.PixelSize), (int)(y / Screen.PixelSize));
                OnScroll?.Invoke();
            };
        }
Esempio n. 4
0
        /// <summary>
        /// Makes a new instance of <see cref="GlfwMouse"/> class.
        /// </summary>
        /// <param name="window">Current context.</param>
        public GlfwMouse(GlfwWindow window)
        {
            handler = window;

            handler.OnRestore += Handler_OnRestore;

            cursorCallback = (w, x, y) =>
            {
                OnMove?.Invoke(this, new MousePositiontEventArgs
                {
                    Position = new Vector2((float)x, (float)y)
                });
            };

            scrollCallback = (w, x, y) =>
            {
                OnScroll?.Invoke(this, new MouseOffsetEventArgs
                {
                    Offset = new Vector2((float)x, (float)y)
                });
            };

            buttonCallback = (w, button, action, modifiers) =>
            {
                OnButtonEvent?.Invoke(this, new MouseKeyEventArgs
                {
                    Key       = (MouseButton)button,
                    Action    = (KeyState)action,
                    Modifiers = (KeyModifier)modifiers
                });
            };
        }
Esempio n. 5
0
        public Window(WindowConfig config)
        {
            _config = config;

            var opts = WindowOptions.DefaultVulkan;

            opts.WindowBorder = WindowBorder.Resizable;
            opts.Size         = new Silk.NET.Maths.Vector2D <int>((int)config.Width, (int)config.Height);
            opts.Title        = config.Title;
            opts.WindowState  = config.Fullscreen ? WindowState.Fullscreen : WindowState.Normal;

            _window         = Silk.NET.Windowing.Window.Create(opts);
            _window.Render += (time) => DrawFrame?.Invoke(time);

            _window.Initialize();

            _input = _window.CreateInput();
            var primaryKeyboard = _input.Keyboards.FirstOrDefault();

            if (primaryKeyboard != null)
            {
                primaryKeyboard.KeyDown += (keyboard, key, code) => OnKeyDown?.Invoke(key);
                primaryKeyboard.KeyUp   += (keyboard, key, code) => OnKeyUp?.Invoke(key);
            }
            for (int i = 0; i < _input.Mice.Count; i++)
            {
                _input.Mice[i].Cursor.CursorMode = config.CursorDisabled ? CursorMode.Disabled : CursorMode.Normal;
                _input.Mice[i].MouseMove        += (mouse, pos) => OnCursorPosition?.Invoke(pos.X, pos.Y);
                _input.Mice[i].Scroll           += (mouse, wheel) => OnScroll?.Invoke(wheel.X, wheel.Y);
                _input.Mice[i].MouseDown        += (mouse, button) => OnMouseDown?.Invoke(button);
                _input.Mice[i].MouseUp          += (mouse, button) => OnMouseUp?.Invoke(button);
            }
        }
Esempio n. 6
0
 public async void DidScrollAsync()
 {
     if (OnScroll.HasDelegate)
     {
         await OnScroll.InvokeAsync(new EventArgs());
     }
 }
 private async Task HandleScroll(string direction, EventArgs e)
 {
     if (OnScroll.HasDelegate)
     {
         await OnScroll.InvokeAsync(new TransferScrollArgs(direction, e));
     }
 }
Esempio n. 8
0
    void Update()
    {
        // more to be added based on need

        if (Input.GetKeyDown(PAUSE))
        {
            OnPause?.Invoke();
        }

        if (!DialogueManager.InConversation && !TimelineController.InCutscene)
        {
            Horizontal = Input.GetAxisRaw("Horizontal");
            Vertical   = Input.GetAxisRaw("Vertical");
            if (Input.GetKeyDown(INTERACT))
            {
                OnInteract?.Invoke();
            }
            if (Input.GetKeyUp(INTERACT))
            {
                OnStopInteract?.Invoke();
            }
            if (!EventSystem.current.IsPointerOverGameObject())
            {
                if (Input.GetMouseButtonDown(0))
                {
                    OnMouseClickLeft?.Invoke();
                }
                if (Input.GetMouseButtonDown(1))
                {
                    OnMouseClickRight?.Invoke();
                }
                if (Input.GetMouseButtonUp(0))
                {
                    OnMouseUpLeft?.Invoke();
                }
                if (Input.GetMouseButtonUp(1))
                {
                    OnMouseUpRight?.Invoke();
                }
            }
        }
        else
        {
            Horizontal = 0;
            Vertical   = 0;

            if (Input.GetKeyDown(INTERACT) || Input.GetKeyDown(KeyCode.Space))
            {
                OnNextDialogue?.Invoke();
            }
        }

        int scrollDirection = (int)Input.mouseScrollDelta.y;

        if (scrollDirection != 0)
        {
            OnScroll?.Invoke(scrollDirection);
        }
    }
Esempio n. 9
0
 void OnScrollInvoke(int index)
 {
     ScrollIndex = index;
     if (OnScroll != null)
     {
         OnScroll.Execute();
     }
 }
Esempio n. 10
0
        private void ScrollListenerOnScrolled(RecyclerView recyclerView, int i, int arg3)
        {
            var firstIndex = CurrentAbsoluteVerseNumber;

            if (firstIndex == _lastPosition)
            {
                return;
            }
            _lastPosition = firstIndex;
            OnScroll?.Invoke();
        }
Esempio n. 11
0
        public void Scroll(T2[] list, float value, float elementSize)
        {
            SetContentSize(list.Length * elementSize / ConstraintCount);
            int index = Mathf.FloorToInt(Mathf.Clamp(list.Length - Elements.Count, 0, list.Length) * (1 - value));

            for (int i = 0; i < Elements.Count; i++)
            {
                T2 data = index < list.Length ? list[index] : default;
                Elements[i].Scroll(index, data, elementSize, ConstraintCount, index < list.Length);
                OnScroll?.Invoke(Elements[i], index, data, elementSize, ConstraintCount, index < list.Length);
                index++;
            }
        }
Esempio n. 12
0
        private void ScrollToMouseLocation(Point location)
        {
            var sigArea          = GetSignalArea();
            var scrollArea       = GetScrollbarArea(sigArea);
            var scrollLeftOffset = location.X - (_scrollbarDragLeft + sigArea.X);

            PinchedSampleOffset = (long)MapToInterval(
                scrollLeftOffset,
                new Interval(0, sigArea.Width - scrollArea.Width),
                new Interval(0, PinchedDataLength - sigArea.Width)
                );

            LimitSampleOffset(sigArea);

            OnScroll?.Invoke(this);
        }
Esempio n. 13
0
        public HitBox HitTest()
        {
            var delta = UiState.ScrollDelta;

            if (delta != 0 && _parent.Bounds.Contains(UiState.Mouse.Position) && KeyboardManager.IsModifierDown(_modifier))
            {
                if (delta > 0)
                {
                    OnScrollBackward?.Invoke(delta / 120);
                }
                else
                {
                    OnScrollForward?.Invoke(delta / 120);
                }
                OnScroll?.Invoke(delta / 120);
                return(HitBox.Hit(_parent));
            }

            return(HitBox.Miss);
        }
Esempio n. 14
0
 private void GridMouseMoveEventCalled(object sender, MouseEventArgs e)
 {
     if (isMouseDown)
     {
         double x        = e.GetPosition(this).X;
         double relative = (double)(x - 10) / (this.RenderSize.Width - 20);
         if (relative < 0)
         {
             relative = 0;
         }
         if (relative > 1)
         {
             relative = 1;
         }
         Canvas.SetLeft(this.itemSelector, relative * (this.RenderSize.Width - 20));
         this.Ratio = relative;
         itemColorSelection.Fill = new SolidColorBrush(GeneratorFunction(Ratio));
         OnScroll?.Invoke(this, null);
     }
 }
Esempio n. 15
0
        public void Update(IFrameBasedClock clock)
        {
            while (currentState != null && currentState.Events.Count > 0)
            {
                IInputEvent e = currentState.Events.Dequeue();

                if (e is InputEvent <MouseKeyEventArgs> keyEvent && keyEvent.Name == "OnButtonEvent")
                {
                    OnButtonEvent?.Invoke(this, keyEvent.Info);
                }

                if (e is InputEvent <MousePositiontEventArgs> modEvent && modEvent.Name == "OnMove")
                {
                    OnMove?.Invoke(this, modEvent.Info);
                }

                if (e is InputEvent <MouseOffsetEventArgs> tyEvent && tyEvent.Name == "OnScroll")
                {
                    OnScroll?.Invoke(this, tyEvent.Info);
                }
            }
        }
Esempio n. 16
0
        private void OnScrollInvoke(int index)
        {
            _scrollIndex = _view.FirstVisiblePosition;
            if (_containerBehaviour.Childrens.Count > index && index >= 0)
            {
                View view = _containerBehaviour.Childrens[index].View;
                if (view != null)
                {
                    _scrollTop = view.Top;
                }

                ScrollIndex = index;
                if (OnScroll != null)
                {
                    OnScroll.Execute();
                }
            }
            else
            {
                Console.WriteLine("Bad index: " + index);
            }
        }
Esempio n. 17
0
        protected override void WndProc(ref Message m)
        {
            var scrollType = ScrollType.Vertical;

            switch (m.Msg)
            {
            case WM_HSCROL:
                scrollType = ScrollType.Horizontal;
                goto action;

            case WM_MOUSEWHEEL:
            case WM_VSCROLL:
                action :;
                OnScroll.Invoke(
                    this,
                    new ScrollEventArgs {
                    ScrollType = scrollType
                });
                break;
            }

            base.WndProc(ref m);
        }
Esempio n. 18
0
 private void XTrackBar_MouseMove(object sender, MouseEventArgs e)
 {
     if (Capture)
     {
         Value = XtoValue(e.X);
         if (OnScroll != null)
         {
             OnScroll.Invoke();
         }
         thumbState = TrackBarThumbState.Pressed;
     }
     else
     {
         if ((e.X > thumbX - this.Height / 2) && (e.X < thumbX + this.Height) && (e.Y > thumby - this.Height / 2) && (e.Y < thumby + this.Height))
         {
             thumbState = TrackBarThumbState.Hot;
         }
         else
         {
             thumbState = TrackBarThumbState.Normal;
         }
     }
     this.Invalidate();
 }
Esempio n. 19
0
        private void Update()
        {
            if (CheckKey(KeyCode.W))
            {
                OnWPressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.W);
                OnKeyPressed?.Invoke(this, args);
                OnMovementKeyPressed?.Invoke(this, args);
            }
            if (CheckKey(KeyCode.A))
            {
                OnAPressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.A);
                OnKeyPressed?.Invoke(this, args);
                OnMovementKeyPressed?.Invoke(this, args);
            }
            if (CheckKey(KeyCode.S))
            {
                OnSPressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.S);
                OnKeyPressed?.Invoke(this, args);
                OnMovementKeyPressed?.Invoke(this, args);
            }
            if (CheckKey(KeyCode.D))
            {
                OnDPressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.D);
                OnKeyPressed?.Invoke(this, args);
                OnMovementKeyPressed?.Invoke(this, args);
            }
            if (CheckKey(KeyCode.Space))
            {
                OnSpacePressed?.Invoke(this, EventArgs.Empty);
                KeyEventArgs args = new KeyEventArgs(KeyCode.Space);
                OnKeyPressed?.Invoke(this, args);
            }

            RunKey(KeyCode.G);
            RunKey(KeyCode.H);
            RunKey(KeyCode.Q);
            RunKey(KeyCode.Escape);

            var scrollDelta = Input.GetAxis("Mouse ScrollWheel");

            if (scrollDelta != 0.0F)
            {
                ScrollEventArgs args;
                if (scrollDelta > 0.0F)
                {
                    args = new ScrollEventArgs(true);
                    OnScrollUp?.Invoke(this, EventArgs.Empty);
                }
                else
                {
                    args = new ScrollEventArgs(false);
                    OnScrollDown?.Invoke(this, EventArgs.Empty);
                }
                OnScroll?.Invoke(this, args);
            }

            if (CheckMouseSingle(MouseButton.LEFT))
            {
                ClickEventArgs args = new ClickEventArgs(MouseButton.LEFT, Input.mousePosition);
                OnMouseClick?.Invoke(this, args);
                OnLeftMouseClick?.Invoke(this, args);
            }
            if (CheckMouseSingle(MouseButton.RIGHT))
            {
                ClickEventArgs args = new ClickEventArgs(MouseButton.RIGHT, Input.mousePosition);
                OnMouseClick?.Invoke(this, args);
                OnRightMouseClick?.Invoke(this, args);
            }
        }
Esempio n. 20
0
 public void RaiseOnScroll(int absoluteVerseNumber)
 {
     CurrentAbsoluteVerseNumber = absoluteVerseNumber;
     OnScroll?.Invoke();
 }
Esempio n. 21
0
        /// <summary>
        /// Updates the state of the input manager.
        /// </summary>
        public void Update()
        {
            // updates the mouse and keyboard state
            prevKeyState   = currentKeyState;
            prevMouseState = currentMouseState;

            currentKeyState   = Keyboard.GetState();
            currentMouseState = Mouse.GetState();

            // checks if any mouse buttons have been pressed
            if (OnMousePress != null)
            {
                if (prevMouseState.LeftButton.Equals(ButtonState.Released) &&
                    currentMouseState.LeftButton.Equals(ButtonState.Pressed))
                {
                    OnMousePress(MouseButton.LEFT);
                }
                if (prevMouseState.RightButton.Equals(ButtonState.Released) &&
                    currentMouseState.RightButton.Equals(ButtonState.Pressed))
                {
                    OnMousePress(MouseButton.RIGHT);
                }
                if (prevMouseState.MiddleButton.Equals(ButtonState.Released) &&
                    currentMouseState.MiddleButton.Equals(ButtonState.Pressed))
                {
                    OnMousePress(MouseButton.MIDDLE);
                }
            }

            // checks if any mouse buttons have been released
            if (OnMouseRelease != null)
            {
                if (currentMouseState.LeftButton.Equals(ButtonState.Released) &&
                    prevMouseState.LeftButton.Equals(ButtonState.Pressed))
                {
                    OnMouseRelease(MouseButton.LEFT);
                }
                if (currentMouseState.RightButton.Equals(ButtonState.Released) &&
                    prevMouseState.RightButton.Equals(ButtonState.Pressed))
                {
                    OnMouseRelease(MouseButton.RIGHT);
                }
                if (currentMouseState.MiddleButton.Equals(ButtonState.Released) &&
                    prevMouseState.MiddleButton.Equals(ButtonState.Pressed))
                {
                    OnMouseRelease(MouseButton.MIDDLE);
                }
            }

            // checks if any keys have been pressed or released
            if (OnKeyPress != null || OnKeyRelease != null)
            {
                Keys[] prevDownKeys = prevKeyState.GetPressedKeys();
                Keys[] downKeys     = currentKeyState.GetPressedKeys();
                // check for newly pressed keys
                if (OnKeyPress != null)
                {
                    List <Keys> newlyPressed = findNewKeys(downKeys, prevDownKeys);
                    foreach (Keys key in newlyPressed)
                    {
                        OnKeyPress(key);
                    }
                }

                // checks for newly released keys
                if (OnKeyRelease != null)
                {
                    List <Keys> newlyReleased = findNewKeys <Keys>(prevDownKeys, downKeys);
                    foreach (Keys key in newlyReleased)
                    {
                        OnKeyRelease(key);
                    }
                }
            }

            // checks if the mouse wheel has been scrolled
            if (MouseScrollAmount() != 0)
            {
                OnScroll?.Invoke(MouseButton.MIDDLE);
            }
        }
Esempio n. 22
0
 public MockScrollListener()
 {
     OnScroll?.Invoke(this, new ScrollEventArgs());
 }
Esempio n. 23
0
 private void HandleScroll(Vector2 pos)
 {
     OnScroll?.Invoke();
 }
Esempio n. 24
0
 internal void TriggerOnScroll(float amount)
 {
     OnScroll?.Invoke(amount);
 }
Esempio n. 25
0
 private void UpdateMouse()
 {
     OnScroll?.Invoke(Input.GetAxis(scrollAxisName));
     OnMousePosition?.Invoke(Input.mousePosition);
 }
Esempio n. 26
0
        public void Content()
        {
            if (!window.IsOpen || !window.IsFocused)
            {
                return;
            }

            var offset = GetCursorScreenPos();
            var size   = GetContentRegionAvail();

            validBounds = new Rect(offset + size / 2, size);

            // Scroll event
            bool isCurrentlyInside = validBounds.IsInside(GetIO().MousePos);

            if (isCurrentlyInside && MathF.Abs(GetIO().MouseWheel) > 0.01f)
            {
                OnScroll?.Invoke(GetIO().MouseWheel);
            }

            // Move event
            if (isCurrentlyInside)
            {
                var newPosition = MousePosition;
                if (lastPosition != null)
                {
                    OnMove?.Invoke(newPosition - lastPosition.Value);
                }
                lastPosition = MousePosition;
            }
            else
            {
                lastPosition = null;
            }

            // Drag event
            for (int i = 0; i < (int)ImGuiMouseButton.COUNT; i++)
            {
                var button = (ImGuiMouseButton)i;
                if (!validBounds.IsInside(GetIO().MouseClickedPos[i]))
                {
                    continue;
                }

                if (triggerClickEvent[i] != IsMouseDown(button))
                {
                    ((triggerClickEvent[i] = IsMouseDown(button))
                        ? OnButtonDown
                        : OnButtonUp)?.Invoke(ToVeldrid(button), validBounds.RelativePos(GetIO().MouseClickedPos[i]));
                }

                if (!IsMouseDragging(button))
                {
                    lastDragDelta[i] = Vector2.Zero;
                    continue;
                }

                var delta = GetMouseDragDelta(button);
                OnDrag?.Invoke(ToVeldrid(button), delta - lastDragDelta[i]);
                lastDragDelta[i] = delta;
            }
        }
Esempio n. 27
0
        public void RaiseOnScroll(float delta, float currentY)
        {
            var args = new ControlScrollEventArgs(delta, currentY);

            OnScroll?.Invoke(this, args);
        }
Esempio n. 28
0
 public static void BroadcastOnScroll(Vector3 pointerPos)
 {
     OnScroll?.Invoke(pointerPos);
 }
        public override void Scrolled(UIScrollView scrollView)
        {
            var offset = scrollView.ContentOffset;

            OnScroll?.Invoke(this, new CGPoint(offset.X, offset.Y - headerHeight));
        }
Esempio n. 30
0
 public static void InvokeOnScroll()
 {
     OnScroll?.Invoke();
 }