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 { } } }
public void AddAlbum(string URI) { top += 30; using (StreamReader SR = new StreamReader(URI)) { Label Nimda = new Label(); Nimda.AutoSize = true; Nimda.Text = SR.ReadLine(); Label Year = new Label(); Year.Text = "(" + DateTime.Now.Year.ToString() + ")"; Year.Font = new Font("Arial", 10); Year.ForeColor = Color.White; Nimda.Font = new Font("Arial Black", 10); top += 10; Nimda.Top = top; top += 40; Nimda.Left = 220; Nimda.ForeColor = Color.FromArgb(255, 255, 255); Year.Left = Nimda.Left + Nimda.Text.Length*(int)Nimda.Font.Size; Year.Top = Nimda.Top; PictureBox D = new PictureBox(); PictureBox C = new PictureBox(); C.BackgroundImage = Properties.Resources.cord; try { D.BackgroundImage = Bitmap.FromFile(folder + "\\" + "covers\\" + Nimda.Text + ".png"); } catch { D.BackgroundImage = Bitmap.FromFile(folder + "\\" + "covers\\" + Nimda.Text + ".jpg"); } D.BackgroundImageLayout = ImageLayout.Stretch; D.Width = 133; D.Height = 133; D.Left = 50; D.Top = top-30; C.Left = D.Left - 4; C.Top = D.Top - 3; C.Width = C.BackgroundImage.Width; C.Height = C.BackgroundImage.Height; int countTrack = 0; string track; int CD = 1; bool foundArtist = false; while ((track = SR.ReadLine()) != null) { String Artist = ""; String[] ds = track.Split(';'); if (ds.Length > 1) { Artist = ds[1]; } if (Artist == artist || (artist == "" && Artist == "")) foundArtist = true; } if (!foundArtist) { top -= 80; return; } SR.BaseStream.Seek(0, SeekOrigin.Begin); SR.ReadLine(); while ((track = SR.ReadLine()) != null) { string[] sp = track.Split(';'); if (track == "---") { top += 33; CDNotice Dx = new CDNotice(); Dx.Number = CD.ToString(); CD++; Dx.Left = 220; Dx.Top = top-23; this.contentPanel.Controls.Add(Dx); continue; } spotiEntry A = new spotiEntry(); A.Title = sp[0]; System.Media.SoundPlayer Ds = new SoundPlayer(folder + ("\\WAV\\" + sp[0].Replace(":", "_") + ".wav")); if (File.Exists(folder + ("\\WAV\\" + sp[0].Replace(":", "_") + ".wav"))) { decimal d = (decimal)GetDSSDuration((folder + ("\\WAV\\" + sp[0].Replace(":", "_") + ".wav"))); A.Length = Math.Round(d).ToString(); } A.Number = countTrack+1; A.Tag = (object)folder + ("\\WAV\\" + sp[0].Replace(":", "_") + ".wav"); A.Anchor = AnchorStyles.Right | AnchorStyles.Left; A.Anchor = ~AnchorStyles.Bottom; A.Top = top; A.Left = 220; A.Width = this.Width - 220; this.contentPanel.Controls.Add(A); countTrack++; A.Even = countTrack % 2 == 0; top += A.Height; if (sp.Length > 1 && sp[1] != artist) { A.Artist = sp[1]; } else { A.Artist = ""; } A.Unavailable = !File.Exists(folder + "\\WAV\\" + sp[0].Replace(":", "_") + ".wav"); } if (countTrack * 16 < D.Height + 40) { top += (D.Height + 20) - countTrack * 16; } else { top += 20; } this.contentPanel.Controls.Add(D); this.contentPanel.Controls.Add(C); this.contentPanel.Controls.Add(Nimda); this.contentPanel.Controls.Add(Year); Panel x = new Panel(); x.Left = 0; x.Top = top; x.Width = this.Width; x.Height = 1; x.BackColor = Color.Black; this.contentPanel.Controls.Add(x); x.Anchor = AnchorStyles.Right | AnchorStyles.Left; x.Anchor = ~AnchorStyles.Bottom; } }
private void timer3_Tick(object sender, EventArgs e) { try { Element Control = remaining.Pop(); switch (Control.Type) { case "Section": Section D = new Section(); D.Name = Control.GetAttribute("name"); this.Content.View.Sections.Add(D); break; case "sp:entry": spotiEntry entry = new spotiEntry(); entry.Title = Control.GetAttribute("name"); ContentPanel.Controls.Add(entry); entry.Tag = Control.GetAttribute("tag"); break; } } catch { } }