Пример #1
0
 protected override void OnCreateDeviceResources(WindowRenderTarget renderTarget)
 {
     base.OnCreateDeviceResources(renderTarget);
     this._bitmap           = renderTarget.CreateBitmap(this.GetType(), "fern.jpg");
     this._brush            = renderTarget.CreateSolidColorBrush(Color.FromARGB(Colors.Orange, 1));
     this._brush.Opacity    = 0.75f;
     this._gridPatternBrush = renderTarget.CreateGridPatternBrush(new SizeF(10, 10), Color.FromARGB(1, 0.93f, 0.94f, 0.96f));
 }
Пример #2
0
 protected override void OnCreateDeviceResources(WindowRenderTarget renderTarget)
 {
     base.OnCreateDeviceResources(renderTarget);
     this._blackBrush = renderTarget.CreateSolidColorBrush(Color.FromKnown(Colors.Black, 1));
     using (Bitmap bitmap = renderTarget.CreateBitmap(this.GetType(), "flowers.jpg"))
     {
         this._bitmapBrush = renderTarget.CreateBitmapBrush(bitmap, new BitmapBrushProperties(ExtendMode.Wrap, ExtendMode.Wrap, BitmapInterpolationMode.NearestNeighbor), BrushProperties.Default);
     }
     _customRenderer = new CustomTextRenderer(this.Direct2DFactory, renderTarget, this._blackBrush, this._bitmapBrush);
 }
Пример #3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            timer1.Enabled = false;
            Random rand = new Random();

            _renderTarget.BeginDraw();
            for (int index = 0; index < 20; ++index)
            {
                Color color = Color.FromRGB((float)rand.NextDouble(), (float)rand.NextDouble(), (float)rand.NextDouble());
                using (SolidColorBrush brush = _renderTarget.CreateSolidColorBrush(color))
                {
                    float strokeWidth = rand.Next(1, 5);
                    float patch       = strokeWidth / 2 - (int)(strokeWidth / 2);
                    _renderTarget.DrawRect(brush, strokeWidth, _strokeStyle,
                                           new RectF(
                                               new PointF(rand.Next(0, ClientSize.Width) + patch, rand.Next(0, ClientSize.Height) + patch),
                                               new PointF(rand.Next(0, ClientSize.Width) + patch, rand.Next(0, ClientSize.Height) + patch)));
                }
            }
            _cache = _renderTarget.CreateBitmap(new SizeU((uint)ClientSize.Width, (uint)ClientSize.Height), IntPtr.Zero, 0,
                                                new BitmapProperties(new PixelFormat(DxgiFormat.B8G8R8A8_UNORM, AlphaMode.Ignore), 96, 96));
            _cache.CopyFromRenderTarget(new PointU(0, 0), _renderTarget, new RectU(0, 0, (uint)ClientSize.Width, (uint)ClientSize.Height));
            _renderTarget.EndDraw();
        }
Пример #4
0
 protected override void OnCreateDeviceResources(WindowRenderTarget renderTarget)
 {
     base.OnCreateDeviceResources(renderTarget);
     this._blackBrush = renderTarget.CreateSolidColorBrush(Color.FromARGB(Colors.Black, 1));
     using (Bitmap bitmap = renderTarget.CreateBitmap(this.GetType(), "flowers.jpg"))
     {
         this._bitmapBrush = renderTarget.CreateBitmapBrush(bitmap, new BitmapBrushProperties(ExtendMode.Wrap, ExtendMode.Wrap, BitmapInterpolationMode.NearestNeighbor), BrushProperties.Default);
     }
     _customRenderer = new CustomTextRenderer(this.Direct2DFactory, renderTarget, this._blackBrush, this._bitmapBrush);
 }
Пример #5
0
 protected override void OnCreateDeviceResources(WindowRenderTarget renderTarget)
 {
     base.OnCreateDeviceResources(renderTarget);
     this._bitmap = renderTarget.CreateBitmap(this.GetType(), "fern.jpg");
     this._brush = renderTarget.CreateSolidColorBrush(Color.FromARGB(Colors.Orange, 1));
     this._brush.Opacity = 0.75f;
     this._gridPatternBrush = renderTarget.CreateGridPatternBrush(new SizeF(10, 10), Color.FromARGB(1, 0.93f, 0.94f, 0.96f));
 }