public MoveToolChanges(IEnumerable <KeyValuePair <string, object> > drawingSettingsValues, MoveToolPixelSource pixelSource, ISurface <ColorBgra> bitmapSource, bool leaveCopyBehind, RectDouble baseBounds, Matrix3x2Double baseTransform, Matrix3x2Double deltaTransform, TransformEditingMode editingMode, Matrix3x2Double editTransform, PointDouble?rotationAnchorOffset) : base(drawingSettingsValues) { if (((pixelSource == MoveToolPixelSource.Bitmap) && (bitmapSource == null)) || ((pixelSource != MoveToolPixelSource.Bitmap) && (bitmapSource != null))) { ExceptionUtil.ThrowArgumentException($"MoveToolPixelSource.{pixelSource} specified, but bitmapSourcePersistenceKey={this.bitmapSourcePersistenceKey}"); } if (bitmapSource == null) { this.bitmapSourcePO = null; this.bitmapSourcePersistenceKey = Guid.Empty; } else { this.bitmapSourcePO = new PersistedObject <ISurface <ColorBgra> >(bitmapSource, true); this.bitmapSourcePersistenceKey = PersistedObjectLocker.Add <ISurface <ColorBgra> >(this.bitmapSourcePO); } this.pixelSource = pixelSource; this.leaveCopyBehind = leaveCopyBehind; this.baseBounds = baseBounds; this.baseTransform = baseTransform; this.deltaTransform = deltaTransform; this.editingMode = editingMode; this.editTransform = editTransform; this.rotationAnchorOffset = rotationAnchorOffset; this.Initialize(); }
private void Initialize() { if ((this.bitmapSourcePO == null) && (this.bitmapSourcePersistenceKey != Guid.Empty)) { this.bitmapSourcePO = PersistedObjectLocker.TryGet <ISurface <ColorBgra> >(this.bitmapSourcePersistenceKey); if (this.bitmapSourcePO == null) { throw new PaintDotNet.InternalErrorException("this.bitmapSource == null"); } } }
private void Initialize() { if ((this.baseGeometryPO == null) && (this.baseGeometryPersistenceKey != Guid.Empty)) { this.baseGeometryPO = PersistedObjectLocker.TryGet <GeometryList>(this.baseGeometryPersistenceKey); if (this.baseGeometryPO == null) { throw new InternalErrorException("this.baseGeometry == null"); } } }
public MagicWandToolChanges(IEnumerable <KeyValuePair <string, object> > drawingSettingsValues, PointDouble originPoint, PaintDotNet.SelectionCombineMode?selectionCombineModeOverride, FloodMode?floodModeOverride, GeometryList baseGeometry) : base(drawingSettingsValues, originPoint, floodModeOverride) { this.selectionCombineModeOverride = selectionCombineModeOverride; if (baseGeometry == null) { this.baseGeometryPO = null; this.baseGeometryPersistenceKey = Guid.Empty; } else { this.baseGeometryPO = new PersistedObject <GeometryList>(baseGeometry, true); this.baseGeometryPersistenceKey = PersistedObjectLocker.Add <GeometryList>(this.baseGeometryPO); } this.Initialize(); }
public PaintBucketToolChanges(IEnumerable <KeyValuePair <string, object> > drawingSettingsValues, PointDouble originPoint, FloodMode?floodModeOverride, PaintDotNet.WhichUserColor whichUserColor, GeometryList clippingMask) : base(drawingSettingsValues, originPoint, floodModeOverride) { this.whichUserColor = whichUserColor; if (clippingMask == null) { this.clippingMaskPO = null; this.clippingMaskPersistenceKey = Guid.Empty; } else { this.clippingMaskPO = new PersistedObject <GeometryList>(clippingMask, true); this.clippingMaskPersistenceKey = PersistedObjectLocker.Add <GeometryList>(this.clippingMaskPO); } this.Initialize(); }
protected override HistoryMemento OnUndo() { BitmapHistoryMementoData data = this.Data as BitmapHistoryMementoData; BitmapLayer layer = (BitmapLayer)this.historyWorkspace.Document.Layers[this.layerIndex]; PdnRegion region; MaskedSurface maskedSurface = null; if (this.poMaskedSurfaceRef != Guid.Empty) { PersistedObject <MaskedSurface> poMS = PersistedObjectLocker.Get <MaskedSurface>(this.poMaskedSurfaceRef); maskedSurface = poMS.Object; region = maskedSurface.CreateRegion(); } else if (data.UndoImage == null) { region = data.SavedRegion; } else { region = data.UndoImage.Region; } BitmapHistoryMemento redo; if (this.poUndoMaskedSurfaceRef == Guid.Empty) { redo = new BitmapHistoryMemento(Name, Image, this.historyWorkspace, this.layerIndex, region); redo.poUndoMaskedSurfaceRef = this.poMaskedSurfaceRef; } else { redo = new BitmapHistoryMemento(Name, Image, this.historyWorkspace, this.layerIndex, this.poUndoMaskedSurfaceRef); } PdnRegion simplified = Utility.SimplifyAndInflateRegion(region); if (maskedSurface != null) { maskedSurface.Draw(layer.Surface); } else if (data.UndoImage == null) { using (FileStream input = FileSystem.OpenStreamingFile(this.tempFileName, FileAccess.Read)) { LoadSurfaceRegion(input, layer.Surface, data.SavedRegion); } data.SavedRegion.Dispose(); this.tempFileHandle.Dispose(); this.tempFileHandle = null; } else { data.UndoImage.Draw(layer.Surface); data.UndoImage.Dispose(); } layer.Invalidate(simplified); simplified.Dispose(); return(redo); }
public MoveToolContext(SerializationInfo info, StreamingContext context) : base(info, context) { this.poLiftedPixelsGuid = (Guid)info.GetValue("poLiftedPixelsGuid", typeof(Guid)); this.poLiftedPixels = PersistedObjectLocker.Get <MaskedSurface>(this.poLiftedPixelsGuid); }