示例#1
0
        private void CheckForCollision(MovieEntry entry)
        {
            StringBuilder sb = new StringBuilder();

            string common = $"SELECT Id FROM MovieEntry WHERE Theater={entry.Theatre} ";

            foreach (var showtime in entry.Showings)
            {
                string start = ((DateTime)showtime.Start).ToString("yyyy-MM-dd HH:mm:ss");
                string end   = ((DateTime)showtime.End).ToString("yyyy-MM-dd HH:mm:ss");

                sb.Append(common);
                sb.Append($"AND Start BETWEEN '{start}' AND '{end}' ");
                sb.Append("UNION ");
                sb.Append(common);
                sb.Append($"AND End BETWEEN '{start}' AND '{end}' ");
                sb.Append("UNION ");
                sb.Append(common);
                sb.Append($"AND Start <= '{start}' AND End >= '{end}' ");

                _cmd.CommandText = sb.ToString();
                _reader          = _cmd.ExecuteReader();

                if (_reader.HasRows)
                {
                    showtime.Start = null; //flag conflicting showtimes
                }
                _reader.Close();
                sb.Clear();
            }
        }
示例#2
0
        public void Submit(MovieEntry entry, DateTime?start, DateTime?end)
        {
            if (start != null && end != null)
            {
                entry.AddTime(new Showtime(start, end));
            }

            int num;

            if (Validate(entry, out string msg))
            {
                if ((num = _dbConn.Save(entry)) < 1)
                {
                    msg = "Invalid entry. There's a scheduling or duration conflict with existing entries.";
                }
                else
                {
                    int i = msg.IndexOf('e') - 2;
                    msg = msg.Insert(i, num.ToString());
                }
            }

            _form.Display(msg);
            _form.Close();
            Homepage homepage = new Homepage(_token);

            homepage.Show();
        }
示例#3
0
        private bool TitleCheck(MovieEntry entry, out string msg)
        {
            HashSet <char> forbidden = new HashSet <char>()
            {
                '*', ';', '|', '&', '=', '.', '%', '#', '\\', '/', '-', '+', '!', '`', '\'', ':', ',', '@', '^', '<', '>', '?', '{', '}', '[', ']', '(', ')', '$', '\"'
            };
            string title   = entry.Title;
            int    len     = title.Length;
            bool   isValid = len > 0;

            for (int i = 0; isValid && i < len; i++)
            {
                if (forbidden.Contains(title[i]))
                {
                    isValid = false;
                }
            }

            if (!isValid)
            {
                msg  = "Invalid entry. ";
                msg += len == 0 ? "Title cannot be empty." : "Title contains invalid characters.";
                return(false);
            }

            msg = "";
            return(true);
        }
示例#4
0
        public IActionResult MovieEntry(MovieEntry movieEntry)
        {
            if (movieEntry.Title == "Independence Day")
            {
                ModelState.AddModelError(movieEntry.Title, "Independence Day is not a good movie");
                return(View(movieEntry));
            }

            if (ModelState.IsValid)
            {
                _context.Movies.Add(movieEntry);
                _context.SaveChanges();

                return(View("ViewEntries", _context.Movies));

                //this is for temp storage, before adding the DB
                ////adding the submitted form to the local storage for display on another page
                //TempStorage.AddEntry(movieEntry);
                ////once the fomr is successfully sumbitted, it redirects to the view of all submitted movies
                //Response.Redirect("ViewEntries");
            }
            else
            {
                return(View(movieEntry));
            };
        }
示例#5
0
        public frmManualFetch(MovieEntry entry, MetadataAccessor accessor)
        {
            InitializeComponent();

            m_entry = entry;
            m_accessor = accessor;
        }
示例#6
0
        public IActionResult EditView(long moviesId)
        {
            MovieEntry movie = _context.Movies.Where(m => m.MoviesId == moviesId).First();

            movie.Edited = true;

            return(View("EditEntry", movie));
        }
示例#7
0
        public IActionResult EditEntry(MovieEntry movie)
        {
            _context.Update(movie);

            _context.SaveChanges();

            return(View("ViewEntries", _context.Movies));
        }
        // delete movie
        public IActionResult DeleteMovie(int movie_id)
        {
            MovieEntry movie = _context.Movies.Where(m => m.MovieEntryID == movie_id).FirstOrDefault();

            _context.Remove(movie);
            _context.SaveChanges();
            return(Redirect("/Home/EditMovie"));
        }
 public IActionResult MovieEntry(MovieEntry movie)
 {
     if (ModelState.IsValid)
     {
         TempStorage.AddMovie(movie);
         return(View("MovieList", TempStorage.Movies));
     }
     return(View());
 }
示例#10
0
        private void cmdOK_Click(object sender, EventArgs e)
        {
            var selected = (TmdbResult)comboBox1.SelectedItem;

            SelectedEntry = new MovieEntry();
            SelectedEntry.SetData(_oldEntry);
            SelectedEntry.SetData(selected);
            DialogResult = DialogResult.OK;
        }
示例#11
0
        private bool PosterCheck(MovieEntry entry, out string msg)
        {
            if ((_poster = _dbConn.GetPoster(entry.Title)) == null) //user may have changed title without changing theater - need to update poster
            {
                msg = "Invalid entry. Database does not contain a matching movie poster.";
                return(false);
            }

            msg = "";
            return(true);
        }
 public PropertyEditorMovie(MovieEntry entry, Game game, PCKFile archive)
 {
     InitializeComponent();
     Movie = new MovieEntry()
     {
         FriendlyName = entry.FriendlyName, ID = entry.ID, FilePath = entry.FilePath, Unknown4 = entry.Unknown4, GameID = entry.GameID, Unknown5 = entry.Unknown5
     };
     OldMovie    = entry;
     _game       = game;
     _archive    = archive;
     DataContext = this;
 }
