// Adds extra data and updates to automation object
 private static void UpdateAutomationObject(AnnAutomationObject automationObject)
 {
     if (automationObject.ObjectTemplate != null && automationObject.ObjectTemplate.SupportsFill && automationObject.ObjectTemplate.Fill == null)
     {
         automationObject.ObjectTemplate.Fill = AnnSolidColorBrush.Create("transparent");
     }
 }
Beispiel #2
0
        void fillPropertyInfo_ValueChanged(object oldValue, object newValue)
        {
            if (newValue != null)
            {
                if (_annObject != null)
                {
                    AnnHiliteObject annHiliteObject = _annObject as AnnHiliteObject;
                    if (annHiliteObject != null)
                    {
                        annHiliteObject.HiliteColor = (string)newValue;

                        if (OnPropertyChanged != null)
                        {
                            OnPropertyChanged("HiliteColor", newValue);
                        }
                    }
                    else
                    {
                        AnnBrush newFill = AnnSolidColorBrush.Create((string)newValue);
                        _annObject.Fill = newFill;

                        if (OnPropertyChanged != null)
                        {
                            OnPropertyChanged("Fill", newFill);
                        }
                    }
                }
            }
        }
Beispiel #3
0
 private void UpdateBrush()
 {
     if (!_annObj.SupportsFill)
     {
         if (_annObj is AnnHiliteObject)
         {
             _lblBrushColor.BackColor = Color.FromName(((AnnHiliteObject)_annObj).HiliteColor);
         }
         else
         {
             _lblBrushColor.BackColor = Color.Red;
         }
     }
     else
     {
         if (((AnnSolidColorBrush)_annObj.Fill == null))
         {
             _annObj.Fill             = AnnSolidColorBrush.Create("Transparent");
             _lblBrushColor.BackColor = Color.FromName(((AnnSolidColorBrush)_annObj.Fill).Color.ToString());
             _chkUseBrush.Checked     = false;
         }
         else
         {
             _lblBrushColor.BackColor = Color.FromName(((AnnSolidColorBrush)_annObj.Fill).Color.ToString());
         }
     }
 }
        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));
            }
        }
Beispiel #5
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);
        }
Beispiel #6
0
 void strokePropertyInfo_ValueChanged(object oldValue, object newValue)
 {
     _annStroke.Stroke = AnnSolidColorBrush.Create((string)newValue);
     if (OnValueChanged != null)
     {
         OnValueChanged(oldValue, newValue);
     }
 }
Beispiel #7
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);
        }
Beispiel #8
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);
                        }
                    }
                }
            }
        }
Beispiel #9
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;
        }
Beispiel #10
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;
        }
Beispiel #11
0
        AnnRectangleObject CreateRectangle(LeadRectD rect, AnnBrush brush, AnnLayer layer)
        {
            AnnRectangleObject annRectObject = new AnnRectangleObject();

            annRectObject.Rect          = rect;
            annRectObject.Fill          = brush;
            annRectObject.Stroke.Stroke = AnnSolidColorBrush.Create("yellow");
            _automation.Container.Children.Add(annRectObject);
            layer.Children.Add(annRectObject);

            return(annRectObject);
        }
Beispiel #12
0
        void CreateDefaultLayers()
        {
            string[] layers = new string[] { "Red", "Green", "Blue" };

            LeadRectD rect = new LeadRectD(LeadPointD.Create(860, 700), LeadPointD.Create(5200, 1850));

            foreach (string layer in layers)
            {
                CreateRectangle(rect, AnnSolidColorBrush.Create(layer), CreateLayer(string.Format("{0} Layer", layer)));
                rect.Offset(360, 360);
            }
        }
Beispiel #13
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));
        }
Beispiel #14
0
        public AnnNorbergObject()
        {
            SetId(-1008);

            this.Labels["FirstAngle"]  = new AnnLabel();
            this.Labels["SecondAngle"] = new AnnLabel();

            this.Labels["AngleText"].Background = AnnSolidColorBrush.Create("white");
            this.Labels["AngleText"].Foreground = AnnSolidColorBrush.Create("blue");

            this.Labels["FirstRulerLength"].IsVisible  = false;
            this.Labels["SecondRulerLength"].IsVisible = false;
        }
