Beispiel #1
0
 void TreeView_SelectionChanged(object sender, TVSelectionChangedEventArgs e)
 {
     if (disable_SelectionChanged)
     {
         return;
     }
     SelectionChanged?.Invoke(this, e);
 }
Beispiel #2
0
 void TreeView_SelectionChanged(object sender, TVSelectionChangedEventArgs e)
 {
     if (disable_SelectionChanged)
     {
         return;
     }
     if (SelectionChanged != null)
     {
         SelectionChanged(this, e);
     }
 }
Beispiel #3
0
        void FileTreeView_SelectionChanged(object sender, TVSelectionChangedEventArgs e)
        {
            if (disableSelectionChangedEventCounter > 0)
            {
                return;
            }
            var nodes = ((IFileTreeView)sender).TreeView.TopLevelSelection.OfType <IFileTreeNodeData>().ToArray();

            // Prevent a new empty tab from opening when closing the last tab
            if (nodes.Length == 0 && ActiveTabContentImpl == null)
            {
                return;
            }

            // When the treeview selects nodes it will unselect everything and then select the new
            // nodes. We're not interested in the empty selection since it shouldn't be recorded in
            // the navigation history. If we get an empty selection, it could be because of the
            // treeview or it's because the user unselected everything. Show the empty nodes with
            // a slight delay so we can cancel it if the real selection immediately follows.
            // Reproduce: Select a node, then collapse its parent to unselect the node and select
            // the parent. Or open a new file.
            if (nodes.Length != 0 || inEmptySelectionHack)
            {
                ignoreEmptySelection = true;
                ShowNodes(nodes);
            }
            else
            {
                inEmptySelectionHack = true;
                ignoreEmptySelection = false;
                Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Send, new Action(() => {
                    var old = ignoreEmptySelection;
                    inEmptySelectionHack = false;
                    ignoreEmptySelection = false;
                    if (!old)
                    {
                        ShowNodes(nodes);
                    }
                }));
            }
        }