protected override void Dispose(bool disposing) { if (disposing) { DisposableUtil.Free <Document>(ref this.oldDocument); } base.Dispose(disposing); }
public override void Dispose() { // dispose this class level this.chunkingOutput = null; DisposableUtil.ClearDisposableObject(ref this.bodyStream); // dispose the base class level base.Dispose(); }
protected override void Dispose(bool disposing) { if (disposing && (this.document != null)) { this.Document = null; } DisposableUtil.Free <ThumbnailManager>(ref this.thumbnailManager, disposing); base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing) { DisposableUtil.Free <DropShadowRenderer>(ref this.dropShadowRenderer); DisposableUtil.Free <SelectionHighlightRenderer>(ref this.selectionHighlightRenderer); } base.Dispose(disposing); }
private void DestroyBitmapResources() { if (this.wheelBackgroundDeviceBitmap != null) { this.wheelBackgroundDeviceBitmap.BitmapSource = null; this.wheelBackgroundDeviceBitmap = null; } DisposableUtil.Free <ISurface <ColorBgra> >(ref this.wheelBackgroundSurface); }
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); }
/// <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); }
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(); }
protected override void Dispose(bool disposing) { if (disposing) { DisposableUtil.Free <SelectionHighlightRenderer>(ref this.selectionHighlightRenderer); DisposableUtil.Free <ISurface <ColorBgra> >(ref this.renderBuffer); } base.Dispose(disposing); }
protected override void Dispose(bool disposing) { if (disposing) { DisposableUtil.Free(ref this.heifReaderHandle); } base.Dispose(disposing); }
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; }
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; } } }
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); } }
protected override void Dispose(bool disposing) { if (disposing) { DisposableUtil.Free(ref this.heifWriterHandle); DisposableUtil.Free(ref this.writerErrors); } base.Dispose(disposing); }
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(); }
protected override void Dispose(bool disposing) { if (disposing) { DisposableUtil.Free(ref this.successMessage); DisposableUtil.Free(ref this.writeErrorMessage); } base.Dispose(disposing); }
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; } }
public void Args_target_null() { // ARRANGE SampleDisposable arg = null; // ACT DisposableUtil.DisposeSuppressingErrors(arg); // ASSERT // no ArgumentNullException expected }
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); }
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--; } }
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); }
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); }
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(); }
public void General() { // ARRANGE SampleDisposable arg = new SampleDisposable(); // ACT DisposableUtil.DisposeSuppressingErrors(arg); // ASSERT Assert.Equal(1, arg.DisposedCount); }
public void Args_target_null() { // ARRANGE SampleDisposable arg = null; // ACT DisposableUtil.ClearDisposableObject(ref arg); // ASSERT // no ArgumentNullException expected Assert.Equal(null, arg); }