void Nodes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (var item in e.NewItems) { if (item is NodeModel) { var node = item as NodeModel; var nodeViewModel = new NodeViewModel(this, node); nodeViewModel.SnapInputEvent += nodeViewModel_SnapInputEvent; _nodes.Add(nodeViewModel); Errors.Add(nodeViewModel.ErrorBubble); nodeViewModel.UpdateBubbleContent(); } } break; case NotifyCollectionChangedAction.Reset: _nodes.Clear(); Errors.Clear(); break; case NotifyCollectionChangedAction.Remove: foreach (var item in e.OldItems) { NodeViewModel nodeViewModel = _nodes.First(x => x.NodeLogic == item); Errors.Remove(nodeViewModel.ErrorBubble); _nodes.Remove(nodeViewModel); } break; } }
void Model_NodeAdded(NodeModel node) { var nodeViewModel = new NodeViewModel(this, node); nodeViewModel.SnapInputEvent += nodeViewModel_SnapInputEvent; nodeViewModel.NodeLogic.Modified += OnNodeModified; _nodes.Add(nodeViewModel); Errors.Add(nodeViewModel.ErrorBubble); nodeViewModel.UpdateBubbleContent(); PostNodeChangeActions(); }
void Nodes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (var item in e.NewItems) { if (item is NodeModel) { var node = item as NodeModel; var nodeViewModel = new NodeViewModel(this, node); nodeViewModel.SnapInputEvent += nodeViewModel_SnapInputEvent; nodeViewModel.NodeLogic.Modified += OnNodeModified; _nodes.Add(nodeViewModel); Errors.Add(nodeViewModel.ErrorBubble); nodeViewModel.UpdateBubbleContent(); } } break; case NotifyCollectionChangedAction.Reset: _nodes.Clear(); Errors.Clear(); break; case NotifyCollectionChangedAction.Remove: foreach (var item in e.OldItems) { NodeViewModel nodeViewModel = _nodes.First(x => x.NodeLogic == item); Errors.Remove(nodeViewModel.ErrorBubble); _nodes.Remove(nodeViewModel); } break; } if (RunSettingsViewModel == null) { return; } CheckAndSetPeriodicRunCapability(); }
void Nodes_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { switch (e.Action) { case NotifyCollectionChangedAction.Add: foreach (var item in e.NewItems) { if (item is NodeModel) { var node = item as NodeModel; var nodeViewModel = new NodeViewModel(this, node); nodeViewModel.SnapInputEvent +=nodeViewModel_SnapInputEvent; nodeViewModel.NodeLogic.Modified +=OnNodeModified; _nodes.Add(nodeViewModel); Errors.Add(nodeViewModel.ErrorBubble); nodeViewModel.UpdateBubbleContent(); } } break; case NotifyCollectionChangedAction.Reset: _nodes.Clear(); Errors.Clear(); break; case NotifyCollectionChangedAction.Remove: foreach (var item in e.OldItems) { NodeViewModel nodeViewModel = _nodes.First(x => x.NodeLogic == item); Errors.Remove(nodeViewModel.ErrorBubble); _nodes.Remove(nodeViewModel); } break; } if (RunSettingsViewModel == null) return; CheckAndSetPeriodicRunCapability(); }