Beispiel #15
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);
        }
Beispiel #16
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);
        }
Beispiel #17
0
        private void _okButton_Click(object sender, EventArgs e)
        {
            if (IsSnaptoGridDirty)
            {
                // Set Stoke Color Value
                _snapToGridOptions.GridStroke.Stroke = AnnSolidColorBrush.Create(ColorTranslator.ToHtml(_gridColorColorPicker.Color));

                // Set Stoke Style Value
                if (_lineStyleComboBox.SelectedIndex == 0)
                {
                    _snapToGridOptions.GridStroke.StrokeDashArray = null;
                }
                else
                {
                    _snapToGridOptions.GridStroke.StrokeDashArray = new double[] { 4, 4 }
                };

                // Set Show Grid Value
                _snapToGridOptions.ShowGrid = _showGridCheckBox.Checked;

                // Set Enable Snap Value
                _snapToGridOptions.EnableSnap = _enableSnapCheckBox.Checked;

                // Set Line Spacing Value.
                int gridLength = _snapToGridOptions.GridLength;
                int.TryParse(_gridLengthTextBox.Text, out gridLength);
                if (gridLength < 5 || gridLength > 999)
                {
                    MessageBox.Show("Grid Length must be between 5 and 999.");
                    _gridLengthTextBox.Text = _snapToGridOptions.GridLength.ToString();
                    return;
                }
                _snapToGridOptions.GridLength = gridLength;

                // Set Line Spacing Value.
                int lineSpacing = _snapToGridOptions.LineSpacing;
                int.TryParse(_lineSpacingTextBox.Text, out lineSpacing);
                if (lineSpacing < 1 || lineSpacing > 100)
                {
                    MessageBox.Show("Line Spacing must be between 1 and 100.");
                    _lineSpacingTextBox.Text = _snapToGridOptions.LineSpacing.ToString();
                    return;
                }
                _snapToGridOptions.LineSpacing = lineSpacing;

                _automation.Manager.SnapToGridOptions = _snapToGridOptions.Clone() as AnnSnapToGridOptions;
            }

            this.Close();
        }
    }
        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;
        }
Beispiel #19
0
        void textBackgroundPropertyInfo_ValueChanged(object oldValue, object newValue)
        {
            AnnTextObject annTextObject = _annObject as AnnTextObject;

            if (annTextObject != null)
            {
                AnnBrush newBrush = AnnSolidColorBrush.Create((string)newValue);
                annTextObject.TextBackground = newBrush;

                if (OnPropertyChanged != null)
                {
                    OnPropertyChanged("TextBackground", newBrush);
                }
            }
        }
Beispiel #20
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();
        }
Beispiel #21
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)));
            }
        }
        // Adds extra data to the automation object like context menu, cursors and toolbar image
        private static void UpdateAutomationObject(AnnAutomationObject automationObject)
        {
            if (automationObject.DrawCursor == null)
            {
                automationObject.DrawCursor = GetAutomationObjectCursor(automationObject.Id);
            }

            // Set the automation object toolbar image
            if (automationObject.ToolBarImage == null)
            {
                automationObject.ToolBarImage = GetAutomationObjectToolBarImage(automationObject.Id);
            }

            if (automationObject.ObjectTemplate != null && automationObject.ObjectTemplate.SupportsFill && automationObject.ObjectTemplate.Fill == null)
            {
                automationObject.ObjectTemplate.Fill = AnnSolidColorBrush.Create(Color.Transparent.Name);
            }

            // Set the automation object tooltip
            automationObject.ToolBarToolTipText = automationObject.Name;
            switch (automationObject.Id)
            {
            case AnnObject.EncryptObjectId:
                automationObject.ContextMenu = new EncryptContextMenu();
                break;

            case AnnObject.RedactionObjectId:
                automationObject.ContextMenu = new RedactionContextMenu();
                break;

            case AnnObject.PolyRulerObjectId:
            case AnnObject.ProtractorObjectId:
            case AnnObject.CrossProductObjectId:
            case AnnObject.RulerObjectId:
                automationObject.ContextMenu = new CalibrateContextMenu();
                break;

            default:
                automationObject.ContextMenu = new ObjectContextMenu();
                break;
            }
        }
