/// <summary> /// Initializes a new instance of the SelectionUndoTask class /// </summary> /// <param name="targetBitmap">The target bitmap for the undo task</param> /// <param name="selectionBitmap">The selection bitmap</param> /// <param name="originalSlice">The original image slice before a Move operation was made</param> /// <param name="selectionStartArea">The area that the selection started at</param> /// <param name="area">The area of the affected SelectionUndoTask</param> /// <param name="operationType">The operation type of this SelectionUndoTask</param> /// <param name="compositingMode">The compositing mode for the operation</param> public SelectionUndoTask(Bitmap targetBitmap, Bitmap selectionBitmap, Bitmap originalSlice, Rectangle selectionStartArea, Rectangle area, SelectionOperationType operationType, CompositingMode compositingMode) { _targetbitmap = targetBitmap; _selectionBitmap = (Bitmap)selectionBitmap.Clone(); _originalSlice = (Bitmap)originalSlice?.Clone(); _selectionStartArea = selectionStartArea; _area = area; _operationType = operationType; _compositingMode = compositingMode; }
/// <summary> /// Starts the selection operation witht he given area, bitmap and operation type /// </summary> /// <param name="area">The area to place the bitmap at</param> /// <param name="pasteBitmap">The bitmap to paste</param> /// <param name="operation">The operation type to mark this selection as</param> public void StartOperation(Rectangle area, Bitmap pasteBitmap, SelectionOperationType operation) { pictureBox.OwningPanel.UndoSystem.StartGroupUndo("Selection", true); OperationType = operation; ForceApplyChanges = false; selectionBitmap?.Dispose(); selected = true; selectedArea = area; selectedStartArea = area; // Get the selected area if (pasteBitmap == null) { pasteBitmap = ExtractBitmap(area); // Clear the bitmap behind the image graphics = Graphics.FromImage(pictureBox.Image); graphics.SetClip(selectedArea); graphics.Clear(Color.Transparent); graphics.Dispose(); graphics = null; UpdateClipboardState(); } selectionBitmap = pasteBitmap; pictureBox.Invalidate(GetSelectionArea(true)); _animTimer.Start(); }
/// <summary> /// Starts the selection operation with the given area and operation mode /// </summary> /// <param name="area">The area to select</param> /// <param name="operation">The operation mode to apply</param> public void StartOperation(Rectangle area, SelectionOperationType operation) { StartOperation(area, null, operation); }