public TrailerPage(string description, TrailerGenreItem genre) : base() { //description this.Description = description; this.Model = new Library.Code.V3.BrowseModel(this); this.Model.Pivots = new Choice(this, "desc", new ArrayListDataSet(this)); base.CreateCommands(); }
private void ParseDocument(XmlDocument xDoc) { //this.trailers = new List<TrailerItem>(); XPathNavigator nav = xDoc.CreateNavigator(); XPathExpression expr; expr = nav.Compile("//*/genre/name[not(.=preceding::*/genre/name)] "); XPathNodeIterator iterator = nav.Select(expr); // Iterate on the node set //genres = new List<TrailerGenreItem>(); while (iterator.MoveNext()) { XPathNavigator nav2 = iterator.Current.Clone(); Application.DeferredInvoke(delegate { TrailerGenreItem genre = new TrailerGenreItem(this); genre.Description = nav2.Value; genre.Invoked += delegate(object genreSender, EventArgs genreArgs) { OMLProperties properties = new OMLProperties(); properties.Add("Application", OMLApplication.Current); properties.Add("I18n", I18n.Instance); Library.Code.V3.TrailerPage gallery = new Library.Code.V3.TrailerPage("trailers", genre); Command CommandContextPopOverlay = new Command(); properties.Add("CommandContextPopOverlay", CommandContextPopOverlay); //add name piv List <TrailerItem> nameTrailers = this.SortTrailersByName(genre.Trailers) as List <TrailerItem>; VirtualList nameGalleryList = new VirtualList(gallery, null); foreach (TrailerItem t in nameTrailers) { nameGalleryList.Add(t); } Library.Code.V3.BrowsePivot namePivot = new Library.Code.V3.BrowsePivot(gallery, "title", "No titles were found.", nameGalleryList); namePivot.ContentLabel = genre.Description; namePivot.SetupContextMenu(); namePivot.SupportsJIL = true; namePivot.ContentTemplate = "resx://Library/Library.Resources/V3_Controls_BrowseGallery#Gallery"; namePivot.ContentItemTemplate = "oneRowGalleryItemPoster"; namePivot.DetailTemplate = Library.Code.V3.BrowsePivot.ExtendedDetailTemplate; gallery.Model.Pivots.Options.Add(namePivot); gallery.Model.Pivots.Chosen = namePivot; List <TrailerItem> dateTrailers = this.SortTrailersByDate(genre.Trailers) as List <TrailerItem>; VirtualList dateGalleryList = new VirtualList(gallery, null); foreach (TrailerItem t in dateTrailers) { dateGalleryList.Add(t); } Library.Code.V3.BrowsePivot datePivot = new Library.Code.V3.BrowsePivot(gallery, "date added", "No titles were found.", dateGalleryList); datePivot.ContentLabel = genre.Description; datePivot.SetupContextMenu(); datePivot.SupportsJIL = true; datePivot.ContentTemplate = "resx://Library/Library.Resources/V3_Controls_BrowseGallery#Gallery"; datePivot.ContentItemTemplate = "oneRowGalleryItemPoster"; datePivot.DetailTemplate = Library.Code.V3.BrowsePivot.ExtendedDetailTemplate; gallery.Model.Pivots.Options.Add(datePivot); properties.Add("Page", gallery); OMLApplication.Current.Session.GoToPage(@"resx://Library/Library.Resources/V3_GalleryPage", properties); }; genres.Add(genre); }); } if (nav.MoveToChild("records", "")) { XPathNodeIterator nIter = nav.SelectChildren("movieinfo", ""); nav.MoveToFirstChild(); XPathNavigator localNav = nav.CreateNavigator(); nav.MoveToParent(); for (int i = 0; i < nIter.Count; i++) { Application.DeferredInvoke(delegate { TrailerItem currentTrailer = new TrailerItem(this); if (localNav.MoveToChild("info", "")) { currentTrailer.Copyright = GetChildNodesValue(localNav, "copyright"); currentTrailer.Tagline = GetChildNodesValue(localNav, "description"); currentTrailer.Director = GetChildNodesValue(localNav, "director"); //currentTrailer.Postdate = GetChildNodesValue(localNav, "postdate"); currentTrailer.Rating = GetChildNodesValue(localNav, "rating"); //currentTrailer.ReleaseDate = GetChildNodesValue(localNav, "releasedate"); string postdate = GetChildNodesValue(localNav, "postdate"); if (!string.IsNullOrEmpty(postdate)) { try { currentTrailer.Postdate = Convert.ToDateTime(postdate); } catch { currentTrailer.Postdate = new DateTime(1900, 1, 1); } } string releaseDate = GetChildNodesValue(localNav, "releasedate"); if (!string.IsNullOrEmpty(releaseDate)) { try { currentTrailer.ReleaseDate = Convert.ToDateTime(releaseDate); currentTrailer.MetadataTop = string.Format("{0}, in theaters {1}", currentTrailer.Rating, currentTrailer.ReleaseDate.ToString("D", CultureInfo.CreateSpecificCulture("en-US"))); } catch { currentTrailer.ReleaseDate = new DateTime(1900, 1, 1); } } currentTrailer.Runtime = GetChildNodesValue(localNav, "runtime"); currentTrailer.Studio = GetChildNodesValue(localNav, "studio"); currentTrailer.Metadata = currentTrailer.Studio; currentTrailer.Description = GetChildNodesValue(localNav, "title"); localNav.MoveToParent(); } if (localNav.MoveToChild("cast", "")) { XPathNodeIterator castIter = localNav.SelectChildren("name", ""); if (localNav.MoveToFirstChild()) { XPathNavigator castNav = localNav.CreateNavigator(); for (int j = 0; j < castIter.Count; j++) { currentTrailer.Actors.Add(castNav.Value); castNav.MoveToNext("name", ""); } localNav.MoveToParent(); } localNav.MoveToParent(); } if (localNav.MoveToChild("genre", "")) { XPathNodeIterator genreIter = localNav.SelectChildren("name", ""); if (localNav.MoveToFirstChild()) { XPathNavigator genreNav = localNav.CreateNavigator(); for (int k = 0; k < genreIter.Count; k++) { currentTrailer.Genres.Add(genreNav.Value); genreNav.MoveToNext("name", ""); } localNav.MoveToParent(); } localNav.MoveToParent(); } if (localNav.MoveToChild("poster", "")) { if (localNav.MoveToChild("location", "")) { currentTrailer.PosterUrl = localNav.Value; localNav.MoveToParent(); } if (localNav.MoveToChild("xlarge", "")) { currentTrailer.XLargePosterUrl = localNav.Value; localNav.MoveToParent(); } localNav.MoveToParent(); } if (localNav.MoveToChild("preview", "")) { if (localNav.MoveToChild(XPathNodeType.Element)) { currentTrailer.TrailerUrl = localNav.Value; currentTrailer.Filesize = localNav.GetAttribute("filesize", ""); localNav.MoveToParent(); } localNav.MoveToParent(); } trailers.Add(currentTrailer); //this could probably be done better foreach (string strGenre in currentTrailer.Genres) { foreach (TrailerGenreItem genre in this.genres) { if (strGenre == genre.Description) { genre.Trailers.Add(currentTrailer); break; } } } localNav.MoveToNext(); }); } } //return trailers; }