//===================================================================== /// <summary> /// Get the check state of the specified item from the tree view /// </summary> /// <param name="index">The index of the item in this collection</param> /// <returns>The check state of the checked item from the checkbox list</returns> public NodeCheckState CheckStateOf(int index) { TreeNode node = this[index]; ExtendedTreeView tree = (ExtendedTreeView)node.TreeView; return(tree.GetNodeCheckState(node.Name)); }
// protected override void OnMouseWheel(MouseWheelEventArgs e) // { // don't call the method of the base class // } public override void OnApplyTemplate() { base.OnApplyTemplate(); _treeView = (ExtendedTreeView)this.GetTemplateChild("treeView"); _treeView.OnHierarchyMouseUp += new MouseEventHandler(OnTreeViewHierarchyMouseUp); _contentPresenter = (ContentPresenter)this.GetTemplateChild("ContentPresenter"); this.SetSelectedItemToHeader(); }
protected virtual void GenerateTreeView() { IsGenerating = true; NotifyPropertyChanged("IsGenerating"); panelMain.Children.Clear(); UpdateProgress(0, 0); ExtendedTreeView treeviewSample = new ExtendedTreeView(); treeviewSample.SetValue(ScrollViewer.IsDeferredScrollingEnabledProperty, TreeViewSettingsWindow.IsDeferredScrollingEnabled); treeviewSample.SetValue(VirtualizingPanel.IsVirtualizingProperty, TreeViewSettingsWindow.IsVirtualizing); treeviewSample.SetValue(VirtualizingPanel.VirtualizationModeProperty, TreeViewSettingsWindow.VirtualizationMode); treeviewSample.SelectionMode = TreeViewSettingsWindow.SelectionMode; treeviewSample.AllowDragDrop = TreeViewSettingsWindow.AllowDragDrop; treeviewSample.IsRootAlwaysExpanded = TreeViewSettingsWindow.IsRootAlwaysExpanded; treeviewSample.IsItemExpandedAtStart = TreeViewSettingsWindow.IsItemExpandedAtStart; treeviewSample.Content = GenerateRoot(TreeViewSettingsWindow.IsCloneable); treeviewSample.DropCheck += OnDropCheck; Collection <ResourceDictionary> MergedDictionaries = Application.Current.Resources.MergedDictionaries; MergedDictionaries.Clear(); switch (TreeViewSettingsWindow.TreeViewType) { case TreeViewType.VS2013: MergedDictionaries.Add(VS2013Dictionnary); treeviewSample.ExpandButtonStyle = FindResource("VS2013ExpandButtonStyle") as Style; treeviewSample.ExpandButtonWidth = 16; treeviewSample.IndentationWidth = 16; break; case TreeViewType.Explorer: MergedDictionaries.Add(ExplorerDictionnary); ButtonList = new List <FrameworkElement>(); Style ButtonStyle = FindResource("ExplorerExpandButtonStyle") as Style; Style NewButtonStyle = new Style(typeof(ToggleButton), ButtonStyle); NewButtonStyle.Setters.Add(new EventSetter(ToggleButton.LoadedEvent, new RoutedEventHandler(OnButtonLoaded))); NewButtonStyle.Setters.Add(new EventSetter(ToggleButton.UnloadedEvent, new RoutedEventHandler(OnButtonUnloaded))); treeviewSample.ExpandButtonStyle = NewButtonStyle; treeviewSample.ExpandButtonWidth = 12; treeviewSample.IndentationWidth = 8; treeviewSample.MouseEnter += OnTreeViewMouseEnter; treeviewSample.MouseLeave += OnTreeViewMouseLeave; break; case TreeViewType.Custom: switch (TreeViewSettingsWindow.TreeViewItemType) { case TreeViewItemType.FixedHeightImage: MergedDictionaries.Add(CustomFixedHeightImageDictionnary); break; case TreeViewItemType.Text: MergedDictionaries.Add(CustomTextImageDictionnary); break; case TreeViewItemType.VariableHeightImageAndText: MergedDictionaries.Add(CustomVariableHeightImageAndTextDictionnary); break; default: throw new ArgumentException("Invalid TreeViewItemType"); } break; default: throw new ArgumentException("Invalid TreeViewType"); } panelMain.Children.Add(treeviewSample); }