protected override void OnStartTransform() { base.OnStartTransform(); Document doc = PintaCore.Workspace.ActiveDocument; // If there is no selection, select the whole image. if (doc.Selection.SelectionPolygons.Count == 0) { doc.Selection.CreateRectangleSelection( new Cairo.Rectangle(0, 0, doc.ImageSize.Width, doc.ImageSize.Height)); } original_selection = doc.Selection.Clone(); original_transform.InitMatrix(doc.SelectionLayer.Transform); hist = new MovePixelsHistoryItem(Icon, Name, doc); hist.TakeSnapshot(!doc.ShowSelectionLayer); if (!doc.ShowSelectionLayer) { // Copy the selection to the temp layer doc.CreateSelectionLayer(); doc.ShowSelectionLayer = true; //Use same BlendMode, Opacity and Visibility for SelectionLayer doc.SelectionLayer.BlendMode = doc.CurrentUserLayer.BlendMode; doc.SelectionLayer.Opacity = doc.CurrentUserLayer.Opacity; doc.SelectionLayer.Hidden = doc.CurrentUserLayer.Hidden; using (Cairo.Context g = new Cairo.Context(doc.SelectionLayer.Surface)) { g.AppendPath(doc.Selection.SelectionPath); g.FillRule = FillRule.EvenOdd; g.SetSource(doc.CurrentUserLayer.Surface); g.Clip(); g.Paint(); } Cairo.ImageSurface surf = doc.CurrentUserLayer.Surface; using (Cairo.Context g = new Cairo.Context(surf)) { g.AppendPath(doc.Selection.SelectionPath); g.FillRule = FillRule.EvenOdd; if (is_alt_pressed) { g.Operator = Cairo.Operator.Clear; } else { g.Operator = Operator.Source; g.SetSourceColor(PintaCore.Palette.SecondaryColor); } g.Fill(); } } PintaCore.Workspace.Invalidate(); }
protected override void OnStartTransform() { base.OnStartTransform(); Document doc = PintaCore.Workspace.ActiveDocument; // If there is no selection, select the whole image. if (doc.Selection.SelectionPolygons.Count == 0) { doc.Selection.CreateRectangleSelection( doc.SelectionLayer.Surface, new Cairo.Rectangle(0, 0, doc.ImageSize.Width, doc.ImageSize.Height)); } original_selection = new List <List <IntPoint> > (doc.Selection.SelectionPolygons); original_transform.InitMatrix(doc.SelectionLayer.Transform); hist = new MovePixelsHistoryItem(Icon, Name, doc); hist.TakeSnapshot(!doc.ShowSelectionLayer); if (!doc.ShowSelectionLayer) { // Copy the selection to the temp layer doc.CreateSelectionLayer(); doc.ShowSelectionLayer = true; using (Cairo.Context g = new Cairo.Context(doc.SelectionLayer.Surface)) { g.AppendPath(doc.Selection.SelectionPath); g.FillRule = FillRule.EvenOdd; g.SetSource(doc.CurrentUserLayer.Surface); g.Clip(); g.Paint(); } Cairo.ImageSurface surf = doc.CurrentUserLayer.Surface; using (Cairo.Context g = new Cairo.Context(surf)) { g.AppendPath(doc.Selection.SelectionPath); g.FillRule = FillRule.EvenOdd; g.Operator = Cairo.Operator.Clear; g.Fill(); } } PintaCore.Workspace.Invalidate(); }
protected override void OnMouseDown(Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point) { // If we are already drawing, ignore any additional mouse down events if (is_dragging) { return; } Document doc = PintaCore.Workspace.ActiveDocument; origin_offset = point; is_dragging = true; hist = new MovePixelsHistoryItem(Icon, Name, doc); hist.TakeSnapshot(!doc.ShowSelectionLayer); if (!doc.ShowSelectionLayer) { // Copy the selection to the temp layer doc.CreateSelectionLayer(); doc.ShowSelectionLayer = true; using (Cairo.Context g = new Cairo.Context(doc.SelectionLayer.Surface)) { g.AppendPath(doc.SelectionPath); g.FillRule = FillRule.EvenOdd; g.SetSource(doc.CurrentLayer.Surface); g.Clip(); g.Paint(); } Cairo.ImageSurface surf = doc.CurrentLayer.Surface; using (Cairo.Context g = new Cairo.Context(surf)) { g.AppendPath(doc.SelectionPath); g.FillRule = FillRule.EvenOdd; g.Operator = Cairo.Operator.Clear; g.Fill(); } } canvas.GdkWindow.Invalidate(); }