private void RenameUnmatchedFolders()
        {
            var result = System.Windows.MessageBox.Show("Sure you want to rename all folders checked?", "Rename folders", System.Windows.MessageBoxButton.YesNo);

            if (result == System.Windows.MessageBoxResult.Yes)
            {
                var foldersToRemove = new List <UnMatchedFolder>();

                //Add folders to Matched (CurrentGames)
                foreach (var folder in UnmatchedFolders.Where(x => x.Rename))
                {
                    try
                    {
                        Directory.Move(Path.Combine(CurrentMediaFolder, folder.FolderName), Path.Combine(CurrentMediaFolder, folder.RecommendedName));

                        foldersToRemove.Add(folder);

                        CurrentGames.Add(new TempGame {
                            HasFolder = true, RomName = folder.RecommendedName
                        });
                    }
                    catch (Exception) { }
                }

                //remove folders from unmatched
                foreach (var item in foldersToRemove)
                {
                    UnmatchedFolders.Remove(item);
                }
            }
        }
        public async Task LoadAndScanFolders()
        {
            IsBusy = false;

            try
            {
                CurrentGames.Clear();

                await Task.Run(() =>
                {
                    Directories = _rlScan.GetAllFolders(CurrentMediaFolder);
                    Results     = _rlScan.MatchFoldersToGames(Directories, _games);
                });

                Results.UnMatchedFolders.ForEach(folder =>
                {
                    UnmatchedFolders.Add(new UnMatchedFolder {
                        FolderName = folder
                    });
                });

                var games = _games.Select(x => new TempGame {
                    RomName = x.RomName, HasFolder = Results.MatchedFolders.Any(y => y == x.RomName)
                });
                foreach (var game in games)
                {
                    CurrentGames.Add(game);
                }
            }
            catch { }
            finally { IsBusy = true; }
        }
예제 #3
0
        private async void RefreshBoard()
        {
            //Refresh the board
            BoardSection.Clear();
            BoardSection.Add(new ViewCell()
            {
                View = common.Common.GetLoadingGridView("Loading The Board™")
            });
            Settings.Players = await BasicRequest <List <Player> >("Players/List", "POST");

            var boardStatus = await BasicRequest <Dictionary <string, decimal> >("Status/All", "POST");

            Settings.Players.Sort((x, y) => y.CurrentMargin.CompareTo(x.CurrentMargin));
            BoardSection.Clear();
            foreach (Player Play in Settings.Players)
            {
                var LabelColor = Color.Red;
                if (Play.Active)
                {
                    LabelColor = Color.White;
                }
                var Cell = new EntryCell()
                {
                    IsEnabled = false, Text = boardStatus[Play.Name].ToString("F2"), Label = Play.Name, LabelColor = LabelColor
                };
                BoardSection.Add(Cell);
            }

            //refresh the games
            CurrentGames.Clear();
            CurrentGames.Add(new ViewCell()
            {
                View = common.Common.GetLoadingGridView("Loading Current Games")
            });
            var Games = await BasicRequest <List <GameInfo> >("GamesPlayed/Unfinished", "POST");

            CurrentGameEntries = new Dictionary <TextCell, GameInfo>();
            Games.Sort((x, y) => y.GameUniqueId.CompareTo(x.GameUniqueId));
            CurrentGames.Clear();
            foreach (GameInfo game in Games)
            {
                var playernames = new List <string>();
                foreach (Player player in game.Players)
                {
                    playernames.Add(player.Name);
                }
                var Cell = new TextCell()
                {
                    Text = game.GameType.Name + " - £" + game.Entry.ToString("F2"), Detail = $"ID: {game.GameUniqueId} Players: {string.Join(", ",playernames)}"
                };
                Cell.Tapped += CurrentGamePress;
                CurrentGameEntries.Add(Cell, game);
                CurrentGames.Add(Cell);
            }
        }