示例#1
0
        protected override unsafe void CreateTexture()
        {
            if (string.IsNullOrEmpty(Text))
            {
                return;
            }

            if (Size.Width == 0 || Size.Height == 0)
            {
                return;
            }

            if (ControlTexture != null && !ControlTexture.Disposed && TextureSize != Size)
            {
                ControlTexture.Dispose();
            }

            if (ControlTexture == null || ControlTexture.Disposed)
            {
                DXManager.ControlList.Add(this);

                ControlTexture            = new Texture(DXManager.Device, Size.Width, Size.Height, 1, Usage.None, Format.A8R8G8B8, Pool.Managed);
                ControlTexture.Disposing += ControlTexture_Disposing;
                TextureSize = Size;
            }

            using (GraphicsStream stream = ControlTexture.LockRectangle(0, LockFlags.Discard))
                using (Bitmap image = new Bitmap(Size.Width, Size.Height, Size.Width * 4, PixelFormat.Format32bppArgb, (IntPtr)stream.InternalDataPointer))
                {
                    using (Graphics graphics = Graphics.FromImage(image))
                    {
                        graphics.SmoothingMode      = SmoothingMode.AntiAlias;
                        graphics.TextRenderingHint  = TextRenderingHint.AntiAliasGridFit;
                        graphics.CompositingQuality = CompositingQuality.HighQuality;
                        graphics.InterpolationMode  = InterpolationMode.HighQualityBicubic;
                        graphics.PixelOffsetMode    = PixelOffsetMode.HighQuality;
                        graphics.TextContrast       = 0;
                        graphics.Clear(BackColour);


                        if (OutLine)
                        {
                            TextRenderer.DrawText(graphics, Text, Font, new Rectangle(1, 0, Size.Width, Size.Height), OutLineColour, DrawFormat);
                            TextRenderer.DrawText(graphics, Text, Font, new Rectangle(0, 1, Size.Width, Size.Height), OutLineColour, DrawFormat);
                            TextRenderer.DrawText(graphics, Text, Font, new Rectangle(2, 1, Size.Width, Size.Height), OutLineColour, DrawFormat);
                            TextRenderer.DrawText(graphics, Text, Font, new Rectangle(1, 2, Size.Width, Size.Height), OutLineColour, DrawFormat);
                            TextRenderer.DrawText(graphics, Text, Font, new Rectangle(1, 1, Size.Width, Size.Height), ForeColour, DrawFormat);
                        }
                        else
                        {
                            TextRenderer.DrawText(graphics, Text, Font, new Rectangle(1, 0, Size.Width, Size.Height), ForeColour, DrawFormat);
                        }
                    }
                }
            ControlTexture.UnlockRectangle(0);
            DXManager.Sprite.Flush();
            TextureValid = true;
        }
示例#2
0
        protected unsafe override void CreateTexture()
        {
            if (!Settings.FullScreen)
            {
                return;
            }

            if (Size.Width == 0 || Size.Height == 0)
            {
                return;
            }

            if (ControlTexture != null && !ControlTexture.Disposed && TextureSize != Size)
            {
                ControlTexture.Dispose();
            }

            if (ControlTexture == null || ControlTexture.Disposed)
            {
                DXManager.ControlList.Add(this);

                ControlTexture            = new Texture(DXManager.Device, Size.Width, Size.Height, 1, Usage.None, Format.A8R8G8B8, Pool.Managed);
                ControlTexture.Disposing += ControlTexture_Disposing;
                TextureSize = Size;
            }

            Point caret = GetCaretPosition();

            using (GraphicsStream stream = ControlTexture.LockRectangle(0, LockFlags.Discard))
                using (Bitmap bm = new Bitmap(Size.Width, Size.Height, Size.Width * 4, PixelFormat.Format32bppArgb, (IntPtr)stream.InternalDataPointer))
                {
                    TextBox.DrawToBitmap(bm, new Rectangle(0, 0, Size.Width, Size.Height));
                    using (Graphics graphics = Graphics.FromImage(bm))
                    {
                        graphics.DrawImage(bm, Point.Empty);
                        if (TextBox.Focused)
                        {
                            graphics.DrawLine(CaretPen, new Point(caret.X, caret.Y), new Point(caret.X, caret.Y + TextBox.Font.Height));
                        }
                    }
                }
            ControlTexture.UnlockRectangle(0);
            DXManager.Sprite.Flush();
            TextureValid = true;
        }
示例#3
0
        protected override unsafe void CreateTexture()
        {
            if (string.IsNullOrEmpty(Text))
            {
                return;
            }

            if (Size.Width == 0 || Size.Height == 0)
            {
                return;
            }

            if (ControlTexture != null && !ControlTexture.Disposed && TextureSize != Size)
            {
                ControlTexture.Dispose();
            }

            if (ControlTexture == null || ControlTexture.Disposed)
            {
                DXManager.ControlList.Add(this);

                ControlTexture = new Texture(DXManager.Device, Size.Width, Size.Height, 1, Usage.None, Format.A8R8G8B8, Pool.Managed);
                TextureSize    = Size;
            }

            DataRectangle stream = ControlTexture.LockRectangle(0, LockFlags.Discard);

            using (Bitmap image = new Bitmap(Size.Width, Size.Height, Size.Width * 4, PixelFormat.Format32bppArgb, stream.Data.DataPointer))
            {
                using (Graphics graphics = Graphics.FromImage(image))
                {
                    graphics.SmoothingMode      = SmoothingMode.AntiAlias;
                    graphics.TextRenderingHint  = TextRenderingHint.AntiAliasGridFit;
                    graphics.CompositingQuality = CompositingQuality.HighQuality;
                    graphics.InterpolationMode  = InterpolationMode.NearestNeighbor;
                    graphics.PixelOffsetMode    = PixelOffsetMode.HighQuality;
                    graphics.TextContrast       = 0;
                    graphics.Clear(BackColour);


                    if (OutLine)
                    {
                        TextRenderer.DrawText(graphics, Text, Font, new Rectangle(1, 0, Size.Width, Size.Height), OutLineColour, DrawFormat);
                        TextRenderer.DrawText(graphics, Text, Font, new Rectangle(0, 1, Size.Width, Size.Height), OutLineColour, DrawFormat);
                        TextRenderer.DrawText(graphics, Text, Font, new Rectangle(2, 1, Size.Width, Size.Height), OutLineColour, DrawFormat);
                        TextRenderer.DrawText(graphics, Text, Font, new Rectangle(1, 2, Size.Width, Size.Height), OutLineColour, DrawFormat);
                        TextRenderer.DrawText(graphics, Text, Font, new Rectangle(1, 1, Size.Width, Size.Height), ForeColour, DrawFormat);

                        //LinearGradientBrush brush = new LinearGradientBrush(new Rectangle(0, 0, this.Size.Width, this.Size.Height), Color.FromArgb(239, 243, 239), Color.White, LinearGradientMode.Vertical);
                        ////graphics.DrawString(Text, Font, brush, 37, 9);
                        ////graphics.DrawString(this.Text, this.Font, new SolidBrush(Color.Black), 39, 9, StringFormat.GenericDefault);
                    }
                    else
                    {
                        TextRenderer.DrawText(graphics, Text, Font, new Rectangle(1, 0, Size.Width, Size.Height), ForeColour, DrawFormat);
                    }
                }
            }

            ControlTexture.UnlockRectangle(0);
            DXManager.Sprite.Flush();
            TextureValid = true;
        }