Ejemplo n.º 1
0
        public void SetZone(Page ocrPage, int zoneIndex, bool isVisible, bool isNameVisible)
        {
            _ocrPage   = ocrPage;
            _zoneIndex = zoneIndex;

            IsVisible         = isVisible;
            mylabel.IsVisible = isNameVisible;

            if (_ocrPage != null && _zoneIndex >= 0 && _zoneIndex < _ocrPage.Fields.Count)
            {
                Field zone = _ocrPage.Fields[_zoneIndex];
                if (string.IsNullOrEmpty(zone.Name))
                {
                    mylabel.Text = "Zone " + (_zoneIndex + 1).ToString();
                }
                else
                {
                    mylabel.Text = zone.Name;
                }


                //if (zone.ZoneType == OcrZoneType.None || zone.ZoneType == OcrZoneType.Graphic || zone.ZoneType == OcrZoneType.Barcode)
                //{
                //   RasterColor color = RasterColorConverter.FromColor(Color.FromArgb(32, Color.Yellow));
                //   this.Fill = AnnSolidColorBrush.Create(color.ToString());//Color.FromArgb(32, Color.Yellow)
                //   this.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), new LeadLengthD(1));
                //}
                //else
                this.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Red"), new LeadLengthD(1));
            }
        }
Ejemplo n.º 2
0
        AnnAutomationObject CreateZoneAutomationObject()
        {
            AnnAutomationObject  automationObj        = new AnnAutomationObject();
            ZoneAnnotationObject zoneAnnotationObject = new ZoneAnnotationObject();

            AnnAutomationObject rectAutomationObject = GetAutomationObject(_annAutomationManager, AnnObject.RectangleObjectId);
            AnnRectangleObject  rectObject           = rectAutomationObject.ObjectTemplate as AnnRectangleObject;

            zoneAnnotationObject.Stroke = rectObject.Stroke != null?rectObject.Stroke.Clone() as AnnStroke : null;

            zoneAnnotationObject.Fill = rectObject.Fill != null?rectObject.Fill.Clone() as AnnBrush : null;

            zoneAnnotationObject.CellPen = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), new LeadLengthD(1));

            automationObj.Id               = AnnObject.UserObjectId;
            automationObj.Name             = zoneAnnotationObject.FriendlyName;
            automationObj.ObjectTemplate   = zoneAnnotationObject;
            automationObj.DrawDesignerType = rectAutomationObject.DrawDesignerType;
            automationObj.EditDesignerType = typeof(ZoneAnnotationObjectEditDesigner);
            automationObj.RunDesignerType  = rectAutomationObject.RunDesignerType;
            automationObj.DrawCursor       = rectAutomationObject.DrawCursor;

            // Disable the rotation points
            automationObj.UseRotateThumbs = false;
            return(automationObj);
        }
Ejemplo n.º 3
0
        private void AddAnnotationRectangle(MedicalViewerSubCell subCell)
        {
            AnnRectangleObject rect = new AnnRectangleObject();

            rect.IsVisible = false;
            rect.Stroke    = AnnStroke.Create(AnnSolidColorBrush.Create("Red"), LeadLengthD.Create(5));
            subCell.AnnotationContainer.Children.Add(rect);
        }
