예제 #1
0
        void dBListView_ItemSelectionChanged(object sender, ListViewItemSelectionChangedEventArgs e)
        {
            //if no items are selected, or we have just started selecting multiple items, clear the panel.
            //With multiple selections, only call the below code on the 2nd selection otherwise it will be
            //called for every new item added - which is unnecessary and expensive.
            if (dBListView.SelectedItems.Count == 2)
            {
                selectedGame     = null;
                selectedListItem = null;
                if (itemThumbs != null)
                {
                    itemThumbs.Dispose();
                    itemThumbs = null;
                }
                clearPanel();
                return;
            }

            //When the user changes selection in the list view the SelectionChanged event is fired twice,
            //once for the item losing selection and once for the item gaining it, ensure we only
            //update once.
            if (!e.IsSelected || dBListView.SelectedItems.Count > 1)
            {
                return;
            }

            updateGame();

            selectedListItem = dBListView.SelectedItems[0];
            setRomToPanel(selectedListItem);
        }
예제 #2
0
        public bool IsMissingInfo()
        {
            if (this.GameID == -2)
            {
                return(true);
            }
            if (String.IsNullOrEmpty(this.Title))
            {
                return(true);
            }
            if (this.Grade == 0)
            {
                return(true);
            }
            if (this.Yearmade == 0)
            {
                return(true);
            }
            if (String.IsNullOrEmpty(this.Description))
            {
                return(true);
            }
            if (String.IsNullOrEmpty(this.Genre))
            {
                return(true);
            }
            if (String.IsNullOrEmpty(this.Company))
            {
                return(true);
            }
            //don't technically need to dispose of ThumbGroup as we don't load any images
            //but just in case
            using (ThumbGroup thumbs = new ThumbGroup(this))
            {
                if (string.IsNullOrEmpty(thumbs.FrontCover.Path))
                {
                    return(true);
                }
                if (string.IsNullOrEmpty(thumbs.BackCover.Path))
                {
                    return(true);
                }
                if (string.IsNullOrEmpty(thumbs.InGame.Path))
                {
                    return(true);
                }
                if (string.IsNullOrEmpty(thumbs.TitleScreen.Path))
                {
                    return(true);
                }
                if (string.IsNullOrEmpty(thumbs.Fanart.Path))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #3
0
        void updateThumbs(string oldId, string newId, DataType dataType, bool merge)
        {
            if (thumbDir == null || (dataType != DataType.Emulator && dataType != DataType.Game))
            {
                return;
            }

            string dirName;

            if (dataType == DataType.Emulator)
            {
                dirName = ThumbGroup.EMULATOR_DIR_NAME;
            }
            else
            {
                dirName = ThumbGroup.GAME_DIR_NAME;
            }

            string currDir = string.Format(@"{0}\{1}\{2}", thumbDir, dirName, oldId);

            if (!Directory.Exists(currDir))
            {
                return;
            }

            string newDir = string.Format(@"{0}\{1}\{2}\{3}", Emulators2Settings.Instance.ThumbDirectory, ThumbGroup.THUMB_DIR_NAME, dirName, newId);

            if (!Directory.Exists(newDir))
            {
                try
                {
                    Directory.CreateDirectory(newDir);
                }
                catch (Exception ex)
                {
                    Logger.LogError("Unable to create thumb directory '{0}' - {1}", newDir, ex.Message);
                    return;
                }
            }

            foreach (string file in Directory.GetFiles(currDir))
            {
                if (isThumb(file) && (!merge || !thumbExists(newDir, Path.GetFileNameWithoutExtension(file))))
                {
                    try
                    {
                        string savePath = newDir + "\\" + Path.GetFileName(file);
                        File.Copy(file, savePath, true);
                        ThumbGroup.RemoveAlternateThumb(savePath);
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError("Unable to copy thumb to new directory '{0}' - {1}", newDir, ex.Message);
                        continue;
                    }
                }
            }
        }
예제 #4
0
        void ThumbPanel_DoubleClick(object sender, EventArgs e)
        {
            if (ThumbGroup == null)
            {
                return;
            }

            ThumbGroup.LaunchThumb(ThumbType);
        }
예제 #5
0
        void setGameArt(ThumbGroup thumbGroup)
        {
            bool lAllowEvents = allowChangedEvents;

            allowChangedEvents   = false;
            pnlLogo.ThumbGroup   = thumbGroup;
            pnlFanart.ThumbGroup = thumbGroup;
            allowChangedEvents   = lAllowEvents;
        }
예제 #6
0
 internal void UpdateGameInfo(Game game)
 {
     lock (syncRoot)
     {
         Label          = game.Title;
         AssociatedGame = game;
         thumbGroup     = null;
         ThumbnailImage = ThumbGroup.FrontCoverDefaultPath;
     }
 }
예제 #7
0
        void setGameArt(ThumbGroup thumbGroup)
        {
            bool lAllowEvents = allowChangedEvents;

            allowChangedEvents         = false;
            pnlBoxFront.ThumbGroup     = thumbGroup;
            pnlBoxBack.ThumbGroup      = thumbGroup;
            pnlTitleScreen.ThumbGroup  = thumbGroup;
            pnlInGameScreen.ThumbGroup = thumbGroup;
            pnlFanart.ThumbGroup       = thumbGroup;
            allowChangedEvents         = lAllowEvents;
        }
예제 #8
0
        private void newEmuButton_Click(object sender, EventArgs e)
        {
            newEmu = null;
            using (Wzd_NewEmu_Main wzd = new Wzd_NewEmu_Main())
            {
                if (wzd.ShowDialog() == DialogResult.OK)
                {
                    newEmu = wzd.NewEmulator;
                }

                if (newEmu != null)
                {
                    updateEmulator();
                    updateProfile();
                    newEmu.Save();
                    Emulators2Settings.Instance.Importer.Restart();
                    using (ThumbGroup thumbGroup = new ThumbGroup(newEmu))
                    {
                        if (wzd.Logo != null)
                        {
                            thumbGroup.FrontCover.Image = wzd.Logo;
                            thumbGroup.SaveThumb(ThumbType.FrontCover);
                            wzd.Logo.Dispose();
                        }
                        if (wzd.Fanart != null)
                        {
                            thumbGroup.Fanart.Image = wzd.Fanart;
                            thumbGroup.SaveThumb(ThumbType.Fanart);
                            wzd.Fanart.Dispose();
                        }
                    }

                    ListViewItem item = new ListViewItem(newEmu.Title)
                    {
                        Tag = newEmu
                    };
                    emulatorListView.Items.Add(item);
                    selectedListItem = item;
                    emulatorListView.SelectedItems.Clear();
                    if (selectedListItem != null)
                    {
                        selectedListItem.Selected = true;
                    }
                    else if (emulatorListView.Items.Count > 0)
                    {
                        emulatorListView.Items[0].Selected = true;
                    }
                }
            }
        }
예제 #9
0
        void clearForm()
        {
            allowChangedEvents = false;

            saveSelectedEmulator = false;
            saveProfile          = false;
            saveThumbs           = false;

            txt_Title.Text       = "";
            romDirTextBox.Text   = "";
            filterTextBox.Text   = "";
            txt_company.Text     = "";
            txt_yearmade.Text    = "";
            txt_description.Text = "";
            gradeUpDown.Value    = 0;

            thumbAspectComboBox.Text = "";

            txt_Manual.Text = "";
            idLabel.Text    = "";

            enableGoodCheckBox.Checked = false;
            videoTextBox.Text          = "";

            if (platformComboBox.Items.Count > 0)
            {
                platformComboBox.SelectedIndex = 0;
            }
            emuPathTextBox.Text       = "";
            argumentsTextBox.Text     = "";
            workingDirTextBox.Text    = "";
            useQuotesCheckBox.Checked = true;
            suspendMPCheckBox.Checked = false;
            goodComboBox.Text         = "";

            mountImagesCheckBox.Checked     = false;
            escExitCheckBox.Checked         = false;
            checkControllerCheckBox.Checked = false;

            if (emuThumbs != null)
            {
                emuThumbs.Dispose();
                emuThumbs = null;
            }
            pnlLogo.ThumbGroup   = null;
            pnlFanart.ThumbGroup = null;

            allowChangedEvents = true;
        }
예제 #10
0
        void ThumbPanel_DragDrop(object sender, DragEventArgs e)
        {
            if (ThumbGroup == null)
            {
                return;
            }

            if (e.Data.GetDataPresent(typeof(Bitmap)))
            {
                ThumbGroup.UpdateThumb(ThumbType, (Bitmap)e.Data.GetData(typeof(Bitmap)));
                this.BackgroundImage = ThumbGroup.GetThumb(ThumbType);
            }
            else if (e.Data.GetDataPresent(DataFormats.FileDrop, false))
            {
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
                ThumbGroup.UpdateThumb(ThumbType, files[0]);
                this.BackgroundImage = ThumbGroup.GetThumb(ThumbType);
            }
        }
예제 #11
0
 internal void DeleteThumbs()
 {
     using (ThumbGroup thumbs = new ThumbGroup(this))
     {
         System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(thumbs.ThumbPath);
         if (dir.Exists)
         {
             Logger.LogDebug("Deleting thumb folder {0}", dir.FullName);
             try
             {
                 dir.Delete(true);
             }
             catch (Exception ex)
             {
                 Logger.LogDebug("Failed to delete pre-existing thumb folder {0} - {1}", dir.FullName, ex.Message);
             }
         }
     }
 }
예제 #12
0
 /// <summary>
 /// Reset the game object to a blank state. Only the filepath and filename remains.
 /// </summary>
 public void Reset()
 {
     this.Title       = titleFromPath(Path);
     this.Grade       = 0;
     this.Yearmade    = 0;
     this.Description = "";
     this.Genre       = "";
     this.Company     = "";
     this.Hash        = "";
     using (ThumbGroup thumbs = new ThumbGroup(this))
     {
         thumbs.FrontCover.Image  = null;
         thumbs.BackCover.Image   = null;
         thumbs.InGame.Image      = null;
         thumbs.TitleScreen.Image = null;
         thumbs.Fanart.Image      = null;
         thumbs.SaveAllThumbs();
     }
 }
예제 #13
0
        public static void LaunchDocument(DBItem item)
        {
            string manualPath = null;

            using (ThumbGroup thumbGroup = new ThumbGroup(item))
                manualPath = thumbGroup.ManualPath;

            if (string.IsNullOrEmpty(manualPath))
            {
                return;
            }

            //Execute
            using (Process proc = new Process())
            {
                proc.StartInfo          = new ProcessStartInfo();
                proc.StartInfo.FileName = manualPath;
                proc.Start();
            }
        }
예제 #14
0
        void clearPanel()
        {
            allowChangedEvents = false;

            idLabel.Text = "";

            lblPath.Text = "";

            txt_Title.Text       = "";
            txt_company.Text     = "";
            txt_description.Text = "";
            txt_yearmade.Text    = "";
            txt_genre.Text       = "";
            gradeUpDown.Value    = 0;
            txt_Manual.Text      = "";

            chk_Visible.Checked   = false;
            chk_Favourite.Checked = false;

            videoTextBox.Text = "";

            label14.Text        = "";
            playCountLabel.Text = "";
            lastPlayLabel.Text  = "";

            profileComboBox.Items.Clear();

            setGameArt(null);
            if (itemThumbs != null)
            {
                itemThumbs.Dispose();
                itemThumbs = null;
            }

            discBindingSource.Clear();

            allowChangedEvents = true;
        }
예제 #15
0
        void updateEmuInfo()
        {
            if (selectedEmulator == null)
            {
                return;
            }

            updateEmulator();
            updateProfile();

            EmulatorInfo lEmuInfo = new EmulatorScraperHandler().UpdateEmuInfo(selectedEmulator.PlatformTitle, (o) =>
            {
                EmulatorInfo emuInfo = (EmulatorInfo)o;
                if (emuInfo == null)
                {
                    return(false);
                }

                if (!string.IsNullOrEmpty(emuInfo.Title))
                {
                    selectedEmulator.Title = emuInfo.Title;
                }

                if (!string.IsNullOrEmpty(emuInfo.Developer))
                {
                    selectedEmulator.Company = emuInfo.Developer;
                }

                int grade;
                if (!string.IsNullOrEmpty(emuInfo.Grade) && int.TryParse(emuInfo.Grade, out grade))
                {
                    selectedEmulator.Grade = grade;
                }

                string description = emuInfo.GetDescription();
                if (!string.IsNullOrEmpty(description))
                {
                    selectedEmulator.Description = description;
                }

                using (ThumbGroup thumbGroup = new ThumbGroup(selectedEmulator))
                {
                    if (!string.IsNullOrEmpty(emuInfo.LogoUrl))
                    {
                        thumbGroup.FrontCover.Path = emuInfo.LogoUrl;
                        thumbGroup.SaveThumb(ThumbType.FrontCover);
                    }
                    if (!string.IsNullOrEmpty(emuInfo.FanartUrl))
                    {
                        thumbGroup.Fanart.Path = emuInfo.FanartUrl;
                        thumbGroup.SaveThumb(ThumbType.Fanart);
                    }
                }

                selectedEmulator.Save();
                return(true);
            });

            if (lEmuInfo != null)
            {
                setEmulatorToPanel(selectedListItem);
            }
        }
예제 #16
0
        private void delEmuButton_Click(object sender, EventArgs e)
        {
            if (selectedEmulator == null || selectedEmulator.UID < 0)
            {
                return;
            }

            if (MessageBox.Show(
                    string.Format("Are you sure you want to remove {0} and\r\nall of it's associated games from the database?", selectedEmulator.Title),
                    "Delete Emulator?",
                    MessageBoxButtons.YesNo)
                != DialogResult.Yes)
            {
                return;
            }

            saveSelectedEmulator = false;
            saveThumbs           = false;
            saveProfile          = false;

            List <Game> games = DB.Instance.GetGames(selectedEmulator);

            if (games.Count > 0)
            {
                Importer importer = Emulators2Settings.Instance.Importer;
                BackgroundTaskHandler <Game> handler = new BackgroundTaskHandler <Game>()
                {
                    Items = games
                };
                handler.StatusDelegate = o => { return("removing " + o.Title); };
                handler.ActionDelegate = o =>
                {
                    importer.Remove(o.GameID);
                    using (ThumbGroup thumbGroup = new ThumbGroup(o))
                    {
                        try
                        {
                            if (System.IO.Directory.Exists(thumbGroup.ThumbPath))
                            {
                                System.IO.Directory.Delete(thumbGroup.ThumbPath, true);
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.LogError("Error deleting {0} thumb directory - {1}", o.Title, ex.Message);
                        }
                    }
                    return(true);
                };

                using (Conf_ProgressDialog progressDlg = new Conf_ProgressDialog(handler))
                    progressDlg.ShowDialog();
            }
            selectedEmulator.Delete();

            if (selectedListItem != null)
            {
                int index = selectedListItem.Index;
                if (index > 0)
                {
                    index--;
                }
                emulatorListView.Items.Remove(selectedListItem);
                if (emulatorListView.Items.Count > index)
                {
                    emulatorListView.SelectedItems.Clear();
                    emulatorListView.Items[index].Selected = true;
                }
            }
        }
예제 #17
0
        void delRomButton_Click(object sender, EventArgs e)
        {
            if (importGridView.SelectedRows.Count < 1)
            {
                return;
            }

            if (MessageBox.Show(
                    "Are you sure you want to delete the selected Game(s) and add them to the ignored files list?",
                    "Delete Game(s)?",
                    MessageBoxButtons.YesNo) != DialogResult.Yes)
            {
                return;
            }

            List <Game> games = new List <Game>();

            foreach (DataGridViewRow row in importGridView.SelectedRows)
            {
                RomMatch match = row.DataBoundItem as RomMatch;
                if (match != null && match.Game != null)
                {
                    games.Add(match.Game);
                }
            }

            BackgroundTaskHandler <Game> handler = new BackgroundTaskHandler <Game>()
            {
                Items = games
            };

            handler.StatusDelegate = o => { return("removing " + o.Title); };
            handler.ActionDelegate = o =>
            {
                importer.Remove(o.GameID);
                using (ThumbGroup thumbGroup = new ThumbGroup(o))
                {
                    try
                    {
                        if (System.IO.Directory.Exists(thumbGroup.ThumbPath))
                        {
                            System.IO.Directory.Delete(thumbGroup.ThumbPath, true);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError("Error deleting {0} thumb directory - {1}", o.Title, ex.Message);
                    }
                }

                Options.Instance.AddIgnoreFile(o.Path);
                foreach (GameDisc disc in o.GetDiscs())
                {
                    Options.Instance.AddIgnoreFile(disc.Path);
                }
                return(true);
            };

            using (Conf_ProgressDialog progressDlg = new Conf_ProgressDialog(handler))
                progressDlg.ShowDialog();

            string sql = "DELETE FROM {0} WHERE gameid IN ({1})";
            string ids = "";

            for (int x = 0; x < games.Count; x++)
            {
                if (x > 0)
                {
                    ids += ",";
                }
                ids += games[x].GameID;
            }
            lock (DB.Instance.SyncRoot)
            {
                DB.Instance.Execute(sql, Game.TABLE_NAME, ids);
                DB.Instance.Execute(sql, GameDisc.TABLE_NAME, ids);
            }
        }
예제 #18
0
        void delRomButton_Click(object sender, EventArgs e)
        {
            if (dBListView.SelectedItems.Count == 0)
            {
                return;
            }

            DialogResult dlg = MessageBox.Show(
                "Are you sure you want to delete the selected Game(s) and add them to the ignored files list?",
                "Delete Game(s)?",
                MessageBoxButtons.YesNo);

            if (dlg != DialogResult.Yes)
            {
                return;
            }

            saveSelectedGame = false;
            saveThumbs       = false;
            savePCSettings   = false;
            saveDiscs        = false;

            Importer    importer = Emulators2Settings.Instance.Importer;
            List <Game> games    = new List <Game>();

            foreach (ListViewItem item in dBListView.SelectedItems)
            {
                games.Add((Game)item.Tag);
            }

            BackgroundTaskHandler <Game> handler = new BackgroundTaskHandler <Game>()
            {
                Items = games
            };

            handler.StatusDelegate = o => { return("removing " + o.Title); };
            handler.ActionDelegate = o =>
            {
                importer.Remove(o.GameID);
                using (ThumbGroup thumbGroup = new ThumbGroup(o))
                {
                    try
                    {
                        if (System.IO.Directory.Exists(thumbGroup.ThumbPath))
                        {
                            System.IO.Directory.Delete(thumbGroup.ThumbPath, true);
                        }
                    }
                    catch (Exception ex)
                    {
                        Logger.LogError("Error deleting {0} thumb directory - {1}", o.Title, ex.Message);
                    }
                }

                Options.Instance.AddIgnoreFile(o.Path);
                foreach (GameDisc disc in o.GetDiscs())
                {
                    Options.Instance.AddIgnoreFile(disc.Path);
                }
                return(true);
            };

            using (Conf_ProgressDialog progressDlg = new Conf_ProgressDialog(handler))
                progressDlg.ShowDialog();

            string sql = "DELETE FROM {0} WHERE gameid IN ({1})";
            string ids = "";

            for (int x = 0; x < games.Count; x++)
            {
                if (x > 0)
                {
                    ids += ",";
                }
                ids += games[x].GameID;
            }
            DB.Instance.Execute(sql, Game.TABLE_NAME, ids);
            DB.Instance.Execute(sql, GameDisc.TABLE_NAME, ids);

            dBListView.SelectedItems.Clear();
            UpdatePanel();
        }
예제 #19
0
        //update panel with Game info
        void setRomToPanel(ListViewItem listViewItem)
        {
            saveSelectedGame = false;
            saveThumbs       = false;
            saveDiscs        = false;
            savePCSettings   = false;
            Game dbRom = listViewItem.Tag as Game;

            selectedGame = dbRom;

            if (dbRom == null)
            {
                return;
            }

            allowChangedEvents = false;
            if (dbRom.ParentEmulator.IsPc())
            {
                if (!tabControl1.TabPages.Contains(pcSettingsTab))
                {
                    tabControl1.TabPages.Insert(1, pcSettingsTab);
                }
            }
            else
            {
                tabControl1.TabPages.Remove(pcSettingsTab);
            }

            //update ThumbGroup
            if (itemThumbs != null)
            {
                itemThumbs.Dispose();
            }
            itemThumbs = new ThumbGroup(dbRom);
            if (tabControl1.SelectedTab == thumbsTab)
            {
                setGameArt(itemThumbs); //load thumbs to panels
                thumbsLoaded = true;
            }
            else
            {
                setGameArt(null);
                thumbsLoaded = false;
            }
            idLabel.Text = dbRom.GameID.ToString();
            lblPath.Text = dbRom.Path;

            txt_Title.Text       = dbRom.Title;
            txt_company.Text     = dbRom.Company;
            txt_description.Text = dbRom.Description;
            txt_yearmade.Text    = dbRom.Yearmade.ToString();
            txt_genre.Text       = dbRom.Genre;
            gradeUpDown.Value    = dbRom.Grade;

            txt_Manual.Text = itemThumbs.ManualPath;

            chk_Visible.Checked   = dbRom.Visible;
            chk_Favourite.Checked = dbRom.Favourite;

            videoTextBox.Text = dbRom.VideoPreview;

            playCountLabel.Text = dbRom.Playcount.ToString();
            lastPlayLabel.Text  = dbRom.Latestplay.ToShortDateString();

            loadProfileDropdown(dbRom);

            discBindingSource.Clear();

            List <GameDisc> discs = dbRom.GetDiscs();

            int index = dbRom.CurrentDiscNum - 1;

            if (index > discs.Count - 1)
            {
                index = discs.Count - 1;
            }
            if (index < 0)
            {
                index = 0;
            }

            for (int x = 0; x < discs.Count; x++)
            {
                discs[x].Number = x + 1;
                if (x == index)
                {
                    discs[x].Selected = true;
                }
                discBindingSource.Add(discs[x]);
            }

            setPCSettings(dbRom);
            allowChangedEvents = true;
        }
예제 #20
0
        //Updates the panels with the selected Emulator's details.
        private void setEmulatorToPanel(ListViewItem listViewItem)
        {
            //reset status flags
            saveSelectedEmulator = false;
            saveThumbs           = false;
            saveProfile          = false;
            //get the selected Emulator
            Emulator dbEmu = listViewItem.Tag as Emulator;

            selectedEmulator = dbEmu;

            if (dbEmu == null)
            {
                return;
            }

            allowChangedEvents = false;

            int index = platformComboBox.FindStringExact(dbEmu.PlatformTitle);

            if (index < 0)
            {
                index = 0;
            }

            if (index < platformComboBox.Items.Count)
            {
                platformComboBox.SelectedItem = platformComboBox.Items[index];
            }

            txt_Title.Text           = dbEmu.Title;
            romDirTextBox.Text       = dbEmu.PathToRoms;
            filterTextBox.Text       = dbEmu.Filter;
            isArcadeCheckBox.Checked = dbEmu.IsArcade;
            txt_company.Text         = dbEmu.Company;
            txt_yearmade.Text        = dbEmu.Year.ToString();
            txt_description.Text     = dbEmu.Description;
            gradeUpDown.Value        = dbEmu.Grade;

            EmuSettingsAutoFill.SetupAspectDropdown(thumbAspectComboBox, dbEmu.CaseAspect);

            videoTextBox.Text = dbEmu.VideoPreview;

            idLabel.Text = dbEmu.UID.ToString();

            if (emuThumbs != null)
            {
                emuThumbs.Dispose();
            }
            emuThumbs = new ThumbGroup(dbEmu);

            if (mainTabControl.SelectedTab == thumbsTabPage)
            {
                setGameArt(emuThumbs);
                thumbsLoaded = true;
            }
            else
            {
                setGameArt(null);
                thumbsLoaded = false;
            }

            txt_Manual.Text = emuThumbs.ManualPath;


            selectedProfile = null;
            profileComboBox.Items.Clear();
            foreach (EmulatorProfile profile in DB.Instance.GetProfiles(selectedEmulator))
            {
                profileComboBox.Items.Add(profile);
                if (profile.IsDefault)
                {
                    profileComboBox.SelectedItem = profile;
                    selectedProfile = profile;
                }
            }

            allowChangedEvents = true;
            profileComboBox_SelectedIndexChanged(profileComboBox, new EventArgs());
        }