12345678910111213141516171819202122232425262728293031323334 |
- using PaintDotNet.Measurement.HistoryMementos;
- namespace PaintDotNet.Measurement.HistoryFunctions
- {
- public sealed class AddNewBlankLayerFunction : HistoryFunction
- {
- public override HistoryMemento OnExecute(IDocumentWorkspace historyWorkspace)
- {
- BitmapLayer newLayer = null;
- newLayer = new BitmapLayer(historyWorkspace.GetDocument().Width, historyWorkspace.GetDocument().Height);
- string newLayerNameFormat = PdnResources.GetString("AddNewBlankLayer.LayerName.Format");
- newLayer.Name = string.Format(newLayerNameFormat, (1 + historyWorkspace.GetDocument().Layers.Count).ToString());
- newLayer.Opacity = 0;
- int newLayerIndex = historyWorkspace.GetActiveLayerIndex() + 1;
- NewLayerHistoryMemento ha = new NewLayerHistoryMemento(
- PdnResources.GetString("AddNewBlankLayer.HistoryMementoName"),
- PdnResources.GetImageResource("Icons.MenuLayersAddNewLayerIcon.png"),
- historyWorkspace,
- newLayerIndex);
- EnterCriticalRegion();
- historyWorkspace.GetDocument().Layers.Insert(newLayerIndex, newLayer);
- return ha;
- }
- public AddNewBlankLayerFunction()
- : base(PaintDotNet.Measurement.Enum.ActionFlags.None)
- {
- }
- }
- }
|