Ejemplo n.º 4
0
        public override void Render(AnnContainerMapper mapper, AnnObject annObject)
        {
            if (mapper == null)
            {
                ExceptionHelper.ArgumentNullException("mapper");
            }
            if (annObject == null)
            {
                ExceptionHelper.ArgumentNullException("annObject");
            }

            IAnnDrawEngine engine = RenderingEngine as IAnnDrawEngine;

            if (engine != null)
            {
                base.Render(mapper, annObject);

                AnnIntersectionPointObject annIntersectionPointObject = annObject as AnnIntersectionPointObject;
                if (annIntersectionPointObject != null)
                {
                    int count = annIntersectionPointObject.Points.Count;
                    if (count < 2)
                    {
                        return;
                    }

                    LeadPointD[] leadPoints = mapper.PointsFromContainerCoordinates(annIntersectionPointObject.Points.ToArray(), annIntersectionPointObject.FixedStateOperations);

                    if (annIntersectionPointObject.SupportsStroke && annIntersectionPointObject.Stroke != null)
                    {
                        AnnStroke stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), annIntersectionPointObject.Stroke.StrokeThickness);
                        stroke.StrokeDashArray = new double[] { 3, 1, 1, 1, 1, 1 }; // DashDotDot

                        IAnnDrawPen pen = engine.ToPen(mapper.StrokeFromContainerCoordinates(stroke, annIntersectionPointObject.FixedStateOperations), annIntersectionPointObject.Opacity);
                        try
                        {
                            if (leadPoints.Length > 2)
                            {
                                LeadPointD intersectionPoint = annIntersectionPointObject.IntersectionPoint;
                                intersectionPoint = mapper.PointFromContainerCoordinates(intersectionPoint, annIntersectionPointObject.FixedStateOperations);

                                double radius = mapper.LengthFromContainerCoordinates(annIntersectionPointObject.IntersectionPointRadius, annIntersectionPointObject.FixedStateOperations);
                                DrawPoint(annIntersectionPointObject, engine, intersectionPoint, radius);

                                if (leadPoints.Length < 5 && annIntersectionPointObject.IntersectionInsideContainer)
                                {
                                    engine.DrawLine(pen, leadPoints[3], intersectionPoint);
                                }
                            }
                        }
                        finally
                        {
                            engine.Destroy(pen);
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
        private void InitAutomationManager()
        {
            _annManager = new AnnAutomationManager();

            _annManager.CreateDefaultObjects();
            List <AnnAutomationObject> objectsToRemove = new List <AnnAutomationObject>();

            foreach (AnnAutomationObject obj in _annManager.Objects)
            {
                if (Enum.GetName(typeof(AnnObjects), obj.Id) == null)
                {
                    objectsToRemove.Add(obj);
                }
            }

            foreach (AnnAutomationObject obj in objectsToRemove)
            {
                _annManager.Objects.Remove(obj);
            }
            _automationHelper = new AutomationManagerHelper(_annManager);
            _automationHelper.CreateToolBar();
            if (_annManager.RenderingEngine != null)
            {
                _annManager.RenderingEngine.LoadPicture += RenderingEngine_LoadPicture;
            }

            _automationHelper.ToolBar.Dock       = DockStyle.Right;
            _automationHelper.ToolBar.Appearance = ToolBarAppearance.Flat;
            _automationHelper.ToolBar.AutoSize   = false;
            _automationHelper.ToolBar.Visible    = true;
            _automationHelper.ToolBar.BringToFront();

            this.Controls.Add(_automationHelper.ToolBar);

            foreach (AnnAutomationObject obj in _annManager.Objects)
            {
                obj.UseRotateThumbs = true;
                if (obj.ObjectTemplate != null && obj.ObjectTemplate.SupportsStroke)
                {
                    //obj.Object.Pen = new AnnPen(Color.White, new AnnLength(1));
                }
            }

            _automation = new AnnAutomation(_annManager, _viewer);

            _automation.EditText += new EventHandler <AnnEditTextEventArgs>(automation_EditText);

            //Change AnnText to use Pen
            LeadLengthD         annLength  = new LeadLengthD(1);
            AnnAutomationObject annAutText = _automation.Manager.FindObjectById((int)AnnObjects.TextObjectId);

            annAutText.ObjectTemplate.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Red"), annLength);
            _automation.Active = true;
        }
Ejemplo n.º 6
0
        private void AddFusionEditRectangle(MedicalViewerSubCell subCell)
        {
            AnnRectangleObject rect = new AnnRectangleObject();

            rect.IsVisible = false;
            rect.Stroke    = AnnStroke.Create(AnnSolidColorBrush.Create("Red"), LeadLengthD.Create(5));
            subCell.AnnotationContainer.Children.Add(rect);
            //rect.RotateGripper = new LeadLengthD(1);

            _cell.AnnotationPrecedency = true;
        }
Ejemplo n.º 7
0
 private int GetLineStyleFromStrok(AnnStroke annStroke)
 {
     if (annStroke.StrokeDashArray == null)
     {
         return(0);
     }
     else
     {
         return(1);
     }
 }
Ejemplo n.º 8
0
        void scEngine_CaptureInformation(object sender, ScreenCaptureInformationEventArgs e)
        {
            e.Image.XResolution = e.Image.YResolution = 300;
            AnnAutomationObject customAnn   = annAutomationManager.FindObjectById(AnnObject.StampObjectId);
            AnnStampObject      customStamp = (AnnStampObject)customAnn.ObjectTemplate;

            customStamp.Text = " ";

            customStamp.Fill    = null;
            customStamp.Stroke  = AnnStroke.Create(AnnSolidColorBrush.Create("Red"), LeadLengthD.Create(0));;
            customStamp.Picture = new AnnPicture(RasterImageConverter.ConvertToImage(e.Image, ConvertToImageOptions.None));
        }
Ejemplo n.º 9
0
        private AnnThumbStyle CreateRotateGripperThumbStyle()
        {
            AnnThumbStyle rotateGripperThumbStyle = new AnnEllipseThumbStyle();

            double thumbSize = ThumbSize;

            rotateGripperThumbStyle.Size   = LeadSizeD.Create(thumbSize, thumbSize);
            rotateGripperThumbStyle.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("black"), LeadLengthD.Create(1));

            rotateGripperThumbStyle.Fill = AnnSolidColorBrush.Create("lightgreen");

            return(rotateGripperThumbStyle);
        }
Ejemplo n.º 10
0
        private AnnThumbStyle CreateLocationThumbStyle()
        {
            AnnThumbStyle locationThumbStyle = new AnnRectangleThumbStyle();

            double thumbSize = ThumbSize;

            locationThumbStyle.Size   = LeadSizeD.Create(thumbSize, thumbSize);
            locationThumbStyle.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("black"), LeadLengthD.Create(1));

            locationThumbStyle.Fill = AnnSolidColorBrush.Create("lightblue");

            return(locationThumbStyle);
        }
Ejemplo n.º 11
0
        public AnnStrokeEditor(AnnStroke annStroke, string category)
        {
            _category = category;
            AnnPropertyInfo strokePropertyInfo = new AnnPropertyInfo("Stroke", false, annStroke.Stroke, category, "Stroke", string.Empty, true, typeof(AnnSolidColorBrushEditor));

            strokePropertyInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(strokePropertyInfo_ValueChanged);
            _properties["Stroke"]            = strokePropertyInfo;
            AnnPropertyInfo thicknessPropertyInfo = new AnnPropertyInfo("Thickness", false, annStroke.StrokeThickness, category, "Thickness", string.Empty, true, typeof(AnnLengthEditor));

            _annStroke = annStroke;
            thicknessPropertyInfo.ValueChanged += thicknessPropertyInfo_ValueChanged;
            _properties["Thickness"]            = thicknessPropertyInfo;
        }
Ejemplo n.º 12
0
        public ZoneAnnotationObject() :
            base()
        {
            _ocrPage   = null;
            _zoneIndex = 0;
            _cellPen   = null;
            SetId(AnnObject.UserObjectId);

            mylabel                 = this.Labels["AnnObjectName"];
            mylabel.Background      = AnnSolidColorBrush.Create("Black");
            mylabel.Foreground      = AnnSolidColorBrush.Create("White");
            mylabel.RestrictionMode = AnnLabelRestriction.None;
            mylabel.IsVisible       = true;
        }
Ejemplo n.º 13
0
        private void _btnApply_Click(object sender, EventArgs e)
        {
            if (_chkUsePen.Checked)
            {
                GetColor(_lblPenColor.BackColor);
                _annObj.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create(GetColor(_lblPenColor.BackColor)), LeadLengthD.Create((double)_penWidth.Value));//, AnnUnit.Pixel));
                if (_annObj is AnnPolyRulerObject)
                {
                    AnnPolyRulerObject polyRulerObject = (AnnPolyRulerObject)_annObj;

                    polyRulerObject.TickMarksStroke = _annObj.Stroke;
                }
            }
            else
            {
                _annObj.Stroke = null;
            }

            if (_chkUseBrush.Checked)
            {
                if (_annObj is AnnHiliteObject)
                {
                    ((AnnHiliteObject)_annObj).HiliteColor = GetColor(_lblBrushColor.BackColor);
                }
                else
                {
                    _annObj.Fill = AnnSolidColorBrush.Create(GetColor(_lblBrushColor.BackColor));
                }
            }
            else
            {
                _annObj.Fill = null;
            }

            if (_annFont != null)
            {
                if (!_annFont.Equals(_annObj.Font))
                {
                    _annObj.Font = _annFont;
                }

                AnnTextObject textObject = (AnnTextObject)_annObj;

                textObject.TextForeground = AnnSolidColorBrush.Create(GetColor(_fontColor));
            }

            _cell.RefreshAnnotation();
        }
