Pinta.Core.Document.ResizeCanvas C# (CSharp) Method

ResizeCanvas() public method

Resizes the canvas.
public ResizeCanvas ( int width, int height, Anchor anchor, CompoundHistoryItem compoundAction ) : void
width int The new width of the canvas.
height int The new height of the canvas.
anchor Anchor Direction in which to adjust the canvas
compoundAction CompoundHistoryItem /// 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). ///
return void
        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;
        }