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