当前位置: 首页 > ops >正文

界面控件DevExpress WinForms v24.2新版亮点:富文本编辑器功能全新升级

DevExpress WinForms拥有180+组件和UI库,能为Windows Forms平台创建具有影响力的业务解决方案。DevExpress WinForms能完美构建流畅、美观且易于使用的应用程序,无论是Office风格的界面,还是分析处理大批量的业务数据,它都能轻松胜任!

DevExpress WinForms控件v24.2日前已经全新发布,新版本全新升级富文本编辑器组件等功能,欢迎下载最新版体验!

DevExpress WinForms v24.2正式版下载

Rich Text Editor(富文本编辑器)
大小写格式

DevExpress WinForms富文本编辑器支持大小写字符格式,使用小写字母格式的Word文档可以预览、打印和导出为PDF。要在代码中启用格式化,请使用CharacterProperties.SmallCaps属性:

C#

Document document = richEditControl.Document;
Paragraph paragraph = document.Paragraphs[0];
CharacterProperties characterProperties = document.BeginUpdateCharacters(paragraph.Range);
characterProperties.SmallCaps = true;
document.EndUpdateCharacters(characterProperties);

此外,v24.2在Font复选框中添加了一个Small Caps复选框,以便通过UI应用格式。

页面边框

DevExpress WinForms富文本编辑器现在支持页面边框,具有页面边框的Word文档可以保存而不会丢失内容,可以预览、打印和导出为PDF。

DevExpress WinForms v24.2产品图集

v24.2还实现了用于在代码中管理页面边框的API,可以为每个文档部分单独设置边框。使用Section.PageBorders属性来访问和修改特定部分的边框。使用新的API,您可以修改以下边框设置:

  • 线条样式
  • 颜色
  • 宽度
  • 距文本或页边的距离

您还可以对部分中的特定页面应用边框:对所有页面、仅对第一个页面或除第一个页面外的所有页面应用边框,您可以更改边框的z轴顺序来显示它们在主文本的前面或后面。下面的代码片段在包含两个部分的文档中应用不同的边框:

C#

Document document = richEditControl.Document;
string pageBreaks = "\f\f\f";
// Generate a document with two sections and multiple pages in each section
document.AppendText(pageBreaks);
document.Paragraphs.Append();
document.AppendSection();
document.AppendText(pageBreaks);// Set borders for the first page of the first section
SetPageBorders(pageBorders1.LeftBorder, BorderLineStyle.Single, 1f, Color.Red);
SetPageBorders(pageBorders1.TopBorder, BorderLineStyle.Single, 1f, Color.Red);
SetPageBorders(pageBorders1.RightBorder, BorderLineStyle.Single, 1f, Color.Red);
SetPageBorders(pageBorders1.BottomBorder, BorderLineStyle.Single, 1f, Color.Red);
pageBorders1.AppliesTo = PageBorderAppliesTo.FirstPage;Section secondSection = document.Sections[1];
SectionPageBorders pageBorders2 = secondSection.PageBorders;// Set borders for all pages of the second section
SetPageBorders(pageBorders2.LeftBorder, BorderLineStyle.Double, 1.5f, Color.Green);
SetPageBorders(pageBorders2.TopBorder, BorderLineStyle.Double, 1.5f, Color.Green);
SetPageBorders(pageBorders2.RightBorder, BorderLineStyle.Double, 1.5f, Color.Green);
SetPageBorders(pageBorders2.BottomBorder, BorderLineStyle.Double, 1.5f, Color.Green);
pageBorders2.AppliesTo = PageBorderAppliesTo.AllPages;
pageBorders2.ZOrder = PageBorderZOrder.Back;//.....
void SetPageBorders(PageBorder border, BorderLineStyle lineStyle,
float borderWidth, Color color) {
border.LineStyle = lineStyle;
border.LineWidth = borderWidth;
border.LineColor = color;
}
段落边框API

v24.2版本在代码中实现了新的API来管理Word文档的段落边框,使用这些新的API,您可以为文档段落添加边框,单独更改每种边框类型(上、左、右、下或水平)的边框样式、颜色和厚度,或者删除边框格式。此外,还可以管理段落样式的段落边框设置和编号列表中的列表级别。

DevExpress WinForms v24.2产品图集

段落的边框设置可以通过ParagraphBorders类来实现,使用Paragraph.Borders、ParagraphProperties.Borders或ParagraphStyle.Borders属性来获取ParagraphBorders对象,并根据您的具体使用场景修改边框设置。

C#

