示例#1
0
        static Vector2 GetSpriteSize(SpriteControl spriteControl)
        {
            if (spriteControl == null)
            {
                return(Vector2.Zero);
            }

            if (spriteControl.Sprite == null)
            {
                return(Vector2.Zero);
            }

            var src = spriteControl.Sprite.Source;

            return(new Vector2(src.Width, src.Height));
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ListBox{T}"/> class.
        /// </summary>
        /// <param name="guiManager">The GUI manager this <see cref="Control"/> will be managed by.</param>
        /// <param name="position">Position of the Control reletive to its parent.</param>
        /// <param name="clientSize">The size of the <see cref="Control"/>'s client area.</param>
        /// <exception cref="ArgumentNullException"><paramref name="guiManager"/> is null.</exception>
        public ListBox(IGUIManager guiManager, Vector2 position, Vector2 clientSize) : base(guiManager, position, clientSize)
        {
            // ReSharper disable DoNotCallOverridableMethodsInConstructor
            if (Font != null)
            {
                ItemHeight = Font.GetLineSpacing();
            }
            else
            {
                ItemHeight = 12;
            }

            _itemDrawer = GetDefaultItemDrawer();
            // ReSharper restore DoNotCallOverridableMethodsInConstructor

            // Create the buttons
            _btnFirst = new PagedListButton(this, "First", () => CurrentPage = 1);
            _btnPrev  = new PagedListButton(this, "Previous", () => CurrentPage--);
            _btnNext  = new PagedListButton(this, "Next", () => CurrentPage++);
            _btnLast  = new PagedListButton(this, "Last", () => CurrentPage = NumPages);

            UpdateButtonPositions();
        }