Beispiel #23
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);
            }
        }
Beispiel #24
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);
            }
        }
Beispiel #25
0
        private void _btnChangeFont_Click(object sender, EventArgs e)
        {
            using (FontDialog fontDialog = new FontDialog())
            {
                fontDialog.ShowColor = true;
                fontDialog.Font      = _lblBatesText.Font;
                fontDialog.Color     = _lblBatesText.ForeColor;

                if (fontDialog.ShowDialog() == DialogResult.OK)
                {
                    _lblBatesText.Font      = fontDialog.Font;
                    _lblBatesText.ForeColor = fontDialog.Color;

                    Font font = _lblBatesText.Font;
                    _currentBatesStamp.Font       = AnnWinFormsRenderingEngine.FromFont(font);
                    _currentBatesStamp.Logo.Font  = AnnWinFormsRenderingEngine.FromFont(font);
                    _currentBatesStamp.Foreground = AnnSolidColorBrush.Create(_lblBatesText.ForeColor.Name);
                }

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

            AnnWinFormsRenderingEngine engine = RenderingEngine as AnnWinFormsRenderingEngine;

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

                AnnCobbAngleObject annCobbAngleObject = annObject as AnnCobbAngleObject;
                if (annCobbAngleObject != null)
                {
                    base.LinesAsRulers = annCobbAngleObject.LinesAsRulers;

                    int count = annCobbAngleObject.Points.Count;
                    if (count < 2)
                    {
                        return;
                    }

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

                    if (annCobbAngleObject.SupportsStroke && annCobbAngleObject.Stroke != null)
                    {
                        using (Pen pen = AnnWinFormsRenderingEngine.ToPen(mapper.StrokeFromContainerCoordinates(annCobbAngleObject.Stroke, annCobbAngleObject.FixedStateOperations), annCobbAngleObject.Opacity))
                        {
                            if (points.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);

                                pen.Brush       = Brushes.Blue;
                                pen.DashPattern = new float[] { 4, 2, 2, 2, 2, 2 };
                                engine.Context.DrawLine(pen, new PointF((float)firstPoint.X, (float)firstPoint.Y), new PointF((float)intersectionPoint.X, (float)intersectionPoint.Y));
                                engine.Context.DrawLine(pen, new PointF((float)secondPoint.X, (float)secondPoint.Y), new PointF((float)intersectionPoint.X, (float)intersectionPoint.Y));

                                //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);
                                        angle = string.Format("{0} {1}", angle, "\u00B0");

                                        label.Text             = angle;
                                        label.Foreground       = AnnSolidColorBrush.Create("White");
                                        label.Background       = AnnSolidColorBrush.Create("Blue");
                                        label.OriginalPosition = cobbAngleData.IntersectionPoint;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #27
0
        public AnnObjectEditor(AnnObject annObject)
        {
            _annObject = annObject;
            if (annObject.SupportsFill && !(annObject is AnnHotspotObject))
            {
                AnnBrush        fill            = null;
                AnnHiliteObject annHiliteObject = _annObject as AnnHiliteObject;
                if (annHiliteObject != null)
                {
                    fill = AnnSolidColorBrush.Create(annHiliteObject.HiliteColor);
                }
                else
                {
                    fill = annObject.Fill;
                }

                AnnPropertyInfo fillPropertyInfo = new AnnPropertyInfo("Color", false, fill, "Fill", "Hilite Color", string.Empty, annObject.SupportsFill, typeof(AnnSolidColorBrushEditor));
                fillPropertyInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(fillPropertyInfo_ValueChanged);

                _properties["Color"] = fillPropertyInfo;
            }

            if (annObject.SupportsStroke && !(annObject is AnnHotspotObject))
            {
                AnnPropertyInfo strokePropertyInfo = new AnnPropertyInfo("Stroke", false, annObject.Stroke, "Stroke", "Stroke the object", string.Empty, annObject.SupportsStroke, typeof(AnnStrokeEditor));
                strokePropertyInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(strokePropertyInfo_ValueChanged);

                _properties["Stroke"] = strokePropertyInfo;
            }

            if (annObject.SupportsFont)
            {
                AnnPropertyInfo fontPropertyInfo = new AnnPropertyInfo(string.Empty, false, annObject.Font, "Font", "Select Font", string.Empty, annObject.SupportsFont, typeof(AnnFontEditor));
                fontPropertyInfo.ValueChanged += fontPropertyInfo_ValueChanged;
                _properties["Font"]            = fontPropertyInfo;
            }

            AnnPropertyInfo hyperlink = new AnnPropertyInfo(string.Empty, false, annObject.Hyperlink, "Hyperlink", "Hyperlink", "Hyperlink", true, typeof(AnnStringEditor));

            hyperlink.ValueChanged  += new AnnObjectEditorValueChangedHandler(hyperlink_ValueChanged);
            _properties["Hyperlink"] = hyperlink;

            if (annObject.SupportsOpacity)
            {
                AnnPropertyInfo opacity = new AnnPropertyInfo(string.Empty, false, annObject.Opacity, "Opacity", "Opacity", "Opacity", true, typeof(AnnDoubleEditor));
                opacity.ValueChanged  += opacity_ValueChanged;
                _properties["Opacity"] = opacity;
            }

            if (annObject is AnnCurveObject)
            {
                AnnCurveObject  closedCurveObject = annObject as AnnCurveObject;
                AnnPropertyInfo tensionInfo;
                if (closedCurveObject != null)
                {
                    tensionInfo = new AnnPropertyInfo(string.Empty, false, closedCurveObject.Tension, "Curve", "Tension", "Tension", true, typeof(AnnDoubleEditor));
                }
                else
                {
                    AnnCurveObject curveObject = annObject as AnnCurveObject;
                    tensionInfo = new AnnPropertyInfo(string.Empty, false, curveObject.Tension, "Curve", "Tension", "Tension", true, typeof(AnnDoubleEditor));
                }

                tensionInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(tensionInfo_ValueChanged);
                _properties["Tension"]    = tensionInfo;
            }

            if (annObject is AnnPolyRulerObject)
            {
                AnnPolyRulerObject annPolyRulerObject = annObject as AnnPolyRulerObject;

                AnnPropertyInfo showGauge = new AnnPropertyInfo(string.Empty, false, annPolyRulerObject.ShowGauge, "Ruler", "ShowGauge", "Show Gauge", true, typeof(AnnBooleanEditor));

                showGauge.Values["True"]  = true;
                showGauge.Values["False"] = false;

                showGauge.ValueChanged  += new AnnObjectEditorValueChangedHandler(showGauge_ValueChanged);
                _properties["ShowGauge"] = showGauge;

                AnnPropertyInfo gaugeLengthInfo = new AnnPropertyInfo("GaugeLength", false, annPolyRulerObject.GaugeLength, "Ruler", "GaugeLength", "Gauge Length", true, typeof(AnnLengthEditor));
                _properties["GaugeLength"] = gaugeLengthInfo;

                AnnPropertyInfo tickMarksLengthInfo = new AnnPropertyInfo("TickMarksLength", false, annPolyRulerObject.TickMarksLength, "Ruler", "TickMarksLength", "TickMarks Length", true, typeof(AnnLengthEditor));
                _properties["TickMarksLength"] = tickMarksLengthInfo;

                _polyRulerObj = annPolyRulerObject;
                gaugeLengthInfo.ValueChanged     += gaugeLengthInfo_ValueChanged;
                tickMarksLengthInfo.ValueChanged += tickMarksLengthInfo_ValueChanged;

                string          measurementUnit     = Enum.GetName(typeof(AnnUnit), (int)annPolyRulerObject.MeasurementUnit);
                AnnPropertyInfo measurementUnitInfo = new AnnPropertyInfo(string.Empty, false, measurementUnit, "Ruler", "MeasurementUnit", "Measurement Unit", true, typeof(AnnStringEditor));
                measurementUnitInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(measurementUnitInfo_ValueChanged);

                FillEnumValue(measurementUnitInfo, typeof(AnnUnit));
                _properties["MeasurementUnit"] = measurementUnitInfo;

                AnnPropertyInfo precisionInfo = new AnnPropertyInfo(string.Empty, false, annPolyRulerObject.Precision.ToString(), "Ruler", "Precision", "Precision", true, typeof(AnnStringEditor));
                precisionInfo.Values["0"] = 0;
                precisionInfo.Values["1"] = 1;
                precisionInfo.Values["2"] = 2;
                precisionInfo.Values["3"] = 3;
                precisionInfo.Values["4"] = 4;
                precisionInfo.Values["5"] = 5;
                precisionInfo.Values["6"] = 6;

                precisionInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(precisionInfo_ValueChanged);
                _properties["Precision"]    = precisionInfo;


                AnnPropertyInfo showTickMarksInfo = new AnnPropertyInfo(string.Empty, false, annPolyRulerObject.ShowTickMarks, "Ruler", "ShowTickMarks", "Show Tick Marks", true, typeof(AnnBooleanEditor));

                showTickMarksInfo.Values["True"]  = true;
                showTickMarksInfo.Values["False"] = false;

                showTickMarksInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(showTickMarksInfo_ValueChanged);
                _properties["ShowTickMarks"]    = showTickMarksInfo;
            }

            if (annObject is AnnProtractorObject)
            {
                AnnProtractorObject annProtractorObject = annObject as AnnProtractorObject;
                AnnPropertyInfo     acuteInfo           = new AnnPropertyInfo(string.Empty, false, annProtractorObject.Acute.ToString(), "Protractor", "Acute", "Acute", true, typeof(AnnStringEditor));
                acuteInfo.Values["True"]  = true;
                acuteInfo.Values["False"] = false;

                acuteInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(acuteInfo_ValueChanged);
                _properties["Acute"]    = acuteInfo;
                AnnPropertyInfo anglePrecisionInfo = new AnnPropertyInfo(string.Empty, false, annProtractorObject.AnglePrecision.ToString(), "Protractor", "Angle Precision", "Precision", true, typeof(AnnStringEditor));

                anglePrecisionInfo.Values["0"] = 0;
                anglePrecisionInfo.Values["1"] = 1;
                anglePrecisionInfo.Values["2"] = 2;
                anglePrecisionInfo.Values["3"] = 3;
                anglePrecisionInfo.Values["4"] = 4;
                anglePrecisionInfo.Values["5"] = 5;
                anglePrecisionInfo.Values["6"] = 6;

                anglePrecisionInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(anglePrecisionInfo_ValueChanged);
                _properties["AnglePrecision"]    = anglePrecisionInfo;

                string          angulartUnit    = Enum.GetName(typeof(AnnAngularUnit), (int)annProtractorObject.AngularUnit);
                AnnPropertyInfo angularUnitInfo = new AnnPropertyInfo(string.Empty, false, angulartUnit, "Protractor", "AngularUnit", "Angular Unit", true, typeof(AnnStringEditor));
                angularUnitInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(angularUnitInfo_ValueChanged);

                FillEnumValue(angularUnitInfo, typeof(AnnAngularUnit));
                _properties["AngularUnit"] = angularUnitInfo;
            }
            if (annObject is AnnRubberStampObject)
            {
                AnnRubberStampObject annRubberStampObject = annObject as AnnRubberStampObject;
                string rubberStamp = Enum.GetName(typeof(AnnRubberStampType), (int)annRubberStampObject.RubberStampType);
                if (rubberStamp.StartsWith("Stamp"))
                {
                    rubberStamp = rubberStamp.Replace("Stamp", "");
                }
                AnnPropertyInfo ruberStampTypeinfo = new AnnPropertyInfo(string.Empty, false, rubberStamp, "Rubber Stamp", "RuberStampType", "Rubber Stamp Type", true, typeof(AnnStringEditor));

                FillEnumValue(ruberStampTypeinfo, typeof(AnnRubberStampType));

                ruberStampTypeinfo.ValueChanged += new AnnObjectEditorValueChangedHandler(ruberStampTypeinfo_ValueChanged);
                _properties["RuberStampType"]    = ruberStampTypeinfo;
            }

            if (annObject is AnnTextObject)
            {
                AnnTextObject   annTextObject = annObject as AnnTextObject;
                AnnPropertyInfo textBackgroundPropertyInfo = new AnnPropertyInfo(string.Empty, false, annTextObject.TextBackground, "Text", "TextBackground", "Background", true, typeof(AnnSolidColorBrushEditor));
                _properties["TextBackground"]            = textBackgroundPropertyInfo;
                textBackgroundPropertyInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(textBackgroundPropertyInfo_ValueChanged);

                AnnPropertyInfo textForegroundPropertyInfo = new AnnPropertyInfo(string.Empty, false, annTextObject.TextForeground, "Text", "TextForeground", "Foreground", true, typeof(AnnSolidColorBrushEditor));
                textForegroundPropertyInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(textForegroundPropertyInfo_ValueChanged);
                _properties["TextForeground"]            = textForegroundPropertyInfo;

                AnnPropertyInfo text = new AnnPropertyInfo(string.Empty, false, annTextObject.Text, "Text", "Acute", "Text", true, typeof(AnnStringEditor));
                text.ValueChanged  += new AnnObjectEditorValueChangedHandler(text_ValueChanged);
                _properties["Text"] = text;

                string          vertical          = Enum.GetName(typeof(AnnVerticalAlignment), (int)annTextObject.VerticalAlignment);
                AnnPropertyInfo verticalAlignment = new AnnPropertyInfo(string.Empty, false, vertical, "Text", "VerticalAlignment", "Vertical Alignment", true, typeof(AnnStringEditor));
                verticalAlignment.ValueChanged += new AnnObjectEditorValueChangedHandler(verticalAlignment_ValueChanged);
                FillEnumValue(verticalAlignment, typeof(AnnVerticalAlignment));
                _properties["VerticalAlignment"] = verticalAlignment;


                string          horizontal          = Enum.GetName(typeof(AnnHorizontalAlignment), (int)annTextObject.HorizontalAlignment);
                AnnPropertyInfo horizontalAlignment = new AnnPropertyInfo(string.Empty, false, horizontal, "Text", "HorizontalAlignment", "Horizontal Alignment", true, typeof(AnnStringEditor));
                horizontalAlignment.ValueChanged += new AnnObjectEditorValueChangedHandler(horizontalAlignment_ValueChanged);

                FillEnumValue(horizontalAlignment, typeof(AnnHorizontalAlignment));

                _properties["HorizontalAlignment"] = horizontalAlignment;

                AnnPropertyInfo wordWrapInfo = new AnnPropertyInfo(string.Empty, false, annTextObject.WordWrap, "Text", "Word Wrap", "Word Wrap", true, typeof(AnnBooleanEditor));
                wordWrapInfo.Values["True"]  = true;
                wordWrapInfo.Values["False"] = false;

                _properties["WordWrap"] = wordWrapInfo;

                wordWrapInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(wordWrapInfo_ValueChanged);
            }

            if (annObject is AnnTextRollupObject)
            {
                AnnTextRollupObject annTextRollupObject = annObject as AnnTextRollupObject;
                AnnPropertyInfo     expandedInfo        = new AnnPropertyInfo(string.Empty, false, annTextRollupObject.Expanded, "TextRollup", "Expanded", "Expanded", true, typeof(AnnBooleanEditor));

                expandedInfo.Values["True"]  = true;
                expandedInfo.Values["False"] = false;

                expandedInfo.ValueChanged += expandedInfo_ValueChanged;
                _properties["Expanded"]    = expandedInfo;
            }

            if (annObject is AnnTextPointerObject)
            {
                AnnTextPointerObject annTextPointerObject = annObject as AnnTextPointerObject;
                AnnPropertyInfo      fixedPointerInfo     = new AnnPropertyInfo(string.Empty, false, annTextPointerObject.FixedPointer.ToString(), "Text Pointer", "FixedPointer", "Fixed", true, typeof(AnnStringEditor));
                fixedPointerInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(fixedPointerInfo_ValueChanged);

                fixedPointerInfo.Values["True"]  = true;
                fixedPointerInfo.Values["False"] = false;

                _properties["FixedPointer"] = fixedPointerInfo;
            }

            if (annObject is AnnStampObject)
            {
                AnnStampObject  annStampObject = annObject as AnnStampObject;
                AnnPropertyInfo pictureInfo    = new AnnPropertyInfo(string.Empty, false, annStampObject.Picture, "Picture", "Picture", "Picture", true, typeof(AnnPictureEditor));
                pictureInfo.ValueChanged += pictureInfo_ValueChanged;
                _properties["Picture"]    = pictureInfo;
            }

            if (annObject is AnnImageObject)
            {
                AnnImageObject  annImageObject = annObject as AnnImageObject;
                AnnPropertyInfo pictureInfo    = new AnnPropertyInfo(string.Empty, false, annImageObject.Picture, "Picture", "Picture", "Picture", true, typeof(AnnPictureEditor));
                pictureInfo.ValueChanged += annImageObject_PictureInfo_ValueChanged;
                _properties["Picture"]    = pictureInfo;
            }

            if (annObject is AnnFreehandHotspotObject)
            {
                AnnFreehandHotspotObject annFreehandHotspotObject = annObject as AnnFreehandHotspotObject;
                AnnPropertyInfo          pictureInfo = new AnnPropertyInfo(string.Empty, false, annFreehandHotspotObject.Picture, "Picture", "Picture", "Picture", true, typeof(AnnPictureEditor));
                pictureInfo.ValueChanged += freeHandPictureInfo_ValueChanged;
                _properties["Picture"]    = pictureInfo;
            }

            if (annObject is AnnPointObject)
            {
                AnnPointObject  annPointObject  = annObject as AnnPointObject;
                AnnPropertyInfo showPictureInfo = new AnnPropertyInfo(string.Empty, false, annPointObject.ShowPicture, "Point", "ShowPicture", "Show Picture", true, typeof(AnnBooleanEditor));

                showPictureInfo.Values["True"]  = true;
                showPictureInfo.Values["False"] = false;

                showPictureInfo.ValueChanged += new AnnObjectEditorValueChangedHandler(showPictureInfo_ValueChanged);
                _properties["ShowPicture"]    = showPictureInfo;
            }

            if (annObject.Id == AnnObject.MediaObjectId || annObject.Id == AnnObject.AudioObjectId)
            {
                AnnMediaObject annMediaObject = annObject as AnnMediaObject;

                AnnPropertyInfo media = new AnnPropertyInfo(string.Empty, false, annMediaObject.Media, "Media", "Media", "Source", true, typeof(AnnMediaEditor));

                media.ValueChanged  += new AnnObjectEditorValueChangedHandler(media_ValueChanged);
                _properties["Media"] = media;
            }

            if (annObject.Id == AnnObject.EncryptObjectId)
            {
                AnnEncryptObject annEncryptObject = annObject as AnnEncryptObject;
                if (annEncryptObject != null)
                {
                    AnnPropertyInfo key = new AnnPropertyInfo(string.Empty, false, annEncryptObject.Key, "Encrypt", "", "Key", true, typeof(AnnIntegerEditor));
                    key.ValueChanged  += new AnnObjectEditorValueChangedHandler(encryptKey_ValueChanged);
                    _properties["Key"] = key;

                    if (!annEncryptObject.IsEncrypted)
                    {
                        AnnPropertyInfo encryptor = new AnnPropertyInfo(string.Empty, false, annEncryptObject.Encryptor, "Encrypt", "", "Encryptor", true, typeof(AnnBooleanEditor));

                        encryptor.Values["True"]  = true;
                        encryptor.Values["False"] = false;
                        encryptor.ValueChanged   += new AnnObjectEditorValueChangedHandler(encryptor_ValueChanged);
                        _properties["Encryptor"]  = encryptor;
                    }
                }
            }
        }
        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);
                        }
                    }
                }
            }
        }
