using MediaBrowser.Model.Dto; using MediaBrowser.UI.Controller; using MediaBrowser.UI.Controls; using MediaBrowser.UI.Playback; using MediaBrowser.UI.ViewModels; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; namespace MediaBrowser.Plugins.DefaultTheme.Controls.Details { /// /// Interaction logic for ItemChapters.xaml /// public partial class ItemChapters : BaseDetailsControl { /// /// Initializes a new instance of the class. /// public ItemChapters() { InitializeComponent(); lstItems.ItemInvoked += lstItems_ItemInvoked; } /// /// LSTs the items_ item invoked. /// /// The sender. /// The e. void lstItems_ItemInvoked(object sender, ItemEventArgs e) { var chapterViewModel = (ChapterInfoDtoViewModel) e.Argument; UIKernel.Instance.PlaybackManager.Play(new PlayOptions { Items = new List { Item }, StartPositionTicks = chapterViewModel.Chapter.StartPositionTicks }); } /// /// Called when [item changed]. /// protected override void OnItemChanged() { const double height = 297; var width = ChapterInfoDtoViewModel.GetChapterImageWidth(Item, height, 528); var chapters = Item.Chapters ?? new List { }; lstItems.ItemsSource = new ObservableCollection(chapters.Select(i => new ChapterInfoDtoViewModel { Item = Item, Chapter = i, ImageWidth = width, ImageHeight = height, ImageDownloadOptions = new ImageOptions { MaxHeight = 400 } })); } } }