本文整理汇总了C#中ShapeCollection.Remove方法的典型用法代码示例。如果您正苦于以下问题:C# ShapeCollection.Remove方法的具体用法?C# ShapeCollection.Remove怎么用?C# ShapeCollection.Remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ShapeCollection
的用法示例。
在下文中一共展示了ShapeCollection.Remove方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SortSelectedShapes
private void SortSelectedShapes(MoveShapesDirection moveDirection)
{
ShapeCollection selected = shapeTreeView.SelectedShapes;
// return if any of the indices is already on the maximum.
foreach (ShapeBase shape in selected)
{
if (moveDirection == MoveShapesDirection.Up)
{
if (shape.Parent.ChildCollection.FindIndex(i => i == shape) <= 0)
return;
}
else
if (shape.Parent.ChildCollection.FindIndex(i => i == shape) >= shape.Parent.ChildCollection.Count - 1)
return;
}
// get all parents to share modified collections between their children.
ShapeCollection parents = new ShapeCollection();
foreach (ShapeBase shape in selected)
if (!parents.Contains(shape.Parent))
parents.Add(shape.Parent);
EditorManager.Actions.StartGroup("Sort Shapes");
foreach (ShapeBase parent in parents)
{
// create copy of the original collection before sorting
ShapeCollection copyOfChildren = new ShapeCollection();
copyOfChildren.AddRange(parent.ChildCollection);
if (moveDirection == MoveShapesDirection.Up)
{
for (int i = 0; i < selected.Count; i++)
{
ShapeBase child = selected[i];
if (child.Parent == parent)
{
int index = copyOfChildren.FindIndex(c => c == child);
copyOfChildren.Remove(child);
copyOfChildren.Insert(index - 1, child);
EditorManager.Actions.Add(new SortShapeChildrenAction(parent, copyOfChildren));
}
}
}
else
for (int i = selected.Count - 1; i > -1; i--)
{
ShapeBase child = selected[i];
if (child.Parent == parent)
{
int index = copyOfChildren.FindIndex(c => c == child);
copyOfChildren.Remove(child);
copyOfChildren.Insert(index + 1, child);
EditorManager.Actions.Add(new SortShapeChildrenAction(parent, copyOfChildren));
}
}
}
EditorManager.Actions.EndGroup();
// recover selection
ArrayList newSelection = new ArrayList();
foreach (ShapeTreeNode node in shapeTreeView.Nodes)
{
if (selected.Contains(node.shape)) // root
newSelection.Add(node);
foreach (ShapeTreeNode subNode in shapeTreeView.GetChildNodes(node))
{
if (selected.Contains(subNode.shape)) // all children
newSelection.Add(subNode);
}
}
shapeTreeView.SelectedNodes = newSelection;
}