将进度条扭转 90 度
我正在做一个能量流的应用程序。我想使用进度条显示能量流动。我需要在某个时刻转动进度条并且仍然持续流动。有没有办法将进度条上的点旋转 90 度?例如L形。
知道如何去做吗?
I am doing an application for energy flow. I would like to show energy flowing using progress bars. I would need to turn the progress bars at some point and still flow continously. Is there a way to turn a point on the progress bar by 90 degrees? For example an L shape.
Any idea how to go about it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
好的,我完成了。所以编辑这个页面。我想这就是你需要的。
创建一个新的 WPF 项目并对其进行编辑。
Xaml 代码 MainWindow.xaml:
将此类添加到 MainWindow.xaml.cs 文件中:
Ok, i finished it. so edit this page. i guess this is you need.
Create a New WPF Project and edit it.
Xaml code MainWindow.xaml:
Add this class into your MainWindow.xaml.cs file:
我用混合创建了一个简单的动画:一个 L 形路径和一个 DoubleKeyFrame 动画,它改变了 GradientStop 偏移量,使 L 看起来像是被填充了。
通过一些额外的努力,您还可以旋转画笔,使其路径跟随弯曲,从而获得更好的填充效果。动画在框架加载事件上触发,并出于演示原因永远重复。
I have created a simple animation with blend: An L-shaped Path and a DoubleKeyFrame animation which changes the GradientStop Offsets so the L looks like it gets filled.
With some additional effort you could also Rotate the Brush so its path is following the bend abd you get a nicer fill effect. The animation triggers on the framework Loaded Event and repeats forever for demo reasons.
这可以使用 VisualBrush 来完成。
可能需要一段时间才能正确,但我会按如下方式处理:
添加一个
ProgressBar
,根据需要连接使用
VisualBrush
,引用ProgressBar
作为其Visual
,使用Path 设置
基于不透明蒙版足够大覆盖ProgressBar
的左半部分(使用渐变混合或 -45 度对角线右侧边缘),以绘制“L 形条”的水平部分使用第二个
VisualBrush
,同时引用ProgressBar
作为其Visual
,设置一个基于Path
的不透明蒙版,该蒙版足够大以覆盖 ProgressBar 的右半部分(渐变混合或 45 度对角线左手边),绘制“L 形条”的垂直部分This can be done using a VisualBrush.
It may take a while to get it right, but I would approach it as follows:
Add a single
ProgressBar
, hooked up as requiredUse a
VisualBrush
, referencing theProgressBar
as itsVisual
, set up with aPath
based opacity mask big enough to cover the left half of theProgressBar
(with a gradient blended or -45 degree diagonal right hand edge), to draw the horizontal part of the 'L-shaped bar'Use a second
VisualBrush
, also referencing theProgressBar
as itsVisual
, set up with aPath
based opacity mask big enough to cover the right half of the ProgressBar (with a gradient blended or 45 degree diagonal left hand edge), to draw the vertical part of the 'L-shaped bar'