public MainViewModel()
        {
            ButtonEventNode eventNode = new ButtonEventNode {
                CanBeRemovedByUser = false
            };

            Network.Nodes.Add(eventNode);

            //NodeList.AddNodeType(() => new ButtonEventNode());
            NodeList.AddNodeType(() => new ForLoopNode());
            NodeList.AddNodeType(() => new IntLiteralNode());
            NodeList.AddNodeType(() => new PrintNode());
            NodeList.AddNodeType(() => new TextLiteralNode());

            var codeObservable = eventNode.OnClickFlow.Values.Changed.Select(_ => new StatementSequence(eventNode.OnClickFlow.Values));

            codeObservable.BindTo(this, vm => vm.CodePreview.Code);
            codeObservable.BindTo(this, vm => vm.CodeSim.Code);

            ForceDirectedLayouter layouter = new ForceDirectedLayouter();
            var config = new Configuration
            {
                Network = Network,
            };

            AutoLayout          = ReactiveCommand.Create(() => layouter.Layout(config, 10000));
            StartAutoLayoutLive = ReactiveCommand.CreateFromObservable(() =>
                                                                       Observable.StartAsync(ct => layouter.LayoutAsync(config, ct)).TakeUntil(StopAutoLayoutLive)
                                                                       );
            StopAutoLayoutLive = ReactiveCommand.Create(() => { }, StartAutoLayoutLive.IsExecuting);
        }
示例#2
0
        public MainViewModel()
        {
            ButtonEventNode eventNode = new ButtonEventNode {
                CanBeRemovedByUser = false
            };

            Network.Nodes.Add(eventNode);

            //NodeList.AddNodeType(() => new ButtonEventNode());
            NodeList.AddNodeType(() => new ForLoopNode());
            NodeList.AddNodeType(() => new IntLiteralNode());
            NodeList.AddNodeType(() => new PrintNode());
            NodeList.AddNodeType(() => new TextLiteralNode());

            var codeObservable = eventNode.OnClickFlow.Values.Changed.Select(_ => new StatementSequence(eventNode.OnClickFlow.Values));

            codeObservable.BindTo(this, vm => vm.CodePreview.Code);
            codeObservable.BindTo(this, vm => vm.CodeSim.Code);
        }