当前位置: 首页>>代码示例>>C#>>正文


C# ShapeCollection.Remove方法代码示例

本文整理汇总了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;
        }
开发者ID:shuaiharry,项目名称:projectanarchy,代码行数:73,代码来源:ShapeTreePanel.cs


注:本文中的ShapeCollection.Remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。