Exemple #1
0
        /// <summary>
        /// Recursive method to duplicate (deep copy) the current node and its children.
        /// </summary>
        /// <param name="fnParent">The FeedNode to which the new node will be parented under.</param>
        /// <returns>The new FeedNode which contains the same information as the current node (this).</returns>
        public FeedNode Duplicate(FeedNode fnParent)
        {
            FeedNode fnNew = new FeedNode(Title, XmlUrl, fnParent, IsFolder);

            fnNew.m_strText        = m_strText;
            fnNew.m_strHtmlUrl     = m_strHtmlUrl;
            fnNew.m_strDescription = m_strDescription;
            fnNew.m_strPath        = m_strPath;
            if (fnParent != null)
            {
                fnParent.AddChildNode(fnNew);
            }

            if (m_bFolder)
            {
                IDictionaryEnumerator enumNodes = m_listChildren.GetEnumerator();
                while (enumNodes.MoveNext())
                {
                    FeedNode feedNode = (FeedNode)enumNodes.Key;
                    if (feedNode != null)
                    {
                        feedNode.Duplicate(fnNew);
                    }
                }
            }
            return(fnNew);
        }
Exemple #2
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 #3
0
        /// <summary>
        /// Parses feeds.xml and constructs the tree of FeedNode's.
        /// </summary>
        public override void Run()
        {
            XmlTextReader reader = null;

            try
            {
                FeedNode nodeCurrent = m_form.RootFeedNode;
                nodeCurrent.Clear();
                string strXmlUrl      = String.Empty;
                string strFeedName    = String.Empty;
                string strGroupName   = String.Empty;
                string strElementName = String.Empty;
                reader = new XmlTextReader("feeds.xml");
                reader.WhitespaceHandling = WhitespaceHandling.None;
                while (reader.Read())
                {
                    XmlNodeType type = reader.NodeType;
                    if (type == XmlNodeType.Element)
                    {
                        strElementName = reader.Name;
                        if (strElementName == "group" && reader.HasAttributes)
                        {
                            strGroupName = reader.GetAttribute("title");
                            FeedNode node = new FeedNode(strGroupName, null, nodeCurrent, true);
                            nodeCurrent.AddChildNode(node);
                            if (!reader.IsEmptyElement)
                            {
                                nodeCurrent = node;
                            }
                        }
                        else if (strElementName == "outline" && reader.HasAttributes)
                        {
                            strFeedName = reader.GetAttribute("title");
                            strXmlUrl   = reader.GetAttribute("xmlUrl");
                            FeedNode node = new FeedNode(strFeedName, strXmlUrl, nodeCurrent, false);
                            node.Text        = reader.GetAttribute("text");
                            node.HtmlUrl     = reader.GetAttribute("htmlUrl");
                            node.Description = reader.GetAttribute("description");
                            nodeCurrent.AddChildNode(node);
                        }
                    }
                    else if (type == XmlNodeType.EndElement)
                    {
                        strElementName = reader.Name;
                        if (strElementName == "group")
                        {
                            nodeCurrent = nodeCurrent.Parent;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Utils.DbgOutExc("ParseFeedsThread::Run()", ex);
            }
            finally
            {
                if (reader != null)
                {
                    reader.Close();
                }
                m_form.Invoke(new OnEndCallback(OnEnd));
            }
        }