예제 #1
0
        /// <summary>
        /// Create the commands for the episode details page.
        /// </summary>
        private void CreateEpisodeDetailsCommands(DetailsPage page, DataRow episodeData, int episodeId)
        {
            page.Commands = new ArrayListDataSet(page);

            //
            // There is a list of actions associated with each episode.
            // We need to walk through the episode->action table (tbl_TV_And_Action)
            // and build a list of Commands for each entry.
            //

            DataTable tbl_TV_Episode_And_Action = dataSet.Tables["tbl_TV_Episode_And_Action"];
            DataTable tbl_TV_Action             = dataSet.Tables["tbl_TV_Action"];

            // Get the matching actions specified by our item.
            string query = String.Format("TV_Episode_ID = '{0}'", episodeId);

            DataRow[] episodeAndActionMatches = tbl_TV_Episode_And_Action.Select(query);

            foreach (DataRow episodeAndActionData in episodeAndActionMatches)
            {
                // Look up the standard type of this action
                DataRow actionTypeData = Z.DataSetHelpers.GetIDMappedDataRow(episodeAndActionData, "TV_Action_ID",
                                                                             tbl_TV_Action, "TV_Action_ID");
                string actionName   = (string)actionTypeData["TV_Action"];
                int    actionTypeId = (int)actionTypeData["TV_Action_ID"];

                // Some actions have a "value" associated with them.
                // TODO: Needs to be added to data source.
                //string value = (string)episodeAndActionData["TV_Action_Value"];
                string value = null;

                CreateEpisodeDetailsCommand(page, actionName, actionTypeId, value, episodeId);
            }
        }
예제 #2
0
        /// <summary>
        /// Navigate to the specified details page.
        /// </summary>
        /// <param name="page">The state object for the details page</param>
        public void GoToDetails(DetailsPage page)
        {
            if (page == null)
            {
                throw new ArgumentNullException("page", "Must specify the model for the details page");
            }

            // If we have no page session, just spit out a trace statement.
            if (session == null)
            {
                Debug.WriteLine("GoToDetails: " + page.Title);
                return;
            }


            //
            // Construct the arguments dictionary and then navigate to the
            // details page template.
            //

            Dictionary <string, object> properties = new Dictionary <string, object>();

            properties["Page"]        = page;
            properties["Application"] = this;

            session.GoToPage("resx://Z/Z.Resources/DetailsPage", properties);
        }
예제 #3
0
        /// <summary>
        /// Create a gallery item from a row of episode data.
        /// </summary>
        private GalleryItem CreateEpisodeGalleryItem(DataRow episodeData)
        {
            GalleryItem item = new GalleryItem();

            item.Description = (string)episodeData["TV_Episode_Title"];
            item.ItemId      = (int)episodeData["TV_Episode_ID"];

            // Show the release data of the episode in the metadata.
            DateTime releaseDate = (DateTime)episodeData["TV_Episode_Release_Date"];

            item.Metadata = releaseDate.ToString("d");

            //
            // Hook up an event for when the gallery item is invoked.
            //

            item.Invoked += delegate(object sender, EventArgs args)
            {
                GalleryItem galleryItem = (GalleryItem)sender;

                // Navigate to a details page for this episode.
                DetailsPage page = CreateEpisodeDetailsPage(galleryItem.ItemId);
                Application.Current.GoToDetails(page);
            };

            return(item);
        }
        /// <summary>
        /// Construct a gallery item for a row of data.
        /// </summary>
        private GalleryItem CreateGalleryItem(DataRow movieData)
        {
            GalleryItem item = new GalleryItem();

            item.Description = (string)movieData["Movie_Title"];
            item.ItemId      = (int)movieData["Movie_ID"];

            // Display the release year as this item's metadata.
            DateTime releaseDate = (DateTime)movieData["Movie_Release_Date"];

            item.Metadata = releaseDate.Year.ToString();


            //
            // Hook up an event for when the gallery item is invoked.
            //

            item.Invoked += delegate(object sender, EventArgs args)
            {
                GalleryItem galleryItem = (GalleryItem)sender;

                // Navigate to a details page for this item.
                DetailsPage page = CreateDetailsPage(galleryItem.ItemId);
                Application.Current.GoToDetails(page);
            };

            return(item);
        }
        /// <summary>
        /// Fill in all the metadata on serach result.
        /// </summary>
        private SearchResult CreateSearchResult(DataRow movieData)
        {
            // Grab all the available metadata from the data source.
            MovieMetadata metadata = ExtractMetadata(movieData);

            // Create the search result object
            SearchResult item = new SearchResult(metadata.Id);

            item.Type = Z.Resources.Movies_Search_Type;

            //
            // Fill in all the string metadata.
            //

            item.Description = metadata.Title;

            string cast = String.Empty;

            foreach (string actor in metadata.Actors)
            {
                Z.DataSetHelpers.AppendCommaSeparatedValue(ref cast, actor);
            }

            item.Metadata1 = String.Format(Z.Resources.Movies_Search_Metadata1,
                                           metadata.Genre,
                                           cast,
                                           metadata.Length,
                                           metadata.CountryShortName,
                                           metadata.ReleaseDate.Year);

            item.Metadata2 = String.Format(Z.Resources.Movies_Search_Metadata2,
                                           metadata.Genre,
                                           cast,
                                           metadata.Length,
                                           metadata.CountryShortName,
                                           metadata.ReleaseDate.Year);

            //
            // Load the image.
            //

            string imageName = (string)movieData["Movie_Image_Gallery_Small"];

            item.Image = LoadImage(imageName);


            // Hook up an invoked handler
            item.Invoked += delegate(object sender, EventArgs args)
            {
                SearchResult searchResult = (SearchResult)sender;

                // Navigate to a details page for this item.
                DetailsPage page = CreateDetailsPage(searchResult.Id);
                Application.Current.GoToDetails(page);
            };

            return(item);
        }
