Пример #1
0
 private void MainWindow_Load(object sender, EventArgs e)
 {
     if (_dxgiDevice != null)
     {
         CleanUp();
     }
     _dxgiDevice = DxgiDevice.CreateDevice();
     _factory    = Direct2DFactory.CreateFactory(FactoryType.SingleThreaded, DebugLevel.None);
     using (Device device = _factory.CreateDevice(_dxgiDevice))
     {
         _deviceContext = device.CreateDeviceContext(DeviceContextOptions.None);
         using (DxgiAdapter adapter = _dxgiDevice.GetAdapter())
             using (DxgiFactory factory = adapter.GetFactory())
             {
                 _swapChain = factory.CreateSwapChainForHwnd(_dxgiDevice, Handle);
                 _dxgiDevice.MaximumFrameLatency = 1;
                 _swapChain.GetBuffer(0, out _surface);
                 _bitmap = _deviceContext.CreateBitmapFromDxgiSurface(_surface);
                 _deviceContext.SetTarget(_bitmap);
             }
         for (int index = 0; index < _brushes.Length; ++index)
         {
             _pens[index]    = _deviceContext.CreateSolidColorBrush(GetRandomColor(_random, 1));
             _brushes[index] = _deviceContext.CreateSolidColorBrush(GetRandomColor(_random, 0.25f));
         }
     }
     _directWriteFactory = DirectWriteFactory.Create(DirectWriteFactoryType.Shared);
 }
Пример #2
0
 private async void MainWindow_Load(object sender, EventArgs e)
 {
     if (_dxgiDevice != null)
     {
         CleanUp();
     }
     _dxgiDevice = DxgiDevice.CreateDevice();
     _factory    = Direct2DFactory.CreateFactory(FactoryType.SingleThreaded, DebugLevel.None);
     using (Device device = _factory.CreateDevice(_dxgiDevice))
     {
         _deviceContext = device.CreateDeviceContext(DeviceContextOptions.None);
         using (DxgiAdapter adapter = _dxgiDevice.GetAdapter())
             using (DxgiFactory factory = adapter.GetFactory())
             {
                 _swapChain = factory.CreateSwapChainForHwnd(_dxgiDevice, Handle);
                 _dxgiDevice.MaximumFrameLatency = 1;
                 _swapChain.GetBuffer(0, out _surface);
                 _bitmap = _deviceContext.CreateBitmapFromDxgiSurface(_surface);
                 _deviceContext.SetTarget(_bitmap);
                 _brush  = _deviceContext.CreateSolidColorBrush(Color.FromRGB(0.1f, 0.75f, 0.5f, 1f));
                 _brush1 = _deviceContext.CreateSolidColorBrush(Color.FromRGB(0.1f, 0.5f, 0.75f, 1f));
             }
     }
     _directWriteFactory = DirectWriteFactory.Create(DirectWriteFactoryType.Shared);
     await CreatePoints();
 }
Пример #3
0
 private void MainWindow_Load(object sender, EventArgs e)
 {
     if (_dxgiDevice != null)
     {
         CleanUp();
     }
     _dxgiDevice = DxgiDevice.CreateDevice();
     _factory    = Direct2DFactory.CreateFactory(FactoryType.SingleThreaded, DebugLevel.None);
     using (Device device = _factory.CreateDevice(_dxgiDevice))
     {
         _deviceContext = device.CreateDeviceContext(DeviceContextOptions.None);
         using (DxgiAdapter adapter = _dxgiDevice.GetAdapter())
             using (DxgiFactory factory = adapter.GetFactory())
             {
                 _swapChain = factory.CreateSwapChainForHwnd(_dxgiDevice, Handle);
                 _dxgiDevice.MaximumFrameLatency = 1;
                 _swapChain.GetBuffer(0, out _surface);
                 _bitmap = _deviceContext.CreateBitmapFromDxgiSurface(_surface);
                 _deviceContext.SetTarget(_bitmap);
                 _brush = _deviceContext.CreateSolidColorBrush(Color.FromKnown(Colors.Black, 0.4f));
             }
     }
     uint value = _deviceContext.MaximumBitmapSize;
 }