public void UpdateReadStatus(TreeFeedsNodeBase thisNode, bool anyUnread) { if (thisNode == null) { return; } if (!anyUnread) // mark read // traverse tree: upwards, one by one. On every step // look for unread childs (go down). If there is one, stop walking up. // If not, mark it read (normal font state), go on upwards { if (this.Equals(thisNode)) { // this can happen only once. // A Feed can only have category/root folder as parents thisNode.AnyUnread = false; UpdateReadStatus(thisNode, 0); // correct the counters } else // Category/Root mark read { thisNode.AnyUnread = false; UpdateReadStatus(thisNode.Parent, false); } } else // mark unread // traverse tree: upwards, one by one. On each parent // mark it unread (bold font state), go on upwards { thisNode.AnyUnread = true; UpdateReadStatus(thisNode.Parent, true); } }
/// <summary> /// Resets the read status starting with this instance Node to zero. /// </summary> public void ResetReadStatus() { this.UnreadCount = 0; for (TreeFeedsNodeBase t = this.FirstNode; t != null; t = t.NextNode) { t.ResetReadStatus(); // recursive! } }
/// <summary> /// Helper that builds the full path trimmed category name (without root caption) /// </summary> /// <param name="node">the FeedTreeNodeBase</param> /// <returns> /// Category name in this form: /// 'Main Category\Sub Category\...\catNode Category'. /// Returns null in case node was null or no categories are found. /// </returns> public static string BuildCategoryStoreName(TreeFeedsNodeBase node) { string[] catArray = BuildCategoryStoreNameArray(node); if (catArray.Length == 0) { return(null); } return(String.Join(FeedSource.CategorySeparator, catArray)); }
/// <summary> /// Helper that builds the full path trimmed category name array (without root caption) /// </summary> /// <param name="node">the FeedTreeNodeBase</param> /// <returns>Category names in this form: ['Main Category', 'Sub Category', ...,'catNode Category'].</returns> public static string[] BuildCategoryStoreNameArray(TreeFeedsNodeBase node) { if (node == null) { return new string[] {} } ; if (node.Type == FeedNodeType.Feed || node.Type == FeedNodeType.Finder) { return(TreeHelper.BuildCategoryStoreNameArray(node.FullPath, true)); } return(TreeHelper.BuildCategoryStoreNameArray(node.FullPath, false)); }
/// <summary> /// Populates the treeview used as RSS search scope selection. /// </summary> /// <param name="sourceRootNode">The source root node.</param> /// <param name="nodeImages"></param> public void PopulateTreeRssSearchScope(TreeFeedsNodeBase sourceRootNode, ImageList nodeImages) { this.externalScopeRootNode = sourceRootNode; this.treeRssSearchScope.ImageList = nodeImages; this.treeRssSearchScope.Nodes.Clear(); if (this.externalScopeRootNode != null) { TreeHelper.CopyNodes(this.externalScopeRootNode, this.treeRssSearchScope, true); } if (this.treeRssSearchScope.Nodes.Count > 0) { this.treeRssSearchScope.Nodes[0].Expand(); } }
/// <summary> /// Updates the read status. Works upwards the node hierarchy. /// </summary> /// <param name="thisNode">The this node.</param> /// <param name="readCounter">The read counter.</param> public void UpdateReadStatus(TreeFeedsNodeBase thisNode, int readCounter) { //_log.DebugFormat("called at node {0}, with thisNode = {1}, readCounter = {2}", this.FullPath, thisNode == null ? "null" : thisNode.Text, readCounter); if (thisNode == null) { return; } if (readCounter <= 0) // mark read // traverse tree: upwards, one by one. On every step // look for unread childs (go down). If there is one, stop walking up. // If not, mark it read (normal font state), go on upwards { if (this.Equals(thisNode)) { // this can happen only once. A Feed can only have category/root as parents if (thisNode.UnreadCount < Math.Abs(readCounter)) { readCounter = -thisNode.UnreadCount; } if (readCounter == 0) { readCounter = -thisNode.UnreadCount; } thisNode.UnreadCount += readCounter; UpdateReadStatus(thisNode.Parent, readCounter); } else // Category/Root mark read { thisNode.UnreadCount += readCounter; UpdateReadStatus(thisNode.Parent, readCounter); } } else // mark unread (readCounter > 0) // traverse tree: upwards, one by one. On each parent // mark it unread (bold font state), go on upwards { if (!thisNode.HasNodes /*thisNode.Type != FeedNodeType.Root && thisNode.Type != FeedNodeType.Category */) { // this can happen only once. // A Feed can only have category/root as parents // we assume here, that the readCounter is a "reset" // of the current node.UnreadCounter to the new value. // So at first we have to correct all the parents UpdateReadStatus(thisNode.Parent, -thisNode.UnreadCount); thisNode.UnreadCount = readCounter; } else { thisNode.UnreadCount += readCounter; } // now we had set the new value, refresh the parent(s) UpdateReadStatus(thisNode.Parent, readCounter); } }
public void InitFromFinders(ArrayList finderList, ContextMenuStrip menu) { var categories = new Hashtable(); foreach (RssFinder finder in finderList) { TreeFeedsNodeBase parent = this; finder.Container = null; // may contain old node references on a re-populate call if (finder.FullPath.IndexOf(FeedSource.CategorySeparator) > 0) { // one with category string[] a = finder.FullPath.Split(FeedSource.CategorySeparator.ToCharArray()); int aLen = a.GetLength(0); string sCat = String.Join(FeedSource.CategorySeparator, a, 0, aLen - 1); if (categories.ContainsKey(sCat)) { parent = (TreeFeedsNodeBase)categories[sCat]; } else { // create category/categories var sb = new StringBuilder(); sb.Append(a[0]); for (int i = 0; i <= aLen - 2; i++) { sCat = sb.ToString(); if (categories.ContainsKey(sCat)) { parent = (TreeFeedsNodeBase)categories[sCat]; } else { TreeFeedsNodeBase cn = new FinderCategoryNode(a[i], 2, 3, menu); // menu??? categories.Add(sCat, cn); parent.Nodes.Add(cn); // cn.Cells[0].Value = cn.Text; // cn.Cells[0].Appearance.Image = cn.Override.NodeAppearance.Image; // cn.Cells[0].Appearance.Cursor = WinGuiMain.CursorHand; parent = cn; } sb.Append(FeedSource.CategorySeparator + a[i + 1]); } } } var n = new FinderNode(finder.Text, 10, 10, menu) { Finder = finder }; finder.Container = n; parent.Nodes.Add(n); // n.Cells[0].Value = n.Text; // n.Cells[0].Appearance.Image = n.Override.NodeAppearance.Image; // n.Cells[0].Appearance.Cursor = WinGuiMain.CursorHand; } //foreach finder }