コード例 #1
0
        //Adding movie to database or just to the current instance
        private MovieConnector.Movie addMovieToDisplay(SearchMovie movie)
        {
            TMDbLib.Objects.Movies.Movie movie2 = client.GetMovieAsync(movie.Id).Result;
            List <string> ourGenres             = new List <string>();

            List <MovieConnector.Cast> ourCasts = new List <MovieConnector.Cast>();

            foreach (Genre genre in movie2.Genres)
            {
                ourGenres.Add(genre.Name);
            }

            try
            {
                TMDbLib.Objects.Movies.Movie casts;  casts = getCasts(movie.Id);
                int castCount = casts.Credits.Cast.Capacity;
                if (castCount > 5)
                {
                    castCount = 5;
                }
                for (int i = 0; i < castCount; i++)
                {
                    ourCasts.Add(new MovieConnector.Cast(casts.Credits.Cast[i].Id, casts.Credits.Cast[i].Character, casts.Credits.Cast[i].Name, casts.Credits.Cast[i].ProfilePath));
                }
            }
            catch (Exception e) { }

            currentMovie = new MovieConnector.Movie(movie.Id, movie.Title, movie.Overview, movie.ReleaseDate.Value, movie.VoteAverage,
                                                    movie.PosterPath, ourCasts, string.Join(",", ourGenres.ToArray()), movie2.Runtime.Value);

            return(currentMovie);
        }
コード例 #2
0
        //Showing movie content EventHandler
        private void movieGetContent_mouseDownHandler(object sender, EventArgs e)
        {
            clearListBoxMovCont();

            Button buttonSender = (Button)sender;
            int    movieId      = Int32.Parse(buttonSender.Name.Substring(7));

            MovieConnector.Movie m = dbController.getMovieContent(movieId);
            displayMovieContent((m));
        }
コード例 #3
0
        private MovieConnector.Movie addMovieToDatabase(SearchMovie movie)
        {
            if (dbController.checkIfMovieInDatabase(movie.Id))
            {
                currentMovie = dbController.getMovieContent(movie.Id);
            }
            else
            {
                TMDbLib.Objects.Movies.Movie movie2 = client.GetMovieAsync(movie.Id).Result;
                List <Genre>  genres    = movie2.Genres;
                List <string> ourGenres = new List <string>();

                TMDbLib.Objects.Movies.Movie casts;

                foreach (Genre genre in genres)
                {
                    ourGenres.Add(genre.Name);
                }

                currentMovie = dbController.insertToMovie(movie.Id, movie.Title, movie.Overview, movie.ReleaseDate.Value, movie.VoteAverage,
                                                          movie.PosterPath, string.Join(",", ourGenres.ToArray()), movie2.Runtime.Value);

                try
                {
                    casts = getCasts(movie.Id);
                    int castCount = casts.Credits.Cast.Capacity;
                    if (castCount > 5)
                    {
                        castCount = 5;
                    }
                    for (int i = 0; i < castCount; i++)
                    {
                        if (!dbController.checkIfCastInDatabase(casts.Credits.Cast[i].Id))
                        {
                            dbController.insertToCast(casts.Credits.Cast[i].Id, casts.Credits.Cast[i].Character, casts.Credits.Cast[i].Name, casts.Credits.Cast[i].ProfilePath);
                        }
                        dbController.insertCastToMovie(movie.Id, casts.Credits.Cast[i].Id);
                    }
                }
                catch (Exception e) { }
            }
            return(currentMovie);
        }
