public void DeleteArrows(UserControl sender = null) { foreach (var arrow in ArrowControls) { arrow.IsCollapsed = true; var arrowViewModel = arrow.DataContext as ArrowViewModel; if (arrowViewModel == null || arrowViewModel.ViewModelRelationship == null) { continue; } if (arrow.From != null) { if (arrow.From.ChildNodes.Count == 0) { arrow.From.CollapseControl.State = CollapseState.None; } else if (arrow.From.ChildNodes.All(q => q.IsCollapsed)) { arrow.From.CollapseControl.State = CollapseState.Collapsed; } } } IoC.GetInstance <ISuperGraphRelationshipFactory>().DeleteRelationships(ArrowControls.Select(q => q.DataContext) .OfType <ArrowViewModel>() .Select(q => q.ViewModelRelationship)); }
//Remove node from selection public void RemoveArrow(ArrowControl arrowControl) { if (HasArrow(arrowControl)) { ArrowControls.Remove(arrowControl); arrowControl.DeSelect(); } }
//Add node to selection public void AddArrow(ArrowControl arrowControl) { if (!HasArrow(arrowControl)) { ArrowControls.Add(arrowControl); arrowControl.Select(); } }
//Clear selection public void Clear() { foreach (var nodeControl in NodeControls) { nodeControl.DeSelect(); } NodeControls.Clear(); foreach (var arrowControl in ArrowControls) { arrowControl.DeSelect(); } ArrowControls.Clear(); }
public bool HasArrow(ArrowControl arrowControl) { return(ArrowControls.Contains(arrowControl)); }