0

I am making an application in C# using WinForms and I don't know exactly how to implement the following. I want a circle-shaped control that has a needle and allows user to move the needle. The position of the needle should mark the angle with respect to the circle (counterclockwise)

It occurred to me to create a panel and put a background imagebox but I don't know how I would implement the needle and allow the user to interact with it.

This is an example of what I want it to look like:

enter image description here

Alexei Levenkov
  • 98,904
  • 14
  • 127
  • 179
Kokox
  • 519
  • 1
  • 9
  • 24
  • You probably will need to draw the needle. VS and Drag-Drop are unneeded tags. – Ňɏssa Pøngjǣrdenlarp Apr 24 '20 at 22:15
  • 1
    You can take the gauge calculation (rotation of a shape anchored on a fixed point) from here: [Arc graphic quality](https://stackoverflow.com/a/54139910/7444103) and some simple math that can come in handy from [here](https://stackoverflow.com/a/52921415/7444103). To draw a *fancier* needle, you can build a transparent Bitmap, then draw it inside a shape (a rectangle), check whether the shape contains the mouse pointer (with `Rectangle.Contains(Point)`) and, if the mouse left button is down, rotate the needle on the fixed point using `Matrix.RotateAt()` – Jimi Apr 24 '20 at 22:25
  • 1
    This is way too broad for SO. You may want to start with some tutorial on creating custom controls, continue to some drawing once, check questions about "circular UI element in Winforms", do some math research on computing angle between two vectors... And than [edit] the question with one single concrete problem you are facing (or at least one-per -question) – Alexei Levenkov Apr 24 '20 at 22:26

0 Answers0