OnPaintCrosshair Method

Summary

Occurs when the Magnifying Glass crosshair is redrawn.

Syntax

C#
C++/CLI
C++
protected virtual void OnPaintCrosshair( 
   Graphics graphics, 
   Point centerPoint 
) 
protected: 
virtual void OnPaintCrosshair(  
   Graphics^ graphics, 
   Point centerPoint 
)  
protected:  
   virtual void OnPaintCrosshair( 
      Graphics^ graphics, 
      Point^ centerPoint 
   ) 

Parameters

graphics
The Graphics object used to paint.

centerPoint
The center point of the Magnifying Glass rectangle

Remarks

You can override this method in order to paint your own crosshair for the Magnifying Glass. Call the base class implementation for the default behavior.

Example

C#
using Leadtools.WinForms; 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Drawing; 
 
class MyRasterMagnifyGlass : RasterMagnifyGlass 
{ 
   public MyRasterMagnifyGlass() 
   { 
      Shape = RasterMagnifyGlassShape.Border3D; 
   } 
 
   protected override void OnPaintBorder(Graphics graphics, Point centerPoint) 
   { 
      int width = (Size.Width - 2) / 2; 
      int height = (Size.Height - 2) / 2; 
 
      Rectangle rc = new Rectangle(centerPoint.X - width, centerPoint.Y - height, 2 * width, 2 * height); 
      graphics.DrawRectangle(Pens.Blue, rc); 
   } 
 
   protected override void OnPaintCrosshair(Graphics graphics, Point centerPoint) 
   { 
      int width = (Size.Width - 2) / 2; 
      int height = (Size.Height - 2) / 2; 
      Point p1 = new Point(centerPoint.X - width, centerPoint.Y - height); 
      Point p2 = new Point(centerPoint.X + width, centerPoint.Y + height); 
      graphics.DrawLine(Pens.Red, p1, p2); 
 
      p1 = new Point(centerPoint.X + width, centerPoint.Y - height); 
      p2 = new Point(centerPoint.X - width, centerPoint.Y + height); 
      graphics.DrawLine(Pens.Red, p1, p2); 
   } 
} 
 
private void viewer_MagnifyGlassChanged(object sender, EventArgs e) 
{ 
   MessageBox.Show("Custom Magnify Glass being used -- red X for crosshair, blue for border"); 
} 
 
public void RasterImageViewer_MagnifyGlass(RasterImageViewer viewer) 
{ 
   viewer.MagnifyGlassChanged += new EventHandler(viewer_MagnifyGlassChanged); 
   viewer.MagnifyGlass = new MyRasterMagnifyGlass(); 
   viewer.InteractiveMode = RasterViewerInteractiveMode.MagnifyGlass; 
 
   viewer.MagnifyGlassChanged -= new EventHandler(viewer_MagnifyGlassChanged); 
} 

Requirements

Target Platforms

See Also

Reference

RasterMagnifyGlass Class

RasterMagnifyGlass Members

Help Version 22.0.2023.2.9
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.WinForms Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.