![]() In the project demo, the class ImageViewer implements a user control for image rendering. render the image m_Image with a scaling to the size of the control // for that we have to override the OnPaint of the usercontrol protected override void OnPaint(PaintEventArgs e) TempImage.Dispose() // do not forget to dispose and don't wait for GC ![]() G.InterpolationMode = InterpolationMode.HighQualityBicubic Graphics g = Graphics.FromImage(m_Image) Image tempImage = Image.FromFile(imageFilename) load the image and scale it to the given width and height // we don't use GetThumbnailImage because GDI does not always provide // an optimal quality public void LoadImage( string imageFilename, int width, int height) We could work with these two controls like this: This control is good at showing images with some options like SizeMode = PictureBoxSizeMode.Zoom. ![]() Now let's continue with an image viewer: PictureBox. If you want to know more about anchoring and docking, have a look at How to: Anchor and Dock Child Controls in a FlowLayoutPanel Control. Now you get the point: just use FlowLayoutPanel, set the property FlowDirection to FlowDirection.LeftToRight and that's it. This panel dynamically lays out its contents horizontally or vertically, contents are of course controls. The main idea is to use the FlowLayoutPanel control. Everything with C# 2.0 and minimal code.Detect if someone clicks on an image, show the selected image in the thumbnail and in an external viewer.Adapt the layout from left to right dynamically depending on the size of the application.Manage the memory consumption nicely and smoothly.Load asynchronously images from a folder and show them in a thumbnail viewer.So this article is about how to easily add thumbnail viewer functionality to an application with C# 2.0. and you are right!īut let me explain the purpose of this article: I saw a very good article by Marc Clifton Multi Image Viewer and I was just thinking that there must be a simple solution with. Ok, I know, you're thinking: another thumbnail viewer.
0 Comments
Leave a Reply. |