示例#1
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // TODO: Add your update logic here
            hScrollbar.Update(gameTime);
            vScrollbar.Update(gameTime);

            if (isResizing && MouseHelper.IsReleased)
            {
                isResizing = false;
            }

            selectionArea.X      = (int)(Owner.Position.X + Position.X);
            selectionArea.Y      = (int)(Owner.Position.Y + Position.Y);
            selectionArea.Width  = (int)area.Width;
            selectionArea.Height = (int)area.Height;

            if (headerStyle != ListviewHeaderStyle.None)
            {
                selectionArea.Y      += Font.LineSpacing;
                selectionArea.Height -= Font.LineSpacing;
            }

            if (vScrollbar.Max > 0)
            {
                selectionArea.Width -= 12;
            }
            if (hScrollbar.Max > 0)
            {
                selectionArea.Height -= 12;
            }

            if (hoverRowIndex != -1)
            {
                UpdateSelection();
            }

            //ColumnHeader_OnRelease
            if (headerStyle == ListviewHeaderStyle.Clickable && headerHoverIndex != -1 &&
                MouseHelper.HasBeenReleased && columnHeader[headerHoverIndex].OnRelease != null)
            {
                columnHeader[headerHoverIndex].OnRelease(null, null);
                headerHoverIndex = -1;
            }
        }
示例#2
0
        private void UpdateScrollbars(GameTime gameTime)
        {
            if (vscrollbar != null)
            {
                if (hscrollbar != null && hscrollbar.Max > 0)
                {
                    vscrollbar.Max = System.Math.Max(0, line.Count - (visibleLines - 1));
                }
                else
                {
                    vscrollbar.Max = System.Math.Max(0, line.Count - visibleLines);
                }
            }


            if (vscrollbar != null && vscrollbar.Max > 0)
            {
                if (hscrollbar != null && hscrollbar.Max > 0)
                {
                    vscrollbar.Height = Height - 13;
                }
                else
                {
                    vscrollbar.Height = Height - 2;
                }

                vscrollbar.Update(gameTime);
            }

            if (hscrollbar != null && hscrollbar.Max > 0)
            {
                if (vscrollbar != null && vscrollbar.Max > 0)
                {
                    hscrollbar.Width = Width - 13;
                }
                else
                {
                    hscrollbar.Width = Width - 2;
                }

                hscrollbar.Update(gameTime);
            }
        }
示例#3
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            // TODO: Add your update logic here
            if (vscrollbar != null && vscrollbar.Visible)
            {
                vscrollbar.Update(gameTime);
            }
            if (horizontalScrollbar && hscrollbar != null && hscrollbar.Visible)
            {
                hscrollbar.Update(gameTime);
            }

            if (!isSorted && sorted)
            {
                items.Sort();
            }

            if (FormCollection.TopMostForm == Owner)
            {
                if (hoverIndex != -1 && MouseHelper.HasBeenPressed)
                {
                    int previousIndex = selectedIndex;
                    selectedIndex = hoverIndex;
                    if (OnSelect != null)
                    {
                        OnSelect(items[selectedIndex], null);
                    }
                    if (selectedIndex != previousIndex && OnChangeSelection != null)
                    {
                        OnChangeSelection(items[selectedIndex], null);
                    }
                }

                if (area.Contains(MouseHelper.Cursor.Location))
                {
                    if (!bMouseOver)
                    {
                        bMouseOver = true;
                        if (OnMouseOver != null)
                        {
                            OnMouseOver(this, null);
                        }
                    }

                    if (MouseHelper.HasBeenPressed && OnPress != null)
                    {
                        OnPress(this, null);
                    }
                    else if (MouseHelper.HasBeenReleased && OnRelease != null)
                    {
                        OnRelease(this, null);
                    }
                }
                else if (bMouseOver)
                {
                    bMouseOver = false;
                    if (OnMouseOut != null)
                    {
                        OnMouseOut(this, null);
                    }
                }
            }
        }