public void RedrawToolWindow() { SortedDictionary <string, List <VBookmarkPrim> > labels = new SortedDictionary <string, List <VBookmarkPrim> >(); foreach (var bookmarkPrims in m_FileBookmarkPrims) { foreach (var bookmarkPrimIt in bookmarkPrims.Value) { BookmarkPrim bookmarkPrim = bookmarkPrimIt.Value; List <VBookmarkPrim> bookmarkPrimList = null; if (labels.ContainsKey(bookmarkPrim.m_tag)) { bookmarkPrimList = labels[bookmarkPrim.m_tag]; } else { bookmarkPrimList = new List <VBookmarkPrim>(); labels.Add(bookmarkPrim.m_tag, bookmarkPrimList); } VBookmarkPrim vBookmarkPrim = new VBookmarkPrim(bookmarkPrims.Key, bookmarkPrimIt.Key, bookmarkPrim); bookmarkPrimList.Add(vBookmarkPrim); } } /* ToolWindowControl toolWindowControl = ToolWindowControl.GetInstance(); * System.Windows.Forms.TreeView treeView = toolWindowControl.m_BookmarkTreeView; */ var treeView = ToolWindowControl.GetBookmarkTreeView(); if (treeView != null) { SortedDictionary <string, TreeViewItem> treeViewItems = new SortedDictionary <string, TreeViewItem>(); foreach (var item in treeView.Items) { TreeViewItem treeViewItem = item as TreeViewItem; if (treeViewItem != null) { treeViewItems.Add(treeViewItem.Header.ToString(), treeViewItem); } } // treeView.Items.Clear(); foreach (var label in labels) { TreeViewItem treeViewItem = null; string keystr = label.Key.ToString(); if (treeViewItems.ContainsKey(keystr)) { treeViewItem = treeViewItems[keystr]; // TreeViewItem prim = null; // treeViewItems.TryRemove(keystr, out prim); treeViewItems.Remove(keystr); treeViewItem.Items.Clear(); } else { treeViewItem = new TreeViewItem(); treeViewItem.Header = label.Key.ToString(); treeView.Items.Add(treeViewItem); } foreach (var vBookmarkPrim in label.Value) { TreeViewItem item = new TreeViewItem(); item.DataContext = vBookmarkPrim; item.Header = vBookmarkPrim.m_Label; treeViewItem.Items.Add(item); } } foreach (var treeViewItem in treeViewItems) { treeView.Items.Remove(treeViewItem.Value); } } }
public ToolWindowControl() { m_Instance = this; this.InitializeComponent(); }