using C#;
I'm trying to make an application using a Leap Motion sensor to map finger movements to cursor movement. On the screen, I would like to draw a circle around the cursor.
After some searching I found someone trying to do the same thing (Leap Motion excluded) Want a drawn circle to follow my mouse in C#. The code presented there:
private void drawCircle(int x, int y)
{
Pen skyBluePen = new Pen(Brushes.DeepSkyBlue);
Graphics graphics = CreateGraphics();
graphics.DrawEllipse(
skyBluePen, x - 150, y - 150, 300, 300);
graphics.Dispose();
this.Invalidate();
}
I Made some changed to make it work for my application:
private void drawCircle(int x, int y, int size)
{
Pen skyBluePen = new Pen(Brushes.DeepSkyBlue);
Graphics graphics = Graphics.FromHwnd(IntPtr.Zero);
graphics.DrawEllipse(
skyBluePen, x - size / 2, y - size / 2, size, size);
graphics.Dispose();
}
The reason I had to make some changes is because my application runs from the console and does not use forms. Meaning that I can't use the solutions presented in the other question.
The code above does draw circles , but they don't disappear as you can see in this image:
Something else to notice is that my application needs to runs even when it's console is not the active window (this works right now).
Now, I am very new to C# so it could be that the solution is very easy, but I can't find it.
So in short: I would like it to be such that only the last drawn circle is visible.