Ejemplo n.º 1
0
        private async void Subitem_Click(object sender, RoutedEventArgs e)
        {
            if (FilesProvidedEvent != null)
            {
                if (sender is MenuItem s)
                {
                    IEnumerable <string> files = null;
                    string tag     = s.Tag.ToString();
                    string content = s.Header.ToString();
                    try
                    {
                        switch (tag)
                        {
                        case "Albums":
                            files = iTunes.Filter(FilterKind.Album, content).Select(t => t.FilePath);
                            break;

                        case "Artists":
                            files = iTunes.Filter(FilterKind.Artist, content).Select(t => t.FilePath);
                            break;

                        case "Years":
                            files = iTunes.Filter(FilterKind.Year, content).Select(t => t.FilePath);
                            break;

                        case "Genres":
                            files = iTunes.Filter(FilterKind.Genre, content).Select(t => t.FilePath);
                            break;

                        case "Playlists":
                            files = iTunes.ReadPlaylist(content).Select(t => t.FilePath);
                            break;
                        }
                        FilesProvidedEvent.Invoke(this, files);
                    }
                    catch (Exception ex)
                    {
                        await App?.ShowMessageBox("Error", "Selection can't be loaded", DialogButtons.Ok);

                        App?.Log?.Exception(ex);
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private void Subitem_Click(object sender, RoutedEventArgs e)
        {
            if (FilesProvidedEvent != null)
            {
                if (sender is MenuItem s)
                {
                    IEnumerable <string> files = null;
                    string tag     = s.Tag.ToString();
                    string content = s.Header.ToString();
                    try
                    {
                        switch (tag)
                        {
                        case "Albums":
                            files = iTunes.Filter(FilterKind.Album, content).Select(t => t?.FilePath);
                            break;

                        case "Artists":
                            files = iTunes.Filter(FilterKind.Artist, content).Select(t => t?.FilePath);
                            break;

                        case "Years":
                            files = iTunes.Filter(FilterKind.Year, content).Select(t => t?.FilePath);
                            break;

                        case "Genres":
                            files = iTunes.Filter(FilterKind.Genre, content).Select(t => t?.FilePath);
                            break;

                        case "Playlists":
                            files = iTunes.ReadPlaylist(content).Select(t => t?.FilePath);
                            break;
                        }
                        FilesProvidedEvent?.Invoke(this, files);
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(Properties.Resources.Error_Title, ex.Message, MessageBoxButton.OK, MessageBoxImage.Error);
                    }
                }
            }
        }