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

MergeCurrentLayerDown() public method

public MergeCurrentLayerDown ( ) : void
return void
        public void MergeCurrentLayerDown()
        {
            if (current_layer == 0)
                throw new InvalidOperationException ("Cannot flatten layer because current layer is the bottom layer.");

            // Get our source and destination layers
            var source = CurrentUserLayer;
            var dest = UserLayers[current_layer - 1];

            // Blend the layers
            using (var g = new Context (dest.Surface))
                source.Draw (g);

            DeleteCurrentLayer ();
        }

Usage Example

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