Esempio n. 1
0
        /// <summary>
        /// Draw the entity.
        /// </summary>
        /// <param name="spriteBatch">Sprite batch to draw on.</param>
        override protected void DrawEntity(SpriteBatch spriteBatch)
        {
            // get mouse state for graphics
            EntityState state = _entityState;

            if (Checked)
            {
                state = EntityState.MouseDown;
            }

            // get texture based on skin and state
            Texture2D texture = _customSkin == null ? Resources.ButtonTextures[(int)_skin, (int)state] : _customSkin[(int)state];

            // get frame width
            TextureData data      = Resources.ButtonData[(int)_skin];
            Vector2     frameSize = _customSkin == null ? new Vector2(data.FrameWidth, data.FrameHeight) : _customFrame;

            // draw the button background with frame
            if (frameSize.Length() > 0)
            {
                float scale = frameSize.Y > 0 ? Scale : 1f;
                DrawUtils.DrawSurface(spriteBatch, texture, _destRect, frameSize, 1, FillColor, scale);
            }
            // draw the button background without frame (just stretch texture)
            else
            {
                DrawUtils.DrawImage(spriteBatch, texture, _destRect, FillColor, 1);
            }

            // call base draw function
            base.DrawEntity(spriteBatch);
        }
Esempio n. 2
0
        /// <summary>
        /// Draw the entity.
        /// </summary>
        /// <param name="spriteBatch">Sprite batch to draw on.</param>
        override protected void DrawEntity(SpriteBatch spriteBatch)
        {
            // get textures based on type
            Texture2D texture     = Resources.VerticalScrollbarTexture;
            Texture2D markTexture = Resources.VerticalScrollbarMarkTexture;
            float     FrameHeight = Resources.VerticalScrollbarData.FrameHeight;

            // draw scrollbar body
            DrawUtils.DrawSurface(spriteBatch, texture, _destRect, new Vector2(0f, FrameHeight), 1, FillColor);

            // calc frame actual height and scaling factor (this is needed to calc frame width in pixels)
            Vector2 frameSizeTexture = new Vector2(texture.Width, texture.Height * FrameHeight);
            Vector2 frameSizeRender  = frameSizeTexture;
            float   ScaleYfac        = _destRect.Width / frameSizeRender.X;

            // calc the size of the mark piece
            int markWidth = _destRect.Width;

            _markHeight = (int)(((float)markTexture.Height / (float)markTexture.Width) * (float)markWidth);

            // calc frame width in pixels
            _frameActualHeight = FrameHeight * texture.Height * ScaleYfac * UserInterface.SCALE;

            // now draw mark
            float     markY    = _destRect.Y + _frameActualHeight + _markHeight * 0.5f + (_destRect.Height - _frameActualHeight * 2 - _markHeight) * (GetValueAsPercent());
            Rectangle markDest = new Rectangle(_destRect.X, (int)System.Math.Round(markY) - _markHeight / 2, markWidth, _markHeight);

            DrawUtils.DrawImage(spriteBatch, markTexture, markDest, FillColor);
        }
        /// <summary>
        /// Draw the entity.
        /// </summary>
        /// <param name="spriteBatch">Sprite batch to draw on.</param>
        override protected void DrawEntity(SpriteBatch spriteBatch)
        {
            // get textures based on skin
            Texture2D texture     = Resources.SliderTextures[(int)_skin];
            Texture2D markTexture = Resources.SliderMarkTextures[(int)_skin];

            // get slider metadata
            DataTypes.TextureData data = Resources.SliderData[(int)_skin];
            float frameWidth           = data.FrameWidth;

            // draw slider body
            DrawUtils.DrawSurface(spriteBatch, texture, _destRect, new Vector2(frameWidth, 0f), 1, FillColor);

            // calc frame actual height and scaling factor (this is needed to calc frame width in pixels)
            Vector2 frameSizeTexture = new Vector2(texture.Width * frameWidth, texture.Height);
            Vector2 frameSizeRender  = frameSizeTexture;
            float   ScaleXfac        = _destRect.Height / frameSizeRender.Y;

            // calc the size of the mark piece
            int markHeight = _destRect.Height;

            _markWidth = (int)(((float)markTexture.Width / (float)markTexture.Height) * (float)markHeight);

            // calc frame width in pixels
            _frameActualWidth = frameWidth * texture.Width * ScaleXfac;

            // now draw mark
            float     markX    = _destRect.X + _frameActualWidth + _markWidth * 0.5f + (_destRect.Width - _frameActualWidth * 2 - _markWidth) * GetValueAsPercent();
            Rectangle markDest = new Rectangle((int)System.Math.Round(markX) - _markWidth / 2, _destRect.Y, _markWidth, markHeight);

            DrawUtils.DrawImage(spriteBatch, markTexture, markDest, FillColor);

            // call base draw function
            base.DrawEntity(spriteBatch);
        }
Esempio n. 4
0
        /// <summary>
        /// Draw the entity.
        /// </summary>
        /// <param name="spriteBatch">Sprite batch to draw on.</param>
        override protected void DrawEntity(SpriteBatch spriteBatch)
        {
            // draw image based on DrawMode
            switch (DrawMode)
            {
            // panel mode
            case ImageDrawMode.Panel:
                DrawUtils.DrawSurface(spriteBatch, Texture, _destRect, FrameWidth, Scale, FillColor);
                break;

            // stretch mode
            case ImageDrawMode.Stretch:
                DrawUtils.DrawImage(spriteBatch, Texture, _destRect, FillColor, Scale);
                break;
            }

            // call base draw function
            base.DrawEntity(spriteBatch);
        }
Esempio n. 5
0
        /// <summary>
        /// Draw the entity.
        /// </summary>
        /// <param name="spriteBatch">Sprite batch to draw on.</param>
        override protected void DrawEntity(SpriteBatch spriteBatch)
        {
            // draw background
            if (DrawBackground)
            {
                // when draw background we recalc dest rect with minimal padding
                Vector2 prevSpaceBefore = SpaceBefore;
                SpaceBefore       = new Vector2(System.Math.Max(7, SpaceBefore.X), System.Math.Max(12, SpaceBefore.Y));
                _destRect         = CalcDestRect();
                _destRectInternal = CalcInternalRect();
                SpaceBefore       = prevSpaceBefore;

                // get background dest rect
                Rectangle dest = _destRect;
                dest.X -= 5; dest.Y -= 5; dest.Width += 10; dest.Height += 10;
                DrawUtils.DrawImage(spriteBatch, Resources.IconBackgroundTexture, dest, Color.White);
            }

            // now draw the image itself
            base.DrawEntity(spriteBatch);
        }