/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { lock (this) { // Do nothing if the object has already been disposed of. if (disposed) { return; } if (disposing) { singletonInstance = null; if (graphicsDevice != null) { graphicsDevice.Dispose(); } } // Release unmanaged resources here. Don't access reference type fields. // Remember that the object has been disposed of. disposed = true; } }
/// <summary> /// Gets a reference to the singleton instance. /// </summary> /// <param name="windowHandle">The window handle.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <returns></returns> public static AlmiranteGraphicsService AddRef(IntPtr windowHandle, int width, int height) { if (Interlocked.Increment(ref referenceCount) == 1) { singletonInstance = new AlmiranteGraphicsService(windowHandle, width, height); } return(singletonInstance); }
/// <summary> /// Initializes the control. /// </summary> protected override void OnCreateControl() { if (!DesignMode) { this.graphicsDeviceService = AlmiranteGraphicsService.AddRef(Handle, ClientSize.Width, ClientSize.Height); AlmiranteEngine.Instance.InitializeWindowsServices(); this.OnInitialize(); } base.OnCreateControl(); }
/// <summary> /// Disposes the control. /// </summary> protected override void Dispose(bool disposing) { this.OnUninitialize(); if (graphicsDeviceService != null) { graphicsDeviceService.Release(disposing); graphicsDeviceService.Dispose(); graphicsDeviceService = null; } base.Dispose(disposing); }
/// <summary> /// Releases unmanaged and - optionally - managed resources. /// </summary> /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param> protected virtual void Dispose(bool disposing) { lock (this) { // Do nothing if the object has already been disposed of. if (disposed) return; if (disposing) { singletonInstance = null; if (graphicsDevice != null) graphicsDevice.Dispose(); } // Release unmanaged resources here. Don't access reference type fields. // Remember that the object has been disposed of. disposed = true; } }
/// <summary> /// Gets a reference to the singleton instance. /// </summary> /// <param name="windowHandle">The window handle.</param> /// <param name="width">The width.</param> /// <param name="height">The height.</param> /// <returns></returns> public static AlmiranteGraphicsService AddRef(IntPtr windowHandle, int width, int height) { if (Interlocked.Increment(ref referenceCount) == 1) { singletonInstance = new AlmiranteGraphicsService(windowHandle, width, height); } return singletonInstance; }