コード例 #1
0
        public override void Render(YSpriteBatch batch, Rectangle area, Color? color = null)
        {
            Color Color = (color == null) ? Color.White : color.Value;
            Rectangle drawArea;

            int left_width = m_LeftBorderIsRightBorderReversed ? m_Right.Width : m_Left.Width;

            // ##### Draw Left portion ##### //
            drawArea = new Rectangle(
                area.Left,
                area.Top,
                left_width,
                m_Left.Height);
            batch.GUIDrawSprite(Texture, drawArea,
                m_LeftBorderIsRightBorderReversed ? m_Right : m_Left, Color,
                effects: m_LeftBorderIsRightBorderReversed ? SpriteEffects.FlipHorizontally : SpriteEffects.None);

            // ##### Draw Center portion ##### //
            drawArea = new Rectangle(
                area.Left + left_width,
                area.Top,
                area.Width - left_width - m_Right.Width,
                m_Center.Height);
            batch.GUIDrawSprite(Texture, drawArea, m_Center, Color);

            // ##### Draw Right portion ##### //
            drawArea = new Rectangle(
                area.Right - m_Right.Width,
                area.Top,
                m_Right.Width,
                m_Right.Height);
            batch.GUIDrawSprite(Texture, drawArea, m_Right, Color);
        }
コード例 #2
0
        public override void Render(YSpriteBatch batch, Rectangle area, Color? color = null)
        {
            Color Color = (color == null) ? Color.White : color.Value;

            // ##### Draw Background ##### //
            Rectangle drawArea = new Rectangle(
                area.Left + BorderWidth,
                area.Top + BorderWidth,
                area.Width - (2 * BorderWidth),
                area.Height - (2 * BorderWidth));
            batch.GUIDrawSprite(Texture, drawArea, m_BG, Color);

            // ##### Draw Corners ##### //
            drawArea.Width = BorderWidth;
            drawArea.Height = BorderWidth;

            //Top Left
            drawArea.X = area.Left;
            drawArea.Y = area.Top;
            batch.GUIDrawSprite(Texture, drawArea, m_UL, Color);

            //Top Right
            drawArea.X = area.Right - BorderWidth;
            drawArea.Y = area.Top;
            batch.GUIDrawSprite(Texture, drawArea, m_UR, Color);

            //Bottom Right
            drawArea.X = area.Right - BorderWidth;
            drawArea.Y = area.Bottom - BorderWidth;
            batch.GUIDrawSprite(Texture, drawArea, m_LR, Color);

            //Bottom Left
            drawArea.X = area.Left;
            drawArea.Y = area.Bottom - BorderWidth;
            batch.GUIDrawSprite(Texture, drawArea, m_LL, Color);

            // ##### Draw Edges ##### //

            //Top Edge
            drawArea.X = area.Left + BorderWidth;
            drawArea.Y = area.Top;
            drawArea.Width = area.Width - (2 * BorderWidth);
            batch.GUIDrawSprite(Texture, drawArea, m_T, Color);

            //Bottom Edge
            drawArea.Y = area.Bottom - BorderWidth;
            batch.GUIDrawSprite(Texture, drawArea, m_B, Color);

            //Left Edge
            drawArea.X = area.Left;
            drawArea.Y = area.Top + BorderWidth;
            drawArea.Width = BorderWidth;
            drawArea.Height = area.Height - (2 * BorderWidth);
            batch.GUIDrawSprite(Texture, drawArea, m_L, Color);

            //Right Edge
            drawArea.X = area.Right - BorderWidth;
            batch.GUIDrawSprite(Texture, drawArea, m_R, Color);
        }
