Exemple #1
0
        public ElementBase(IEventAggregator eventAggregatorInstance, ICachingService cachingServiceInstance, DIDLContainer container)
        {
            eventAggregator = eventAggregatorInstance;
            cachingService  = cachingServiceInstance;

            IsFolder             = true;
            ParentID             = container?.ParentID ?? string.Empty;
            Id                   = container?.Id ?? string.Empty;
            RefId                = container?.RefId ?? string.Empty;
            Restricted           = container.Restricted;
            ChildCount           = container.ChildCount;
            NumberOfAlbums       = container.NumberOfAlbums;
            Name                 = container?.Name ?? string.Empty;
            Class                = container?.Class ?? string.Empty;
            Section              = container?.Section ?? string.Empty;
            TotalPlayTime        = container?.TotalPlayTime ?? string.Empty;
            Title                = container?.Title ?? string.Empty;
            Date                 = container?.Date ?? string.Empty;
            Album                = container?.Album ?? string.Empty;
            OriginalTrackNumber  = 0;
            Artist               = container?.Artist ?? string.Empty;
            Genre                = container?.Genre ?? string.Empty;
            Creator              = container?.Creator ?? string.Empty;
            Description          = container?.Description ?? string.Empty;
            AlbumArtProfileId    = container?.AlbumArtUri?.ProfileId ?? string.Empty;
            AlbumArtUri          = container?.AlbumArtUri?.AlbumArtUri ?? "ms-appx:///Assets/disc_gray.png";
            Resource             = container?.Res?.Value ?? string.Empty;
            ResourceProtocolInfo = container?.Res?.ProtocolInfo ?? string.Empty;
            ResourceResolution   = container?.Res?.Resolution ?? string.Empty;
            ResourceSize         = container?.Res?.Size ?? string.Empty;
            if (TimeSpan.TryParse(container?.Res?.Duration ?? string.Empty, out TimeSpan timeSpan))
            {
                Duration = timeSpan.ToString(@"mm\:ss");
            }
            else
            {
                Duration = container?.Res?.Duration ?? string.Empty;
            }

            switch (container.Class)
            {
            case "object.container":
            case "object.container.albumContainer":
            case "object.container.favoritesContainer":
            case "object.container.genre.musicGenre":
            case "object.container.person.musicArtist":
            case "object.container.person.musicComposer":
                IsPlayable = false;
                break;

            case "object.container.album.musicAlbum":
            case "object.container.playlistContainer":
            case "object.container.playlistContainer.shuffle":
            case "object.container.storageFolder":
            case "object.container.trackContainer.allTracks":
            case "object.container.album.musicAlbum.compilation":
                IsPlayable = true;
                break;

            default:
                IsPlayable = false;
                break;
            }

            IsSelected           = false;
            IsSelectedVisibility = Visibility.Collapsed;
            Index = 0;

            VisibleCount = container.ChildCount > 0 ? container.ChildCount.ToString() : string.Empty;
            //VisibleCountVisibility = container.ChildCount > 0 ? Visibility.Visible : Visibility.Collapsed;
            VisibleCountVisibility = Visibility.Collapsed;

            Line1 = container?.Album ?? string.Empty;
            if (string.IsNullOrEmpty(container.Artist) || string.IsNullOrEmpty(container.Genre))
            {
                Line2 = string.Format("{0}{1}", container?.Artist ?? string.Empty, container?.Genre ?? string.Empty);
            }
            else
            {
                Line2 = string.Format("{0} - {1}", container?.Artist ?? string.Empty, container?.Genre ?? string.Empty);
            }

            Element         = this;
            BrowsedMetaData = string.Empty;

            fileName = $"{AlbumArtUri.ComputeMD5()}.png";
            eventAggregator.GetEvent <DataCachedEvent>().Subscribe(onDataCached, ThreadOption.UIThread, false,
                                                                   data => (data?.ID ?? string.Empty) == Id);

            IntializeCommand.Execute(null);
        }
Exemple #2
0
        public ElementBase(IEventAggregator eventAggregatorInstance, ICachingService cachingServiceInstance, DIDLItem item)
        {
            eventAggregator = eventAggregatorInstance;
            cachingService  = cachingServiceInstance;

            IsFolder             = false;
            ParentID             = item?.ParentID ?? string.Empty;
            Id                   = item?.Id ?? string.Empty;
            RefId                = item?.RefId ?? string.Empty;
            Restricted           = item.Restricted;
            ChildCount           = 0;
            NumberOfAlbums       = 0;
            Name                 = item?.Name ?? string.Empty;
            Class                = item?.Class ?? string.Empty;
            Section              = item?.Section ?? string.Empty;
            TotalPlayTime        = string.Empty;
            Title                = item?.Title ?? string.Empty;
            Date                 = string.Empty;
            Album                = item?.Album ?? string.Empty;
            OriginalTrackNumber  = item.OriginalTrackNumber;
            Artist               = item?.Artist ?? string.Empty;
            Genre                = item?.Genre ?? string.Empty;
            Creator              = item?.Creator ?? string.Empty;
            Description          = string.Empty;
            AlbumArtProfileId    = item?.AlbumArtUri?.ProfileId ?? string.Empty;
            AlbumArtUri          = item?.AlbumArtUri?.AlbumArtUri ?? "ms-appx:///Assets/disc_gray.png";
            Resource             = item?.Res?.Value ?? string.Empty;
            ResourceProtocolInfo = item?.Res?.ProtocolInfo ?? string.Empty;
            ResourceResolution   = item?.Res?.Resolution ?? string.Empty;
            ResourceSize         = item?.Res?.Size ?? string.Empty;
            if (TimeSpan.TryParse(item?.Res?.Duration ?? string.Empty, out TimeSpan timeSpan))
            {
                Duration = timeSpan.ToString(@"mm\:ss");
            }
            else
            {
                Duration = item?.Res?.Duration ?? string.Empty;
            }

            IsPlayable           = true;
            IsSelected           = false;
            IsSelectedVisibility = Visibility.Collapsed;
            Index = 0;

            VisibleCount           = item.OriginalTrackNumber > 0 ? item.OriginalTrackNumber.ToString() : string.Empty;
            VisibleCountVisibility = item.OriginalTrackNumber > 0 ? Visibility.Visible : Visibility.Collapsed;

            Line1 = item?.Album ?? string.Empty;
            if (string.IsNullOrEmpty(item.Artist) || string.IsNullOrEmpty(item.Genre))
            {
                Line2 = string.Format("{0}{1}", item?.Artist ?? string.Empty, item?.Genre ?? string.Empty);
            }
            else
            {
                Line2 = string.Format("{0} - {1}", item?.Artist ?? string.Empty, item?.Genre ?? string.Empty);
            }

            Element         = this;
            BrowsedMetaData = string.Empty;

            fileName = $"{AlbumArtUri.ComputeMD5()}.png";

            eventAggregator.GetEvent <DataCachedEvent>().Subscribe(onDataCached, ThreadOption.UIThread, false,
                                                                   name => (name?.FileName ?? string.Empty) == fileName);

            IntializeCommand.Execute(null);
        }