// Flatten image public void FlattenImage() { if (UserLayers.Count < 2) { throw new InvalidOperationException("Cannot flatten image because there is only one layer."); } // Find the "bottom" layer var bottom_layer = UserLayers[0]; var old_surf = bottom_layer.Surface; // Replace the bottom surface with the flattened image, // and dispose the old surface bottom_layer.Surface = GetFlattenedImage(); (old_surf as IDisposable).Dispose(); // Reset our layer pointer to the only remaining layer current_layer = 0; // Delete all other layers while (UserLayers.Count > 1) { UserLayers.RemoveAt(1); } PintaCore.Layers.OnLayerRemoved(); Workspace.Invalidate(); }
// Clean up any native resources we had public void Close() { // Dispose all of our layers while (UserLayers.Count > 0) { Layer l = UserLayers[UserLayers.Count - 1]; UserLayers.RemoveAt(UserLayers.Count - 1); (l.Surface as IDisposable).Dispose(); } current_layer = -1; if (tool_layer != null) { (tool_layer.Surface as IDisposable).Dispose(); } if (selection_layer != null) { (selection_layer.Surface as IDisposable).Dispose(); } Selection.DisposeSelection(); Workspace.History.Clear(); }
public void Clear() { while (UserLayers.Count > 0) { Layer l = UserLayers[UserLayers.Count - 1]; UserLayers.RemoveAt(UserLayers.Count - 1); (l.Surface as IDisposable).Dispose(); } current_layer = -1; PintaCore.Layers.OnLayerRemoved(); }
// Move current layer up public void MoveCurrentLayerUp() { if (current_layer == UserLayers.Count) { throw new InvalidOperationException("Cannot move layer up because current layer is the top layer."); } UserLayer layer = CurrentUserLayer; UserLayers.RemoveAt(current_layer); UserLayers.Insert(++current_layer, layer); PintaCore.Layers.OnSelectedLayerChanged(); Workspace.Invalidate(); }
// Move current layer down public void MoveCurrentLayerDown() { if (current_layer == 0) { throw new InvalidOperationException("Cannot move layer down because current layer is the bottom layer."); } UserLayer layer = CurrentUserLayer; UserLayers.RemoveAt(current_layer); UserLayers.Insert(--current_layer, layer); PintaCore.Layers.OnSelectedLayerChanged(); Workspace.Invalidate(); }
// Delete the current layer public void DeleteCurrentLayer() { Layer layer = CurrentUserLayer; UserLayers.RemoveAt(current_layer); // Only change this if this wasn't already the bottom layer if (current_layer > 0) { current_layer--; } layer.PropertyChanged -= RaiseLayerPropertyChangedEvent; PintaCore.Layers.OnLayerRemoved(); }
// Delete the layer public void DeleteLayer(int index, bool dispose) { Layer layer = UserLayers[index]; UserLayers.RemoveAt(index); if (dispose) { (layer.Surface as IDisposable).Dispose(); } // Only change this if this wasn't already the bottom layer if (current_layer > 0) { current_layer--; } layer.PropertyChanged -= RaiseLayerPropertyChangedEvent; PintaCore.Layers.OnLayerRemoved(); }