Beispiel #1
0
 /// <summary>
 /// SimpleView Constructor
 /// </summary>
 public SongViewModel(Song song, LibraryViewModel parent)
     : base(
         data: song,
         parent: parent,
         lazyLoadChildren: true)
 {
     Recording = null;
 }
Beispiel #2
0
 /// <summary>
 /// ClassicView & AlbumView Constructor
 /// </summary>
 public SongViewModel(Recording recording, bool isHome, LibraryViewModel parent)
     : base(
         data: recording.Song,
         parent: parent,
         lazyLoadChildren: true)
 {
     _isHome   = isHome;
     Recording = recording;
 }
Beispiel #3
0
        public LibraryViewModel(BaseData data, LibraryViewModel parent, bool lazyLoadChildren)
        {
            Data   = data;
            Parent = parent;

            if (lazyLoadChildren)
            {
                Children.Add(DummyChild);
            }
        }
Beispiel #4
0
        private IEnumerable <BaseData> ExtractContextAndIDs(MenuAction option)
        {
            IEnumerable <LibraryViewModel> selectedItems =
                ClassicTreeView.SelectedItems.OfType <LibraryViewModel>();

            LibraryContext context = LibraryContext.MAX;

            if (selectedItems.Count() > 0)
            {
                LibraryViewModel firstSelectedItem = selectedItems.First();

                if (firstSelectedItem is ArtistViewModel)
                {
                    context = LibraryContext.Artist;
                }
                else if (firstSelectedItem is AlbumViewModel)
                {
                    context = LibraryContext.Album;
                }
                else if (firstSelectedItem is SongViewModel)
                {
                    switch (option)
                    {
                    case MenuAction.Play:
                    case MenuAction.Add:
                        context = LibraryContext.Song;
                        break;

                    case MenuAction.Lyrics:
                    case MenuAction.Tags:
                    case MenuAction.Edit:
                        context = LibraryContext.Track;
                        break;

                    default:
                        throw new ArgumentException($"Unexpected MenuAction: {option}");
                    }
                }
                else if (firstSelectedItem is RecordingViewModel)
                {
                    context = LibraryContext.Recording;
                }

                if (context == LibraryContext.Track)
                {
                    return(selectedItems.Cast <SongViewModel>().Select(x => x.Recording));
                }
                else
                {
                    return(selectedItems.Select(x => x.Data));
                }
            }

            return(null);
        }
Beispiel #5
0
        private IEnumerable <BaseData> ExtractContextAndData(
            MenuAction option,
            ViewMode overrideMode = ViewMode.MAX)
        {
            IEnumerable <LibraryViewModel> selectedItems =
                GetSelectedItems(overrideMode).OfType <LibraryViewModel>();

            LibraryContext context = LibraryContext.MAX;

            if (selectedItems.Count() > 0)
            {
                LibraryViewModel firstSelectedItem = selectedItems.First();

                if (firstSelectedItem is ArtistViewModel artist)
                {
                    context = LibraryContext.Artist;
                }
                else if (firstSelectedItem is AlbumViewModel album)
                {
                    context = LibraryContext.Album;
                }
                else if (firstSelectedItem is SongViewModel song)
                {
                    switch (option)
                    {
                    case MenuAction.Play:
                    case MenuAction.Add:
                        context = LibraryContext.Song;
                        break;

                    case MenuAction.Lyrics:
                    case MenuAction.Tags:
                    case MenuAction.Edit:
                        if (song.Recording != null)
                        {
                            context = LibraryContext.Track;
                        }
                        else
                        {
                            context = LibraryContext.Song;
                        }
                        break;

                    default:
                        throw new ArgumentException($"Unexpected MenuAction: {option}");
                    }
                }
                else if (firstSelectedItem is RecordingViewModel recording)
                {
                    context = LibraryContext.Recording;
                }

                if (context == LibraryContext.Track)
                {
                    return(selectedItems.Cast <SongViewModel>().Select(x => x.Recording));
                }
                else
                {
                    return(selectedItems.Select(x => x.Data));
                }
            }

            return(new List <BaseData>());
        }