DrawToolsRedux/CommandChangeState.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System.Collections.Generic;
namespace DrawTools
{
/// <summary>
/// Changing state of existing objects:
/// move, resize, change properties.
/// </summary>
internal class CommandChangeState : Command
{
// Selected object(s) before operation
private List<DrawObject> listBefore;
// Selected object(s) after operation
private List<DrawObject> listAfter;
// Track the active Layer where the change took place
private int activeLayer;
// Create this command BEFORE operation.
public CommandChangeState(Layers layerList)
{
// Keep objects state before operation.
activeLayer = layerList.ActiveLayerIndex;
FillList(layerList[activeLayer].Graphics, ref listBefore);
}
// Call this function AFTER operation.
public void NewState(Layers layerList)
{
// Keep objects state after operation.
FillList(layerList[activeLayer].Graphics, ref listAfter);
}
public override void Undo(Layers list)
{
// Replace all objects in the list with objects from listBefore
ReplaceObjects(list[activeLayer].Graphics, listBefore);
}
public override void Redo(Layers list)
{
// Replace all objects in the list with objects from listAfter
ReplaceObjects(list[activeLayer].Graphics, listAfter);
}
// Replace objects in graphicsList with objects from list
private void ReplaceObjects(GraphicsList graphicsList, List<DrawObject> list)
{
for (int i = 0; i < graphicsList.Count; i++)
{
DrawObject replacement = null;
foreach (DrawObject o in list)
{
if (o.ID ==
graphicsList[i].ID)
{
replacement = o;
break;
后面还有 22 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。