Beispiel #1
0
        public MainWindowDataContext()
        {
            Nodes       = new ObservableCollection <INodeDataContext>();
            Connections = new ObservableCollection <IConnectionDataContext>();

            var node1 = new PresetNodeViewModel()
            {
                OutputPlugs = new ObservableCollection <IPlugDataContext>
                {
                    new PresentPlugViewModel(),
                }
            };

            var node2 = new PresetNodeViewModel()
            {
                X          = 150,
                InputPlugs = new ObservableCollection <IPlugDataContext>
                {
                    new PresentPlugViewModel(),
                },
            };

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

            var connection = new PresetConnectionViewModel()
            {
                SourcePlug = node1.OutputPlugs[0],
                DestPlug   = node2.InputPlugs[0],
            };

            Connections.Add(connection);
        }
        private void CreateNodes()
        {
            // 実装サンプル
            var node1 = new PresetNodeViewModel()
            {
                X          = 0,
                Y          = 50,
                InputPlugs = new ObservableCollection <IPlugDataContext>
                {
                    new PresentPlugViewModel(),
                    new PresentPlugViewModel(),
                },
                OutputPlugs = new ObservableCollection <IPlugDataContext>
                {
                    new PresentPlugViewModel(),
                    new PresentPlugViewModel(),
                }
            };
            var node2 = new PresetNodeViewModel()
            {
                X          = 100,
                Y          = 500,
                InputPlugs = new ObservableCollection <IPlugDataContext>
                {
                    new PresentPlugViewModel(),
                    new PresentPlugViewModel(),
                },
                OutputPlugs = new ObservableCollection <IPlugDataContext>
                {
                    new PresentPlugViewModel(),
                    new PresentPlugViewModel(),
                }
            };
            var node3 = new PresetNodeViewModel()
            {
                X          = 200,
                Y          = 50,
                InputPlugs = new ObservableCollection <IPlugDataContext>
                {
                    new PresentPlugViewModel(),
                    new PresentPlugViewModel(),
                },
                OutputPlugs = new ObservableCollection <IPlugDataContext>
                {
                    new PresentPlugViewModel(),
                    new PresentPlugViewModel(),
                }
            };

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

            var connection = new PresetConnectionViewModel()
            {
                SourcePlug = node1.OutputPlugs.First(),
                DestPlug   = node3.InputPlugs.First(),
            };

            Connections.Add(connection);
        }