/// <summary>
        /// Disposes the control.
        /// </summary>
        protected override void Dispose(bool disposing)
        {
            if (graphicsDeviceService != null) {
                graphicsDeviceService.Release(disposing);
                graphicsDeviceService = null;
            }

            base.Dispose(disposing);
        }
        /// <summary>
        /// Gets a reference to the singleton instance.
        /// </summary>
        public static GraphicsDeviceService AddRef (IntPtr windowHandle,
                                                   int width, int height) {
            // 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);
            }

            return singletonInstance;
        }
        /// <summary>
        /// Gets a reference to the singleton instance.
        /// </summary>
        public static GraphicsDeviceService AddRef(IntPtr windowHandle,
                                                   int width, int height)
        {
            // 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);
            }

            return(singletonInstance);
        }
Example #4
0
        /// <summary>
        /// シングルトン インスタンスに対する参照を取得します。
        ///
        /// staticメソッドでインスタンスを作成または取得する。
        /// GraphicsDeviceService device = GraphicsDeviceService.AddRef(・・・);
        /// </summary>
        public static GraphicsDeviceService AddRef(IntPtr windowHandle,
                                                   int width, int height)
        {
            // "デバイスを共有しているコントロールの数" カウンターを増やします。
            if (Interlocked.Increment(ref referenceCount) == 1)
            {
                // これが、デバイスを使用し始める最初のコントロールの場合、
                // シングルトン インスタンスを作成する必要があります。
                // ここでは、同じクラス内なのでnewできる。
                singletonInstance = new GraphicsDeviceService(windowHandle,
                                                              width, height);
            }

            return(singletonInstance);
        }
Example #5
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);

                // Register the service, so components like ContentManager can find it.
                services.AddService <IGraphicsDeviceService>(graphicsDeviceService);

                // Give derived classes a chance to initialize themselves.
                Initialize();
            }

            base.OnCreateControl();
        }
        /// <summary>
        /// コントロールを初期化します。
        /// </summary>
        protected override void OnCreateControl()
        {
            // デザイナー内で実行している場合は、
            // グラフィック デバイスを初期化しません。
            if (!DesignMode)
            {
                graphicsDeviceService = GraphicsDeviceService.AddRef(Handle,
                                                                     ClientSize.Width,
                                                                     ClientSize.Height);

                // ContentManager などのコンポーネントから検出できるように、サービスを登録します。
                services.AddService <IGraphicsDeviceService>(graphicsDeviceService);

                // 派生クラスに自身を初期化する機会を与えます。
                Initialize();
            }

            base.OnCreateControl();
        }
        /// <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);

                // Register the service, so components like ContentManager can find it.
                services.AddService<IGraphicsDeviceService>(graphicsDeviceService);

                // Give derived classes a chance to initialize themselves.
                Initialize();
            }

            base.OnCreateControl();
        }
        /// <summary>
        /// �R���g���[������������܂��B
        /// </summary>
        protected override void OnCreateControl()
        {
            // �f�U�C�i�[��Ŏ��s���Ă���ꍇ�́A
            // �O���t�B�b�N �f�o�C�X����������܂���B
            if (!DesignMode)
            {
                graphicsDeviceService = GraphicsDeviceService.AddRef(Handle,
                                                                     ClientSize.Width,
                                                                     ClientSize.Height);

                // ContentManager �Ȃǂ̃R���|�[�l���g���猟�o�ł���悤�ɁA�T�[�r�X��o�^���܂��B
                services.AddService<IGraphicsDeviceService>(graphicsDeviceService);

                // �h���N���X�Ɏ��g�����������@���^���܂��B
                Initialize();
            }

            base.OnCreateControl();
        }
        /// <summary>
        /// シングルトン インスタンスに対する参照を取得します。
        /// 
        /// staticメソッドでインスタンスを作成または取得する。
        /// GraphicsDeviceService device = GraphicsDeviceService.AddRef(・・・);
        /// </summary>
        public static GraphicsDeviceService AddRef(IntPtr windowHandle,
                                                   int width, int height)
        {
            // "デバイスを共有しているコントロールの数" カウンターを増やします。
            if (Interlocked.Increment(ref referenceCount) == 1)
            {
                // これが、デバイスを使用し始める最初のコントロールの場合、
                // シングルトン インスタンスを作成する必要があります。
                // ここでは、同じクラス内なのでnewできる。
                singletonInstance = new GraphicsDeviceService(windowHandle,
                                                              width, height);
            }

            return singletonInstance;
        }