Push() 공개 메소드

public Push ( BaseHistoryItem item ) : void
item BaseHistoryItem
리턴 void
예제 #1
0
        private void HandlePintaCoreActionsLayersMergeLayerDownActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit();

            CompoundHistoryItem    hist = new CompoundHistoryItem("Menu.Layers.MergeLayerDown.png", Catalog.GetString("Merge Layer Down"));
            DeleteLayerHistoryItem h1   = new DeleteLayerHistoryItem(string.Empty, string.Empty, doc.CurrentLayer, doc.CurrentLayerIndex);
            SimpleHistoryItem      h2   = new SimpleHistoryItem(string.Empty, string.Empty, doc.Layers[doc.CurrentLayerIndex - 1].Surface.Clone(), doc.CurrentLayerIndex - 1);

            hist.Push(h1);
            hist.Push(h2);

            doc.MergeCurrentLayerDown();

            doc.History.PushNewItem(hist);
        }
예제 #2
0
파일: ImageActions.cs 프로젝트: ywscr/Pinta
		private void HandlePintaCoreActionsImageFlattenActivated (object sender, EventArgs e)
		{
			Document doc = PintaCore.Workspace.ActiveDocument;

			PintaCore.Tools.Commit ();

			var oldBottomSurface = doc.UserLayers[0].Surface.Clone ();

			CompoundHistoryItem hist = new CompoundHistoryItem ("Menu.Image.Flatten.png", Catalog.GetString ("Flatten"));

			for (int i = doc.UserLayers.Count - 1; i >= 1; i--)
				hist.Push (new DeleteLayerHistoryItem (string.Empty, string.Empty, doc.UserLayers[i], i));

			doc.FlattenImage ();

			hist.Push (new SimpleHistoryItem (string.Empty, string.Empty, oldBottomSurface, 0));
			doc.History.PushNewItem (hist);
		}
예제 #3
0
        private void HandlePintaCoreActionsLayersMergeLayerDownActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit();

            int bottomLayerIndex = doc.Layers.CurrentUserLayerIndex - 1;
            var oldBottomSurface = doc.Layers.UserLayers[bottomLayerIndex].Surface.Clone();

            CompoundHistoryItem    hist = new CompoundHistoryItem(Resources.Icons.LayerMergeDown, Translations.GetString("Merge Layer Down"));
            DeleteLayerHistoryItem h1   = new DeleteLayerHistoryItem(string.Empty, string.Empty, doc.Layers.CurrentUserLayer, doc.Layers.CurrentUserLayerIndex);

            doc.Layers.MergeCurrentLayerDown();

            SimpleHistoryItem h2 = new SimpleHistoryItem(string.Empty, string.Empty, oldBottomSurface, bottomLayerIndex);

            hist.Push(h1);
            hist.Push(h2);

            doc.History.PushNewItem(hist);
        }
예제 #4
0
파일: Document.cs 프로젝트: JoeyScarr/Pinta
        /// <summary>
        /// Resizes the canvas.
        /// </summary>
        /// <param name='compoundAction'>
        /// Optionally, the history item for resizing the canvas can be added to
        /// a CompoundHistoryItem if it is part of a larger action (e.g. pasting an image).
        /// </param>
        public void ResizeCanvas(int width, int height, Anchor anchor, CompoundHistoryItem compoundAction)
        {
            double scale;

            if (ImageSize.Width == width && ImageSize.Height == height)
            {
                return;
            }

            PintaCore.Tools.Commit();

            ResizeHistoryItem hist = new ResizeHistoryItem(ImageSize);

            hist.Icon = "Menu.Image.CanvasSize.png";
            hist.Text = Catalog.GetString("Resize Canvas");
            hist.StartSnapshotOfImage();

            scale = Workspace.Scale;

            ImageSize = new Gdk.Size(width, height);

            foreach (var layer in UserLayers)
            {
                layer.ResizeCanvas(width, height, anchor);
            }

            hist.FinishSnapshotOfImage();

            if (compoundAction != null)
            {
                compoundAction.Push(hist);
            }
            else
            {
                Workspace.History.PushNewItem(hist);
            }

            ResetSelectionPath();

            Workspace.Scale = scale;
        }
