J
James
Hello,
I'm new to c# and have created an animation which draws directly
to the window, it uses the code below which all works. I would
like to know if this is the 'correct' way to do it - or would an
experienced c# programmer do it another way?
This part defines the screen and the graphics pad I'm drawing to:
Graphics screen = CreateGraphics();
Graphics drawpadg = Graphics.FromImage(drawpad);
Next, the background and the frames of animation
Bitmap back =
(Bitmap)Bitmap.FromStream(this.GetType().Assembly.GetManifestResourceStream("WindowsApplication1.skyground.gif"));
Bitmap lemframes =
(Bitmap)Bitmap.FromStream(this.GetType().Assembly.GetManifestResourceStream("WindowsApplication1.lemwalk.gif"));
Clear the pad I draw to
drawpadg.Clear(this.BackColor);
Copy the background and then the frame of animation to the draw pad.
drawpadg.DrawImage(back, new Rectangle(0, 0, 400, 120), 0,
0, 400, 120, GraphicsUnit.Pixel);
drawpadg.DrawImage(lemframes, new Rectangle(x+lo[f], y,
lw[f], 46), lx[f], 0, lw[f], 46, GraphicsUnit.Pixel);
Finally copy the draw pad to the screen
screen.DrawImage(drawpad, 0, 0);
Then I dispose of everything afterwards (like a good little c# coder
)
I also want to start developing an application which allows you to
scroll around an image, and which lets you resize the window (and have
the scroll bars update). I cannot get the scroll bars to appear by
playing with the properties - how should I be doing this please?
Ta, James
I'm new to c# and have created an animation which draws directly
to the window, it uses the code below which all works. I would
like to know if this is the 'correct' way to do it - or would an
experienced c# programmer do it another way?
This part defines the screen and the graphics pad I'm drawing to:
Graphics screen = CreateGraphics();
Graphics drawpadg = Graphics.FromImage(drawpad);
Next, the background and the frames of animation
Bitmap back =
(Bitmap)Bitmap.FromStream(this.GetType().Assembly.GetManifestResourceStream("WindowsApplication1.skyground.gif"));
Bitmap lemframes =
(Bitmap)Bitmap.FromStream(this.GetType().Assembly.GetManifestResourceStream("WindowsApplication1.lemwalk.gif"));
Clear the pad I draw to
drawpadg.Clear(this.BackColor);
Copy the background and then the frame of animation to the draw pad.
drawpadg.DrawImage(back, new Rectangle(0, 0, 400, 120), 0,
0, 400, 120, GraphicsUnit.Pixel);
drawpadg.DrawImage(lemframes, new Rectangle(x+lo[f], y,
lw[f], 46), lx[f], 0, lw[f], 46, GraphicsUnit.Pixel);
Finally copy the draw pad to the screen
screen.DrawImage(drawpad, 0, 0);
Then I dispose of everything afterwards (like a good little c# coder
)
I also want to start developing an application which allows you to
scroll around an image, and which lets you resize the window (and have
the scroll bars update). I cannot get the scroll bars to appear by
playing with the properties - how should I be doing this please?
Ta, James