Exemplo n.º 1
0
        public WindowTexture(Texture2D texture, int spriteWidth, int spriteHeight)
        {
            texture.ThrowIfNull("texture");

            _texture = texture;
            _spriteWidth = spriteWidth;
            _spriteHeight = spriteHeight;
            _padding = new Padding(spriteWidth, spriteHeight);
            _borderTopLeftRectangle = new Rectangle(0, 0, spriteWidth, spriteHeight);
            _borderTopRectangle = new Rectangle(spriteWidth, 0, spriteWidth, spriteHeight);
            _borderTopRightRectangle = new Rectangle(spriteWidth * 2, 0, spriteWidth, spriteHeight);
            _borderRightRectangle = new Rectangle(spriteWidth * 2, spriteHeight, spriteWidth, spriteHeight);
            _borderBottomRightRectangle = new Rectangle(spriteWidth * 2, spriteHeight * 2, spriteWidth, spriteHeight);
            _borderBottomRectangle = new Rectangle(spriteWidth, spriteHeight * 2, spriteWidth, spriteHeight);
            _borderBottomLeftRectangle = new Rectangle(0, spriteHeight * 2, spriteWidth, spriteHeight);
            _borderTextureLeftRectangle = new Rectangle(0, spriteHeight, spriteWidth, spriteHeight);
            _backgroundTopLeftRectangle = new Rectangle(0, spriteHeight * 3, spriteWidth, spriteHeight);
            _backgroundTopRectangle = new Rectangle(spriteWidth, spriteHeight * 3, spriteWidth, spriteHeight);
            _backgroundTopRightRectangle = new Rectangle(spriteWidth * 2, spriteHeight * 3, spriteWidth, spriteHeight);
            _backgroundRightRectangle = new Rectangle(spriteWidth * 2, spriteHeight + (spriteHeight * 3), spriteWidth, spriteHeight);
            _backgroundBottomRightRectangle = new Rectangle(spriteWidth * 2, (spriteHeight * 2) + (spriteHeight * 3), spriteWidth, spriteHeight);
            _backgroundBottomRectangle = new Rectangle(spriteWidth, (spriteHeight * 2) + (spriteHeight * 3), spriteWidth, spriteHeight);
            _backgroundBottomLeftRectangle = new Rectangle(0, (spriteHeight * 2) + (spriteHeight * 3), spriteWidth, spriteHeight);
            _backgroundLeftRectangle = new Rectangle(0, spriteHeight + (spriteHeight * 3), spriteWidth, spriteHeight);
            _backgroundCenterRectangle = new Rectangle(spriteWidth, spriteHeight + (spriteHeight * 3), spriteWidth, spriteHeight);
            _upArrowRectangle = new Rectangle(spriteWidth * 3, 0, spriteWidth, spriteHeight);
            _downArrowRectangle = new Rectangle(spriteWidth * 3, spriteHeight, spriteWidth, spriteHeight);
        }
