First big mistake I can see is creation of the instance of
Graphics
in the event handler of the event
Paint
. You should use the instance provided in the event arguments. Well, the way of setting up event handles is bad; and the naming conventions are not observed. Also, it's much better to override
OnPaint
instead of adding the handler. And, by the way, you will need to use the custom control by sub-classing
System.Windows.Forms.Control
anyway. First reason for that is using protected
SetStyle
to add optimized double buffering, to avoid flicker.
Please see my past answers:
Drawing Lines between mdi child forms[
^],
capture the drawing on a panel[
^],
What kind of playful method is Paint? (DataGridViewImageCell.Paint(...))[
^].
[EDIT #1]
See also my second comment to the question. Do not hard-code
immediate constants. Work in a supportable way.
[EDIT #2]
AliRadman asked:
I want Rotation & Move & Scale Code
So, what's the problem? You can use the property
System.Drawing.Graphics.Transform
or the methods having the word "Transform" in their names. You would need
RotateTransform
,
ScaleTransform
,
TranslateTransform
and maybe
ResetTransform
. Please see:
http://msdn.microsoft.com/en-us/library/system.drawing.graphics.aspx[
^].
A note: Please, don't post your questions or comments as answers. Such posts will be deleted; no one gets e-mail notifications.
—SA