public Game(SockClient client, int questionCount, int timePerQuestion)
        {
            InitializeComponent();
            this.client                 = client;
            this.questionCount          = questionCount;
            this.timePerQuestion        = timePerQuestion;
            this.questionNum            = (TextBlock)this.FindName("QuestionNum");
            this.currQuestion           = (TextBlock)this.FindName("CurrQuestion");
            this.timer                  = (TextBlock)this.FindName("Timer");
            this.question               = (TextBlock)this.FindName("Question");
            this.op1                    = (Button)this.FindName("Op1");
            this.op2                    = (Button)this.FindName("Op2");
            this.op3                    = (Button)this.FindName("Op3");
            this.op4                    = (Button)this.FindName("Op4");
            this.questionNum.Text       = questionCount.ToString();
            this.currQuestion.Text      = "1";
            timer.Text                  = timePerQuestion.ToString();
            this.questionTimer          = new DispatcherTimer();
            this.questionTimer.Tick    += new EventHandler(TimerTick);
            this.questionTimer.Interval = new TimeSpan(0, 0, 1);
            var currQuestion = this.client.GetQuestion();

            this.question.Text = currQuestion.question;
            this.op1.Content   = currQuestion.answers[0];
            this.op2.Content   = currQuestion.answers[1];
            this.op3.Content   = currQuestion.answers[2];
            this.op4.Content   = currQuestion.answers[3];
            this.questionTimer.Start();
        }
 public JoinRoom(SockClient client)
 {
     InitializeComponent();
     empty       = (TextBlock)this.FindName("EmptyTxt");
     roomList    = (ListBox)this.FindName("RoomList");
     this.client = client;
     Room[] rooms = this.client.GetRooms().Rooms;
     roomLst = new List <RoomData>();
     if (rooms.Length < 1)
     {
         ((TextBlock)this.FindName("EmptyTxt")).Visibility = Visibility.Visible;
     }
     for (int i = 0; i < rooms.Length; i++)
     {
         int playersInRoom = this.client.GetPlayers(new GetPlayersRequest(rooms[i].id)).players.Length;
         roomLst.Add(new RoomData(rooms[i].name + " ", playersInRoom, rooms[i].maxPlayers, rooms[i].id, rooms[i].timePerQuestion, rooms[i].questionsCount));
     }
     roomList.ItemsSource = roomLst;
     roomUpdater          = new BackgroundWorker
     {
         WorkerReportsProgress      = true,
         WorkerSupportsCancellation = true
     };
     roomUpdater.DoWork += UpdateRoomList;
     roomUpdater.RunWorkerAsync();
 }
Example #3
0
 public RegisterWindow(SockClient client)
 {
     InitializeComponent();
     this.registerBtn  = (Button)this.FindName("registerBtn");
     this.userBox      = (TextBox)this.FindName("usernameBox");
     this.passBox      = (PasswordBox)this.FindName("passwordBox");
     this.emailTextBox = (TextBox)this.FindName("emailBox");
     this.client       = client;
 }
Example #4
0
        public Leaderboard(SockClient client)
        {
            InitializeComponent();
            this.client = client;
            this.grid   = (DataGrid)this.FindName("Grid");
            var res = this.client.GetLeaderboard();

            this.grid.ItemsSource = res.players;
        }
Example #5
0
 public PersonalStatistics(SockClient client)
 {
     InitializeComponent();
     DataContext          = this;
     this.client          = client;
     this.response        = this.client.GetStatistics();
     gameCount            = this.response.numOfPlayerGames;
     correctAnswersCount  = this.response.numOfCorrectAnswers;
     totalAnswersCount    = this.response.numOfTotalAnswers;
     averageTimeForAnswer = this.response.averageTimeForAnswer;
 }
Example #6
0
        public RoomInfo(SockClient client, bool isAdmin)
        {
            InitializeComponent();
            this.client          = client;
            this.thisWindow      = (Window)this.FindName("this");
            this.closeButton     = (Button)this.FindName("CloseButton");
            this.startButton     = (Button)this.FindName("StartButton");
            this.leaveButton     = (Button)this.FindName("LeaveButton");
            this.participantList = (ListBox)this.FindName("ParticipantList");
            this.maxTxt          = (TextBlock)this.FindName("MaxTxt");
            this.timeText        = (TextBlock)this.FindName("TimeTxt");
            this.numTxt          = (TextBlock)this.FindName("NumTxt");
            this.nameTxt         = (TextBlock)this.FindName("NameTxt");
            GetRoomStateResponse state = this.client.GetRoomState();

            this.numTxt.Text   = state.questionCount.ToString();
            this.maxTxt.Text   = state.maxPlayers.ToString();
            this.timeText.Text = state.answerTimeout.ToString();
            this.nameTxt.Text  = state.name;
            this.roomId        = state.id;
            if (isAdmin)
            {
                closeButton.Visibility = Visibility.Visible;
                startButton.Visibility = Visibility.Visible;
                leaveButton.Visibility = Visibility.Hidden;
                leaveButton.IsEnabled  = false;
            }
            else
            {
                closeButton.Visibility = Visibility.Hidden;
                closeButton.IsEnabled  = false;
                startButton.Visibility = Visibility.Hidden;
                startButton.IsEnabled  = false;
                leaveButton.Visibility = Visibility.Visible;
            }
            this.participants = new List <Participant>();
            foreach (var player in this.client.GetRoomState().players)
            {
                participants.Add(new Participant(player));
            }
            this.participantList.ItemsSource = participants;
            this.participantUpdate           = new BackgroundWorker
            {
                WorkerReportsProgress      = true,
                WorkerSupportsCancellation = true
            };
            participantUpdate.DoWork += UpdateParticipants;
            participantUpdate.RunWorkerAsync();
        }
 public EndOfGame(SockClient client)
 {
     InitializeComponent();
     this.client        = client;
     this.leaderboard   = (DataGrid)this.FindName("Leaderboard");
     this.border        = (Border)this.FindName("Border");
     this.txt           = (TextBlock)this.FindName("Txt");
     this.resultsWorker = new BackgroundWorker
     {
         WorkerReportsProgress      = true,
         WorkerSupportsCancellation = true
     };
     this.resultsWorker.DoWork += UpdateLeaderboard;
     this.resultsWorker.RunWorkerAsync();
 }
Example #8
0
 public MainWindow(SockClient client)
 {
     InitializeComponent();
     this.client = client;
 }
Example #9
0
 public MainWindow()
 {
     InitializeComponent();
     client = new SockClient();
 }
 public MainMenu(SockClient client)
 {
     InitializeComponent();
     this.client = client;
     cm          = this.FindResource("cmStatistics") as ContextMenu;
 }
 public CreateRoomWindow(SockClient client)
 {
     InitializeComponent();
     this.client = client;
 }