How to draw C # / WinForms with decent speed?

I try to visualize the schedule and let people play with it. I found a great Graph # library that can create an initial layout so that this part is covered. Now I need to make a control that actually draws it and provides the necessary interactivity.

Graph # comes with a beautiful visualizer, but I donโ€™t like it because it is written in WPF (while my application is WinForms), and because I want to add some more interactivity options, which will require quite some modification anyway.

The graphs that I draw will usually be quite large, at about 100 vertices and the same number of edges (the graphs will be trees at 99% of the time). This means that the resulting rendering can be up to 2000 pixels by 2000 pixels and even more. Users should be able to zoom in and out, scroll, select and drag vertices and edges and get some pop-ups with additional information when you hover over the vertex.

I am worried that the standard System.Drawingmay not be able to provide decent speed for this. I would like the drag / zoom / scroll operations to be smooth and the pop-ups should open with a little animation. The need should be 20 frames per second.

I know that I can try to speed up the process by pre-creating many elements and storing them as bitmaps in memory - but this is likely to take up a lot of RAM, and I'm still not sure what performance is needed.

What are your thoughts?

+3
source share
3 answers

"Premature optimization is the root of all evil."

GDI + can be great for your needs. Do not go or buy third-party libraries before you know what you even need.

I made a thousand polygons on a 1000x800 bitmap and redrawn it completely at a speed of over 100 frames per second using only GDI +

, , . , GDI.

+5

Graph # Windows Forms.

, , , System.Drawing.

+1

GDI + , , ( ) , , / . , ( SmoothingMode Graphics). , , InterpolationMode.

As a reference, I wrote the GPS.Net Compact Framework application for Windows Mobile, which displayed about 10,000 lines on the screen in real time. This only reached a frame rate of several frames per second, but the processing power on a smartphone, of course, is less than that of a modern PC.

0
source

Source: https://habr.com/ru/post/1716245/


All Articles