WPF PathGeometry渲染(WPF PathGeometry rendering)

编程入门 行业动态 更新时间:2024-10-24 16:33:17
WPF PathGeometry渲染(WPF PathGeometry rendering)

我有一个包含单个折线的PathGeometry,并且在固定的间隔我向线添加一个新点(绘制波形)。 使用穿孔器工具时,我可以看到每次向线添加一个点时,WPF都会将整个PathGeometry标记为“脏”,从而导致整个形状被重新渲染。

我希望它只会重绘单个像素。 有没有办法实现这一目标?

I have a PathGeometry containg a single polyline, and at a fixed interval I add a new point to the line (to plot a waveform). When using the Perforator tool I can see that every time I add a point to the line, WPF marks the entire PathGeometry as 'dirty', causing the entire shape to be re-rendered.

I hoped it would only redraw the single pixel. Is there any way to accomplish that?

最满意答案

最简洁的答案是不..

WPF在更改整个几何体时是正确的,因为它考虑了当前路径值也发生变化的情况。

如果你打破这个,你可以使用行列表而不是路径..但​​是, 这意味着每次用户调整绘图区域时都必须更新线条值以保持比例。

所以要处理这个问题,你可能会写一些代码说: “如果用户调整大小 - 脏了所有行”

另一个问题是当你添加另一行时, 你可能想挤出所有的线条以适应你的绘图区域, 所以你可能会写一些代码说: “如果新线添加 - 脏所有线”..

现在,路径几何行为与您的迷你引擎具有1比1的相似性。

如果你不需要或想要处理新行中的加法或改装, 只需使用一系列行。

The short answer is No..

WPF is correct in dirtying the entire geometry upon a change as it take into consideration a situation where current path values had changes as well.

If you break this down, you can use a list of lines instead of path.. but, That would mean you will have to update the lines values each time the user resize your plotting area in order to keep your proportions..

So to handle this you would probably write some code that says: "if user resized - dirty all lines"..

Another issue is when you add another line, you might want to squeeze all your lines to fit into your plotting area, So you would probably write some code that says: "if new line add - dirty all lines"..

which now give path geometry behavior a 1 to 1 similarity to your mini-engine..

If you don't need to or want to handle resizings or refittings in new lines add, Simply use a list of lines.

更多推荐

本文发布于:2023-07-30 00:06:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1320834.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:WPF   PathGeometry   rendering

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!