Example #1
0
        /// <summary>
        /// Adds a cover image, for usage with a playlist or a album, like those in the artist view.
        /// </summary>
        /// <param name="B">UserControl of the target view</param>
        /// <param name="Source">The URL/Path to the image file</param>
        /// <param name="Location">The Point of the target Location</param>
        /// <returns>Cover</returns>
        public spotiImage AddImage(UserControl B, Image Source, Rectangle Location)
        {
            spotiImage Section = new  spotiImage();
            Section.Bounds = Location;

            Section.Picture = Source;

            B.Controls.Add(Section);
            return Section;
        }
Example #2
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (newElements.Count > 0)
            {

                Element D = newElements.Pop();
                Control F = new Control();
                Type d = Type.GetType(D.Type);
                switch (D.Type)
                {
                    case "sp:label":
                        F = new Label();
                        F.Text = D.GetAttribute("label");
                        ((Label)F).AutoSize = true;
                        F.Font = new Font("MS Sans Serif", int.Parse(D.GetAttribute("size")));
                        break;
                    case "sp:button":
                        F = new spotifyButton();
                        F.Click  += new EventHandler(F_Click);

                        break;
                    case "sp:group":

                        break;
                    case "sp:cover":
                        F = new spotiImage();
                        string ImageURI = D.GetAttribute("image");
                        Stream Fx;
                        if (ImageURI.StartsWith("http://"))
                        {
                            WebClient R = new WebClient();
                            Fx = R.OpenRead(ImageURI);
                        }
                        else
                        {
                            Fx = new FileStream(ImageURI, FileMode.Open);

                        }
                        ((spotiImage)F).Picture = Bitmap.FromStream(Fx);
                        Fx.Close();
                        break;
                    case "sp:link":
                        F = new LinkLabel();
                        F.Text = D.GetAttribute("label");
                        ((LinkLabel)F).AutoSize = true;
                        ((LinkLabel)F).LinkColor = Color.FromArgb(133, 133, 133);
                        F.Font = new Font("MS Sans Serif", int.Parse(D.GetAttribute("size")));
                        F.Click += new EventHandler(F_Click);
                        F.Tag = (object)D.GetAttribute("href");
                        ((LinkLabel)F).LinkBehavior = LinkBehavior.HoverUnderline;

                        break;
                    case "sp:entry":
                        F = new spotiEntry();
                        F.Text = D.GetAttribute("label");
                        ((spotiEntry)F).Title = D.GetAttribute("title");
                        ((spotiEntry)F).Artist=D.GetAttribute("artist");

                        F.Font = new Font("Tahoma", 8.25f);
                        F.DoubleClick += new EventHandler(F_Click);
                        F.Tag = (object)D.GetAttribute("href");
                        ((spotiEntry)F).Song = false;
                        break;
                    default:

                        F = (Control)Activator.CreateInstance(d);
                        /// Set object properties

                        foreach (Attribute Attribs in D.Attributes)
                        {
                            try
                            {
                                _PropertyInfo X = d.GetProperty(Attribs.name);
                                X.SetValue(F, Attribs.value, null);
                            }
                            catch
                            {
                            }
                        }
                        break;
                }
                try
                {

                    F.Left = int.Parse(D.GetAttribute("x"));
                    F.Top = int.Parse(D.GetAttribute("y"));
                    F.Width = int.Parse(D.GetAttribute("width"));
                    F.Height = int.Parse(D.GetAttribute("height"));

                }
                catch
                {
                }

                try
                {
                    F.Tag = (object)D;
                    this.sects[D.GetAttribute("section")].Controls.Add(F);
                    elements.Add(D.GetAttribute("Name"), F);
                    if (F.GetType() == typeof(spotiEntry))
                    {
                        ((spotiEntry)F).Even = bool.Parse(D.GetAttribute("even"));
                        ((spotiEntry)F).OldColor = F.BackColor;
                    }
                }
                catch
                {
                }
            }
        }