示例#1
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         DisposableUtil.Free <Document>(ref this.oldDocument);
     }
     base.Dispose(disposing);
 }
示例#2
0
        public override void Dispose()
        {
            // dispose this class level
            this.chunkingOutput = null;
            DisposableUtil.ClearDisposableObject(ref this.bodyStream);

            // dispose the base class level
            base.Dispose();
        }
示例#3
0
 protected override void Dispose(bool disposing)
 {
     if (disposing && (this.document != null))
     {
         this.Document = null;
     }
     DisposableUtil.Free <ThumbnailManager>(ref this.thumbnailManager, disposing);
     base.Dispose(disposing);
 }
示例#4
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         DisposableUtil.Free <DropShadowRenderer>(ref this.dropShadowRenderer);
         DisposableUtil.Free <SelectionHighlightRenderer>(ref this.selectionHighlightRenderer);
     }
     base.Dispose(disposing);
 }
示例#5
0
 private void DestroyBitmapResources()
 {
     if (this.wheelBackgroundDeviceBitmap != null)
     {
         this.wheelBackgroundDeviceBitmap.BitmapSource = null;
         this.wheelBackgroundDeviceBitmap = null;
     }
     DisposableUtil.Free <ISurface <ColorBgra> >(ref this.wheelBackgroundSurface);
 }
示例#6
0
 private void PopTimerScope()
 {
     ((BrushToolBase <TDerived, TChanges, TUI>) this).VerifyAccess <BrushToolBase <TDerived, TChanges, TUI> >();
     if (this.timerResolutionScope == null)
     {
         throw new InvalidOperationException("mismatched push/pop");
     }
     DisposableUtil.Free <TimerResolutionScope>(ref this.timerResolutionScope);
 }
示例#7
0
        /// <summary>
        /// Releases unmanaged and - optionally - managed resources.
        /// </summary>
        /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                DisposableUtil.Free(ref this.image);
            }

            base.Dispose(disposing);
        }
        protected override void Dispose(bool disposing)
        {
            if (!this.leaveOpen)
            {
                DisposableUtil.Free(ref this.textWriter, disposing);
            }

            base.Dispose(disposing);
        }
        private bool TryUpdateDeviceBitmap(int tileColumn, int tileRow)
        {
            IRenderTarget renderTarget = this.canvasView.RenderTarget;

            if (renderTarget == null)
            {
                return(false);
            }
            bool flag = renderTarget.IsSupported(RenderTargetType.Software, null, null, null);

            if (!flag && (!this.IsVisible || !this.IsActive))
            {
                throw new PaintDotNet.InternalErrorException();
            }
            if (!this.isDeviceBitmapCurrent[tileRow][tileColumn])
            {
                using (IBitmap <ColorPbgra32> bitmap = this.tileCache.TryGetTileBufferRef(tileColumn, tileRow))
                {
                    if (bitmap != null)
                    {
                        if (bitmap.IsDisposed)
                        {
                            throw new ObjectDisposedException("tileBufferRef");
                        }
                        if (flag)
                        {
                            DisposableUtil.Free <IDeviceBitmap>(ref this.deviceBitmaps[tileRow][tileColumn]);
                            DisposableUtil.Free <IBitmap <ColorPbgra32> >(ref this.tileBuffers[tileRow][tileColumn]);
                            IBitmapLock   bitmapLock = bitmap.Lock <ColorPbgra32>(BitmapLockOptions.Read);
                            IDeviceBitmap bitmap2    = renderTarget.CreateSharedBitmap(bitmapLock, null);
                            this.deviceBitmaps[tileRow][tileColumn] = bitmap2;
                            this.tileBuffers[tileRow][tileColumn]   = bitmap.CreateRef <ColorPbgra32>();
                        }
                        else
                        {
                            ObjectPoolTicket <IDeviceBitmap> ticket = this.deviceBitmapTickets[tileRow][tileColumn];
                            if (ticket == null)
                            {
                                try
                                {
                                    ticket = this.owner.DeviceBitmapPool.Get(bitmap.Size);
                                }
                                catch (RecreateTargetException)
                                {
                                    return(false);
                                }
                                this.deviceBitmapTickets[tileRow][tileColumn] = ticket;
                                this.deviceBitmaps[tileRow][tileColumn]       = ticket.Value;
                            }
                            ticket.Value.CopyFromBitmap(null, bitmap, null);
                        }
                        this.isDeviceBitmapCurrent[tileRow][tileColumn] = true;
                    }
                }
            }
            return(true);
        }
