private void CopyBlockBrick(BlockBeginBrick scriptBrick, List<ModelBase> list, List<ModelBase> alreadyCopied) { BlockBeginBrick copy = scriptBrick.Clone(); BlockEndBrick copyEnd = scriptBrick.End.Clone(); copy.End = copyEnd; copyEnd.Begin = copy; list.Add(copy); alreadyCopied.Add(scriptBrick); for (int i = Actions.IndexOf(scriptBrick) + 1; i < Actions.IndexOf(scriptBrick.End);) { if (Actions[i] is ElseBrick && scriptBrick is IfBrick) { ElseBrick copyElse = (scriptBrick as IfBrick).Else.Clone(); (copy as IfBrick).Else = copyElse; (copyEnd as EndIfBrick).Else = copyElse; copyElse.Begin = copy as IfBrick; copyElse.End = copyEnd as EndIfBrick; list.Add(copyElse); alreadyCopied.Add((scriptBrick as IfBrick).Else); i++; } else { int tmpCount = list.Count; CopyBrick(Actions[i] as ModelBase, list, alreadyCopied); i += (list.Count - tmpCount); } } list.Add(copyEnd); alreadyCopied.Add(scriptBrick.End); }
private void CopyBlockBrickNotGrouped(BlockBeginBrick scriptBrick, List<ModelBase> list, List<ModelBase> alreadyCopied) { BlockBeginBrick tmpBlockBeginBrick = scriptBrick.Clone(); BlockEndBrick tmpBlockEndBrick = scriptBrick.End.Clone(); tmpBlockBeginBrick.End = tmpBlockEndBrick; tmpBlockEndBrick.Begin = tmpBlockBeginBrick; list.Add(tmpBlockBeginBrick); alreadyCopied.Add(scriptBrick); for (int i = SelectedActions.IndexOf(scriptBrick) + 1; i < SelectedActions.IndexOf(scriptBrick.End);) { if (SelectedActions[i] is ElseBrick && scriptBrick is IfBrick) { ElseBrick copyElse = (scriptBrick as IfBrick).Else.Clone(); (tmpBlockBeginBrick as IfBrick).Else = copyElse; (tmpBlockEndBrick as EndIfBrick).Else = copyElse; copyElse.Begin = tmpBlockBeginBrick as IfBrick; copyElse.End = tmpBlockEndBrick as EndIfBrick; list.Add(copyElse); alreadyCopied.Add((scriptBrick as IfBrick).Else); i++; } else { int tmpCount = list.Count; CopyBrick(SelectedActions[i], list, alreadyCopied); i += (list.Count - tmpCount); } } list.Add(tmpBlockEndBrick); alreadyCopied.Add(scriptBrick.End); }