Exemple #1
0
        public virtual void Cleanup()
        {
            Context?.ClearState();
            Context?.Flush();

            BackBuffer?.Dispose();
            BackBuffer = null;
            ZBuffer?.Dispose();
            ZBuffer = null;

            RenderTargetViewRef?.Dispose();
            RenderTargetViewRef = null;

            DepthStencilSRVRef?.Dispose();
            DepthStencilSRVRef = null;

            DepthStencilViewRef?.Dispose();
            DepthStencilViewRef = null;

            FactoryDWrite?.Dispose();
            FactoryDWrite = null;
            Factory2D?.Dispose();
            Factory2D = null;
            RenderTarget2D?.Dispose();
            RenderTarget2D = null;

            Context?.Dispose();
            DeviceRef?.Dispose();
            DeviceRef = null;
        }
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (components != null)
                {
                    components.Dispose();
                }

                if (CurrentTextFormat != null)
                {
                    CurrentTextFormat.Dispose();
                }

                if (CurrentTextLayout != null)
                {
                    CurrentTextLayout.Dispose();
                }

                if (CustomTextRenderer != null)
                {
                    CustomTextRenderer.Dispose();
                }

                if (SceneColorBrush != null)
                {
                    SceneColorBrush.Dispose();
                }

                if (RenderTarget2D != null)
                {
                    RenderTarget2D.Dispose();
                }

                if (FactoryDWrite != null)
                {
                    FactoryDWrite.Dispose();
                }

                if (Factory2D != null)
                {
                    Factory2D.Dispose();
                }
            }
            base.Dispose(disposing);
        }