예제 #5
0
        private void HandlePintaCoreActionsImageFlattenActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit ();

            var oldBottomSurface = doc.UserLayers[0].Surface.Clone ();

            CompoundHistoryItem hist = new CompoundHistoryItem ("Menu.Image.Flatten.png", Catalog.GetString ("Flatten"));

            for (int i = doc.UserLayers.Count - 1; i >= 1; i--)
                hist.Push (new DeleteLayerHistoryItem (string.Empty, string.Empty, doc.UserLayers[i], i));

            doc.FlattenImage ();

            hist.Push (new SimpleHistoryItem (string.Empty, string.Empty, oldBottomSurface, 0));
            doc.History.PushNewItem (hist);
        }
예제 #6
0
        private void HandlePintaCoreActionsImageFlattenActivated(object sender, EventArgs e)
        {
            PintaCore.Layers.FinishSelection ();

            CompoundHistoryItem hist = new CompoundHistoryItem ("Menu.Image.Flatten.png", Catalog.GetString ("Flatten"));
            SimpleHistoryItem h1 = new SimpleHistoryItem (string.Empty, string.Empty, PintaCore.Layers[0].Surface.Clone (), 0);
            hist.Push (h1);

            for (int i = 1; i < PintaCore.Layers.Count; i++)
                hist.Push (new DeleteLayerHistoryItem (string.Empty, string.Empty, PintaCore.Layers[i], i));

            PintaCore.Layers.FlattenImage ();

            PintaCore.History.PushNewItem (hist);
        }
예제 #7
0
        private void HandlePintaCoreActionsLayersMergeLayerDownActivated(object sender, EventArgs e)
        {
            Document doc = PintaCore.Workspace.ActiveDocument;
            PintaCore.Tools.Commit ();

            CompoundHistoryItem hist = new CompoundHistoryItem ("Menu.Layers.MergeLayerDown.png", Catalog.GetString ("Merge Layer Down"));
            DeleteLayerHistoryItem h1 = new DeleteLayerHistoryItem (string.Empty, string.Empty, doc.CurrentLayer, doc.CurrentLayerIndex);
            SimpleHistoryItem h2 = new SimpleHistoryItem (string.Empty, string.Empty, doc.Layers[doc.CurrentLayerIndex - 1].Surface.Clone (), doc.CurrentLayerIndex - 1);

            hist.Push (h1);
            hist.Push (h2);

            doc.MergeCurrentLayerDown ();

            doc.History.PushNewItem (hist);
        }
예제 #8
0
파일: Document.cs 프로젝트: msiyer/Pinta
		/// <summary>
		/// Resizes the canvas.
		/// </summary>
		/// <param name="width">The new width of the canvas.</param>
		/// <param name="height">The new height of the canvas.</param>
		/// <param name="anchor">Direction in which to adjust the canvas</param>
		/// <param name='compoundAction'>
		/// Optionally, the history item for resizing the canvas can be added to
		/// a CompoundHistoryItem if it is part of a larger action (e.g. pasting an image).
		/// </param>
		public void ResizeCanvas (int width, int height, Anchor anchor, CompoundHistoryItem compoundAction)
		{
			double scale;

			if (ImageSize.Width == width && ImageSize.Height == height)
				return;

			PintaCore.Tools.Commit ();

			ResizeHistoryItem hist = new ResizeHistoryItem (ImageSize);
			hist.Icon = "Menu.Image.CanvasSize.png";
			hist.Text = Catalog.GetString ("Resize Canvas");
			hist.StartSnapshotOfImage ();

			scale = Workspace.Scale;

			ImageSize = new Gdk.Size (width, height);

			foreach (var layer in UserLayers)
				layer.ResizeCanvas (width, height, anchor);

			hist.FinishSnapshotOfImage ();

			if (compoundAction != null) {
				compoundAction.Push (hist);
			} else {
				Workspace.History.PushNewItem (hist);
			}

			ResetSelectionPaths ();

			Workspace.Scale = scale;
		}
