コード例 #1
0
ファイル: CustomGames.xaml.cs プロジェクト: drilus/OCTGN
        private void ButtonJoinClick(object sender, RoutedEventArgs e)
        {
            if (WindowManager.PlayWindow != null)
            {
                MessageBox.Show(
                    "You are currently in a game or game lobby. Please leave before you join game.",
                    "OCTGN",
                    MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
                return;
            }
            var hostedgame = ListViewGameList.SelectedItem as HostedGameViewModel;

            if (hostedgame == null)
            {
                return;
            }
            if (hostedgame.Status == EHostedGame.GameInProgress && hostedgame.Spectator == false)
            {
                TopMostMessageBox.Show(
                    "You can't join a game in progress.",
                    "Error",
                    MessageBoxButton.OK,
                    MessageBoxImage.Information);
                return;
            }
            if (hostedgame.GameSource == "Online")
            {
                var client = new Octgn.Site.Api.ApiClient();
                if (!client.IsGameServerRunning(Program.LobbyClient.Username, Program.LobbyClient.Password))
                {
                    TopMostMessageBox.Show(
                        "The game server is currently down. Please try again later.",
                        "Error",
                        MessageBoxButton.OK,
                        MessageBoxImage.Information);
                    return;
                }
            }
            var game = GameManager.Get().GetById(hostedgame.GameId);

            if (game == null)
            {
                TopMostMessageBox.Show("You don't currently have that game installed.", "Error", MessageBoxButton.OK, MessageBoxImage.Information);
                return;
            }
            var spectate = hostedgame.Status == EHostedGame.GameInProgress && hostedgame.Spectator == true;
            var task     = new Task(() => this.StartJoinGame(hostedgame, game, spectate));

            task.ContinueWith((t) => { this.Dispatcher.Invoke(new Action(() => this.FinishJoinGame(t))); });
            BorderButtons.IsEnabled = false;
            task.Start();
        }
コード例 #2
0
 private void SubscribeClick(object sender, RoutedEventArgs e)
 {
     Log.Info("Sub clicked");
     Task.Factory.StartNew(() =>
                           this.ShowSubscribeSite(new SubType())).ContinueWith(x =>
     {
         if (x.Exception != null)
         {
             Log.Warn("Sub Problem", x.Exception);
             TopMostMessageBox.Show(
                 "Could not subscribe. Please visit "
                 + AppConfig.WebsitePath + " to subscribe.",
                 "Error",
                 MessageBoxButton.OK,
                 MessageBoxImage.Asterisk);
         }
     });
 }