Files

138 lines
4.7 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections.Generic;
namespace XP.ReportEngine.Models
{
public class TemplateElement
{
/// <summary>
/// 元素类型:text / image / table / divider / spacer / row / grid
/// </summary>
public string Type { get; set; }
/// <summary>
/// 文本内容(可含 ${} 绑定表达式)| Text content with binding expressions
/// </summary>
public string Content { get; set; }
/// <summary>
/// 样式名称引用 | Style name reference
/// </summary>
public string Style { get; set; }
/// <summary>
/// 数据绑定键 | Data binding key
/// </summary>
public string DataKey { get; set; }
/// <summary>
/// 位置坐标 [x, y]mm| Position coordinates in mm
/// </summary>
public float[] Position { get; set; }
/// <summary>
/// 尺寸 [width, height]mm| Size in mm
/// </summary>
public float[] Size { get; set; }
/// <summary>
/// 表格列定义 | Table column definitions
/// </summary>
public List<ColumnDefinition> Columns { get; set; }
/// <summary>
/// 是否显示边框 | Whether to show border
/// </summary>
public bool Border { get; set; }
/// <summary>
/// 定位方式:absolute / flow | Positioning mode
/// </summary>
public string Positioning { get; set; } = "absolute";
/// <summary>
/// 子元素列表(用于 row 类型的水平布局容器)
/// Child elements (for row type horizontal layout container)
/// </summary>
public List<TemplateElement> Children { get; set; }
/// <summary>
/// 水平对齐方式(用于 row 子元素):left / center / right
/// Horizontal alignment for row children
/// </summary>
public string Align { get; set; }
/// <summary>
/// 列宽比例数组(用于 row 类型,如 [7, 3] 表示 7:3 比例)
/// Column width ratios for row type (e.g. [7, 3] means 7:3 ratio)
/// </summary>
public float[] Widths { get; set; }
/// <summary>
/// 条件颜色规则(用于 text 元素,根据内容中包含的关键词匹配颜色)
/// Conditional color rules for text elements (match keywords in content to color)
/// 格式:{ "Pass": "#008000", "Fail": "#FF0000" }
/// </summary>
public Dictionary<string, string> ColorRules { get; set; }
/// <summary>
/// 表格数据行(数据绑定阶段填充,用于排版计算和渲染)
/// Table data rows (populated during data binding phase, used for layout calculation and rendering)
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public List<Dictionary<string, object>> TableData { get; set; }
/// <summary>
/// 图像数据(数据绑定阶段填充)| Image data (populated during data binding phase)
/// </summary>
[Newtonsoft.Json.JsonIgnore]
public ImageData ImageData { get; set; }
}
public class ColumnDefinition
{
public string Header { get; set; }
public string Field { get; set; }
public float Width { get; set; }
public string Align { get; set; } = "left";
/// <summary>
/// 条件颜色规则(根据单元格值匹配颜色)
/// Conditional color rules (match cell value to color)
/// 格式:{ "Pass": "#008000", "Fail": "#FF0000" }
/// </summary>
public Dictionary<string, string> ColorRules { get; set; }
}
public class StyleDefinition
{
public string Font { get; set; }
public float Size { get; set; } = 12f;
public bool Bold { get; set; }
public bool Italic { get; set; }
public string Color { get; set; } = "#000000";
public string Align { get; set; } = "left";
public string BackgroundColor { get; set; }
/// <summary>
/// 上边距(mm| Top margin in mm
/// </summary>
public float MarginTop { get; set; }
/// <summary>
/// 下边距(mm| Bottom margin in mm
/// </summary>
public float MarginBottom { get; set; }
/// <summary>
/// 左缩进(mm| Left indent/padding in mm
/// </summary>
public float PaddingLeft { get; set; }
/// <summary>
/// 行高倍数(1.0 = 单倍行距,1.5 = 1.5倍行距,0 表示使用默认)
/// Line height multiplier (1.0 = single spacing, 1.5 = 1.5x spacing, 0 = use default)
/// </summary>
public float LineHeight { get; set; }
}
}