I'm writing a app to built a CAD viewer. When I using EllipseGeometry in canvas, it's very slow to create/move graphics. So i change to use DrawVisual. it's faster than using EllipseGeometry, but still very slow to move the whole graphics. is there any sample code to show me how to deal with so many ellipses.
Asked
Active
Viewed 272 times
-3
-
My first suggestion would be to draw these ellipses onto a bitmap, and then show that onscreen and move it around, instead of redrawing every time. – Neil Aug 10 '20 at 12:18
-
Do you need to move these around independently? Or the user interact with them? I would expect cad to be more a static picture. If you don't then more low level stuff and drawingcontext drawellipse is going to be faster. – Andy Aug 10 '20 at 12:33
-
@Andy No need independently, I have a canvas in a canvas, move and zoom the canvas outside. – Neo Aug 10 '20 at 13:14
-
@Neil if i draw a bitmap, can I select one ellipse by mouse and search it? – Neo Aug 10 '20 at 13:15
-
You don't 'check the bitmap', you need to, get a mouse click and then work out which ellipse has been clicked (and there may be more than one if the ellipses overlap), but it's just a bit of maths. – Neil Aug 10 '20 at 14:19
-
What do you mean by "select one ellipse by mouse and search it". – Andy Aug 10 '20 at 15:43
-
You can have thousands of complicated pieces of ui drawn in a canvas which are controls. WPF can handle that. It will not be instant drawing them though. Or. You can draw a complicated bitmap and calculate the meaning of where the user clicks. Which would allow for very fast rendering, Both approaches have + and -. – Andy Aug 10 '20 at 15:45
-
thank you @Andy, Your suggest "draw a complicated bitmap and calculate the meaning of where the user clicks" is a good idea. – Neo Aug 11 '20 at 00:03
1 Answers
-2
I think it's probabily too much for WPF.
I would go for DirectX. See SharpDX which is no longer mantained but will give you an idea.
See also Fast 2D graphics in WPF

corradolab
- 718
- 3
- 16