Example #1
0
 /// <summary>
 /// Adds a Button that shares a Spotify theme
 /// </summary>
 /// <param name="B">The UserControl of the target view</param>
 /// <param name="Text">The text of the button</param>
 /// <param name="Bounds">The Rectangle bounds</param>
 /// <param name="Click">A reference to a EventHandler handling the click on the button</param>
 /// <returns>Returns the new button</returns>
 public spotifyButton AddButton(UserControl B, string Text, Rectangle Bounds, EventHandler Click)
 {
     spotifyButton Button = new spotifyButton();
     Button.Label = Text;
     Button.Bounds = Bounds;
     Button.Click += new EventHandler(Click);
     B.Controls.Add(Button);
     return Button;
 }
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
                {
                }
            }
        }