Exemplo n.º 1
0
        public EpisodeItem(Title title, IModelItem owner)
            : base(owner)
        {
            this._titleObj = title;
            //this.InternalMovieItem = new Library.MovieItem(title, null);

            this.ItemType = 0;
            if(OMLEngine.Settings.OMLSettings.ShowUnwatchedIcon)
                this.OverlayContentTemplate = "resx://Library/Library.Resources/V3_Controls_BrowseGalleryItem#UnwatchedOverlay";
            if (this._titleObj.WatchedCount == 0)
                this.isUnwatched = true;

            DateTime releaseDate = Convert.ToDateTime(_titleObj.ReleaseDate.ToString("MMMM dd, yyyy"));// new DateTime(2000, 1, 1);
            //invalid dates
            if (releaseDate.Year != 1 && releaseDate.Year != 1900)
                this.MetadataTop = releaseDate.Year.ToString();
            else
                this.MetadataTop = "";

            this.ItemId = 1;
            string starRating = Convert.ToString(Math.Round((Convert.ToDouble(_titleObj.UserStarRating.HasValue ? _titleObj.UserStarRating.Value : 0) * 0.8), MidpointRounding.AwayFromZero));
            this.StarRating = starRating;
            string extendedMetadata = string.Empty;

            this.SortName = title.SortName;

            //this.Metadata = this.InternalMovieItem.Rating.Replace("PG13", "PG-13").Replace("NC17", "NC-17");
            this.Metadata = _titleObj.ParentalRating;
            if (string.IsNullOrEmpty(_titleObj.ParentalRating))
                this.Metadata = "Not Rated";
            if (_titleObj.Runtime.ToString() != "0")
                this.Metadata += string.Format(", {0} minutes", _titleObj.Runtime.ToString());
            this.Tagline = _titleObj.Synopsis;

            this.Description = title.Name;

            //TODO: not sure how to read this yet...
            //temporarially disabled due to bug in eagerloading
            //this.SimpleVideoFormat = _titleObj.VideoFormat.ToString();

            this.Invoked += delegate(object sender, EventArgs args)
            {

                //to test v3
                Library.Code.V3.DetailsPage page = new Library.Code.V3.DetailsPage();

                page.Description = "episode details";
                page.Title = this.Description;
                page.Summary = _titleObj.Synopsis;
                page.Background = this.DefaultImage;

                page.Details = new Library.Code.V3.ExtendedDetails();

                page.Details.CastArray = new ArrayListDataSet();

                string directors = string.Empty;
                int directorCount = 0;
                foreach (Person director in _titleObj.Directors)
                {
                    Library.Code.V3.CastCommand directorCommand = new Library.Code.V3.CastCommand();
                    directorCommand.Role = " ";
                    directorCommand.Description = director.full_name;
                    directorCommand.Invoked += new EventHandler(actorCommand_Invoked);
                    if (directorCount == 0)
                    {
                        directorCommand.CastType = "TitleAndDesc";
                        directorCommand.GroupTitle = "DIRECTOR";
                        directorCommand.ActorId = 1;//not sure how this works in oml
                    }
                    else
                        directorCommand.CastType = "Desc";
                    page.Details.CastArray.Add(directorCommand);
                    directorCount++;
                    AppendSeparatedValue(ref directors, director.full_name, "; ");
                }
                if (!string.IsNullOrEmpty(directors))
                    page.Details.Director = string.Format("Directed By: {0}", directors);

                string cast = string.Empty;
                int actorCount = 0;
                foreach (Role kvp in _titleObj.ActingRoles)
                {
                    Library.Code.V3.CastCommand actorCommand = new Library.Code.V3.CastCommand();
                    actorCommand.Description = kvp.PersonName;
                    actorCommand.ActorId = 1;//not sure how this works in oml
                    actorCommand.Invoked += new EventHandler(actorCommand_Invoked);
                    actorCommand.Role = kvp.RoleName;
                    if (actorCount == 0)
                    {
                        //add the title "CAST"
                        actorCommand.CastType = "TitleAndDesc";
                        actorCommand.GroupTitle = "CAST";
                    }
                    else
                        actorCommand.CastType = "Desc";

                    page.Details.CastArray.Add(actorCommand);
                    actorCount++;
                    AppendSeparatedValue(ref cast, kvp.PersonName, "; ");
                }

                //foreach (string castmember in this.InternalMovieItem.Actors)
                //{
                //    AppendSeparatedValue(ref cast, castmember, "; ");
                //}
                if (!string.IsNullOrEmpty(cast))
                    page.Details.Cast = string.Format("Cast Info: {0}", cast);

                if (this.StarRating != "0")
                    page.Details.StarRating = new Image(string.Format("resx://Library/Library.Resources/V3_Controls_Common_Stars_{0}", starRating));

                //strip invalid dates
                if (releaseDate.Year != 1 && releaseDate.Year != 1900)
                    page.Details.YearString = releaseDate.Year.ToString();

                page.Details.Studio = _titleObj.Studio;

                string genres = string.Empty;
                if (_titleObj.Genres.Count > 0)
                {
                    foreach (string genre in _titleObj.Genres)
                    {
                        AppendSeparatedValue(ref genres, genre, ", ");
                    }
                }
                AppendSeparatedValue(ref genres, this.Metadata, ", ");
                page.Details.GenreRatingandRuntime = genres;

                //fixes double spacing issues
                page.Details.Summary = _titleObj.Synopsis.Replace("\r\n", "\n");
                page.Commands = new ArrayListDataSet(page);
                //default play command
                Command playCmd = new Command();
                playCmd.Description = "Play";
                playCmd.Invoked += new EventHandler(playCmd_Invoked);
                page.Commands.Add(playCmd);

                if (page.Details.CastArray.Count > 0)
                {
                    Command command = new Command();
                    command.Description = "Cast + More";

                    command.Invoked += delegate(object castSender, EventArgs castArgs)
                    {
                        Dictionary<string, object> castProperties = new Dictionary<string, object>();
                        castProperties["Page"] = page;
                        castProperties["Application"] = Library.OMLApplication.Current;
                        Library.OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_DetailsPageCastCrew", castProperties);
                    };

                    page.Commands.Add(command);
                }

                page.Watched = new BooleanChoice(this, "Watched");

                //is this the right way?
                // yes :)
                if (_titleObj.WatchedCount > 0)
                    page.Watched.Value = true;
                else
                    page.Watched.Value = false;

                page.Watched.ChosenChanged += new EventHandler(Watched_ChosenChanged);

                this.SetFanArtImage(page.Details, _titleObj);

                Dictionary<string, object> properties = new Dictionary<string, object>();
                properties["Page"] = page;
                properties["Application"] = Library.OMLApplication.Current;

                if (page.Details.FanArt!=null)
                    Library.OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_FanArtDetailsPage", properties);
                else
                    Library.OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_EpisodeDetailsPage", properties);
            };
        }
