Exemplo n.º 1
0
        public override void DrawImage(int x, int y, int w, int h, IImage image, float us, float vs, float ue, float ve, Color color, bool outLineOnly)
        {
            Texture2D texture = ((XNAImage)image).Texture;
            Microsoft.Xna.Framework.Rectangle destinationRectangle = new Microsoft.Xna.Framework.Rectangle(x, y, w, h);
            Microsoft.Xna.Framework.Color imageColor = new Microsoft.Xna.Framework.Color(color.R, color.G, color.B, color.A);
            Microsoft.Xna.Framework.Rectangle sourceRectangle = new Microsoft.Xna.Framework.Rectangle((int)(us * texture.Width), (int)(ue * texture.Height), (int)(vs * texture.Width), (int)(ve * texture.Height));

            this.spriteBatch.Draw(texture, destinationRectangle, sourceRectangle, imageColor);
        }
Exemplo n.º 2
0
        public void DrawLine(int x1, int y1, int x2, int y2, ThW.UI.Utils.Color color)
        {
            if (null != this.graphics)
            {
                Pen pen = new Pen(System.Drawing.Color.FromArgb((int)(color.A * 0xff), (int)(color.R * 0xff), (int)(color.G * 0xff), (int)(color.B * 0xff)));

                this.graphics.DrawLine(pen, x1, y1, x2, y2);
            }
        }
Exemplo n.º 3
0
        public virtual void DrawImage(int x, int y, int w, int h, IImage image, float us, float vs, float ue, float ve, ThW.UI.Utils.Color color, bool outLineOnly)
        {
            float d = -0.5f;

            XNAVertex[] v = new XNAVertex[4];
            v[0].Position.X          = (float)x + d;
            v[0].Position.Y          = (float)y + d;
            v[0].Position.Z          = 0.0f;
            v[0].TextureCoordinate.X = us;
            v[0].TextureCoordinate.Y = vs;
            v[0].Color.R             = (byte)(255 * color.R);
            v[0].Color.G             = (byte)(255 * color.G);
            v[0].Color.B             = (byte)(255 * color.B);
            v[0].Color.A             = (byte)(255 * color.A);

            v[1].Position.X          = (float)x + (float)w + d;
            v[1].Position.Y          = (float)y + d;
            v[1].Position.Z          = 0.0f;
            v[1].TextureCoordinate.X = ue;
            v[1].TextureCoordinate.Y = vs;
            v[1].Color.R             = (byte)(255 * color.R);
            v[1].Color.G             = (byte)(255 * color.G);
            v[1].Color.B             = (byte)(255 * color.B);
            v[1].Color.A             = (byte)(255 * color.A);

            v[2].Position.X          = (float)x + d;
            v[2].Position.Y          = (float)y + (float)h + d;
            v[2].Position.Z          = 0.0f;
            v[2].TextureCoordinate.X = us;
            v[2].TextureCoordinate.Y = ve;
            v[2].Color.R             = (byte)(255 * color.R);
            v[2].Color.G             = (byte)(255 * color.G);
            v[2].Color.B             = (byte)(255 * color.B);
            v[2].Color.A             = (byte)(255 * color.A);

            v[3].Position.X          = (float)x + (float)w + d;
            v[3].Position.Y          = (float)y + (float)h + d;
            v[3].Position.Z          = 0.0f;
            v[3].TextureCoordinate.X = ue;
            v[3].TextureCoordinate.Y = ve;
            v[3].Color.R             = (byte)(255 * color.R);
            v[3].Color.G             = (byte)(255 * color.G);
            v[3].Color.B             = (byte)(255 * color.B);
            v[3].Color.A             = (byte)(255 * color.A);

            short[] indx = { 0, 1, 3, 3, 2, 0 };

            this.effect2d.Texture = ((XNAImage)image).Texture;

            foreach (EffectPass pass in this.effect2d.CurrentTechnique.Passes)
            {
                pass.Apply();

                device.DrawUserIndexedPrimitives(PrimitiveType.TriangleList, v, 0, 4, indx, 0, 2, this.vertexShaderDeclaration);
            }
        }
Exemplo n.º 4
0
 public void DrawLine(int x1, int y1, int x2, int y2, ThW.UI.Utils.Color color)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 5
0
        public void DrawImage(int x, int y, int w, int h, IImage image, float us, float vs, float ue, float ve, ThW.UI.Utils.Color color, bool outLineOnly)
        {
            if ((null != this.graphics) && (null != image))
            {
                if (true == outLineOnly)
                {
                    Pen pen = new Pen(System.Drawing.Color.FromArgb((int)(color.A * 0xff), (int)(color.R * 0xff), (int)(color.G * 0xff), (int)(color.B * 0xff)));

                    this.graphics.DrawRectangle(pen, x, y, w, h);
                }
                else
                {
                    Image bmp = ((GDIImage)image).Image;

                    System.Drawing.Rectangle rectangle = new System.Drawing.Rectangle(x, y, w, h);

                    ImageAttributes imageAttributes = new ImageAttributes();

                    float[][] pointsArray =
                    {
                        new float[] { color.R,       0,       0,       0, 0 },
                        new float[] {       0, color.G,       0,       0, 0 },
                        new float[] {       0,       0, color.B,       0, 0 },
                        new float[] {       0,       0,       0, color.A, 0 },
                        new float[] {       0,       0,       0,       0, 1 }
                    };

                    try
                    {
                        ColorMatrix clrMatrix = new ColorMatrix(pointsArray);
                        imageAttributes.SetColorMatrix(clrMatrix, ColorMatrixFlag.Default, ColorAdjustType.Default);
                        imageAttributes.SetWrapMode(System.Drawing.Drawing2D.WrapMode.Tile);
                        this.graphics.DrawImage(bmp, rectangle, us * bmp.Width, vs * bmp.Height, bmp.Width * (ue - us), bmp.Height * (ve - vs), GraphicsUnit.Pixel, imageAttributes);
                    }
                    catch (Exception ex)
                    {
                        Debug.WriteLine(ex.Message);
                    }
                }
            }
        }