Esempio n. 1
0
        private void NavigateGridPictures(CuratorDataSet.ROMRow rom, Func <int, int> direction)
        {
            var currentIndex = GridPictureImageLocations.IndexOf(romDetailsGridPicture.ImageLocation);

            int newIndex = GetNewIndex(currentIndex, direction, GridPictureImageLocations);

            if (newIndex >= 0)
            {
                romDetailsGridPicture.ImageLocation = GridPictureImageLocations[newIndex];

                if (rom.GridPicture != GridPictureImageLocations[newIndex])
                {
                    _romController.SetGridImage(rom, GridPictureImageLocations[newIndex]);
                }
            }

            romDetailsPictureIndex.Text = $"{newIndex} of {GridPictureImageLocations.Count -1}";

            var romDetailsPictureIndexToolTip = new ToolTip();

            romDetailsPictureIndexToolTip.Active   = false;
            romDetailsPictureIndex.Style           = MetroColorStyle.Default;
            romDetailsPictureIndex.UseStyleColors  = false;
            romDetails_helpToolStripButton.Visible = false;

            //1 means nothing was found, as a blank image is always added to the collection
            if (GridPictureImageLocations.Count == 1)
            {
                romDetails_helpToolStripButton.Visible = true;
            }
        }
Esempio n. 2
0
        public string GetExePath(CuratorDataSet.ROMRow rom, CuratorDataSet.ConsoleRow console)
        {
            var romArgs = rom.OverrideArgs ? rom.CustomArgs : $"{console.RomArgs} {rom.CustomArgs}";

            var exepath = $"\"{console.EmulatorPath}\" {console.EmulatorArgs} \"{rom.FileName}\"";

            if (!string.IsNullOrWhiteSpace(romArgs))
            {
                exepath += $" {romArgs}";
            }

            return(exepath);
        }
Esempio n. 3
0
        public static async Task FetchGamePictures(CuratorDataSet.ROMRow rom)
        {
            var urlEncodedROMName = GetUrlEncodedROMName(rom.Name);

            await PopulateGamesList(urlEncodedROMName);

            var bigPictureFilePath     = Path.Combine(ImageLocation, Path.GetFileNameWithoutExtension(rom.FileName).TrimEnd(' '), "Big Picture").TrimEnd(' ');
            var libraryPictureFilePath = Path.Combine(ImageLocation, Path.GetFileNameWithoutExtension(rom.FileName).TrimEnd(' '), "Library").TrimEnd(' ');

            if (!_gamesDictionary.Where(x => x.Key == urlEncodedROMName).Any())
            {
                _gamesNotFound.Add(rom.Name);
                return;
            }

            var request = new RestRequest
            {
                Method   = Method.GET,
                Resource = $"/grids/game/{ _gamesDictionary[urlEncodedROMName]}"
            };

            request.AddHeader("Authorization", "Bearer 850ea77df1c635de67acc76bbb197bd7");
            request.AddParameter("dimensions", "legacy");

            var response = await _steamGridDbClient.ExecuteTaskAsync(request);

            var bigPictureGridUrls = JsonConvert.DeserializeObject <GridUrlsResponse>(response.Content).Data;

            await SaveImagesToDisc(bigPictureFilePath, bigPictureGridUrls);

            request.AddOrUpdateParameter("dimensions", "600x900");

            response = await _steamGridDbClient.ExecuteTaskAsync(request);

            var libraryPictureUrls = JsonConvert.DeserializeObject <GridUrlsResponse>(response.Content).Data;

            await SaveImagesToDisc(libraryPictureFilePath, libraryPictureUrls);

            if (bigPictureGridUrls.Count > 0)
            {
                rom.GridPicture = Directory.GetFiles(bigPictureFilePath)[0];
            }

            if (libraryPictureUrls.Count > 0)
            {
                rom.LibraryPicture = Directory.GetFiles(libraryPictureFilePath)[0];
            }
        }
