public void TakeSnapshot() { var doc = PintaCore.Workspace.ActiveDocument; old_selection = doc.Selection.Clone (); show_selection = PintaCore.Layers.ShowSelection; hide_tool_layer = doc.ToolLayer.Hidden; }
private void Swap () { DocumentSelection swap_selection = PintaCore.Workspace.ActiveDocument.Selection; PintaCore.Workspace.ActiveDocument.Selection = old_selection; old_selection = swap_selection; Matrix swap_transform = new Matrix(); swap_transform.InitMatrix(PintaCore.Layers.SelectionLayer.Transform); PintaCore.Layers.SelectionLayer.Transform.InitMatrix(old_transform); old_transform.InitMatrix(swap_transform); if (lifted) { // Grab the original surface ImageSurface surf = PintaCore.Layers[layer_index].Surface; // Undo to the "old" surface PintaCore.Layers[layer_index].Surface = old_surface; // Store the original surface for Redo old_surface = surf; is_lifted = !is_lifted; doc.ShowSelectionLayer = is_lifted; } PintaCore.Workspace.Invalidate (); }
private void Swap() { DocumentSelection swap_selection = PintaCore.Workspace.ActiveDocument.Selection; PointD swap_offset = PintaCore.Layers.SelectionLayer.Offset; PintaCore.Workspace.ActiveDocument.Selection = old_selection; PintaCore.Layers.SelectionLayer.Offset = old_offset; old_selection = swap_selection; old_offset = swap_offset; if (lifted) { // Grab the original surface ImageSurface surf = PintaCore.Layers[layer_index].Surface; // Undo to the "old" surface PintaCore.Layers[layer_index].Surface = old_surface; // Store the original surface for Redo old_surface = surf; is_lifted = !is_lifted; doc.ShowSelectionLayer = is_lifted; } PintaCore.Workspace.Invalidate(); }
private void Swap() { var doc = PintaCore.Workspace.ActiveDocument; DocumentSelection swap_selection = doc.Selection; bool swap_show = PintaCore.Layers.ShowSelection; bool swap_hide_tool_layer = doc.ToolLayer.Hidden; doc.Selection = old_selection; PintaCore.Layers.ShowSelection = show_selection; doc.ToolLayer.Hidden = hide_tool_layer; old_selection = swap_selection; show_selection = swap_show; hide_tool_layer = swap_hide_tool_layer; swap_selection = doc.PreviousSelection; doc.PreviousSelection = old_previous_selection; old_previous_selection = swap_selection; PintaCore.Workspace.CallSelectionChanged(this, EventArgs.Empty); PintaCore.Workspace.Invalidate(); }
public override void Undo() { // maintain the current scaling setting after the operation double scale = PintaCore.Workspace.Scale; Size swap = PintaCore.Workspace.ImageSize; PintaCore.Workspace.ImageSize = old_size; PintaCore.Workspace.CanvasSize = old_size; old_size = swap; base.Undo(); if (RestoreSelection != null) { DocumentSelection old = PintaCore.Workspace.ActiveDocument.Selection; PintaCore.Workspace.ActiveDocument.Selection = RestoreSelection.Clone(); if (old != null) { old.DisposeSelection(); } PintaCore.Layers.ShowSelection = true; } else { PintaCore.Layers.ResetSelectionPath(); } PintaCore.Workspace.Invalidate(); PintaCore.Workspace.Scale = scale; }
private void Swap() { DocumentSelection swap_selection = PintaCore.Workspace.ActiveDocument.Selection; PintaCore.Workspace.ActiveDocument.Selection = old_selection; old_selection = swap_selection; Matrix swap_transform = new Matrix(); swap_transform.InitMatrix(PintaCore.Layers.SelectionLayer.Transform); PintaCore.Layers.SelectionLayer.Transform.InitMatrix(old_transform); old_transform.InitMatrix(swap_transform); if (lifted) { // Grab the original surface ImageSurface surf = PintaCore.Layers[layer_index].Surface; // Undo to the "old" surface PintaCore.Layers[layer_index].Surface = old_surface; // Store the original surface for Redo old_surface = surf; is_lifted = !is_lifted; doc.ShowSelectionLayer = is_lifted; } PintaCore.Workspace.Invalidate(); }
public PasteHistoryItem(Gdk.Pixbuf pasteImage, DocumentSelection oldSelection) { Text = Translations.GetString("Paste"); Icon = Resources.StandardIcons.EditPaste; paste_image = pasteImage; old_selection = oldSelection; }
public void TakeSnapshot() { var doc = PintaCore.Workspace.ActiveDocument; old_selection = doc.Selection.Clone(); old_previous_selection = doc.PreviousSelection.Clone(); hide_tool_layer = doc.ToolLayer.Hidden; }
public void TakeSnapshot() { var doc = PintaCore.Workspace.ActiveDocument; old_selection = doc.Selection.Clone(); show_selection = PintaCore.Layers.ShowSelection; hide_tool_layer = doc.ToolLayer.Hidden; }
public PasteHistoryItem(Gdk.Pixbuf pasteImage, DocumentSelection oldSelection) { Text = Catalog.GetString("Paste"); Icon = Stock.Paste; paste_image = pasteImage; old_selection = oldSelection; }
public PasteHistoryItem (Gdk.Pixbuf pasteImage, DocumentSelection oldSelection, bool oldShowSelection) { Text = Catalog.GetString ("Paste"); Icon = Stock.Paste; paste_image = pasteImage; old_selection = oldSelection; old_show_selection = oldShowSelection; }
/// <summary> /// Make a complete copy of the Selection. /// </summary> /// <returns>A copy of this Selection (as a DocumentSelection object).</returns> public DocumentSelection Clone() { DocumentSelection clonedSelection = new DocumentSelection(); clonedSelection.selection_path = selection_path.Clone(); clonedSelection.SelectionPolygons = SelectionPolygons.ToList(); clonedSelection.SelectionClipper = new Clipper(); return(clonedSelection); }
private void Swap() { // Swap the selection paths, and whether the // selection path should be visible Document doc = PintaCore.Workspace.ActiveDocument; DocumentSelection swap_selection = doc.Selection; doc.Selection = old_selection; old_selection = swap_selection; }
private void Swap() { DocumentSelection swap_selection = PintaCore.Workspace.ActiveDocument.Selection; bool swap_show = PintaCore.Layers.ShowSelection; PintaCore.Workspace.ActiveDocument.Selection = old_selection; PintaCore.Layers.ShowSelection = show_selection; old_selection = swap_selection; show_selection = swap_show; PintaCore.Workspace.Invalidate(); }
public void TakeSnapshot(bool lift) { lifted = lift; is_lifted = true; if (lift) { layer_index = doc.CurrentLayerIndex; old_surface = doc.CurrentLayer.Surface.Clone(); } old_selection = PintaCore.Workspace.ActiveDocument.Selection.Clone(); old_offset = PintaCore.Layers.SelectionLayer.Offset; }
public void TakeSnapshot(bool lift) { lifted = lift; is_lifted = true; if (lift) { layer_index = doc.CurrentUserLayerIndex; old_surface = doc.CurrentUserLayer.Surface.Clone(); } old_selection = PintaCore.Workspace.ActiveDocument.Selection.Clone(); old_transform.InitMatrix(PintaCore.Layers.SelectionLayer.Transform); }
public Document(Gdk.Size size) { Selection = new DocumentSelection(); Guid = Guid.NewGuid(); Layers = new DocumentLayers(this); Workspace = new DocumentWorkspace(this); IsDirty = false; HasFile = false; HasBeenSavedInSession = false; ImageSize = size; ResetSelectionPaths(); }
/// <summary> /// Make a complete copy of the Selection. /// </summary> /// <returns>A copy of this Selection (as a DocumentSelection object).</returns> public DocumentSelection Clone() { DocumentSelection clonedSelection = new DocumentSelection(); if (selection_path != null) { clonedSelection.selection_path = selection_path.Clone(); } clonedSelection.SelectionPolygons = SelectionPolygons.ToList(); clonedSelection.SelectionClipper = new Clipper(); clonedSelection.selOrigin = new PointD(selOrigin.X, selOrigin.Y); clonedSelection.selEnd = new PointD(selEnd.X, selEnd.Y); return(clonedSelection); }
private void Swap() { var doc = PintaCore.Workspace.ActiveDocument; DocumentSelection swap_selection = doc.Selection; bool swap_show = PintaCore.Layers.ShowSelection; bool swap_hide_tool_layer = doc.ToolLayer.Hidden; doc.Selection = old_selection; PintaCore.Layers.ShowSelection = show_selection; doc.ToolLayer.Hidden = hide_tool_layer; old_selection = swap_selection; show_selection = swap_show; hide_tool_layer = swap_hide_tool_layer; PintaCore.Workspace.Invalidate(); }
private void Swap() { var doc = PintaCore.Workspace.ActiveDocument; DocumentSelection swap_selection = doc.Selection; bool swap_hide_tool_layer = doc.ToolLayer.Hidden; doc.Selection = old_selection; doc.ToolLayer.Hidden = hide_tool_layer; old_selection = swap_selection; hide_tool_layer = swap_hide_tool_layer; swap_selection = old_previous_selection; old_previous_selection = doc.PreviousSelection; doc.PreviousSelection = swap_selection; PintaCore.Workspace.Invalidate(); }
public override void Undo() { var doc = PintaCore.Workspace.ActiveDocument; // maintain the current scaling setting after the operation double scale = PintaCore.Workspace.Scale; Size swap = PintaCore.Workspace.ImageSize; var window = PintaCore.Workspace.ActiveWorkspace.Canvas.Window; window.FreezeUpdates(); PintaCore.Workspace.ImageSize = old_size; PintaCore.Workspace.CanvasSize = old_size; old_size = swap; base.Undo(); if (RestoreSelection != null) { DocumentSelection old = PintaCore.Workspace.ActiveDocument.Selection; doc.Selection = RestoreSelection.Clone(); if (old != null) { old.Dispose(); } } else { doc.ResetSelectionPaths(); } PintaCore.Workspace.Invalidate(); PintaCore.Workspace.Scale = scale; PintaCore.Actions.View.UpdateCanvasScale(); window.ThawUpdates(); }
private void Swap () { var doc = PintaCore.Workspace.ActiveDocument; DocumentSelection swap_selection = doc.Selection; bool swap_show = PintaCore.Layers.ShowSelection; bool swap_hide_tool_layer = doc.ToolLayer.Hidden; doc.Selection = old_selection; PintaCore.Layers.ShowSelection = show_selection; doc.ToolLayer.Hidden = hide_tool_layer; old_selection = swap_selection; show_selection = swap_show; hide_tool_layer = swap_hide_tool_layer; swap_selection = old_previous_selection; old_previous_selection = doc.PreviousSelection; doc.PreviousSelection = swap_selection; PintaCore.Workspace.Invalidate (); }
public Document(Gdk.Size size) { Selection = new DocumentSelection(); Guid = Guid.NewGuid(); Workspace = new DocumentWorkspace(this); IsDirty = false; HasFile = false; HasBeenSavedInSession = false; ImageSize = size; UserLayers = new List <UserLayer>(); tool_layer = CreateLayer("Tool Layer"); tool_layer.Hidden = true; selection_layer = CreateLayer("Selection Layer"); selection_layer.Hidden = true; ResetSelectionPaths(); }
public Document (Gdk.Size size) { Selection = new DocumentSelection (); Guid = Guid.NewGuid (); Workspace = new DocumentWorkspace (this); IsDirty = false; HasFile = false; HasBeenSavedInSession = false; ImageSize = size; UserLayers = new List<UserLayer>(); tool_layer = CreateLayer ("Tool Layer"); tool_layer.Hidden = true; selection_layer = CreateLayer ("Selection Layer"); selection_layer.Hidden = true; ResetSelectionPaths (); }
/// <summary> /// Make a complete copy of the Selection. /// </summary> /// <returns>A copy of this Selection (as a DocumentSelection object).</returns> public DocumentSelection Clone() { DocumentSelection clonedSelection = new DocumentSelection(); clonedSelection.selection_path = selection_path.Clone(); clonedSelection.SelectionPolygons = SelectionPolygons.ToList(); clonedSelection.SelectionClipper = new Clipper(); return clonedSelection; }
public void TakeSnapshot (bool lift) { lifted = lift; is_lifted = true; if (lift) { layer_index = doc.CurrentUserLayerIndex; old_surface = doc.CurrentUserLayer.Surface.Clone (); } old_selection = PintaCore.Workspace.ActiveDocument.Selection.Clone (); old_transform.InitMatrix(PintaCore.Layers.SelectionLayer.Transform); }
protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point) { ctrlKey = (args.Event.State & ModifierType.ControlMask) != 0; //Store the mouse position. Point pt = point.ToGdkPoint(); // Grab focus so we can get keystrokes canvas.GrabFocus (); if (selection != null) selection.Dispose (); selection = PintaCore.Workspace.ActiveDocument.Selection.Clone (); // A right click allows you to move the text around if (args.Event.Button == 3) { //The user is dragging text with the right mouse button held down, so track the mouse as it moves. tracking = true; //Remember the position of the mouse before the text is dragged. startMouseXY = point; startClickPoint = clickPoint; //Change the cursor to indicate that the text is being dragged. SetCursor(cursor_hand); return; } // The user clicked the left mouse button if (args.Event.Button == 1) { // If the user is [editing or holding down Ctrl] and clicked //within the text, move the cursor to the click location if ((is_editing || ctrlKey) && CurrentTextBounds.ContainsCorrect(pt)) { StartEditing(); //Change the position of the cursor to where the mouse clicked. TextPosition p = CurrentTextLayout.PointToTextPosition(pt); CurrentTextEngine.SetCursorPosition(p, true); //Redraw the text with the new cursor position. RedrawText(true, true); return; } // We're already editing and the user clicked outside the text, // commit the user's work, and start a new edit switch (CurrentTextEngine.State) { // We were editing, save and stop case TextMode.Uncommitted: StopEditing(true); break; // We were editing, but nothing had been // keyed. Stop editing. case TextMode.Unchanged: StopEditing(false); break; } if (ctrlKey) { //Go through every UserLayer. foreach (UserLayer ul in PintaCore.Workspace.ActiveDocument.UserLayers) { //Check each UserLayer's editable text boundaries to see if they contain the mouse position. if (ul.textBounds.ContainsCorrect(pt)) { //The mouse clicked on editable text. //Change the current UserLayer to the Layer that contains the text that was clicked on. PintaCore.Workspace.ActiveDocument.SetCurrentUserLayer(ul); //The user is editing text now. is_editing = true; //Set the cursor in the editable text where the mouse was clicked. TextPosition p = CurrentTextLayout.PointToTextPosition(pt); CurrentTextEngine.SetCursorPosition(p, true); //Redraw the editable text with the cursor. RedrawText(true, true); //Don't check any more UserLayers - stop at the first UserLayer that has editable text containing the mouse position. return; } } } else { if (CurrentTextEngine.State == TextMode.NotFinalized) { //The user is making a new text and the old text hasn't been finalized yet. FinalizeText(); } if (!is_editing) { // Start editing at the cursor location clickPoint = pt; CurrentTextEngine.Clear(); clickPoint.Offset (0, -CurrentTextLayout.FontHeight/2); CurrentTextEngine.Origin = clickPoint; StartEditing(); RedrawText(true, true); } } } }
/// <summary> /// Finalize re-editable text (if applicable). /// </summary> public void FinalizeText() { //If this is true, don't finalize any text - this is used to prevent the code from looping recursively. if (!ignoreCloneFinalizations) { //Only bother finalizing text if editing. if (CurrentTextEngine.State != TextMode.Unchanged) { //Start ignoring any Surface.Clone calls from this point on (so that it doesn't start to loop). ignoreCloneFinalizations = true; Document doc = PintaCore.Workspace.ActiveDocument; //Create a backup of everything before redrawing the text and etc. Cairo.ImageSurface oldTextSurface = doc.CurrentUserLayer.TextLayer.Layer.Surface.Clone(); Cairo.ImageSurface oldUserSurface = doc.CurrentUserLayer.Surface.Clone(); TextEngine oldTextEngine = CurrentTextEngine.Clone(); //Draw the text onto the UserLayer (without the cursor) rather than the TextLayer. RedrawText(false, false); //Clear the TextLayer. doc.CurrentUserLayer.TextLayer.Layer.Clear(); //Clear the text and its boundaries. CurrentTextEngine.Clear(); CurrentTextBounds = Gdk.Rectangle.Zero; //Create a new TextHistoryItem so that the finalization of the text can be undone. Construct //it on the spot so that it is more memory efficient if the changes are small. TextHistoryItem hist = new TextHistoryItem(Icon, FinalizeName, oldTextSurface, oldUserSurface, oldTextEngine, doc.CurrentUserLayer); //Add the new TextHistoryItem. doc.History.PushNewItem(hist); //Stop ignoring any Surface.Clone calls from this point on. ignoreCloneFinalizations = false; //Now that the text has been finalized, change its state. CurrentTextEngine.State = TextMode.Unchanged; if (selection != null) { selection.Dispose (); selection = null; } } } }
private void StartEditing() { is_editing = true; imContext.ClientWindow = PintaCore.Workspace.ActiveWorkspace.Canvas.GdkWindow; if (selection == null) selection = PintaCore.Workspace.ActiveDocument.Selection.Clone (); //Start ignoring any Surface.Clone calls from this point on (so that it doesn't start to loop). ignoreCloneFinalizations = true; //Store the previous state of the current UserLayer's and TextLayer's ImageSurfaces. user_undo_surface = PintaCore.Workspace.ActiveDocument.CurrentUserLayer.Surface.Clone(); text_undo_surface = PintaCore.Workspace.ActiveDocument.CurrentUserLayer.TextLayer.Layer.Surface.Clone(); //Store the previous state of the Text Engine. undo_engine = CurrentTextEngine.Clone(); //Stop ignoring any Surface.Clone calls from this point on. ignoreCloneFinalizations = false; }
public void TakeSnapshot() { old_selection = PintaCore.Workspace.ActiveDocument.Selection.Clone(); show_selection = PintaCore.Layers.ShowSelection; }
public void TakeSnapshot() { old_selection = PintaCore.Workspace.ActiveDocument.Selection.Clone (); show_selection = PintaCore.Layers.ShowSelection; }
private void Swap() { DocumentSelection swap_selection = PintaCore.Workspace.ActiveDocument.Selection; bool swap_show = PintaCore.Layers.ShowSelection; PintaCore.Workspace.ActiveDocument.Selection = old_selection; PintaCore.Layers.ShowSelection = show_selection; old_selection = swap_selection; show_selection = swap_show; PintaCore.Workspace.Invalidate (); }
private void Swap () { // Swap the selection paths, and whether the // selection path should be visible Document doc = PintaCore.Workspace.ActiveDocument; DocumentSelection swap_selection = doc.Selection; bool swap_show_sel = doc.ShowSelection; doc.Selection = old_selection; doc.ShowSelection = old_show_selection; old_selection = swap_selection; old_show_selection = swap_show_sel; }
private void Swap() { DocumentSelection swap_selection = PintaCore.Workspace.ActiveDocument.Selection; PointD swap_offset = PintaCore.Layers.SelectionLayer.Offset; PintaCore.Workspace.ActiveDocument.Selection = old_selection; PintaCore.Layers.SelectionLayer.Offset = old_offset; old_selection = swap_selection; old_offset = swap_offset; if (lifted) { // Grab the original surface ImageSurface surf = PintaCore.Layers[layer_index].Surface; // Undo to the "old" surface PintaCore.Layers[layer_index].Surface = old_surface; // Store the original surface for Redo old_surface = surf; is_lifted = !is_lifted; doc.ShowSelectionLayer = is_lifted; } PintaCore.Workspace.Invalidate (); }
public void PerformSelectionMode(Point[][] polygonSet) { Document doc = PintaCore.Workspace.ActiveDocument; //Convert Pinta's passed in Polygon Set to a Clipper Polygon collection. List <List <IntPoint> > newPolygons = DocumentSelection.ConvertToPolygons(polygonSet); doc.Selection = doc.PreviousSelection.Clone(); using (Context g = new Context(PintaCore.Layers.CurrentLayer.Surface)) { //Make sure time isn't wasted if the CombineMode is Replace - Replace is much simpler than the other 4 selection modes. if (combineMode == CombineMode.Replace) { //Clear any previously stored Polygons. doc.Selection.SelectionPolygons.Clear(); //Set the resulting selection path to the new selection path. doc.Selection.SelectionPolygons = newPolygons; doc.Selection.SelectionPath = g.CreatePolygonPath(polygonSet); } else { List <List <IntPoint> > resultingPolygons = new List <List <IntPoint> >(); //Specify the Clipper Subject (the previous Polygons) and the Clipper Clip (the new Polygons). //Note: for Union, ignore the Clipper Library instructions - the new polygon(s) should be Clips, not Subjects! doc.Selection.SelectionClipper.AddPolygons(doc.Selection.SelectionPolygons, PolyType.ptSubject); doc.Selection.SelectionClipper.AddPolygons(newPolygons, PolyType.ptClip); switch (combineMode) { case CombineMode.Xor: //Xor means "Combine both Polygon sets, but leave out any areas of intersection between the two." doc.Selection.SelectionClipper.Execute(ClipType.ctXor, resultingPolygons); break; case CombineMode.Exclude: //Exclude == Difference //Exclude/Difference means "Subtract any overlapping areas of the new Polygon set from the old Polygon set." doc.Selection.SelectionClipper.Execute(ClipType.ctDifference, resultingPolygons); break; case CombineMode.Intersect: //Intersect means "Leave only the overlapping areas between the new and old Polygon sets." doc.Selection.SelectionClipper.Execute(ClipType.ctIntersection, resultingPolygons); break; default: //Default should only be *CombineMode.Union*, but just in case... //Union means "Combine both Polygon sets, and keep any overlapping areas as well." doc.Selection.SelectionClipper.Execute(ClipType.ctUnion, resultingPolygons); break; } //After using Clipper, it has to be cleared so there are no conflicts with its next usage. doc.Selection.SelectionClipper.Clear(); //Set the resulting selection path to the calculated ("clipped") selection path. doc.Selection.SelectionPolygons = resultingPolygons; doc.Selection.SelectionPath = g.CreatePolygonPath(DocumentSelection.ConvertToPolygonSet(resultingPolygons)); } } PintaCore.Workspace.CallSelectionChanged(this, EventArgs.Empty); }
/// <summary> /// Pastes an image from the clipboard. /// </summary> /// <param name="toNewLayer">Set to TRUE to paste into a /// new layer. Otherwise, will paste to the current layer.</param> /// <param name="x">Optional. Location within image to paste to. /// Position will be adjusted if pasted image would hang /// over right or bottom edges of canvas.</param> /// <param name="y">Optional. Location within image to paste to. /// Position will be adjusted if pasted image would hang /// over right or bottom edges of canvas.</param> public void Paste(bool toNewLayer, int x = 0, int y = 0) { // Create a compound history item for recording several // operations so that they can all be undone/redone together. CompoundHistoryItem paste_action; if (toNewLayer) { paste_action = new CompoundHistoryItem(Stock.Paste, Catalog.GetString("Paste Into New Layer")); } else { paste_action = new CompoundHistoryItem(Stock.Paste, Catalog.GetString("Paste")); } Gtk.Clipboard cb = Gtk.Clipboard.Get(Gdk.Atom.Intern("CLIPBOARD", false)); // See if the current tool wants to handle the paste // operation (e.g., the text tool could paste text) if (!toNewLayer) { if (PintaCore.Tools.CurrentTool.TryHandlePaste(cb)) { return; } } PintaCore.Tools.Commit(); Path p; // Don't dispose this, as we're going to give it to the history Gdk.Pixbuf cbImage = cb.WaitForImage(); if (cbImage == null) { ShowClipboardEmptyDialog(); return; } Gdk.Size canvas_size = PintaCore.Workspace.ImageSize; // If the image being pasted is larger than the canvas size, allow the user to optionally resize the canvas if (cbImage.Width > canvas_size.Width || cbImage.Height > canvas_size.Height) { ResponseType response = ShowExpandCanvasDialog(); if (response == ResponseType.Accept) { PintaCore.Workspace.ResizeCanvas(cbImage.Width, cbImage.Height, Pinta.Core.Anchor.Center, paste_action); PintaCore.Actions.View.UpdateCanvasScale(); } else if (response == ResponseType.Cancel || response == ResponseType.DeleteEvent) { return; } } // If the pasted image would fall off bottom- or right- // side of image, adjust paste position x = Math.Max(0, Math.Min(x, canvas_size.Width - cbImage.Width)); y = Math.Max(0, Math.Min(y, canvas_size.Height - cbImage.Height)); // If requested, create a new layer, make it the current // layer and record it's creation in the history if (toNewLayer) { UserLayer l = AddNewLayer(string.Empty); SetCurrentUserLayer(l); paste_action.Push(new AddLayerHistoryItem("Menu.Layers.AddNewLayer.png", Catalog.GetString("Add New Layer"), UserLayers.IndexOf(l))); } // Copy the paste to the temp layer, which should be at least the size of this document. CreateSelectionLayer(Math.Max(ImageSize.Width, cbImage.Width), Math.Max(ImageSize.Height, cbImage.Height)); ShowSelectionLayer = true; using (Cairo.Context g = new Cairo.Context(SelectionLayer.Surface)) { g.DrawPixbuf(cbImage, new Cairo.Point(0, 0)); p = g.CreateRectanglePath(new Cairo.Rectangle(x, y, cbImage.Width, cbImage.Height)); } SelectionLayer.Transform.InitIdentity(); SelectionLayer.Transform.Translate(x, y); PintaCore.Tools.SetCurrentTool(Catalog.GetString("Move Selected Pixels")); DocumentSelection old_selection = Selection.Clone(); bool old_show_selection = ShowSelection; Selection.SelectionPath = p; Selection.SelectionPolygons.Clear(); ShowSelection = true; Workspace.Invalidate(); paste_action.Push(new PasteHistoryItem(cbImage, old_selection, old_show_selection)); History.PushNewItem(paste_action); }
public void TakeSnapshot(bool lift) { lifted = lift; is_lifted = true; if (lift) { layer_index = doc.CurrentLayerIndex; old_surface = doc.CurrentLayer.Surface.Clone (); } old_selection = PintaCore.Workspace.ActiveDocument.Selection.Clone (); old_offset = PintaCore.Layers.SelectionLayer.Offset; }