Exemplo n.º 2
0
        public MovieItem(Title title, IModelItem owner)
            : base(owner)
        {
            this._titleObj = title;
            this.setCoverArtThemeId(title.Name);
            //this.InternalMovieItem = new Library.MovieItem(title, null);

            this.ItemType = 0;
            if (OMLEngine.Settings.OMLSettings.ShowUnwatchedIcon)
            {
                this.OverlayContentTemplate = "resx://Library/Library.Resources/V3_Controls_BrowseGalleryItem#UnwatchedOverlay";
            }
            if (this._titleObj.WatchedCount == 0)
            {
                this.isUnwatched = true;
            }

            DateTime releaseDate = Convert.ToDateTime(_titleObj.ReleaseDate.ToString("MMMM dd, yyyy"));// new DateTime(2000, 1, 1);

            //invalid dates
            if (releaseDate.Year != 1 && releaseDate.Year != 1900)
            {
                this.MetadataTop = releaseDate.Year.ToString();
            }
            else
            {
                this.MetadataTop = "";
            }

            this.ItemId = 1;
            string starRating = Convert.ToString(Math.Round((Convert.ToDouble(_titleObj.UserStarRating.HasValue ? _titleObj.UserStarRating.Value : 0) * 0.8), MidpointRounding.AwayFromZero));

            this.StarRating = starRating;
            string extendedMetadata = string.Empty;

            this.SortName = title.SortName;

            //this.Metadata = this.InternalMovieItem.Rating.Replace("PG13", "PG-13").Replace("NC17", "NC-17");
            this.Metadata = _titleObj.ParentalRating;
            if (string.IsNullOrEmpty(_titleObj.ParentalRating))
            {
                this.Metadata = "Not Rated";
            }
            if (_titleObj.Runtime.ToString() != "0")
            {
                this.Metadata += string.Format(", {0} minutes", _titleObj.Runtime.ToString());
            }
            this.Tagline = _titleObj.Synopsis;

            this.Description = title.Name;

            //TODO: not sure how to read this yet...
            //temporarially disabled due to bug in eagerloading
            //this.SimpleVideoFormat = _titleObj.VideoFormat.ToString();


            this.Invoked += delegate(object sender, EventArgs args)
            {
                //to test v3
                Library.Code.V3.DetailsPage page = new Library.Code.V3.DetailsPage();

                page.Description = "movie details";
                page.Title       = this.Description;
                page.Summary     = _titleObj.Synopsis;
                page.Background  = this.DefaultImage;

                page.Details = new Library.Code.V3.ExtendedDetails();

                page.Details.CastArray = new ArrayListDataSet();

                string directors     = string.Empty;
                int    directorCount = 0;
                foreach (Person director in _titleObj.Directors)
                {
                    Library.Code.V3.CastCommand directorCommand = new Library.Code.V3.CastCommand();
                    directorCommand.Role        = " ";
                    directorCommand.Description = director.full_name;
                    directorCommand.Invoked    += new EventHandler(actorCommand_Invoked);
                    if (directorCount == 0)
                    {
                        directorCommand.CastType   = "TitleAndDesc";
                        directorCommand.GroupTitle = "DIRECTOR";
                        directorCommand.ActorId    = 1;//not sure how this works in oml
                    }
                    else
                    {
                        directorCommand.CastType = "Desc";
                    }
                    page.Details.CastArray.Add(directorCommand);
                    directorCount++;
                    AppendSeparatedValue(ref directors, director.full_name, "; ");
                }
                if (!string.IsNullOrEmpty(directors))
                {
                    page.Details.Director = string.Format("Directed By: {0}", directors);
                }

                string cast       = string.Empty;
                int    actorCount = 0;
                foreach (Role kvp in _titleObj.ActingRoles)
                {
                    Library.Code.V3.CastCommand actorCommand = new Library.Code.V3.CastCommand();
                    actorCommand.Description = kvp.PersonName;
                    actorCommand.ActorId     = 1;//not sure how this works in oml
                    actorCommand.Invoked    += new EventHandler(actorCommand_Invoked);
                    actorCommand.Role        = kvp.RoleName;
                    if (actorCount == 0)
                    {
                        //add the title "CAST"
                        actorCommand.CastType   = "TitleAndDesc";
                        actorCommand.GroupTitle = "CAST";
                    }
                    else
                    {
                        actorCommand.CastType = "Desc";
                    }

                    page.Details.CastArray.Add(actorCommand);
                    actorCount++;
                    AppendSeparatedValue(ref cast, kvp.PersonName, "; ");
                }

                //foreach (string castmember in this.InternalMovieItem.Actors)
                //{
                //    AppendSeparatedValue(ref cast, castmember, "; ");
                //}
                if (!string.IsNullOrEmpty(cast))
                {
                    page.Details.Cast = string.Format("Cast Info: {0}", cast);
                }


                if (this.StarRating != "0")
                {
                    page.Details.StarRating = new Image(string.Format("resx://Library/Library.Resources/V3_Controls_Common_Stars_{0}", starRating));
                }

                //strip invalid dates
                if (releaseDate.Year != 1 && releaseDate.Year != 1900)
                {
                    page.Details.YearString = releaseDate.Year.ToString();
                }

                page.Details.Studio = _titleObj.Studio;

                string genres = string.Empty;
                if (_titleObj.Genres.Count > 0)
                {
                    foreach (string genre in _titleObj.Genres)
                    {
                        AppendSeparatedValue(ref genres, genre, ", ");
                    }
                }
                AppendSeparatedValue(ref genres, this.Metadata, ", ");
                page.Details.GenreRatingandRuntime = genres;

                //fixes double spacing issues
                page.Details.Summary = _titleObj.Synopsis.Replace("\r\n", "\n");
                page.Commands        = new ArrayListDataSet(page);
                //default play command
                Command playCmd = new Command();
                playCmd.Description = "Play";
                playCmd.Invoked    += new EventHandler(playCmd_Invoked);
                page.Commands.Add(playCmd);

                if (page.Details.CastArray.Count > 0)
                {
                    Command command = new Command();
                    command.Description = "Cast + More";

                    command.Invoked += delegate(object castSender, EventArgs castArgs)
                    {
                        Dictionary <string, object> castProperties = new Dictionary <string, object>();
                        castProperties["Page"]        = page;
                        castProperties["Application"] = Library.OMLApplication.Current;
                        Library.OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_DetailsPageCastCrew", castProperties);
                    };

                    page.Commands.Add(command);
                }

                if (Properties.Settings.Default.AllowDelete)
                {
                    //delete a title
                    Command deleteCmd = new Command();
                    deleteCmd.Description = "Delete";
                    deleteCmd.Invoked    += new EventHandler(deleteCmd_Invoked);
                    page.Commands.Add(deleteCmd);
                }

                page.Watched = new BooleanChoice(this, "Watched");

                //is this the right way?
                // yes :)
                if (_titleObj.WatchedCount > 0)
                {
                    page.Watched.Value = true;
                }
                else
                {
                    page.Watched.Value = false;
                }

                page.Watched.ChosenChanged += new EventHandler(Watched_ChosenChanged);

                this.SetFanArtImage(page.Details, _titleObj);

                Dictionary <string, object> properties = new Dictionary <string, object>();
                properties["Page"]        = page;
                properties["Application"] = Library.OMLApplication.Current;

                if (page.Details.FanArt != null)
                {
                    Library.OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_FanArtDetailsPage", properties);
                }
                else
                {
                    Library.OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_DetailsPage", properties);
                }
            };
        }
