public ArrowControl CreateArrow(ViewModel.Relationship viewModelRelationship) { if (viewModelRelationship.From == Guid.Empty || viewModelRelationship.To == Guid.Empty) { return(null); } if (Arrows.ContainsKey(viewModelRelationship.Id)) { return(null); } if (IsArrowExist(viewModelRelationship.From, viewModelRelationship.To)) { return(null); } var fromControl = NodeFactory.FindNodeControl(viewModelRelationship.From); var toControl = NodeFactory.FindNodeControl(viewModelRelationship.To); if (fromControl == null || toControl == null) { PendingRelationships[viewModelRelationship.Id] = viewModelRelationship; return(null); } var set = CreateSet(viewModelRelationship, fromControl, toControl); Arrows[viewModelRelationship.Id] = set; return(set.Control); }
private ArrowControlFactorySet CreateSet(ViewModel.Relationship viewModelRelationship, NodeControl fromControl, NodeControl toControl) { ArrowController arrowController = new ArrowController(viewModelRelationship, fromControl, toControl); arrowController.ViewModel.Id = viewModelRelationship.Id; if (toControl != null) { toControl.LinkFromNode(fromControl); } ArrowControl arrowControl = new ArrowControl(fromControl, toControl); Canvas.SetZIndex(arrowControl, 40); arrowControl.DataContext = arrowController.ViewModel; if (toControl != null && toControl.ViewModelNode.State == CollapseState.None) { toControl.ViewModelNode.State = CollapseState.Expanded; } ArrowControlFactorySet set = new ArrowControlFactorySet(); set.Relationship = viewModelRelationship; set.Control = arrowControl; set.Controller = arrowController; return(set); }
public bool IsRelationshipExist(ViewModel.Relationship viewModelRelationship) { var exist = Arrows.Values.FirstOrDefault( q => q.Relationship.From == viewModelRelationship.From && q.Relationship.To == viewModelRelationship.To); return(exist != null); }
public ArrowController(ViewModel.Relationship relationship, IPolymorphicShape from, IPolymorphicShape to) { From = from; To = to; ViewModel = new ViewModel.ArrowViewModel(); ViewModel.ViewModelRelationship = relationship; RefreshViewModel(); From.ShapeMoved += OnFromShapeMoved; To.ShapeMoved += OnToShapeMoved; }
public ArrowControlFactorySet RemoveArrow(ViewModel.Relationship viewModelRelationship) { return(RemoveArrow(viewModelRelationship.Id)); }