public static Control CreateLabel(Indicator indicator, bool isStatic) { var text = indicator.DisplayName; if (isStatic) text = TranslationLookup.GetValue(indicator.DisplayName, indicator.DisplayName); if (indicator.IsRequired) { var required = new H3Required { Text = text, Name = "ciLabel_" + indicator.Id, AutoSize = true, Anchor = (AnchorStyles.Bottom | AnchorStyles.Left), TabStop = false }; required.SetMaxWidth(370); return required; } else { var lbl = new H3bLabel { Text = text, Name = "ciLabel_" + indicator.Id, AutoSize = true, Anchor = (AnchorStyles.Bottom | AnchorStyles.Left), TabStop = false }; lbl.SetMaxWidth(370); return lbl; } }
private void LoadSavedReports() { ReportRepository repo = new ReportRepository(); var reports = repo.GetCustomReports(); tblReportBuilder.Visible = false; this.SuspendLayout(); tblReportBuilder.Controls.Clear(); int rowIndex = tblReportBuilder.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); var tblNew = new TableLayoutPanel { AutoSize = true, AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink }; tblNew.RowStyles.Clear(); tblNew.ColumnStyles.Clear(); tblNew.ColumnStyles.Add(new ColumnStyle { SizeType = System.Windows.Forms.SizeType.AutoSize }); tblNew.ColumnStyles.Add(new ColumnStyle { SizeType = System.Windows.Forms.SizeType.AutoSize }); tblNew.RowStyles.Add(new RowStyle { SizeType = System.Windows.Forms.SizeType.AutoSize }); var name2 = new H3bLabel { Text = Translations.CustomReport, Name = "rpt_cr", AutoSize = true, }; name2.SetMaxWidth(400); var edit2 = new H3Link { Text = Translations.NewLink, Margin = new Padding(0, 2, 0, 0) }; edit2.ClickOverride += () => { WizardForm wiz = new WizardForm(new StepCategory(), Translations.CustomReportBuilder); wiz.Height = 695; wiz.OnRunReport = RunCustomReport; wiz.Show(); }; tblNew.Controls.Add(name2, 0, 0); tblNew.Controls.Add(edit2, 1, 0); tblReportBuilder.Controls.Add(tblNew, 0, rowIndex); foreach (var report in reports) { rowIndex = tblReportBuilder.RowStyles.Add(new RowStyle { SizeType = SizeType.AutoSize }); var tbl = new TableLayoutPanel { AutoSize = true, AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink }; tbl.RowStyles.Clear(); tbl.ColumnStyles.Clear(); tbl.ColumnStyles.Add(new ColumnStyle { SizeType = System.Windows.Forms.SizeType.AutoSize }); tbl.ColumnStyles.Add(new ColumnStyle { SizeType = System.Windows.Forms.SizeType.AutoSize }); tbl.ColumnStyles.Add(new ColumnStyle { SizeType = System.Windows.Forms.SizeType.AutoSize }); tbl.RowStyles.Add(new RowStyle { SizeType = System.Windows.Forms.SizeType.AutoSize }); var name = new H3bLabel { Text = report.DisplayName, Name = "rpt_" + report.DisplayName, AutoSize = true, }; name.SetMaxWidth(400); var edit = new H3Link { Text = Translations.Edit + "...", Margin = new Padding(0, 2, 0, 0) }; edit.ClickOverride += () => { WizardForm wiz = new WizardForm(new StepIndicators(report), Translations.CustomReportBuilder); wiz.Height = 695; wiz.OnRunReport = RunCustomReport; wiz.Show(); }; var delete = new H3Link { Text = Translations.Delete + "...", Margin = new Padding(0, 2, 0, 0) }; delete.ClickOverride += () => { DeleteConfirm confirm = new DeleteConfirm(Translations.Delete, Translations.DeleteConfirmMessage); if (confirm.ShowDialog() == DialogResult.OK) { repo.DeleteCustomReport(report, ApplicationData.Instance.GetUserId()); LoadSavedReports(); } }; tbl.Controls.Add(name, 0, 0); tbl.Controls.Add(edit, 1, 0); tbl.Controls.Add(delete, 2, 0); tblReportBuilder.Controls.Add(tbl, 0, rowIndex); } this.ResumeLayout(); tblReportBuilder.Visible = true; }