コード例 #1
0
        // I/F
        public virtual void Draw(Control control, IDrawContext drawContext)
        {
            if (control.Focused)
            {
                if (FocusTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), FocusTexture, FocusColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), FocusColor);
                }
            }

            if (control.MouseOver)
            {
                if (MouseOverTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), MouseOverTexture, MouseOverColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), MouseOverColor);
                }
            }
        }
コード例 #2
0
        // I/F
        public virtual void Draw(Control control, IDrawContext drawContext)
        {
            if (control.Focused)
            {
                if (FocusTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), FocusTexture, FocusColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), FocusColor);
                }
            }

            if (control.MouseOver)
            {
                if (MouseOverTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), MouseOverTexture, MouseOverColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), MouseOverColor);
                }
            }
        }
コード例 #3
0
ファイル: Image.cs プロジェクト: willcraftia/Blocks
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            if (Texture != null)
                drawContext.DrawTexture(new Rect(Vector2.Zero, RenderSize), Texture, BackgroundColor);
        }
コード例 #4
0
 // I/F
 public virtual void Draw(Control control, IDrawContext drawContext)
 {
     if (Texture != null)
     {
         drawContext.DrawTexture(new Rect(control.RenderSize), Texture, Color);
     }
 }
コード例 #5
0
        public override void Draw(GameTime gameTime, IDrawContext drawContext)
        {
            base.Draw(gameTime, drawContext);

            if (Texture != null)
            {
                drawContext.DrawTexture(new Rect(Vector2.Zero, RenderSize), Texture, BackgroundColor);
            }
        }
コード例 #6
0
        // I/F
        public virtual void Draw(Control control, IDrawContext drawContext)
        {
            if (control.Focused)
            {
                if (FocusTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), FocusTexture, FocusColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), FocusColor);
                }
            }

            if (control.MouseOver)
            {
                if (MouseOverTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), MouseOverTexture, MouseOverColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), MouseOverColor);
                }
            }

            var listBoxItem = control as ListBoxItem;

            if (listBoxItem != null && listBoxItem.IsSelected)
            {
                if (SelectionTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), SelectionTexture, SelectionColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), SelectionColor);
                }
            }
        }
コード例 #7
0
        // I/F
        public virtual void Draw(Control control, IDrawContext drawContext)
        {
            if (control.Focused)
            {
                if (FocusTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), FocusTexture, FocusColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), FocusColor);
                }
            }

            if (control.MouseOver)
            {
                if (MouseOverTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), MouseOverTexture, MouseOverColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), MouseOverColor);
                }
            }

            var listBoxItem = control as ListBoxItem;
            if (listBoxItem != null && listBoxItem.IsSelected)
            {
                if (SelectionTexture != null)
                {
                    drawContext.DrawTexture(new Rect(control.RenderSize), SelectionTexture, SelectionColor);
                }
                else
                {
                    drawContext.DrawRectangle(new Rect(control.RenderSize), SelectionColor);
                }
            }
        }
コード例 #8
0
 // I/F
 public virtual void Draw(Control control, IDrawContext drawContext)
 {
     if (Texture != null)
         drawContext.DrawTexture(new Rect(control.RenderSize), Texture, Color);
 }
