Exemplo n.º 1
0
 void _rasterImageViewer_InteractiveZoomTo(object sender, ImageViewerRubberBandEventArgs e)
 {
     // Go back to selection mode
     // We must invoke this because the select button will change the
     // interactive mode of the viewer and hence, cancel the current
     // operation
     BeginInvoke(new MethodInvoker(_selectModeToolStripButton.PerformClick));
 }
Exemplo n.º 2
0
        private void rubberBandMode_RubberBandCompleted(object sender, ImageViewerRubberBandEventArgs e)
        {
            // User selected a new rectangle
            _overlayRect = _imageViewer.ConvertRect(
                null,
                ImageViewerCoordinateType.Control,
                ImageViewerCoordinateType.Image,
                LeadRect.FromLTRB(e.Points[0].X, e.Points[0].Y, e.Points[1].X, e.Points[1].Y));

            // We need to change the interactive mode back to "None"
            ResetInteractiveMode();
        }
Exemplo n.º 3
0
        private void _rasterImageViewer_InteractiveRegionRectangle(object sender, ImageViewerRubberBandEventArgs e)
        {
            // Go back to selection mode
            // We must invoke this because the select button will change the
            // interactive mode of the viewer and hence, cancel the current
            // operation
            BeginInvoke(new MethodInvoker(DoSelectMode));
            BeginInvoke(new MethodInvoker(UpdateUIState));

            _disableExtraDrawing = false;
            _viewerRegionCopy    = true;
        }
Exemplo n.º 4
0
        void _rubberBand_RubberBandCompleted(object sender, ImageViewerRubberBandEventArgs e)
        {
            if (_ocrPage == null)
            {
                return;
            }

            try
            {
                _tsMainZoomComboBox.Enabled = false;

                using (WaitCursor cursor = new WaitCursor())
                {
                    if (_viewer.Image != null)
                    {
                        _currentHighlightRect = _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));

                        if (_currentHighlightRect.Width > 2 && _currentHighlightRect.Height > 2)
                        {
                            OcrZone zone = new OcrZone();
                            zone.Bounds           = _currentHighlightRect;
                            zone.ZoneType         = OcrZoneType.Text;
                            zone.CharacterFilters = OcrZoneCharacterFilters.None;

                            _ocrPage.Zones.Clear();
                            _ocrPage.Zones.Add(zone);

                            _ocrPage.Recognize(null);
                            _recognitionResults.Text = _ocrPage.GetText(0);

                            if (_recognitionResults.Text == "\n" || _recognitionResults.Text == "")
                            {
                                Messager.ShowInformation(this, "No text was recognized.");
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Messager.ShowError(this, ex);
            }
            finally
            {
                _viewer.Invalidate();
                _tsMainZoomComboBox.Enabled = true;
            }
        }
Exemplo n.º 5
0
        void RectInteractiveMode_RubberBandCompleted(object sender, ImageViewerRubberBandEventArgs e)
        {
            string actionName = null;

            if (InteractiveMode == ViewerControlInteractiveMode.ReadBarcodeMode)
            {
                actionName = "ReadBarcode";
            }
            else if (InteractiveMode == ViewerControlInteractiveMode.WriteBarcodeMode)
            {
                actionName = "WriteBarcode";
            }

            if (actionName != null)
            {
                LeadRect  MyRect = LeadRect.Create(e.InteractiveEventArgs.Origin.X, e.InteractiveEventArgs.Origin.Y, e.InteractiveEventArgs.Position.X - e.InteractiveEventArgs.Origin.X, e.InteractiveEventArgs.Position.Y - e.InteractiveEventArgs.Origin.Y);
                Rectangle pixels = new Rectangle((int)MyRect.X, (int)MyRect.Y, (int)MyRect.Width, (int)MyRect.Height);

                if (pixels.Left > pixels.Right)
                {
                    pixels = Rectangle.FromLTRB(pixels.Right, pixels.Top, pixels.Left, pixels.Bottom);
                }
                if (pixels.Top > pixels.Bottom)
                {
                    pixels = Rectangle.FromLTRB(pixels.Left, pixels.Bottom, pixels.Right, pixels.Top);
                }

                if (pixels.Width > 2 && pixels.Height > 2)
                {
                    RectangleF pixelsF = pixels;

                    using (Matrix m = GetMatrixFromLeadMatrix(_rasterImageViewer.GetImageTransformWithDpi(true)))
                    {
                        Transformer trans = new Transformer(m);
                        pixelsF = trans.RectangleToLogical(pixelsF);
                    }

                    pixelsF = RectangleF.Intersect(new RectangleF(0, 0, _rasterImageViewer.Image.ImageWidth, _rasterImageViewer.Image.ImageHeight), pixelsF);
                    pixels  = Rectangle.Round(pixelsF);

                    LeadRect bounds = new LeadRect(pixels.X, pixels.Y, pixels.Width, pixels.Height);
                    BeginInvoke(new DoActionDelegate(DoAction), new object[] { actionName, bounds });
                }
            }
        }
Exemplo n.º 6
0
 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));
     try
     {
         if (_viewer.Image != null)
         {
             AddZones(true);
             _viewer.Invalidate();
             UpdateMyControls();
         }
     }
     catch (Exception ex)
     {
         Messager.ShowError(this, ex);
     }
 }