Beispiel #29
0
        private void UpdateObjectsInsideSelection(AnnSelectionObject selection, string propertyName)
        {
            propertyChangedCounter++;

            if (propertyName == "FixedStateOperations")
            {
                selection.FixedStateOperations = _targetObject.FixedStateOperations;
            }

            if (propertyName == "Name" && _tabControlObjectProperties.SelectedIndex == 0) // double check that we are in common tab , to avoid confliction between label font and text object font
            {
                foreach (AnnObject annObject in selection.SelectedObjects)
                {
                    if (annObject != _targetObject)
                    {
                        if (annObject.Labels.ContainsKey("AnnObjectName"))
                        {
                            annObject.Labels["AnnObjectName"] = _targetObject.Labels["AnnObjectName"].Clone();
                        }
                    }
                }
            }
            else if (propertyName == "UnitsAbbreviation")
            {
                AnnPolyRulerObject targetPolyRuler = _targetObject as AnnPolyRulerObject;
                if (targetPolyRuler != null)
                {
                    foreach (AnnObject annObject in selection.SelectedObjects)
                    {
                        AnnPolyRulerObject polyRuler = annObject as AnnPolyRulerObject;
                        if (polyRuler != null)
                        {
                            AnnUnit[] units = new AnnUnit[targetPolyRuler.UnitsAbbreviation.Keys.Count];
                            targetPolyRuler.UnitsAbbreviation.Keys.CopyTo(units, 0);
                            foreach (AnnUnit unit in units)
                            {
                                polyRuler.UnitsAbbreviation[unit] = targetPolyRuler.UnitsAbbreviation[unit];
                            }
                        }
                    }
                }
            }
            else
            {
                SetPolyRulerTickMarks(_targetObject);

                Type         srcType         = _targetObject.GetType();
                PropertyInfo srcPropertyInfo = srcType.GetProperty(propertyName);
                if (srcPropertyInfo != null)
                {
                    object newValue = srcPropertyInfo.GetValue(_targetObject, null);

                    foreach (AnnObject annObject in selection.SelectedObjects)
                    {
                        if (annObject != _targetObject)
                        {
                            if (annObject.Id == AnnObject.HiliteObjectId && propertyName == "Fill")
                            {
                                (annObject as AnnHiliteObject).HiliteColor = (newValue as AnnSolidColorBrush).Color;
                            }
                            if (annObject is AnnRectangleObject && propertyName == "HiliteColor")
                            {
                                (annObject as AnnRectangleObject).Fill = AnnSolidColorBrush.Create((newValue as string));
                            }

                            Type         destType         = annObject.GetType();
                            PropertyInfo destPropertyInfo = destType.GetProperty(propertyName);
                            if (destPropertyInfo != null)
                            {
                                if (propertyName == "Stroke")
                                {
                                    annObject.Stroke = (newValue as AnnStroke).Clone();
                                    SetPolyRulerTickMarks(annObject);
                                }
                                else
                                {
                                    destPropertyInfo.SetValue(annObject, newValue, null);
                                }
                            }
                        }
                    }
                }
            }

            propertyChangedCounter--;
        }
Beispiel #30
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;
        }