Take the following steps to start a project and to add some code
that uses the Magnifying Glass:
Start Visual Studio .NET. Choose File->New->Project… from the menu. In the New Project dialog box, Choose either "Visual C# Projects" or "Visual Basic Projects" in the Projects Type List, and choose "Windows Application " in the Templates List. Type the project name as "Using the Magnifying Glass" in the Project Name field, and then choose OK. If desired, type a new location for your project or select a directory using the Browse button, and then choose OK . In the "Solution Explorer" window, right-click on the "References" folder, and select "Add Reference…" from the context menu. In the "Add Reference" dialog box, select the ".NET" tab and browse to Leadtools For .NET "\LEAD Technologies\LEADTOOLS 15\Bin\DotNet\Win32 " folder and select the following DLLs: Leadtools.dll Leadtools.Codecs.dll Leadtools.WinForms.dll
Make sure Form1 is in design view. Go to the toolbox (View->Toolbox) and Drag and drop an instance of RasterImageViewer to the form. If you do not have RasterImageViewer in your toolbox, select Tools->Add Remove Toolbox Items from the menu. Click Browse and then select Leadtools.WinForms.DLL from "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Bin\DotNet\Win32" and then click Open and then click OK. Change the following properties: Property Value Dock Fill Switch to Form1 code view (right-click Form1 in the solution explorer then select View Code ) and add the following lines at the beginning of the file: [Visual Basic]
[C#]Imports Leadtools Imports Leadtools.Codecs Imports Leadtools.WinForms
using Leadtools; using Leadtools.Codecs; using Leadtools.WinForms;
Add an event handler to the Form1 Load event and add the following code: [Visual Basic]
[C#]Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load RasterCodecs.Startup() ' Load an image into the viewer Dim codecs As New RasterCodecs rasterImageViewer1.Image = codecs.Load("C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image2.cmp") RasterCodecs.Shutdown() ' Use an elliptical magnifying glass with a thick green cross rasterImageViewer1.InteractiveMode = RasterViewerInteractiveMode.MagnifyGlass rasterImageViewer1.MagnifyGlass.Size = New Size(180, 180) rasterImageViewer1.MagnifyGlass.BorderColor = Color.Red rasterImageViewer1.MagnifyGlass.BorderWidth = 2 rasterImageViewer1.MagnifyGlass.Crosshair = RasterMagnifyGlassCrosshair.Fine rasterImageViewer1.MagnifyGlass.CrosshairColor = Color.Green rasterImageViewer1.MagnifyGlass.CrosshairWidth = 3 rasterImageViewer1.MagnifyGlass.RoundRectangleEllipseSize = New Size(20, 20) rasterImageViewer1.MagnifyGlass.ScaleFactor = 4 rasterImageViewer1.MagnifyGlass.Shape = RasterMagnifyGlassShape.Ellipse rasterImageViewer1.Show() Text = "Click and drag on the image to see the MagnifyGlass" End Sub
private void Form1_Load(object sender, System.EventArgs e) { RasterCodecs.Startup(); // Load an image into the viewer RasterCodecs codecs = new RasterCodecs(); rasterImageViewer1.Image = codecs.Load(@"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Image2.cmp"); RasterCodecs.Shutdown(); // Use an elliptical magnifying glass with a thick green cross rasterImageViewer1.InteractiveMode = RasterViewerInteractiveMode.MagnifyGlass; rasterImageViewer1.MagnifyGlass.Size = new Size(180, 180); rasterImageViewer1.MagnifyGlass.BorderColor = Color.Red; rasterImageViewer1.MagnifyGlass.BorderWidth = 2; rasterImageViewer1.MagnifyGlass.Crosshair = RasterMagnifyGlassCrosshair.Fine; rasterImageViewer1.MagnifyGlass.CrosshairColor = Color.Green; rasterImageViewer1.MagnifyGlass.CrosshairWidth = 3; rasterImageViewer1.MagnifyGlass.RoundRectangleEllipseSize = new Size(20, 20); rasterImageViewer1.MagnifyGlass.ScaleFactor = 4; rasterImageViewer1.MagnifyGlass.Shape = RasterMagnifyGlassShape.Ellipse; rasterImageViewer1.Show(); Text = "Click and drag on the image to see the MagnifyGlass"; }
Build, and Run the program to test it.