TakeSnapshot() public method

public TakeSnapshot ( ) : void
return void
Beispiel #1
0
		protected override void OnMouseDown (DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
		{
			// Ignore extra button clicks while drawing
			if (is_drawing)
				return;

			Document doc = PintaCore.Workspace.ActiveDocument;
			hist = new SelectionHistoryItem(Icon, Name);
			hist.TakeSnapshot();

			reset_origin = args.Event.GetPoint();

            active_control = HandleResize (point);
			if (!active_control.HasValue)
			{
				combine_mode = PintaCore.Workspace.SelectionHandler.DetermineCombineMode(args);

				double x = Utility.Clamp(point.X, 0, doc.ImageSize.Width - 1);
				double y = Utility.Clamp(point.Y, 0, doc.ImageSize.Height - 1);
				shape_origin = new PointD(x, y);

                doc.PreviousSelection.Dispose ();
				doc.PreviousSelection = doc.Selection.Clone();
				doc.Selection.SelectionPolygons.Clear();

                // The bottom right corner should be selected.
                active_control = 3;
			}

            is_drawing = true;
		}
Beispiel #2
0
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            shape_origin = point;
            is_drawing = true;

            hist = new SelectionHistoryItem (Icon, Name);
            hist.TakeSnapshot ();
        }
Beispiel #3
0
		protected override void OnStartTransform ()
		{
			base.OnStartTransform ();

			Document doc = PintaCore.Workspace.ActiveDocument;
			original_selection = new List<List<IntPoint>> (doc.Selection.SelectionPolygons);

			hist = new SelectionHistoryItem (Icon, Name);
			hist.TakeSnapshot ();
		}
Beispiel #4
0
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            // Ignore extra button clicks while drawing
            if (is_drawing)
                return;

            shape_origin = point;
            is_drawing = true;

            hist = new SelectionHistoryItem (Icon, Name);
            hist.TakeSnapshot ();
        }
Beispiel #5
0
        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();
        }
Beispiel #6
0
        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();
        }
Beispiel #7
0
        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();
        }
Beispiel #8
0
		protected override void OnMouseDown (Gtk.DrawingArea canvas, Gtk.ButtonPressEventArgs args, Cairo.PointD point)
		{
			if (is_drawing)
				return;

			hist = new SelectionHistoryItem (Icon, Name);
			hist.TakeSnapshot ();

			combine_mode = PintaCore.Workspace.SelectionHandler.DetermineCombineMode (args);			
			path = null;
			is_drawing = true;

			var doc = PintaCore.Workspace.ActiveDocument;
			doc.PreviousSelection.Dispose ();
			doc.PreviousSelection = doc.Selection.Clone();
		}
Beispiel #9
0
        void HandleInvertSelectionActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            // Clear the selection resize handles if necessary.
            doc.ToolLayer.Clear();

            SelectionHistoryItem historyItem = new SelectionHistoryItem("Menu.Edit.InvertSelection.png",
                                                                        Catalog.GetString("Invert Selection"));

            historyItem.TakeSnapshot();

            doc.Selection.Invert(doc.SelectionLayer.Surface, doc.ImageSize);

            doc.History.PushNewItem(historyItem);
            doc.Workspace.Invalidate();
        }
Beispiel #10
0
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            // Ignore extra button clicks while drawing
            if (is_drawing)
                return;

            Document doc = PintaCore.Workspace.ActiveDocument;

            // Selection is around the pixel selection so add 1 pixel
            double x = Utility.Clamp (point.X, 0, doc.ImageSize.Width);
            double y = Utility.Clamp (point.Y, 0, doc.ImageSize.Height);
            shape_origin = new PointD (x, y);

            is_drawing = true;

            hist = new SelectionHistoryItem (Icon, Name);
            hist.TakeSnapshot ();
        }
Beispiel #11
0
        void HandleInvertSelectionActivated(object sender, EventArgs e)
        {
            PintaCore.Tools.Commit();

            Document doc = PintaCore.Workspace.ActiveDocument;

            // Clear the selection resize handles if necessary.
            doc.Layers.ToolLayer.Clear();

            SelectionHistoryItem historyItem = new SelectionHistoryItem(Resources.Icons.EditSelectionInvert,
                                                                        Translations.GetString("Invert Selection"));

            historyItem.TakeSnapshot();

            doc.Selection.Invert(doc.Layers.SelectionLayer.Surface, doc.ImageSize);

            doc.History.PushNewItem(historyItem);
            doc.Workspace.Invalidate();
        }