示例#10
0
 protected override void OnDeactivate()
 {
     base.ToolSettings.PixelSampleMode.ValueChangedT -= new ValueChangedEventHandler <PixelSampleMode>(this.OnPixelSampleModeValueChangedT);
     DisposableUtil.Free <Surface>(ref this.allLayersRenderSurface);
     base.DocumentCanvas.CanvasLayers.Remove(this.previewRenderer);
     DisposableUtil.Free <PickerPreviewCanvasLayer>(ref this.previewRenderer);
     DisposableUtil.Free <Cursor>(ref this.colorPickerToolCursor);
     base.OnDeactivate();
 }
示例#11
0
 protected override void Dispose(bool disposing)
 {
     if (disposing)
     {
         DisposableUtil.Free <SelectionHighlightRenderer>(ref this.selectionHighlightRenderer);
         DisposableUtil.Free <ISurface <ColorBgra> >(ref this.renderBuffer);
     }
     base.Dispose(disposing);
 }
示例#12
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                DisposableUtil.Free(ref this.heifReaderHandle);
            }

            base.Dispose(disposing);
        }
示例#13
0
        private void UpdateTileWhileLocked(TileData tileData, ICancellationToken cancelToken)
        {
            RectInt32  tileSourceRect = this.tileMathHelper.GetTileSourceRect(tileData.Offset);
            RectDouble num2           = tileSourceRect;

            cancelToken.ThrowIfCancellationRequested <ICancellationToken>();
            object newCurrencyToken = this.renderData.CreateCurrencyToken();

            cancelToken.ThrowIfCancellationRequested <ICancellationToken>();
            IList <int?> list  = this.renderData.GetStrokeSampleIndicesInRect(tileSourceRect, tileData.CurrencyToken, newCurrencyToken);
            int          count = list.Count;

            if (count > 0)
            {
                SizeDouble      size = this.stamp.Size;
                RectDouble      num5 = new RectDouble(PointDouble.Zero, size);
                IDrawingContext dc   = null;
                try
                {
                    for (int i = 0; i < count; i++)
                    {
                        int?nullable = list[i];
                        if (nullable.HasValue)
                        {
                            if (tileData.Mask == null)
                            {
                                cancelToken.ThrowIfCancellationRequested <ICancellationToken>();
                                tileData.Mask = new SurfaceAlpha8(tileSourceRect.Size);
                            }
                            if (tileData.MaskRenderTarget == null)
                            {
                                cancelToken.ThrowIfCancellationRequested <ICancellationToken>();
                                tileData.MaskRenderTarget = RenderTarget.FromSurface(tileData.Mask, FactorySource.PerThread);
                            }
                            if (dc == null)
                            {
                                cancelToken.ThrowIfCancellationRequested <ICancellationToken>();
                                dc = DrawingContext.FromRenderTarget(tileData.MaskRenderTarget);
                                dc.UseTranslateTransform((float)-tileSourceRect.X, (float)-tileSourceRect.Y, MatrixMultiplyOrder.Prepend);
                                dc.AntialiasMode = AntialiasMode.Aliased;
                            }
                            int        valueOrDefault = nullable.GetValueOrDefault();
                            RectDouble bounds         = this.renderData.StrokeSamples[valueOrDefault].GetBounds(size);
                            RectDouble num9           = this.stamp.Antialiased ? bounds : RectDouble.Round(bounds, MidpointRounding.AwayFromZero);
                            cancelToken.ThrowIfCancellationRequested <ICancellationToken>();
                            RectDouble?srcRect = null;
                            dc.FillOpacityMask(this.lazyStampMaskDevBitmap.CancelableValue <DeviceBitmap>(), whiteBrush, OpacityMaskContent.Graphics, new RectDouble?(num9), srcRect);
                        }
                    }
                }
                finally
                {
                    DisposableUtil.Free <IDrawingContext>(ref dc);
                }
            }
            tileData.CurrencyToken = newCurrencyToken;
        }
