示例#1
0
        /// <summary>
        /// Adds dynamic set of controls that are bound to a particular feed. They will be removed when updating the feed.
        /// </summary>
        /// <param name="Section">The section of the SpotiApp the feed will be applied to</param>
        /// <param name="elementType">Type of elements that can be created.</param>
        /// <param name="URI">The URI to the feed (must be RSS 2.0)</param>
        /// <param name="limit">The limit of amount elements to add</param>
        /// <param name="Location">Location of the feed</param>
        /// <param name="nspace">Space of the feed</param>
        /// <param name="Enter">Event that occur when the user activates the feed elements,</param>
        public void AddFeed(String Section,string elementType, string URI, int limit, Point Location, string nspace,EventHandler Enter)
        {
            try
            {
                XmlDocument DR = new XmlDocument();
                DR.Load(URI);

                int i = 0;

                foreach (XmlElement D in DR.GetElementsByTagName("item"))
                {
                    if (i == limit)
                    {
                        break;
                    }
                    string name = D.GetElementsByTagName("title")[0].InnerText;
                    string description = "";
                    try
                    {
                        description = D.GetElementsByTagName("description")[0].InnerText;
                    }
                    catch
                    {
                    }
                    string url = D.GetElementsByTagName("link")[0].InnerText;

                    Element Name = new Element(Location.X,Location.Y,120,32);
                    Name.Type = elementType;
                    Name.Attributes.Add(new Attribute() { name = "x", value = Location.X.ToString() });
                    Name.Attributes.Add(new Attribute() { name = "y", value = (Location.Y + i * 20).ToString() });
                    Name.Attributes.Add(new Attribute() { name = "title", value = name });
                    Name.Attributes.Add(new Attribute() { name = "href", value = url });
                    Name.Attributes.Add(new Attribute() { name = "artist", value = "Playlist" });
                    Name.Feed = nspace;
                    Name.OnClick += Enter;
                    Name.Attributes.Add(new Attribute() { name = "section", value = Section });
                    Name.Attributes.Add(new Attribute() { name = "size", value = "10" });
                    Name.Attributes.Add(new Attribute() { name = "name", value = "playlist-" + name });
                    Name.Attributes.Add(new Attribute() { name = "even", value = (i % 2 == 0).ToString() });
                    this.NewElements.Push(Name);
                    i++;
                }
            }
            catch
            {
            }
        }
示例#2
0
 void D_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
 {
     XmlDocument D = new XmlDocument();
     XmlDocument RS = new XmlDocument();
     RS.LoadXml(e.Result);
        foreach(XmlElement RN in RS.GetElementsByTagName("element"))
     {
         Element El = new Element(0,0,0,0);
         El.Feed = currentFeed.Name;
         foreach (XmlElement RNS in RN.GetElementsByTagName("attribute"))
         {
             Attribute r = new Attribute();
             r.name = RNS.GetAttribute("name");
             r.value = RNS.GetAttribute("value");
             El.Attributes.Add(r);
         }
         newElements.Push(El);
     }
        currentFeed = null;
 }