コード例 #1
0
 private void ResetDeviceContentType(IList <DeviceItemViewModel> items, IEnumerable <Tuple <ZmdbPropertyList, DeviceItemType> > models, CollectionViewSource viewSource)
 {
     if (this.Device != null)
     {
         for (int i = items.Count - 1; i >= 0; i--)
         {
             DeviceItemViewModel model = items[i];
             object         obj2       = null;
             DeviceItemType other      = DeviceItemType.Other;
             foreach (Tuple <ZmdbPropertyList, DeviceItemType> tuple in models)
             {
                 if (tuple.Item1.TryGetValue(model.ZmdbId, out obj2))
                 {
                     tuple.Item1.Remove(model.ZmdbId);
                     other = tuple.Item2;
                     break;
                 }
             }
             if (obj2 != null)
             {
                 model.UpdateProperties((ZmdbPropertyList)obj2, other);
             }
             else
             {
                 items.RemoveAt(i);
             }
         }
         foreach (Tuple <ZmdbPropertyList, DeviceItemType> tuple2 in models)
         {
             foreach (KeyValuePair <string, object> pair in tuple2.Item1)
             {
                 DeviceItemViewModel model3 = new DeviceItemViewModel {
                     ZmdbId = pair.Key
                 };
                 DeviceItemViewModel item = model3;
                 item.UpdateProperties((ZmdbPropertyList)pair.Value, tuple2.Item2);
                 items.Add(item);
             }
         }
     }
     else
     {
         items.Clear();
     }
     using (viewSource.View.DeferRefresh())
     {
         foreach (SortDescription description in viewSource.SortDescriptions)
         {
             viewSource.View.SortDescriptions.Remove(description);
             viewSource.View.SortDescriptions.Add(description);
         }
     }
 }
コード例 #2
0
        public void UpdateProperties(ZmdbPropertyList properties, DeviceItemType type)
        {
            if (properties != null)
            {
                this.ZmdbProperties = properties;
                this.ItemType = type;
                this.Location = MakeLocationString(properties[ZMEDIAITEM_INTATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_STORAGELOCATION]);
                string str = properties[ZMEDIAITEM_STRINGATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_NAME];
                this.Name = !string.IsNullOrWhiteSpace(str) ? str : properties[ZMEDIAITEM_STRINGATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_FILENAME];
                if (this.Name == null)
                {
                    this.Name = string.Empty;
                }
                int? nullable3 = properties[ZMEDIAITEM_INTATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_FILESIZE];
                ulong? sizeInBytes = nullable3.HasValue ? new ulong?((ulong) ((long) nullable3.GetValueOrDefault())) : null;
                this.Size = StringUtilities.MakeSizeString(sizeInBytes);
                ulong? nullable5 = sizeInBytes;
                this.ZmdbSize = nullable5.HasValue ? nullable5.GetValueOrDefault() : ((ulong) 0L);
                if (((type == DeviceItemType.Music) || (type == DeviceItemType.AudioPodcast)) || (type == DeviceItemType.VideoPodcast))
                {
                    this.Artist = properties[ZMEDIAITEM_STRINGATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_ARTIST] ?? string.Empty;
                }
                if (((type == DeviceItemType.Music) || (type == DeviceItemType.Video)) || ((type == DeviceItemType.AudioPodcast) || (type == DeviceItemType.VideoPodcast)))
                {
                    int? nullable6 = properties[ZMEDIAITEM_INTATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_DURATION];
                    long? ms = nullable6.HasValue ? new long?((long) nullable6.GetValueOrDefault()) : null;
                    this.Duration = StringUtilities.MakeTimeString(ms);
                    long? nullable8 = ms;
                    this.ZmdbDuration = nullable8.HasValue ? nullable8.GetValueOrDefault() : 0L;
                }
                switch (type)
                {
                    case DeviceItemType.Photo:
                    {
                        string str2 = properties[ZMEDIAITEM_STRINGATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_FILEPATH];
                        this.Album = !string.IsNullOrWhiteSpace(str2) ? (Path.GetFileName(Path.GetDirectoryName(str2)) ?? string.Empty) : string.Empty;
                        return;
                    }
                    case DeviceItemType.Music:
                    {
                        this.Album = properties[ZMEDIAITEM_STRINGATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_ALBUM] ?? string.Empty;
                        int? nullable9 = properties[ZMEDIAITEM_INTATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_DISKNUMBER];
                        this.Disk = nullable9.HasValue ? nullable9.GetValueOrDefault() : 0;
                        int? nullable10 = properties[ZMEDIAITEM_INTATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_TRACKNUMBER];
                        this.Track = nullable10.HasValue ? nullable10.GetValueOrDefault() : 0;
                        return;
                    }
                    case DeviceItemType.Video:
                        return;

                    case DeviceItemType.AudioPodcast:
                        this.Album = properties[ZMEDIAITEM_STRINGATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_PODCASTSERIES] ?? string.Empty;
                        return;

                    case DeviceItemType.VideoPodcast:
                        this.Album = properties[ZMEDIAITEM_STRINGATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_VIDEOSERIES] ?? string.Empty;
                        return;
                }
            }
        }
