本文整理汇总了C#中Dynamo.Models.DynamoModel.UndoRedoCommand类的典型用法代码示例。如果您正苦于以下问题:C# DynamoModel.UndoRedoCommand类的具体用法?C# DynamoModel.UndoRedoCommand怎么用?C# DynamoModel.UndoRedoCommand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DynamoModel.UndoRedoCommand类属于Dynamo.Models命名空间,在下文中一共展示了DynamoModel.UndoRedoCommand类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Redo
private void Redo(object parameter)
{
var command = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Redo);
this.ExecuteCommand(command);
}
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:5,代码来源:DynamoViewModel.cs
示例2: TestNodeToCodeUndoBase
private void TestNodeToCodeUndoBase(string filePath)
{
// Verify after undo all nodes and connectors should be resotored back
// to original state.
OpenModel(filePath);
var wp = CurrentDynamoModel.CurrentWorkspace;
var nodeGuids = wp.Nodes.Select(n => n.GUID).ToList();
nodeGuids.Sort();
var connectorGuids = wp.Connectors.Select(c => c.GUID).ToList();
connectorGuids.Sort();
SelectAll(wp.Nodes);
var command = new DynamoModel.ConvertNodesToCodeCommand();
CurrentDynamoModel.ExecuteCommand(command);
var undo = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);
CurrentDynamoModel.ExecuteCommand(undo);
var curNodeGuids = wp.Nodes.Select(n => n.GUID).ToList();
curNodeGuids.Sort();
var curConnectorGuids = wp.Connectors.Select(c => c.GUID).ToList();
curConnectorGuids.Sort();
Assert.AreEqual(curNodeGuids.Count, nodeGuids.Count);
Assert.IsTrue(nodeGuids.SequenceEqual(curNodeGuids));
Assert.AreEqual(curConnectorGuids.Count, connectorGuids.Count);
Assert.IsTrue(connectorGuids.SequenceEqual(curConnectorGuids));
}
开发者ID:Conceptual-Design,项目名称:Dynamo,代码行数:32,代码来源:NodeToCodeTest.cs
示例3: RunTest
public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer)
{
bool pass = false;
var valueMap = new Dictionary<Guid, String>();
if (node.OutPorts.Count > 0)
{
var firstNodeConnectors = node.AllConnectors.ToList(); //Get node connectors
foreach (ConnectorModel connector in firstNodeConnectors)
{
Guid guid = connector.Start.Owner.GUID;
if (!valueMap.ContainsKey(guid))
{
Object data = connector.Start.Owner.GetValue(0, engine).Data;
String val = data != null ? data.ToString() : "null";
valueMap.Add(guid, val);
writer.WriteLine(guid + " :: " + val);
writer.Flush();
}
}
}
int numberOfUndosNeeded = Mutate(node);
Thread.Sleep(100);
writer.WriteLine("### - Beginning undo");
for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++)
{
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.UndoRedoCommand undoCommand =
new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);
DynamoViewModel.ExecuteCommand(undoCommand);
}));
Thread.Sleep(100);
}
writer.WriteLine("### - undo complete");
writer.Flush();
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.RunCancelCommand runCancel =
new DynamoModel.RunCancelCommand(false, false);
DynamoViewModel.ExecuteCommand(runCancel);
}));
while (!DynamoViewModel.HomeSpace.RunSettings.RunEnabled)
{
Thread.Sleep(10);
}
writer.WriteLine("### - Beginning test of NumberSequence");
if (node.OutPorts.Count > 0)
{
try
{
var firstNodeConnectors = node.AllConnectors.ToList();
foreach (ConnectorModel connector in firstNodeConnectors)
{
String valmap = valueMap[connector.Start.Owner.GUID].ToString();
Object data = connector.Start.Owner.GetValue(0, engine).Data;
String nodeVal = data != null ? data.ToString() : "null";
if (valmap != nodeVal)
{
writer.WriteLine("!!!!!!!!!!! - test of NumberSequence is failed");
writer.WriteLine(node.GUID);
writer.WriteLine("Was: " + nodeVal);
writer.WriteLine("Should have been: " + valmap);
writer.Flush();
return pass;
}
}
}
catch (Exception)
{
writer.WriteLine("!!!!!!!!!!! - test of NumberSequence is failed");
writer.Flush();
return pass;
}
}
writer.WriteLine("### - test of NumberSequence complete");
writer.Flush();
return pass = true;
}
开发者ID:JinWooShin,项目名称:Dynamo,代码行数:88,代码来源:NumberSequenceMutator.cs
示例4: TestBasicNode2CodeWorkFlow2
public void TestBasicNode2CodeWorkFlow2()
{
// 1 -> Point.ByCoordinates ---+
// |---------------------------+
// +-- List.Create (index0) |-> Line.ByStartPointEndPoint
// +--> List.Create (index1) |
// |---------------------------+
// 2 -> Point.ByCoordinates ---+
OpenModel(@"core\node2code\workflow2.dyn");
var nodes = CurrentDynamoModel.CurrentWorkspace.Nodes;
SelectAll(nodes);
var command = new DynamoModel.ConvertNodesToCodeCommand();
CurrentDynamoModel.ExecuteCommand(command);
Assert.AreEqual(0, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());
Assert.AreEqual(1, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
var undo = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);
CurrentDynamoModel.ExecuteCommand(undo);
Assert.AreEqual(6, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());
Assert.AreEqual(6, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
}
开发者ID:Conceptual-Design,项目名称:Dynamo,代码行数:24,代码来源:NodeToCodeTest.cs
示例5: TestBasicNode2CodeWorkFlow4
public void TestBasicNode2CodeWorkFlow4()
{
OpenModel(@"core\node2code\workflow4.dyn");
var nodes = CurrentDynamoModel.CurrentWorkspace.Nodes;
SelectAll(nodes);
var command = new DynamoModel.ConvertNodesToCodeCommand();
CurrentDynamoModel.ExecuteCommand(command);
Assert.AreEqual(3, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());
Assert.AreEqual(3, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
var undo = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);
CurrentDynamoModel.ExecuteCommand(undo);
Assert.AreEqual(4, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());
Assert.AreEqual(4, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
}
开发者ID:Conceptual-Design,项目名称:Dynamo,代码行数:18,代码来源:NodeToCodeTest.cs
示例6: MutationTest
/// <summary>
/// Run the dyn file and get all preview values in string representation.
/// Then, iterate all nodes, for each iteration, choose a node and convert
/// the remaining nodes to code, and compare the preview value of this
/// node against with its original value; then undo, run and compare the
/// preview values of all nodes with original values.
/// </summary>
/// <param name="dynFilePath"></param>
protected void MutationTest(string dynFilePath)
{
CurrentDynamoModel.Scheduler.ProcessMode = TaskProcessMode.Asynchronous;
RunModel(dynFilePath);
// Block until all tasks are executed
while (CurrentDynamoModel.Scheduler.HasPendingTasks);
var allNodes = CurrentDynamoModel.CurrentWorkspace.Nodes.Select(n => n.GUID).ToList();
int nodeCount = allNodes.Count();
var previewMap = allNodes.ToDictionary(n => n, n => GetStringData(n));
var convertibleNodes = CurrentDynamoModel.CurrentWorkspace.Nodes
.Where(node => node.IsConvertible)
.Select(n => n.GUID).ToList();
int connectorCount = CurrentDynamoModel.CurrentWorkspace.Connectors.Count();
for (int i = 1; i <= Math.Min(convertibleNodes.Count(), 10); ++i)
{
var toBeConvertedNodes = convertibleNodes.Take(i);
var otherNodes = allNodes.Except(toBeConvertedNodes);
SelectAll(toBeConvertedNodes);
var command = new DynamoModel.ConvertNodesToCodeCommand();
CurrentDynamoModel.ExecuteCommand(command);
// Block until all tasks are executed
while (CurrentDynamoModel.Scheduler.HasPendingTasks);
foreach (var node in otherNodes)
{
// Verify after converting remaining nodes to code, the value
// of node that is not converted should remain same.
var preValue = previewMap[node];
var currentValue = GetStringData(node);
Assert.AreEqual(preValue, currentValue);
}
var undo = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);
CurrentDynamoModel.ExecuteCommand(undo);
// Block until all tasks are executed
while (CurrentDynamoModel.Scheduler.HasPendingTasks) ;
// Verify after undo everything is OK
Assert.AreEqual(nodeCount, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
Assert.AreEqual(connectorCount, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());
foreach (var node in CurrentDynamoModel.CurrentWorkspace.Nodes)
{
Assert.IsTrue(previewMap.ContainsKey(node.GUID));
var preValue = previewMap[node.GUID];
var currentValue = GetStringData(node.GUID);
Assert.AreEqual(preValue, currentValue);
}
}
}
开发者ID:Conceptual-Design,项目名称:Dynamo,代码行数:64,代码来源:NodeToCodeTest.cs
示例7: TestBasicNode2CodeWorkFlow1
public void TestBasicNode2CodeWorkFlow1()
{
// 1 -> a -> x
OpenModel(@"core\node2code\workflow1.dyn");
var nodes = CurrentDynamoModel.CurrentWorkspace.Nodes;
var engine = CurrentDynamoModel.EngineController;
var result = engine.ConvertNodesToCode(nodes, nodes);
result = NodeToCodeCompiler.ConstantPropagationForTemp(result, Enumerable.Empty<string>());
Assert.IsNotNull(result);
Assert.IsNotNull(result.AstNodes);
var expr1 = result.AstNodes.First() as BinaryExpressionNode;
var expr2 = result.AstNodes.Last() as BinaryExpressionNode;
Assert.IsNotNull(expr1);
Assert.IsNotNull(expr2);
Assert.IsTrue(expr1.ToString().StartsWith("a = 1;"));
Assert.IsTrue(expr2.ToString().StartsWith("x = a;"));
var undo = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);
CurrentDynamoModel.ExecuteCommand(undo);
Assert.AreEqual(2, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());
Assert.AreEqual(3, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
}
开发者ID:Conceptual-Design,项目名称:Dynamo,代码行数:27,代码来源:NodeToCodeTest.cs
示例8: UndoTest
/// <summary>
/// Run the dyn file and get all preview values in string representation.
/// Undo, force run and get all preview values in string representation.
/// These two sets of preview value should be the same.
/// </summary>
/// <param name="dynFilePath"></param>
protected void UndoTest(string dynFilePath)
{
Dictionary<Guid, string> previewMap = new Dictionary<Guid, string>();
RunModel(dynFilePath);
foreach (var node in CurrentDynamoModel.CurrentWorkspace.Nodes)
{
previewMap[node.GUID] = GetStringData(node.GUID);
}
int nodeCount = CurrentDynamoModel.CurrentWorkspace.Nodes.Count();
int connectorCount = CurrentDynamoModel.CurrentWorkspace.Connectors.Count();
SelectAll();
var command = new DynamoModel.ConvertNodesToCodeCommand();
CurrentDynamoModel.ExecuteCommand(command);
CurrentDynamoModel.ForceRun();
var undo = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);
CurrentDynamoModel.ExecuteCommand(undo);
CurrentDynamoModel.ForceRun();
// Verify after undo everything is OK
Assert.AreEqual(nodeCount, CurrentDynamoModel.CurrentWorkspace.Nodes.Count());
Assert.AreEqual(connectorCount, CurrentDynamoModel.CurrentWorkspace.Connectors.Count());
foreach (var node in CurrentDynamoModel.CurrentWorkspace.Nodes)
{
Assert.IsTrue(previewMap.ContainsKey(node.GUID));
var preValue = previewMap[node.GUID];
var currentValue = GetStringData(node.GUID);
Assert.AreEqual(preValue, currentValue);
}
}
开发者ID:dspeckhard,项目名称:Dynamo,代码行数:40,代码来源:NodeToCodeTest.cs
示例9: MutationTest
/// <summary>
/// Run the dyn file and get all preview values in string representation.
/// Then, iterate all nodes, for each iteration, choose a node and convert
/// the remaining nodes to code, and compare the preview value of this
/// node against with its original value.
/// </summary>
/// <param name="dynFilePath"></param>
protected void MutationTest(string dynFilePath)
{
Dictionary<Guid, string> previewMap = new Dictionary<Guid, string>();
RunModel(dynFilePath);
foreach (var node in CurrentDynamoModel.CurrentWorkspace.Nodes)
{
previewMap[node.GUID] = GetStringData(node.GUID);
}
var nodes = CurrentDynamoModel.CurrentWorkspace.Nodes.Select(n => n.GUID).ToList();
foreach (var node in nodes)
{
SelectAllExcept(node);
var command = new DynamoModel.ConvertNodesToCodeCommand();
CurrentDynamoModel.ExecuteCommand(command);
CurrentDynamoModel.ForceRun();
var preValue = previewMap[node];
var currentValue = GetStringData(node);
Assert.AreEqual(preValue, currentValue);
var undo = new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);
CurrentDynamoModel.ExecuteCommand(undo);
}
}
开发者ID:dspeckhard,项目名称:Dynamo,代码行数:33,代码来源:NodeToCodeTest.cs
示例10: RunTest
public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer)
{
bool pass = false;
List<ConnectorModel> firstNodeConnectors = node.AllConnectors.ToList();
Dictionary<Guid, String> valueMap = new Dictionary<Guid, String>();
foreach (ConnectorModel connector in firstNodeConnectors)
{
if (connector.Start.Owner.GUID != node.GUID)
{
Guid guid = connector.Start.Owner.GUID;
if (!valueMap.ContainsKey(guid))
{
String val = connector.Start.Owner.NickName;
valueMap.Add(guid, val);
writer.WriteLine(guid + " :: " + val);
writer.Flush();
}
}
else if (connector.End.Owner.GUID != node.GUID)
{
Guid guid = connector.End.Owner.GUID;
if (!valueMap.ContainsKey(guid))
{
String val = connector.End.Owner.NickName;
valueMap.Add(guid, val);
writer.WriteLine(guid + " :: " + val);
writer.Flush();
}
}
}
int numberOfUndosNeeded = Mutate(node);
Thread.Sleep(0);
IEnumerable<NodeModel> nodesAfterMutate = DynamoViewModel.Model.CurrentWorkspace.Nodes;
if (nodesAfterMutate.Contains(node))
{
writer.WriteLine("### - Connector wasn't deleted");
writer.Flush();
return pass;
}
else
writer.WriteLine("### - Connector was deleted");
for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++)
{
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.UndoRedoCommand undoCommand =
new DynamoModel.UndoRedoCommand(
DynamoModel.UndoRedoCommand.Operation.Undo);
DynamoViewModel.ExecuteCommand(undoCommand);
}));
}
Thread.Sleep(0);
IEnumerable<NodeModel> nodesAfterUndo = DynamoViewModel.Model.CurrentWorkspace.Nodes;
NodeModel nodeAfterUndo = nodesAfterUndo.FirstOrDefault(t => t.GUID.Equals(node.GUID));
List<ConnectorModel> firstNodeConnectorsAfterUndo = nodeAfterUndo.AllConnectors.ToList();
foreach (ConnectorModel connector in firstNodeConnectorsAfterUndo)
{
if (connector.Start.Owner.GUID != node.GUID)
{
Guid guid = connector.Start.Owner.GUID;
if (!valueMap.ContainsKey(guid))
{
writer.WriteLine("### - ### - Connector wasn't recreated");
writer.Flush();
return pass;
}
else
{
writer.WriteLine("### - Connector was recreated");
writer.Flush();
}
}
else if (connector.End.Owner.GUID != node.GUID)
{
Guid guid = connector.End.Owner.GUID;
if (!valueMap.ContainsKey(guid))
{
writer.WriteLine("### - ### - Connector wasn't recreated");
writer.Flush();
return pass;
}
else
{
writer.WriteLine("### - Connector was recreated");
writer.Flush();
//.........这里部分代码省略.........
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:101,代码来源:ConnectorMutator.cs
示例11: RunTest
public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer)
{
bool pass = false;
var valueMap = new Dictionary<Guid, String>();
if (node.OutPorts.Count > 0)
{
Guid guid = node.GUID;
Object data = node.GetValue(0, engine).Data;
String val = data != null ? data.ToString() : "null";
valueMap.Add(guid, val);
writer.WriteLine(guid + " :: " + val);
writer.Flush();
}
int numberOfUndosNeeded = Mutate(node);
Thread.Sleep(100);
writer.WriteLine("### - Beginning undo");
for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++)
{
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.UndoRedoCommand undoCommand =
new DynamoModel.UndoRedoCommand(
DynamoModel.UndoRedoCommand.Operation.Undo);
DynamoViewModel.ExecuteCommand(undoCommand);
}));
}
Thread.Sleep(100);
writer.WriteLine("### - undo complete");
writer.Flush();
writer.WriteLine("### - Beginning re-exec");
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.RunCancelCommand runCancel =
new DynamoModel.RunCancelCommand(false, false);
DynamoViewModel.ExecuteCommand(runCancel);
}));
Thread.Sleep(10);
while (!DynamoViewModel.HomeSpace.RunSettings.RunEnabled)
{
Thread.Sleep(10);
}
writer.WriteLine("### - re-exec complete");
writer.Flush();
writer.WriteLine("### - Beginning readback");
writer.WriteLine("### - Beginning test of DirectoryPath");
if (node.OutPorts.Count > 0)
{
try
{
string valmap = valueMap[node.GUID].ToString();
object data = node.GetValue(0, engine).Data;
string nodeVal = data != null ? data.ToString() : "null";
if (valmap != nodeVal)
{
writer.WriteLine("!!!!!!!!!!! - test of DirectoryPath is failed");
writer.WriteLine(node.GUID);
writer.WriteLine("Was: " + nodeVal);
writer.WriteLine("Should have been: " + valmap);
writer.Flush();
return pass;
}
}
catch (Exception)
{
writer.WriteLine("!!!!!!!!!!! - test of DirectoryPath is failed");
writer.Flush();
return pass;
}
}
writer.WriteLine("### - test of DirectoryPath complete");
writer.Flush();
return pass = true;
}
开发者ID:JinWooShin,项目名称:Dynamo,代码行数:86,代码来源:DirectoryPathMutator.cs
示例12: RunTest
public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer)
{
const bool pass = false;
var nodes = DynamoViewModel.Model.CurrentWorkspace.Nodes;
if (nodes.Count() == 0)
return pass;
int nodesCountBeforeCopying = nodes.Count();
int numberOfUndosNeeded = this.Mutate(node);
Thread.Sleep(10);
writer.WriteLine("### - Beginning undo");
for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++)
{
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.UndoRedoCommand undoCommand =
new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);
DynamoViewModel.ExecuteCommand(undoCommand);
}));
Thread.Sleep(0);
}
writer.WriteLine("### - undo complete");
writer.Flush();
ExecuteAndWait();
writer.WriteLine("### - Beginning test of CopyNode");
if (node.OutPorts.Count > 0)
{
try
{
int nodesCountAfterCopying = DynamoViewModel.Model.CurrentWorkspace.Nodes.Count();
if (nodesCountBeforeCopying != nodesCountAfterCopying)
{
writer.WriteLine("!!!!!!!!!!! - test of CopyNode is failed");
writer.WriteLine(node.GUID);
writer.WriteLine("Was: " + nodesCountAfterCopying);
writer.WriteLine("Should have been: " + nodesCountBeforeCopying);
writer.Flush();
return pass;
}
else
{
writer.WriteLine("### - test of CopyNode is passed");
writer.Flush();
}
}
catch (Exception)
{
writer.WriteLine("!!!!!!!!!!! - test of CopyNode is failed");
writer.Flush();
return pass;
}
}
writer.WriteLine("### - test of CopyNode complete");
writer.Flush();
return true;
}
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:66,代码来源:CopyNodeMutator.cs
示例13: RunTest
public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer)
{
bool pass = false;
var types = LoadAllTypesFromDynamoAssemblies();
foreach (Type type in types)
{
string nodeName = GetName(type);
var firstNodeConnectors = node.AllConnectors.ToList();
double coordinatesX = node.X;
double coordinatesY = node.Y;
if (!string.IsNullOrEmpty(nodeName))
{
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
var newNode = type.GetDefaultConstructor<NodeModel>()();
DynamoModel.CreateNodeCommand createCommand =
new DynamoModel.CreateNodeCommand(
newNode, coordinatesX, coordinatesY, false, false);
DynamoViewModel.ExecuteCommand(createCommand);
}));
var valueMap = new Dictionary<Guid, String>();
foreach (ConnectorModel connector in firstNodeConnectors)
{
Guid guid = connector.Start.Owner.GUID;
Object data = connector.Start.Owner.GetValue(0, engine).Data;
String val = data != null ? data.ToString() : "null";
valueMap.Add(guid, val);
writer.WriteLine(guid + " :: " + val);
writer.Flush();
}
int numberOfUndosNeeded = Mutate(node);
Thread.Sleep(100);
writer.WriteLine("### - Beginning undo");
for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++)
{
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.UndoRedoCommand undoCommand =
new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);
DynamoViewModel.ExecuteCommand(undoCommand);
}));
}
Thread.Sleep(100);
writer.WriteLine("### - undo complete");
writer.Flush();
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.RunCancelCommand runCancel =
new DynamoModel.RunCancelCommand(false, false);
DynamoViewModel.ExecuteCommand(runCancel);
}));
while (!DynamoViewModel.HomeSpace.RunSettings.RunEnabled)
{
Thread.Sleep(10);
}
writer.WriteLine("### - Beginning test of CustomNode");
if (node.OutPorts.Count > 0)
{
try
{
NodeModel nodeAfterUndo =
DynamoViewModel.Model.CurrentWorkspace.Nodes.FirstOrDefault(
(t) => (t.GUID == node.GUID));
if (nodeAfterUndo != null)
{
var firstNodeConnectorsAfterUndo = nodeAfterUndo.AllConnectors.ToList();
foreach (ConnectorModel connector in firstNodeConnectors)
{
Guid guid = connector.Start.Owner.GUID;
Object data = connector.Start.Owner.GetValue(0, engine).Data;
String val = data != null ? data.ToString() : "null";
if (valueMap[guid] != val)
{
writer.WriteLine("!!!!!!!!!!! - test of CustomNode is failed");
writer.WriteLine(node.GUID);
writer.WriteLine("Was: " + val);
writer.WriteLine("Should have been: " + valueMap[guid]);
writer.Flush();
return pass;
}
}
}
//.........这里部分代码省略.........
开发者ID:norbertzsiros,项目名称:Dynamo,代码行数:101,代码来源:CustomNodeCompatibilityMutator.cs
示例14: RunTest
public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer)
{
bool pass = false;
int workspaceIndex = DynamoViewModel.CurrentWorkspaceIndex;
var firstNodeConnectors = node.AllConnectors.ToList();
var valueMap = new Dictionary<Guid, String>();
foreach (ConnectorModel connector in firstNodeConnectors)
{
if (connector.End.Owner.GUID != node.GUID)
{
Guid guid = connector.Start.Owner.GUID;
Object data = connector.Start.Owner.GetValue(0, engine).Data;
String val = data != null ? data.ToString() : "null";
valueMap.Add(guid, val);
writer.WriteLine(guid + " :: " + val);
writer.Flush();
}
}
string customNodeFilePath = string.Empty;
var function = node as Function;
CustomNodeInfo info = null;
if (function != null)
{
var id = function.Definition.FunctionId;
if (DynamoViewModel.Model.CustomNodeManager.TryGetNodeInfo(id, out info))
{
customNodeFilePath = info.Path;
}
}
var workspaces = DynamoViewModel.Model.Workspaces;
if (File.Exists(customNodeFilePath))
{
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.OpenFileCommand openFile =
new DynamoModel.OpenFileCommand(customNodeFilePath);
DynamoViewModel.ExecuteCommand(openFile);
}));
Thread.Sleep(100);
var nodesInCustomNodeBeforeMutation =
workspaces.FirstOrDefault((t) => (t.Name == info.Name)).Nodes.ToList();
var customNodeStructureBeforeMutation =
GetDictionaryOfConnectedNodes(nodesInCustomNodeBeforeMutation);
int numberOfUndosNeeded = Mutate(node);
Thread.Sleep(100);
writer.WriteLine("### - Beginning undo");
for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++)
{
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.UndoRedoCommand undoCommand =
new DynamoModel.UndoRedoCommand(DynamoModel.UndoRedoCommand.Operation.Undo);
DynamoViewModel.ExecuteCommand(undoCommand);
}));
Thread.Sleep(100);
}
writer.WriteLine("### - undo complete");
writer.Flush();
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.RunCancelCommand runCancel =
new DynamoModel.RunCancelCommand(false, false);
DynamoViewModel.ExecuteCommand(runCancel);
}));
while (!DynamoViewModel.HomeSpace.RunSettings.RunEnabled)
{
Thread.Sleep(10);
}
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.SwitchTabCommand switchCmd =
new DynamoModel.SwitchTabCommand(workspaceIndex);
DynamoViewModel.ExecuteCommand(switchCmd);
}));
Thread.Sleep(100);
var nodesInCustomNodeAfterMutation =
workspaces.FirstOrDefault((t) => (t.Name == info.Name)).Nodes.ToList();
var customNodeStructureAfterMutation =
GetDictionaryOfConnectedNodes(nodesInCustomNodeAfterMutation);
writer.WriteLine("### - Beginning test of CustomNode structure");
//.........这里部分代码省略.........
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:101,代码来源:CustomNodeMutator.cs
示例15: RunTest
public override bool RunTest(NodeModel node, EngineController engine, StreamWriter writer)
{
bool pass = false;
var nodes = DynamoViewModel.Model.CurrentWorkspace.Nodes;
if (nodes.Count() == 0)
return true;
int nodesCountBeforeDelete = nodes.Count();
writer.WriteLine("### - Beginning readout");
writer.WriteLine("### - Beginning delete");
writer.WriteLine("### - Deletion target: " + node.GUID);
int numberOfUndosNeeded = Mutate(node);
Thread.Sleep(0);
writer.WriteLine("### - delete complete");
writer.Flush();
writer.WriteLine("### - Beginning re-exec");
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.RunCancelCommand runCancel =
new DynamoModel.RunCancelCommand(false, false);
DynamoViewModel.ExecuteCommand(runCancel);
}));
Thread.Sleep(0);
writer.WriteLine("### - re-exec complete");
writer.Flush();
writer.WriteLine("### - Beginning undo");
int nodesCountAfterDelete = DynamoViewModel.Model.CurrentWorkspace.Nodes.Count();
if (nodesCountBeforeDelete > nodesCountAfterDelete)
{
for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++)
{
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.UndoRedoCommand undoCommand =
new DynamoModel.UndoRedoCommand(
DynamoModel.UndoRedoCommand.Operation.Undo);
DynamoViewModel.ExecuteCommand(undoCommand);
}));
Thread.Sleep(0);
}
writer.WriteLine("### - undo complete");
writer.Flush();
writer.WriteLine("### - Beginning re-exec");
ExecuteAndWait();
writer.WriteLine("### - re-exec complete");
writer.Flush();
int nodesCountAfterUbdo = DynamoViewModel.Model.CurrentWorkspace.Nodes.Count();
if (nodesCountBeforeDelete == nodesCountAfterUbdo)
writer.WriteLine("### - Node was restored");
else
{
writer.WriteLine("### - Node wasn't restored");
return pass;
}
writer.Flush();
}
else
{
writer.WriteLine("### - Error removing a node");
writer.Flush();
return pass;
}
return pass = true;
}
开发者ID:rafatahmed,项目名称:Dynamo,代码行数:81,代码来源:DeleteNodeMutator.cs
示例16: RunTest
public override bool RunTest(NodeModel node, StreamWriter writer)
{
bool pass = false;
writer.WriteLine("### - Beginning readout");
var valueMap = new Dictionary<Guid, String>();
if (node.OutPorts.Count > 0)
{
Guid guid = node.GUID;
Object data = node.GetValue(0).Data;
String val = data != null ? data.ToString() : "null";
valueMap.Add(guid, val);
writer.WriteLine(guid + " :: " + val);
writer.Flush();
}
writer.WriteLine("### - Readout complete");
writer.Flush();
writer.WriteLine("### - Beginning delete");
writer.WriteLine("### - Deletion target: " + node.GUID);
int numberOfUndosNeeded = Mutate(node);
Thread.Sleep(100);
writer.WriteLine("### - delete complete");
writer.Flush();
writer.WriteLine("### - Beginning re-exec");
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.RunCancelCommand runCancel =
new DynamoModel.RunCancelCommand(false, false);
DynamoViewModel.ExecuteCommand(runCancel);
}));
Thread.Sleep(100);
writer.WriteLine("### - re-exec complete");
writer.Flush();
writer.WriteLine("### - Beginning undo");
for (int iUndo = 0; iUndo < numberOfUndosNeeded; iUndo++)
{
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.UndoRedoCommand undoCommand =
new DynamoModel.UndoRedoCommand(
DynamoModel.UndoRedoCommand.Operation.Undo);
DynamoViewModel.ExecuteCommand(undoCommand);
}));
}
Thread.Sleep(100);
writer.WriteLine("### - undo complete");
writer.Flush();
writer.WriteLine("### - Beginning re-exec");
DynamoViewModel.UIDispatcher.Invoke(new Action(() =>
{
DynamoModel.RunCancelCommand runCancel =
new DynamoModel.RunCancelCommand(false, false);
DynamoViewModel.ExecuteCommand(runCancel);
}));
Thread.Sleep(10);
while (DynamoViewModel.Model.Runner.Running)
{
Thread.Sleep(10);
}
writer.WriteLine("### - re-exec complete");
writer.Flush();
writer.WriteLine("### - Beginning readback");
if (node.OutPorts.Count > 0)
{
try
{
String valmap = valueMap[node.GUID].ToString();
Object data = node.GetValue(0).Data;
String nodeVal = data != null ? data.ToString() : "null";
if (valmap != nodeVal)
{
writer.WriteLine("!!!!!!!!!!! Read-back failed");
writer.WriteLine(node.GUID);
writer.WriteLine("Was: " + nodeVal);
writer.WriteLine("Should have been: " + valmap);
writer.Flush();
return pass;
}
}
//.........这里部分代码省略.........
开发者ID:whztt07,项目名称:Dynamo,代码行数:101,代码来源:CodeBlockNodeMutator.cs
注:本文中的Dynamo.Models.DynamoModel.UndoRedoCommand类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论