예제 #9
0
        private void HandlePintaCoreActionsLayersMergeLayerDownActivated(object sender, EventArgs e)
        {
            PintaCore.Layers.FinishSelection ();

            CompoundHistoryItem hist = new CompoundHistoryItem ("Menu.Layers.MergeLayerDown.png", Mono.Unix.Catalog.GetString ("Merge Layer Down"));
            DeleteLayerHistoryItem h1 = new DeleteLayerHistoryItem (string.Empty, string.Empty, PintaCore.Layers.CurrentLayer, PintaCore.Layers.CurrentLayerIndex);
            SimpleHistoryItem h2 = new SimpleHistoryItem (string.Empty, string.Empty, PintaCore.Layers[PintaCore.Layers.CurrentLayerIndex - 1].Surface.Clone (), PintaCore.Layers.CurrentLayerIndex - 1);

            hist.Push (h1);
            hist.Push (h2);

            PintaCore.Layers.MergeCurrentLayerDown ();

            PintaCore.History.PushNewItem (hist);
        }
예제 #10
0
        private void Activated(object sender, EventArgs e)
        {
            Gtk.Clipboard cb = Gtk.Clipboard.Get (Gdk.Atom.Intern ("CLIPBOARD", false));
            if (PintaCore.Tools.CurrentTool.TryHandlePaste (cb))
                return;

            Document doc = PintaCore.Workspace.ActiveDocument;

            PintaCore.Tools.Commit ();

            Path p;

            // Don't dispose this, as we're going to give it to the history
            Gdk.Pixbuf image = cb.WaitForImage ();

            if (image == null)
            {
                Dialogs.ClipboardEmptyDialog.Show ();
                return;
            }

            Gdk.Size canvas_size = PintaCore.Workspace.ImageSize;

            // Merge the (optional) canvas resize and the pasted image into a single history item.
            var paste_action = new CompoundHistoryItem (Stock.Paste, Catalog.GetString ("Paste"));

            // If the image being pasted is larger than the canvas size, allow the user to optionally resize the canvas
            if (image.Width > canvas_size.Width || image.Height > canvas_size.Height)
            {
                ResponseType response = ShowExpandCanvasDialog ();

                if (response == ResponseType.Accept)
                {
                    PintaCore.Workspace.ResizeCanvas (image.Width, image.Height,
                                                      Pinta.Core.Anchor.Center, paste_action);
                    PintaCore.Actions.View.UpdateCanvasScale ();
                }
                else if (response == ResponseType.Cancel || response == ResponseType.DeleteEvent)
                {
                    return;
                }
            }

            // Copy the paste to the temp layer
            doc.CreateSelectionLayer ();
            doc.ShowSelectionLayer = true;

            using (Cairo.Context g = new Cairo.Context (doc.SelectionLayer.Surface))
            {
                g.DrawPixbuf (image, new Cairo.Point (0, 0));
                p = g.CreateRectanglePath (new Rectangle (0, 0, image.Width, image.Height));
            }

            PintaCore.Tools.SetCurrentTool (Catalog.GetString ("Move Selected Pixels"));

            DocumentSelection old_selection = doc.Selection.Clone();
            bool old_show_selection = doc.ShowSelection;

            doc.Selection.SelectionPath = p;
            doc.Selection.SelectionPolygons.Clear();
            doc.ShowSelection = true;

            doc.Workspace.Invalidate ();

            paste_action.Push (new PasteHistoryItem (image, old_selection, old_show_selection));
            doc.History.PushNewItem (paste_action);
        }