public void TestCutLine() { NodeOutputViewModel nodeAOutput = new NodeOutputViewModel(); NodeViewModel nodeA = new NodeViewModel(); nodeA.Outputs.Add(nodeAOutput); NodeInputViewModel nodeBInput = new NodeInputViewModel(); NodeOutputViewModel nodeBOutput = new NodeOutputViewModel(); NodeViewModel nodeB = new NodeViewModel { CanBeRemovedByUser = false, IsSelected = true }; nodeB.Inputs.Add(nodeBInput); nodeB.Outputs.Add(nodeBOutput); NodeInputViewModel nodeCInput = new NodeInputViewModel(); NodeViewModel nodeC = new NodeViewModel { IsSelected = true }; nodeC.Inputs.Add(nodeCInput); NodeViewModel nodeD = new NodeViewModel { IsSelected = true }; NetworkViewModel network = new NetworkViewModel(); network.Nodes.AddRange(new[] { nodeA, nodeB, nodeC, nodeD }); var conAB = network.ConnectionFactory(nodeBInput, nodeAOutput); var conBC = network.ConnectionFactory(nodeCInput, nodeBOutput); network.Connections.Add(conAB); network.Connections.Add(conBC); network.StartCut(); network.CutLine.IntersectingConnections.Add(conAB); network.FinishCut(); Assert.IsTrue(network.Connections.Items.SequenceEqual(new [] { conBC })); Assert.IsFalse(network.CutLine.IsVisible); }
public void TestValidateAfterConnectionsAllUpdated() { NodeInputViewModel input1 = new NodeInputViewModel(); NodeOutputViewModel output1 = new NodeOutputViewModel(); NodeViewModel node1 = new NodeViewModel { Inputs = { input1 }, Outputs = { output1 } }; NodeInputViewModel input2 = new NodeInputViewModel(); NodeOutputViewModel output2 = new NodeOutputViewModel(); NodeViewModel node2 = new NodeViewModel { Inputs = { input2 }, Outputs = { output2 } }; NetworkViewModel network = new NetworkViewModel(); network.Validator = n => { if (GraphAlgorithms.FindLoops(network).Any()) { return(new NetworkValidationResult(false, false, null)); } return(new NetworkValidationResult(true, true, null)); }; network.Nodes.Add(node1); network.Nodes.Add(node2); var conn1 = network.ConnectionFactory(input1, output2); network.Connections.Add(conn1); Assert.IsTrue(network.LatestValidation.IsValid); var conn2 = network.ConnectionFactory(input2, output1); network.Connections.Add(conn2); Assert.IsFalse(network.LatestValidation.IsValid); network.Connections.Remove(conn1); Assert.IsTrue(network.LatestValidation.IsValid); }
public void TestValuePropagation() { //Setup var scheduler = new TestScheduler(); var nodeA = new NodeViewModel(); Subject <int> sourceA = new Subject <int>(); var outputA = new ValueNodeOutputViewModel <int> { Value = sourceA }; nodeA.Outputs.Add(outputA); var nodeB = new NodeViewModel(); var inputB = new ValueListNodeInputViewModel <int>(); nodeB.Inputs.Add(inputB); NetworkViewModel network = new NetworkViewModel(); network.Nodes.AddRange(new [] { nodeA, nodeB }); network.Connections.Add(network.ConnectionFactory(inputB, outputA)); //Define actions scheduler.Schedule(TimeSpan.FromTicks(10), () => sourceA.OnNext(1)); scheduler.Schedule(TimeSpan.FromTicks(20), () => sourceA.OnNext(0)); scheduler.Schedule(TimeSpan.FromTicks(30), () => sourceA.OnNext(1)); scheduler.Schedule(TimeSpan.FromTicks(40), () => sourceA.OnNext(0)); scheduler.Schedule(TimeSpan.FromTicks(50), () => sourceA.OnNext(2)); var actual = scheduler.Start(() => inputB.Values.Connect().QueryWhenChanged(), created: 0, subscribed: 0, disposed: 100); //Assert Assert.AreEqual(actual.Messages.Count, 6); Assert.AreEqual(actual.Messages[0].Time, 1); Assert.IsTrue(actual.Messages[0].Value.Value.SequenceEqual(new[] { 0 })); Assert.AreEqual(actual.Messages[1].Time, 10); Assert.IsTrue(actual.Messages[1].Value.Value.SequenceEqual(new[] { 1 })); Assert.AreEqual(actual.Messages[2].Time, 20); Assert.IsTrue(actual.Messages[2].Value.Value.SequenceEqual(new[] { 0 })); Assert.AreEqual(actual.Messages[3].Time, 30); Assert.IsTrue(actual.Messages[3].Value.Value.SequenceEqual(new[] { 1 })); Assert.AreEqual(actual.Messages[4].Time, 40); Assert.IsTrue(actual.Messages[4].Value.Value.SequenceEqual(new[] { 0 })); Assert.AreEqual(actual.Messages[5].Time, 50); Assert.IsTrue(actual.Messages[5].Value.Value.SequenceEqual(new[] { 2 })); }
public MainWindow() { InitializeComponent(); NetworkViewModel v = SimpleIoc.Default.GetInstance <NetworkViewModel>(); v.MainWindow = this; ToggleSidebar(); //turn sidebar off HideNodeList(); /* * InfoWindow info = new InfoWindow(); * info.ShowDialog(); * */ }
public bool StopNetwork(NetworkViewModel viewModel, bool stopServers) { Process p = ApplicationManager.Instance.ActiveEntities[viewModel.Network]; if (p == null) { return(false); } p.StandardInput.WriteLine("end"); if (stopServers) { ConsoleWriter.Write("Stopping all " + viewModel.Servers.Count + " servers of this network...", viewModel); foreach (NetworkServer networkServer in viewModel.Servers) { if (networkServer is NetworkForkServer networkForkServer) { ServerViewModel serverViewModel = networkForkServer.ServerViewModel; if (serverViewModel.CurrentStatus == ServerStatus.RUNNING) { ConsoleWriter.Write("Stopping server " + serverViewModel.Server, viewModel); ServerManager.Instance.StopServer(serverViewModel); } else if (serverViewModel.CurrentStatus == ServerStatus.STOPPED) { ConsoleWriter.Write("Server " + serverViewModel.Server + " is already stopped.", viewModel); } else if (serverViewModel.CurrentStatus == ServerStatus.STARTING) { ConsoleWriter.Write("Server " + serverViewModel.Server + " is currently starting (manual stop needed)", viewModel); } } else { ConsoleWriter.Write("Server " + networkServer.Name + " can't be stopped automatically because it is no Fork server.", viewModel); } } } while (viewModel.CurrentStatus == ServerStatus.RUNNING) { Thread.Sleep(500); } return(true); }
public void CreateNodesRecursive(NetworkViewModel model, Cut previous_cut) { Name = EventDefinitionManager.GetCutDisplayName(Cut.ParentActor.Name, Cut.Name); GenerateContextMenu(); // Add ourselves to the node network model.Nodes.Edit(x => x.Add(this)); // If this is the first node in the chain, create the "Begin" node. if (previous_cut == null) { Position = new System.Windows.Point(Position.X + 400, Position.Y); CreateBeginNode(model); } else { Position = new System.Windows.Point(previous_cut.NodeViewModel.Position.X + 400, previous_cut.NodeViewModel.Position.Y); // If this node is blocked, create a blocking node and insert it between the previous node and this node. if (Cut.IsBlocked()) { CreateBlockingNode(model, previous_cut.NodeViewModel); } // Otherwise, just connect the previous to this node. else { // Create a connection between this cut and the next cut in the list. ConnectionViewModel cut_connection = new ConnectionViewModel( model, Inputs.Items.First(), previous_cut.NodeViewModel.Outputs.Items.First()); // Add the connection to the node network. model.Connections.Edit(x => x.Add(cut_connection)); } } // Now that our position is finalized, we can add our property nodes to the graph. AddPropertiesToNode(); if (Cut.NextCut != null) { Cut.NextCut.NodeViewModel.CreateNodesRecursive(model, Cut); } }
public MainWindow() { InitializeComponent(); //Create a new viewmodel for the NetworkView var network = new NetworkViewModel(); //Create the node for the first node, set its name and add it to the network. var node1 = new NodeViewModel(); node1.Name = "Node 1"; network.Nodes.Add(node1); //Create the viewmodel for the input on the first node, set its name and add it to the node. var node1Input = new NodeInputViewModel(); node1Input.Name = "Node 1 input"; node1.Inputs.Add(node1Input); //Create the second node viewmodel, set its name, add it to the network and add an output in a similar fashion. var node2 = new NodeViewModel(); node2.Name = "Node 2"; network.Nodes.Add(node2); var node2Output = new NodeOutputViewModel(); node2Output.Name = "Node 2 output"; node2.Outputs.Add(node2Output); //Create a third test node var node3 = new NodeViewModel(); node3.Name = "Test "; network.Nodes.Add(node3); var node3Input = new ValueNodeInputViewModel <string>(); node3Input.Name = "Test String"; node3.Inputs.Add(node3Input); //Assign the viewmodel to the view. networkView.ViewModel = network; }
public void TestNestedObserving() { //Setup var scheduler = new TestScheduler(); NodeInputViewModel input1 = new NodeInputViewModel(); NodeOutputViewModel output1 = new NodeOutputViewModel(); NodeViewModel node1 = new NodeViewModel { Inputs = { input1 }, Outputs = { output1 } }; NodeInputViewModel input2 = new NodeInputViewModel(); NodeOutputViewModel output2 = new NodeOutputViewModel(); NodeViewModel node2 = new NodeViewModel { Inputs = { input2 }, Outputs = { output2 } }; NetworkViewModel network = new NetworkViewModel(); network.Nodes.Add(node1); network.Nodes.Add(node2); var conn1 = network.ConnectionFactory(input1, output2); network.Connections.Add(conn1); var obs = network.ConnectionsUpdated; //Define actions scheduler.Schedule(TimeSpan.FromTicks(10), () => network.Connections.Remove(conn1)); var actual = scheduler.Start(() => obs, created: 0, subscribed: 0, disposed: 100); // But subscribe to it here //Assert var expected = new[] { ReactiveTest.OnNext(10, Unit.Default) }; ReactiveAssert.AreElementsEqual(expected, actual.Messages); }
public NetworkViewModel GetNetwork(int _netId) { var network = database.NeuralNetworks.Get(_netId); if (network != null) { NetworkViewModel model = new NetworkViewModel { NetworkName = network.Name, NetworkId = network.Id, NetworkType = network.NetworkType.Name, TypeDescription = network.NetworkType.Description, NetworkDescription = network.Description }; return(model); } return(null); }
public void TestCreatePendingConnection() { TestableOutput output = new TestableOutput(); var node = new NodeViewModel(); node.Outputs.Add(output); NetworkViewModel network = new NetworkViewModel(); network.Nodes.Add(node); Assert.AreEqual(null, network.PendingConnection); output.CreatePendingConnection_public(); Assert.AreEqual(output, network.PendingConnection.Output); Assert.IsTrue(network.PendingConnection.OutputIsLocked); }
public void TestDeleteNodeShouldRemoveConnections() { NodeInputViewModel input1 = new NodeInputViewModel(); NodeOutputViewModel output1 = new NodeOutputViewModel(); NodeViewModel node1 = new NodeViewModel { Inputs = { input1 }, Outputs = { output1 } }; NodeInputViewModel input2 = new NodeInputViewModel(); NodeOutputViewModel output2 = new NodeOutputViewModel(); NodeViewModel node2 = new NodeViewModel { Inputs = { input2 }, Outputs = { output2 } }; NetworkViewModel network = new NetworkViewModel(); network.Nodes.Add(node1); network.Nodes.Add(node2); var conn1 = network.ConnectionFactory(input1, output2); var conn2 = network.ConnectionFactory(input2, output1); network.Connections.Add(conn1); network.Connections.Add(conn2); Assert.IsTrue(network.Connections.Contains(conn1)); Assert.IsTrue(network.Connections.Contains(conn2)); network.Nodes.Remove(node1); Assert.IsFalse(network.Connections.Contains(conn1)); Assert.IsFalse(network.Connections.Contains(conn2)); network.Nodes.AddRange(new [] { node1, node2 }); network.Connections.AddRange(new[] { conn1, conn2 }); Assert.IsTrue(network.Connections.Contains(conn1)); Assert.IsTrue(network.Connections.Contains(conn2)); network.Nodes.Clear(); Assert.IsFalse(network.Connections.Contains(conn1)); Assert.IsFalse(network.Connections.Contains(conn2)); }
public void TestDeleteSelectedNodes() { NodeOutputViewModel nodeAOutput = new NodeOutputViewModel(); NodeViewModel nodeA = new NodeViewModel(); nodeA.Outputs.Add(nodeAOutput); NodeInputViewModel nodeBInput = new NodeInputViewModel(); NodeOutputViewModel nodeBOutput = new NodeOutputViewModel(); NodeViewModel nodeB = new NodeViewModel { CanBeRemovedByUser = false, IsSelected = true, }; nodeB.Inputs.Add(nodeBInput); nodeB.Outputs.Add(nodeBOutput); NodeInputViewModel nodeCInput = new NodeInputViewModel(); NodeViewModel nodeC = new NodeViewModel { IsSelected = true }; nodeC.Inputs.Add(nodeCInput); NodeViewModel nodeD = new NodeViewModel { IsSelected = true }; NetworkViewModel network = new NetworkViewModel { Nodes = { nodeA, nodeB, nodeC, nodeD } }; network.Connections.Add(network.ConnectionFactory(nodeBInput, nodeAOutput)); network.Connections.Add(network.ConnectionFactory(nodeCInput, nodeBOutput)); Observable.Return(Unit.Default).InvokeCommand(network.DeleteSelectedNodes); Assert.AreEqual(1, network.Connections.Count); Assert.IsTrue(network.Nodes.SequenceEqual(new [] { nodeA, nodeB })); }
public void TestRectangleSelection() { NodeOutputViewModel nodeAOutput = new NodeOutputViewModel(); NodeViewModel nodeA = new NodeViewModel(); nodeA.Outputs.Add(nodeAOutput); NodeInputViewModel nodeBInput = new NodeInputViewModel(); NodeOutputViewModel nodeBOutput = new NodeOutputViewModel(); NodeViewModel nodeB = new NodeViewModel { CanBeRemovedByUser = false, IsSelected = true }; nodeB.Inputs.Add(nodeBInput); nodeB.Outputs.Add(nodeBOutput); NodeInputViewModel nodeCInput = new NodeInputViewModel(); NodeViewModel nodeC = new NodeViewModel { IsSelected = true }; nodeC.Inputs.Add(nodeCInput); NodeViewModel nodeD = new NodeViewModel { IsSelected = true }; NetworkViewModel network = new NetworkViewModel { Nodes = { nodeA, nodeB, nodeC, nodeD } }; network.StartRectangleSelection(); network.SelectionRectangle.IntersectingNodes.Add(nodeA); network.SelectionRectangle.IntersectingNodes.Add(nodeD); network.FinishRectangleSelection(); Assert.IsTrue(network.SelectedNodes.SequenceEqual(new[] { nodeA, nodeD })); }
public NetworkViewModel GetNetwork(int id) { NetworkViewModel users = new NetworkViewModel { Individuals = new List <IndividualViewModel>(), Organizations = new List <OrganizationViewModel>() }; List <DbParameter> parameters = new List <DbParameter> { new SqlParameter(Constants.Individual.Id, id) }; using ( IDataReader reader = ExecuteReader(Constants.SPROC.GetUsersNetwork, DbCommandType.StoredProcedure, parameters)) { while (reader.Read()) { IndividualViewModel individual = new IndividualViewModel { Id = (int)reader[Constants.Individual.Id], Name = (string)reader[Constants.Individual.Name], Title = (string)reader[Constants.Individual.Title], Organisation = (string)reader[Constants.Individual.Organization] }; users.Individuals.Add(individual); } if (reader.NextResult()) { while (reader.Read()) { OrganizationViewModel organization = new OrganizationViewModel { Id = (int)reader[Constants.Organization.Id], Name = (string)reader[Constants.Organization.Name], Description = (string)reader[Constants.Organization.Description] }; users.Organizations.Add(organization); } } } return(users); }
public void TestConnectionsUpdatedAfterPreexistingConnectionRemoved() { //Setup var scheduler = new TestScheduler(); NodeInputViewModel input1 = new NodeInputViewModel(); NodeOutputViewModel output1 = new NodeOutputViewModel(); NodeViewModel node1 = new NodeViewModel(); node1.Inputs.Add(input1); node1.Outputs.Add(output1); NodeInputViewModel input2 = new NodeInputViewModel(); NodeOutputViewModel output2 = new NodeOutputViewModel(); NodeViewModel node2 = new NodeViewModel(); node2.Inputs.Add(input2); node2.Outputs.Add(output2); NetworkViewModel network = new NetworkViewModel(); var observable = network.ConnectionsUpdated; // Create observable before nodes/connections are added network.Nodes.Add(node1); network.Nodes.Add(node2); var conn1 = network.ConnectionFactory(input1, output2); network.Connections.Add(conn1); //Define actions scheduler.Schedule(TimeSpan.FromTicks(10), () => network.Connections.Remove(conn1)); var actual = scheduler.Start(() => observable, created: 0, subscribed: 0, disposed: 100); // But subscribe to it here //Assert var expected = new[] { ReactiveTest.OnNext(10, Unit.Default) }; ReactiveAssert.AreElementsEqual(expected, actual.Messages); }
public ActionResult Edit(int id, NetworkViewModel model) { if (ModelState.IsValid) { Network network = db.Networks.Find(id); if (network == null) { return(HttpNotFound()); } network.ContactsNumber = model.ContactsNumber; network.PlatformType = model.PlatformType; db.Entry(network).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.EmployeeId = new SelectList(db.Employees, "Id", "FullName"); return(View(model)); }
public static void Init() { LocalisedContentLoader.FallBackLCID = 0; LocalisedContentLoader.SupportedLCIDs.Add(1033); LocalisedContentLoader.LoadContent("dev1_/js/NetworkViewConfig.js", 1033, delegate() { // Check the webresource parameters Dictionary <string, string> data = GetQueryStringData(); // Webresource accepts the root id and entity type name (etn) if (!data.ContainsKey("etn")) { data["etn"] = "account"; } NetworkViewModel vm = new NetworkViewModel(new Guid(data["id"]), data["etn"], GlobalSettings.GraphOptions); view = new NetworkView(vm); }); }
public void TestChildNodeParent() { NodeViewModel node = new NodeViewModel(); Assert.AreEqual(null, node.Parent); NetworkViewModel network = new NetworkViewModel(); network.Nodes.Add(node); Assert.AreEqual(network, node.Parent); network.Nodes.Remove(node); Assert.AreEqual(null, node.Parent); network.Nodes.Add(node); Assert.AreEqual(network, node.Parent); network.Nodes.Clear(); Assert.AreEqual(null, node.Parent); }
public NodeGrid() { //InitializeComponent(); FrameworkElementFactory factoryPanel = new FrameworkElementFactory(typeof(Canvas)); factoryPanel.SetValue(Canvas.IsItemsHostProperty, true); ItemsPanelTemplate template = new ItemsPanelTemplate(); template.VisualTree = factoryPanel; this.ItemsPanel = template; GridConnectionColor = new SolidColorBrush(Color.FromRgb(150, 150, 150)); previousDrawTime = DateTime.Now; gridSize = defaultGridSize; GridOffset = defaultGridOffset; var paintTimer = new Timer { AutoReset = true, Interval = 1000.0 / 60 }; paintTimer.Elapsed += (o, e) => Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)(InvalidateVisual)); paintTimer.Start(); this.MouseMove += OnMouseMove; this.MouseDown += OnMouseDown; this.MouseUp += OnMouseUp; this.MouseWheel += OnMouseWheel; NodeViewModel.GlobalScaleDelta = 0; if (networkView == null) { networkView = SimpleIoc.Default.GetInstance <NetworkViewModel>(); } elapsedTime = 0; }
public ActionResult AddNetworkPartial(NetworkViewModel model) { if (ModelState.IsValid) { var network = new Network { PlatformType = model.PlatformType, ContactsNumber = model.ContactsNumber, EmployeeId = model.EmployeeId, }; db.Networks.Add(network); db.SaveChanges(); return(PartialView()); } return(PartialView(model)); }
public void NodeOnSuccessReturnsNode() { //arrange var nodeId = 1; var networkName = "networkname"; var networkUrl = "networkurl"; var nodeUrl = "nodeurl"; var nodeRecord = new NodeRecord { Id = nodeId }; var nodeService = new Mock <INodeService>(); nodeService.Setup(s => s.GetNodeByUrl(It.Is <string>(url => url == nodeUrl), It.Is <string>(url => url == networkUrl))).Returns(nodeRecord); var node = new NodeViewModel { Id = nodeId }; var dictionary = new Dictionary <int, NodeViewModel> { { nodeId, node } }; var network = new NetworkViewModel { Url = networkUrl, Name = networkName, Nodes = dictionary }; var networkService = new Mock <INetworkService>(); networkService.Setup(s => s.GetNetworkByUrl(It.Is <string>(url => url == networkUrl))).Returns(network); var controller = new NetworkController(networkService.Object, nodeService.Object); //act var result = (ViewResult)controller.Node(networkUrl, nodeUrl); var nodeResult = (NodeViewModel)result.Model; Assert.AreEqual("Node", result.ViewName); Assert.AreEqual(networkName, nodeResult.NetworkName); Assert.AreEqual(networkUrl, nodeResult.NetworkUrl); }
private void SetupContextMenuViewModels() { AddNodeMenuVM.Network = NetworkViewModel; AddNodeMenuVM.AddNodeTypes(nodeTemplates); AddNodeMenuVM.Commands.Add(new LabeledCommand { Label = "Collapse All", Command = CollapseAllCommand }); AddNodeForPendingConnectionMenuVM.Network = NetworkViewModel; AddNodeForPendingConnectionMenuVM.AddNodeTypes(nodeTemplates); NetworkViewModel.OnPendingConnectionDropped = () => { var pendingCon = NetworkViewModel.PendingConnection; NetworkViewModel.RemovePendingConnection(); AddNodeForPendingConnectionMenuVM.SearchQuery = ""; AddNodeForPendingConnectionMenuVM.ShowAddNodeForPendingConnectionMenu(pendingCon); }; }
public void TestCreatePendingConnection() { TestableInput input = new TestableInput(); var node = new NodeViewModel(); node.Inputs.Add(input); NetworkViewModel network = new NetworkViewModel { Nodes = { node } }; Assert.AreEqual(null, network.PendingConnection); input.CreatePendingConnection_public(); Assert.AreEqual(input, network.PendingConnection.Input); Assert.IsTrue(network.PendingConnection.InputIsLocked); }
public void MainTabbed_Should_ReturnTabPages() { // Arrange base.Setup(); // -- Suburb var mockSuburb = new Mock <ISuburbService>(); mockSuburb.Setup(g => g.Get()).Returns(Task.FromResult(new List <Suburb>())); Ioc.RegisterSingleton <ISuburbService>(mockSuburb.Object); // -- Network var mockNetwork = new Mock <INetworkAPIService>(); Ioc.RegisterSingleton <INetworkAPIService>(mockNetwork.Object); // Act NetworkViewModel view = new NetworkViewModel(mockNetwork.Object); // Assert Assert.True(String.IsNullOrEmpty(view.APIResult)); }
public void Layout(NetworkViewModel network) { NodeLayout = null; NodeColumns.Clear(); m_nodeColumnLookup.Clear(); m_inputLookup.Clear(); m_outputLookup.Clear(); m_levelWidth.Clear(); NodeViewModel first = network?.Nodes?.Items.FirstOrDefault(); if (first == null) { return; } BuildNodeLevels(network, first); NodeLayout = LayoutNodesInNetwork(network, first); RepositionNodes(NodeLayout, first); }
public MainWindow() { InitializeComponent(); var myBinding = new Binding("Index") { Source = this, Path = new PropertyPath("Index") }; label.SetBinding(Label.ContentProperty, myBinding); var deserialized = (hkpackfileT) new XmlSerializer(typeof(hkpackfileT)).Deserialize(new FileStream(@"D:\Program Files (x86)\Steam\steamapps\common\DARK SOULS III\Game\chr\c0000-behbnd-dcx\Action\c0000\Export\Behaviors\c0000.xml", FileMode.Open)); parsed = HksDataParser.Parse(deserialized); Console.WriteLine(parsed.cStateMachines.Count()); //Create a new viewmodel for the NetworkView network = new NetworkViewModel(); UpdateNetwork(); ////Create the node for the first node, set its name and add it to the network. //var node1 = new NodeViewModel(); //node1.Name = "Node 1"; //network.Nodes.Add(node1); ////Create the viewmodel for the input on the first node, set its name and add it to the node. //var node1Input = new NodeInputViewModel(); //node1Input.Name = "Node 1 input"; //node1.Inputs.Add(node1Input); ////Create the second node viewmodel, set its name, add it to the network and add an output in a similar fashion. //var node2 = new NodeViewModel(); //node2.Name = "Node 2"; //network.Nodes.Add(node2); //var node2Output = new NodeOutputViewModel(); //node2Output.Name = "Node 2 output"; //node2.Outputs.Add(node2Output); //Assign the viewmodel to the view. HksView.ViewModel = network; }
public void TestCreatePendingConnection() { TestableOutput output = new TestableOutput(); NetworkViewModel network = new NetworkViewModel { Nodes = { new NodeViewModel { Outputs ={ output } } } }; Assert.AreEqual(null, network.PendingConnection); output.CreatePendingConnection_public(); Assert.AreEqual(output, network.PendingConnection.Output); Assert.IsTrue(network.PendingConnection.OutputIsLocked); }
public void GetNodesOnSuccessReturnsNetwork() { //arrange var url = "url"; var network = new NetworkViewModel { Url = url }; var service = new Mock <INetworkService>(); service.Setup(s => s.GetNetworkByUrl(It.Is <string>(u => u == url))).Returns(network); var controller = new NetworkController(service.Object, null); //act var response = (ViewResult)controller.Nodes(url); var result = response.Model as NetworkViewModel; //assert Assert.AreEqual(url, result.Url); }
public VisualEditorView() : base(DataWindowMode.Custom) { InitializeComponent(); //Create a new viewmodel for the NetworkView var network = new NetworkViewModel(); //Create the node for the first node, set its name and add it to the network. var node1 = new HelloWorldNode(); node1.Name = "Node 1"; network.Nodes.Add(node1); //Create the viewmodel for the input on the first node, set its name and add it to the node. var node1Input = new ValueNodeInputViewModel <string>(); node1Input.Name = "Node 1 input"; node1.Inputs.Add(node1Input); node1Input.ValueChanged.Subscribe(newValue => { Console.WriteLine(newValue); }); //Create the second node viewmodel, set its name, add it to the network and add an output in a similar fashion. var node2 = new NodeViewModel(); node2.Name = "Node 2"; network.Nodes.Add(node2); var node2Output = new ValueNodeOutputViewModel <string>(); node2Output.Name = "Node 2 output"; node2.Outputs.Add(node2Output); node2Output.Value = Observable.Return("Example string"); //Assign the viewmodel to the view. networkView.ViewModel = network; }
private void CreateBeginNode(NetworkViewModel model) { // Create the begin node for the actor and add it to the network. BeginNodeViewModel begin_node = new BeginNodeViewModel(Cut.ParentActor); model.Nodes.Edit(x => x.Add(begin_node)); if (Cut.IsBlocked()) { CreateBlockingNode(model, begin_node); } else { ConnectionViewModel connection = new ConnectionViewModel( model, Inputs.Items.First(), begin_node.Outputs.Items.First()); // Add the connection to the node network. model.Connections.Edit(x => x.Add(connection)); } }