コード例 #1
0
ファイル: BookmarksTreeView.cs プロジェクト: NHxD/NHxD
        public void Populate(Func <BookmarkNode, bool> predicate)
        {
            bool shouldInitializeTree = treeView.Nodes.Count == 0;

            using (new CursorScope(Cursors.WaitCursor))
            {
                treeView.BeginUpdate();

                treeView.Nodes.Clear();

                if (shouldInitializeTree)
                {
                    foreach (KeyValuePair <string, BookmarkFolder> kvp in BookmarksModel.BookmarkFolders)
                    {
                        AddFolder(kvp.Key, false);
                    }
                }

                foreach (KeyValuePair <string, BookmarkNode> kvp in BookmarksModel.Bookmarks.Where(x => predicate.Invoke(x.Value)))
                {
                    AddItem(kvp.Key, kvp.Value);
                }

                ExpandOrCollapseFolderRecursive(treeView.Nodes);

                treeView.EndUpdate();
            }
        }
コード例 #2
0
        public static void Init(TreeViewEx tree)
        {
            if (AppVars.Profile.Contacts.Count == 0)
            {
                AppVars.Profile.Contacts.Add("Мастер Создатель".ToLower(), new Contact("Мастер Создатель", 0, 0, "Платите деньги за солнечный свет...", true, false));
                AppVars.Profile.Contacts.Add("Шандор-Волшебник".ToLower(), new Contact("Шандор-Волшебник", 0, 0, "Массовик-затейник", true, false));
                AppVars.Profile.Contacts.Add("Черный".ToLower(), new Contact("Черный", 2, 0, "Автор клиента ABClient (2007-2016)\r\n\nE-mail: [email protected]\r\n\nSkype: wmlab.home", true, false));
            }

            try
            {
                Rwl.AcquireWriterLock(5000);
                try
                {
                    tree.BeginUpdate();
                    tree.Nodes.Clear();

                    foreach (var contact in AppVars.Profile.Contacts)
                    {
                        Add(tree, contact.Value);
                    }

                    tree.EndUpdate();
                }
                finally
                {
                    Rwl.ReleaseWriterLock();
                }
            }
            catch (ApplicationException)
            {
            }
        }
コード例 #3
0
        public void Populate(Func <KeyValuePair <string, BrowsingItem>, bool> predicate)
        {
            using (new CursorScope(Cursors.WaitCursor))
            {
                treeView.BeginUpdate();

                treeView.Nodes.Clear();

                foreach (KeyValuePair <string, BrowsingItem> searchRecord in BrowsingModel.SearchHistory
                         .Where(x => predicate.Invoke(x)))
                {
                    AddItem(searchRecord.Key, searchRecord.Value);
                }

                foreach (TreeNode dateNode in treeView.Nodes)
                {
                    DateTime date = (DateTime)dateNode.Tag;

                    if (BrowsingListSettings.Collapsed.ContainsKey(date.Date))
                    {
                        if (BrowsingListSettings.Collapsed[date.Date])
                        {
                            dateNode.Collapse();
                        }
                        else
                        {
                            dateNode.Expand();
                        }
                    }
                }

                treeView.EndUpdate();
            }
        }
