static void Main(string[] args) { Console.WriteLine("test"); /* IBot bot = new VkQuizBot(); * Console.WriteLine(bot.BotName); * Console.WriteLine(bot.SocialNetwork); * // Authorization a = new Authorization(); * VkToken t = (VkToken)a.Token; * Console.WriteLine(t.Name + " " + t.SurName); * string[] s = new string[] { t.login, t.pass, "25" }; * bot.Start(s); * Console.WriteLine("END");*/ QuizForm qf = new QuizForm(); qf.ShowDialog(); //35 /* MainForm m = new MainForm(); * m.ShowDialog();*/ /* Authorization a = new Authorization(); * VkToken t = (VkToken)a.Token; * string[] s = new string[] { t.login, t.pass }; * IBot bot = new VkPresentBot(); * Console.WriteLine("START"); * bot.Start(s); * Console.WriteLine("STOP");*/ /* GraphForm form = new GraphForm(); * form.ShowDialog();*/ Console.Read(); }
private void OnDataSourceChanged(QuizForm qf) { if (qf == null) { return; } piQ.Image = Utils.Base64ToImage(qf.Question.ImageContent); if (IsDesign && qf.IsOpen) { chOpen.Checked = true; } for (int i = 1; i <= qf.Answers.Count; i++) { Answer answer = qf.Answers.ElementAt(i - 1); TextBox txtValue = GetControl($"txtA{i}Value") as TextBox; PictureBox piAnswer = GetControl($"piA{i}") as PictureBox; if (!string.IsNullOrEmpty(answer.ImageContent)) { piAnswer.Image = Utils.Base64ToImage(answer.ImageContent); } if (IsDesign) { txtValue.Text = answer.Value.ToString(); } } UpdateUI(qf.IsOpen); }
public QuizForm GetForm() { QuizForm qf = new QuizForm { Question = new Question() }; //validazione if (piQ.Image == null) { MessageBox.Show($"Domanda mancante in scheda {Id}"); return(null); } for (int i = 1; i <= 5; i++) { TextBox txt = GetControl($"txtA{i}Value") as TextBox; PictureBox pi = GetControl($"piA{i}") as PictureBox; double qVal; if (!qf.IsOpen && (pi.Image != null) && !double.TryParse(txt.Text, out qVal)) { MessageBox.Show($"Inserire valore risposta {i} in scheda {Id}"); return(null); } } qf.Question.ImageContent = Utils.ImageToBase64(piQ.Image); qf.IsOpen = chOpen.Checked; for (int i = 1; i <= 5; i++) { PictureBox pi = GetControl($"piA{i}") as PictureBox; TextBox txt = GetControl($"txtA{i}Value") as TextBox; Answer answ = new Answer(); bool answerValid = false; if (!qf.IsOpen) { //risposta chiusa - immagine if (pi.Image != null) { answ.ImageContent = Utils.ImageToBase64(pi.Image); answ.Value = Convert.ToDouble(txt.Text); answerValid = true; } } if (answerValid) { qf.Answers.Add(answ); } } return(qf); }
private void btnCreate_Click(object sender, EventArgs e) { var forms = Convert.ToInt32(txtForms.Text); Quiz q = new Quiz { RandomForms = checkRandomForms.Checked, RandomQuestions = checkRandomQuestions.Checked, AllowBack = checkAllowBack.Checked, StartDateTime = dtStart.Value }; int timeLimit = 0; if (!int.TryParse(txtTime.Text, out timeLimit)) { MessageBox.Show($"Inserire il tempo massimo per la consegna verifica"); return; } q.TimeLimit = timeLimit; for (int i = 0; i < forms; i++) { TabPage t = tabControl.TabPages[i]; FormControl fc = t.Controls[0] as FormControl; if (fc != null) { QuizForm res = fc.GetForm(); q.Forms.Add(res); } } string json = JsonConvert.SerializeObject(q); var fileToSave = Path.Combine(_curFolder, txtFilename.Text); if (File.Exists(fileToSave)) { switch (MessageBox.Show($"SovraScrivere {fileToSave}?", "Attenzione", MessageBoxButtons.YesNo)) { case DialogResult.No: return; default: break; } } File.WriteAllText(fileToSave, json); MessageBox.Show("File salvato"); }