コード例 #3
0
        public void UpdateProperties(ZmdbPropertyList properties, DeviceItemType type)
        {
            if (properties != null)
            {
                this.ZmdbProperties = properties;
                this.ItemType       = type;
                this.Location       = MakeLocationString(properties[ZMEDIAITEM_INTATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_STORAGELOCATION]);
                string str = properties[ZMEDIAITEM_STRINGATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_NAME];
                this.Name = !string.IsNullOrWhiteSpace(str) ? str : properties[ZMEDIAITEM_STRINGATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_FILENAME];
                if (this.Name == null)
                {
                    this.Name = string.Empty;
                }
                int?  nullable3   = properties[ZMEDIAITEM_INTATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_FILESIZE];
                ulong?sizeInBytes = nullable3.HasValue ? new ulong?((ulong)((long)nullable3.GetValueOrDefault())) : null;
                this.Size = StringUtilities.MakeSizeString(sizeInBytes);
                ulong?nullable5 = sizeInBytes;
                this.ZmdbSize = nullable5.HasValue ? nullable5.GetValueOrDefault() : ((ulong)0L);
                if (((type == DeviceItemType.Music) || (type == DeviceItemType.AudioPodcast)) || (type == DeviceItemType.VideoPodcast))
                {
                    this.Artist = properties[ZMEDIAITEM_STRINGATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_ARTIST] ?? string.Empty;
                }
                if (((type == DeviceItemType.Music) || (type == DeviceItemType.Video)) || ((type == DeviceItemType.AudioPodcast) || (type == DeviceItemType.VideoPodcast)))
                {
                    int? nullable6 = properties[ZMEDIAITEM_INTATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_DURATION];
                    long?ms        = nullable6.HasValue ? new long?((long)nullable6.GetValueOrDefault()) : null;
                    this.Duration = StringUtilities.MakeTimeString(ms);
                    long?nullable8 = ms;
                    this.ZmdbDuration = nullable8.HasValue ? nullable8.GetValueOrDefault() : 0L;
                }
                switch (type)
                {
                case DeviceItemType.Photo:
                {
                    string str2 = properties[ZMEDIAITEM_STRINGATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_FILEPATH];
                    this.Album = !string.IsNullOrWhiteSpace(str2) ? (Path.GetFileName(Path.GetDirectoryName(str2)) ?? string.Empty) : string.Empty;
                    return;
                }

                case DeviceItemType.Music:
                {
                    this.Album = properties[ZMEDIAITEM_STRINGATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_ALBUM] ?? string.Empty;
                    int?nullable9 = properties[ZMEDIAITEM_INTATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_DISKNUMBER];
                    this.Disk = nullable9.HasValue ? nullable9.GetValueOrDefault() : 0;
                    int?nullable10 = properties[ZMEDIAITEM_INTATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_TRACKNUMBER];
                    this.Track = nullable10.HasValue ? nullable10.GetValueOrDefault() : 0;
                    return;
                }

                case DeviceItemType.Video:
                    return;

                case DeviceItemType.AudioPodcast:
                    this.Album = properties[ZMEDIAITEM_STRINGATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_PODCASTSERIES] ?? string.Empty;
                    return;

                case DeviceItemType.VideoPodcast:
                    this.Album = properties[ZMEDIAITEM_STRINGATTRIBUTE.ZMEDIAITEM_ATTRIBUTE_VIDEOSERIES] ?? string.Empty;
                    return;
                }
            }
        }