private void RegisterButton_Click(object sender, EventArgs e) { if (loginBox.Text.Length > 0 && passBox.Text == repPassBox.Text && passBox.Text.Length > 0) { QuizClient quizClient = new QuizClient("127.0.0.1", 7777); quizClient.username = loginBox.Text; var stream = quizClient.Start(); if (QuizClient.Register(loginBox.Text, passBox.Text, stream)) { QuizClient.Disconnect(stream); stream.Close(); MessageBox.Show("Rejestracja przebiegła pomyślnie."); GoBack(); } else { QuizClient.Disconnect(stream); stream.Close(); MessageBox.Show("Wystąpił błąd. Sprawdź poprawnośc danych."); } } else { MessageBox.Show("Niepoprawne dane"); } }
private void EndForm_Load(object sender, EventArgs e) { this.messageLabel.Text = message; this.timeLeft.Text = "Pozostały czas:\n" + time.ToString(); this.totalResult.Text = "Uzyskane punkty:\n" + points.ToString(); if (!QuizClient.SendPoints(stream, points)) { MessageBox.Show("Nie udało się zsynchronizować wyników z serwerem"); } }
private void loadData() { PersonalStats personalStats = QuizClient.GetPersonalStats(stream); for (int i = 0; i < personalStats.stats.Length; i++) { DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone(); row.Cells[0].Value = personalStats.stats[i].category; row.Cells[1].Value = personalStats.stats[i].score; dataGridView1.Rows.Add(row); } }
private void getCategories() { Categories temp = QuizClient.GetCategories(stream); for (int i = 0; i < 9; i++) { if (i < temp.quizes.Count()) { categories[i].Text = temp.quizes[i]; } else { categories[i].Visible = false; } } }
//OBSŁUGA LOGOWANIA private bool login(string username, string password) { QuizClient quizClient = new QuizClient("127.0.0.1", 7777); quizClient.username = username; stream = quizClient.Start(); if (quizClient.Login(password, stream)) { return(true); } else { return(false); } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { var category = comboBox1.SelectedItem.ToString(); dataGridView1.Rows.Clear(); dataGridView1.Refresh(); //var category = comboBox1.SelectedIndex if (category.Length > 0) { var table = QuizClient.GetRanking(stream, category); if (table.stats != null) { for (int i = 0; i < table.stats.Length; i++) { DataGridViewRow row = (DataGridViewRow)dataGridView1.Rows[0].Clone(); row.Cells[0].Value = table.stats[i].username; row.Cells[1].Value = table.stats[i].score; dataGridView1.Rows.Add(row); } } } }
private void GetQuestions() { questions.Clear(); /*Question question = new Question("Ile mam rąk", "2", "3", "4", "5"); * questions.Add(question); * question = new Question("Ile mam włosów", "Duuuużo", "3", "4", "5"); * questions.Add(question); * question = new Question("Ile mam nóg", "2", "3", "4", "5"); * questions.Add(question); * question = new Question("Ile mam oczu", "2", "3", "4", "5"); * questions.Add(question); * question = new Question("Ile mam uszu", "2", "3", "4", "5"); * questions.Add(question); * question = new Question("Ile mam dłoni", "2", "3", "4", "5"); * questions.Add(question); * question = new Question("Ile mam stóp", "2", "3", "4", "5"); * questions.Add(question); * * question = new Question("Ile mam nosów", "1", "3", "4", "5"); * questions.Add(question); * question = new Question("Ile mam kolan", "2", "3", "4", "5"); * questions.Add(question); * question = new Question("Dzik jest dziki, dzik jest... ", "zły", "duży", "fajny", "niefajny"); * questions.Add(question);*/ for (int i = 0; i < 10; i++) { if (i == 0) { questions.Add(QuizClient.GetQuestion(stream, category, 0)); } else { questions.Add(QuizClient.GetQuestion(stream, category, 1)); } } }
public void LoadData() { Categories categories = QuizClient.GetCategories(stream); comboBox1.Items.AddRange(categories.quizes); }
private void Disconnect(object sender, FormClosingEventArgs e) { QuizClient.Disconnect(stream); }
private void logoutButton_Click(object sender, EventArgs e) { QuizClient.Disconnect(stream); Application.Restart(); }