Ejemplo n.º 14
0
        private void DrawPoint(AnnMidlineObject annObject, Graphics context, PointF point, double radius)
        {
            LeadRectD  pointBounds = new LeadRectD(point.X - radius, point.Y - radius, radius * 2, radius * 2);
            LeadPointD topLeft     = pointBounds.TopLeft;
            LeadPointD topRight    = pointBounds.TopRight;
            LeadPointD bottomLeft  = pointBounds.BottomLeft;
            LeadPointD bottomRight = pointBounds.BottomRight;

            using (Pen pen = AnnWinFormsRenderingEngine.ToPen(AnnStroke.Create(AnnSolidColorBrush.Create("blue"), annObject.Stroke.StrokeThickness), annObject.Opacity))
            {
                context.DrawLine(pen, new PointF((float)topLeft.X, (float)topLeft.Y), new PointF((float)bottomRight.X, (float)bottomRight.Y));
                context.DrawLine(pen, new PointF((float)bottomLeft.X, (float)bottomLeft.Y), new PointF((float)topRight.X, (float)topRight.Y));
                context.DrawLine(pen, new PointF((float)point.X, (float)(point.Y - pointBounds.Width / 2)), new PointF((float)point.X, (float)(point.Y + pointBounds.Width / 2)));
                context.DrawLine(pen, new PointF((float)point.X - (float)pointBounds.Width / 2, (float)(point.Y)), new PointF((float)point.X + (float)pointBounds.Width / 2, (float)(point.Y)));
            }
        }
