本文整理汇总了C#中WorkspaceModel.RemoveNode方法的典型用法代码示例。如果您正苦于以下问题:C# WorkspaceModel.RemoveNode方法的具体用法?C# WorkspaceModel.RemoveNode怎么用?C# WorkspaceModel.RemoveNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WorkspaceModel
的用法示例。
在下文中一共展示了WorkspaceModel.RemoveNode方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Collapse
//.........这里部分代码省略.........
#endregion
#region Handle partially selected connectors
// Step 3: Partially selected connectors (either one of its start
// and end owners is in the selection) are to be destroyed.
var partiallySelectedConns =
currentWorkspace.Connectors.Where(
conn =>
selectedNodeSet.Contains(conn.Start.Owner)
|| selectedNodeSet.Contains(conn.End.Owner)).ToList();
foreach (var connector in partiallySelectedConns)
{
undoRecorder.RecordDeletionForUndo(connector);
connector.Delete();
}
#endregion
#region Transfer nodes and connectors to new workspace
var newNodes = new List<NodeModel>();
var newAnnotations = new List<AnnotationModel>();
// Step 4: move all nodes to new workspace remove from old
// PB: This could be more efficiently handled by a copy paste, but we
// are preservering the node
foreach (var node in selectedNodeSet)
{
undoRecorder.RecordDeletionForUndo(node);
currentWorkspace.RemoveNode(node);
// Assign a new guid to this node, otherwise when node is
// compiled to AST, literally it is still in global scope
// instead of in function scope.
node.GUID = Guid.NewGuid();
// shift nodes
node.X = node.X - leftShift;
node.Y = node.Y - topMost;
newNodes.Add(node);
}
//Copy the group from newNodes
foreach (var group in DynamoSelection.Instance.Selection.OfType<AnnotationModel>())
{
undoRecorder.RecordDeletionForUndo(group);
currentWorkspace.RemoveGroup(group);
group.GUID = Guid.NewGuid();
group.SelectedModels = group.DeletedModelBases;
newAnnotations.Add(group);
}
// Now all selected nodes already moved to custom workspace,
// clear the selection.
DynamoSelection.Instance.ClearSelection();
foreach (var conn in fullySelectedConns)
{
ConnectorModel.Make(conn.Start.Owner, conn.End.Owner, conn.Start.Index, conn.End.Index);
}