Click here to Skip to main content
15,896,367 members
Articles / Programming Languages / C#

Webpage thumbnailer

Rate me:
Please Sign up or sign in to vote.
4.75/5 (25 votes)
17 Aug 20062 min read 169K   6K   98  
An article on how to get a webpage thumbnail and give your favorite links a face.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace net.grool.util
{   
	public partial class TestForm : Form
	{
		
		public TestForm()
		{
			InitializeComponent();
			
	     }
		PicDoc picDoc = null;
		BrowserForm browserForm=null;
		
		private void btnGo_Click(object sender, EventArgs e)
		{
			if (tbUrl.Text.Equals(string.Empty)) return;
			picDoc = new PicDoc();
			picDoc.refreshPicture += new RefreshPictureDelegate(picDoc_refreshPicture);
			picDoc.Url=tbUrl.Text;
			picDoc.PicSize = (PSize)this.cbPicSize.SelectedItem;
			browserForm.CurDoc = picDoc;
		    browserForm.getImageFromUrl(picDoc.Url);
			

		}
		/// <summary>
		/// Here I paint a border to picture and  display it
		/// </summary>
		/// <param name="im"></param>
		private void picDoc_refreshPicture(Image im) {

			Graphics g = Graphics.FromImage(im);
			g.DrawRectangle(Pens.Blue,new Rectangle(0,0,im.Width-1,im.Height-1));
			this.pPicture.BackgroundImage = im;
		
		
		}
		/// <summary>
		/// Here I populate combo box with PSize objects representing sizes available for thumbnails.
		/// Invisible BrowserForm is created  here as well.
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void TestForm_Load(object sender, EventArgs e)
		{
			cbPicSize.Items.Add(new PSize(200, 200));
			cbPicSize.Items.Add(new PSize(300,300));
			cbPicSize.SelectedIndex = 0;
			browserForm = new BrowserForm();

		}
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Belgium Belgium
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions