Esempio n. 1
0
 /// <summary>
 /// Gets or sets the <see cref="T:DirectoryItem"/> with the specified GUID.
 /// </summary>
 /// <value></value>
 public DirectoryItem this[Guid Guid]
 {
     get
     {
         for (int q = 0; q < List.Count; q++)
         {
             DirectoryItem ei = (DirectoryItem)List[q];
             if (ei.GUID == Guid)
             {
                 return((DirectoryItem)List[q]);
             }
         }
         return(new DirectoryItem());
     }
     set
     {
         for (int q = 0; q < List.Count; q++)
         {
             DirectoryItem ei = (DirectoryItem)List[q];
             if (ei.GUID == Guid)
             {
                 List[q] = value;
                 break;
             }
         }
     }
 }
Esempio n. 2
0
 public OPMLDirectoryForm(DirectoryItem directoryItem)
 {
     //
     // Required for Windows Form Designer support
     //
     InitializeComponent();
     _directoryItem = directoryItem;
     //
     // TODO: Add any constructor code after InitializeComponent call
     //
 }
Esempio n. 3
0
 /// <summary>
 /// Removes the specified GUID.
 /// </summary>
 /// <param name="Guid">The GUID.</param>
 /// <returns></returns>
 public bool Remove(Guid GUID)
 {
     for (int q = 0; q < Count; q++)
     {
         DirectoryItem ei = (DirectoryItem)List[q];
         if (ei.GUID == GUID)
         {
             List.RemoveAt(q);
             return(true);
         }
     }
     return(false);
 }
Esempio n. 4
0
 private void DirectoryDropDown_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (DirectoryDropDown.Text != "- " + FormStrings.SelectDirectory + " -")
     {
         OPMLTreeView.Nodes.Clear();
         DirectoryItem dirItem       = (DirectoryItem)DirectoryDropDown.SelectedItem;
         OPMLRetriever opmlRetriever = new OPMLRetriever(dirItem);
         opmlRetriever.AddNode               += new AddNodeHandler(opmlRetriever_AddNode);
         opmlRetriever.AddNodeToNode         += new AddNodeToNodeHandler(opmlRetriever_AddNodeToNode);
         opmlRetriever.AddNodeToNodeWithText += new AddNodeToNodeWithTextHandler(opmlRetriever_AddNodeToNodeWithText);
         opmlRetriever.AddNodeWithText       += new AddNodeWithTextHandler(opmlRetriever_AddNodeWithText);
         Thread oThread = new Thread(new ThreadStart(opmlRetriever.populateTree));
         oThread.IsBackground = true;
         oThread.Start();
     }
     else
     {
         OPMLTreeView.Nodes.Clear();
     }
 }
Esempio n. 5
0
 public OPMLRetriever(DirectoryItem itemIn)
 {
     dirItem = itemIn;
 }
Esempio n. 6
0
        /// <summary>
        /// Adds the specified directory item.
        /// </summary>
        /// <param name="directoryItem">The directory item.</param>
        public void Add(DirectoryItem directoryItem)
        {
            directoryItem.GUID = System.Guid.NewGuid();

            List.Add(directoryItem);
        }
Esempio n. 7
0
 /// <summary>
 /// Sets the item.
 /// </summary>
 /// <param name="Index">The index.</param>
 /// <param name="Item">The item.</param>
 private void SetItem(int Index, DirectoryItem Item)
 {
     List[Index] = Item;
 }
Esempio n. 8
0
        private void populateTree()
        {
            Cursor.Current = Cursors.WaitCursor;
            OPMLTreeView.Nodes.Clear();
            OPMLTreeView.BeginUpdate();
            System.Net.WebClient Client = new WebClient();
            System.IO.Stream     strm   = null;
            string opmlUrl = "";

            try
            {
                DirectoryItem dirItem = (DirectoryItem)DirectoryDropDown.SelectedItem;
                opmlUrl = dirItem.URL;

                strm = Client.OpenRead(opmlUrl);

                XmlNodeList opmlCategories = null;
                XmlDocument doc            = new XmlDocument();

                doc.Load(opmlUrl);

                XmlNode body = doc.DocumentElement.SelectSingleNode("body");

                opmlCategories = body.SelectNodes("outline[not(@type='link')]");
                if (opmlCategories != null)
                {
                    foreach (XmlNode category in opmlCategories)
                    {
                        string strCat = "";
                        if (category.Attributes["title"] != null)
                        {
                            strCat = category.Attributes["title"].InnerText;
                        }
                        else
                        {
                            strCat = category.Attributes["text"].InnerText;
                        }
                        TreeNode catNode = OPMLTreeView.Nodes.Add(strCat);
                        catNode.ImageIndex         = 0;
                        catNode.SelectedImageIndex = 2;
                        // check if we have items at this level
                        XmlNodeList opmlEntries = category.SelectNodes("outline[(@type='link')]");
                        foreach (XmlNode opmlEntry in opmlEntries)
                        {
                            string strTitle = "";
                            if (opmlEntry.Attributes["title"] != null)
                            {
                                strTitle = opmlEntry.Attributes["title"].InnerText;
                            }
                            else
                            {
                                strTitle = opmlEntry.Attributes["text"].InnerText;
                            }
                            TreeNode entry = new TreeNode(strTitle);

                            string strXmlUrl = "";
                            if (opmlEntry.Attributes["xmlUrl"] != null)
                            {
                                strXmlUrl = opmlEntry.Attributes["xmlUrl"].InnerText;
                            }
                            else
                            {
                                strXmlUrl = opmlEntry.Attributes["url"].InnerText;
                            }
                            entry.Tag = strXmlUrl;
                            if (strXmlUrl.Substring(strXmlUrl.LastIndexOf(".") + 1).ToLower() == "opml")
                            {
                                entry.ImageIndex         = 0;
                                entry.SelectedImageIndex = 2;
                            }
                            else
                            {
                                entry.ImageIndex         = 1;
                                entry.SelectedImageIndex = 1;
                            }
                            catNode.Nodes.Add(entry);
                        }



                        GetCategories(category, catNode);
                    }

                    // check for root level items
                    XmlNodeList opmlOutlineEntries = body.SelectNodes("outline[@type='link']");
                    foreach (XmlNode opmlEntry in opmlOutlineEntries)
                    {
                        string strTitle = "";
                        if (opmlEntry.Attributes["title"] != null)
                        {
                            strTitle = opmlEntry.Attributes["title"].InnerText;
                        }
                        else
                        {
                            strTitle = opmlEntry.Attributes["text"].InnerText;
                        }
                        TreeNode entry     = new TreeNode(strTitle);
                        string   strXmlUrl = "";
                        if (opmlEntry.Attributes["xmlUrl"] != null)
                        {
                            strXmlUrl = opmlEntry.Attributes["xmlUrl"].InnerText;
                        }
                        else
                        {
                            strXmlUrl = opmlEntry.Attributes["url"].InnerText;
                        }
                        entry.Tag = strXmlUrl;
                        if (strXmlUrl.Substring(strXmlUrl.LastIndexOf(".") + 1).ToLower() == "opml")
                        {
                            entry.ImageIndex         = 0;
                            entry.SelectedImageIndex = 2;
                        }
                        else
                        {
                            entry.ImageIndex         = 1;
                            entry.SelectedImageIndex = 1;
                        }
                        OPMLTreeView.Nodes.Add(entry);
                    }
                    // end check
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
                MessageBox.Show("Error\n\n" + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
            }
            finally
            {
                if (strm != null)
                {
                    strm.Close();
                }
                OPMLTreeView.EndUpdate();
                Cursor.Current = Cursors.Default;
            }
        }