Exemplo n.º 1
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                //dispose of all layouts
                while (layouts.Keys.Count > 0)
                {
                    foreach (string key in layouts.Keys)
                    {
                        layouts[key].Dispose();
                        layouts.Remove(key);
                        break;
                    }
                }

                if (brush != null)
                {
                    brush.Dispose();
                }
                brush = null;
                if (dcRenderTarget != null)
                {
                    dcRenderTarget.Dispose();
                }
                dcRenderTarget = null;
                if (dwriteFactory != null)
                {
                    dwriteFactory.Dispose();
                }
                dwriteFactory = null;
                if (d2DFactory != null)
                {
                    d2DFactory.Dispose();
                }
                d2DFactory = null;
            }
            base.Dispose(disposing);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Dispose of resources (IDisposable implementation)
        /// </summary>
        /// <param name="disposing">true to release both managed and unmanaged resources; false to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && !disposed)
            {
                lock (renderSyncObject)
                {
                    render = null;

                    lock (sharedSyncObject)
                    {
                        if (sharedD2DFactory != null && d2DFactory == sharedD2DFactory)
                        {
                            sharedRefCount--;
                        }

                        if (d2DFactory != null && d2DFactory != sharedD2DFactory)
                        {
                            d2DFactory.Dispose();
                        }
                        d2DFactory = null;

                        if (dwriteFactory != null && dwriteFactory != sharedDwriteFactory)
                        {
                            dwriteFactory.Dispose();
                        }
                        dwriteFactory = null;

                        if (wicFactory != null && wicFactory != sharedWicFactory)
                        {
                            wicFactory.Dispose();
                        }
                        wicFactory = null;

                        if (sharedRefCount == 0)
                        {
                            if (sharedD2DFactory != null)
                            {
                                sharedD2DFactory.Dispose();
                            }
                            sharedD2DFactory = null;

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

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

                    foreach (DrawingShape shape in drawingShapes)
                    {
                        shape.Dispose();
                    }

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

                    if (dcRenderTarget != null)
                    {
                        dcRenderTarget.Dispose();
                    }
                    dcRenderTarget = null;
                    if (bitmapRenderTarget != null)
                    {
                        bitmapRenderTarget.Dispose();
                    }
                    bitmapRenderTarget = null;
                    if (hwndRenderTarget != null)
                    {
                        hwndRenderTarget.Dispose();
                    }
                    hwndRenderTarget = null;


                    disposed = true;
                }
            }
            base.Dispose(disposing);
        }