Exemplo n.º 1
0
        void app_OnEndGameEnd(GeniusTetrisPlayer arg1, string arg2)
        {
            //Sorted player by their score
            CollectionViewSource sortedCollection         = new CollectionViewSource();
            ObservableCollection <ScorePlayer> allplayers = new ObservableCollection <ScorePlayer>(app.GameMembersList.Select(x => ScorePlayer.FromPlayer(x)));

            app.CurrentPlayer.Score = app.CurrentGame.Score;
            var Me = ScorePlayer.FromPlayer(app.CurrentPlayer);

            Me.IsYou = true;
            allplayers.Add(Me);
            foreach (var teamGrp in allplayers.GroupBy(x => x.TeamName))
            {
                var teamScore = teamGrp.Sum(x => x.Score);
                foreach (var player in teamGrp)
                {
                    player.TeamScore = teamScore;
                }
            }
            sortedCollection.Source = allplayers;
            var grp = new PropertyGroupDescription("TeamName");

            sortedCollection.GroupDescriptions.Add(grp);
            sortedCollection.SortDescriptions.Add(new SortDescription("Score", ListSortDirection.Descending));

            ScoresDlgUC dlg = new ScoresDlgUC();

            dlg.DataContext = sortedCollection;
            ModalService.ShowModal(dlg);
        }
Exemplo n.º 2
0
        private void WaitForOtherPlayers()
        {
            MessageDlgUC dlg = new MessageDlgUC(null,
                                                delegate
            {
                app.StopMultiPlayerGameWF();
                Console.WriteLine("user click on close button");
            }
                                                , false, false);

            dlg.Message = "Wait for players...(15 seconds)";
            ModalService.ShowModal(dlg);
            _PlayersBoard.Clear();
            _PlayersKey.Clear();
            app.StartMultiplayerGameWF();
        }
Exemplo n.º 3
0
        void app_OnGameRequestReceived(GeniusTetrisPlayer player, string message)
        {
            _PlayersBoard.Clear();
            _PlayersKey.Clear();
            ClearAllPlayersBoard();
            MessageDlgUC dlg = new MessageDlgUC(delegate
            {
                app.AcceptGameRequest();
            },
                                                delegate
            {
                app.RejectGameRequest();
            },
                                                true,
                                                true);

            dlg.Message = message;
            ModalService.ShowModal(dlg);
        }
Exemplo n.º 4
0
 private void Button_Click(object sender, RoutedEventArgs e)
 {
     _ = ModalService.ShowModal(this, "Modal", "This is a modal", "Aceptar", "Cancelar", true);
 }
Exemplo n.º 5
0
 public void ShowModalTest()
 {
     Assert.AreEqual(ModalService.ShowModal(BootstrapUISample.App.Current.MainWindow, "Titulo", "Hola", "Aceptar", "Cancelar", true), ModalResult.Accept);
 }
Exemplo n.º 6
0
        static void ShowException(Exception ex)
        {
            ExceptionDlgUC dlg = new ExceptionDlgUC(ex);

            ModalService.ShowModal(dlg);
        }
Exemplo n.º 7
0
        void OnGameWon(object sender, RoutedEventArgs e)
        {
            WonUC uc = new WonUC();

            ModalService.ShowModal(uc);
        }
Exemplo n.º 8
0
        void OnAbout(object sender, RoutedEventArgs e)
        {
            AboutUC uc = new AboutUC();

            ModalService.ShowModal(uc);
        }
Exemplo n.º 9
0
        private void OnGameAction(object sender, ExecutedRoutedEventArgs e)
        {
            if (e.Parameter != null)
            {
                string key = e.Parameter.ToString();
                if (!app.CurrentGame.Started)
                {
                    switch (key)
                    {
                    case "OnNetworkOptions":
                        ModalService.ShowModal(new OptionsUC(app.GameOptions));
                        break;

                    case "OnHelp":
                        ModalService.ShowModal(new HelpUC());
                        break;

                    case "OnAbout":
                        e.Handled = true;
                        OnAbout(null, null);
                        break;

                    case "ConnectToMesh":
                        this.board.PlayerName = app.GameOptions.Member;
                        app.ConnectToMesh();
                        break;

                    case "DisconnectToMesh":
                        this.board.PlayerName = app.GameOptions.Member;
                        app.DisconnectFromMesh();
                        break;

                    case "StartMultiplayerGame":
                        WaitForOtherPlayers();
                        break;

                    case "StartAlone":
                        ClearAllPlayersBoard();
                        this.board.GameOver = Visibility.Collapsed;
                        app.StartStandalone();
                        this.board.Focus();
                        break;
                    }
                    return;
                }
                switch (key)
                {
                case "Drop":
                    app.CurrentGame.Drop();
                    e.Handled = true;
                    break;

                case "Left":
                    app.CurrentGame.MoveLeft();
                    e.Handled = true;
                    break;

                case "Right":
                    app.CurrentGame.MoveRight();
                    e.Handled = true;
                    break;

                case "Down":
                    app.CurrentGame.MoveDown();
                    e.Handled = true;
                    break;

                case "Up":
                    app.CurrentGame.RotateRight();
                    e.Handled = true;
                    break;

                case "1":
                case "2":
                case "3":
                case "4":
                case "5":
                case "6":
                case "7":
                case "8":
                case "9":
                    app.CurrentGame.SendNextOption(GetReceiver(key));
                    break;

                case "StopGame":
                    app.CurrentGame.Stop();
                    break;

#if DEBUG
                case "a":
                    Game.Options.Add((byte)'r');
                    ((TetrisMultiplayerApplicationBase)app)._Game_OnOptionsChanged(Game, EventArgs.Empty);
                    break;
#endif
                }
            }
        }