Example #1
0
        public override void Update(GameTime gameTime)
        {
            if (!Enabled || !Game.IsActive)
            {
                return;
            }

            _mouseDown = ScrollableGame.CheckLeftDown() || ScrollableGame.CheckLeftPressed();

            bool newMouseOver = MouseCollide();

            // Se antes não estava com o MouseOver e agora esta
            if (!IsMouseOver && newMouseOver)
            {
                if (MouseOver != null)
                {
                    MouseOver(this, EventArgs.Empty);
                }
            }
            // Se antes estava com o MouseOver e agora não esta
            if (!newMouseOver && IsMouseOver)
            {
                if (MouseOut != null)
                {
                    MouseOut(this, EventArgs.Empty);
                }
            }

            IsMouseOver = newMouseOver;

            Hits = Hits && _mouseDown && IsMouseOver;

            if (IsMouseOver && ScrollableGame.CheckLeftPressed())
            {
                _pressedOver = true;
                Hits         = true;
            }

            if (ScrollableGame.CheckLeftReleased())
            {
                if (IsMouseOver && _pressedOver)
                {
                    OnClick();
                    Hits = true;
                }
                _pressedOver = false;
            }

            base.Update(gameTime);
        }
Example #2
0
        public override void Update(GameTime gameTime)
        {
            if (!Enabled || !Game.IsActive)
            {
                return;
            }

            if (Rec.Contains(ScrollableGame.MousePoint))
            {
                if (ScrollableGame.CheckLeftPressed())
                {
                    _clickXDif = ScrollableGame.MousePos.X;
                    _clickYDif = ScrollableGame.MousePos.Y;
                }
                else if (ScrollableGame.CheckLeftDown())
                {
                    if (Horizontal)
                    {
                        XDif -= ScrollableGame.MousePos.X - _clickXDif;
                        if (XDif > Width - _sourceRec.Width)
                        {
                            XDif = Width - _sourceRec.Width;
                        }
                        if (XDif < 0)
                        {
                            XDif = 0;
                        }
                        _sourceRec.X = (int)XDif;
                        _clickXDif   = ScrollableGame.MousePos.X;
                    }
                    if (Vertical)
                    {
                        YDif -= ScrollableGame.MousePos.Y - _clickYDif;
                        if (YDif > Height - _sourceRec.Height)
                        {
                            YDif = Height - _sourceRec.Height;
                        }
                        if (YDif < 0)
                        {
                            YDif = 0;
                        }
                        _sourceRec.Y = (int)YDif;
                        _clickYDif   = ScrollableGame.MousePos.Y;
                    }
                }
            }

            base.Update(gameTime);
        }
Example #3
0
        public override void Update(GameTime gameTime)
        {
            if (!Enabled || !Game.IsActive)
            {
                return;
            }

            bool mouseDown = ScrollableGame.CheckLeftDown() || ScrollableGame.CheckLeftPressed();

            bool mouseOver = MouseCollide();

            Hits = Hits && mouseDown && mouseOver;

            if (mouseOver && ScrollableGame.CheckLeftPressed())
            {
                SetFocus();
                Hits = true;
            }

            if (SelectedGuid == MyGuid)
            {
                _cursorFlickTime += gameTime.ElapsedGameTime;
                if (_cursorFlickTime.TotalMilliseconds >= 500)
                {
                    ShowCursorFlick  = !ShowCursorFlick;
                    _cursorFlickTime = TimeSpan.Zero;
                }
                if (ValidadeKeyboard())
                {
                    if (SelectedEvent != null)
                    {
                        SelectedEvent(this, new EventArgs());
                    }
                }
            }
            else
            {
                ShowCursorFlick = false;
            }

            base.Update(gameTime);
        }
