Ejemplo n.º 1
0
        private void LoadPictures()
        {
            try
            {
                pictureBoxBoxart.Image   = null;
                pictureBoxTitle.Image    = null;
                pictureBoxGameplay.Image = null;

                if (!string.IsNullOrEmpty(RomFunctions.GetRomPicture(SelectedRom, Values.BoxartFolder)))
                {
                    pictureBoxBoxart.Image = Functions.CreateBitmap(RomFunctions.GetRomPicture(SelectedRom, Values.BoxartFolder));
                }

                if (!string.IsNullOrEmpty(RomFunctions.GetRomPicture(SelectedRom, Values.TitleFolder)))
                {
                    pictureBoxTitle.Image = Functions.CreateBitmap(RomFunctions.GetRomPicture(SelectedRom, Values.TitleFolder));
                }

                if (!string.IsNullOrEmpty(RomFunctions.GetRomPicture(SelectedRom, Values.GameplayFolder)))
                {
                    pictureBoxGameplay.Image = Functions.CreateBitmap(RomFunctions.GetRomPicture(SelectedRom, Values.GameplayFolder));
                }
            }
            catch (Exception ex)
            {
                FormCustomMessage.ShowError(ex.Message);
            }
        }
        private void buttonRemove_Click(object sender, EventArgs e)
        {
            Platform emu  = (Platform)comboBoxChoosePlatform.SelectedItem;
            var      roms = RomBusiness.GetAll().Where
                                (x =>
                                x.Platform != null &&
                                x.Platform.Name == emu.Name &&
                                (
                                    (radioButtonBoxart.Checked && !string.IsNullOrEmpty(RomFunctions.GetRomPicture(x, Values.BoxartFolder))) ||
                                    (radioButtonTitle.Checked && !string.IsNullOrEmpty(RomFunctions.GetRomPicture(x, Values.TitleFolder))) ||
                                    (radioButtonGameplay.Checked && !string.IsNullOrEmpty(RomFunctions.GetRomPicture(x, Values.GameplayFolder)))
                                )
                                ).ToList();

            int successfulFind = 0;

            string type = radioButtonBoxart.Checked ? Values.BoxartFolder : radioButtonTitle.Checked ? Values.TitleFolder : Values.GameplayFolder;

            foreach (var rom in roms)
            {
                if (type == Values.BoxartFolder)
                {
                    if (File.Exists(RomFunctions.GetRomPicture(rom, Values.BoxartFolder)))
                    {
                        File.Delete(RomFunctions.GetRomPicture(rom, Values.BoxartFolder));
                    }

                    successfulFind++;
                }
                else if (type == Values.TitleFolder)
                {
                    if (File.Exists(RomFunctions.GetRomPicture(rom, Values.TitleFolder)))
                    {
                        File.Delete(RomFunctions.GetRomPicture(rom, Values.TitleFolder));
                    }

                    successfulFind++;
                }
                else if (type == Values.GameplayFolder)
                {
                    if (File.Exists(RomFunctions.GetRomPicture(rom, Values.GameplayFolder)))
                    {
                        File.Delete(RomFunctions.GetRomPicture(rom, Values.GameplayFolder));
                    }

                    successfulFind++;
                }
            }

            FormCustomMessage.ShowSuccess("Number of successful rom pictures removed: " + successfulFind);
        }
Ejemplo n.º 3
0
        private void LoadPictures()
        {
            try
            {
                pictureBoxBoxart.Image   = null;
                pictureBoxTitle.Image    = null;
                pictureBoxGameplay.Image = null;

                if (dataGridView.SelectedRows.Count == 0)
                {
                    return;
                }

                Rom rom = (Rom)dataGridView.SelectedRows[0].Tag;

                if (rom == null)
                {
                    return;
                }

                if (rom.Platform == null)
                {
                    return;
                }

                var box      = RomFunctions.GetRomPicture(rom, Values.BoxartFolder);
                var title    = RomFunctions.GetRomPicture(rom, Values.TitleFolder);
                var gameplay = RomFunctions.GetRomPicture(rom, Values.GameplayFolder);

                if (!string.IsNullOrEmpty(box))
                {
                    pictureBoxBoxart.Image = Functions.CreateBitmap(box);
                }

                if (!string.IsNullOrEmpty(title))
                {
                    pictureBoxTitle.Image = Functions.CreateBitmap(title);
                }

                if (!string.IsNullOrEmpty(gameplay))
                {
                    pictureBoxGameplay.Image = Functions.CreateBitmap(gameplay);
                }
            }
            catch (Exception ex)
            {
                FormCustomMessage.ShowError(ex.Message);
            }
        }
