WPF PathGeometry 渲染 [英] WPF PathGeometry rendering

查看:69
本文介绍了WPF PathGeometry 渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个包含单条折线的 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?

推荐答案

简短的回答是否定的..

The short answer is No..

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

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"..

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

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.

这篇关于WPF PathGeometry 渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