richEditControl.Text = "paragraph 1\r\nparagraph 2\r\nparagraph 3\r\nparagraph 4\r\n";
Document document = richEditControl.Document;// Setup borders for one paragraph
Paragraph firstParagraph = document.Paragraphs[0];
ParagraphBorders borders1 = firstParagraph.Borders;
SetBorders(borders1.LeftBorder, BorderLineStyle.Single, 1f, Color.Red);
SetBorders(borders1.TopBorder, BorderLineStyle.Single, 1f, Color.Red);
SetBorders(borders1.RightBorder, BorderLineStyle.Single, 1f, Color.Red);
SetBorders(borders1.BottomBorder, BorderLineStyle.Single, 1f, Color.Red);// Setup borders for multiple paragraphs
Paragraph secondParagraph = document.Paragraphs[1];
Paragraph forthParagraph = document.Paragraphs[3];
DocumentRange paragraphRange = document.CreateRange(secondParagraph.Range.Start,
forthParagraph.Range.End.ToInt() - secondParagraph.Range.Start.ToInt());
ParagraphProperties paragraphProperties = document.BeginUpdateParagraphs(paragraphRange);
ParagraphBorders borders2 = paragraphProperties.Borders;
SetBorders(borders2.LeftBorder, BorderLineStyle.Double, 1.5f, Color.Green);
SetBorders(borders2.TopBorder, BorderLineStyle.Double, 1.5f, Color.Green);
SetBorders(borders2.RightBorder, BorderLineStyle.Double, 1.5f, Color.Green);
SetBorders(borders2.BottomBorder, BorderLineStyle.Double, 1.5f, Color.Green);
SetBorders(borders2.HorizontalBorder, BorderLineStyle.Double, 1.5f, Color.Green);
document.EndUpdateParagraphs(paragraphProperties);// Reset paragraph borders
secondParagraph.Borders.Reset();//...
void SetBorders(ParagraphBorder border, BorderLineStyle lineStyle,
float borderWidth, Color color) {
border.LineStyle = lineStyle;
border.LineWidth = borderWidth;
border.LineColor = color;
}
表格的Alt文本

Table.Title和Table.Description属性允许您指定Word文档表中包含的信息的替代、基于文本的表示形式。在将Word文档导出为可访问的PDF格式时,也会使用表格标题和描述。

C#

RichEditDocumentServer documentProcessor = new RichEditDocumentServer();
documentProcessor.LoadDocument("tables.docx");
Document document = documentProcessor.Document;
if(document.Tables.Count > 0) {
Table table = document.Tables[0];
table.Title = "Table title..";
table.Description = "Table description..";
}

注意,表格标题和描述只支持OpenXml文档格式(.docx, .docm, .dotx, .dotm)和HTML。

AI支持的图像Alt文本对话框

DevExpress WinForms v24.2附带了一个新的AI支持的Alt Text对话框,该对话框允许您为Word文档中的形状对象设置可访问的描述,或将非信息文档图形标记为装饰性(此设置允许屏幕阅读器在扫描文档时忽略装饰性图形)。此外,您可以使用AI支持的Alt Text对话框来为文档图像生成有意义的描述。

DevExpress WinForms v24.2产品图集

要启用此功能,请注册AI服务,然后在WinForms应用程序中附加GenerateImageDescriptionBehavior操作。

C#

using DevExpress.AIIntegration.WinForms;//...
public RichEditControlForm() {
InitializeComponent();
behaviorManager1.Attach<GenerateImageDescriptionBehavior>(richEditControl1);
}

如果GenerateDescriptionBehavior没有为DevExpress富文本编辑器注册,则Generate按钮将被禁用,只能为文档图像生成描述。当选择形状或图表对象时,Generate选项将被禁用。

新的内置对话框可以从形状的上下文菜单中获得,要激活Alt Text对话框,请选择文档形状、图像或图表,打开上下文菜单并单击 "View Alt Text..."上下文菜单项。

Macros API

Document.VbaProject属性允许您以编程方式访问存储在启用宏的Word文件中的VBA项目,使用VbaProject.Modules集合来获取有关VBA项目模块的信息(模块的数量、模块的名称和二进制数据),或者从项目中删除特定的模块。如果当前文档格式不支持宏,或者启用宏的文档不包含宏,则VbaProject.Modules集合为空。

C#

// Check if the current document has macros and remove them
Document document = wordProcessor.Document;
if(document.VbaProject.Modules.Count > 0)
document.VbaProject.Modules.Clear();

http://www.xdnf.cn/news/9339.html

相关文章:

  • Java五种方法批量处理List元素全解
  • 【操作系统】内核态、用户态
  • [Python] 避免 PyPDF2 写入 PDF 出现黑框问题:基于语言自动匹配系统字体的解决方案
  • CS144 - LAB0
  • 文本编辑器vi的使用
  • SECS/GEM协议中Report ID、SV ID、CE ID与S2F33/S2F35/S2F37指令的关系及配置示例
  • 专业库室联管联控系统|门禁联管联控系统
  • Browser-use快速了解
  • 流光溢彩的数字长河:Linux基础IO,文件系统的诗意漫游
  • Google Play的最新安全变更可能会让一些高级用户无法使用App
  • 函数抓取图片microsoft excel与wps的区别
  • 【n-grams】基于统计方法的语言模型
  • 深入理解设计模式之中介者模式
  • 基于Springboot + vue3实现的图书管理系统
  • 【Mysql开启慢查询日志】
  • 泰迪杯特等奖案例深度解析:基于联邦时空图卷积网络的跨区域碳排放协同预测与优化系统
  • 详解Kubernetes Scheduler 的调度策略
  • Day04
  • python进程间通信
  • C++数据结构 : map和set的使用
  • 高精度微型导轨在3D打印机中有多重要?
  • 2024 CKA模拟系统制作 | Step-By-Step | 9、题目搭建-扩容deployment副本数量
  • 打破云平台壁垒支持多层级JSON生成的MQTT网关技术解析
  • 《数据结构笔记四》双链表:创建,插入(头插、尾插、中间任意位置插入),删除,遍历,释放内存等核心操作。
  • 释放生产力潜能 AI-Hub智能数据中枢引领企业数字化转型
  • 粒子群优化(Particle Swarm Optimization, PSO)
  • 大模型(7)——向量模型(向量化存储)
  • Science综述:光电超构器件
  • Spring IoC(2)
  • 18、Python字符串全解析:Unicode支持、三种创建方式与长度计算实战