private void Init(object sender, RoutedEventArgs e)
        {
            try
            {
                _songs.Clear();

                foreach (var song in _settings.DisabledSongs)
                {
                    _songs.Add(song);
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(
                    ex.InnerException.GetType().ToString() + "\n"
                    + ex.InnerException.Message + "\n"
                    + ex.InnerException.StackTrace + "\n"
                    );
            }

            Status.Content = "右クリックメニューから復元できます。";
        }
Beispiel #2
0
        public async Task RefreshListAsync(bool doShuffle = false)
        {
            try
            {
                if (!Directory.Exists(settings.OsuPath + @"\Songs"))
                {
                    MessageBox.Show("正しい osu! フォルダの場所を指定してください。", "osu! Player");
                    OpenSettings(null, null);
                    return;
                }

                IsSearching = true;
                StopSong();

                PlayingStatus.ToolTip = null;
                PlayingStatus.Content = "";
                PlayingTitle.Text     = "曲を検索しています";
                PlayingArtist.Text    = "しばらくお待ちください...";

                await Task.Run(() =>
                {
                    _songs.Clear();

                    var parent     = new DirectoryInfo(settings.OsuPath + @"\Songs");
                    var subFolders = parent.GetDirectories("*", SearchOption.TopDirectoryOnly);

                    if (doShuffle)
                    {
                        subFolders = subFolders.OrderBy(i => Guid.NewGuid()).ToArray();
                    }
                    foreach (var subFolder in subFolders)
                    {
                        try
                        {
                            var song = new Song(subFolder);
                            if (!song.IsBeatmap)
                            {
                                continue;
                            }
                            if (settings.DisabledSongs.Contains(song))
                            {
                                continue;
                            }
                            Dispatcher.BeginInvoke((Action)(() =>
                            {
                                _songs.Add(song);
                            }));
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message + "\n" + ex.StackTrace, ex.GetType().ToString());
                        }
                    }
                });

                PlayingStatus.Content = "";
                PlayingTitle.Text     = "曲を選択してください";
                PlayingArtist.Text    = "クリックして再生します...";
                IsSearching           = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + "\n" + ex.StackTrace, ex.GetType().ToString());
            }
        }