private void LoadGameDialogIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if (IsVisible) { DataContext = SavedGameManager.FindSavedGames(); } if (IsLoaded) { Focus(); SaveGameList.Focus(); } }
private void SaveGameDialogIsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e) { if (!((bool)e.NewValue)) { return; } DataContext = SavedGameManager.FindSavedGames(includeAutoSave: false); SaveGameFilename.Clear(); SaveGameFilename.Text = GenerateFileName(GameContext.Current); SaveGameFilename.Focus(); SaveGameFilename.SelectAll(); }
public static void UpdateJumpList() { //works GameLog.Print("UpdateJumpList (List of saved games)"); var savedGames = ( from savedGame in SavedGameManager.FindSavedGames() let file = SavedGameManager.GetSavedGameFile(savedGame) where file.Exists orderby savedGame.Timestamp descending select savedGame ) .Take(10) .ToList(); var jumpListCreated = false; JumpList jumpList = null; Application.Current.Dispatcher.Invoke( DispatcherPriority.Background, (Action) (() => jumpList = JumpList.GetJumpList(Application.Current))); if (jumpList == null) { jumpList = new JumpList(); jumpListCreated = true; } else { jumpList.JumpItems.Clear(); } var entryExe = typeof(ClientModule).Assembly.Location; var singlePlayerCategory = ResourceManager.GetString("SAVED_SINGLE_PLAYER_GAMES_CATEGORY"); var multiplayerCategory = ResourceManager.GetString("SAVED_MULTIPLAYER_GAMES_CATEGORY"); var singlePlayerDescription = ResourceManager.GetString("SAVED_SINGLE_PLAYER_GAME_DESCRIPTION"); var multiplayerDescription = ResourceManager.GetString("SAVED_MULTIPLAYER_GAME_DESCRIPTION"); var iconFiles = savedGames .Select(o => o.LocalPlayerEmpireName) .Distinct() .Select(o => new { EmpireName = o, IconFile = FindEmpireShellIcon(o) }) .ToDictionary(o => o.EmpireName); foreach (var savedGame in savedGames) { AddToJumpList( jumpList, savedGame, savedGame.IsAutoSave ? _autoSaveGameTitle.Value : Path.GetFileNameWithoutExtension(savedGame.FileName), entryExe, iconFiles[savedGame.LocalPlayerEmpireName].IconFile, savedGame.IsMultiplayerGame ? multiplayerCategory : singlePlayerCategory, savedGame.IsMultiplayerGame ? multiplayerDescription : singlePlayerDescription); } Application.Current.Dispatcher.Invoke( DispatcherPriority.Background, (Action) (() => { if (jumpListCreated) { JumpList.SetJumpList( Application.Current, jumpList); } jumpList.Apply(); })); }