Esempio n. 1
0
        static void HandleExecuted_Delete(object sender, ExecutedRoutedEventArgs e)
        {
            SharpTreeView treeView = (SharpTreeView)sender;

            treeView.updatesLocked = true;
            int selectedIndex = -1;

            try
            {
                foreach (SharpTreeNode node in treeView.GetTopLevelSelection().ToArray())
                {
                    if (selectedIndex == -1)
                    {
                        selectedIndex = treeView.flattener.IndexOf(node);
                    }
                    node.Delete();
                }
            }
            finally
            {
                treeView.updatesLocked = false;
                treeView.UpdateFocusedNode(null, Math.Max(0, selectedIndex - 1));
            }
        }
Esempio n. 2
0
        static void HandleCanExecute_Delete(object sender, CanExecuteRoutedEventArgs e)
        {
            SharpTreeView treeView = (SharpTreeView)sender;

            e.CanExecute = treeView.GetTopLevelSelection().All(node => node.CanDelete());
        }
Esempio n. 3
0
 public UpdateLock(SharpTreeView instance)
 {
     this.instance = instance;
     this.instance.updatesLocked = true;
 }