DrawToolsRedux/CommandDeleteAll.cs
(完整代码) 1KBusing System.Collections.Generic;
namespace DrawTools
{
/// <summary>
/// Delete All command
/// </summary>
internal class CommandDeleteAll : Command
{
private List<DrawObject> cloneList;
// Create this command BEFORE applying Delete All function.
public CommandDeleteAll(Layers list)
{
cloneList = new List<DrawObject>();
// Make clone of the whole list.
// Add objects in reverse order because GraphicsList.Add
// insert every object to the beginning.
int n = list[list.ActiveLayerIndex].Graphics.Count;
for (int i = n - 1; i >= 0; i--)
{
cloneList.Add(list[list.ActiveLayerIndex].Graphics[i].Clone());
}
}
public override void Undo(Layers list)
{
// Add all objects from clone list to list -
// opposite to DeleteAll
foreach (DrawObject o in cloneList)
{
list[list.ActiveLayerIndex].Graphics.Add(o);
}
}
public override void Redo(Layers list)
{
// Clear list - make DeleteAll again
list[list.ActiveLayerIndex].Graphics.Clear();
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。