コード例 #1
0
		/// <summary>
		/// Disposes the control.
		/// </summary>
		protected override void Dispose(bool disposing)
		{
			if (_graphicsDeviceService != null)
			{
				_graphicsDeviceService.Release(disposing);
				_graphicsDeviceService = null;
			}

			base.Dispose(disposing);
		}
コード例 #2
0
		/// <summary>
		/// Gets a reference to the singleton instance.
		/// </summary>
		public static GraphicsDeviceService AddRef(IntPtr windowHandle, int width, int height,
			IServiceProvider serviceProvider)
		{
			// Increment the "how many controls sharing the device" reference count.
			if (Interlocked.Increment(ref referenceCount) == 1)
			{
				// If this is the first control to start using the
				// device, we must create the singleton instance.
				singletonInstance = new GraphicsDeviceService(windowHandle, width, height,
					serviceProvider);
			}

			return singletonInstance;
		}
コード例 #3
0
        /// <summary>
        /// Initializes the control.
        /// </summary>
        protected override void OnCreateControl()
        {
            // Don't initialize the graphics device if we are running in the designer.
            if (!DesignMode)
            {
                _graphicsDeviceService = GraphicsDeviceService.AddRef(Handle,
                                                                      ClientSize.Width, ClientSize.Height,
                                                                      _services);

                // Register the service, so components like ContentManager can find it.
                _services.AddService(typeof(IGraphicsDeviceService), _graphicsDeviceService);
            }

            base.OnCreateControl();
        }
コード例 #4
0
		/// <summary>
		/// Initializes the control.
		/// </summary>
		protected override void OnCreateControl()
		{
			// Don't initialize the graphics device if we are running in the designer.
			if (!DesignMode)
			{
				_graphicsDeviceService = GraphicsDeviceService.AddRef(Handle,
					ClientSize.Width, ClientSize.Height,
					_services);

				// Register the service, so components like ContentManager can find it.
				_services.AddService(typeof(IGraphicsDeviceService), _graphicsDeviceService);
			}

			base.OnCreateControl();
		}