예제 #6
0
        /// <summary>
        /// Create a details page for an episode.
        /// NOTE: This is public to enable debug markup access.
        /// </summary>
        public DetailsPage CreateEpisodeDetailsPage(int episodeId)
        {
            DetailsPage page = new DetailsPage();

            //
            // Get the full metadata on the episode.
            //

            DataRow         episodeData     = GetEpisodeData(episodeId);
            EpisodeMetadata episodeMetadata = ExtractEpisodeMetadata(episodeData, episodeId);


            //
            // Get the full metadata on the show.
            //

            DataRow      showData     = GetShowData(episodeMetadata.ShowId);
            ShowMetadata showMetadata = ExtractShowMetadata(showData, episodeMetadata.ShowId);


            //
            // Fill in the page's easy properties.
            //

            page.Title      = episodeMetadata.Title;
            page.Summary    = episodeMetadata.Summary;
            page.Background = LoadImage(episodeMetadata.DetailImagePath);


            //
            // Metadata
            //
            // Now that we have all the little pieces, we can put together our
            // final metadata string.
            //

            page.Metadata = String.Format(Z.Resources.TV_Details_Metadata,
                                          showMetadata.Provider,
                                          episodeMetadata.Season,
                                          showMetadata.Genre,
                                          episodeMetadata.Length,
                                          showMetadata.CountryShortName,
                                          episodeMetadata.ReleaseDate.Year);


            //
            // Actions
            //

            CreateEpisodeDetailsCommands(page, episodeData, episodeId);

            return(page);
        }
        /// <summary>
        /// Create a details page for a movie.
        /// NOTE: This is public to enable debug markup access.
        /// </summary>
        public DetailsPage CreateDetailsPage(int movieId)
        {
            DetailsPage page = new DetailsPage();

            //
            // Get the full metadata from this row.
            //

            DataRow       movieData = GetMovieData(movieId);
            MovieMetadata metadata  = ExtractMetadata(movieData, movieId);


            //
            // Fill in the page's easy properties.
            //

            page.Title      = metadata.Title;
            page.Summary    = metadata.Summary;
            page.Background = LoadImage(metadata.ImagePath);


            //
            // Metadata
            //
            // Now that we have all the little pieces, we can put together our
            // final metadata string.
            //

            string cast = String.Empty;

            foreach (string actor in metadata.Actors)
            {
                Z.DataSetHelpers.AppendCommaSeparatedValue(ref cast, actor);
            }

            page.Metadata = String.Format(Z.Resources.Movies_Details_Metadata,
                                          metadata.Genre,
                                          cast,
                                          metadata.Length,
                                          metadata.CountryShortName,
                                          metadata.ReleaseDate.Year);


            //
            // Actions
            //

            CreateDetailsCommands(page, movieData, movieId);

            return(page);
        }