示例#13
0
        public int Save(MovieEntry entry)
        {
            _connection.Open();

            if (!CheckDuration(entry))
            {
                _connection.Close();
                return(-1);
            }

            CheckForCollision(entry); //initial scan to throw out showtimes that conflict with existing showtimes

            _cmd.CommandText = $"Select TotalCapacity from Theater where Id={entry.Theatre}";
            _reader          = _cmd.ExecuteReader();
            _reader.Read();
            int total = _reader.GetInt32(0);

            _reader.Close();

            string        common = "Insert into MovieEntry(Title, Date, Start, End, Theater, CurrentCapacity) VALUES ('";
            StringBuilder sb     = new StringBuilder();
            int           result = 0;

            foreach (var showtime in entry.Showings)
            {
                if (showtime.Start == null) //skip showtimes flagged as duplicate in CheckForConflicts()
                {
                    continue;
                }
                sb.Append(common);
                sb.Append(entry.Title);
                sb.Append("', '");
                sb.Append(((DateTime)showtime.Start).Date.ToString("d"));
                sb.Append("', '");
                sb.Append(((DateTime)showtime.Start).ToString("yyyy-MM-dd HH:mm:ss"));
                sb.Append("', '");
                sb.Append(((DateTime)showtime.End).ToString("yyyy-MM-dd HH:mm:ss"));
                sb.Append("', ");
                sb.Append(entry.Theatre);
                sb.Append(", ");
                sb.Append(total);
                sb.Append(");");

                _cmd.CommandText = sb.ToString();
                result          += _cmd.ExecuteNonQuery();
                sb.Clear();
            }

            _connection.Close();
            return(result);   //return rows affected, so, in case collision occured, we can display correct message
        }
 public ActionResult Create([Bind(Include = "ID,Title,ReleaseDate,Genre,Price,Rating")] MovieEntry movie)
 {
     // バインディング状態がOKなら登録
     if (ModelState.IsValid)
     {
         // リストに追加して変更を保存→INSERT+COMMIT
         db.Movies.Add(movie.GetMovie());
         db.SaveChanges();
         // 登録成功→一覧画面へリダイレクト(アクションを指定)
         return(RedirectToAction("Index"));
     }
     // NGなら入力データで表示
     return(View(movie));
 }
示例#15
0
        private bool Validate(MovieEntry entry, out string msg)
        {
            if (!TitleCheck(entry, out msg))
            {
                return(false);
            }

            if (!PosterCheck(entry, out msg))
            {
                return(false);
            }

            return(ShowingsCheck(entry, out msg));
        }
示例#16
0
        public void Save(string dirPath, MovieEntry entry)
        {
            var path = Path.Combine(dirPath, Commons.PersistentFileName);

            if (File.Exists(path))
            {
                File.SetAttributes(path, FileAttributes.Normal);
            }
            File.WriteAllText(path, JsonConvert.SerializeObject(entry));
            if (_hideFile)
            {
                File.SetAttributes(path, FileAttributes.Hidden);
            }
        }
示例#17
0
        private bool ShowingsCheck(MovieEntry entry, out string msg)
        {
            int      len      = entry.Showings.Count; //Showings will always have at least 1 Showtime
            Showtime time     = entry.Showings[0];
            TimeSpan duration = (DateTime)time.End - (DateTime)time.Start;

            bool isValid = duration.TotalMinutes > 0;

            if (!isValid && duration.TotalMinutes != 0)  //entries crossing over midnight
            {
                time.End = ((DateTime)time.End).AddDays(1);
                duration = (DateTime)time.End - (DateTime)time.Start;
                isValid  = !isValid;
            }

            for (int i = 1; isValid && i < len; i++)  // make sure all showings have same duration
            {
                time = entry.Showings[i];
                if (time.End - time.Start != duration)
                {
                    if (((TimeSpan)(time.End - time.Start)).TotalMinutes < 0) //entries crossing over midnight
                    {
                        time.End = ((DateTime)time.End).AddDays(1);
                        isValid  = (DateTime)time.End - (DateTime)time.Start == duration;
                    }
                    else
                    {
                        isValid = false;  //durations simply don't match
                    }
                }
            }

            for (int i = 0; isValid && i < len; i++)    // check for concurrent showings
            {
                time = entry.Showings[i];
                DateTime tmpStart, tmpEnd;

                for (int j = i + 1; isValid && j < len; j++)
                {
                    tmpStart = (DateTime)entry.Showings[j].Start;
                    tmpEnd   = (DateTime)entry.Showings[j].End;
                    isValid  = (tmpEnd <time.Start || tmpStart> time.End);   //OR because valid times are in the union of(tmp's that finish before time.Start, tmp's that start after time.End)
                }
            }

            msg = isValid ? "\n                                   entries were successfully created." :
                  "Invalid entry. A show time must contain chronological start and end times. \nAll show time durations must match. No concurrent showings allowed."; //whitespace needed for rendering
            return(isValid);
        }
