private async void Window_Loaded(object sender, RoutedEventArgs e) { var games = await BotzoneProtocol.GetGames(); ViewModel.AllGames.RemoveAt(0); ViewModel.AllGames.AddRange(games); ViewModel.GamesLoaded = true; var lastGame = Properties.Settings.Default.LastSelectedGame; if (lastGame?.Length > 0) { ViewModel.CurrentConfiguration.Game = ViewModel.AllGames.First(x => x.Name == lastGame); // Dirty hack……设置Game后,绑定了Type的ComboBox会在下一时刻更新Type,并覆盖掉这里的初值…… // 所以要等一时刻 await Task.Delay(500); if (LastConf.Configuration?.Length > 0) { for (int i = 0; i < LastConf.Configuration.Length; i++) { ViewModel.CurrentConfiguration[i].Type = LastConf.Configuration[i].Type; ViewModel.CurrentConfiguration[i].ID = LastConf.Configuration[i].ID; } } } }
public override async Task AbortMatch() { if (Runner.CurrentProcess != null) { Runner.CurrentProcess.Kill(); } await BotzoneProtocol.AbortMatch(MatchID); await base.AbortMatch(); }