예제 #8
0
        /// <summary>
        /// Create a single episode details page command.
        /// </summary>
        private void CreateEpisodeDetailsCommand(DetailsPage page, string description, int type, string value, int itemId)
        {
            DetailsCommand command = new DetailsCommand(page, description);

            command.Type   = type;
            command.Value  = value;
            command.ItemId = itemId;

            // Hook up the event handler.  This handler will disambiguate
            // what the actual action that should occur based on the item's
            // action type.
            command.Invoked += delegate(object sender, EventArgs e)
            {
                OnEpisodeDetailsActionInvoked((DetailsCommand)sender);
            };

            page.Commands.Add(command);
        }
        /// <summary>
        /// Create the commands for the details page.
        /// </summary>
        private void CreateDetailsCommands(DetailsPage page, DataRow movieData, int movieId)
        {
            page.Commands = new ArrayListDataSet(page);

            //
            // We always have a "Preview" command.  Populate that.
            //

            string previewContent = (string)movieData["Movie_Preview_Content"];

            CreateDetailsCommand(page, Z.Resources.Movies_Details_Preview, (int)MoviesDetailsActionType.Preview, previewContent, movieId);


            //
            // There is a list of actions associated with each movie.
            // We need to walk through the movie->action table (tbl_Movie_And_Action)
            // and build a list of Commands for each entry.
            //

            DataTable tbl_Movie_And_Action = dataSet.Tables["tbl_Movie_And_Action"];
            DataTable tbl_Movie_Action     = dataSet.Tables["tbl_Movie_Action"];

            // Get the matching actions specified by our movie.
            string query = String.Format("Movie_ID = '{0}'", movieId);

            DataRow[] movieActionMatches = tbl_Movie_And_Action.Select(query);

            foreach (DataRow movieAndActionData in movieActionMatches)
            {
                // Look up the standard type of this action
                DataRow actionTypeData = Z.DataSetHelpers.GetIDMappedDataRow(movieAndActionData, "Movie_Action_ID",
                                                                             tbl_Movie_Action, "Movie_Action_ID");
                string actionName   = (string)actionTypeData["Movie_Action"];
                int    actionTypeId = (int)actionTypeData["Movie_Action_ID"];

                // Some actions have a "value" associated with them.
                string value = (string)movieAndActionData["Movie_Action_Value"];

                CreateDetailsCommand(page, actionName, actionTypeId, value, movieId);
            }
        }
예제 #10
0
        /// <summary>
        /// Return Commands for items that match the search string.
        /// </summary>
        public override IList <SearchResult> Search(string value)
        {
            IList <SearchResult> results = new List <SearchResult>();

            //
            // Episodes
            //
            // Search the episode table for items that have this search
            // string in their title.
            //

            DataTable tbl_TV_Episode = dataSet.Tables["tbl_TV_Episode"];
            string    query          = String.Format("TV_Episode_Title LIKE '*{0}*'", value);

            DataRow[] matches = tbl_TV_Episode.Select(query);

            foreach (DataRow episodeData in matches)
            {
                int episodeId = (int)episodeData["TV_Episode_ID"];

                // Create the search result object
                SearchResult item = new SearchResult(episodeId);
                item.Description = (string)episodeData["TV_Episode_Title"];
                item.Type        = Z.Resources.TV_Search_Type_Episode;

                string imageName = (string)episodeData["TV_Episode_Gallery_Image"];
                item.Image = LoadImage(imageName);

                // Hook up an invoked handler
                item.Invoked += delegate(object sender, EventArgs args)
                {
                    SearchResult searchResult = (SearchResult)sender;

                    // Navigate to a details page for this item.
                    DetailsPage page = CreateEpisodeDetailsPage(searchResult.Id);
                    Application.Current.GoToDetails(page);
                };

                results.Add(item);
            }


            //
            // Shows
            //
            // Search the show table for items that have this search
            // string in their title.
            //

            DataTable tbl_TV_Show = dataSet.Tables["tbl_TV_Show"];

            query   = String.Format("TV_Show_Title LIKE '*{0}*'", value);
            matches = tbl_TV_Show.Select(query);

            foreach (DataRow showData in matches)
            {
                int showId = (int)showData["TV_Show_ID"];

                // Create the search result object
                SearchResult item = new SearchResult(showId);
                item.Description = (string)showData["TV_Show_Title"];
                item.Type        = Z.Resources.TV_Search_Type_Show;

                string imageName = (string)showData["TV_Show_Image"];
                item.Image = LoadImage(imageName);

                // Hook up an invoked handler
                item.Invoked += delegate(object sender, EventArgs args)
                {
                    SearchResult searchResult = (SearchResult)sender;

                    // Navigate to a gallery page for this item.
                    GalleryPage page = CreateEpisodeGalleryPage(searchResult.Id);
                    Application.Current.GoToGallery(page);
                };

                results.Add(item);
            }

            return(results);
        }
 public DetailsCommand(DetailsPage page, string description)
     : base(page, description, null)
 {
 }