/// <summary> /// Removes the host shape. /// </summary> /// <param name="shape">Host shape to remove.</param> protected virtual void RemoveHostShape(GraphicalDependencyShape shape) { shape.LinkShape.Delete(); for (int y = shape.NestedChildren.Count - 1; y >= 0; y--) { NodeShape nodeShape = shape.NestedChildren[y]; for (int i = this.childItemElements.Count - 1; i >= 0; i--) { if (this.childItemElements[i].ShapeElement.Id == nodeShape.Id) { if (this.childItems.Contains(this.childItemElements[i])) { this.childItems.Remove(this.childItemElements[i]); } this.childItemElements[i].Dispose(); this.childItemElements.RemoveAt(i); } } } // delete shape shape.Delete(); }
/// <summary> /// Updates the link between the main shape and the dependency shape. /// </summary> /// <param name="shape"></param> /// <param name="bSource"></param> protected virtual void UpdateLink(GraphicalDependencyShape shape, bool bSource) { GraphicalDependencyLinkShape linkShape = new GraphicalDependencyLinkShape(this.Store); linkShape.Element = shape.Element; linkShape.SourceAnchor = new SourceAnchor(this.Store); if (bSource) { linkShape.SourceAnchor.FromShape = shape; } else { linkShape.SourceAnchor.FromShape = this.Diagram.MainElementShape; } linkShape.TargetAnchor = new TargetAnchor(this.Store); if (bSource) { linkShape.TargetAnchor.ToShape = this.Diagram.MainElementShape; } else { linkShape.TargetAnchor.ToShape = shape; } linkShape.RoutingMode = RoutingMode.Orthogonal; linkShape.DependencyShape = shape; linkShape.MainShape = this.Diagram.MainElementShape; this.Diagram.UpdateLinkShapePosition(linkShape, shape, this.Diagram.MainElementShape, bSource); this.Diagram.LinkShapes.Add(linkShape); }
private GraphicalDependencyShape CreateHostShape(ElementLink link, DomainRelationshipInfo info) { GraphicalDependencyShape shape = new GraphicalDependencyShape(this.Store); shape.RelationshipName = info.DisplayName; shape.Element = link; shape.SetLocation(new PointD(5, 5)); shape.RelationshipTypeId = info.Id; this.Diagram.Children.Add(shape); return(shape); }
/// <summary> /// Updates the displayed dependencies based on filter information. /// </summary> public virtual void UpdateBasedOnFilter(GraphicalDependenciesFilterItem filterItem) { this.Store.UndoManager.UndoState = UndoState.DisabledNoFlush; using (Transaction t = this.Store.TransactionManager.BeginTransaction("", true)) { if (filterItem.IsFiltered) { // remove elements for (int i = 0; i < this.Diagram.SourceDependencyShapes.Count; i++) { if (this.Diagram.SourceDependencyShapes[i].RelationshipTypeId == filterItem.RelationshipType && this.Diagram.SourceDependencyShapes[i].RelationshipTypeId != Guid.Empty) { RemoveHostShape(this.Diagram.SourceDependencyShapes[i]); break; } if (this.Diagram.SourceDependencyShapes[i].CustomInfo == filterItem.CustomFilterInformation && !String.IsNullOrEmpty(this.Diagram.SourceDependencyShapes[i].CustomInfo)) { RemoveHostShape(this.Diagram.SourceDependencyShapes[i]); break; } } for (int i = 0; i < this.Diagram.TargetDependencyShapes.Count; i++) { if (this.Diagram.TargetDependencyShapes[i].RelationshipTypeId == filterItem.RelationshipType && this.Diagram.TargetDependencyShapes[i].RelationshipTypeId != Guid.Empty) { RemoveHostShape(this.Diagram.TargetDependencyShapes[i]); break; } if (this.Diagram.TargetDependencyShapes[i].CustomInfo == filterItem.CustomFilterInformation && !String.IsNullOrEmpty(this.Diagram.TargetDependencyShapes[i].CustomInfo)) { RemoveHostShape(this.Diagram.TargetDependencyShapes[i]); break; } } UpdateLayout(); } else { // add elements GraphicalDependencyShape hostShape = null; bool bSource = true; DomainClassInfo elementInfo = this.MainElement.GetDomainClass(); ReadOnlyCollection <ElementLink> links = DomainRoleInfo.GetAllElementLinks(this.MainElement); foreach (ElementLink link in links) { DomainRelationshipInfo info = link.GetDomainRelationship(); if (info.Id == filterItem.RelationshipType) { if (DomainRoleInfo.GetSourceRolePlayer(link) != this.MainElement) { bSource = false; } if (hostShape == null) { hostShape = CreateHostShape(link, info); if (bSource) { this.Diagram.TargetDependencyShapes.Add(hostShape); } else { this.Diagram.SourceDependencyShapes.Add(hostShape); } } if (bSource) { hostShape.AddNestedChild(CreateChildShape(link, true)); } else { hostShape.AddNestedChild(CreateChildShape(link, false)); } } } UpdateLayout(); if (hostShape != null) { UpdateLink(hostShape, !bSource); } } t.Commit(); } this.Store.UndoManager.UndoState = UndoState.Enabled; }
public GraphicalDependencyHostViewModel(ViewModelStore viewModelStore, GraphicalDependenciesViewModel diagram, GraphicalDependencyShape shapeElement) : base(viewModelStore, diagram, shapeElement) { }