Ejemplo n.º 15
0
        public StrokeStyleProxy(AnnStroke stroke)
        {
            if (stroke == null)
            {
                throw new ArgumentNullException("stroke");
            }

            _stroke = stroke;

            if (_stroke.StrokeDashArray != null && _stroke.StrokeDashArray.Length > 0)
            {
                StringBuilder builder = new StringBuilder();
                foreach (double item in _stroke.StrokeDashArray)
                {
                    builder.Append(item);
                    builder.Append(",");
                }

                string strokeDashArray = builder.ToString();
                strokeDashArray = strokeDashArray.TrimEnd(',');

                if (strokeDashArray == "3,1")
                {
                    _style = StrokeStyle.Dash;
                }
                else if (strokeDashArray == "1,1")
                {
                    _style = StrokeStyle.Dot;
                }
                else if (strokeDashArray == "3,1,1,1")
                {
                    _style = StrokeStyle.DashDot;
                }
                else if (strokeDashArray == "3,1,1,1,1,1")
                {
                    _style = StrokeStyle.DashDotDot;
                }
                else
                {
                    _style = StrokeStyle.Dot;
                }
            }
        }
Ejemplo n.º 16
0
        private void DrawPoint(AnnMidlineObject annObject, IAnnDrawEngine engine, LeadPointD point, double radius)
        {
            LeadRectD  pointBounds = new LeadRectD(point.X - radius, point.Y - radius, radius * 2, radius * 2);
            LeadPointD topLeft     = pointBounds.TopLeft;
            LeadPointD topRight    = pointBounds.TopRight;
            LeadPointD bottomLeft  = pointBounds.BottomLeft;
            LeadPointD bottomRight = pointBounds.BottomRight;

            IAnnDrawPen pen = engine.ToPen(AnnStroke.Create(AnnSolidColorBrush.Create("blue"), annObject.Stroke.StrokeThickness), annObject.Opacity);

            try
            {
                engine.DrawLine(pen, topLeft, bottomRight);
                engine.DrawLine(pen, bottomLeft, topRight);
                engine.DrawLine(pen, new LeadPointD(point.X, (point.Y - pointBounds.Width / 2)), new LeadPointD(point.X, (point.Y + pointBounds.Width / 2)));
                engine.DrawLine(pen, new LeadPointD(point.X - pointBounds.Width / 2, point.Y), new LeadPointD(point.X + pointBounds.Width / 2, point.Y));
            }
            finally
            {
                engine.Destroy(pen);
            }
        }
