Example #1
0
        private void CreatePivots()
        {
            titlePivot = new Library.Code.V3.BrowsePivot(this, "title", "No titles were found.", new VirtualList(this, null));
            titlePivot.ContentLabel = this.Description;
            titlePivot.SetupContextMenu();
            titlePivot.LoadingContentMessage = "Loading trailers...";
            titlePivot.SupportsJIL           = false;
            titlePivot.ContentTemplate       = "resx://Library/Library.Resources/V3_Controls_BrowseGallery#Gallery";
            titlePivot.ContentItemTemplate   = "oneRowGalleryItemPoster";
            titlePivot.DetailTemplate        = Library.Code.V3.BrowsePivot.ExtendedDetailTemplate;
            titlePivot.IsBusy = true;
            this.Model.Pivots.Options.Add(titlePivot);
            //setting this as the default chosen pivot
            this.Model.Pivots.Chosen = titlePivot;

            dateAddedPivot = new Library.Code.V3.BrowsePivot(this, "date added", "No titles were found.", new VirtualList(this, null));
            dateAddedPivot.ContentLabel = this.Description;
            dateAddedPivot.SetupContextMenu();
            dateAddedPivot.LoadingContentMessage = "Loading trailers...";
            dateAddedPivot.SupportsJIL           = false;
            dateAddedPivot.ContentTemplate       = "resx://Library/Library.Resources/V3_Controls_BrowseGallery#Gallery";
            dateAddedPivot.ContentItemTemplate   = "oneRowGalleryItemPoster";
            dateAddedPivot.DetailTemplate        = Library.Code.V3.BrowsePivot.ExtendedDetailTemplate;
            dateAddedPivot.IsBusy = true;
            this.Model.Pivots.Options.Add(dateAddedPivot);


            genrePivot = new Library.Code.V3.BrowsePivot(this, "genres", "No titles were found.", new VirtualList(this, null));
            genrePivot.ContentLabel = this.Description;
            genrePivot.SetupContextMenu();
            genrePivot.LoadingContentMessage = "Loading trailers...";
            genrePivot.SupportsJIL           = true;
            genrePivot.ContentTemplate       = "resx://Library/Library.Resources/V3_Controls_BrowseGallery#Gallery";
            genrePivot.ContentItemTemplate   = "ListViewItem";
            genrePivot.DetailTemplate        = Library.Code.V3.BrowsePivot.ExtendedDetailTemplate;
            genrePivot.IsBusy = true;
            this.Model.Pivots.Options.Add(genrePivot);
        }
Example #2
0
        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;
        }