What would be the best way to simulate Radar in C#?

后端 未结 4 1864
北海茫月
北海茫月 2020-12-20 00:33

I have a Picture box inside a Groupbox in my form with the Picture of a radar set as the background picture. My intention is to dynamically load tiny Jpeg images within the

4条回答
  •  忘掉有多难
    2020-12-20 01:14

    The simplest way is to load your tiny JPEGs into tiny PictureBoxes, and add them to the main PictureBox's Controls collection (i.e. place them on the PictureBox) at runtime.

    Since this will probably produce flicker, the slightly more complex way is to keep the main picture and the tiny pictures in class-level Bitmap objects, and in the main PictureBox's Paint event, you copy the main picture followed by each tiny picture onto a second class-level Bitmap (named _doubleBuffer or something like that) using the DrawImage method, and then copy _doubleBuffer onto your PictureBox (also using DrawImage). Whenever you need to update your display and redraw everything, you just call the PictureBox's Invalidate method.

    There are loads of examples here on SO that show how to use these methods. Good luck, it sounds fun (if you're rewriting the classic arcade game Submarine, let me know - I loved that game).

提交回复
热议问题