Ejemplo n.º 17
0
        void strokePropertyInfo_ValueChanged(object oldValue, object newValue)
        {
            string    color     = newValue as string;
            AnnStroke newStroke = null;

            newStroke = _annObject.Stroke.Clone();
            if (color == null)
            {
                newStroke.StrokeThickness = LeadLengthD.Create(double.Parse(newValue.ToString()));
            }
            else
            {
                newStroke.Stroke = AnnSolidColorBrush.Create(color);
            }

            _annObject.Stroke = newStroke.Clone();

            if (OnPropertyChanged != null)
            {
                OnPropertyChanged("Stroke", newStroke);
            }
        }
        public override void Render(AnnContainerMapper mapper, AnnObject annObject)
        {
            if (mapper == null)
            {
                ExceptionHelper.ArgumentNullException("mapper");
            }
            if (annObject == null)
            {
                ExceptionHelper.ArgumentNullException("annObject");
            }

            IAnnDrawEngine engine = RenderingEngine as IAnnDrawEngine;

            if (engine != null)
            {
                base.Render(mapper, annObject);

                AnnCobbAngleObject annCobbAngleObject = annObject as AnnCobbAngleObject;
                if (annCobbAngleObject != null)
                {
                    int count = annCobbAngleObject.Points.Count;
                    if (count < 2)
                    {
                        return;
                    }

                    LeadPointD[] leadPoints = mapper.PointsFromContainerCoordinates(annCobbAngleObject.Points.ToArray(), annCobbAngleObject.FixedStateOperations);

                    if (annCobbAngleObject.SupportsStroke && annCobbAngleObject.Stroke != null)
                    {
                        AnnStroke stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), annCobbAngleObject.Stroke.StrokeThickness);
                        stroke.StrokeDashArray = new double[] { 4, 2, 2, 2, 2, 2 };
                        IAnnDrawPen pen = engine.ToPen(mapper.StrokeFromContainerCoordinates(annCobbAngleObject.Stroke, annCobbAngleObject.FixedStateOperations), annCobbAngleObject.Opacity);
                        try
                        {
                            if (leadPoints.Length > 3)
                            {
                                AnnCobbAngleData cobbAngleData     = annCobbAngleObject.CobbAngleData;
                                LeadPointD       firstPoint        = mapper.PointFromContainerCoordinates(cobbAngleData.FirstPoint, annCobbAngleObject.FixedStateOperations);
                                LeadPointD       secondPoint       = mapper.PointFromContainerCoordinates(cobbAngleData.SecondPoint, annCobbAngleObject.FixedStateOperations);
                                LeadPointD       intersectionPoint = mapper.PointFromContainerCoordinates(cobbAngleData.IntersectionPoint, annCobbAngleObject.FixedStateOperations);

                                engine.DrawLine(pen, firstPoint, intersectionPoint);
                                engine.DrawLine(pen, secondPoint, intersectionPoint);

                                //Draw angle label
                                if (annCobbAngleObject.Labels.ContainsKey("CobbAngle"))
                                {
                                    AnnLabel label = annCobbAngleObject.Labels["CobbAngle"];
                                    if (label != null)
                                    {
                                        string precisionFormat = string.Format("XXX:F{0}", annCobbAngleObject.AnglePrecision);
                                        precisionFormat = precisionFormat.Replace("XXX", "{0");
                                        precisionFormat = string.Format("{0}{1}", precisionFormat, "}");

                                        string angle = string.Format(precisionFormat, cobbAngleData.Angle);

                                        label.Text             = angle;
                                        label.Foreground       = AnnSolidColorBrush.Create("Blue");
                                        label.OriginalPosition = cobbAngleData.IntersectionPoint;
                                    }
                                }
                            }
                        }
                        finally
                        {
                            engine.Destroy(pen);
                        }
                    }
                }
            }
        }
