我有一个包含单个折线的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.
更多推荐
发布评论