I have a form that I use a transparent background so I can display texts on screen without hide other applications.
Basically I have a instance of a Form where I set the transparence color etc, then I hava a function addtext("Hello World", X, Y) where it creates a Label object, set the settings and add to this form controls.
this.Controls.Add(newLabel);
Well, now I need to create something to add a retangle so people can "draw" things on screen, so I need something similar to the Label object.
I saw some examples in the internet but all of them need the Paint() event to use the Graphics etc and adding the LAbel it doesn't need everything like that.
I tried to use the event and tried call the Graphic propertie etc but didn't work.
Here are some tests that I made:
private class Line : Control
{
public float FromX { get; set; }
public float FromY { get; set; }
public float ToX { get; set; }
public float ToY { get; set; }
public Pen PenColor { get; set; }
public Line() { }
}
Graphics g = this.CreateGraphics();
Line line = (Line)cc;
g.DrawRectangle(line.PenColor, line.FromX, line.FromY, line.ToX, line.ToY);
Edit: The code above works in some cases, not all the time, if I try to debug the code, sometimes after executing the g.DrawRect~ it doesn't move to the next line, looks like it's "executing forever" the g.DrawRectangle() function, the thread who controls this draw keep saying "Running", someone know what might be happening ?