/// <summary> /// Makes sure child and link shapes are visible /// </summary> public virtual void FixupShapeVisibility() { ReadOnlyCollection <NodeShapeReferencesNestedChildren> linksN = NodeShapeReferencesNestedChildren.GetLinksToNestedChildren(this.ShapeElement); foreach (NodeShapeReferencesNestedChildren link in linksN) { OnNestedChildShapeElementAdded(link); } ReadOnlyCollection <NodeShapeReferencesRelativeChildren> linksR = NodeShapeReferencesRelativeChildren.GetLinksToRelativeChildren(this.ShapeElement); foreach (NodeShapeReferencesRelativeChildren link in linksR) { OnRelativeChildShapeElementAdded(link); } foreach (BaseDiagramItemElementViewModel vm in this.NestedChildren) { vm.FixupShapeVisibility(); } foreach (BaseDiagramItemElementViewModel vm in this.RelativeChildren) { vm.FixupShapeVisibility(); } }
/// <summary> /// Called whenever a relationship of type NodeShapeReferencesNestedChildren is added and /// the element hosted by this model is the source. /// </summary> /// <param name="con"></param> protected virtual void OnNestedChildShapeElementAdded(NodeShapeReferencesNestedChildren con) { if (IsDisplayingNodeShape(con.ChildShape)) { return; } DiagramItemElementViewModel vm = this.ViewModelStore.Factory.CreateDiagramItemViewModel(con.ChildShape.GetDomainClassId(), this.Diagram, con.ChildShape); this.AddNestedChild(vm); }
/// <summary> /// Remove nested children. /// </summary> /// <param name="args"></param> protected override void OnNestedChildShapeElementRemoved(Microsoft.VisualStudio.Modeling.ElementDeletedEventArgs args) { NodeShapeReferencesNestedChildren con = args.ModelElement as NodeShapeReferencesNestedChildren; NodeShape nodeShape = con.ChildShape; if (nodeShape != null) { for (int i = this.Diagram.Children.Count - 1; i >= 0; i--) { if (this.Diagram.Children[i].ShapeElement.Id == nodeShape.Id) { this.Diagram.RemoveElement(this.Diagram.Children[i]); } } } }
/// <summary> /// Called whenever a relationship of type NodeShapeReferencesNestedChildren is removed and /// the element hosted by this model is the source. /// </summary> /// <param name="args"></param> protected virtual void OnNestedChildShapeElementRemoved(ElementDeletedEventArgs args) { NodeShapeReferencesNestedChildren con = args.ModelElement as NodeShapeReferencesNestedChildren; NodeShape nodeShape = con.ChildShape; if (nodeShape != null) { for (int i = this.nestedChildItems.Count - 1; i >= 0; i--) { if (this.nestedChildItems[i].ShapeElement.Id == nodeShape.Id) { BaseDiagramItemElementViewModel vm = this.nestedChildItems[i]; this.RemoveNestedChild(vm); vm.Dispose(); } } } }
public override void ElementAdded(ElementAddedEventArgs e) { NodeShapeReferencesNestedChildren con = e.ModelElement as NodeShapeReferencesNestedChildren; if (con != null) { NodeShape childShape = con.ChildShape; NodeShape parentShape = con.ParentShape; if (childShape != null && parentShape != null) { childShape.ResizeParentIfRequired(); } else { con.Delete(); } } }
/// <summary> /// Add nested children. /// </summary> /// <param name="con"></param> protected override void OnNestedChildShapeElementAdded(NodeShapeReferencesNestedChildren con) { DomainClassInfo info = con.ChildShape.GetDomainClass(); if (info.Id != NodeShape.DomainClassId) { DiagramItemElementViewModel elementVM = this.ViewModelStore.Factory.CreateDiagramItemViewModel( info.Id, this.Diagram, con.ChildShape); if (elementVM != null) { this.Diagram.AddElement(elementVM); return; } } GraphicalDependencyItemViewModel vm = new GraphicalDependencyItemViewModel( this.ViewModelStore, this.Diagram, con.ChildShape); this.Diagram.AddElement(vm); }
/// <summary> /// /// </summary> /// <param name="con"></param> protected override void OnNestedChildShapeElementAdded(NodeShapeReferencesNestedChildren con) { throw new NotSupportedException(); }