static void CropImageToRectangle (Document doc, Gdk.Rectangle rect, Path selection) { if (rect.Width > 0 && rect.Height > 0) { ResizeHistoryItem hist = new ResizeHistoryItem(doc.ImageSize); hist.Icon = "Menu.Image.Crop.png"; hist.Text = Catalog.GetString("Crop to Selection"); hist.StartSnapshotOfImage(); hist.RestoreSelection = doc.Selection.Clone(); doc.Workspace.Canvas.GdkWindow.FreezeUpdates(); double original_scale = doc.Workspace.Scale; doc.ImageSize = rect.Size; doc.Workspace.CanvasSize = rect.Size; doc.Workspace.Scale = original_scale; PintaCore.Actions.View.UpdateCanvasScale(); doc.Workspace.Canvas.GdkWindow.ThawUpdates(); foreach (var layer in doc.UserLayers) layer.Crop (rect, selection); hist.FinishSnapshotOfImage(); doc.History.PushNewItem(hist); doc.ResetSelectionPaths(); doc.Workspace.Invalidate(); } }
private void HandlePintaCoreActionsEditEraseSelectionActivated(object sender, EventArgs e) { Document doc = PintaCore.Workspace.ActiveDocument; PintaCore.Tools.Commit(); Cairo.ImageSurface old = doc.CurrentUserLayer.Surface.Clone(); using (var g = new Cairo.Context(doc.CurrentUserLayer.Surface)) { g.AppendPath(doc.Selection.SelectionPath); g.FillRule = FillRule.EvenOdd; g.Operator = Cairo.Operator.Clear; g.Fill(); } doc.ResetSelectionPaths(); doc.Workspace.Invalidate(); if (sender is string && (sender as string) == "Cut") { doc.History.PushNewItem(new SimpleHistoryItem(Stock.Cut, Catalog.GetString("Cut"), old, doc.CurrentUserLayerIndex)); } else { doc.History.PushNewItem(new SimpleHistoryItem("Menu.Edit.EraseSelection.png", Catalog.GetString("Erase Selection"), old, doc.CurrentUserLayerIndex)); } }
private void HandlePintaCoreActionsImageRotate180Activated (object sender, EventArgs e) { Document doc = PintaCore.Workspace.ActiveDocument; PintaCore.Tools.Commit (); doc.RotateImage180 (); doc.ResetSelectionPaths (); doc.History.PushNewItem (new InvertHistoryItem (InvertType.Rotate180)); }
private void HandlePintaCoreActionsEditDeselectActivated(object sender, EventArgs e) { Document doc = PintaCore.Workspace.ActiveDocument; PintaCore.Tools.Commit(); SelectionHistoryItem hist = new SelectionHistoryItem(Resources.Icons.EditSelectionNone, Translations.GetString("Deselect")); hist.TakeSnapshot(); doc.ResetSelectionPaths(); doc.History.PushNewItem(hist); doc.Workspace.Invalidate(); }
private void HandlePintaCoreActionsEditDeselectActivated(object sender, EventArgs e) { Document doc = PintaCore.Workspace.ActiveDocument; PintaCore.Tools.Commit(); SelectionHistoryItem hist = new SelectionHistoryItem("Menu.Edit.Deselect.png", Catalog.GetString("Deselect")); hist.TakeSnapshot(); doc.ResetSelectionPaths(); doc.History.PushNewItem(hist); doc.Workspace.Invalidate(); }
private void HandlePintaCoreActionsEditSelectAllActivated(object sender, EventArgs e) { Document doc = PintaCore.Workspace.ActiveDocument; PintaCore.Tools.Commit(); SelectionHistoryItem hist = new SelectionHistoryItem(Stock.SelectAll, Catalog.GetString("Select All")); hist.TakeSnapshot(); doc.ResetSelectionPaths(); doc.Selection.Visible = true; doc.History.PushNewItem(hist); doc.Workspace.Invalidate(); }
private void HandlePintaCoreActionsEditFillSelectionActivated(object sender, EventArgs e) { Document doc = PintaCore.Workspace.ActiveDocument; PintaCore.Tools.Commit(); Cairo.ImageSurface old = doc.CurrentUserLayer.Surface.Clone(); using (var g = new Cairo.Context(doc.CurrentUserLayer.Surface)) { g.AppendPath(doc.Selection.SelectionPath); g.FillRule = FillRule.EvenOdd; g.Operator = Operator.Source; g.SetSourceColor(PintaCore.Palette.SecondaryColor); g.Fill(); } doc.ResetSelectionPaths(); doc.Workspace.Invalidate(); doc.History.PushNewItem(new SimpleHistoryItem("Menu.Edit.FillSelection.png", Catalog.GetString("Fill Selection"), old, doc.CurrentUserLayerIndex)); }