|
@@ -302,8 +302,13 @@ namespace InABox.DynamicGrid
|
|
|
return name;
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
public static Report? GenerateReport(DigitalFormLayout layout, DataModel model)
|
|
|
{
|
|
|
+
|
|
|
+ bool IsValidChar(char c) => "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_0123456789".Contains(c);
|
|
|
+
|
|
|
var report = ReportUtils.SetupReport(null, model, true);
|
|
|
|
|
|
var dfLayout = new DFLayout();
|
|
@@ -328,17 +333,80 @@ namespace InABox.DynamicGrid
|
|
|
Height = Units.Millimeters * (page.PaperHeight - (page.TopMargin + page.BottomMargin)),
|
|
|
Width = Units.Millimeters * (page.PaperWidth - (page.LeftMargin + page.RightMargin)),
|
|
|
PrintIfDatasourceEmpty = true,
|
|
|
- DataSource = formData
|
|
|
+ DataSource = formData,
|
|
|
+ StartNewPage = true
|
|
|
};
|
|
|
page.AddChild(band);
|
|
|
|
|
|
+ var logo = new PictureObject()
|
|
|
+ {
|
|
|
+ Height = 20F * Units.Millimeters,
|
|
|
+ Width = 30F * Units.Millimeters,
|
|
|
+ DataColumn = "CompanyLogo.Data"
|
|
|
+ };
|
|
|
+ band.AddChild(logo);
|
|
|
+
|
|
|
+ var company = new TextObject()
|
|
|
+ {
|
|
|
+ Left = band.Width - (90F * Units.Millimeters),
|
|
|
+ Width = 90F * Units.Millimeters,
|
|
|
+ Height = 5F * Units.Millimeters,
|
|
|
+ Text = "[CompanyInformation.CompanyName]",
|
|
|
+ HorzAlign = HorzAlign.Right,
|
|
|
+ VertAlign = VertAlign.Center,
|
|
|
+ Font = new System.Drawing.Font("Arial", 12F, FontStyle.Bold)
|
|
|
+ };
|
|
|
+ band.AddChild(company);
|
|
|
+
|
|
|
+ var address = new TextObject()
|
|
|
+ {
|
|
|
+ Left = band.Width - (90F * Units.Millimeters),
|
|
|
+ Width = 90F * Units.Millimeters,
|
|
|
+ Height = 15F * Units.Millimeters,
|
|
|
+ Top = 5F * Units.Millimeters,
|
|
|
+ Text = "[CompanyInformation.PostalAddress_Street]\n[CompanyInformation.PostalAddress_City] [CompanyInformation.PostalAddress_PostCode]",
|
|
|
+ HorzAlign = HorzAlign.Right,
|
|
|
+ VertAlign = VertAlign.Top,
|
|
|
+ Font = new System.Drawing.Font("Arial", 12F)
|
|
|
+ };
|
|
|
+ band.AddChild(address);
|
|
|
+
|
|
|
+ var instancetable = model
|
|
|
+ .GetType()
|
|
|
+ .GetInterfaces()
|
|
|
+ .FirstOrDefault(x => x.IsConstructedGenericType && x.GetGenericTypeDefinition() == typeof(IDataModel<>))?
|
|
|
+ .GetGenericArguments()
|
|
|
+ .FirstOrDefault()?
|
|
|
+ .EntityName()
|
|
|
+ .Split('.')
|
|
|
+ .Last();
|
|
|
+
|
|
|
+ var title = new TextObject()
|
|
|
+ {
|
|
|
+ Top = 23F * Units.Millimeters,
|
|
|
+ Width = band.Width,
|
|
|
+ Height = 6F * Units.Millimeters,
|
|
|
+ Text = $"[Form_Data.{instancetable}.Number] - {layout.Form.Description}",
|
|
|
+ HorzAlign = HorzAlign.Center,
|
|
|
+ VertAlign = VertAlign.Center,
|
|
|
+ Font = new System.Drawing.Font("Arial", 14F, FontStyle.Bold)
|
|
|
+ };
|
|
|
+ band.AddChild(title);
|
|
|
+ /*
|
|
|
+ <TextObject Name="Text2" Left="500.85" Top="28.35" Width="207.9" Height="56.7" Text="16 Madrid Place Maddington WA 6109 Phone: (08) 9492 1200 Email: admin@com-al.com.au" HorzAlign="Right" Font="Arial, 9pt"/>
|
|
|
+ <PictureObject Name="Picture1" Left="9.45" Top="9.45" Width="113.4" Height="75.6" DataColumn="CompanyLogo.Data"/>
|
|
|
+ <TextObject Name="Text1" Left="444.15" Top="9.45" Width="264.6" Height="18.9" Text="Com-Al Windows Pty Ltd" HorzAlign="Right" Font="Arial, 10pt, style=Bold" TextFill.Color="RoyalBlue"/>
|
|
|
+ <TextObject Name="Text3" Left="9.45" Top="103.95" Width="699.3" Height="28.35" Text="TEST & TAG REPORT: [KanbanForm.Number]" HorzAlign="Center" VertAlign="Center" Font="Arial, 14pt, style=Bold"/>
|
|
|
+ */
|
|
|
+
|
|
|
var elementNames = new HashSet<string>();
|
|
|
|
|
|
var table = new TableObject()
|
|
|
{
|
|
|
Name = "FormTable",
|
|
|
ColumnCount = dfLayout.ColumnWidths.Count,
|
|
|
- RowCount = dfLayout.RowHeights.Count
|
|
|
+ RowCount = dfLayout.RowHeights.Count,
|
|
|
+ Top = 32F * Units.Millimeters
|
|
|
};
|
|
|
band.AddChild(table);
|
|
|
foreach(var element in dfLayout.Elements)
|
|
@@ -356,7 +424,7 @@ namespace InABox.DynamicGrid
|
|
|
{
|
|
|
var manualHeight = 0.0f;
|
|
|
|
|
|
- cell.Name = ElementName(elementNames, $"Cell_{new string(field.Name.Where(c => !Char.IsWhiteSpace(c)).ToArray())}");
|
|
|
+ cell.Name = ElementName(elementNames, $"Cell_{new string(field.Name.Where(c => IsValidChar(c)).ToArray())}");
|
|
|
|
|
|
var dataColumn = $"Form_Data.{field.Name}";
|
|
|
if(field is DFLayoutEmbeddedImage || field is DFLayoutSignaturePad)
|
|
@@ -395,8 +463,12 @@ namespace InABox.DynamicGrid
|
|
|
else
|
|
|
{
|
|
|
cell.Text = $"[{dataColumn}]";
|
|
|
- cell.Font = new System.Drawing.Font(cell.Font.FontFamily, 8F, FontStyle.Italic);
|
|
|
+ cell.Font = new System.Drawing.Font(cell.Font.FontFamily, 10F, FontStyle.Italic);
|
|
|
cell.TextColor = Color.Navy;
|
|
|
+ cell.HorzAlign = HorzAlign.Left;
|
|
|
+ cell.VertAlign = VertAlign.Center;
|
|
|
+ if (field is DFLayoutStringField lsf)
|
|
|
+ cell.WordWrap = lsf.Properties.TextWrapping;
|
|
|
}
|
|
|
|
|
|
if(manualHeight > 0 && dfLayout.RowHeights[element.Row - 1] == "Auto")
|
|
@@ -445,8 +517,8 @@ namespace InABox.DynamicGrid
|
|
|
fontstyle |= System.Drawing.FontStyle.Italic;
|
|
|
if (style.Underline != UnderlineType.None)
|
|
|
fontstyle |= FontStyle.Underline;
|
|
|
- float fontsize = (float)style.FontSize * 8F / 12F;
|
|
|
- fontsize = fontsize == 0F ? 8F : fontsize;
|
|
|
+ float fontsize = (float)style.FontSize;
|
|
|
+ fontsize = fontsize == 0F ? 10F : fontsize;
|
|
|
cell.Font = new System.Drawing.Font(cell.Font.FontFamily, fontsize, fontstyle);
|
|
|
cell.HorzAlign = style.HorizontalTextAlignment switch
|
|
|
{
|
|
@@ -475,7 +547,9 @@ namespace InABox.DynamicGrid
|
|
|
if (!values[iFixed].Contains("*"))
|
|
|
{
|
|
|
if (!float.TryParse(values[iFixed], out float value))
|
|
|
- value = 4F;
|
|
|
+ value = 25F / Units.Millimeters;
|
|
|
+ else
|
|
|
+ value = value / (1.5f * Units.Millimeters);
|
|
|
rows[iFixed].Height = Units.Millimeters * value;
|
|
|
fixedtotal += Units.Millimeters * value;
|
|
|
}
|
|
@@ -505,7 +579,7 @@ namespace InABox.DynamicGrid
|
|
|
if (!values[iFixed].Contains("*"))
|
|
|
{
|
|
|
if (!float.TryParse(values[iFixed], out float value))
|
|
|
- value = 20F;
|
|
|
+ value = 40F;
|
|
|
columns[iFixed].Width = Units.Millimeters * value;
|
|
|
fixedtotal += Units.Millimeters * value;
|
|
|
}
|