没有找到合适的产品?
联系客服协助选型:023-68661681
提供3000多款全球软件/控件产品
针对软件研发的各个阶段提供专业培训与技术咨询
根据客户需求提供定制化的软件开发服务
全球知名设计软件,显著提升设计质量
打造以经营为中心,实现生产过程透明化管理
帮助企业合理产能分配,提高资源利用率
快速打造数字化生产线,实现全流程追溯
生产过程精准追溯,满足企业合规要求
以六西格玛为理论基础,实现产品质量全数字化管理
通过大屏电子看板,实现车间透明化管理
对设备进行全生命周期管理,提高设备综合利用率
实现设备数据的实时采集与监控
利用数字化技术提升油气勘探的效率和成功率
钻井计划优化、实时监控和风险评估
提供业务洞察与决策支持实现数据驱动决策
原创|使用教程|编辑:龚雪|2020-04-22 09:40:08.343|阅读 326 次
概述:DevExpress Winforms Controls 内置140多个UI控件和库,完美构建流畅、美观且易于使用的应用程序,本文主要为大家介绍如何使用渐变绘制进度条。
# 界面/图表报表/文档/IDE等千款热门软控件火热销售中 >>
相关链接:
下载DevExpress v19.2完整版 DevExpress v19.2汉化资源获取
DevExpress Winforms Controls 内置140多个UI控件和库,完美构建流畅、美观且易于使用的应用程序。想要体验?点击下载>>
开发人员想要使用带有3中颜色的渐变来显示进度条,即开始、中间和末尾有3中不同的颜色,但目前只能使用property.startcolor和property.endcolor对两种颜色实现,没有可用的middlecolor属性。是否有办法或者可以使用那些控件来实现如下图所示的效果:
如果要绘制一些文本,则必须在进度行下为其留出空间。 由于进度线始终占据整个空间,因此您需要更新所有必需矩形的高度。相关代码示例如下:
private void progressBarControl1_Paint(object sender, PaintEventArgs e) { ProgressBarViewInfo vi = (ProgressBarViewInfo)this.progressBarControl1.GetViewInfo(); Padding bt = CalcBorderThickness(vi); int progressHeight = 22; int textIndent = 2; vi.ProgressInfo.Bounds = UpdateHeight(vi.ProgressInfo.Bounds, progressHeight); vi.ProgressInfo.EmptyBounds = UpdateHeight(vi.ProgressInfo.EmptyBounds, progressHeight); vi.ProgressInfo.EmptyBounds2 = UpdateHeight(vi.ProgressInfo.EmptyBounds2, progressHeight); vi.ProgressInfo.ProgressBounds = UpdateHeight(vi.ProgressInfo.ProgressBounds, progressHeight); Rectangle all = vi.ProgressInfo.Bounds; Rectangle filled = vi.ProgressInfo.ProgressBounds; Rectangle part1 = new Rectangle(filled.X, filled.Y, filled.Width / 2 + 1, filled.Height); Rectangle part2 = new Rectangle(part1.Right, filled.Y, filled.Right - part1.Right, filled.Height); using (GraphicsCache cache = new GraphicsCache(e.Graphics)) { cache.Graphics.Clear(this.progressBarControl1.Parent.BackColor); Rectangle borderBounds = vi.ProgressInfo.Bounds; borderBounds.Inflate(bt.Left, bt.Top); vi.ProgressInfo.Cache = cache; vi.BorderPainter.DrawObject(new ObjectInfoArgs() { Bounds = borderBounds, Cache = cache }); cache.FillRectangle(cache.GetGradientBrush(part1, Color.Red, Color.Yellow, LinearGradientMode.Horizontal), part1); cache.FillRectangle(cache.GetGradientBrush(part2, Color.Yellow, Color.Green, LinearGradientMode.Horizontal), part2); Size textSize = vi.ProgressAppearance.CalcTextSize(cache, vi.DisplayText, -1).ToSize(); int linePos = part2.Right >= all.Right - 1? all.Right -1: part2.Right; cache.DrawLine(cache.GetPen(Color.Black), new Point(linePos, part2.Top), new Point(linePos, part2.Bottom + textSize.Height + textIndent)); Rectangle textRect = new Rectangle(new Point(linePos + textIndent, part2.Bottom + textIndent), textSize); if (textRect.Right > all.Right) textRect.X -= textRect.Width + textIndent * 2; vi.ProgressAppearance.DrawString(cache, vi.DisplayText, textRect); } } private Padding CalcBorderThickness(ProgressBarViewInfo vi) { SkinProgressBarObjectPainter p = new SkinProgressBarObjectPainter(vi.LookAndFeel); ProgressBarObjectInfoArgs e = new ProgressBarObjectInfoArgs(vi.Appearance); Rectangle client = new Rectangle(0, 0, 100, 100); Rectangle r = vi.BorderPainter.CalcBoundsByClientRectangle(vi.ProgressInfo, client); Padding res = new Padding(client.X - r.X, client.Y - r. Y, r.Right - client.Right, r.Bottom - client.Bottom); return res; } private Rectangle UpdateHeight(Rectangle bounds, int height) { bounds.Height = height; return bounds; }
ProgressBarControl控件不支持此功能,为了实现您的目标,建议使用ProgressBarControl.Paint事件并编写代码来绘制渐变进度条,示例如下:
private void progressBarControl1_Paint(object sender, PaintEventArgs e) { ProgressBarViewInfo vi = (ProgressBarViewInfo)this.progressBarControl1.GetViewInfo(); Padding bt = CalcBorderThickness(vi); int progressHeight = 22; int textIndent = 2; vi.ProgressInfo.Bounds = UpdateHeight(vi.ProgressInfo.Bounds, progressHeight); vi.ProgressInfo.EmptyBounds = UpdateHeight(vi.ProgressInfo.EmptyBounds, progressHeight); vi.ProgressInfo.EmptyBounds2 = UpdateHeight(vi.ProgressInfo.EmptyBounds2, progressHeight); vi.ProgressInfo.ProgressBounds = UpdateHeight(vi.ProgressInfo.ProgressBounds, progressHeight); Rectangle all = vi.ProgressInfo.Bounds; Rectangle filled = vi.ProgressInfo.ProgressBounds; Rectangle part1 = new Rectangle(filled.X, filled.Y, filled.Width / 2 + 1, filled.Height); Rectangle part2 = new Rectangle(part1.Right, filled.Y, filled.Right - part1.Right, filled.Height); using (GraphicsCache cache = new GraphicsCache(e.Graphics)) { cache.Graphics.Clear(this.progressBarControl1.Parent.BackColor); Rectangle borderBounds = vi.ProgressInfo.Bounds; borderBounds.Inflate(bt.Left, bt.Top); vi.ProgressInfo.Cache = cache; vi.BorderPainter.DrawObject(new ObjectInfoArgs() { Bounds = borderBounds, Cache = cache }); cache.FillRectangle(cache.GetGradientBrush(part1, Color.Red, Color.Yellow, LinearGradientMode.Horizontal), part1); cache.FillRectangle(cache.GetGradientBrush(part2, Color.Yellow, Color.Green, LinearGradientMode.Horizontal), part2); Size textSize = vi.ProgressAppearance.CalcTextSize(cache, vi.DisplayText, -1).ToSize(); int linePos = part2.Right >= all.Right - 1? all.Right -1: part2.Right; cache.DrawLine(cache.GetPen(Color.Black), new Point(linePos, part2.Top), new Point(linePos, part2.Bottom + textSize.Height + textIndent)); Rectangle textRect = new Rectangle(new Point(linePos + textIndent, part2.Bottom + textIndent), textSize); if (textRect.Right > all.Right) textRect.X -= textRect.Width + textIndent * 2; vi.ProgressAppearance.DrawString(cache, vi.DisplayText, textRect); } } private Padding CalcBorderThickness(ProgressBarViewInfo vi) { SkinProgressBarObjectPainter p = new SkinProgressBarObjectPainter(vi.LookAndFeel); ProgressBarObjectInfoArgs e = new ProgressBarObjectInfoArgs(vi.Appearance); Rectangle client = new Rectangle(0, 0, 100, 100); Rectangle r = vi.BorderPainter.CalcBoundsByClientRectangle(vi.ProgressInfo, client); Padding res = new Padding(client.X - r.X, client.Y - r. Y, r.Right - client.Right, r.Bottom - client.Bottom); return res; } private Rectangle UpdateHeight(Rectangle bounds, int height) { bounds.Height = height; return bounds; }
DevExpress Dashboard控件实操公开课4月即将开启,
DevExpress技术交流群:540330292 欢迎一起进群讨论
扫描关注DevExpress中文网微信公众号,及时获取最新动态及最新资讯
本站文章除注明转载外,均为本站原创或翻译。欢迎任何形式的转载,但请务必注明出处、不得修改原文相关链接,如果存在内容上的异议请邮件反馈至chenjj@evget.com
文章转载自:慧都网本指南将向您展示如何借助Aspose.PDF,仅用几行代码删除不需要的页面。让我们深入了解如何使用 Java 从 PDF 文档中删除页面。
PDF文件因其高度的跨平台兼容性和安全稳定的格式特点,广泛应用于企业文档管理和电子资料传输中。本文将详细讲解如何使用 Spire.PDF for .NET 库在C# 中实现多种PDF拆分功能,包含按每页拆分、按页码范围拆分、按关键字拆分及提取指定页面等场景的完整示例代码,帮助开发者轻松掌握高效的PDF分割技巧,优化文档管理流程。
本文主要介绍如何使用DevExpress WPF Grid控件获取节点,欢迎下载最新版组件体验!
通过将绘图转换为 Photoshop 格式,您可以轻松编辑和增强设计。Aspose.CAD是一款功能强大的 SDK,可无缝实现此转换。借助Aspose.CAD for Python via .NET,开发人员可以自动化转换过程,从而节省时间并减少错误。本博客将指导您如何使用 Python 将绘图转换为 Photoshop。
为Windows Forms平台创建具有影响力的业务解决方案,高性价比WinForms界面控件套包。
服务电话
重庆/ 023-68661681
华东/ 13452821722
华南/ 18100878085
华北/ 17347785263
客户支持
技术支持咨询服务
服务热线:400-700-1020
邮箱:sales@evget.com
关注我们
地址 : 重庆市九龙坡区火炬大道69号6幢
慧都科技 版权所有 Copyright 2003-
2025 渝ICP备12000582号-13 渝公网安备
50010702500608号