求助,请教下面这个方法的逻辑是否合理
本帖最后由 yan_hyz 于 2014-01-17 10:31:26 编辑
/// <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;
}