Exemple #1
0
        /// <summary>
        /// Moves the current FeedNode from one folder to another.
        /// </summary>
        /// <param name="fnDest">Destination folder that this FeedNode will be moved to.</param>
        /// <returns></returns>
        public bool MoveTo(FeedNode fnDest, System.Windows.Forms.TreeView tvFeeds)
        {
            Debug.WriteLine(String.Format("MoveTo() {0} -> {1}", this.ToString(), fnDest.ToString()));

            if (fnDest.IsFolder == false)
            {
                return(false);                  // Can't move into anything else than a folder.
            }
            if (m_parent == fnDest)
            {
                return(false);                  // The FeedNode can't be moved into the same folder it already is in.
            }

            TreeNode tnOld = (TreeNode)Tag;

            tnOld.Remove();                             // remove the treenode from the old folder

            m_parent.DeleteChildNode(this);             // remove the feednode from this folder

            m_parent = fnDest;                          // parent this node to the destination feednode
            fnDest.AddChildNode(this);                  // add this node to the destination feednode

            TreeNode tnDest = (TreeNode)fnDest.Tag;     // the destination folder's treenode

            tnDest.Nodes.Clear();

            fnDest.PopulateTreeNodes(tnDest, tvFeeds);

            return(true);
        }
Exemple #2
0
        /// <summary>
        /// Populates the tree nodes of the current FeedNode.
        /// Recursive method to generate the TreeView tree structure
        /// in accordance to the FeedNode tree structure.
        /// </summary>
        /// <param name="crtTreeNode">TreeNode with which this FeedNode is to be associated with.</param>
        public void PopulateTreeNodes(TreeNode crtTreeNode, System.Windows.Forms.TreeView tvFeeds)
        {
            if ((m_parent == null) && (crtTreeNode == null))
            {                   // root node?
                TreeNode treeNode = tvFeeds.Nodes.Add(m_strTitle);
                treeNode.Tag = this;
                this.Tag     = treeNode;
                crtTreeNode  = treeNode;
            }
            IDictionaryEnumerator enumNodes = this.Enumerator;

            while (enumNodes.MoveNext())
            {
                FeedNode feedNode = (FeedNode)enumNodes.Key;
                if (feedNode != null)
                {
                    TreeNode treeNode = crtTreeNode.Nodes.Add(feedNode.Title);
                    treeNode.Tag = feedNode;
                    feedNode.Tag = treeNode;
                    if (feedNode.IsFolder)
                    {
                        treeNode.ImageIndex         = 0;
                        treeNode.SelectedImageIndex = 0;
                        feedNode.PopulateTreeNodes(treeNode, tvFeeds);
                    }
                    else
                    {
                        treeNode.ImageIndex         = 1;
                        treeNode.SelectedImageIndex = 1;
                    }
                }
            }
        }