本文整理汇总了C#中Dynamo.Models.WorkspaceModel.DisableReporting方法的典型用法代码示例。如果您正苦于以下问题:C# WorkspaceModel.DisableReporting方法的具体用法?C# WorkspaceModel.DisableReporting怎么用?C# WorkspaceModel.DisableReporting使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Dynamo.Models.WorkspaceModel
的用法示例。
在下文中一共展示了WorkspaceModel.DisableReporting方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
//.........这里部分代码省略.........
示例2: Collapse
/// <summary>
/// Collapse a set of nodes in a given workspace. Has the side effects of prompting the user
/// first in order to obtain the name and category for the new node,
/// writes the function to a dyf file, adds it to the FunctionDict, adds it to search, and compiles and
/// places the newly created symbol (defining a lambda) in the Controller's FScheme Environment.
/// </summary>
/// <param name="selectedNodes"> The function definition for the user-defined node </param>
/// <param name="currentWorkspace"> The workspace where</param>
public static void Collapse(IEnumerable<NodeModel> selectedNodes, WorkspaceModel currentWorkspace, FunctionNamePromptEventArgs args=null)
{
var selectedNodeSet = new HashSet<NodeModel>(selectedNodes);
if (args == null || !args.Success)
{
args = new FunctionNamePromptEventArgs();
dynSettings.Controller.DynamoModel.OnRequestsFunctionNamePrompt(null, args);
//if (!dynSettings.Controller.DynamoViewModel.ShowNewFunctionDialog(ref newNodeName, ref newNodeCategory))
if (!args.Success)
{
return;
}
}
var newNodeWorkspace = new CustomNodeWorkspaceModel(args.Name, args.Category, args.Description, 0, 0)
{
WatchChanges = false,
HasUnsavedChanges = true
};
var newNodeDefinition = new FunctionDefinition(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();
//MVVM : Don't make direct reference to view here
//MVVM: no reference to view here
//dynNodeView nodeUI = node.NodeUI;
var elNameAttrib =
node.GetType().GetCustomAttributes(typeof(NodeNameAttribute), true)[0] as
NodeNameAttribute;
if (elNameAttrib != null)
{
node.NickName = elNameAttrib.Name;
}
node.GUID = Guid.NewGuid();
//store the element in the elements list
newNodeWorkspace.Nodes.Add(node);
node.WorkSpace = newNodeWorkspace;
node.DisableReporting();
//MVVM : Can't set view location here
//dynSettings.Bench.WorkBench.Children.Add(nodeUI);
//Place it in an appropriate spot
//Canvas.SetLeft(nodeUI, Canvas.GetLeft(outerNode.NodeUI));
//Canvas.SetTop(nodeUI, Canvas.GetTop(outerNode.NodeUI));
node.X = outerNode.X;
node.Y = outerNode.Y;
//Fetch all input ports
// in order
// that have inputs
//.........这里部分代码省略.........