Beispiel #12
0
        protected override void OnMouseDown(DrawingArea canvas, ButtonPressEventArgs args, Cairo.PointD point)
        {
            // Ignore extra button clicks while drawing
            if (is_drawing)
                return;

            reset_origin = args.Event.GetPoint ();

            Document doc = PintaCore.Workspace.ActiveDocument;
            if (!handler_active || !HandleResize (point.X, point.Y)) {
                double x = Utility.Clamp (point.X, 0, doc.ImageSize.Width - 1);
                double y = Utility.Clamp (point.Y, 0, doc.ImageSize.Height - 1);

                shape_origin = new PointD (x, y);

                doc.Selection.SelectionPolygons.Clear ();
                is_drawing = true;
            }
            hist = new SelectionHistoryItem (Icon, Name);
            hist.TakeSnapshot ();
        }
Beispiel #13
0
        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;

            origin_offset = point;
            is_dragging = true;

            hist = new SelectionHistoryItem (Icon, Name);
            hist.TakeSnapshot ();
        }
Beispiel #14
0
        protected override void OnFillRegionComputed(Point[][] polygonSet)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            SelectionHistoryItem undoAction = new SelectionHistoryItem(this.Icon, this.Name);
            undoAction.TakeSnapshot();

            //Convert Pinta's passed in Polygon Set to a Clipper Polygon collection.
            List<List<IntPoint>> newPolygons = DocumentSelection.ConvertToPolygons(polygonSet);

            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));
                }
            }

            doc.History.PushNewItem(undoAction);
            doc.Workspace.Invalidate();
        }
Beispiel #15
0
        void HandleInvertSelectionActivated(object sender, EventArgs e)
        {
            PintaCore.Tools.Commit ();

            Document doc = PintaCore.Workspace.ActiveDocument;

            // Clear the selection resize handles if necessary.
            doc.ToolLayer.Clear ();

            SelectionHistoryItem historyItem = new SelectionHistoryItem ("Menu.Edit.InvertSelection.png",
                                                                         Catalog.GetString ("Invert Selection"));
            historyItem.TakeSnapshot ();

            doc.Selection.Invert (doc.SelectionLayer.Surface, doc.ImageSize);

            doc.History.PushNewItem (historyItem);
            doc.Workspace.Invalidate ();
        }
Beispiel #16
0
        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.ResetSelectionPath ();
            doc.ShowSelection = true;

            doc.History.PushNewItem (hist);
            doc.Workspace.Invalidate ();
        }
Beispiel #17
0
        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.ResetSelectionPath ();

            doc.History.PushNewItem (hist);
            doc.Workspace.Invalidate ();
        }
Beispiel #18
0
        private void HandlePintaCoreActionsEditSelectAllActivated(object sender, EventArgs e)
        {
            PintaCore.Layers.FinishSelection ();

            SelectionHistoryItem hist = new SelectionHistoryItem ("Menu.Edit.SelectAll.png", Mono.Unix.Catalog.GetString ("Select All"));
            hist.TakeSnapshot ();

            PintaCore.Layers.ResetSelectionPath ();
            PintaCore.Layers.ShowSelection = true;

            PintaCore.History.PushNewItem (hist);
            PintaCore.Workspace.Invalidate ();
        }
Beispiel #19
0
        protected override void OnFillRegionComputed(Point[][] polygonSet)
        {
            SelectionHistoryItem undoAction = new SelectionHistoryItem (this.Icon, this.Name);
            undoAction.TakeSnapshot ();

            Path path = PintaCore.Layers.SelectionPath;

            using (Context g = new Context (PintaCore.Layers.CurrentLayer.Surface)) {
                PintaCore.Layers.SelectionPath = g.CreatePolygonPath (polygonSet);

                switch (combineMode) {
                    case CombineMode.Union:
                        g.AppendPath (path);
                        break;
                    case CombineMode.Xor:
                        //not supported
                        break;
                    case CombineMode.Exclude:
                        //not supported
                        break;
                    case CombineMode.Replace:
                        //do nothing
                        break;
                }

            }

            (path as IDisposable).Dispose ();

            //Selection.PerformChanging();
            //Selection.SetContinuation(polygonSet, this.combineMode);
            //Selection.CommitContinuation();
            //Selection.PerformChanged();

            PintaCore.History.PushNewItem (undoAction);
            PintaCore.Workspace.Invalidate ();
        }
Beispiel #20
0
		protected override void OnFillRegionComputed(Point[][] polygonSet)
		{
			Document doc = PintaCore.Workspace.ActiveDocument;

			SelectionHistoryItem undoAction = new SelectionHistoryItem(this.Icon, this.Name);
			undoAction.TakeSnapshot();

            doc.PreviousSelection.Dispose ();
            doc.PreviousSelection = doc.Selection.Clone ();

            doc.Selection.SelectionPolygons.Clear ();
            SelectionModeHandler.PerformSelectionMode (combine_mode, DocumentSelection.ConvertToPolygons (polygonSet));

			doc.History.PushNewItem(undoAction);
			doc.Workspace.Invalidate();
		}