private void OnDiagramChanged(DiagramEvent diagramEvent) { var diagram = diagramEvent.NewDiagram; var diagramLayoutInfo = _layoutAlgorithm.Calculate(diagram); DiagramService.ApplyLayout(diagramLayoutInfo); }
private void OnDiagramChanged(DiagramEvent diagramEvent) { foreach (var shapeEvent in diagramEvent.ShapeEvents) { ProcessShapeEvent(shapeEvent); } }
private void OnDiagramChanged(DiagramEvent diagramEvent) { foreach (var change in diagramEvent.ShapeEvents) { EnsureUiThread(() => DispatchDiagramEvent(change)); } }
public DiagramEvent UpdateModel(IModel newModel) { // TODO: remove all shapes whose model ID does not exist in the new model. var newDiagram = CreateInstance(newModel, _nodes, _connectors); return(DiagramEvent.Create(newDiagram)); }
private void OnDiagramChanged(DiagramEvent @event) { foreach (var change in @event.ShapeEvents) { ProcessDiagramChange(change); } }
public DiagramEvent Clear() { var newDiagram = Create(Model, _connectorTypeResolver); // Shall we raise node and connector removed events ? return(DiagramEvent.Create(newDiagram)); }
protected override bool PublishDiagramEvent(DiagramEvent diagramEvent, object args) { if (diagramEvent == DiagramEvent.SelectionBoundsChanged) { var mainContainer = this.SelectedItem as MainContainerShapeBase; UpdateHandlers(mainContainer); } return base.PublishDiagramEvent(diagramEvent, args); }
private void OnDiagramChanged(DiagramEvent @event) { var diagram = @event.NewDiagram; var model = diagram.Model; foreach (var change in @event.ShapeEvents) { ProcessDiagramChange(change, model, diagram); } }
public DiagramEvent Clear() { var itemEvents = Connectors.Select(i => new DiagramConnectorRemovedEvent(i)) .OfType <DiagramShapeEventBase>() .Concat(Nodes.Select(i => new DiagramNodeRemovedEvent(i))); var newDiagram = Create(Model, _connectorTypeResolver); return(DiagramEvent.Create(newDiagram, itemEvents)); }
private DiagramEvent CreateDiagramEvent(DiagramOperationResult diagramOperationResult) { if (!diagramOperationResult.Events.Any()) { return(DiagramEvent.None(this)); } var newDiagram = CreateInstance(Model, diagramOperationResult.Nodes, diagramOperationResult.Connectors); return(new DiagramEvent(newDiagram, diagramOperationResult.Events)); }
private void OnDiagramChanged(DiagramEvent @event) { _lastDiagram = @event.NewDiagram; if (_lastDiagram.IsEmpty) { HideAllWidgets(); } UpdateDiagramContentRect(@event.NewDiagram); }
public DiagramEvent ApplyLayout(GroupLayoutInfo diagramLayout) { var events = new List <DiagramShapeEventBase>(); var updatedNodes = new Dictionary <ModelNodeId, IDiagramNode>(); var updatedConnectors = new Dictionary <ModelRelationshipId, IDiagramConnector>(); ApplyLayoutRecursive(diagramLayout, events, updatedNodes, updatedConnectors); var newDiagram = CreateInstance(Model, _nodes.SetItems(updatedNodes), _connectors.SetItems(updatedConnectors)); return(DiagramEvent.Create(newDiagram, events)); }
private void OnDiagramChanged(DiagramEvent diagramEvent) { if (diagramEvent.ShapeEvents.All(i => !IsLayoutTriggeringChange(i))) { return; } var diagram = diagramEvent.NewDiagram; var diagramLayoutInfo = _layoutAlgorithm.Calculate(diagram); DiagramService.ApplyLayout(diagramLayoutInfo); }
private void OnDiagramChanged(DiagramEvent @event) { if (@event.NewDiagram.IsEmpty) { ClearViewport(); return; } foreach (var diagramChange in @event.ShapeEvents) { // 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(diagramChange)); } }
public DiagramEvent UpdateConnectorRoute(ModelRelationshipId relationshipId, Route newRoute) { var maybeDiagramConnector = TryGetConnector(relationshipId); if (!maybeDiagramConnector.HasValue) { throw new InvalidOperationException($"Connector {relationshipId} does not exist."); } var oldConnector = maybeDiagramConnector.Value; var newConnector = oldConnector.WithRoute(newRoute); var newDiagram = CreateInstance(Model, _nodes, _connectors.SetItem(relationshipId, newConnector)); return(DiagramEvent.Create(newDiagram, new DiagramConnectorRouteChangedEvent(oldConnector, newConnector))); }
private async Task OnDiagramChangedAsync(DiagramEvent diagramEvent) { foreach (var shapeEvent in diagramEvent.ShapeEvents) { switch (shapeEvent) { case DiagramNodeAddedEvent diagramNodeAddedEvent: await ExtendModelNodeAsync(diagramNodeAddedEvent.NewNode.ModelNode); break; case DiagramNodeChangedEvent diagramNodeChangedEvent when diagramNodeChangedEvent.ChangedMember == DiagramNodeMember.ModelNode: await ExtendModelNodeAsync(diagramNodeChangedEvent.NewNode.ModelNode); break; } } }
private DiagramEvent UpdateNodeCore( ModelNodeId nodeId, [NotNull] Func <IDiagramNode, IDiagramNode> nodeMutatorFunc, [NotNull] Func <IDiagramNode, IDiagramNode, DiagramNodeChangedEvent> nodeChangedEventFunc) { var maybeDiagramNode = TryGetNode(nodeId); if (!maybeDiagramNode.HasValue) { return(DiagramEvent.None(this)); } var oldNode = maybeDiagramNode.Value; var newNode = nodeMutatorFunc(oldNode); var newDiagram = CreateInstance(Model, _nodes.SetItem(newNode.Id, newNode), _connectors); var diagramNodeChangedEvent = nodeChangedEventFunc(oldNode, newNode); return(DiagramEvent.Create(newDiagram, diagramNodeChangedEvent)); }
private DiagramEvent UpdateNode( ModelNodeId nodeId, [NotNull] Func <IDiagramNode, IDiagramNode> nodeMutatorFunc, [NotNull] Func <IDiagramNode, IDiagramNode, DiagramNodeChangedEvent> nodeChangedEventFunc) { var maybeDiagramNode = TryGetNode(nodeId); if (!maybeDiagramNode.HasValue) { throw new InvalidOperationException($"Trying to update {nodeId} but it does not exist."); } var oldNode = maybeDiagramNode.Value; var newNode = nodeMutatorFunc(oldNode); var newDiagram = CreateInstance(Model, _nodes.SetItem(newNode.Id, newNode), _connectors); var diagramNodeChangedEvent = nodeChangedEventFunc(oldNode, newNode); return(DiagramEvent.Create(newDiagram, diagramNodeChangedEvent)); }
//public IEnumerable<IDiagramNode> GetAdjacentNodes(ModelNodeId id, DirectedModelRelationshipType? directedModelRelationshipType = null) //{ // IEnumerable<IDiagramNode> result; // if (directedModelRelationshipType != null) // { // result = _allShapesGraph.GetAdjacentVertices( // id, // directedModelRelationshipType.Value.Direction, // e => e.ModelRelationship.Stereotype == directedModelRelationshipType.Value.Stereotype); // } // else // { // result = _allShapesGraph.GetAdjacentVertices(id, EdgeDirection.In) // .Union(_allShapesGraph.GetAdjacentVertices(id, EdgeDirection.Out)); // } // return result; //} public DiagramEvent AddNode(ModelNodeId nodeId, ModelNodeId?parentNodeId = null) { var maybeDiagramNode = TryGetNode(nodeId); if (maybeDiagramNode.HasValue) { return(DiagramEvent.None(this)); } var maybeModelNode = Model.TryGetNode(nodeId); if (!maybeModelNode.HasValue) { throw new Exception($"Node {nodeId} not found in model."); } var newNode = CreateNode(maybeModelNode.Value).WithParentNodeId(parentNodeId); var newDiagram = CreateInstance(Model, _nodes.Add(newNode.Id, newNode), _connectors); return(DiagramEvent.Create(newDiagram, new DiagramNodeAddedEvent(newNode))); }
public DiagramEvent AddConnector(ModelRelationshipId relationshipId) { var maybeConnector = TryGetConnector(relationshipId); if (maybeConnector.HasValue) { return(DiagramEvent.None(this)); } var maybeRelationship = Model.TryGetRelationship(relationshipId); if (!maybeRelationship.HasValue) { throw new InvalidOperationException($"Relationship {relationshipId} does not exist."); } var newConnector = CreateConnector(maybeRelationship.Value); var newDiagram = CreateInstance(Model, _nodes, _connectors.Add(newConnector.Id, newConnector)); return(DiagramEvent.Create(newDiagram, new DiagramConnectorAddedEvent(newConnector))); }
private void OnDiagramChanged(DiagramEvent @event) { _diagramContentRect = @event.NewDiagram.Rect.ToWpf(); }
private void OnDiagramChanged(DiagramEvent @event) { _lastDiagram = @event.NewDiagram; UpdateEnabledState(); }
private void OnDiagramChanged(DiagramEvent diagramEvent) { _hostUiServices.Run(async() => await OnDiagramChangedAsync(diagramEvent)); }
private void OnDiagramChanged(DiagramEvent @event) { _lastDiagram = @event.NewDiagram; UpdateVisibility(); }
/// <remarks> /// When the model (backing the diagram) is updated there can be an interim time /// when there are diagram shapes that does not exist in the model any more. /// This is fine because those model events will eventually arrive that remove such shapes. /// </remarks> public DiagramEvent UpdateModel(IModel newModel) { var newDiagram = CreateInstance(newModel, _nodes, _connectors); return(DiagramEvent.Create(newDiagram)); }