Esempio n. 4
0
        private async Task LoadLibraryPic(CuratorDataSet.ROMRow rom)
        {
            await Task.Run(() =>
            {
                LibraryPictureImageLocations = new List <string> {
                    string.Empty
                };

                var imageDirectory = Path.Combine(SteamGridDbClient.ImageLocation, Path.GetFileNameWithoutExtension(rom.FileName).TrimEnd(' '), "Library").TrimEnd(' ');
                if (!Directory.Exists(imageDirectory))
                {
                    return;
                }

                LibraryPictureImageLocations.AddRange(Directory.GetFiles(imageDirectory));
            });
        }
Esempio n. 5
0
        private void NavigateLibraryPictures(CuratorDataSet.ROMRow rom, Func <int, int> direction)
        {
            var currentIndex = LibraryPictureImageLocations.IndexOf(romDetailsLibraryPicture.ImageLocation);

            int newIndex = GetNewIndex(currentIndex, direction, LibraryPictureImageLocations);

            if (newIndex >= 0)
            {
                romDetailsLibraryPicture.ImageLocation = LibraryPictureImageLocations[newIndex];

                if (rom.GridPicture != LibraryPictureImageLocations[newIndex])
                {
                    _romController.SetLibraryImage(rom, LibraryPictureImageLocations[newIndex]);
                }
            }

            romDetailsLibraryPictureIndex.Text    = $"{newIndex} of {LibraryPictureImageLocations.Count - 1}";
            romDetailsLibraryPictureIndex.Visible = true;
        }
Esempio n. 6
0
        public async void UpdateSelectedRomDetails(CuratorDataSet.ROMRow rom)
        {
            if (rom == null)
            {
                SetAllDetailsEmpty();
                return;
            }

            romDetailsName.Text                    = rom.Name;
            romDetailsFolder.Text                  = _romFolderController.GetRomFolderById(rom.RomFolder_Id).Path;
            romDetailsCustomArgs.Text              = rom.CustomArgs;
            romDetailsOverride.Checked             = rom.OverrideArgs;
            romDetailsEnabledToggle.Checked        = rom.Enabled;
            romDetailsGridPicture.ImageLocation    = rom.GridPicture;
            romDetailsLibraryPicture.ImageLocation = rom.LibraryPicture;
            romDetailsPathPreview.Text             = _steamController.GetExePath(rom, ActiveConsole);

            await LoadGridPictures(rom);

            NavigateGridPictures(rom, x => x + 0);
            NavigateLibraryPictures(rom, x => x + 0);
        }
Esempio n. 7
0
 public void SetLibraryImage(CuratorDataSet.ROMRow rom, string libraryPicturePath)
 {
     rom.LibraryPicture = libraryPicturePath;
 }
Esempio n. 8
0
 public void SetGridImage(CuratorDataSet.ROMRow rom, string gridPicturePath)
 {
     rom.GridPicture = gridPicturePath;
 }
Esempio n. 9
0
 public void RenameRom(CuratorDataSet.ROMRow rom, string newName)
 {
     rom.Name = newName;
     RomData.Rows[RomData.Rows.IndexOf(rom)].AcceptChanges();
 }
Esempio n. 10
0
 public void SetRomEnabledState(CuratorDataSet.ROMRow rom, bool enabled)
 {
     rom.Enabled = enabled;
 }
Esempio n. 11
0
 public string RomNameConstructor(CuratorDataSet.ROMRow romItem)
 {
     return($"{romItem.Name} ({romItem.Extension.Trim('.').ToUpper()})");
 }
Esempio n. 12
0
 private async Task LoadGridPictures(CuratorDataSet.ROMRow rom)
 {
     await LoadBigPictureImages(rom);
     await LoadLibraryPic(rom);
 }
Esempio n. 13
0
        public void RomListViewUpdateCheckedState(CuratorDataSet.ROMRow rom)
        {
            var romIndex = romListRoms.IndexOf(rom);

            romListView.Items[romIndex].Checked = rom.Enabled;
        }