Exemplo n.º 2
0
        public BorderedWindow(Rectangle windowRectangle, Padding padding)
            : base(windowRectangle)
        {
            Rectangle absoluteClientRectangle = windowRectangle;

            absoluteClientRectangle.X += padding.Left;
            absoluteClientRectangle.Y += padding.Top;
            absoluteClientRectangle.Width -= padding.X;
            absoluteClientRectangle.Height -= padding.Y;

            _absoluteClientRectangle = absoluteClientRectangle;
            _relativeClientRectangle = new Rectangle(padding.Left, padding.Top, windowRectangle.Width - padding.X, windowRectangle.Height - padding.Y);
            _topLeftCornerRectangle = new Rectangle(
                WindowRectangle.X,
                WindowRectangle.Y,
                _relativeClientRectangle.X,
                _relativeClientRectangle.Y);
            _topRightCornerRectangle = new Rectangle(
                _absoluteClientRectangle.Right,
                WindowRectangle.Y,
                WindowRectangle.Right - _absoluteClientRectangle.Right,
                _relativeClientRectangle.Y);
            _bottomLeftCornerRectangle = new Rectangle(
                WindowRectangle.X,
                _absoluteClientRectangle.Bottom,
                _relativeClientRectangle.X,
                WindowRectangle.Bottom - _absoluteClientRectangle.Bottom);
            _bottomRightCornerRectangle = new Rectangle(
                _absoluteClientRectangle.Right,
                _absoluteClientRectangle.Bottom,
                WindowRectangle.Right - _absoluteClientRectangle.Right,
                WindowRectangle.Bottom - _absoluteClientRectangle.Bottom);
            _leftRectangle = new Rectangle(
                WindowRectangle.X,
                _absoluteClientRectangle.Y,
                _relativeClientRectangle.X,
                _relativeClientRectangle.Height);
            _rightRectangle = new Rectangle(
                _absoluteClientRectangle.Right,
                _absoluteClientRectangle.Y,
                WindowRectangle.Right - _absoluteClientRectangle.Right,
                _relativeClientRectangle.Height);
            _topRectangle = new Rectangle(
                _absoluteClientRectangle.X,
                WindowRectangle.Y,
                _relativeClientRectangle.Width,
                _relativeClientRectangle.Y);
            _bottomRectangle = new Rectangle(
                _absoluteClientRectangle.X,
                _absoluteClientRectangle.Bottom,
                _relativeClientRectangle.Width,
                WindowRectangle.Bottom - _absoluteClientRectangle.Bottom);
            _centerRectangle = _absoluteClientRectangle;
        }
        protected void SetWindowRectangleUsingWindowYAndWindowSize(WindowHorizontalAlignment alignment, int windowY, int windowWidth, int windowHeight, Padding padding)
        {
            Rectangle windowDestinationRectangle = Constants.GameWindow.DestinationRectangle;
            Point windowCenterPoint = windowDestinationRectangle.Center;
            Rectangle windowRectangle;

            switch (alignment)
            {
                case WindowHorizontalAlignment.Left:
                    windowRectangle = new Rectangle(0, windowY, windowWidth, windowHeight);
                    break;
                case WindowHorizontalAlignment.Center:
                    windowRectangle = new Rectangle(windowCenterPoint.X - (windowWidth / 2), windowY, windowWidth, windowHeight);
                    break;
                case WindowHorizontalAlignment.Right:
                    windowRectangle = new Rectangle(windowDestinationRectangle.Right - windowWidth, windowY, windowWidth, windowHeight);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("alignment");
            }

            Window = new BorderedWindow(windowRectangle, padding);
        }
 protected void SetWindowRectangleUsingWindowYAndClientSize(WindowHorizontalAlignment alignment, int windowY, int clientWidth, int clientHeight, Padding padding)
 {
     SetWindowRectangleUsingWindowYAndWindowSize(alignment, windowY, clientWidth + padding.X, clientHeight + padding.Y, padding);
 }
        protected void SetWindowRectangleUsingWindowXAndWindowSize(WindowVerticalAlignment alignment, int windowX, int windowWidth, int windowHeight, Padding padding)
        {
            Rectangle windowDestinationRectangle = Constants.GameWindow.DestinationRectangle;
            Point windowCenterPoint = windowDestinationRectangle.Center;
            Rectangle windowRectangle;

            switch (alignment)
            {
                case WindowVerticalAlignment.Top:
                    windowRectangle = new Rectangle(windowX, 0, windowWidth, windowHeight);
                    break;
                case WindowVerticalAlignment.Center:
                    windowRectangle = new Rectangle(windowX, windowCenterPoint.Y - (windowHeight / 2), windowWidth, windowHeight);
                    break;
                case WindowVerticalAlignment.Bottom:
                    windowRectangle = new Rectangle(windowX, windowDestinationRectangle.Bottom - windowHeight, windowWidth, windowHeight);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("alignment");
            }

            Window = new BorderedWindow(windowRectangle, padding);
        }
 protected void SetWindowRectangleUsingWindowLocationAndClientSize(int windowX, int windowY, int clientWidth, int clientHeight, Padding padding)
 {
     Window = new BorderedWindow(new Rectangle(windowX, windowY, clientWidth + padding.X, clientHeight + padding.Y), padding);
 }
 protected void SetWindowRectangleUsingClientSize(WindowAlignment alignment, int clientWidth, int clientHeight, Padding padding)
 {
     SetWindowRectangle(alignment, clientWidth + padding.X, clientHeight + padding.Y, padding);
 }
 protected void SetWindowRectangleUsingClientLocationAndClientSize(int clientX, int clientY, int clientWidth, int clientHeight, Padding padding)
 {
     Window = new BorderedWindow(new Rectangle(clientX - padding.Left, clientY - padding.Top, clientWidth + padding.X, clientHeight + padding.Y), padding);
 }
        protected void SetWindowRectangle(WindowAlignment alignment, int windowWidth, int windowHeight, Padding padding)
        {
            Rectangle windowDestinationRectangle = Constants.GameWindow.DestinationRectangle;
            Point windowCenterPoint = windowDestinationRectangle.Center;
            Rectangle rectangle;

            switch (alignment)
            {
                case WindowAlignment.TopLeft:
                    rectangle = new Rectangle(0, 0, windowWidth, windowHeight);
                    break;
                case WindowAlignment.TopCenter:
                    rectangle = new Rectangle(windowCenterPoint.X - (windowWidth / 2), 0, windowWidth, windowHeight);
                    break;
                case WindowAlignment.TopRight:
                    rectangle = new Rectangle(windowDestinationRectangle.Right - windowWidth, 0, windowWidth, windowHeight);
                    break;
                case WindowAlignment.RightCenter:
                    rectangle = new Rectangle(windowDestinationRectangle.Right - windowWidth, windowCenterPoint.Y - (windowHeight / 2), windowWidth, windowHeight);
                    break;
                case WindowAlignment.BottomRight:
                    rectangle = new Rectangle(windowDestinationRectangle.Right - windowWidth, windowDestinationRectangle.Bottom - windowHeight, windowWidth, windowHeight);
                    break;
                case WindowAlignment.BottomCenter:
                    rectangle = new Rectangle(windowCenterPoint.X - (windowWidth / 2), windowDestinationRectangle.Bottom - windowHeight, windowWidth, windowHeight);
                    break;
                case WindowAlignment.BottomLeft:
                    rectangle = new Rectangle(0, windowDestinationRectangle.Bottom - windowHeight, windowWidth, windowHeight);
                    break;
                case WindowAlignment.LeftCenter:
                    rectangle = new Rectangle(0, windowCenterPoint.Y - (windowHeight / 2), windowWidth, windowHeight);
                    break;
                case WindowAlignment.Center:
                    rectangle = new Rectangle(windowCenterPoint.X - (windowWidth / 2), windowCenterPoint.Y - (windowHeight / 2), windowWidth, windowHeight);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("alignment");
            }

            Window = new BorderedWindow(rectangle, padding);
        }
 protected void SetWindowRectangle(int x, int y, int width, int height, Padding padding)
 {
     Window = new BorderedWindow(new Rectangle(x, y, width, height), padding);
 }
 protected void SetWindowRectangle(Rectangle windowRectangle, Padding padding)
 {
     Window = new BorderedWindow(windowRectangle, padding);
 }
 public void Update(Rectangle windowRectangle, Padding padding, Color color, float alpha, Rectangle scissorRectangle, Matrix transformMatrix)
 {
     SetWindowRectangle(windowRectangle, padding);
     BackgroundColor = color;
     BorderColor = color;
     Alpha = alpha;
     _scissorRectangle = scissorRectangle;
     _transformMatrix = transformMatrix;
 }