// Create empty questionlist private void CreateQuestionList() { CanEditQuestionList = true; SelectedQuestionList = new QuestionListVM(_sfestival.Model); Questions = new ObservableCollection <QuestionVM>(); SwitchView = 1; }
// Show/Edit a questionlist when CanEditQuestionList: false || true private void ShowCreateEdit(int id) { var t = _sfestival.QuestionLists.Single(i => i.Id == id); SelectedQuestionList = new QuestionListVM(t); Questions = new ObservableCollection <QuestionVM>(SelectedQuestionList.Questions.Select(q => new QuestionVM(q))); SwitchView = 1; }
// PDF generator private void ToPDF(int id) { SelectedQuestionList = new QuestionListVM(DBContext.Instance.QuestionLists.FirstOrDefault(i => i.Id == id)); CustomerCompany customer = SelectedQuestionList.Festival.CustomerCompany; Builder PDF = new Builder(); var name = SelectedQuestionList.Festival.Name; var Startdate = SelectedQuestionList.Festival.StartDate; var EndDate = SelectedQuestionList.Festival.EndDate; var convert = Convert.ToDateTime(Startdate).Day + "-" + Convert.ToDateTime(EndDate).Day + " " + Convert.ToDateTime(Startdate).ToString("MMMM") + " " + Convert.ToDateTime(Startdate).Year; PDF.Renderer.PrintOptions.Header = new HtmlHeaderFooter() { HtmlFragment = "<a><em style='color:gray'>" + "Inspectie " + name + " " + convert + " – Festispec – Inspectie formulier v" + SelectedQuestionList.VersionNumber.ToString("F1", CultureInfo.InvariantCulture) + "</em></a>" }; PDF.AddNode(new PdfHeaderNode($"Bedrijf: {customer.NameCompany}") { Size = new FontSizeTag("20px") }); PDF.AddNode(new PdfHeaderNode($"Datum: {DateTime.Now.ToShortDateString()}") { Size = new FontSizeTag("20px") }); PDF.AddNode(new PdfHeaderNode($"Locatie: {customer.City} - {customer.Street} {customer.HouseNumber}\n") { Size = new FontSizeTag("20px") }); PDF.AddText(""); PDF.AddHeader("Introductie"); PDF.AddNode(new PdfTextNode(Interaction.InputBox("Introductie", "Vul hier je introducerend commentaar in", "")) { Size = new FontSizeTag("20px") }); PDF.AddText(""); PDF.AddHeader("Vragenlijst " + name + " " + Convert.ToDateTime(Startdate).Year); PDF.AddText("Instructies vragenlijst \n\r" + SelectedQuestionList.Description); foreach (var s in SelectedQuestionList.Questions) { PDF.AddNode(new PdfTextNode(s.QuestionText) { Weight = new FontWeightTag(FontWeightTag.Values.bold), Size = new FontSizeTag("22px") }); PDF.AddNode(new PdfTextNode(s.Description) { Weight = new FontWeightTag(FontWeightTag.Values.lighter), Size = new FontSizeTag("15px") }); if (s.Answers != null) { foreach (var a in s.Answers) { string table = getTable(s, a.Inspection.Employee.Id); if (table != "") { PDF.AddNode(new PdfTextNode(a.Inspection.Employee.Name + ":")); PDF.AddNode(new PdfHtmlNode(table)); } else { PDF.AddNode(new PdfTextNode(a.Inspection.Employee.Name + ": " + a.AnswerText)); } if (s.Attachments.Count != 0) { var imageBack = @"data:image/png;base64," + s.Attachments.FirstOrDefault().FilePath; var imageFront = @"data:image/png;base64," + a.Attachments.FirstOrDefault().FilePath; var html = "<style>" + ".img {" + "position: absolute;" + "z-index:1;" + "}" + "#container {" + "display:inline-block;" + "}" + ".img2 {" + "position:relative;" + "z-index:20;" + "}" + "</style>" + "<div id='container'>" + "<img class='img' width='500' height='300' src='" + imageBack + "'/>" + "<img class='img2' width='500' height='300' src='" + imageFront + "'/>" + "</div>"; PDF.AddNode(new PdfHtmlNode(html)); } else if (a.Attachments.Count != 0) { PDF.AddImageBase64(a.Attachments.FirstOrDefault().FilePath, "500", "300"); } PDF.AddText("\n"); } string chart = getChart(s); if (chart != "") { PDF.AddImageBase64(chart, "300px", "300px"); } } } PDF.AddText(""); PDF.AddHeader("Advies"); PDF.AddNode(new PdfTextNode(Interaction.InputBox("Advies", "Vul hier je advies in", "")) { Size = new FontSizeTag("20px") }); PDF.AddText(""); PDF.Export("file.pdf"); System.Diagnostics.Process.Start("file.pdf"); }
public QuestionManager(Quiz quiz) { InitializeComponent(); DataContext = new QuestionListVM(quiz); }