コード例 #4
0
        private void displayMovieContent(MovieConnector.Movie m)
        {
            contentIsNotAvailable.Visibility = Visibility.Hidden;
            clearListBoxCast();
            int numObj = 2;

            if (m != null)
            {
                textBoxSearch.Text = m.Title;
                Grid grid = new Grid();
                grid.Height = 478;
                grid.Width  = 844;
                var bc = new BrushConverter();
                grid.Background = (Brush)bc.ConvertFrom("#FF212121");
                GridSplitter gridSplitter = new GridSplitter();
                gridSplitter.HorizontalAlignment = HorizontalAlignment.Left;
                gridSplitter.VerticalAlignment   = VerticalAlignment.Top;
                gridSplitter.Height     = 430;
                gridSplitter.Width      = 3;
                gridSplitter.Margin     = new Thickness(252, 13, 0, 0);
                gridSplitter.Background = (Brush)bc.ConvertFrom("#FFBCBCBC");
                grid.Children.Add(gridSplitter);
                //Images
                int numImage = 1;
                //Image1
                grid.Children.Add(drawImage(numObj + "" + numImage++, "http://image.tmdb.org/t/p/w185/" + m.PosterPath, 301, 290, new int[] { 20, 15, 0, 0 }, m.Image));
                //Image2
                grid.Children.Add(drawImage(numObj + "" + numImage++, "pack://siteoforigin:,,,/files/ic_stars_white_48dp_2x.ico", 21, 21, new int[] { 295, 65, 0, 0 }, null));
                //Image3
                grid.Children.Add(drawImage(numObj + "" + numImage++, "pack://siteoforigin:,,,/files/ic_timer_white_48dp_2x.ico", 21, 21, new int[] { 390, 65, 0, 0 }, null));
                //TextBlocks
                int    numTextBlock = 1;
                string text         = "";
                //textBlock1
                grid.Children.Add(drawTextBlock(numObj + "" + numTextBlock++, m.Title + " (" + m.ReleaseDate.ToString("yyyy") + ")", "#FFE9E9E9", FontWeights.Bold, 18, new int[] { 288, 10, 0, 0 }, new int[] { 9, 0, 0, 0 }, 31, 551));
                //textBlock2
                text = "Genres: " + m.Genre;
                grid.Children.Add(drawTextBlock(numObj + "" + numTextBlock++, text, "#FFBCBCBC", FontWeights.Bold, 14, new int[] { 288, 42, 0, 0 }, new int[] { 9, 0, 0, 0 }, -1, -1));
                //textBlock3
                TextBlock textBlock = drawTextBlock(numObj + "" + numTextBlock++, "", "#FFE9E9E9", FontWeights.Bold, -1, new int[] { 325, 65, 0, 0 }, null, -1, -1);
                Run       run       = new Run(m.VoteAverage.ToString());
                run.Foreground = (Brush)bc.ConvertFrom("#FFBBBB57");
                textBlock.Inlines.Add(run);
                run = new Run("/10");
                textBlock.Inlines.Add(run);
                grid.Children.Add(textBlock);
                //textBlock4
                grid.Children.Add(drawTextBlock(numObj + "" + numTextBlock++, m.Runtime.ToString() + " min", "#FFE9E9E9", FontWeights.Bold, 14, new int[] { 410, 65, 0, 0 }, new int[] { 9, 0, 0, 0 }, -1, -1));
                //textBlock5
                grid.Children.Add(drawTextBlock(numObj + "" + numTextBlock++, "Release Date: (" + m.ReleaseDate.ToString("MMMM dd, yyyy") + ")", "#FFBCBCBC", FontWeights.Bold, 14, new int[] { 288, 90, 0, 0 }, new int[] { 9, 0, 0, 0 }, 170, 420));

                WrapPanel wrapPanel = new WrapPanel();
                wrapPanel.Width  = 450;
                wrapPanel.Margin = new Thickness(200, 120, 0, 0);
                //textBlock6
                wrapPanel.Children.Add(drawTextBlock(numObj + "" + numTextBlock++, "Storyline: \n" + m.Overview + "\n\nCasts:", "#FFBCBCBC", FontWeights.Bold, 14, null, null, -1, 420));

                List <MovieConnector.Cast> casts;
                if (m.Casts == null)
                {
                    casts = dbController.getAllCastsForMovie(m.Id);
                }
                else
                {
                    casts = m.Casts;
                }

                if (casts.Count != 0)
                {
                    foreach (MovieConnector.Cast cast in casts)
                    {
                        Grid crewMember = new Grid();
                        crewMember.Width  = 400;
                        crewMember.Height = 60;
                        crewMember.Children.Add(drawImage(numObj + "" + numImage++, "http://image.tmdb.org/t/p/w185/" + cast.ProfilePath, 60, -1, new int[] { 0, 10, 10, 0 }, cast.Image));
                        TextBlock crewName = new TextBlock();
                        crewName.MouseDown  += new MouseButtonEventHandler(castName_mouseDownHandler);
                        crewName.MouseEnter += new MouseEventHandler(castName_mouseOverHandler);
                        crewName.MouseLeave += new MouseEventHandler(castName_mouseLeaveHandler);
                        crewName.Text        = cast.Name;
                        crewName.Uid         = m.Id + "_" + cast.Id.ToString();
                        crewName.Margin      = new Thickness(80, 10, 0, 0);
                        crewName.Foreground  = new SolidColorBrush(Color.FromRgb(50, 153, 187));;
                        crewName.FontWeight  = FontWeights.Bold;
                        Label crewCharacter = new Label();
                        crewCharacter.Content    = cast.Character;
                        crewCharacter.Margin     = new Thickness(80, 25, 0, 0);
                        crewCharacter.Foreground = (Brush)bc.ConvertFrom("#FFBCBCBC");

                        crewMember.Children.Add(crewName);
                        crewMember.Children.Add(crewCharacter);
                        wrapPanel.Children.Add(crewMember);
                    }
                }


                grid.Children.Add(wrapPanel);
                //wrapPanel.Children.Add(grid);
                listBoxMovieContent.Items.Add(grid);
            }
        }