public override void Dispose() { if (m_d3dImage != null) m_d3dImage.Dispatcher.Invoke((Action)delegate { m_d3dImage.Lock(); m_d3dImage.SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero); m_d3dImage.Unlock(); m_d3dImage.Dispose(); m_d3dImage = null; ReleaseResources(); }); base.Dispose(); }
private void InitD3DImage(int width, int height) { if (Application.Current == null || Application.Current.Dispatcher == null) return; var dispatcher = Application.Current.Dispatcher; if (!dispatcher.CheckAccess()) { dispatcher.Invoke((Action)delegate { InitD3DImage(width, height); }); return; } ReleaseResources(); m_width = width; m_height = height; rect = new RectangleF(0, 0, m_width, m_height); intRect = new Int32Rect(0, 0, m_width, m_height); if (m_d3dImage == null) { m_d3dImage = new D3DImageSlimDX(); m_d3dImage.IsFrontBufferAvailableChanged += OnIsFrontBufferAvailableChanged; } m_layer1 = new DrawingLayer(Factory, width, height, SlimDX.DXGI.Format.B8G8R8A8_UNorm, ResourceOptionFlags.Shared); m_layer2 = new DrawingLayer(Factory, width, height, SlimDX.DXGI.Format.B8G8R8A8_UNorm, ResourceOptionFlags.Shared); SetBackBuffer(); }