コード例 #9
0
        protected virtual void DrawWindow(Window window, IDrawContext drawContext, SpriteSheet spriteSheet, Color color, Vector2 offset)
        {
            var renderSize = window.RenderSize;
            var texture    = spriteSheet.Texture;

            var template = spriteSheet.Template as WindowSpriteSheetTemplate;
            int w        = template.SpriteWidth;
            int h        = template.SpriteHeight;

            // 計算誤差の問題から先に int 化しておきます。
            int offsetX      = (int)offset.X;
            int offsetY      = (int)offset.Y;
            int renderWidth  = (int)renderSize.Width;
            int renderHeight = (int)renderSize.Height;

            var       bounds = new Rect();
            Rectangle sourceRectangle;

            // Top Lines
            {
                int adjustedH = AdjustHeight(renderHeight, offsetY, h, offsetY);
                int adjustedW = AdjustWidth(renderWidth, offsetX, w, offsetX);
                bounds.Height = adjustedH;
                bounds.Width  = adjustedW;

                sourceRectangle        = spriteSheet.Template[WindowSpriteSheetTemplate.TopLeft];
                sourceRectangle.Width  = adjustedW;
                sourceRectangle.Height = adjustedH;
                bounds.X     = offsetX;
                bounds.Y     = offsetY;
                bounds.Width = sourceRectangle.Width;
                drawContext.DrawTexture(bounds, texture, color, sourceRectangle);

                sourceRectangle        = spriteSheet.Template[WindowSpriteSheetTemplate.Top];
                sourceRectangle.Height = adjustedH;
                for (int x = w + offsetX; x < renderWidth + offsetX - w; x += w)
                {
                    adjustedW = AdjustWidth(renderWidth, offsetX, w, x);

                    sourceRectangle.Width = adjustedW;
                    bounds.X     = x;
                    bounds.Width = adjustedW;
                    drawContext.DrawTexture(bounds, texture, color, sourceRectangle);
                }

                sourceRectangle        = spriteSheet.Template[WindowSpriteSheetTemplate.TopRight];
                sourceRectangle.Height = adjustedH;
                bounds.X     = renderWidth + offsetX - w;
                bounds.Width = w;
                drawContext.DrawTexture(bounds, texture, color, sourceRectangle);
            }

            // Middle Lines
            for (int y = h + offsetY; y < renderHeight + offsetY - h; y += h)
            {
                int adjustedW = AdjustWidth(renderWidth, offsetX, w, offsetX);
                int adjustedH = AdjustHeight(renderHeight, offsetY, h, y);

                sourceRectangle        = spriteSheet.Template[WindowSpriteSheetTemplate.Left];
                sourceRectangle.Width  = adjustedW;
                sourceRectangle.Height = adjustedH;
                bounds.X      = offsetX;
                bounds.Y      = y;
                bounds.Width  = adjustedW;
                bounds.Height = adjustedH;
                drawContext.DrawTexture(bounds, texture, color, sourceRectangle);

                sourceRectangle        = spriteSheet.Template[WindowSpriteSheetTemplate.Fill];
                sourceRectangle.Height = adjustedH;
                for (int x = w + offsetX; x < renderWidth + offsetX - w; x += w)
                {
                    adjustedW = AdjustWidth(renderWidth, offsetX, w, x);

                    sourceRectangle.Width = adjustedW;
                    bounds.X     = x;
                    bounds.Width = adjustedW;
                    drawContext.DrawTexture(bounds, texture, color, sourceRectangle);
                }

                sourceRectangle        = spriteSheet.Template[WindowSpriteSheetTemplate.Right];
                sourceRectangle.Height = adjustedH;
                bounds.X     = renderWidth + offsetX - w;
                bounds.Width = w;
                drawContext.DrawTexture(bounds, texture, color, sourceRectangle);
            }

            // Bottom Lines
            {
                int adjustedW = AdjustWidth(renderWidth, offsetX, w, offsetX);

                sourceRectangle       = spriteSheet.Template[WindowSpriteSheetTemplate.BottomLeft];
                sourceRectangle.Width = adjustedW;
                bounds.X      = offsetX;
                bounds.Y      = renderHeight + offsetY - h;
                bounds.Width  = adjustedW;
                bounds.Height = h;
                drawContext.DrawTexture(bounds, texture, color, sourceRectangle);

                sourceRectangle = spriteSheet.Template[WindowSpriteSheetTemplate.Bottom];
                for (int x = w + offsetX; x < renderWidth + offsetX - w; x += w)
                {
                    adjustedW = AdjustWidth(renderWidth, offsetX, w, x);

                    sourceRectangle.Width = adjustedW;
                    bounds.X     = x;
                    bounds.Width = adjustedW;
                    drawContext.DrawTexture(bounds, texture, color, sourceRectangle);
                }
                bounds.Width = w;

                sourceRectangle = spriteSheet.Template[WindowSpriteSheetTemplate.BottomRight];
                bounds.X        = renderWidth + offsetX - w;
                drawContext.DrawTexture(bounds, texture, color, sourceRectangle);
            }
        }
