public static GraphicsDeviceService AddRef(IntPtr windowHandle, int width, int height) { if (Interlocked.Increment(ref GraphicsDeviceService.referenceCount) == 1) { GraphicsDeviceService.singletonInstance = new GraphicsDeviceService(windowHandle, width, height); } return GraphicsDeviceService.singletonInstance; }
protected override void Dispose(bool disposing) { if (this.graphicsDeviceService != null) { this.graphicsDeviceService.Release(disposing); this.graphicsDeviceService = null; } base.Dispose(disposing); }
protected override void OnCreateControl() { if (!base.DesignMode) { this.graphicsDeviceService = GraphicsDeviceService.AddRef(base.Handle, base.ClientSize.Width, base.ClientSize.Height); this.services.AddService<IGraphicsDeviceService>(this.graphicsDeviceService); this.Initialize(); } base.OnCreateControl(); }