Ejemplo n.º 19
0
        private void InitAnnotations()
        {
            _annAutomationManager = new AnnAutomationManager();

            // Disable the rotation
            _annAutomationManager.RotateModifierKey   = AnnKeys.None;
            _annAutomationManager.EditObjectAfterDraw = false;

            _annAutomationManager.CreateDefaultObjects();

            _annAutomation = new AnnAutomation(_annAutomationManager, _rasterImageViewer);
            _annAutomation.AfterObjectChanged      += new EventHandler <AnnAfterObjectChangedEventArgs>(_annAutomation_AfterObjectChanged);
            _annAutomation.Container.ObjectAdded   += new EventHandler <AnnObjectCollectionEventArgs>(Container_ObjectAdded);
            _annAutomation.Container.ObjectRemoved += new EventHandler <AnnObjectCollectionEventArgs>(Container_ObjectRemoved);
            _annAutomation.OnShowContextMenu       += new EventHandler <AnnAutomationEventArgs>(_annAutomation_OnShowContextMenu);
            _annAutomation.Draw          += new EventHandler <AnnDrawDesignerEventArgs>(_annAutomation_Draw);
            _annAutomation.SetCursor     += new EventHandler <AnnCursorEventArgs>(_annAutomation_SetCursor);
            _annAutomation.RestoreCursor += new EventHandler(_annAutomation_RestoreCursor);
            // We are not going to do undo/redeo
            _annAutomation.UndoCapacity = 0;
            // Set this as the one and only active automation object so mouse and keyboard events
            // get to it
            _annAutomation.Active = true;
            _annAutomation.DefaultCurrentObjectId = AnnObject.None;


            // Get the rectangle and select objects
            AnnAutomationObject selectAutomationObject = GetAutomationObject(_annAutomationManager, AnnObject.SelectObjectId);

            AnnAutomationObject zoneAutomationObject = CreateZoneAutomationObject();

            _automationManagerHelper = new AutomationManagerHelper(_annAutomationManager);

            ZoneAnnotationObjectRenderer zoneObjectRenderer         = new ZoneAnnotationObjectRenderer();
            IAnnObjectRenderer           annRectangleObjectRenderer = _annAutomationManager.RenderingEngine.Renderers[AnnObject.RectangleObjectId];

            zoneObjectRenderer.LocationsThumbStyle     = annRectangleObjectRenderer.LocationsThumbStyle;
            zoneObjectRenderer.RotateCenterThumbStyle  = annRectangleObjectRenderer.RotateCenterThumbStyle;
            zoneObjectRenderer.RotateGripperThumbStyle = annRectangleObjectRenderer.RotateGripperThumbStyle;
            zoneObjectRenderer.CellPen = AnnStroke.Create(AnnSolidColorBrush.Create("Blue"), new LeadLengthD(1));

            _annAutomationManager.Objects.Clear();

            ContextMenu cm = new ContextMenu();

            cm.MenuItems.Add(new MenuItem("&Delete", _zoneDeleteMenuItem_Click));
            cm.MenuItems.Add(new MenuItem("-", null as EventHandler));
            cm.MenuItems.Add(new MenuItem("&Properties...", _zonePropertiesMenuItem_Click));

            zoneAutomationObject.ContextMenu = cm;

            _annAutomationManager.RenderingEngine.Renderers[AnnObject.UserObjectId] = zoneObjectRenderer;

            _annAutomationManager.Objects.Add(selectAutomationObject);
            _annAutomationManager.Objects.Add(zoneAutomationObject);

            // Disable Annotation selection object since we don't want users to group annotation objects.
            var selectionObject = _annAutomationManager.FindObjectById(AnnObject.SelectObjectId);

            selectionObject.DrawDesignerType = null;
        }
Ejemplo n.º 20
0
 public StrokeDescriptor(AnnStroke stroke, string category)
 {
     _stroke   = stroke;
     _category = category;
 }