示例#14
0
        public void Rollback()
        {
            object sync = this.sync;

            lock (sync)
            {
                try
                {
                    switch (this.state)
                    {
                    case SaveTransactionState.Initializing:
                    case SaveTransactionState.FailedInitialization:
                    case SaveTransactionState.Committing:
                    case SaveTransactionState.Committed:
                    case SaveTransactionState.RollingBack:
                    case SaveTransactionState.FailedRollback:
                    case SaveTransactionState.RolledBack:
                        throw new InvalidOperationException($"This transaction is not in a state that allows it to be committed ({this.state})");

                    case SaveTransactionState.Initialized:
                    case SaveTransactionState.FailedCommit:
                        break;

                    case SaveTransactionState.Disposed:
                        throw new ObjectDisposedException("SaveTransaction");

                    default:
                        throw new InternalErrorException(new InvalidEnumArgumentException("this.state", (int)this.state, typeof(SaveTransactionState)));
                    }
                    this.state = SaveTransactionState.RollingBack;
                    try
                    {
                        DisposableUtil.Free <GuardedStream>(ref this.guardedStream);
                    }
                    catch (IOException)
                    {
                    }
                    if (this.kernelTx != null)
                    {
                        this.kernelTx.Rollback();
                        this.kernelTx = null;
                    }
                    else if (this.tempPath != null)
                    {
                        File.Delete(this.tempPath);
                    }
                    this.tempPath = null;
                    this.state    = SaveTransactionState.RolledBack;
                }
                catch (Exception)
                {
                    this.state = SaveTransactionState.FailedRollback;
                    throw;
                }
            }
        }
示例#15
0
 private void Dispose(bool disposing)
 {
     this.disposed = true;
     if (disposing)
     {
         DisposableUtil.Free <RenderArgs>(ref this.srcArgs);
         DisposableUtil.Free <RenderArgs>(ref this.dstArgs);
         DisposableUtil.Free <EffectRendererWorkItemQueue>(ref this.threadPool);
     }
 }
示例#16
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                DisposableUtil.Free(ref this.heifWriterHandle);
                DisposableUtil.Free(ref this.writerErrors);
            }

            base.Dispose(disposing);
        }
示例#17
0
 protected override void OnDeactivate()
 {
     DisposableUtil.Free <Cursor>(ref this.cursorZoom);
     DisposableUtil.Free <Cursor>(ref this.cursorZoomIn);
     DisposableUtil.Free <Cursor>(ref this.cursorZoomOut);
     DisposableUtil.Free <Cursor>(ref this.cursorZoomPan);
     base.DocumentCanvas.CanvasLayers.Remove(this.outlineRenderer);
     DisposableUtil.Free <SelectionCanvasLayer>(ref this.outlineRenderer);
     base.OnDeactivate();
 }
示例#18
0
            protected override void Dispose(bool disposing)
            {
                if (disposing)
                {
                    DisposableUtil.Free(ref this.successMessage);
                    DisposableUtil.Free(ref this.writeErrorMessage);
                }

                base.Dispose(disposing);
            }
示例#19
0
        protected override void OnExit(ExitEventArgs e)
        {
            // process this class level tasks
            StopProxy();
            this.Command.ProxyStateChanged -= command_ProxyStateChanged;
            DisposableUtil.ClearDisposableObject(ref this.notifyIcon);

            // process the base class level tasks
            base.OnExit(e);
        }
 private void Dispose(bool disposing)
 {
     if (disposing)
     {
         DisposableUtil.Free <EditableDataWorkItemQueue <PointInt32> >(ref this.workItemQueue);
         Work.QueueDisposeStream((IEnumerable <IDisposable>) this.tileBuffers.SelectMany <IBitmap <ColorPbgra32> >());
         this.tileBuffers = null;
         this.source      = null;
     }
 }
