I am trying to develop a metronome application which I have almost completed.
The only portion I have left is a secondary visual that requires me to rotate an image of an arm (think minute hand on a clock) backwards and forwards in time.
how can I rotate an image and do so by not rotating it around its center point. in the scenario I am writing for I need to be able to rotate the image around a point in the middle of its bottom border.
Also, I would like to be able to rotate the image from X to Y in n milliseconds and have it ease in and out in the animation. Is this a bridge too far for C# and are there any libraries that could help me achieve this advance type of physics animation.
many thanks
Dan
may be this sample code is useful:
Expanded Reply
There is no flicker whatsoever. The SetStyle in the ctor takes care of that. What you see as "flicker" is an artifact cause by three factors:
Look at the code more carefully. This is not "painted on the form", it's a custom control. See how
MetronomeControl
derives fromControl
? See how we created the form by adding a MetronomeControl to it?Picture boxes are for displaying static images, not for custom controls!
The way it updates is by creating a timer. When the timer's Tick event fires we update the angle and direction, more generally, we update the state of the control. The call to Invalidate tells the Operating System, "Hey, I need to be repainted, send me a WM_PAINT message when it's convenient!". Our OnPaint override simply paints the current state of the control.
Not what you asked for, but:
Instead of doing a processor-intensive operation many times per second, you should consider flipping through a set of static images instead.