public void TestListInputDisconnect()
        {
            using (TestUtils.WithScheduler(ImmediateScheduler.Instance))
            {
                var           input1 = new ValueListNodeInputViewModel <string>();
                NodeViewModel node1  = new NodeViewModel
                {
                    Inputs = { input1 }
                };

                var output2 = new ValueNodeOutputViewModel <string>
                {
                    Value = Observable.Return("Test")
                };
                NodeViewModel node2 = new NodeViewModel
                {
                    Outputs = { output2 }
                };

                NetworkViewModel network = new NetworkViewModel();

                network.Nodes.Add(node1);
                network.Nodes.Add(node2);

                var conn1 = network.ConnectionFactory(input1, output2);
                network.Connections.Add(conn1);

                CollectionAssert.AreEqual(new[] { "Test" }, input1.Values.ToArray());

                network.Connections.Remove(conn1);

                CollectionAssert.AreEqual(new string[0], input1.Values.ToArray());
            }
        }
        public void TestListInputDisconnect()
        {
            var           input1 = new ValueListNodeInputViewModel <string>();
            NodeViewModel node1  = new NodeViewModel();

            node1.Inputs.Add(input1);

            var output2 = new ValueNodeOutputViewModel <string>
            {
                Value = Observable.Return("Test")
            };
            NodeViewModel node2 = new NodeViewModel();

            node2.Outputs.Add(output2);

            NetworkViewModel network = new NetworkViewModel();

            network.Nodes.Add(node1);
            network.Nodes.Add(node2);

            var conn1 = network.ConnectionFactory(input1, output2);

            network.Connections.Add(conn1);

            CollectionAssert.AreEqual(new[] { "Test" }, input1.Values.Items.AsArray());

            network.Connections.Remove(conn1);

            CollectionAssert.AreEqual(new string[0], input1.Values.Items.AsArray());
        }
        public DialogueResponseNode() : base("Response", null)
        {
            SpeechInput = new ValueNodeInputViewModel <string>()
            {
                Name = "Line of Speech"
            };

            PromptsInput = new ValueListNodeInputViewModel <DialoguePrompt>()
            {
                Name = "Prompts"
            };

            Order = new ValueNodeInputViewModel <long>()
            {
                Name = "Response Order"
            };

            ConditionLua = new ValueNodeInputViewModel <string>()
            {
                Name = "Lua Condition"
            };

            ActionLua = new ValueNodeInputViewModel <string>()
            {
                Name = "Lua Action"
            };

            Title = new ValueNodeInputViewModel <string>()
            {
                Name = "Prompt Name"
            };

            FinalPrompt = new ValueNodeOutputViewModel <DialogueResponse>();

            this.Inputs.Add(SpeechInput);
            this.Inputs.Add(PromptsInput);
            this.Inputs.Add(Order);
            this.Inputs.Add(ConditionLua);
            this.Inputs.Add(ActionLua);
            this.Inputs.Add(Title);
            this.Outputs.Add(FinalPrompt);
            this.WhenAnyObservable(vm => vm.SpeechInput.Changed, vm => vm.Title.Changed, vm => vm.PromptsInput.Changed, vm => vm.Order.Changed, vm => vm.ActionLua.Changed, vm => vm.ConditionLua.Changed).Subscribe(ip =>
            {
                FinalPrompt.Value = Observable.Return(new DialogueResponse()
                {
                    Speech       = SpeechInput.Value,
                    Title        = Title.Value,
                    Prompts      = new ObservableCollection <DialoguePrompt>(PromptsInput.Values.Items.ToList()),
                    Order        = (int)Order.Value,
                    ActionLua    = ActionLua.Value,
                    ConditionLua = ConditionLua.Value,
                });
                RodskaApp app     = (RodskaApp)System.Windows.Application.Current;
                MainWindow window = (MainWindow)app.MainWindow;
                window.SignalDocumentChanged(InputDocument);
            });
        }
Example #4
0
        public ButtonEventNode() : base(NodeType.EventNode)
        {
            this.Name = "Button Events";

            OnClickFlow = new CodeGenListInputViewModel <IStatement>(PortType.Execution)
            {
                Name = "On Click"
            };

            this.Inputs.Add(OnClickFlow);
        }
