本文整理汇总了C#中Dynamo.Models.DynamoModel.OnRequestsFunctionNamePrompt方法的典型用法代码示例。如果您正苦于以下问题:C# DynamoModel.OnRequestsFunctionNamePrompt方法的具体用法?C# DynamoModel.OnRequestsFunctionNamePrompt怎么用?C# DynamoModel.OnRequestsFunctionNamePrompt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dynamo.Models.DynamoModel
的用法示例。
在下文中一共展示了DynamoModel.OnRequestsFunctionNamePrompt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Collapse
/// <summary>
/// Collapse a set of nodes in a given workspace.
/// </summary>
/// <param name="dynamoModel">The current DynamoModel</param>
/// <param name="selectedNodes"> The function definition for the user-defined node </param>
/// <param name="currentWorkspace"> The workspace where</param>
/// <param name="args"></param>
public static void Collapse(DynamoModel dynamoModel, IEnumerable<NodeModel> selectedNodes, WorkspaceModel currentWorkspace, FunctionNamePromptEventArgs args = null)
{
var selectedNodeSet = new HashSet<NodeModel>(selectedNodes);
if (args == null || !args.Success)
{
args = new FunctionNamePromptEventArgs();
dynamoModel.OnRequestsFunctionNamePrompt(null, args);
if (!args.Success)
{
return;
}
}
// Note that undoable actions are only recorded for the "currentWorkspace",
// the nodes which get moved into "newNodeWorkspace" are not recorded for undo,
// even in the new workspace. Their creations will simply be treated as part of
// the opening of that new workspace (i.e. when a user opens a file, she will
// not expect the nodes that show up to be undoable).
//
// After local nodes are moved into "newNodeWorkspace" as the result of
// conversion, if user performs an undo, new set of nodes will be created in
// "currentWorkspace" (not moving those nodes in the "newNodeWorkspace" back
// into "currentWorkspace"). In another word, undo recording is on a per-
// workspace basis, it does not work across different workspaces.
//
UndoRedoRecorder undoRecorder = currentWorkspace.UndoRecorder;
using (undoRecorder.BeginActionGroup())
{
var newNodeWorkspace = new CustomNodeWorkspaceModel(
dynamoModel,
args.Name,
args.Category,
args.Description,
0,
0) { WatchChanges = false, HasUnsavedChanges = true };
var newNodeDefinition = new CustomNodeDefinition(Guid.NewGuid())
{
WorkspaceModel = newNodeWorkspace
};
currentWorkspace.DisableReporting();
#region Determine Inputs and Outputs
//Step 1: determine which nodes will be inputs to the new node
var inputs =
new HashSet<Tuple<NodeModel, int, Tuple<int, NodeModel>>>(
selectedNodeSet.SelectMany(
node =>
Enumerable.Range(0, node.InPortData.Count)
.Where(node.HasConnectedInput)
.Select(data => Tuple.Create(node, data, node.Inputs[data]))
.Where(input => !selectedNodeSet.Contains(input.Item3.Item2))));
var outputs =
new HashSet<Tuple<NodeModel, int, Tuple<int, NodeModel>>>(
selectedNodeSet.SelectMany(
node =>
Enumerable.Range(0, node.OutPortData.Count)
.Where(node.HasOutput)
.SelectMany(
data =>
node.Outputs[data].Where(
output => !selectedNodeSet.Contains(output.Item2))
.Select(output => Tuple.Create(node, data, output)))));
#endregion
#region Detect 1-node holes (higher-order function extraction)
var curriedNodeArgs =
new HashSet<NodeModel>(
inputs.Select(x => x.Item3.Item2)
.Intersect(outputs.Select(x => x.Item3.Item2))).Select(
outerNode =>
{
//var node = new Apply1();
var node = newNodeWorkspace.AddNode<Apply1>();
node.SetNickNameFromAttribute();
node.DisableReporting();
node.X = outerNode.X;
node.Y = outerNode.Y;
//Fetch all input ports
// in order
// that have inputs
//.........这里部分代码省略.........