private void FindRelatedArrows() { if (NodeControls.Count > 0) { foreach (var arrowControl in SelectorControl.GetArrowControls()) { var viewModelArrow = arrowControl.DataContext as ArrowViewModel; if (viewModelArrow != null) { foreach (var nodeControl in NodeControls) { if (viewModelArrow.ViewModelRelationship.From == nodeControl.ViewModelNode.Id || viewModelArrow.ViewModelRelationship.To == nodeControl.ViewModelNode.Id) { AddArrow(arrowControl); } } } } NodeControls[0].Focus(); } }
public void MouseManagerOnLeftButtonDragReleased(object sender, MouseManagerEventArgs e) { if (!IsDrag) { return; } Visibility = Visibility.Collapsed; // If nothing is pressed, clean selection if ((Keyboard.Modifiers & ModifierKeys.Shift) != ModifierKeys.Shift && (Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.Control) { Clear(); } // If Control is pressed, remove selected nodes from selection if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control) { var removedNodeControl = false; foreach (var child in SelectorControl.NodeContainer.Children) { if (child is NodeControl) { var nodeControl = child as NodeControl; if (nodeControl.Visibility == Visibility.Visible) { if (IsPointInSelection(nodeControl.Centre) && nodeControl.ViewModelNode.IsSelected) { RemoveNode(nodeControl); removedNodeControl = true; } } } } if (!removedNodeControl) { foreach (var arrowControl in SelectorControl.GetArrowControls().Where(q => q.IsCollapsed == false)) { var viewModelArrow = arrowControl.DataContext as ArrowViewModel; if (viewModelArrow != null) { if (IsArrowInSelection(viewModelArrow.FirstCoordinate, viewModelArrow.SecondCoordinate)) { RemoveArrow(arrowControl); } } } } } // Add selected nodes to selection else { foreach (var child in SelectorControl.GetVisibleNodeControls()) { if (IsPointInSelection(child.Centre)) { AddNode(child); } } if (NodeControls.Count == 0 || ArrowControls.Count > 0) { foreach (var arrowControl in SelectorControl.GetArrowControls().Where(q => q.IsCollapsed == false)) { var viewModelArrow = arrowControl.DataContext as ArrowViewModel; if (viewModelArrow != null) { if (IsArrowInSelection(viewModelArrow.FirstCoordinate, viewModelArrow.SecondCoordinate)) { AddArrow(arrowControl); } } } } } FindRelatedArrows(); IsDrag = false; }