Exemplo n.º 7
0
        void RectangleInteractiveMode_RubberBandCompleted(object sender, ImageViewerRubberBandEventArgs e)
        {
            Rectangle pixels = new Rectangle(e.InteractiveEventArgs.Origin.X, e.InteractiveEventArgs.Origin.Y, e.InteractiveEventArgs.Position.X - e.InteractiveEventArgs.Origin.X, e.InteractiveEventArgs.Position.Y - e.InteractiveEventArgs.Origin.Y);

            if (pixels.Left > pixels.Right)
            {
                pixels = Rectangle.FromLTRB(pixels.Right, pixels.Top, pixels.Left, pixels.Bottom);
            }
            if (pixels.Top > pixels.Bottom)
            {
                pixels = Rectangle.FromLTRB(pixels.Left, pixels.Bottom, pixels.Right, pixels.Top);
            }

            if (pixels.Width > 2 && pixels.Height > 2)
            {
                RectangleF pixelsF = pixels;


                LeadMatrix  mm    = _rasterImageViewer.GetImageTransformWithDpi(true);
                Matrix      m     = new Matrix((float)mm.M11, (float)mm.M12, (float)mm.M21, (float)mm.M22, (float)mm.OffsetX, (float)mm.OffsetY);
                Transformer trans = new Transformer(m);
                pixelsF = trans.RectangleToLogical(pixelsF);


                pixelsF = RectangleF.Intersect(new RectangleF(0, 0, _rasterImageViewer.Image.ImageWidth, _rasterImageViewer.Image.ImageHeight), pixelsF);
                pixels  = Rectangle.Round(pixelsF);

                LeadRect bounds = new LeadRect(pixels.X, pixels.Y, pixels.Width, pixels.Height);
                BeginInvoke(new DoActionDelegate(DoAction), new object[] { "HighlightText", bounds });
            }

            // Go back to selection mode
            // We must invoke this because the select button will change the
            // interactive mode of the viewer and hence, cancel the current
            // operation
            BeginInvoke(new MethodInvoker(DoSelectMode));
        }
Exemplo n.º 8
0
 void RegionInteractiveMode_RubberBandStarted(object sender, ImageViewerRubberBandEventArgs e)
 {
     _disableExtraDrawing = true;
     _rasterImageViewer.Invalidate();
     _rasterImageViewer.Update();
 }
        void _rubberBand_RubberBandCompleted(object sender, ImageViewerRubberBandEventArgs e)
        {
            if (_ocrPage == null)
            return;

             try
             {
            _tsMainZoomComboBox.Enabled = false;

            using (WaitCursor cursor = new WaitCursor())
            {
               if (_viewer.Image != null)
               {
                  _currentHighlightRect = _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));

                  if (_currentHighlightRect.Width > 2 && _currentHighlightRect.Height > 2)
                  {
                     OcrZone zone = new Leadtools.Forms.Ocr.OcrZone();
                     zone.Bounds = LogicalRectangle.FromRectangle(_currentHighlightRect);
                     zone.ZoneType = OcrZoneType.Text;
                     zone.CharacterFilters = OcrZoneCharacterFilters.None;

                     _ocrPage.Zones.Clear();
                     _ocrPage.Zones.Add(zone);

                     _ocrPage.Recognize(null);
                     _recognitionResults.Text = _ocrPage.GetText(0);

                     if (_recognitionResults.Text == "\n" || _recognitionResults.Text == "")
                        Messager.ShowInformation(this, "No text was recognized.");
                  }
               }
            }
             }
             catch (Exception ex)
             {
            Messager.ShowError(this, ex);
             }
             finally
             {
            _viewer.Invalidate();
            _tsMainZoomComboBox.Enabled = true;
             }
        }