Click here to Skip to main content
15,890,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My Requirement is finding the selected text on image . While i am drawing rectangle on top of the image using the mouse ,Then my event "viewer_InteractiveRegionRectangle" is not firing or not working.
Getting data also into InteractiveRegionRectangle.

What I have tried:

ViewerUserControl.cs
public partial class ViewerUserControl : UserControl
{
public event EventHandler<rasterviewerrectangleeventargs>InteractiveRegionRectangle = null;
public ImageViewer _imageViewer;
}

WBaseRealEstate.cs:
protected ViewerUserControl imageViewerControl1;
protected virtual void WBaseRealEstate_Load(object sender, EventArgs e)
{
ImageViewerRubberBandInteractiveMode rubberBandMode = new
ImageViewerRubberBandInteractiveMode();

this.imageViewerControl1._imageViewer.InteractiveModes.Add(rubberBandMode);
this.imageViewerControl1.InteractiveRegionRectangle += new EventHandler<leadtools.winforms.rasterviewerrectangleeventargs>(viewer_InteractiveRegionRectangle);

}


protected virtual void viewer_InteractiveRegionRectangle(object sender, Leadtools.WinForms.RasterViewerRectangleEventArgs e)
{
RubberbandDelegate del = new RubberbandDelegate(this.RubberBand);
this.BeginInvoke(del, new object[] { e });
}
Posted

1 solution

The Rubberband interactive mode of our ImageViewer control is implemented in several demos that ship with the toolkit, including the OcrModulesDemo project.

The event you need to handle is ImageViewerRubberBandInteractiveMode.RubberBandCompleted.

The code to initialize the mode is this:
C#
_viewer.InteractiveModes.BeginUpdate();
_rubberBandMode = new ImageViewerRubberBandInteractiveMode();
_rubberBandMode.IdleCursor = Cursors.Cross;
_rubberBandMode.WorkingCursor = Cursors.Cross;
_rubberBandMode.RubberBandCompleted += new EventHandler(_rubberBandMode_RubberBandCompleted);
_viewer.InteractiveModes.Add(_rubberBandMode);
_viewer.InteractiveModes.EndUpdate();

The event handler looks like this:
C#
private void _rubberBandMode_RubberBandCompleted(object sender, ImageViewerRubberBandEventArgs e)
{
   _frameRect = _viewer.ConvertRect(null,
      ImageViewerCoordinateType.Control,
      ImageViewerCoordinateType.Image,
      LeadRect.FromLTRB(e.Points[0].X, e.Points[0].Y, e.Points[1].X, e.Points[1].Y));
// ...use the rectangle
}

Please check how the demos implement this event to obtain the selected area. If you still face problems, contact our support through email or chat (both are free) and include full details about the problem, your LEADTOOLS version and what you tried so far.

The contact details are on this page.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900