Visual C#.NET: Create Windows Image Viewer

How to create Windows image viewer using C#.NET
Developers may create Windows-based Image Viewer if they use our Yiigo.Image for .NET. Besides, you may create Web-based Image Viewer with C#. This document provides comprehensive Visual C#.NET samples for guiding developers to create Windows image viewer using Yiigo.Image for .NET. If you are VB.NET developer, find Windows image viewer creation on Create Windows image viewer in VB.NET.
Create Windows Image Viewer with C#.NET Sample Code

Requirements

Before creating Windows image viewer using Yiigo.Image for .NET in Visual C#.NET, make sure that you have installed.
  • Operating systems - Windowss 7, Windowss Vista, and Windowss XP, etc
  • Compatible with .NET framework 2.0 and above versions
  • Support Visual Studio 2005, 2010 and other .NET development environments
  • Yiigo.Image for .NET installation

Start to Create Windows Image Viewer

  • Open and run your Microsoft Visual Studio;
  • Choose either "Visual C# Projects" in "New Project" dialog box;
  • Choose "Windows Application" in the "Templates" List and name it "YiigoImagingWindowsViewer";
  • Right-click on the "References" folder, and select "Add Reference..." from the context menu in the "Solution Explorer" window;
  • In the "Add Reference" dialog box, select the ".NET" tab and browse to Yiigo.Imaging.Net.Windows.dll library;
  • Add it to your Visual C# applications;
  • Add a ToolStrip control to the top of the form by dragging it from the Visual Studio Toolbox;
  • Drag a WindowsImageViewer control from the Visual Studio Toolbox YiigoImage tab;
  • Select Fill from the Dock property located in the property grid of the WindowsImageViewer control;
  • Drag an Acquisition Component from YiigoImage tab in the toolbox.
using System.IO;
using System.Drawing.Printing;
using YiigoImage.Imaging;
using System.Windowss;
using YiigoImage.Imaging.WindowssControl;

// Add Open button to viewer
private void Open_Click(object sender, EventArgs e)
{
if (openFileDialog1.ShowDialog(this) == DialogResult.OK)
{
WindowsViewer.Load(new FileSystemImageSource(new string[] {
openFileDialog1.FileName }, true), null);
}
}

// Add Zoom and Scale button to viewer
private void FitToWidth_Click(object sender, EventArgs e)
{
WindowsViewer.ImageControl.AutoZoom =
YiigoImage.Imaging.WindowsControl.AutoZoomMode.FitToWidth;
}
private void FitToHeight_Click(object sender, EventArgs e)
{
WindowsViewer.ImageControl.AutoZoom =
YiigoImage.Imaging.WindowsControl.AutoZoomMode.FitToHeight;
}
private void FullSize_Click(object sender, EventArgs e)
{
WindowsViewer.ImageControl.AutoZoom =
YiigoImage.Imaging.WindowssControl.AutoZoomMode.None;
WindowsViewer.ImageControl.Zoom = 1.0;
}

// Add Scan button to viewer
private void acquisition1_ImageAcquired(object sender, AcquireEventArgs e)
{
WindowsViewer.Add(YiigoImage.FromBitmap(e.Image), "", "");
}
private void Scan_Click(object sender, EventArgs e)
{
foreach (Device dev in acquisition1.Devices)
{
if (dev.Identity.ProductName ==
tcbChooseScanner.SelectedItem.ToString())
{
dev.Acquire();
}
}
}

// Add Save button to viewer
private void Save_Click(object sender, EventArgs e)
{
if (saveFileDialog1.ShowDialog(this) == DialogResult.OK)
{
WindowsViewer.Save(saveFileDialog1.FileName, new TiffEncoder());
}
}
Imaging Solution
Yiigo.Image for .NET
Online C# Tutorial
C#: Yiigo.Image for .NETC#: How to StartC#: Doc Management SolutionC#: Web Doc ViewerC#: How to Deploy SDK
Doc & Image Formats
C#: PDFC#: TIFFC#: WordC#: DICOM
Advanced Functions
C#: Programming with Image SDKC#: Barcode ReadingC#: Barcode GeneratingC#: Twain ScanningC#: OCR Recognition