Ejemplo n.º 4
0
        private void pictureBoxGameplay_MouseClick(object sender, MouseEventArgs e)
        {
            if (e.Button != MouseButtons.Right)
            {
                return;
            }

            try
            {
                if (dataGridView.SelectedRows.Count == 0)
                {
                    return;
                }

                Rom rom = (Rom)dataGridView.SelectedRows[0].Tag;
                ProcessStartInfo sInfo = new ProcessStartInfo(RomFunctions.GetRomPicture(rom, Values.GameplayFolder));
                Process.Start(sInfo);
            }
            catch (Exception ex)
            {
                FormCustomMessage.ShowError(ex.Message);
            }
        }
Ejemplo n.º 5
0
        private void buttonGetRomData_Click(object sender, EventArgs e)
        {
            try
            {
                //FormWait.ShowWait(this);

                if (textBoxId.Text == string.Empty)
                {
                    textBoxId.Text = SyncDataFunctions.DiscoverGameId(SelectedRom);

                    if (string.IsNullOrEmpty(textBoxId.Text))
                    {
                        FormCustomMessage.ShowError("Could not discover TheGamesDB Id");
                        return;
                    }
                }

                var access = "";
                var game   = APIFunctions.GetGameDetails(textBoxId.Text, SelectedRom.Platform, out access);

                if (game == null)
                {
                    FormCustomMessage.ShowError("Could not get rom data");
                    return;
                }

                textBoxDBName.Text = game.DBName;

                if (radioButtonOnlyMissing.Checked)
                {
                    if (string.IsNullOrEmpty(textBoxPublisher.Text))
                    {
                        textBoxPublisher.Text = game.Publisher;
                    }

                    if (string.IsNullOrEmpty(textBoxDeveloper.Text))
                    {
                        textBoxDeveloper.Text = game.Developer;
                    }

                    if (string.IsNullOrEmpty(textBoxDescription.Text))
                    {
                        textBoxDescription.Text = game.Description;
                    }

                    if (string.IsNullOrEmpty(textBoxYearReleased.Text))
                    {
                        textBoxYearReleased.Text = game.YearReleased;
                    }

                    if (string.IsNullOrEmpty(textBoxRating.Text))
                    {
                        textBoxRating.Text = game.Rating.ToString("#.#");
                    }

                    if (string.IsNullOrEmpty(comboBoxGenre.Text))
                    {
                        comboBoxGenre.SelectedValue = game.Genre != null ? game.Genre.Name : string.Empty;
                    }
                }
                else
                {
                    if (!string.IsNullOrEmpty(game.Publisher))
                    {
                        textBoxPublisher.Text = game.Publisher;
                    }

                    if (!string.IsNullOrEmpty(game.Developer))
                    {
                        textBoxDeveloper.Text = game.Developer;
                    }

                    if (!string.IsNullOrEmpty(game.Description))
                    {
                        textBoxDescription.Text = game.Description;
                    }

                    if (!string.IsNullOrEmpty(game.YearReleased))
                    {
                        textBoxYearReleased.Text = game.YearReleased;
                    }

                    if (game.Rating != 0)
                    {
                        textBoxRating.Text = game.Rating.ToString("#.#");
                    }
                }

                var box      = RomFunctions.GetRomPicture(SelectedRom, Values.BoxartFolder);
                var title    = RomFunctions.GetRomPicture(SelectedRom, Values.TitleFolder);
                var gameplay = RomFunctions.GetRomPicture(SelectedRom, Values.GameplayFolder);

                bool missingBox      = string.IsNullOrEmpty(box);
                bool missingTitle    = string.IsNullOrEmpty(title);
                bool missingGameplay = string.IsNullOrEmpty(gameplay);

                if (!missingBox && !missingTitle && !missingGameplay)
                {
                    //FormWait.CloseWait();
                    return;
                }

                string boxUrl      = string.Empty;
                string titleUrl    = string.Empty;
                string gameplayUrl = string.Empty;

                var found = APIFunctions.GetGameArtUrls(textBoxId.Text, out boxUrl, out titleUrl, out gameplayUrl, out access);

                if (!found)
                {
                    //FormWait.CloseWait();
                    return;
                }

                if (missingBox)
                {
                    Functions.SavePictureFromUrl(SelectedRom, boxUrl, Values.BoxartFolder, checkBoxSaveAsJpg.Checked);
                    boxToDeleteIfCanceled = RomFunctions.GetRomPicture(SelectedRom, Values.BoxartFolder);
                }

                if (missingTitle && !string.IsNullOrEmpty(titleUrl))
                {
                    Functions.SavePictureFromUrl(SelectedRom, titleUrl, Values.TitleFolder, checkBoxSaveAsJpg.Checked);
                    titleToDeleteIfCanceled = RomFunctions.GetRomPicture(SelectedRom, Values.TitleFolder);
                }

                if (missingGameplay && !string.IsNullOrEmpty(gameplayUrl))
                {
                    Functions.SavePictureFromUrl(SelectedRom, gameplayUrl, Values.GameplayFolder, checkBoxSaveAsJpg.Checked);
                    gameplayToDeleteIfCanceled = RomFunctions.GetRomPicture(SelectedRom, Values.GameplayFolder);
                }

                MessageBox.Show("Remaining access: " + access);
            }
            catch (Exception ex)
            {
                //FormWait.CloseWait();
                FormCustomMessage.ShowError(ex.Message);
            }
            finally
            {
                //FormWait.CloseWait();
            }
        }
        private void buttonAdd_Click(object sender, EventArgs e)
        {
            progressBar1.Value = 0;

            if (!Directory.Exists(textBoxDir.Text))
            {
                FormCustomMessage.ShowError("Directory doesn't exists");
                return;
            }

            Platform platform = (Platform)comboBoxChoosePlatform.SelectedItem;
            var      images   = Directory.GetFiles(textBoxDir.Text);
            var      roms     = RomBusiness.GetAll().Where
                                    (x =>
                                    x.Platform != null &&
                                    x.Platform.Name == platform.Name &&
                                    (
                                        (radioButtonBoxart.Checked && string.IsNullOrEmpty(RomFunctions.GetRomPicture(x, Values.BoxartFolder))) ||
                                        (radioButtonTitle.Checked && string.IsNullOrEmpty(RomFunctions.GetRomPicture(x, Values.TitleFolder))) ||
                                        (radioButtonGameplay.Checked && string.IsNullOrEmpty(RomFunctions.GetRomPicture(x, Values.GameplayFolder)))
                                    )
                                    ).ToList();

            int successfulFind = 0;

            progressBar1.Maximum = roms.Count < images.Length ? roms.Count : images.Length;
            string type = radioButtonBoxart.Checked ? Values.BoxartFolder : radioButtonTitle.Checked ? Values.TitleFolder : Values.GameplayFolder;

            Dictionary <string, Region> imageRegion = new Dictionary <string, Region>();

            foreach (var item in images)
            {
                imageRegion.Add(RomFunctions.GetFileName(item), RomFunctions.DetectRegion(item));
            }

            foreach (var rom in roms)
            {
                string imageFoundPath;
                var    found = RomFunctions.MatchImagesExact(images, rom.FileNameNoExt, out imageFoundPath);

                if (found)
                {
                    successfulFind++;

                    if (progressBar1.Value < progressBar1.Maximum)
                    {
                        progressBar1.Value++;
                    }

                    RomFunctions.SavePicture(rom, imageFoundPath, type, checkBoxSaveAsJpg.Checked);
                }
                else
                {
                    found = RomFunctions.MatchImages(images, imageRegion, rom.Name, out imageFoundPath);

                    if (found)
                    {
                        successfulFind++;

                        if (progressBar1.Value < progressBar1.Maximum)
                        {
                            progressBar1.Value++;
                        }

                        RomFunctions.SavePicture(rom, imageFoundPath, type, checkBoxSaveAsJpg.Checked);
                    }
                    else
                    {
                        found = RomFunctions.MatchImages(images, imageRegion, rom.FileNameNoExt, out imageFoundPath);

                        if (found)
                        {
                            successfulFind++;

                            if (progressBar1.Value < progressBar1.Maximum)
                            {
                                progressBar1.Value++;
                            }

                            RomFunctions.SavePicture(rom, imageFoundPath, type, checkBoxSaveAsJpg.Checked);
                        }
                    }
                }
            }

            progressBar1.Value = progressBar1.Maximum;
            FormCustomMessage.ShowSuccess("Number of successful rom pictures saved: " + successfulFind);
            progressBar1.Value = 0;
        }