ImageBoxSample/MainForm.cs

Download

imageboxsample-part3.zip

(443.55 KB | 23 August 2010 )

Sample project showing how to create an image viewer that supports scrolling with the mouse and keyboard, and panning with the mouse.

Donate

Contents of imageboxsample-part3.zip/ImageBoxSample/MainForm.cs

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace ImageBoxSample
{
  public partial class MainForm : Form
  {

    // ImageBox sample project
    // http://cyotek.com/article/display/creating-a-scrollable-and-zoomable-image-viewer-in-csharp-part-2

    // Preview image based on bwpx.icns - http://paularmstrongdesigns.com/projects/bwpx-icns/
    // Large preview image from http://www.crazythemes.com/colorful-abstract-widescreen-wallpapers-vol2/2153

    public MainForm()
    {
      InitializeComponent();
    }

    private void imageBox_Scroll(object sender, ScrollEventArgs e)
    {
      positionToolStripStatusLabel.Text = imageBox.AutoScrollPosition.ToString();
    }
  }
}

Files