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); }
public ElementContainer(DIDLContainer didl) { IsFolder = true; ParentID = didl?.ParentID ?? string.Empty; Id = didl?.Id ?? string.Empty; RefId = didl?.RefId ?? string.Empty; Restricted = didl.Restricted; ChildCount = didl.ChildCount; NumberOfAlbums = didl.NumberOfAlbums; Name = didl?.Name ?? string.Empty; Class = didl?.Class ?? string.Empty; Section = didl?.Section ?? string.Empty; TotalPlayTime = didl?.TotalPlayTime ?? string.Empty; Title = didl?.Title ?? string.Empty; Date = didl?.Date ?? string.Empty; Album = didl?.Album ?? string.Empty; OriginalTrackNumber = 0; Artist = didl?.Artist ?? string.Empty; Genre = didl?.Genre ?? string.Empty; Creator = didl?.Creator ?? string.Empty; Description = didl?.Description ?? string.Empty; AlbumArtProfileId = didl?.AlbumArtUri?.ProfileId ?? string.Empty; AlbumArtUri = didl?.AlbumArtUri?.AlbumArtUri ?? "ms-appx:///Assets/disc.png"; Resource = didl?.Res?.Value ?? string.Empty; ResourceProtocolInfo = didl?.Res?.ProtocolInfo ?? string.Empty; ResourceResolution = didl?.Res?.Resolution ?? string.Empty; ResourceSize = didl?.Res?.Size ?? string.Empty; if (TimeSpan.TryParse(didl?.Res?.Duration ?? string.Empty, out TimeSpan timeSpan)) { Duration = timeSpan.ToString(@"mm\:ss"); } else { Duration = didl?.Res?.Duration ?? string.Empty; } switch (didl.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 = didl.ChildCount > 0 ? didl.ChildCount.ToString() : string.Empty; VisibleCountVisibility = didl.ChildCount > 0 ? Visibility.Visible : Visibility.Collapsed; Line1 = didl?.Album ?? string.Empty; if (string.IsNullOrEmpty(didl.Artist) || string.IsNullOrEmpty(didl.Genre)) { Line2 = string.Format("{0}{1}", didl?.Artist ?? string.Empty, didl?.Genre ?? string.Empty); } else { Line2 = string.Format("{0} - {1}", didl?.Artist ?? string.Empty, didl?.Genre ?? string.Empty); } Element = this; BrowsedMetaData = string.Empty; }
public ElementContainer(IEventAggregator eventAggregatorInstance, DIDLContainer didl) : base(eventAggregatorInstance, didl) { //ImageArt = new BitmapImage(new Uri(AlbumArtUri, UriKind.Absolute)); //ImageArt.ImageFailed += OnImageFailed; //ImageArt.ImageOpened += OnImageOpened; }