111,094
社区成员




/// <summary>
/// 将一个指定的组合图形拆分为多个图形,拆分后的子图形将被设置为【非锁定】和【非选中】状态。
/// </summary>
/// <param name="dGroup">指定要拆分的组合图形</param>
/// <returns>返回一个包含拆分后的子图形的图形列表</returns>
public static List<BaseElement> BreakObj(DrawGroup dGroup)
{
if (dGroup == null)
{
throw new Exception("请确保参数不为null。方法名:[GroupAction.BreakObj];参数:[DrawGroup dGroup]");
}
if (dGroup.children == null)
{
throw new Exception("请确保参数是一个有效的组合图形。方法名:[GroupAction.BreakObj];参数:[DrawGroup dGroup]");
}
if (dGroup.children.Count <= 0)
{
throw new Exception("请确保参数是一个有效的组合图形。方法名:[GroupAction.BreakObj];参数:[DrawGroup dGroup]");
}
for (int i = 0; i < dGroup.children.Count; i++)
{
if (dGroup.children[i] == null)
{
dGroup.children.RemoveAt(i);
i--;
continue;
}
dGroup.children[i].BLock = false;
}
if (dGroup.children.Count <= 0)
{
throw new Exception("请确保参数是一个有效的组合图形。方法名:[GroupAction.BreakObj];参数:[DrawGroup dGroup]");
}
List<BaseElement> eLst = new List<BaseElement>();
for (int i = 0; i < dGroup.children.Count; i++)
{
eLst.Add(dGroup.children[i]);
if (dGroup.children[i] is DrawSignItem)
{
//Do Samething
}
else
{
dGroup.children[i].resetLocation();
}
}
dGroup.locateToChild();
dGroup.children.Clear();
dGroup.Dispose();
for (int i = 0; i < eLst.Count; i++)
{
eLst[i].resetLocation();
eLst[i].BLock = false;
eLst[i].BIsSelected = false;
eLst[i].FGraphUnit = dGroup.FGraphUnit;
}
return eLst;
}
for (int i = 0; i < dGroup.children.Count; i++)
{
if (dGroup.children[i] == null)
{
dGroup.children.RemoveAt(i);
i--;
continue;
}
dGroup.children[i].BLock = false;
}
额,我们不知道你到底要怎么保证,所以只能给点技巧性提示,这个代码别扭点,这里有下技巧来着,不要正向循环,i++,i--看滴郁闷啊!这里你负向循环,从结尾开始判定移除,这样就不会影响上面的顺序了