12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- using PaintDotNet.Measurement.HistoryMementos;
- using System;
- namespace PaintDotNet.Measurement.HistoryFunctions
- {
- public sealed class DeleteLayerFunction
- : HistoryFunction
- {
- public static string StaticName
- {
- get
- {
- return PdnResources.GetString("DeleteLayer.HistoryMementoName");
- }
- }
- public static ImageResource StaticImage
- {
- get
- {
- return PdnResources.GetImageResource("Icons.MenuLayersDeleteLayerIcon.png");
- }
- }
- private int layerIndex;
- public override HistoryMemento OnExecute(IDocumentWorkspace historyWorkspace)
- {
- if (this.layerIndex < 0 || this.layerIndex >= historyWorkspace.GetDocument().Layers.Count)
- {
- throw new ArgumentOutOfRangeException("layerIndex = " + this.layerIndex +
- ", expected [0, " + historyWorkspace.GetDocument().Layers.Count + ")");
- }
- HistoryMemento hm = new DeleteLayerHistoryMemento(StaticName, StaticImage, historyWorkspace, historyWorkspace.GetDocument().Layers.GetAt(this.layerIndex));
- EnterCriticalRegion();
- historyWorkspace.GetDocument().Layers.RemoveAt(this.layerIndex);
- return hm;
- }
- public DeleteLayerFunction(int layerIndex)
- : base(PaintDotNet.Measurement.Enum.ActionFlags.None)
- {
- this.layerIndex = layerIndex;
- }
- }
- }
|