コード例 #10
0
        protected virtual void DrawWindow(Window window, IDrawContext drawContext, SpriteSheet spriteSheet, Color color, Vector2 offset)
        {
            var renderSize = window.RenderSize;
            var texture = spriteSheet.Texture;

            var template = spriteSheet.Template as WindowSpriteSheetTemplate;
            int w = template.SpriteWidth;
            int h = template.SpriteHeight;

            // 計算誤差の問題から先に int 化しておきます。
            int offsetX = (int) offset.X;
            int offsetY = (int) offset.Y;
            int renderWidth = (int) renderSize.Width;
            int renderHeight = (int) renderSize.Height;

            var bounds = new Rect();
            Rectangle sourceRectangle;

            // Top Lines
            {
                int adjustedH = AdjustHeight(renderHeight, offsetY, h, offsetY);
                int adjustedW = AdjustWidth(renderWidth, offsetX, w, offsetX);
                bounds.Height = adjustedH;
                bounds.Width = adjustedW;

                sourceRectangle = spriteSheet.Template[WindowSpriteSheetTemplate.TopLeft];
                sourceRectangle.Width = adjustedW;
                sourceRectangle.Height = adjustedH;
                bounds.X = offsetX;
                bounds.Y = offsetY;
                bounds.Width = sourceRectangle.Width;
                drawContext.DrawTexture(bounds, texture, color, sourceRectangle);

                sourceRectangle = spriteSheet.Template[WindowSpriteSheetTemplate.Top];
                sourceRectangle.Height = adjustedH;
                for (int x = w + offsetX; x < renderWidth + offsetX - w; x += w)
                {
                    adjustedW = AdjustWidth(renderWidth, offsetX, w, x);

                    sourceRectangle.Width = adjustedW;
                    bounds.X = x;
                    bounds.Width = adjustedW;
                    drawContext.DrawTexture(bounds, texture, color, sourceRectangle);
                }

                sourceRectangle = spriteSheet.Template[WindowSpriteSheetTemplate.TopRight];
                sourceRectangle.Height = adjustedH;
                bounds.X = renderWidth + offsetX - w;
                bounds.Width = w;
                drawContext.DrawTexture(bounds, texture, color, sourceRectangle);
            }

            // Middle Lines
            for (int y = h + offsetY; y < renderHeight + offsetY - h; y += h)
            {
                int adjustedW = AdjustWidth(renderWidth, offsetX, w, offsetX);
                int adjustedH = AdjustHeight(renderHeight, offsetY, h, y);

                sourceRectangle = spriteSheet.Template[WindowSpriteSheetTemplate.Left];
                sourceRectangle.Width = adjustedW;
                sourceRectangle.Height = adjustedH;
                bounds.X = offsetX;
                bounds.Y = y;
                bounds.Width = adjustedW;
                bounds.Height = adjustedH;
                drawContext.DrawTexture(bounds, texture, color, sourceRectangle);

                sourceRectangle = spriteSheet.Template[WindowSpriteSheetTemplate.Fill];
                sourceRectangle.Height = adjustedH;
                for (int x = w + offsetX; x < renderWidth + offsetX - w; x += w)
                {
                    adjustedW = AdjustWidth(renderWidth, offsetX, w, x);

                    sourceRectangle.Width = adjustedW;
                    bounds.X = x;
                    bounds.Width = adjustedW;
                    drawContext.DrawTexture(bounds, texture, color, sourceRectangle);
                }

                sourceRectangle = spriteSheet.Template[WindowSpriteSheetTemplate.Right];
                sourceRectangle.Height = adjustedH;
                bounds.X = renderWidth + offsetX - w;
                bounds.Width = w;
                drawContext.DrawTexture(bounds, texture, color, sourceRectangle);
            }

            // Bottom Lines
            {
                int adjustedW = AdjustWidth(renderWidth, offsetX, w, offsetX);

                sourceRectangle = spriteSheet.Template[WindowSpriteSheetTemplate.BottomLeft];
                sourceRectangle.Width = adjustedW;
                bounds.X = offsetX;
                bounds.Y = renderHeight + offsetY - h;
                bounds.Width = adjustedW;
                bounds.Height = h;
                drawContext.DrawTexture(bounds, texture, color, sourceRectangle);

                sourceRectangle = spriteSheet.Template[WindowSpriteSheetTemplate.Bottom];
                for (int x = w + offsetX; x < renderWidth + offsetX - w; x += w)
                {
                    adjustedW = AdjustWidth(renderWidth, offsetX, w, x);

                    sourceRectangle.Width = adjustedW;
                    bounds.X = x;
                    bounds.Width = adjustedW;
                    drawContext.DrawTexture(bounds, texture, color, sourceRectangle);
                }
                bounds.Width = w;

                sourceRectangle = spriteSheet.Template[WindowSpriteSheetTemplate.BottomRight];
                bounds.X = renderWidth + offsetX - w;
                drawContext.DrawTexture(bounds, texture, color, sourceRectangle);
            }
        }