private void TreeListViewNodeSelected(object sender, ItemSelectedEventArgs <TreeListView.Node> e) { if (m_selectionContext == null) { return; } object item = e.Item.Tag; if (item == null) { return; } if (e.Selected) { m_selectionContext.Add(item); } else { m_selectionContext.Remove(item); } ItemSelected.Raise(this, new NodeAdapterEventArgs(item, e.Item)); }
private void HandleSelectionUpdates() { if (m_selectionContext == null) { return; } object hitItem = LastHit; if ((hitItem == null) || (hitItem == this)) { return; } TreeListView.Node hitNode; if (!m_dictNodes.TryGetValue(hitItem, out hitNode)) { return; } HashSet <object> oldSelection = null; HashSet <object> newSelection = null; var handler = ItemSelected; if (handler != null) { oldSelection = new HashSet <object>(m_selectionContext.Selection); } switch (Control.ModifierKeys) { case Keys.Shift: { if (m_selectionStartItem != null) { int idx1 = m_treeListView.GetNodeIndex(m_selectionStartItem); int idx2 = m_treeListView.GetNodeIndex(hitNode); int startIndex = Math.Min(idx1, idx2); int endIndex = Math.Max(idx1, idx2); newSelection = new HashSet <object>(); for (int i = startIndex; i <= endIndex; i++) { TreeListView.Node item = m_treeListView.GetNodeAtIndex(i); newSelection.Add(item.Tag); } m_selectionContext.SetRange(newSelection); } else { m_selectionContext.Set(hitItem); m_selectionStartItem = hitNode; } } break; case Keys.Control: { if (m_selectionContext.SelectionContains(hitItem)) { m_selectionContext.Remove(hitItem); } else { m_selectionContext.Add(hitItem); } m_selectionStartItem = hitNode; } break; default: { m_selectionContext.Set(hitItem); m_selectionStartItem = hitNode; } break; } if (handler == null) { return; } if (newSelection == null) { newSelection = new HashSet <object>(m_selectionContext.Selection); } foreach (object removed in oldSelection.Except(newSelection)) { TreeListView.Node node; if (!m_dictNodes.TryGetValue(removed, out node)) { continue; } ItemSelected.Raise(this, new NodeAdapterEventArgs(removed, node)); } foreach (object added in newSelection.Except(oldSelection)) { TreeListView.Node node; if (!m_dictNodes.TryGetValue(added, out node)) { continue; } ItemSelected.Raise(this, new NodeAdapterEventArgs(added, node)); } }
private void queryOptionItem_Clicked(object sender, EventArgs e) { ItemSelected.Raise(this, EventArgs.Empty); }