コード例 #1
0
ファイル: NewsNodeDecorator.cs プロジェクト: mo5h/omeo
        private void DecorateArticle(IResource article)
        {
            IResourceList groups = article.GetLinksFrom(null, NntpPlugin._propTo);

            foreach (IResource group in groups)
            {
                IResource res = group;
                do
                {
                    if (res.Type != NntpPlugin._newsGroup)
                    {
                        Core.UserInterfaceAP.QueueJob(new ResourceDelegate(DecorateResource), res);
                    }
                    res = new NewsTreeNode(res).Parent;
                }while(res != null && res != NewsFolders.Root);
            }
        }
コード例 #2
0
        public static IResource GetNewsFolderResource(IResource parent, string name, bool create)
        {
            IResourceStore store   = Core.ResourceStore;
            IResourceList  folders = new NewsTreeNode(parent).Children;

            folders = folders.Intersect(
                store.FindResources(NntpPlugin._newsFolder, Core.Props.Name, name), true);
            IResource folder = null;

            if (folders.Count > 0)
            {
                folder = folders[0];
            }
            else
            {
                if (create)
                {
                    if (!store.IsOwnerThread())
                    {
                        folder = (IResource)Core.ResourceAP.RunUniqueJob(
                            new GetNewsFolderResourceDelegate(GetNewsFolderResource), parent, name, true);
                    }
                    else
                    {
                        folder = store.BeginNewResource(NntpPlugin._newsFolder);
                        try
                        {
                            folder.SetProp(Core.Props.Name, name);
                            new NewsTreeNode(folder).Parent = parent;
                            if (parent == _newsgroupsRoot)
                            {
                                folder.SetProp("VisibleInAllWorkspaces", true);
                                folder.SetProp(NntpPlugin._propNewsSortOrder, Int32.MaxValue);
                            }
                            folder.SetProp(Core.Props.DisplayThreaded, parent.GetProp(Core.Props.DisplayThreaded));
                        }
                        finally
                        {
                            folder.EndUpdate();
                        }
                    }
                }
            }
            return(folder);
        }
コード例 #3
0
ファイル: NewsNodeDecorator.cs プロジェクト: mo5h/omeo
        public bool DecorateNode(IResource res, RichText nodeText)
        {
            if (res.Type == NntpPlugin._newsFolder || res.Type == NntpPlugin._newsServer)
            {
                int count;
                if (NewsFolders.IsDefaultFolder(res))
                {
                    IResourceList folderItems = NntpPlugin.CollectArticles(res, false);
                    IResource     wsp         = Core.WorkspaceManager.ActiveWorkspace;
                    if (wsp != null)
                    {
                        folderItems = folderItems.Intersect(wsp.GetLinksOfType(null, "WorkspaceVisible"), true);
                    }
                    if (NewsFolders.IsSentItems(res))
                    {
                        folderItems = folderItems.Intersect(_allUnread, true);
                    }
                    else
                    {
                        folderItems = folderItems.Minus(Core.ResourceStore.FindResourcesWithProp(null, Core.Props.IsDeleted));
                    }
                    count = folderItems.Count;
                }
                else
                {
                    IResourceList groups = new NewsTreeNode(res).Groups;
                    IResource     wsp    = Core.WorkspaceManager.ActiveWorkspace;
                    if (wsp != null)
                    {
                        groups = groups.Intersect(wsp.GetLinksOfType(null, "WorkspaceVisible"), true);
                    }
                    IResourceList articles = Core.ResourceStore.EmptyResourceList;
                    foreach (IResource group in groups.ValidResources)
                    {
                        articles = articles.Union(
                            group.GetLinksTo(null, NntpPlugin._propTo).Intersect(_allUnread), true);
                    }
                    count = articles.Count;
                }
                if (count != 0)
                {
                    nodeText.Append(" ");
                    nodeText.SetStyle(FontStyle.Bold, 0, res.DisplayName.Length);

                    /////////////////////////////////////////////////////////////////////
                    /// NewsFolders.IsDefaultFolder doesn't synchronously create folders,
                    /// so the check is necessary to avoid RunJobs to resource thread
                    /////////////////////////////////////////////////////////////////////
                    if (NewsFolders.IsDrafts(res))
                    {
                        nodeText.Append("[" + count + "]", _draftsTextStyle);
                    }
                    else
                    {
                        nodeText.Append("(" + count + ")", _unreadTextStyle);
                    }
                }
                return(true);
            }
            return(false);
        }