コード例 #1
0
        public static void ReloadSystemConfig()
        {
            bool wasRunning = Execution.IsOpen;

            Execution.CloseExecution();

            // purge all existing elements, nodes, and controllers (to try and clean up a bit).
            // might not actually matter, since we're going to make new Managers for them all
            // in a tick, but better safe than sorry.
            foreach (ElementNode cn in Nodes.ToArray())
            {
                Nodes.RemoveNode(cn, null, true);
            }
            foreach (OutputController oc in OutputControllers.ToArray())
            {
                OutputControllers.Remove(oc);
            }
            foreach (SmartOutputController smartOutputController in SmartOutputControllers.ToArray())
            {
                SmartOutputControllers.Remove(smartOutputController);
            }
            foreach (OutputPreview outputPreview in Previews.ToArray())
            {
                Previews.Remove(outputPreview);
            }

            LoadSystemConfig();

            if (wasRunning)
            {
                Execution.OpenExecution();
            }
        }
コード例 #2
0
        void Nodes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
        {
            switch (e.Action)
            {
            case NotifyCollectionChangedAction.Add:
                foreach (var item in e.NewItems)
                {
                    if (item != null && item is NodeModel)
                    {
                        var node = item as NodeModel;

                        var nodeViewModel = new NodeViewModel(node);
                        _nodes.Add(nodeViewModel);
                        Errors.Add(nodeViewModel.ErrorBubble);
                        Previews.Add(nodeViewModel.PreviewBubble);
                    }
                }
                break;

            case NotifyCollectionChangedAction.Reset:
                _nodes.Clear();
                Errors.Clear();
                Previews.Clear();
                break;

            case NotifyCollectionChangedAction.Remove:
                foreach (var item in e.OldItems)
                {
                    var           node          = item as NodeModel;
                    NodeViewModel nodeViewModel = _nodes.First(x => x.NodeLogic == item);
                    Previews.Remove(nodeViewModel.PreviewBubble);
                    Errors.Remove(nodeViewModel.ErrorBubble);
                    _nodes.Remove(nodeViewModel);
                }
                break;
            }
        }