示例#18
0
        public void Submit(MovieEntry entry, int seats)
        {
            Reservation res = new Reservation(entry, seats);

            if (Validate(res, out string msg))
            {
                msg += _dbConn.Save(res);
            }

            _form.Display(msg);
            _form.Close();
            Homepage homepage = new Homepage(_token);

            homepage.Show();
        }
        public ActionResult Edit([Bind(Include = "ID,Title,ReleaseDate,Genre,Price,Rating")] MovieEntry movie)  
        {
            if (ModelState.IsValid)
            {
                  {
                    Movie entry = movie.GetMovie();

                    // 対象情報を変更状態にする
                    db.Entry(entry).State = EntityState.Modified;
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            return(View(movie));
        }
示例#20
0
        public SettingsView()
        {
            InitializeComponent();

            _tryitData = new MovieEntry();
            _tryitData.SetData(new TmdbResult
            {
                Genre  = "Science Fiction",
                TmdbId = 1134,
                ImdbId = "tt172845369",
                Plot   = "There is...",
                Title  = "Star Trek Beyond",
                Year   = 2017
            });
        }
示例#21
0
        private async Task <MovieEntry> HelperFetch(string path)
        {
            var tmdb     = _kernel.Get <ITmdb>();
            var guessit  = _kernel.Get <IGuessit>();
            var filename = Path.GetFileName(path);

            // results
            GuessitResult name    = null;
            TmdbResult    newData = null;

            // process
            try
            {
                // guess
                name = await guessit.RealGuessName(filename);

                if (name?.ImdbId != null)
                {
                    // IMDB id detected
                    newData = await tmdb.GetByImdbId(name.ImdbId);
                }
                else if (name?.Title != null)
                {
                    // title detected
                    var movies = await tmdb.SearchMovies(name.Title, name.Year);

                    newData = await tmdb.GetByTmdbId(movies.First());
                }
            }
            catch (Exception e)
            {
                Debug.Print("Unable to fetch: {0}. {1}", filename, e.Message);
            }

            // entry create
            var entry = new MovieEntry();

            entry.SetFullPath(path);
            entry.SetData(newData ?? await tmdb.GetByFilename(filename));
            if (name != null)
            {
                entry.SetData(name);
            }
            return(entry);
        }
        // save edited movie
        public IActionResult SaveEdit(int movie_id, string title, string rating, string year, bool edited, string director, string lentto, string notes)
        {
            // get edited movies
            MovieEntry movie = _context.Movies.Where(m => m.MovieEntryID == movie_id).FirstOrDefault();

            //update values
            movie.Title    = title;
            movie.Rating   = rating;
            movie.Year     = year;
            movie.Edited   = edited;
            movie.Director = director;
            movie.LentTo   = lentto;
            movie.Notes    = notes;

            _context.SaveChanges();

            return(Redirect("/Home/EditMovie"));
        }
示例#23
0
        private async void LoadImage(MovieEntry entry)
        {
            if (entry == null)
            {
                //Model.PicPosterImage?.Dispose();
                Model.PicPosterImage = Commons.DefaultImage();
                return;
            }

            // remove old pict
            Model.PicPosterImage?.Dispose();
            Model.PicPosterImage = Commons.DefaultImage();

            // ReSharper disable once AssignNullToNotNullAttribute
            var posterPath  = Path.Combine(Path.GetDirectoryName(entry.FullPath), Commons.PosterFileName);
            var tmdb        = _kernel.Get <ITmdb>();
            var deleteAfter = false;

            // download if necessary
            if (!File.Exists(posterPath))
            {
                deleteAfter = true;
                posterPath  = Path.GetTempFileName();
                var uri = tmdb.GetPosterUrl(entry.PosterPath, PosterSize.w154);

                await tmdb.DownloadFile(uri, posterPath);
            }

            // load from file
            if (!File.Exists(posterPath))
            {
                return;
            }
            using (var stream = new FileStream(posterPath, FileMode.Open))
            {
                Model.PicPosterImage = Image.FromStream(stream);
            }

            // delete temp file
            if (deleteAfter)
            {
                File.Delete(posterPath);
            }
        }
        public IActionResult MoviePost(MovieEntry movieEntry)
        {
            if (ModelState.IsValid)
            {
                // save movie
                //TempStorage.addMovie(movieEntry);

                _context.Movies.Add(movieEntry);
                _context.SaveChanges();
                MovieList movies = new MovieList {
                    Movies = _context.Movies.Where(m => m.Title != "Independance Day")
                };
                // go to Movie List
                return(Redirect("/Home/EditMovie"));
            }
            else
            {
                return(View("MoviePost"));
            }
        }
示例#25
0
        public List <MovieEntry> GetMovieEntries(DateTime date)
        {
            _connection.Open();
            List <MovieEntry> results = new List <MovieEntry>();

            _cmd.CommandText = $"SELECT Id, Theater, Title, Start, End, CurrentCapacity, ImgPath FROM MovieEntry INNER JOIN Poster ON Poster.MovieTitle=MovieEntry.Title WHERE Date='{date.Date.ToString("d")}';";
            _reader          = _cmd.ExecuteReader();

            while (_reader.Read())
            {
                DateTime   start = DateTime.ParseExact(_reader.GetString(3), "yyyy-MM-dd HH:mm:ss", null);
                DateTime   end   = DateTime.ParseExact(_reader.GetString(4), "yyyy-MM-dd HH:mm:ss", null);
                MovieEntry entry = new MovieEntry(_reader.GetInt32(0), _reader.GetInt32(1), _reader.GetString(2), new Showtime(start, end), _reader.GetInt32(5), _reader.GetString(6));

                results.Add(entry);
            }
            _reader.Close();
            _connection.Close();
            return(results);
        }
示例#26
0
        private bool CheckDuration(MovieEntry entry)
        {
            _cmd.CommandText = $"SELECT Start, End FROM MovieEntry WHERE MovieEntry.Title='{entry.Title}';";
            _reader          = _cmd.ExecuteReader();

            bool isValid = false;

            if (_reader.Read())  //only need to check first one since all durations in entry match
            {
                DateTime dbStart = DateTime.ParseExact(_reader.GetString(0), "yyyy-MM-dd HH:mm:ss", null);
                DateTime dbEnd   = DateTime.ParseExact(_reader.GetString(1), "yyyy-MM-dd HH:mm:ss", null);

                isValid = dbStart - dbEnd == ((DateTime)entry.Showings[0].Start) - ((DateTime)entry.Showings[0].End);
                _reader.Close();
                return(isValid);
            }

            _reader.Close();
            return(true);
        }
示例#27
0
        private void HelperRenameFile(string path, MovieEntry entry)
        {
            // store original path
            var fileInfo         = new PowerPath(path);
            var originalFilePath = fileInfo.GetFullPath();

            // rename path
            var renamedFile = fileInfo.RenameFileByPattern(_settings.FileRenamePattern, entry);

            if (_settings.SwapThe)
            {
                renamedFile.SwapFileName(Commons.TheName);
            }

            // rename
            if (originalFilePath == renamedFile)
            {
                return;
            }
            File.Move(originalFilePath, renamedFile);
        }
示例#28
0
        /// <summary>
        /// Saves a new watching session and creates a new movie if necessary
        /// </summary>
        /// <param name="movieEntry">A movie entry</param>
        /// <returns>A JSON representation of a timeline entry</returns>
        public JsonResult QuickSave(MovieEntry movieEntry)
        {
            // Used to emulate a failure
            if (movieEntry.Director == "FAIL") {
                throw new Exception("Une erreur");
            }

            WatchingSession watchingSession;
            using (var uow = new UnitOfWork(true)) {
                var movie = uow.Movies.FindByTitle(movieEntry.Title) ??
                            new Movie() { Title = movieEntry.Title, Director = movieEntry.Director };

                watchingSession = new WatchingSession() { Date = DateTime.ParseExact(movieEntry.EntryDate, "dd/MM/yyyy", null) };
                movie.AddWatchingSession(watchingSession);

                uow.Movies.SaveOrUpdate(movie);
                uow.Commit();
            }

            var timelineEntry = new TimelineEntry(watchingSession, this);
            return Json(timelineEntry);
        }
示例#29
0
        private void HelperRenameDirectory(string path, MovieEntry entry)
        {
            // store original path
            var fileInfo     = new PowerPath(path);
            var originalPath = fileInfo.GetDirectoryPath();

            // rename path
            var renamedPath = fileInfo.RenameLastDirectoryByPattern(_settings.FolderRenamePattern, entry);

            if (_settings.SwapThe)
            {
                renamedPath.SwapLastDirectoryName(Commons.TheName);
            }
            var directoryPath = renamedPath.GetDirectoryPath();

            // rename
            if (originalPath == directoryPath)
            {
                return;
            }
            Directory.Move(originalPath, directoryPath);
        }
示例#30
0
        /// <summary>
        /// Load list of movies and metadata from library.
        /// </summary>
        public void LoadLibraryMovies(string libraryPath)
        {
            // Ensure this library was not already added.
            if (m_libraryPaths.Contains(libraryPath))
                return;

            // Add library directory to the list of libraries.
            m_libraryPaths.Add(libraryPath);

            // Get library subdirectories.
            AppLog.Instance.Log(AppLog.Severity.Debug, "Looking into library directory '" + libraryPath + "' for movies.");

            string[] movieDirs;
            try
            {
               movieDirs = Directory.GetDirectories(libraryPath);
            }
            catch (IOException exc)
            {
                AppLog.Instance.Log(AppLog.Severity.Error, "Couldn't access library directory '" + libraryPath + "': " + exc.Message);

                // Re-throw exception to caller.
                throw exc;
            }

            // Load movies from library path.
            foreach (string movieDir in movieDirs)
            {
                MovieEntry entry = new MovieEntry();
                entry.movieTag = movieDir.Substring(movieDir.LastIndexOf('\\') + 1);
                entry.moviePath = movieDir;
                entry.libraryPath = libraryPath;
                entry.movie = null;

                // Make sure there is no duplicate entry in the list.
                if (m_movies.Contains(entry.moviePath))
                    continue;

                Exception loadException = null;
                try
                {
                    // Load the movie metadata (if any).
                    entry.movie = LoadMovieMetadata(movieDir);

                    if (entry.movie == null)
                        AppLog.Instance.Log(AppLog.Severity.Debug, "\tNo metadata found for movie '" + entry.movieTag + "'.");
                    else
                        AppLog.Instance.Log(AppLog.Severity.Debug, "\tLoaded metadata for movie '" + entry.movieTag + "'.");
                }
                catch (Exception exc)
                {
                    AppLog.Instance.Log(AppLog.Severity.Error, "\tFailed to load metadata for movie '" + entry.movieTag + "'. Reason: " + exc.Message);
                    loadException = exc;
                }

                // Add the movie to the list.
                m_movies.Add(entry);

                // Notify event subscribers.
                MovieLoaded(entry, loadException);
            }
        }
示例#31
0
        /// <summary>
        /// Deletes all metadata associated with a movie.
        /// </summary>
        /// <param name="entry">Movie to delete metadata.</param>
        public void FlushMovieMetadata(MovieEntry entry)
        {
            AppLog.Instance.Log(AppLog.Severity.Debug, "Flushing metadata for movie '" + entry.moviePath + "'.");
            string metadataPath = entry.moviePath + "\\" + Constants.METADATA_PATH;
            string metadataFile = metadataPath + "\\" + Constants.METADATA_FILE;

            Exception deleteException = null;
            try
            {
                // Tell data managers to clear metadata.
                foreach (DataManager manager in m_dataManagers)
                    manager.Clear(entry);

                if (Directory.Exists(metadataPath))
                {
                    if (File.Exists(metadataFile))
                        File.Delete(metadataFile);

                    // Delete associated images.
                    if (entry.movie != null)
                    {
                        foreach (MovieImage mi in entry.movie.Images)
                        {
                            if (File.Exists(mi.path))
                                File.Delete(mi.path);
                        }
                    }

                    // Try to delete directory.
                    Directory.Delete(metadataPath);
                }

            }
            catch (Exception exc)
            {
                deleteException = exc;
            }

            // Clear movie metadata.
            entry.movie = null;

            // Re-throw delete exception if one occurred.
            if (deleteException != null)
                throw deleteException;
        }
示例#32
0
 private void AddMetadataWith(MovieEntry entry)
 {
     // Add item to 'with' list.
     ListViewItem item = new ListViewItem();
     item.Tag = entry;
     item.Text = "";
     item.SubItems.Add(entry.movie.Name);
     item.SubItems.Add((entry.movie.Released != null) ? entry.movie.Released.Value.Year.ToString() : "");
     lvMetadataWith.Items.Add(item);
 }
示例#33
0
        private void FetchMetadataManual(MovieEntry entry)
        {
            // Show the manual metadata fetch form.
            frmManualFetch dialog = new frmManualFetch(entry, m_library.GetMetadataAccessor());
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                // Fetch the selected item by ID. Use the same fetching
                // infrastructure as with the automated fetch.
                List<MovieEntry> entries = new List<MovieEntry>();

                entry.manualID = dialog.SelectedID;
                entries.Add(entry);

                FetchMetadata(entries);
            }
        }
示例#34
0
        public void Add(MovieEntry entry)
        {
            if (entry.movie == null)
                return;

            string[] idparts = GetID(entry);
            string dvdidFile = entry.moviePath + "\\" + entry.movieTag + ".dvdid.xml";
            if (!File.Exists(dvdidFile))
            {
                // Create dvdid file.
                XDocument idDoc = GenerateIDXML(entry.movie, idparts);
                idDoc.Save(dvdidFile);
            }

            string dvdinfofile = m_infoCachePath + "\\" + idparts[0] + "-" + idparts[1] + ".xml";
            if (!File.Exists(dvdinfofile))
            {
                // Create dvdinfo file.
                XDocument infoDoc = GenerateInfoXml(entry.movie, idparts);
                infoDoc.Save(dvdinfofile);
            }

            string dvdimagefile = m_imageCachePath + "\\" + idparts[0] + "-" + idparts[1] + ".jpg";
            if (!File.Exists(dvdimagefile))
            {
                // Resize and save image to image cache as JPEG.
                if (entry.movie.Images.Count > 0)
                {
                    string sourceImage = entry.movie.Images.First().path;

                    using (Bitmap originalImage = new Bitmap(sourceImage))
                    {
                        using (Bitmap resizedImage = new Bitmap(COVER_RESIZE_WIDTH, COVER_RESIZE_HEIGHT))
                        {
                            using (Graphics surface = Graphics.FromImage(resizedImage))
                            {
                                surface.SmoothingMode = SmoothingMode.AntiAlias;
                                surface.InterpolationMode = InterpolationMode.HighQualityBicubic;
                                surface.PixelOffsetMode = PixelOffsetMode.HighQuality;
                                surface.DrawImage(originalImage, 0, 0, resizedImage.Width, resizedImage.Height);
                            }

                            resizedImage.Save(dvdimagefile, ImageFormat.Jpeg);
                        }
                    }
                }
            }
        }
示例#35
0
 public void MovieLoadEventHandler(MovieEntry entry, Exception loadException)
 {
     // Add the item to the correct list (depending on whether or
     // not it already has metadata available).
     if (entry.movie != null)
     {
         AddMetadataWith(entry);
     }
     else
     {
         if (loadException != null)
             AddMetadataWithout(entry, "Error loading metadata for movie from file.");
         else
             AddMetadataWithout(entry);
     }
 }
示例#36
0
            public void FetchAsync(MovieEntry entry)
            {
                m_doneEvent.Reset();

                Thread workerThread = new Thread(new ParameterizedThreadStart(DoFetch));
                workerThread.Start(entry);
            }
示例#37
0
        public void Clear(MovieEntry entry)
        {
            string[] idparts = GetID(entry);

            string dvdidFile = entry.moviePath + "\\" + entry.movieTag + ".dvdid.xml";
            if (File.Exists(dvdidFile))
                File.Delete(dvdidFile);

            string dvdinfofile = m_infoCachePath + "\\" + idparts[0] + "-" + idparts[1] + ".xml";
            if (File.Exists(dvdinfofile))
                File.Delete(dvdinfofile);

            string dvdimagefile = m_imageCachePath + "\\" + idparts[0] + "-" + idparts[1] + ".jpg";
            if (File.Exists(dvdimagefile))
                File.Delete(dvdimagefile);
        }
        public void aLoad(Stream fileStream)
        {
            base.Load(fileStream);
            var reader = new ExtendedBinaryReader(fileStream);
            var array  = Instructions[0].GetArgument <byte[]>(1);

            for (int i = 0; i < array.Length / 4; ++i)
            {
                int address = BitConverter.ToInt32(array, i * 4);
                SystemText.Add(reader.ReadStringElsewhere(address));
            }
            array = Instructions[1].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x6C; ++i)
            {
                int nameAddress = BitConverter.ToInt32(array, i * 0x6C);
                var entry       = new CGEntry();
                entry.Name          = reader.ReadStringElsewhere(nameAddress);
                entry.ID            = BitConverter.ToInt32(array, i * 0x6C + 0x0004);
                entry.CGID          = BitConverter.ToInt32(array, i * 0x6C + 0x0008);
                entry.CGID2         = BitConverter.ToInt32(array, i * 0x6C + 0x000C);
                entry.Unknown5      = BitConverter.ToUInt32(array, i * 0x6C + 0x0010);
                entry.Unknown6      = BitConverter.ToUInt16(array, i * 0x6C + 0x0014);
                entry.TextureWidth  = BitConverter.ToInt16(array, i * 0x6C + 0x0016);
                entry.TextureHeight = BitConverter.ToInt16(array, i * 0x6C + 0x0018);
                entry.Unknown7      = BitConverter.ToUInt16(array, i * 0x6C + 0x001A);
                entry.Unknown81     = array[i * 0x6C + 0x001C];
                entry.Unknown82     = array[i * 0x6C + 0x001D];
                entry.Unknown83     = array[i * 0x6C + 0x001E];
                entry.Page          = array[i * 0x6C + 0x001F];
                entry.FrameCount    = array[i * 0x6C + 0x0020];
                entry.GameID        = (GameID)array[i * 0x6C + 0x0021];
                entry.Unknown93     = array[i * 0x6C + 0x0022];
                entry.Unknown94     = array[i * 0x6C + 0x0023];
                entry.Unknown10     = BitConverter.ToUInt32(array, i * 0x6C + 0x0024);
                entry.Unknown11     = BitConverter.ToUInt32(array, i * 0x6C + 0x0028);
                entry.Unknown12     = BitConverter.ToUInt32(array, i * 0x6C + 0x002C);
                entry.Unknown13     = BitConverter.ToUInt32(array, i * 0x6C + 0x0030);
                entry.Unknown14     = BitConverter.ToUInt32(array, i * 0x6C + 0x0034);
                entry.Unknown15     = BitConverter.ToUInt32(array, i * 0x6C + 0x0038);
                entry.Unknown16     = BitConverter.ToUInt32(array, i * 0x6C + 0x003C);
                entry.Unknown17     = BitConverter.ToUInt32(array, i * 0x6C + 0x0040);
                entry.Unknown18     = BitConverter.ToUInt32(array, i * 0x6C + 0x0044);
                entry.Unknown19     = BitConverter.ToUInt32(array, i * 0x6C + 0x0048);
                entry.Unknown20     = BitConverter.ToUInt32(array, i * 0x6C + 0x004C);
                entry.Unknown21     = BitConverter.ToUInt32(array, i * 0x6C + 0x0050);
                entry.Unknown22     = BitConverter.ToUInt32(array, i * 0x6C + 0x0054);
                entry.Unknown23     = BitConverter.ToUInt32(array, i * 0x6C + 0x0058);
                entry.Unknown24     = BitConverter.ToUInt32(array, i * 0x6C + 0x005C);
                entry.Unknown25     = BitConverter.ToUInt32(array, i * 0x6C + 0x0060);
                entry.Unknown26     = BitConverter.ToUInt32(array, i * 0x6C + 0x0064);
                entry.Unknown27     = BitConverter.ToUInt32(array, i * 0x6C + 0x0068);
                CGs.Add(entry);
            }

            array = Instructions[2].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x10; ++i)
            {
                var entry = new MovieEntry();
                entry.FriendlyName = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x10 + 0));
                entry.FilePath     = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x10 + 4));
                entry.ID           = BitConverter.ToInt32(array, i * 0x10 + 8);
                entry.Unknown4     = array[i * 0x10 + 12];
                entry.GameID       = (GameID)array[i * 0x10 + 13];
                entry.Unknown5     = BitConverter.ToInt16(array, i * 0x10 + 14);
                Movies.Add(entry);
            }

            array = Instructions[3].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x10; ++i)
            {
                var entry = new MemoryEntry();
                entry.Name        = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x10 + 0));
                entry.Description = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x10 + 4));
                entry.ID          = BitConverter.ToInt32(array, i * 0x10 + 8);
                entry.GameID      = (GameID)array[i * 0x10 + 12];
                entry.Game        = (MemoryEntry.MemoryGame)array[i * 0x10 + 13];
                Memories.Add(entry);
            }

            array = Instructions[4].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x08; ++i)
            {
                var entry = new CharacterEntry();
                entry.FriendlyName = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x08 + 0));
                entry.ID           = BitConverter.ToInt32(array, i * 0x08 + 4);
                Characters.Add(entry);
            }
            array = Instructions[5].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x08; ++i)
            {
                var entry = new Unknown2Entry();
                entry.Unknown1 = BitConverter.ToInt32(array, i * 0x08 + 0);
                entry.Unknown2 = BitConverter.ToInt32(array, i * 0x08 + 4);
                Unknown2.Add(entry);
            }
            array = Instructions[6].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x06; ++i)
            {
                var entry = new Unknown3Entry();
                entry.ID       = BitConverter.ToInt16(array, i * 0x06 + 0);
                entry.Unknown2 = BitConverter.ToInt32(array, i * 0x06 + 2);
                Unknown3.Add(entry);
            }
            array = Instructions[7].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x10; ++i)
            {
                var entry = new VoiceEntry();
                entry.UnknownName  = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x10 + 0));
                entry.KnownName    = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x10 + 4));
                entry.PreferedName = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x10 + 8));
                entry.ID           = BitConverter.ToInt32(array, i * 0x10 + 12);
                Voices.Add(entry);
            }
            array = Instructions[8].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x06; ++i)
            {
                var entry = new Unknown4Entry();
                entry.Unknown1 = BitConverter.ToInt16(array, i * 0x06 + 0);
                entry.Unknown2 = BitConverter.ToInt32(array, i * 0x06 + 2);
                Unknown4.Add(entry);
            }
            array = Instructions[9].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x14; ++i)
            {
                var entry = new ArtBookPageEntry();
                entry.PagePathThumbnail = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x14 + 0));
                entry.PagePathData      = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x14 + 4));
                entry.Name   = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x14 + 8));
                entry.ID     = BitConverter.ToInt32(array, i * 0x14 + 12);
                entry.GameID = (GameID)BitConverter.ToInt16(array, i * 0x14 + 16);
                entry.Page   = BitConverter.ToInt16(array, i * 0x14 + 18);
                ArtBookPages.Add(entry);
            }
            array = Instructions[10].GetArgument <byte[]>(1);
            for (int i = 0; i < array.Length / 0x1C; ++i)
            {
                var entry = new DramaCDEntry();
                entry.FileName      = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x1C + 0));
                entry.FriendlyName  = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x1C + 4));
                entry.SourceAlbum   = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x1C + 8));
                entry.InternalName  = reader.ReadStringElsewhere(BitConverter.ToInt32(array, i * 0x1C + 12));
                entry.ID            = BitConverter.ToInt16(array, i * 0x1C + 16);
                entry.Game          = (GameID)BitConverter.ToInt16(array, i * 0x1C + 18);
                entry.Unknown7      = BitConverter.ToInt16(array, i * 0x1C + 20);
                entry.SourceTrackID = BitConverter.ToInt16(array, i * 0x1C + 22);
                entry.Unknown9      = BitConverter.ToInt16(array, i * 0x1C + 24);
                DramaCDs.Add(entry);
            }

            return;
        }