Exemplo n.º 3
0
        private void AddComplete(IAsyncResult itfAR)
        {
            DvdInfo dvd = DvdInfo.EndGetDvdInfo(itfAR);
            string imgPath = dvd.LargeCoverUrl;
            if (!string.IsNullOrEmpty(imgPath) && imgPath.IndexOf("http") != 0 && imgPath.IndexOf("file") != 0)
                imgPath = string.Format("file://{0}", imgPath);
            this.DefaultImage = new Image(imgPath);
            this.SimpleVideoFormat = "DVD";
            if (!string.IsNullOrEmpty(dvd.ReleaseDate))
                this.MetadataTop = dvd.ReleaseDate;
            else
                this.MetadataTop = "";

            this.ItemId = 1;
            //string dvdStarRating = GetNodeInnerText(dvdDoc, "/METADATA/MDR-DVD/title/providerRating");//dvdDoc.SelectSingleNode("/METADATA/MDR-DVD/title/providerRating").InnerText;
            //if(string.IsNullOrEmpty(dvdStarRating))
            //    dvdStarRating="0";
            ////string starRating = Convert.ToString(Math.Round((Convert.ToDouble(dvdStarRating) * 0.8), MidpointRounding.AwayFromZero));
            //this.StarRating = dvdStarRating;
            string extendedMetadata = string.Empty;

            this.Metadata = dvd.MPAARating;
            if (string.IsNullOrEmpty(dvd.MPAARating))
                this.Metadata = "Not Rated";

            if (!string.IsNullOrEmpty(dvd.Duration))
                this.Metadata += string.Format(", {0} minutes", dvd.Duration);

            this.Tagline = dvd.Synopsis;

            this.Invoked += delegate(object sender, EventArgs args)
            {

                //to test v3
                Library.Code.V3.DetailsPage page = new Library.Code.V3.DetailsPage();
                //DataRow movieData = this.GetMovieData(movieId);

                page.Description = "movie details";
                page.Title = this.Description;
                page.Summary = dvd.Synopsis;
                page.Background = this.DefaultImage;
                page.Details = new Library.Code.V3.ExtendedDetails();

                page.Details.CastArray = new ArrayListDataSet();

                if (!string.IsNullOrEmpty(dvd.Director))
                {
                    int directorCount = 0;
                    string[] directors = dvd.Director.Replace("; ",";").Split(new char[] { ';' });
                    foreach (string director in directors)
                    {
                        Library.Code.V3.CastCommand directorCommand = new Library.Code.V3.CastCommand();
                        directorCommand.Role = " ";
                        directorCommand.Description = director;
                        if (directorCount == 0)
                        {
                            directorCommand.CastType = "TitleAndDesc";
                            directorCommand.GroupTitle = "DIRECTOR";
                            directorCommand.ActorId = 1;//not sure how this works in oml
                        }
                        else
                            directorCommand.CastType = "Desc";
                        page.Details.CastArray.Add(directorCommand);
                        directorCount++;
                    }

                    page.Details.Director = string.Format("Directed By: {0}", dvd.Director);
                }
                if (!string.IsNullOrEmpty(dvd.LeadPerformer))
                {
                    string[] cast = dvd.LeadPerformer.Replace("; ", ";").Split(new char[] { ';' });
                    int actorCount = 0;
                    foreach (string actor in cast)
                    {
                        Library.Code.V3.CastCommand actorCommand = new Library.Code.V3.CastCommand();
                        actorCommand.Description = actor;
                        actorCommand.ActorId = 1;//not sure how this works in oml
                        //actorCommand.Role = kvp.Value;//not sure about role here...
                        if (actorCount == 0)
                        {
                            //add the title "CAST"
                            actorCommand.CastType = "TitleAndDesc";
                            actorCommand.GroupTitle = "CAST";
                        }
                        else
                            actorCommand.CastType = "Desc";

                        page.Details.CastArray.Add(actorCommand);
                        actorCount++;
                    }

                 page.Details.Cast = string.Format("Cast Info: {0}", dvd.LeadPerformer);

                }
                //if (this.StarRating != "0")
                //    page.Details.StarRating = new Image(string.Format("resx://Library/Library.Resources/V3_Controls_Common_Stars_{0}", starRating));

                //strip invalid dates
                if (!string.IsNullOrEmpty(dvd.ReleaseDate))
                    page.Details.YearString = dvd.ReleaseDate;

                page.Details.Studio = dvd.Studio;

                page.Details.GenreRatingandRuntime = dvd.Genre;

                //fixes double spacing issues
                if(!string.IsNullOrEmpty(dvd.Synopsis))
                    page.Details.Summary = dvd.Synopsis.Replace("\r\n", "\n");
                page.Commands = new ArrayListDataSet(page);
                //default play command
                Command playCmd = new Command();
                playCmd.Description = "Play";
                playCmd.Invoked += new EventHandler(playCmd_Invoked);
                page.Commands.Add(playCmd);

                if (page.Details.CastArray.Count > 0)
                {
                    foreach (Library.Code.V3.CastCommand actor in page.Details.CastArray)
                    {
                        //actor.Invoked += new EventHandler(actor_Invoked);
                        //TitleCollection titles = new TitleCollection();
                        OMLEngine.TitleFilter personFilter = new OMLEngine.TitleFilter(OMLEngine.TitleFilterType.Person, actor.Description);
                        OMLEngine.TitleCollectionManager.GetFilteredTitles(new List<OMLEngine.TitleFilter>() { personFilter });
                    }

                    Command command = new Command();
                    command.Description = "Cast + More";

                    command.Invoked += delegate(object castSender, EventArgs castArgs)
                    {
                        Dictionary<string, object> castProperties = new Dictionary<string, object>();
                        castProperties["Page"] = page;
                        castProperties["Application"] = Library.OMLApplication.Current;
                        Library.OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_DetailsPageCastCrew", castProperties);
                    };

                    page.Commands.Add(command);
                }

                Dictionary<string, object> properties = new Dictionary<string, object>();
                properties["Page"] = page;
                properties["Application"] = Library.OMLApplication.Current;

                Library.OMLApplication.Current.Session.GoToPage("resx://Library/Library.Resources/V3_DetailsPage", properties);
            };
        }