Example #4
0
        public override void Update(GameTime gameTime)
        {
            if (!Enabled || !Game.IsActive)
            {
                return;
            }

            // Select for Drag
            if (ScrollableGame.CheckLeftPressed(true))
            {
                if (Rect.Contains(ScrollableGame.MousePoint))
                {
                    Draging     = true;
                    Hits        = true;
                    _draggedDif = ScrollableGame.MousePos;
                }
            }

            // Dragging
            if (Draging && ScrollableGame.CheckLeftDown())
            {
                var pos = ScrollableGame.MousePos - _draggedDif;
                _draggedDif = ScrollableGame.MousePos;

                if (Horizontal)
                {
                    PosX += (int)pos.X;
                    var widthDif = Width - BarWidth;
                    if (widthDif <= 0 || PosX < 0)
                    {
                        PosX = 0;
                    }
                    else if (widthDif > 0 && PosX > widthDif)
                    {
                        PosX = widthDif;
                    }
                    if (widthDif > 0)
                    {
                        PercentageX = PosX / widthDif;
                    }
                    else
                    {
                        UpdateRec();
                    }
                }

                if (Vertical)
                {
                    PosY += (int)pos.Y;
                    var heightDif = Height - BarHeight;
                    if (heightDif <= 0 || PosY < 0)
                    {
                        PosY = 0;
                    }
                    else if (heightDif > 0 && PosY > heightDif)
                    {
                        PosY = heightDif;
                    }
                    if (heightDif > 0)
                    {
                        PercentageY = PosY / heightDif;
                    }
                    else
                    {
                        UpdateRec();
                    }
                }
            }

            // Drop
            if (ScrollableGame.CheckLeftReleased())
            {
                Draging = false;
                Hits    = false;
            }

            base.Update(gameTime);
        }
        public override void Update(GameTime gameTime)
        {
            if (!Enabled || !Game.IsActive)
            {
                return;
            }

            UpdateRec();

            // Select for Drag
            if (ScrollableGame.CheckLeftPressed(true))
            {
                if (Rect.Contains(ScrollableGame.MousePoint))
                {
                    Draging     = true;
                    _draggedDif = ScrollableGame.MousePos;
                }
                if (_rec2.Contains(ScrollableGame.MousePoint))
                {
                    Hits = true;
                }
            }

            // Dragging
            if (Draging && ScrollableGame.CheckLeftDown())
            {
                var pos = ScrollableGame.MousePos - _draggedDif;
                _draggedDif = ScrollableGame.MousePos;

                if (Vertical)
                {
                    PosY += (int)pos.Y;
                    var heightDif = Height - BarHeight;
                    if (heightDif <= 0 || PosY < 0)
                    {
                        PosY = 0;
                    }
                    else if (heightDif > 0 && PosY > heightDif)
                    {
                        PosY = heightDif;
                    }
                    if (heightDif > 0)
                    {
                        PercentageY = PosY / heightDif;
                    }
                    UpdateRec();

                    ScrollContainer.Percentage = PercentageY;
                }
            }

            // Drop
            if (ScrollableGame.CheckLeftReleased())
            {
                Draging = false;
                Hits    = false;
            }

            _barraUp.Position   = Position + new Vector2(0, PosY);
            _barraDown.Position = Position;

            base.Update(gameTime);
        }
Example #6
0
        public override void Update(GameTime gameTime)
        {
            if (!Enabled)
            {
                return;
            }

            bool scrollDrag = false;

            if (_scroll != null)
            {
                _scroll.Update(gameTime);
                scrollDrag = _scroll.Draging || _scroll.Hits;
            }

            if (!scrollDrag)
            {
                // Select for Drag
                if (ScrollableGame.CheckLeftPressed(true))
                {
                    if (_rect.Contains(ScrollableGame.MousePoint))
                    {
                        _draging           = true;
                        _draggedDifInicial = _draggedDif = ScrollableGame.MousePos;
                    }
                }

                // Dragging
                if (_draging && ScrollableGame.CheckLeftDown())
                {
                    if (Horizontal)
                    {
                        var pos = ScrollableGame.MousePos.X - _draggedDif.X;
                        _draggedDif = ScrollableGame.MousePos;
                        PosDif     -= (int)pos;

                        if (Math.Abs(ScrollableGame.MousePos.X - _draggedDifInicial.X) > 5)
                        {
                            Button.CancelClick = true;
                        }

                        var widthDif = ContentSize - Width;

                        if (widthDif <= 0 || PosDif < 0)
                        {
                            PosDif = 0;
                        }
                        else if (widthDif > 0 && PosDif > widthDif)
                        {
                            PosDif = widthDif;
                        }

                        if (widthDif > 0)
                        {
                            Percentage = PosDif / widthDif;
                        }
                    }
                    else
                    {
                        var pos = ScrollableGame.MousePos.Y - _draggedDif.Y;
                        _draggedDif = ScrollableGame.MousePos;
                        PosDif     -= (int)pos;

                        if (Math.Abs(ScrollableGame.MousePos.Y - _draggedDifInicial.Y) > 5)
                        {
                            Button.CancelClick = true;
                        }

                        var heightDif = ContentSize - Height;

                        if (heightDif <= 0 || PosDif < 0)
                        {
                            PosDif = 0;
                        }
                        else if (heightDif > 0 && PosDif > heightDif)
                        {
                            PosDif = heightDif;
                        }

                        if (heightDif > 0)
                        {
                            Percentage = PosDif / heightDif;
                        }
                    }
                }

                // Drop
                if (ScrollableGame.CheckLeftReleased()
#if SILVERLIGHT
                    || !_rect.Contains(ScrollableGame.MousePoint)
#endif
                    )
                {
                    _draging = false;
#if SILVERLIGHT
                    Microsoft.Xna.Framework.Input.Mouse.LeftButtonDown = false;
#endif
                }

                ScrollableGame.Begin(this);

                if (_scrollable != null)
                {
                    _scrollable.Update(gameTime);
                }

                ScrollableGame.End(this);
            }

            UpdateContentSize();

            base.Update(gameTime);
        }