示例#39
0
        private static string[] GetID(MovieEntry entry)
        {
            // Concatenate the header and first 8 characters of
            // the MD5 of the full path to the movie to construct the id.
            MD5 hasher = MD5.Create();
            byte[] hashData = hasher.ComputeHash(Encoding.Default.GetBytes(entry.moviePath));

            StringBuilder hash = new StringBuilder();
            for (int i = 0; i < 4; i++)
                hash.Append(hashData[i].ToString("X2"));

            string[] idparts = new string[2];
            idparts[0] = DVDID_HEADER;
            idparts[1] = hash.ToString();

            return idparts;
        }
示例#40
0
        private void AddMetadataWithout(MovieEntry entry, string errorMessage = null)
        {
            // Add item to 'without' list.
            ListViewItem item = new ListViewItem();
            item.Tag = entry;
            item.Text = "";

            if (errorMessage != null)
            {
                item.ImageIndex = 0;
                item.ToolTipText = errorMessage;
            }

            item.SubItems.Add(entry.movieTag);
            item.SubItems.Add(entry.moviePath);
            lvMetadataWithout.Items.Add(item);
        }
示例#41
0
        /// <summary>
        /// Fetches metadata for a given movie. This method is
        /// thread-safe. Throws an exception on failure.
        /// </summary>
        /// <param name="entry">Entry to fetch.</param>
        public void FetchMovieMetadata(MovieEntry entry)
        {
            if (!m_movies.Contains(entry))
                throw new Exception("Movie entry does not exist in library.");

            // Clear previous metadata if it exists.
            FlushMovieMetadata(entry);

            AppLog.Instance.Log(AppLog.Severity.Debug, "Fetching metadata for '" + entry.moviePath + "'.");

            // Create metadata directory for movie if it doesn't exist.
            CreateMetadataDir(entry.moviePath);

            // If the ID was not provided, search for movie and pick first result.
            string movieID;
            if (!string.IsNullOrEmpty(entry.manualID))
            {
                movieID = entry.manualID;
            }
            else
            {
                IEnumerable<MovieSearchResult> results = m_accessor.SearchMovies(entry.movieTag, null);
                if (results.Count() < 1)
                    throw new NoResultsFoundException("No results found for specified movie.");

                MovieSearchResult result = results.First();
                movieID = result.ID;
            }

            // Fetch the movie.
            Movie movie = m_accessor.FetchMovie(movieID, entry.moviePath + "\\" + Constants.METADATA_PATH);

            lock (entry)
            {
                entry.movie = movie;

                // Write the metadata to disk.
                WriteMovieMetadata(entry.moviePath, entry.movie);

                // Notify data managers of the change.
                foreach (DataManager manager in m_dataManagers)
                    manager.Add(entry);
            }
        }
