开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (17)
标签 (33)
master
sync_branch_202410
sync_branch_2023年3月14日
updatedLicenses
updatedReadme
sync_branch_2023年1月5日
sync_branch_2023年1月4日
sync_branch_2023年1月3日
Detrav-patch-2
sync_branch_202310
KirillKornienko-patch-1
Detrav-patch-1
sync_branch_202230
finalUpdatePackScript
PackScript
SomeFixesInDeterministicBuilds
AddedBuildDirToPack
v2025.2.0
v2025.1.0
v2024.2.0
v2024.1.10
v2024.1.3
v2024.1.0
v2023.3.0
v2023.2.0
v2023.1.0
v2022.3.11
v2022.3.0
v2022.2.0
v2022.1.0
v2021.4.0
v2021.3.28
v2021.3.21
v2021.3.0
v2021.2.0
2021年1月16日
v2021.1.0
master
分支 (17)
标签 (33)
master
sync_branch_202410
sync_branch_2023年3月14日
updatedLicenses
updatedReadme
sync_branch_2023年1月5日
sync_branch_2023年1月4日
sync_branch_2023年1月3日
Detrav-patch-2
sync_branch_202310
KirillKornienko-patch-1
Detrav-patch-1
sync_branch_202230
finalUpdatePackScript
PackScript
SomeFixesInDeterministicBuilds
AddedBuildDirToPack
v2025.2.0
v2025.1.0
v2024.2.0
v2024.1.10
v2024.1.3
v2024.1.0
v2023.3.0
v2023.2.0
v2023.1.0
v2022.3.11
v2022.3.0
v2022.2.0
v2022.1.0
v2021.4.0
v2021.3.28
v2021.3.21
v2021.3.0
v2021.2.0
2021年1月16日
v2021.1.0
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (17)
标签 (33)
master
sync_branch_202410
sync_branch_2023年3月14日
updatedLicenses
updatedReadme
sync_branch_2023年1月5日
sync_branch_2023年1月4日
sync_branch_2023年1月3日
Detrav-patch-2
sync_branch_202310
KirillKornienko-patch-1
Detrav-patch-1
sync_branch_202230
finalUpdatePackScript
PackScript
SomeFixesInDeterministicBuilds
AddedBuildDirToPack
v2025.2.0
v2025.1.0
v2024.2.0
v2024.1.10
v2024.1.3
v2024.1.0
v2023.3.0
v2023.2.0
v2023.1.0
v2022.3.11
v2022.3.0
v2022.2.0
v2022.1.0
v2021.4.0
v2021.3.28
v2021.3.21
v2021.3.0
v2021.2.0
2021年1月16日
v2021.1.0
FastReport
/
FastReport.Base
/
CellularTextObject.cs
FastReport
/
FastReport.Base
/
CellularTextObject.cs
CellularTextObject.cs 9.72 KB
一键复制 编辑 原始数据 按行查看 历史
FastReports-bot 提交于 2022年07月05日 23:09 +08:00 . * sync 7/5/2022 version: 2022年2月13日
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293
using System;
using System.Drawing;
using System.ComponentModel;
using FastReport.Utils;
using FastReport.Table;
namespace FastReport
{
/// <summary>
/// Represents a text object which draws each symbol of text in its own cell.
/// </summary>
/// <remarks>
/// <para/>The text may be aligned to left or right side, or centered. Use the <see cref="HorzAlign"/>
/// property to do this. The "justify" align is not supported now, as well as vertical alignment.
/// <para/>The cell size is defined in the <see cref="CellWidth"/> and <see cref="CellHeight"/> properties.
/// These properties are 0 by default, in this case the size of cell is calculated automatically based
/// on the object's <b>Font</b>.
/// <para/>To define a spacing (gap) between cells, use the <see cref="HorzSpacing"/> and
/// <see cref="VertSpacing"/> properties.
/// </remarks>
public partial class CellularTextObject : TextObject
{
#region Fields
private float cellWidth;
private float cellHeight;
private float horzSpacing;
private float vertSpacing;
#endregion
#region Properties
/// <summary>
/// Gets or sets the width of cell, in pixels.
/// </summary>
/// <remarks>
/// If zero width and/or height specified, the object will calculate the cell size
/// automatically based on its font.
/// </remarks>
[Category("Appearance")]
[TypeConverter("FastReport.TypeConverters.UnitsConverter, FastReport")]
public float CellWidth
{
get { return cellWidth; }
set { cellWidth = value; }
}
/// <summary>
/// Gets or sets the height of cell, in pixels.
/// </summary>
/// <remarks>
/// If zero width and/or height specified, the object will calculate the cell size
/// automatically based on its font.
/// </remarks>
[Category("Appearance")]
[TypeConverter("FastReport.TypeConverters.UnitsConverter, FastReport")]
public float CellHeight
{
get { return cellHeight; }
set { cellHeight = value; }
}
/// <summary>
/// Gets or sets the horizontal spacing between cells, in pixels.
/// </summary>
[Category("Appearance")]
[TypeConverter("FastReport.TypeConverters.UnitsConverter, FastReport")]
public float HorzSpacing
{
get { return horzSpacing; }
set { horzSpacing = value; }
}
/// <summary>
/// Gets or sets the vertical spacing between cells, in pixels.
/// </summary>
[Category("Appearance")]
[TypeConverter("FastReport.TypeConverters.UnitsConverter, FastReport")]
public float VertSpacing
{
get { return vertSpacing; }
set { vertSpacing = value; }
}
#endregion
#region Private Methods
// use the TableObject to represent the contents. It's easier to export it later.
private TableObject GetTable(bool autoRows)
{
TableObject table = new TableObject();
table.SetPrinting(IsPrinting);
table.SetReport(Report);
float cellWidth = CellWidth;
float cellHeight = CellHeight;
// calculate cellWidth, cellHeight automatically
if (cellWidth == 0 || cellHeight == 0)
{
float fontHeight = Font.GetHeight() * 96f / DrawUtils.ScreenDpi;
cellWidth = GetCellWidthInternal(fontHeight);
cellHeight = cellWidth;
}
int colCount = (int)((Width + HorzSpacing + 1) / (cellWidth + HorzSpacing));
if (colCount == 0)
colCount = 1;
int rowCount = (int)((Height + VertSpacing + 1) / (cellHeight + VertSpacing));
if (rowCount == 0 || autoRows)
rowCount = 1;
table.ColumnCount = colCount;
table.RowCount = rowCount;
// process the text
int row = 0;
int lineBegin = 0;
int lastSpace = 0;
string text = Text.Replace("\r\n", "\n");
for (int i = 0; i < text.Length; i++)
{
bool isCRLF = text[i] == '\n';
if (text[i] == ' ' || isCRLF)
lastSpace = i;
if (i - lineBegin + 1 > colCount || isCRLF)
{
if (WordWrap && lastSpace > lineBegin)
{
AddText(table, row, text.Substring(lineBegin, lastSpace - lineBegin));
lineBegin = lastSpace + 1;
}
else if (i - lineBegin > 0)
{
AddText(table, row, text.Substring(lineBegin, i - lineBegin));
lineBegin = i;
}
else
lineBegin = i + 1;
lastSpace = lineBegin;
row++;
if (autoRows && row >= rowCount)
{
rowCount++;
table.RowCount++;
}
}
}
// finish the last line
if (lineBegin < text.Length)
AddText(table, row, text.Substring(lineBegin, text.Length - lineBegin));
// set up cells appearance
for (int i = 0; i < colCount; i++)
{
for (int j = 0; j < rowCount; j++)
{
TableCell cell = table[i, j];
cell.Border = Border.Clone();
cell.Fill = Fill.Clone();
cell.Font = Font;
cell.TextFill = TextFill.Clone();
cell.HorzAlign = HorzAlign.Center;
cell.VertAlign = VertAlign.Center;
}
}
// set cell's width and height
for (int i = 0; i < colCount; i++)
{
table.Columns[i].Width = cellWidth;
}
for (int i = 0; i < rowCount; i++)
{
table.Rows[i].Height = cellHeight;
}
// insert spacing between cells
if (HorzSpacing > 0)
{
for (int i = 0; i < colCount - 1; i++)
{
TableColumn newColumn = new TableColumn();
newColumn.Width = HorzSpacing;
table.Columns.Insert(i * 2 + 1, newColumn);
}
}
if (VertSpacing > 0)
{
for (int i = 0; i < rowCount - 1; i++)
{
TableRow newRow = new TableRow();
newRow.Height = VertSpacing;
table.Rows.Insert(i * 2 + 1, newRow);
}
}
table.Left = AbsLeft;
table.Top = AbsTop;
table.Width = table.Columns[table.ColumnCount - 1].Right;
table.Height = table.Rows[table.RowCount - 1].Bottom;
return table;
}
private void AddText(TableObject table, int row, string text)
{
if (row >= table.RowCount)
return;
text = text.TrimEnd(' ');
if (text.Length > table.ColumnCount)
text = text.Substring(0, table.ColumnCount);
int offset = 0;
if (HorzAlign == HorzAlign.Right)
offset = table.ColumnCount - text.Length;
else if (HorzAlign == HorzAlign.Center)
offset = (table.ColumnCount - text.Length) / 2;
for (int i = 0; i < text.Length; i++)
{
table[i + offset, row].Text = text[i].ToString();
}
}
#endregion
#region Public Methods
/// <inheritdoc/>
public override void Assign(Base source)
{
base.Assign(source);
CellularTextObject src = source as CellularTextObject;
CellWidth = src.CellWidth;
CellHeight = src.CellHeight;
HorzSpacing = src.HorzSpacing;
VertSpacing = src.VertSpacing;
}
/// <inheritdoc/>
public override void Serialize(FRWriter writer)
{
CellularTextObject c = writer.DiffObject as CellularTextObject;
base.Serialize(writer);
if (FloatDiff(CellWidth, c.CellWidth))
writer.WriteFloat("CellWidth", CellWidth);
if (FloatDiff(CellHeight, c.CellHeight))
writer.WriteFloat("CellHeight", CellHeight);
if (FloatDiff(HorzSpacing, c.HorzSpacing))
writer.WriteFloat("HorzSpacing", HorzSpacing);
if (FloatDiff(VertSpacing, c.VertSpacing))
writer.WriteFloat("VertSpacing", VertSpacing);
}
/// <inheritdoc/>
public override void Draw(FRPaintEventArgs e)
{
using (TableObject table = GetTable())
{
table.Draw(e);
}
}
public TableObject GetTable()
{
return GetTable(false);
}
#endregion
#region Report Engine
/// <inheritdoc/>
public override float CalcHeight()
{
using (TableObject table = GetTable(true))
{
return table.Height;
}
}
#endregion
/// <summary>
/// Initializes a new instance of the <see cref="CellularTextObject"/> class with the default settings.
/// </summary>
public CellularTextObject()
{
CanBreak = false;
Border.Lines = BorderLines.All;
}
}
}
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

取消

发行版

暂无发行版

贡献者

全部

语言

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/star8521/FastReport.git
git@gitee.com:star8521/FastReport.git
star8521
FastReport
FastReport
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /