public bool LoadTexture(ThW.Render.Textures.Texture texture, ITexture noTexture)
        {
            Texture2D texture2d = this.contentManager.Load<Texture2D>(texture.Name);
            texture.UpdateTexture(texture2d, TextureState.Loaded, texture2d.Width, texture2d.Height);

            return true;
        }
 public void UnLoad(ThW.Render.Textures.Texture texture)
 {
     // those textures are here for all life cycle
 }
Beispiel #3
0
 public void DrawLine(int x1, int y1, int x2, int y2, ThW.UI.Utils.Color color)
 {
     throw new NotImplementedException();
 }
Beispiel #4
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);
                    }
                }
            }
        }
Beispiel #5
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);
            }
        }
Beispiel #6
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);
            }
        }
Beispiel #7
0
        private void CollectFonts(ThW.UI.Controls.Control control, HashSet<Font> fonts)
        {
            if (null == control)
            {
                return;
            }

            FontStyle style = FontStyle.Regular;

            if (control.FontInfo.Bold)
            {
                style |= FontStyle.Bold;
            }

            if (control.FontInfo.Italic)
            {
                style |= FontStyle.Italic;
            }

            fonts.Add(new Font(control.FontInfo.Name, control.FontInfo.Size, style));

            foreach (var child in control.Controls)
            {
                CollectFonts(child, fonts);
            }
        }
Beispiel #8
0
 private void SetEditControl(ThW.UI.Controls.Control control)
 {
     this.activeControl = control;
     FillProperties();
 }
Beispiel #9
0
        private void SetControl(ThW.UI.Controls.Control selectedControl, bool refreshProperties)
        {
            this.activeControl = selectedControl;
            this.comboBox1.SelectedItem = selectedControl;
            this.propertyGrid.SelectedObject = selectedControl;

            if (null != selectedControl)
            {
                selectedControl.DrawOutline = true;

                foreach (ThW.UI.Controls.Control control in this.activeWindow.WindowControls)
                {
                    if (selectedControl != control)
                    {
                        control.DrawOutline = false;
                    }
                }

                if (selectedControl != this.activeWindow)
                {
                    this.activeWindow.DrawOutline = false;
                }
            }

            this.designControlState = 0;

            if (true == refreshProperties)
            {
                FillControls();
            }
        }
Beispiel #10
0
 public PropertyDescriptorEx(Property property, ThW.UI.Controls.Control control)
     : base(property.Name, new Attribute[] { new CategoryAttribute(property.Group) })
 {
     this.property = property;
     this.control = control;
 }