Example #5
0
        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 DialogueNode(Dialogue value) : base("Conversation", value)
        {
            InitialPrompts = new ValueListNodeInputViewModel <DialoguePrompt>()
            {
                Name = "Initial Prompts"
            };

            Prompts = new ValueListNodeInputViewModel <DialoguePrompt>()
            {
                Name = "Prompts"
            };

            Responses = new ValueListNodeInputViewModel <DialogueResponse>()
            {
                Name = "Responses"
            };

            Inputs.Add(InitialPrompts);
            Inputs.Add(Prompts);
            Inputs.Add(Responses);


            Output = new ValueNodeOutputViewModel <Dialogue>()
            {
                Name       = "Final Result",
                Visibility = NodeNetwork.ViewModels.EndpointVisibility.AlwaysHidden,
            };
            this.WhenAnyObservable(vm => vm.InitialPrompts.Changed, vm => vm.Prompts.Changed, vm => vm.Responses.Changed).Subscribe(ip =>
            {
                Dialogue dialogue       = InputDocument as Dialogue;
                dialogue.Prompts        = new ObservableCollection <DialoguePrompt>(Prompts.Values.Items.ToList());
                dialogue.Responses      = new ObservableCollection <DialogueResponse>(Responses.Values.Items.ToList());
                dialogue.InitialPrompts = new ObservableCollection <DialoguePrompt>(InitialPrompts.Values.Items.ToList());
                InputDocument           = dialogue;
                Output.Value            = Observable.Return(dialogue);
            });
            RodskaApp  app    = (RodskaApp)RodskaApp.Current;
            MainWindow window = (MainWindow)app.MainWindow;

            window.DocumentChanged += Window_DocumentChanged;
            CanBeRemovedByUser      = false;
        }
 public override ValueNodeOutputViewModel <IObservableList <T> > CreateCompatibleOutput <T>(ValueListNodeInputViewModel <T> input)
 {
     return(new CodeGenOutputViewModel <IObservableList <T> >(((CodeGenPortViewModel)input.Port).PortType)
     {
         Editor = new GroupEndpointEditorViewModel <IObservableList <T> >(this)
     });
 }
Example #8
0
 public virtual ValueNodeOutputViewModel <IObservableList <T> > CreateCompatibleOutput <T>(ValueListNodeInputViewModel <T> input)
 {
     return(new ValueNodeOutputViewModel <IObservableList <T> >());
 }
Example #9
0
 protected virtual void BindOutputToInput <T>(ValueNodeOutputViewModel <IObservableList <T> > output, ValueListNodeInputViewModel <T> input)
 {
     BindEndpointProperties(output, input);
     output.Value = Observable.Return(input.Values);
     _outputInputMapping.Add(output, input);
 }
Example #10
0
        public DialoguePromptNode() : base("Prompt", null)
        {
            SpeechInput = new ValueNodeInputViewModel <string>()
            {
                Name = "Line of Speech"
            };

            ChainedPromptsInput = new ValueListNodeInputViewModel <DialoguePrompt>()
            {
                Name = "Chained Prompts"
            };

            Priority = new ValueNodeInputViewModel <long>()
            {
                Name = "Prompt Priority"
            };

            ConditionLua = new ValueNodeInputViewModel <string>()
            {
                Name = "Lua Condition"
            };

            ActionLua = new ValueNodeInputViewModel <string>()
            {
                Name = "Lua Action"
            };

            Title = new ValueNodeInputViewModel <string>()
            {
                Name = "Prompt Name"
            };

            Responses = new ValueListNodeInputViewModel <DialogueResponse>()
            {
                Name = "Responses"
            };

            FinalPrompt = new ValueNodeOutputViewModel <DialoguePrompt>()
            {
                Name = "Resulting Prompt"
            };
            this.Inputs.Add(SpeechInput);
            this.Inputs.Add(ChainedPromptsInput);
            this.Inputs.Add(Priority);
            this.Inputs.Add(ConditionLua);
            this.Inputs.Add(ActionLua);
            this.Inputs.Add(Title);
            this.WhenAnyObservable(vm => vm.SpeechInput.Changed, vm => vm.Title.Changed, vm => vm.ChainedPromptsInput.Changed, vm => vm.Priority.Changed, vm => vm.Responses.Changed, vm => vm.ActionLua.Changed, vm => vm.ConditionLua.Changed).Subscribe(ip =>
            {
                InputDocument = new DialoguePrompt()
                {
                    Speech         = SpeechInput.Value,
                    Title          = Title.Value,
                    ChainedPrompts = new ObservableCollection <DialoguePrompt>(ChainedPromptsInput.Values.Items.ToList()),
                    Priority       = (int)Priority.Value,
                    Responses      = new ObservableCollection <DialogueResponse>(Responses.Values.Items.ToList()),
                    ActionLua      = ActionLua.Value,
                    ConditionLua   = ConditionLua.Value,
                };
                FinalPrompt.Value = Observable.Return(InputDocument as DialoguePrompt);
                RodskaApp app     = (RodskaApp)RodskaApp.Current;
                MainWindow window = (MainWindow)app.MainWindow;
                window.SignalDocumentChanged(FinalPrompt.Value.Wait());
            });

            this.Inputs.Add(Responses);
            this.Outputs.Add(FinalPrompt);
        }