private void DispatchDiagramChangeEvent(DiagramEventBase diagramEvent) { switch (diagramEvent) { case DiagramNodeAddedEvent diagramNodeAddedEvent: AddNode(diagramNodeAddedEvent.DiagramNode); break; case DiagramNodeRemovedEvent diagramNodeRemovedEvent: RemoveNode(diagramNodeRemovedEvent.DiagramNode); break; case DiagramConnectorAddedEvent diagramConnectorAddedEvent: AddConnector(diagramConnectorAddedEvent.DiagramConnector); break; case DiagramConnectorRemovedEvent diagramConnectorRemovedEvent: RemoveConnector(diagramConnectorRemovedEvent.DiagramConnector); break; case DiagramClearedEvent _: ClearViewport(); break; } }
private void OnDiagramChanged(DiagramEventBase diagramEvent) { if (diagramEvent is DiagramNodeAddedEvent diagramNodeAddedEvent) { RemoveModelNode(diagramNodeAddedEvent.NewNode.Id); } }
private void OnDiagramChanged(DiagramEventBase diagramEvent) { switch (diagramEvent) { case DiagramNodeAddedEvent diagramNodeAddedEvent: _incrementalLayoutEngine.EnqueueDiagramAction(new AddDiagramNodeAction(diagramNodeAddedEvent.NewNode)); break; case DiagramConnectorAddedEvent diagramConnectorAddedEvent: _incrementalLayoutEngine.EnqueueDiagramAction(new AddDiagramConnectorAction(diagramConnectorAddedEvent.NewConnector)); break; case DiagramNodeSizeChangedEvent diagramNodeSizeChangedEvent: var diagramNode = diagramNodeSizeChangedEvent.NewNode; _incrementalLayoutEngine.EnqueueDiagramAction(new ResizeDiagramNodeAction(diagramNode, diagramNode.Size)); break; case DiagramNodeRemovedEvent diagramNodeRemovedEvent: _incrementalLayoutEngine.EnqueueDiagramAction(new RemoveDiagramNodeAction(diagramNodeRemovedEvent.OldNode)); break; case DiagramConnectorRemovedEvent diagramConnectorRemovedEvent: _incrementalLayoutEngine.EnqueueDiagramAction(new RemoveDiagramConnectorAction(diagramConnectorRemovedEvent.OldConnector)); break; case DiagramClearedEvent _: _incrementalLayoutEngine.EnqueueDiagramAction(new ClearDiagramAction()); break; } }
private void OnDiagramChanged(DiagramEventBase diagramEvent) { switch (diagramEvent) { case DiagramNodeAddedEvent diagramNodeAddedEvent: var addedDiagramNode = diagramNodeAddedEvent.DiagramNode; var addDiagramNodeAction = new AddDiagramNodeAction(addedDiagramNode); if (addedDiagramNode is IContainerDiagramNode containerDiagramNode) { var incrementalLayoutEngine = CreateLayoutEngine(DiagramService); _layoutEnginesPerNodes.Add(containerDiagramNode.Id, incrementalLayoutEngine); } var layoutEngineForAddedDiagramNode = GetLayoutEngine(addedDiagramNode); layoutEngineForAddedDiagramNode.EnqueueDiagramAction(addDiagramNodeAction); _modelNodeToContainingLayoutEngine.Add(addedDiagramNode.Id, layoutEngineForAddedDiagramNode); break; case DiagramConnectorAddedEvent diagramConnectorAddedEvent: var addedDiagramConnector = diagramConnectorAddedEvent.DiagramConnector; var addDiagramConnectorAction = new AddDiagramConnectorAction(addedDiagramConnector); var layoutEngineForAddedDiagramConnector = GetLayoutEngine(addedDiagramConnector); if (layoutEngineForAddedDiagramConnector != null) { layoutEngineForAddedDiagramConnector.EnqueueDiagramAction(addDiagramConnectorAction); _modelRelationshipToContainingLayoutEngine.Add(addedDiagramConnector.Id, layoutEngineForAddedDiagramConnector); } break; case DiagramNodeSizeChangedEvent diagramNodeSizeChangedEvent: var resizedDiagramNode = diagramNodeSizeChangedEvent.DiagramNode; var resizeDiagramNodeAction = new ResizeDiagramNodeAction(resizedDiagramNode, resizedDiagramNode.Size); _modelNodeToContainingLayoutEngine[resizedDiagramNode.Id].EnqueueDiagramAction(resizeDiagramNodeAction); break; case DiagramNodeRemovedEvent diagramNodeRemovedEvent: var removedDiagramNode = diagramNodeRemovedEvent.DiagramNode; var removeDiagramNodeAction = new RemoveDiagramNodeAction(removedDiagramNode); _modelNodeToContainingLayoutEngine[removedDiagramNode.Id].EnqueueDiagramAction(removeDiagramNodeAction); break; case DiagramConnectorRemovedEvent diagramConnectorRemovedEvent: var removedDiagramConnector = diagramConnectorRemovedEvent.DiagramConnector; var removeDiagramConnectorAction = new RemoveDiagramConnectorAction(removedDiagramConnector); _modelRelationshipToContainingLayoutEngine[removedDiagramConnector.Id].EnqueueDiagramAction(removeDiagramConnectorAction); break; case DiagramClearedEvent _: foreach (var incrementalLayoutEngine in _layoutEnginesPerNodes.Values) { incrementalLayoutEngine.Dispose(); } _layoutEnginesPerNodes.Clear(); _rootLayoutEngine.EnqueueDiagramAction(new ClearDiagramAction()); break; } }
private void DispatchDiagramChangeEvent(DiagramEventBase diagramEvent) { switch (diagramEvent) { case DiagramNodeAddedEvent nodeAddedEvent: AddNode(nodeAddedEvent.NewNode, nodeAddedEvent.NewNode.ParentNodeId.ToNullable()); break; case DiagramNodeRemovedEvent nodeRemovedEvent: RemoveNode(nodeRemovedEvent.OldNode); break; case DiagramConnectorAddedEvent connectorAddedEvent: AddConnector(connectorAddedEvent.NewConnector); break; case DiagramConnectorRemovedEvent connectorRemovedEvent: RemoveConnector(connectorRemovedEvent.OldConnector); break; case DiagramClearedEvent _: ClearViewport(); break; } }
private void OnDiagramChanged(DiagramEventBase diagramEvent) { var model = ModelService.Model; var diagram = diagramEvent.NewDiagram; switch (diagramEvent) { case DiagramNodeAddedEvent diagramNodeAddedEvent: var modelNode = diagramNodeAddedEvent.NewNode.ModelNode; ShowModelRelationshipsIfBothEndsAreVisible(modelNode, model, diagram); break; case DiagramNodeRemovedEvent _: // TODO: optimize: should check only surrounding nodes of the deleted one (not all in diagram) foreach (var diagramNode in diagram.Nodes) { ShowModelRelationshipsIfBothEndsAreVisible(diagramNode.ModelNode, model, diagram); } break; case DiagramConnectorAddedEvent _: HideRedundantConnectors(diagram); break; // DiagramConnectorRemovedEvent is not handled // because that would put back removed connectors immediately // (because nodes are removed after connectors) } }
private void OnDiagramChanged(DiagramEventBase diagramEvent) { if (diagramEvent is DiagramConnectorRouteChangedEvent diagramConnectorRouteChangedEvent && DiagramConnectorIdEqualityComparer.Instance.Equals(diagramConnectorRouteChangedEvent.NewConnector, DiagramConnector)) { DiagramShape = diagramConnectorRouteChangedEvent.NewConnector; RoutePoints = diagramConnectorRouteChangedEvent.NewConnector.Route.ToWpf(); } }
private void DispatchDiagramEvent(DiagramEventBase diagramEvent) { switch (diagramEvent) { case DiagramNodeRectChangedEvent diagramNodeRectChangedEvent: FollowDiagramNode(diagramNodeRectChangedEvent.NewNode); break; } }
protected virtual void OnDiagramChanged(DiagramEventBase diagramEvent) { if (diagramEvent is DiagramNodeChangedEventBase diagramNodeChangedEvent && DiagramNodeIdEqualityComparer.Instance.Equals(diagramNodeChangedEvent.DiagramNode, DiagramNode)) { DiagramShape = diagramNodeChangedEvent.DiagramNode; PopulateFromDiagramNode(diagramNodeChangedEvent.DiagramNode); } }
private void OnDiagramChanged(DiagramEventBase diagramEvent) { switch (diagramEvent) { case DiagramNodeAddedEvent diagramNodeAddedEvent: RoslynModelService.ExtendModelWithRelatedNodes(diagramNodeAddedEvent.DiagramNode.ModelNode, recursive: false); break; } }
private void OnDiagramChangedAsync(DiagramEventBase diagramEvent) { switch (diagramEvent) { case DiagramNodeAddedEvent diagramNodeAddedEvent: // It's a fire-and-forget async call, no need to await. var task = RoslynModelService.ExtendModelWithRelatedNodesAsync(diagramNodeAddedEvent.DiagramNode.ModelNode, recursive: false); break; } }
private void OnDiagramChanged(DiagramEventBase diagramEvent) { lock (_diagramEventQueue) { Debug.WriteLine($"Event arrived: {diagramEvent}"); _diagramEventQueue.Enqueue(diagramEvent); } _diagramEventArrivedEvent.Set(); }
private void OnDiagramChanged(DiagramEventBase diagramEvent) { _lastDiagram = diagramEvent.NewDiagram; if (diagramEvent is DiagramClearedEvent) { HideAllWidgets(); } UpdateDiagramContentRect(diagramEvent.NewDiagram); }
private async Task OnDiagramChangedAsync(DiagramEventBase diagramEvent) { switch (diagramEvent) { case DiagramNodeAddedEvent diagramNodeAddedEvent: // It's a fire-and-forget async call, no need to await. // ReSharper disable once UnusedVariable await RoslynModelService.ExtendModelWithRelatedNodesAsync(diagramNodeAddedEvent.DiagramNode.ModelNode, recursive : false); break; } }
private void OnDiagramChanged([NotNull] DiagramEventBase diagramEvent) { switch (diagramEvent) { case DiagramNodeRectChangedEvent _: case DiagramConnectorRouteChangedEvent _: return; } var diagram = diagramEvent.NewDiagram; var diagramLayoutInfo = _layoutAlgorithm.Calculate(diagram); DiagramService.ApplyLayout(diagramLayoutInfo); }
private void DispatchDiagramEvent(DiagramEventBase diagramEvent) { switch (diagramEvent) { case DiagramNodeSizeChangedEvent diagramNodeSizeChangedEvent: FollowDiagramNode(diagramNodeSizeChangedEvent.DiagramNode); break; case DiagramNodePositionChangedEvent diagramNodePositionChangedEvent: FollowDiagramNode(diagramNodePositionChangedEvent.DiagramNode); break; } }
private DiagramEventBase GetLastEventFromQueue() { DiagramEventBase lastEvent = null; lock (_diagramEventQueue) { while (_diagramEventQueue.Any()) { lastEvent = _diagramEventQueue.Dequeue(); } } return(lastEvent); }
private void OnDiagramChanged(DiagramEventBase diagramEvent) { _hostUiServices.Run(async() => await OnDiagramChangedAsync(diagramEvent)); }
private void OnDiagramChanged(DiagramEventBase diagramEvent) { _lastDiagram = diagramEvent.NewDiagram; UpdateEnabledState(); }
private void OnDiagramChanged(DiagramEventBase diagramEvent) { _diagramContentRect = diagramEvent.NewDiagram.Rect.ToWpf(); }
private void OnDiagramChanged(DiagramEventBase diagramEvent) { EnsureUiThread(() => DispatchDiagramEvent(diagramEvent)); }
private void OnDiagramChanged(DiagramEventBase diagramEvent) { _lastDiagram = diagramEvent.NewDiagram; UpdateVisibility(); }
private void OnDiagramChanged(DiagramEventBase diagramEvent) { // All diagram-induced view model manipulation must occur on the UI thread to avoid certain race conditions. // (E.g. avoid the case when creating a connector view model precedes the creation of its source and target node view models.) EnsureUiThread(() => DispatchDiagramChangeEvent(diagramEvent)); }