示例#21
0
            public void Args_target_null()
            {
                // ARRANGE
                SampleDisposable arg = null;

                // ACT
                DisposableUtil.DisposeSuppressingErrors(arg);

                // ASSERT
                // no ArgumentNullException expected
            }
示例#22
0
        private void OnMenuHelpAboutClick(object sender, EventArgs e)
        {
            AboutDialog dialog;

            using (new WaitCursorChanger(base.AppWorkspace))
            {
                dialog = new AboutDialog();
            }
            dialog.ShowDialog(base.AppWorkspace);
            DisposableUtil.Free <AboutDialog>(ref dialog);
        }
示例#23
0
 private void FreeRow(int row)
 {
     this.rowPtrs[row] = IntPtr.Zero;
     if (!(this.source is ISurface <TPixel>))
     {
         DisposableUtil.Free <SafeGCHandle <TPixel[]> >(ref this.pinnedRows[row]);
         this.freeRow   = this.rows[row];
         this.rows[row] = null;
         this.currentRowCount--;
     }
 }
示例#24
0
 public void Dispose()
 {
     if (this.needsDisposal)
     {
         DisposableUtil.Free <T>(ref this.objectRefT);
     }
     else
     {
         this.objectRefT = default(T);
     }
 }
 protected override void OnInvalidateDeviceResources()
 {
     DisposableUtil.Free <IDeviceBitmap>(ref this.renderedInteriorDeviceBitmap);
     DisposableUtil.FreeContents <IDeviceBitmap>(this.renderedDashedOutlineDeviceBitmaps);
     this.ClearDeviceBitmapPool();
     if ((!base.IsDisposed && !this.isRedrawing) && this.isRedrawNeeded)
     {
         this.QueueBeginRedraw();
     }
     base.OnInvalidateDeviceResources();
 }
        private void ReturnOrFreeDeviceBitmap(ref IDeviceBitmap deviceBitmap)
        {
            object obj2;

            if (((deviceBitmap != null) && AttachedData.TryGetValue(deviceBitmap, isPooledBitmapAttachedKey, out obj2)) && ((bool)obj2))
            {
                this.deviceBitmapPool.Enqueue(deviceBitmap);
                deviceBitmap = null;
            }
            DisposableUtil.Free <IDeviceBitmap>(ref deviceBitmap);
        }
示例#27
0
 protected override unsafe void Dispose(bool disposing)
 {
     DisposableUtil.Free <IBufferLock>(ref this.bufferLockRef, disposing);
     DisposableUtil.Free <IBuffer>(ref this.bufferRef, disposing);
     DisposableUtil.Free <IAllocator>(ref this.allocator, disposing);
     this.buffer     = null;
     this.bufferSize = 0L;
     this.length     = 0L;
     this.position   = 0L;
     base.Dispose(disposing);
 }
示例#28
0
        public override void ResetBuffer()
        {
            // reset this class level
            this.unflushedStart = 0;
            this.chunkingOutput = null;                 // this object does not have its ownership
            this.bodyLength     = 0;
            DisposableUtil.ClearDisposableObject(ref this.bodyStream);

            // reset the base class level
            base.ResetBuffer();
        }
示例#29
0
            public void General()
            {
                // ARRANGE
                SampleDisposable arg = new SampleDisposable();

                // ACT
                DisposableUtil.DisposeSuppressingErrors(arg);

                // ASSERT
                Assert.Equal(1, arg.DisposedCount);
            }
示例#30
0
            public void Args_target_null()
            {
                // ARRANGE
                SampleDisposable arg = null;

                // ACT
                DisposableUtil.ClearDisposableObject(ref arg);

                // ASSERT
                // no ArgumentNullException expected
                Assert.Equal(null, arg);
            }