コード例 #4
0
ファイル: LibraryTreeView.cs プロジェクト: NHxD/NHxD
        public void Populate(Func <string, bool> predicate)
        {
            using (new CursorScope(Cursors.WaitCursor))
            {
                treeView.BeginUpdate();

                treeView.Nodes.Clear();

                if (Directory.Exists(LibraryModel.FileSystemWatcher.Path))
                {
                    DirectoryInfo dirInfo = new DirectoryInfo(LibraryModel.FileSystemWatcher.Path);

                    IEnumerable <DirectoryInfo> dirInfos = dirInfo.EnumerateDirectories();

                    foreach (DirectoryInfo subDirInfo in dirInfos
                             .Where(x => predicate.Invoke(x.FullName)))
                    {
                        TreeNode treeNode = new TreeNode(subDirInfo.Name)
                        {
                            Tag = subDirInfo.FullName, Name = FileNameToControlName(subDirInfo.Name)
                        };

                        treeView.Nodes.Add(treeNode);

                        OnNodeAdded(treeNode);
                    }

                    // TODO: create a list of ArchiveReaders and use that instead of ArchiveWriters.
                    if (ArchiveWriters != null)
                    {
                        foreach (IArchiveWriter archiveWriter in ArchiveWriters)
                        {
                            IEnumerable <FileInfo> fileInfos = dirInfo.EnumerateFiles("*" + archiveWriter.FileExtension);

                            foreach (FileInfo subFileInfo in fileInfos
                                     .Where(x => predicate.Invoke(x.FullName)))
                            {
                                TreeNode treeNode = new TreeNode(subFileInfo.Name)
                                {
                                    Tag = subFileInfo.FullName, Name = FileNameToControlName(subFileInfo.Name)
                                };

                                treeView.Nodes.Add(treeNode);

                                OnNodeAdded(treeNode);
                            }
                        }
                    }
                }

                treeView.EndUpdate();
            }
        }
コード例 #5
0
 // UnCheck All...
 protected void OnUnCheckAllClick(object sender, EventArgs e)
 {
     if (this.UnCheckAllEvent == null)
     {
         TreeNodeEx treeNode = this.TreeNode;
         TreeViewEx treeView = treeNode.TreeView;
         treeView.BeginUpdate();
         TreeViewHelpers.CheckBoxes.UnCheckAll(treeNode);
         treeView.EndUpdate();
     }
     else
     {
         this.UnCheckAllEvent(this, new ContextMenuEventArgs <TreeNodeEx>(this.TreeNode));
     }
 }
コード例 #6
0
 // Collapse All...
 protected void OnCollapseAllClick(object sender, EventArgs e)
 {
     if (this.CollapseAllEvent == null)
     {
         TreeNodeEx treeNode = this.TreeNode;
         TreeViewEx treeView = treeNode.TreeView;
         treeView.BeginUpdate();
         treeNode.Collapse();
         treeView.SelectedNode = treeNode;
         treeNode.EnsureVisible();
         treeView.EndUpdate();
     }
     else
     {
         this.CollapseAllEvent(this, new ContextMenuEventArgs <TreeNodeEx>(this.TreeNode));
     }
 }
コード例 #7
0
ファイル: TagsTreeView.cs プロジェクト: NHxD/NHxD
        public void Populate(Func <TagInfo, bool> predicate)
        {
            using (new CursorScope(Cursors.WaitCursor))
            {
                treeView.BeginUpdate();

                treeView.Nodes.Clear();

                Type tagTypeType = typeof(TagType);

                foreach (TagType tagType in Enum.GetValues(tagTypeType))
                {
                    AddCategory(tagType, tagTypeType, predicate);
                }

                treeView.EndUpdate();
            }
        }
コード例 #8
0
        internal static void RemoveGroup(TreeViewEx tree, string group)
        {
            try
            {
                Rwl.AcquireWriterLock(5000);
                try
                {
                    if (!tree.Nodes.ContainsKey(group))
                    {
                        return;
                    }

                    var tngroup = tree.Nodes[group];
                    tree.BeginUpdate();
                    for (int i = tngroup.Nodes.Count - 1; i >= 0; i--)
                    {
                        var tn      = tngroup.Nodes[i];
                        var contact = (Contact)tn.Tag;
                        tn.Remove();

                        if (AppVars.Profile.Contacts.ContainsKey(contact.Name.ToLower()))
                        {
                            AppVars.Profile.Contacts.Remove(contact.Name.ToLower());
                        }
                    }

                    tngroup.Remove();
                    tree.EndUpdate();

                    AppVars.Profile.Save();
                }
                finally
                {
                    Rwl.ReleaseWriterLock();
                }
            }
            catch (ApplicationException)
            {
            }
        }