public void OnSelect(SelectInfo selectInfo) { ISelectable[] selectionChanged; //! 選択を反転 if (Keyboard.Modifiers == ModifierKeys.Control) { selectionChanged = SelectUtility.ToggleSelect(selectInfo.AllNodes.Concat(selectInfo.Connections), selectInfo.NewSelectNodes.Concat(selectInfo.NewConnections)); } //! 追加選択 else if (Keyboard.Modifiers == ModifierKeys.Shift) { selectionChanged = SelectUtility.AddSelect(selectInfo.AllNodes.Concat(selectInfo.Connections), selectInfo.NewSelectNodes.Concat(selectInfo.NewConnections)); } //! 選択されたものだけを選択するが、既に選択済みの場合は何もしない(Nodeをまとめてドラッグする際にこのモードを利用する) else if (selectInfo.NewSelectNodes.Any()) { selectionChanged = SelectUtility.SingleSelect(selectInfo.AllNodes.Concat(selectInfo.Connections), selectInfo.NewSelectNodes); } //! 選択されたものだけを選択状態とする else { selectionChanged = SelectUtility.OnlySelect(selectInfo.AllNodes.Concat(selectInfo.Connections), selectInfo.NewConnections); } //! 選択が変更されたことをイベントで通知する(undo / redo 等に使用) if (selectionChanged.Any()) { SelectionChanged?.Execute(new SelectionChangedEventArgs(selectionChanged)); } }
public void OnSelect() { var selectNodes = _panel.GetHitTestChildrenWithRect <NodeControl>(_rect).ToArray(); if (selectNodes.Any()) { var changed = SelectUtility.OnlySelect(_nodes.OfType <ISelectable>().Concat(_connections), selectNodes); SelectionChangedCommand?.Execute(new SelectionChangedEventArgs(changed)); return; } var selectConnections = _connections.Where(x => x.HitTestRect(_rect)).ToArray(); if (selectConnections.Any()) { var changed = SelectUtility.OnlySelect(_nodes.OfType <ISelectable>().Concat(_connections), selectConnections); SelectionChangedCommand?.Execute(new SelectionChangedEventArgs(changed)); } }