public override void Dispose() { D3DDevice.Dispose(); DxgiDevice.Dispose(); D2DDevice.Dispose(); base.Dispose(); }
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); }
/// <inheritdoc /> /// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources /// </summary> public void Dispose() { // release resources Alive = false; Duplication.Dispose(); Duplication = null; Output.Dispose(); Output = null; Output1?.Dispose(); Output1 = null; Output6?.Dispose(); Output6 = null; DxgiDevice.Dispose(); DxgiDevice = null; Device.Dispose(); Device = null; Texture.Dispose(); Texture = null; Adapter1.Dispose(); Adapter1 = null; }
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(); }
/// <inheritdoc /> /// <summary> /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources /// </summary> public void Dispose() { // release resources Duplication.Dispose(); Output.Dispose(); Output1?.Dispose(); Output6?.Dispose(); Context.Dispose(); DxgiDevice.Dispose(); Device.Dispose(); Texture.Dispose(); Adapter1.Dispose(); }
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; }