コード例 #1
0
 public static void PlayNew(SongControl s)
 {
     if (PlayingSongs != null)
     {
         PlayingSongs.StopPlayback();
     }
     PlayingSongs = s;
     PlayingSongs.StartPlayback();
 }
コード例 #2
0
ファイル: Form1.cs プロジェクト: zolcsieles/NoodleManager
        private void DownloadCompleteCallback(object sender, DownloadStringCompletedEventArgs e)
        {
            if (!e.Cancelled && e.Error == null && e.Result != null && e.Result != "")
            {
                GlobalVariables.Available = 0;
                byte[]     bytes   = Encoding.Default.GetBytes(e.Result);
                string     content = Encoding.UTF8.GetString(bytes);
                SongInfo[] items   = new SongInfo[1];
                try
                {
                    items = JsonConvert.DeserializeObject <SongInfo[]>(content);
                }
                catch
                {
                    items[0] = JsonConvert.DeserializeObject <SongInfo>(content);
                }

                foreach (SongInfo item in items)
                {
                    if (GlobalVariables.downloadingSongs.Where(i => i.id == item.id).Count() > 0)
                    {
                        Console.WriteLine("already exists");
                        this.Invoke((MethodInvoker) delegate
                        {
                            RemoveDuplicates(item.id);
                            this.songMenu.tableLayoutPanel.Controls.Add(GlobalVariables.downloadingSongs.Where(i => i.id == item.id).ElementAt(0));
                        });
                    }
                    else
                    {
                        SongControl song = new SongControl();
                        song.downloadPath             = baseurl + item.download_url;
                        song.previewPath              = baseurl + item.preview_url;
                        song.originalFilename         = item.filename_original;
                        song.coverImage.ImageLocation = baseurl + item.cover_url + "?size=150";
                        song.songName.Text            = item.title;
                        song.mapperName.Text          = item.mapper;
                        song.difficulties             = item.difficulties;
                        song.artist.Text              = item.artist;
                        song.duration.Text            = item.duration;
                        song.id = item.id;

                        foreach (string difficulty in item.difficulties)
                        {
                            if (difficulty.Equals("Easy"))
                            {
                                song.Easy.ForeColor = System.Drawing.Color.White;
                            }
                            else if (difficulty.Equals("Normal"))
                            {
                                song.Normal.ForeColor = System.Drawing.Color.White;
                            }
                            else if (difficulty.Equals("Hard"))
                            {
                                song.Hard.ForeColor = System.Drawing.Color.White;
                            }
                            else if (difficulty.Equals("Expert"))
                            {
                                song.Expert.ForeColor = System.Drawing.Color.White;
                            }
                            else if (difficulty.Equals("Master"))
                            {
                                song.Master.ForeColor = System.Drawing.Color.White;
                            }
                        }

                        if (this.songMenu.tableLayoutPanel.Controls.Count < 180)
                        {
                            this.Invoke((MethodInvoker) delegate
                            {
                                RemoveDuplicates(song.id);

                                this.songMenu.tableLayoutPanel.Controls.Add(song);
                            });
                        }

                        if (File.Exists(Properties.Settings.Default.path + @"\CustomSongs\" + item.filename_original))
                        {
                            this.Invoke((MethodInvoker) delegate
                            {
                                song.Deactivate();

                                if (this.displayMode.SelectedIndex == 1)
                                {
                                    this.songMenu.tableLayoutPanel.Controls.Remove(song);
                                }
                            });
                        }
                        else
                        {
                            GlobalVariables.Available++;
                            if (this.displayMode.SelectedIndex == 2)
                            {
                                this.songMenu.tableLayoutPanel.Controls.Remove(song);
                            }
                            if (sender != null && downloadMarker.Contains(sender))
                            {
                                this.Invoke((MethodInvoker) delegate
                                {
                                    song.Download();
                                });
                            }
                        }
                    }
                }
                this.Invoke((MethodInvoker) delegate
                {
                    this.songMenu.tableLayoutPanel.Visible = true;
                });
            }
            this.Invoke((MethodInvoker) delegate
            {
                foreach (SongControl c in GlobalVariables.downloadingSongs)
                {
                    if (!this.songMenu.tableLayoutPanel.Controls.Contains(c) && this.songMenu.tableLayoutPanel.Controls.Count < 180)
                    {
                        this.songMenu.tableLayoutPanel.Controls.Add(c);
                    }
                }
                this.Cursor = Cursors.Default;
            });
            downloadMarker.Remove((WebClient)sender);
        }