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