In most cases, yeah. In my experience the decision is made based on how often the images change. If there's at least 1s between images changing, then I prefer the Invalidate route and let them get painted according to the natural paint process. If it's intended to be an animation or pseudo-animation with 4 images per second or more then I get a better effect by constructing the Graphics and painting directly outside of the OnPaint handler.
-----Original Message----- From: Rolf Bjarne Kvinge [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 12, 2007 9:06 AM To: Maser, Dan; 'Abir Bhattacharya'; [email protected] Subject: RE: [Mono-winforms-list] Dynamic drawing of Images on the form Hi, > > (...) >B. you can code up the OnPaint function to paint the correct ONE of >your images. Then you can make a Timer object on your form. When the timer fires, you can call the static Graphics.FromHwnd to get a graphics object and directly >paint the newer image. Also update a member variable with the current image so that if your window is covered and uncovered it will paint the correct thing. Instead of directly drawing the image, in this case use Invalidate (ImageRectangle) which will cause OnPaint to be called, thereby avoiding Graphics.FromHwnd. Rolf ______________________________________ From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Abir Bhattacharya Sent: Wednesday, September 12, 2007 6:16 AM To: [email protected] Subject: [Mono-winforms-list] Dynamic drawing of Images on the form HI, I need to display some dynamic images on a windows form at regular intervals based on some logic. The code runs perfectly fine with .NET and as well as the Win MONO(1.2.4) platforms , but when I port the identical code to the Mono develop running on the Linux (2.6.22-Fedora) the images are displayed in sporadic bursts . The code snippet: protected override void OnPaint(PaintEventArgs e) { //base.OnPaint(e); Graphics gr ,gf; gr = e.Graphics; gf = Graphics.FromHwnd(this.Handle); for (; intCtr < Cntr; intCtr += 1) { // call the final rect //passEncStr = enS.EnCodeString((string)a2[intCtr]); PaintFinalRect(enS.EnCodeString((string)a2[intCtr]),gr); Thread.Sleep(100); base.OnPaint(e); gf.FillRectangle(new SolidBrush(this.BackColor), this.ClientRectangle); gr.Dispose(); if (intCtr == Cntr - 1) { intCtr = 0; } } return; } I s there a problem with the primary thread Sleep methods ? -- Visit us at http://www.2pirad.com/ -- _______________________________________________ Mono-winforms-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-winforms-list
