using MediaBrowser.Model.Dto; using MediaBrowser.Model.Net; using MediaBrowser.UI; using MediaBrowser.UI.Controller; using MediaBrowser.UI.Controls; using MediaBrowser.UI.Playback; using MediaBrowser.UI.ViewModels; using System.Collections.Generic; using System.Linq; namespace MediaBrowser.Plugins.DefaultTheme.Controls.Details { /// /// Interaction logic for ItemSpecialFeatures.xaml /// public partial class ItemSpecialFeatures : BaseDetailsControl { /// /// Initializes a new instance of the class. /// public ItemSpecialFeatures() { InitializeComponent(); lstItems.ItemInvoked += lstItems_ItemInvoked; } /// /// LSTs the items_ item invoked. /// /// The sender. /// The e. void lstItems_ItemInvoked(object sender, ItemEventArgs e) { var viewModel = (SpecialFeatureViewModel) e.Argument; UIKernel.Instance.PlaybackManager.Play(new PlayOptions { Items = new List { viewModel.Item } }); } /// /// Called when [item changed]. /// protected override async void OnItemChanged() { BaseItemDto[] result; try { result = await UIKernel.Instance.ApiClient.GetSpecialFeaturesAsync(App.Instance.CurrentUser.Id, Item.Id); } catch (HttpException) { App.Instance.ShowDefaultErrorMessage(); return; } var resultItems = result ?? new BaseItemDto[] { }; const int height = 297; var aspectRatio = DtoBaseItemViewModel.GetAveragePrimaryImageAspectRatio(resultItems); var width = aspectRatio == 0 ? 528 : height * aspectRatio; lstItems.ItemsSource = resultItems.Select(i => new SpecialFeatureViewModel { Item = i, ImageHeight = height, ImageWidth = width }).ToList(); } } }