示例#42
0
        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            float tempRating;
            int   tempRuntime;

            switch (ResultTabControl.SelectedIndex)
            {
            case 1:
                int tempVotes;
                int tempYear;
                float.TryParse(MovieRating.Text, NumberStyles.Float, AppSettings.CInfo, out tempRating);
                int.TryParse(MovieRuntime.Text, NumberStyles.Integer, AppSettings.CInfo, out tempRuntime);
                int.TryParse(MovieVotes.Text, NumberStyles.Integer, AppSettings.CInfo, out tempVotes);
                int.TryParse(MovieYear.Text, NumberStyles.Integer, AppSettings.CInfo, out tempYear);

                ResultMovieData = new MovieEntry
                {
                    Casts     = _castList.Casts,
                    Aired     = "1969-12-31",
                    Premiered = "1969-12-31",
                    Code      = "",
                    Countries =
                        MovieCountry.Text.Split(new[] { " / " }, StringSplitOptions.RemoveEmptyEntries).ToList(),
                    DateAdded = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    Directors =
                        MovieDirector.Text.Split(new[] { " / " }, StringSplitOptions.RemoveEmptyEntries).ToList(),
                    EpBookmark   = 0f,
                    FanartImages = _backdropsList.ToList(),
                    Genres       =
                        MovieGenre.Text.Split(new[] { " / " }, StringSplitOptions.RemoveEmptyEntries).ToList(),
                    ImdbID        = MovieImdbId.Text,
                    LastPlayed    = "1969-12-31",
                    MPAARating    = MovieMPAARating.Text,
                    OriginalTitle = MovieOriginalTitle.Text,
                    Outline       = "",
                    PlayCount     = 0,
                    Plot          = MoviePlot.Text,
                    PosterImages  = _postersList.ToList(),
                    Rating        = tempRating,
                    Runtime       = tempRuntime,
                    SetNames      =
                        MovieSetName.Text.Split(new[] { " / " }, StringSplitOptions.RemoveEmptyEntries).ToList(),
                    SortTitle = MovieSortTitle.Text,
                    Status    = "",
                    Studios   =
                        MovieStudio.Text.Split(new[] { " / " }, StringSplitOptions.RemoveEmptyEntries).ToList(),
                    Tagline = MovieTagline.Text,
                    Title   = MovieTitle.Text,
                    Top250  = 0,
                    Trailer = MovieTrailer.Text,
                    Votes   = tempVotes,
                    Writers =
                        MovieWriters.Text.Split(new[] { " / " }, StringSplitOptions.RemoveEmptyEntries).ToList(),
                    Year = tempYear,
                    SelectedBackdropImage = ((MovieDBImageInfo)MovieBackdropList.SelectedItem).UrlOriginal,
                    SelectedPosterImage   = ((MovieDBPosterImage)MoviePosterList.SelectedItem).UrlOriginal
                };
                break;

            case 2:
                float.TryParse(TvShowEpisodeRating.Text, NumberStyles.Float, AppSettings.CInfo, out tempRating);
                int.TryParse(TvShowEpisodeRuntime.Text, NumberStyles.Integer, AppSettings.CInfo, out tempRuntime);
                ResultEpisodeData = new EpisodeEntry
                {
                    Title      = TvShowEpisodeTitle.Text,
                    ImdbID     = TvShowEpisodeImdbId.Text,
                    DateAdded  = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"),
                    Code       = "",
                    LastPlayed = "1969-12-31",
                    Aired      = TvShowEpisodeFirstAired.Text,
                    Rating     = tempRating,
                    Runtime    = tempRuntime,
                    Directors  =
                        TvShowEpisodeDirector.Text.Split(new[] { " / " }, StringSplitOptions.RemoveEmptyEntries)
                        .ToList(),
                    Writers =
                        TvShowEpisodeWriter.Text.Split(new[] { " / " }, StringSplitOptions.RemoveEmptyEntries)
                        .ToList(),
                    Plot    = TvShowEpisodePlot.Text,
                    Studios = TvShowNetwork.Text.Split(new[] { " / " }, StringSplitOptions.RemoveEmptyEntries)
                              .ToList(),
                    DisplayEpisode = ((DBTvShowEpisode)TvShowEpisodeNumber.SelectedItem).EpisodeNumber,
                    DisplaySeason  = ((DBTvShowSeason)TvShowSeason.SelectedItem).SeasonNumber,
                    Episode        = ((DBTvShowEpisode)TvShowEpisodeNumber.SelectedItem).EpisodeNumber,
                    Season         = ((DBTvShowSeason)TvShowSeason.SelectedItem).SeasonNumber,
                    MPAARating     = TvShowMpaaRating.Text,
                    ShowTitle      = TvShowTitle.Text,
                    PosterImage    =
                        new MovieDBImageInfo
                    {
                        UrlOriginal = ((DBTvShowEpisode)TvShowEpisodeNumber.SelectedItem).EpisodeImageUrl
                    },
                    SelectedPosterImage = ((DBTvShowEpisode)TvShowEpisodeNumber.SelectedItem).EpisodeImageUrl,
                    Casts     = _castList.Casts,
                    Premiered = TvShowFirstAired.Text
                };

                List <string> gStars = ((DBTvShowEpisode)TvShowEpisodeNumber.SelectedItem).GuestStars;
                foreach (string gStar in gStars)
                {
                    ResultEpisodeData.Casts.Add(new MovieDBCast {
                        Name = gStar
                    });
                }

                break;
            }
            SearchString = MediaTitleInfo.Text;
            AppSettings.LastSelectedSource = DataSource.SelectedIndex;
            DialogResult = true;
        }
示例#43
0
 public ResearchMovieView(MovieEntry entry)
 {
     InitializeComponent();
     _oldEntry = entry;
 }