WPF:创建动态进度指示器

发布于 2024-09-16 09:48:16 字数 847 浏览 3 评论 0原文

我目前正在尝试使用 WPF 在 C# 中编写带有进度指示器的应用程序:

<Path Canvas.Left="15" Canvas.Top="50" Stroke="Red" StrokeThickness="6" Data=" M 700,100 L 620,100 C 620,100 600,100 600,80 L 600,50 C 600,50 600,30 580,30 L 50,30 L 50,340 L 580,340 C 580,340 600,340 600,320 L 600,290 C 600,290 600,270 620,270 L 700,270" Name="Progress" StrokeDashCap="Flat" StrokeEndLineCap="Round" StrokeLineJoin="Round" StrokeStartLineCap="Round" StrokeMiterLimit="30">

image http://img839.imageshack.us/my.php?image=20100831180406。 png

至此指标就完成了。但是我还没有任何可能降低指示器的长度。我可以使用其他坐标重新绘制指示器,但这会有点复杂(考虑圆形部分)。另外,我无法用白色覆盖它,因为由于背景图像它必须是透明的。

有人知道如何实现我想要的吗?或者指出另一种可能的解决方案?

最好的问候, 乔纳斯

I'm currently trying to write an application with a progress indicator in C# using WPF:

<Path Canvas.Left="15" Canvas.Top="50" Stroke="Red" StrokeThickness="6" Data=" M 700,100 L 620,100 C 620,100 600,100 600,80 L 600,50 C 600,50 600,30 580,30 L 50,30 L 50,340 L 580,340 C 580,340 600,340 600,320 L 600,290 C 600,290 600,270 620,270 L 700,270" Name="Progress" StrokeDashCap="Flat" StrokeEndLineCap="Round" StrokeLineJoin="Round" StrokeStartLineCap="Round" StrokeMiterLimit="30">

image
http://img839.imageshack.us/my.php?image=20100831180406.png

So far the indicator is finished. However I don't have any possibility to lower the length of the indicator yet. I could redraw the indicator using other coordinates but that would be kind of complicated (think about the rounded parts). Also I can't overlay it with white color as it must be transparent due to a background image.

Does anyone have an idea on how to achieve what I want? Or point me to another possible solution?

Best greetings,
Jonas

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

朱染 2024-09-23 09:48:16

我不知道我是否理解你想要什么,但这就是我尝试

  1. 将其分成 3 列,每列都有一个路径。第一列具有左边缘的路径。中间列将只有顶部/底部并将拉伸,右列将包含右侧曲线/等。
  2. 创建一个半径与内角相同的矩形,并将其放在第二列中。
  3. 通过更新矩形的宽度来可视化进度。

这种方法只会将进度填满您制作的瓶状指示器的“颈部”。

I dunno if I'm understanding what you want, but this is what I'd try

  1. Split it up into 3 columns, with a path in each column. The 1st column is has the path for the left edge.. the middle column will just have the top/bottom and will stretch, the right column will contain the right curves/etc.
  2. Create a rectangle with a radius the same as your inner corners and put it in the 2nd columns.
  3. visualize progress by updating the width of the rectangle.

This approach would only fill the progress up the "neck" of the bottle-like indicator you made.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文