private void cmdGenerateTemplates_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtOutputDir.Text)) { MessageBox.Show("Must enter output directory"); return; } int tempTemplates; if (Int32.TryParse(this.txtTemplates.Text, out tempTemplates)) { for (int i = 0; i < tempTemplates; i++) { QuestionSet questionSet = new QuestionSet(this.setType, this.txtQuestionInput.Text, Int32.Parse(txtPackets.Text)); questionSet.CreatePackets(this.setType); questionSet.WriteOutput(this.txtOutputDir.Text, this.setType); } lblOutput.Text = "Wrote templates to " + this.txtOutputDir.Text + " on " + DateTime.Now.ToShortTimeString(); } else { MessageBox.Show("Error parsing number of templates"); } }
private void cmdGeneratePackets_Click(object sender, EventArgs e) { txtTemplateInput.Text = txtTemplateInput.Text.Replace("\"", ""); txtQuestionInput.Text = txtQuestionInput.Text.Replace("\"", ""); if (string.IsNullOrWhiteSpace(txtOutputDir.Text)) { MessageBox.Show("Must enter output directory"); return; } if (string.IsNullOrWhiteSpace(txtQuestionInput.Text) || !File.Exists(txtQuestionInput.Text)) { MessageBox.Show("Could not find input file"); return; } if (!string.IsNullOrWhiteSpace(txtLogoFile.Text) && (!File.Exists(txtLogoFile.Text) || Path.GetExtension(txtLogoFile.Text).ToLowerInvariant() != ".bmp")) { MessageBox.Show("Could not parse logo file. Make sure it's a valid bmp."); return; } if (string.IsNullOrWhiteSpace(txtTemplateInput.Text)) { // Read the actual questions, generate a template file to replace QuestionSet questionSet = new QuestionSet(this.setType, this.txtQuestionInput.Text, Int32.Parse(txtPackets.Text)); questionSet.LoadRealQuestions(txtQuestionInput.Text, this.setType); questionSet.CreatePackets(this.setType); string outputFile = questionSet.WriteOutput(this.txtOutputDir.Text, this.setType); questionSet.WriteCategoriesToCsv(this.txtOutputDir.Text, this.setType); //string outputFile = @"C:\Users\mbentley\AppData\Local\Temp\QEMS2\131424937605156008 - Copy.csv"; Utilities.GenerateRtf(outputFile, this.txtOutputDir.Text, this.chkScoresheet.Checked, this.chkDocx.Checked, this.setType, this.txtLogoFile.Text, this.chkComments.Checked, this.GetCommentFilters(), this.chkWriterNames.Checked, this.chkCategories.Checked, this.txtSetName.Text, this.cmbFont.Text); } else if (!File.Exists(txtTemplateInput.Text)) { MessageBox.Show("Could not find template input file."); return; } else { // Load the template file, replace the placeholders with actual questions QuestionSet questionSet = new QuestionSet(this.setType, this.txtQuestionInput.Text, Int32.Parse(txtPackets.Text)); questionSet.LoadRealQuestions(txtQuestionInput.Text, this.setType); //questionSet.LoadTemplate(txtTemplateInput.Text, this.setType); questionSet.LoadOphirTemplate(txtTemplateInput.Text); string outputFile = questionSet.WriteOutput(this.txtOutputDir.Text, this.setType); questionSet.WriteCategoriesToCsv(this.txtOutputDir.Text, this.setType); Utilities.GenerateRtf(outputFile, this.txtOutputDir.Text, this.chkScoresheet.Checked, this.chkDocx.Checked, this.setType, this.txtLogoFile.Text, this.chkComments.Checked, this.GetCommentFilters(), this.chkWriterNames.Checked, this.chkCategories.Checked, this.txtSetName.Text, this.cmbFont.Text); } }