Ejemplo n.º 1
0
 private void HandshakeError(object sender, ServerErrorEventArgs e)
 {
     TopMostMessageBox.Show("The server returned an error:\n" + e.Message, "Error", MessageBoxButton.OK,
                            MessageBoxImage.Error);
     e.Handled = true;
     Back();
 }
Ejemplo n.º 2
0
        private void ButtonJoinClick(object sender, RoutedEventArgs e)
        {
            if (WindowManager.PreGameLobbyWindow != null || 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 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 hostedgame = ListViewGameList.SelectedItem as HostedGameViewModel;

            if (hostedgame == null)
            {
                return;
            }
            var game = GameManager.Get().GetById(hostedgame.GameId);
            var task = new Task(() => this.StartJoinGame(hostedgame, game));

            task.ContinueWith((t) => { this.Dispatcher.Invoke(new Action(() => this.FinishJoinGame(t))); });
            BorderButtons.IsEnabled = false;
            task.Start();
        }
Ejemplo n.º 3
0
        private void SubscribeClick(object sender, RoutedEventArgs e)
        {
            Log.Info("Sub clicked");
            if ((SubBox.SelectedItem as SubType) == null)
            {
                return;
            }
            var subtype = (SubBox.SelectedItem as SubType);

            Log.InfoFormat("Sub clicked type {0}", subtype.Name);
            Task.Factory.StartNew(() =>
                                  this.ShowSubscribeSite(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);
                }
            });
        }
Ejemplo n.º 4
0
        private void GameListItemDoubleClick(object sender, MouseButtonEventArgs 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;
            }
            bool spectate = hostedgame.Status == EHostedGame.GameInProgress && hostedgame.Spectator;
            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();
        }
Ejemplo n.º 5
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);
         }
     });
 }