Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Displaying a map using WPF

Tags:

c#

canvas

wpf

I am new to WPF, and relatively new to GUI coding, so bear with me if this seems obvious to some.

I am trying to display a randomly generated map using WPF/C#, in order to simulate the behaviour of a propagating RF signal. Each map coordinate can have zero or more items within it - it could be buildings, vehicles, fauna or geographical data (none indicates flat grassy fields). I would like to display this in a window, or on a page to the user. But I don't know how.

My original thought was a canvas with a pre-defined method for drawing items. But the map will be massive, and I only want to display a small portion of the map to the user at any one time.

So, what I want to know is, can I create a canvas, draw what I want onto it, and then display only a small portion of that to the user? If not, or if that is not simple, is there a better way of doing it? I don't necessarily want a specific answer either - a more generic solution would be better (i.e. tell me I need to use a "Blah" with a "Blah blah" would be better than writing out the whole code - I like to learn about these things as much as possible by doing, not copy and paste).

Thanks.

David

like image 330
David Avatar asked Jul 12 '26 21:07

David


1 Answers

Here some ideas:

You can try to paint your objects directly via the GraphicsContext. Here you find an overview.

Also check out CompositionTarget.Rendering, it allows you also to render per frame (as far as possible).

If it is graphically intensive, perhaps it's also a good idea to look into the XNA-framework.

like image 180
HCL Avatar answered Jul 14 '26 09:07

HCL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!