コード例 #3
0
ファイル: ImageBoxView.cs プロジェクト: FreeReign/UltimaXNA
        protected override void InternalDraw(YSpriteBatch spritebatch, double frameTime)
        {
            Color background = new Color(32, 32, 32, 255);
            Color border = Color.LightGray;

            DrawCommon_FillBackground(spritebatch, background);

            if (Model.Texture != null)
            {
                Rectangle area = Model.ScreenArea;
                area.X += 1;
                area.Y += 1;
                area.Width -= 2;
                area.Height -= 2;
                Texture2D texture = Model.Texture;

                if (Model.StretchImage)
                {
                    spritebatch.GUIDrawSprite(Model.Texture, Model.ScreenArea);
                }
                else if (texture.Width <= area.Width && texture.Height <= area.Height)
                {
                    Point xy = Model.Centered ? new Point(
                        area.X + (area.Width - texture.Width) / 2,
                        area.Y + (area.Height - texture.Height) / 2) :
                        new Point(area.X, area.Y);
                    Rectangle dest = new Rectangle(
                        xy.X, xy.Y,
                        texture.Width,
                        texture.Height);
                    spritebatch.GUIDrawSprite(Model.Texture, dest);
                }
                else
                {
                    float reduce_value = 1f;
                    if (texture.Width >= texture.Height)
                        reduce_value = ((float)area.Width / texture.Width);
                    else
                        reduce_value = ((float)area.Height / texture.Height);
                    Point xy = Model.Centered ? new Point(
                        area.X + area.Width - (int)(texture.Width * reduce_value),
                        area.Y + area.Height - (int)(texture.Height * reduce_value)) :
                        new Point(area.X, area.Y);
                    Rectangle dest = new Rectangle(
                        xy.X, xy.Y,
                        (int)(texture.Width * reduce_value),
                        (int)(texture.Height * reduce_value));
                    spritebatch.GUIDrawSprite(Model.Texture, dest);
                }
            }

            DrawCommon_Border(spritebatch, border);
        }
コード例 #4
0
        public override void Render(YSpriteBatch batch, Rectangle destination, Color? color = null)
        {
            Color Color = (color == null) ? Color.White : color.Value;
            Rectangle drawArea = new Rectangle(destination.Left, destination.Top, m_edge.Width, m_edge.Height);

            batch.GUIDrawSprite(Texture, drawArea, m_edge, Color, SpriteEffects.FlipHorizontally);

            drawArea.X = destination.Right - m_edge.Width;
            batch.GUIDrawSprite(Texture, drawArea, m_edge, Color);

            drawArea.X = destination.Left + m_edge.Width;
            drawArea.Width = destination.Width - (2 * m_edge.Width);
            batch.GUIDrawSprite(Texture, drawArea, m_center, Color);
        }
コード例 #5
0
ファイル: IconRenderer.cs プロジェクト: FreeReign/UltimaXNA
 public override void Render(YSpriteBatch batch, Rectangle area, Color? color = null)
 {
     Color Color = (color == null) ? Color.White : color.Value;
     // ##### Draw Icon ##### //
     Rectangle drawArea = new Rectangle(
         area.Left,
         area.Top,
         m_Icon.Width,
         m_Icon.Height);
     batch.GUIDrawSprite(Texture, drawArea, m_Icon, Color);
 }
コード例 #6
0
ファイル: TabBarRenderer.cs プロジェクト: FreeReign/UltimaXNA
        public override void Render(YSpriteBatch batch, Rectangle area, Color? color = null)
        {
            Color Color = (color == null) ? Color.White : color.Value;
            Rectangle drawArea;

            int x = 0;

            if (DrawTabs)
            {
                // draw bar to the left of the tab area
                if (m_TabSpaceBegin > 0)
                {
                    drawArea = new Rectangle(area.X, area.Y, m_TabSpaceBegin, area.Height);
                    batch.GUIDrawSprite(Texture, drawArea, m_Bar, Color);
                    x += m_TabSpaceBegin;
                }

                // draw the left tab area edge
                drawArea = new Rectangle(area.X + x, area.Y, m_TabAreaEdge.Width, area.Height);
                batch.GUIDrawSprite(Texture, drawArea, m_TabAreaEdge, effects: SpriteEffects.FlipHorizontally);
                x += m_TabAreaEdge.Width;

                // draw the tab area
                drawArea = new Rectangle(area.X + x, area.Y, m_TabSpaceWidth - m_TabAreaEdge.Width * 2, area.Height);
                batch.GUIDrawSprite(Texture, drawArea, m_TabArea, Color);
                x += drawArea.Width;

                // draw the right tab area edge
                drawArea = new Rectangle(area.X + x, area.Y, m_TabAreaEdge.Width, area.Height);
                batch.GUIDrawSprite(Texture, drawArea, m_TabAreaEdge, Color);
                x += m_TabAreaEdge.Width;
            }

            // draw bar over remainder of width
            if (x < area.Width)
            {
                drawArea = new Rectangle(area.X + x, area.Y, area.Width - x, area.Height);
                batch.GUIDrawSprite(Texture, drawArea, m_Bar, Color);
            }
        }