Пример #1
0
        // take name of selected item in listBox1 and send it to TheMovieDb and retrieve possible movies
        private void identifySelectedMovie()
        {
            string selectedItem = listBox1.SelectedItem.ToString();

            // read API key from textfile (see above)
            string key = "";
            try
            {
                key = File.ReadAllText(_tmdbKeyFile);
            }
            catch (Exception e)
            {
                MessageBox.Show("Something went wrong while reading the TheMovieDb API key from \n" + _tmdbKeyFile + "\n" + e.Message, "Error", MessageBoxButtons.OK);
            }

            TMDbClient client = new TMDbClient(key);
            var results = client.SearchMovie(selectedItem).Results;

            // loop over all the found movies, and put the titles in a list
            var movies = new List<Movie>();
            foreach (SearchMovie mov in results)
            {
                Movie m = new Movie();
                m.MovieObject = mov;
                m.DisplayName = mov.Title;

                movies.Add(m);
            }

            // send all movies to the dialog listbox
            SelectMovie dialog;
            dialog = new SelectMovie(movies.ToArray() );
            DialogResult res = dialog.ShowDialog();

            if ( res == DialogResult.OK )
            {
                // ask the dialog which item was selected
                Movie selectedMovieObject = dialog.GetSelectedItem();

                listBox1.Items[listBox1.SelectedIndex] = selectedMovieObject;
            }
        }
Пример #2
0
        // read folder contents and put all directory names in the listbox
        private void ScanFolder()
        {
            // clear listbox
            listBox1.Items.Clear();

            string[] folders = Directory.GetDirectories(_movieFolder, "*", SearchOption.TopDirectoryOnly);

            foreach (string folder in folders)
            {
                Movie m = new Movie();
                m.OriginalFolder = folder;
                m.DisplayName = ExtractMovieName(extractLastPart(folder));

                listBox1.Items.Add(m);
            }
        }