private void button1_Click(object sender, EventArgs e) { int id = lbQuestion.SelectedIndex; if (id < 0) { return; } Utility.Question q = questionList[id]; var playForm = new Utility.Form1(videoFolder + @"\" + q.questionVideo); playForm.Show(); Utility.Message sendPlay = new Utility.Message(Utility.Message.Type.PlayVideo, null, q.questionVideo, IP, "Server", checkBox1.Checked); foreach (Socket s in listClient) { try { s.Send(MessageToByteArray(sendPlay)); } catch (Exception er) { textBox1.Text = textBox1.Text + er.Message + "\r\n"; s.Close(); } } }
private void btnNewQuestion_Click(object sender, EventArgs e) { Utility.Question newQuest = new Utility.Question(); questionList.Add(newQuest); listBoxQuestion.Items.Add(string.Format("[{0}]", "NULL")); listBoxQuestion.SelectedIndex = questionList.Count - 1; }
private void lbQuestion_SelectedIndexChanged(object sender, EventArgs e) { int id = lbQuestion.SelectedIndex; if (id < 0) { return; } Utility.Question q = questionList[id]; lbQuestionNext.Text = q.question; labelAnsNext.Text = q.ans; if (null != q.questionImage && q.questionImage.CompareTo("") != 0) { ShowImage(imageFolder + @"\" + q.questionImage, 240, 160, pictureBox2); } else { pictureBox2.Image = null; } if (null != q.questionVideo && q.questionVideo.CompareTo("") != 0) { button1.Enabled = true; } else { button1.Enabled = false; } }
private void listBoxQuestion_SelectedIndexChanged(object sender, EventArgs e) { int id = listBoxQuestion.SelectedIndex; if (id < 0) { return; } Utility.Question q = questionList[id]; tbQuestionText.Text = q.question; tbAns.Text = q.ans; if (null != q.questionImage && q.questionImage.CompareTo("") != 0) { ShowImage(imageFolder + @"\" + q.questionImage, 320, 240, pictureBox1); } else { pictureBox1.Image = null; } textQuestionTime.Text = Convert.ToString(q.questionTime); if (null != q.questionVideo && q.questionVideo.CompareTo("") != 0) { textBoxVideo.Text = q.questionVideo; buttonPlay.Enabled = true; } else { textBoxVideo.Text = ""; buttonPlay.Enabled = false; } }
private void textBoxVideo_Leave(object sender, EventArgs e) { int id = listBoxQuestion.SelectedIndex; if (id < 0) { return; } Utility.Question q = questionList[id]; q.questionVideo = textBoxVideo.Text; }
private void tbAns_Leave(object sender, EventArgs e) { int id = listBoxQuestion.SelectedIndex; if (id < 0) { return; } Utility.Question q = questionList[id]; q.ans = tbAns.Text; }
private void tbQuestionText_Leave(object sender, EventArgs e) { int id = listBoxQuestion.SelectedIndex; if (id < 0) { return; } Utility.Question q = questionList[id]; q.question = tbQuestionText.Text; listBoxQuestion.Items[id] = string.Format("[{0}]", q.question); }
private void buttonPlay_Click(object sender, EventArgs e) { int id = listBoxQuestion.SelectedIndex; if (id < 0) { return; } Utility.Question q = questionList[id]; var playForm = new Utility.Form1(videoFolder + @"\" + q.questionVideo); playForm.Show(); }
private void btnRemove_Click(object sender, EventArgs e) { int id = listBoxQuestion.SelectedIndex; if (id < 0) { return; } Utility.Question q = questionList[id]; q.questionImage = null; pictureBox1.Image = null; textQuestionTime.Text = ""; }
private void sendQuestion(Utility.Question q) { Utility.Message sendQuest = new Utility.Message(Utility.Message.Type.Quest, q, "question", IP, "Server", checkBox1.Checked); foreach (Socket s in listClient) { try{ s.Send(MessageToByteArray(sendQuest)); } catch (Exception er) { textBox1.Text = textBox1.Text + er.Message + "\r\n"; s.Close(); } } }
private void btnBrowse_Click(object sender, EventArgs e) { int size = -1; OpenFileDialog OFD = new OpenFileDialog(); OFD.InitialDirectory = imageFolder; OFD.RestoreDirectory = true; OFD.Title = "Browse Image Files"; OFD.Filter = ""; ImageCodecInfo[] codecs = ImageCodecInfo.GetImageEncoders(); string sep = string.Empty; foreach (var c in codecs) { string codecName = c.CodecName.Substring(8).Replace("Codec", "Files").Trim(); OFD.Filter = String.Format("{0}{1}{2} ({3})|{3}", OFD.Filter, sep, codecName, c.FilenameExtension); sep = "|"; } OFD.Filter = String.Format("{0}{1}{2} ({3})|{3}", OFD.Filter, sep, "All Files", "*.*"); DialogResult result = OFD.ShowDialog(); // Show the dialog. if (result == DialogResult.OK) // Test result. { string fullname = OFD.FileName; string filename = System.IO.Path.GetFileName(fullname); try { System.IO.File.Copy(fullname, imageFolder + @"\" + filename, true); } catch (IOException ex) { Console.WriteLine(ex.Message); } finally { int id = listBoxQuestion.SelectedIndex; Utility.Question q = questionList[id]; q.questionImage = filename; ShowImage(imageFolder + @"\" + q.questionImage, 360, 240, pictureBox1); } } Console.WriteLine(result); // <-- For debugging use. }
private void textQuestionTime_Leave(object sender, EventArgs e) { int id = listBoxQuestion.SelectedIndex; if (id < 0) { return; } Utility.Question q = questionList[id]; try { q.questionTime = Int32.Parse(textQuestionTime.Text); } catch (Exception ex) { q.questionTime = 0; } }
private void btnSend_Click(object sender, EventArgs e) { timerCountDown.Enabled = true; int id = lbQuestion.SelectedIndex; if (id < 0) { return; } Utility.Question q = questionList[id]; sendQuestion(q); labelQuest.Text = q.question; labelAns.Text = q.ans; if (null != q.questionImage && q.questionImage.CompareTo("") != 0) { ShowImage(imageFolder + @"\" + q.questionImage, 200, 150, pictureBox1); } else { pictureBox1.Image = null; } if (id + 1 != questionList.Count) { lbQuestion.SelectedIndex = id + 1; } else { lbQuestionNext.Text = ""; pictureBox2.Image = null; labelAnsNext.Text = ""; } if (checkBox1.Checked) { StartTheQuestion(q.questionTime); } switch (comboBox1.SelectedIndex) { case 0: checkBox1.Checked = false; break; } }
private void buttonBroVideo_Click(object sender, EventArgs e) { int size = -1; OpenFileDialog OFD = new OpenFileDialog(); OFD.InitialDirectory = videoFolder; OFD.RestoreDirectory = true; OFD.Title = "Browse Video Files"; OFD.Filter = ""; string sep = string.Empty; OFD.Filter = "(mp3,wav,mp4,mov,wmv,mpg,avi,3gp,flv)|*.mp3;*.wav;*.mp4;*.3gp;*.avi;*.mov;*.flv;*.wmv;*.mpg|all files|*.*"; DialogResult result = OFD.ShowDialog(); // Show the dialog. if (result == DialogResult.OK) // Test result. { string fullname = OFD.FileName; string filename = System.IO.Path.GetFileName(fullname); try { System.IO.File.Copy(fullname, videoFolder + @"\" + filename, true); } catch (IOException ex) { Console.WriteLine(ex.Message); } finally { int id = listBoxQuestion.SelectedIndex; Utility.Question q = questionList[id]; q.questionVideo = filename; textBoxVideo.Text = filename; } } Console.WriteLine(result); // <-- For debugging use. }