Ejemplo n.º 1
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>(_annAutomationObjects_ItemAdded);
            _annAutomation.Container.ObjectRemoved += new EventHandler <AnnObjectCollectionEventArgs>(_annAutomationObjects_ItemRemoved);
            _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;

            _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.º 2
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.º 3
0
        void automation_SetCursor(object sender, AnnCursorEventArgs e)
        {
            Cursor newCursor = null;

            switch (e.DesignerType)
            {
            case AnnDesignerType.Draw:
            {
                AnnAutomationObject annAutomationObject = _automationManager.FindObjectById(e.Id);
                if (annAutomationObject != null && annAutomationObject.UserData != null)
                {
                    newCursor = annAutomationObject.DrawCursor as Cursor;
                }
            }
            break;

            case AnnDesignerType.Edit:
            {
                if (e.IsRotateCenter)
                {
                    newCursor = AutomationManagerHelper.AutomationCursors[CursorType.RotateCenterControlPoint];
                }
                else if (e.IsRotateGripper)
                {
                    newCursor = AutomationManagerHelper.AutomationCursors[CursorType.RotateGripperControlPoint];
                }
                else if (e.ThumbIndex < 0)
                {
                    newCursor = AutomationManagerHelper.AutomationCursors[CursorType.SelectedObject];
                }
                else
                {
                    newCursor = AutomationManagerHelper.AutomationCursors[CursorType.ControlPoint];
                }
            }
            break;

            case AnnDesignerType.Run:
            {
                newCursor = AutomationManagerHelper.AutomationCursors[CursorType.Run];
            }
            break;

            default:
                newCursor = AutomationManagerHelper.AutomationCursors[CursorType.SelectObject];
                break;
            }

            if (_imageViewer.Cursor != newCursor)
            {
                _imageViewer.Cursor = newCursor;
            }
        }
Ejemplo n.º 4
0
        private void CustomizeAutomationMenu()
        {
            AnnAutomationObject autoObj = _annAutomationManager.FindObjectById(AnnObject.LineObjectId);

            if (autoObj != null)
            {
                if (autoObj.ContextMenu != null)
                {
                    ObjectContextMenu menu = autoObj.ContextMenu as ObjectContextMenu;
                    if (menu != null)
                    {
                        menu.MenuItems.RemoveAt(13); //Unlock
                        menu.MenuItems.RemoveAt(12); //Lock
                        menu.MenuItems.RemoveAt(11); //Separator
                        menu.MenuItems.RemoveAt(10); //Reverse
                        menu.MenuItems.RemoveAt(9);  //Flip
                        menu.MenuItems.RemoveAt(8);  //Separator
                    }
                }

                autoObj = _annAutomationManager.FindObjectById(AnnObject.PolygonObjectId);
                if (autoObj != null && autoObj.ObjectTemplate != null)
                {
                    AnnPolylineObject polygon = autoObj.ObjectTemplate as AnnPolylineObject;
                    polygon.IsClosed = true;
                    polygon.FillRule = AnnFillRule.Nonzero;
                }

                autoObj = _annAutomationManager.FindObjectById(AnnObject.ClosedCurveObjectId);
                if (autoObj != null && autoObj.ObjectTemplate != null)
                {
                    AnnCurveObject closedCurve = autoObj.ObjectTemplate as AnnCurveObject;
                    closedCurve.IsClosed = true;
                    closedCurve.FillRule = AnnFillRule.Nonzero;
                }

                // Group
                autoObj = _annAutomationManager.FindObjectById(AnnObject.PolygonObjectId);
                if (autoObj != null && autoObj.ObjectTemplate != null)
                {
                    AnnPolylineObject polygon = autoObj.ObjectTemplate as AnnPolylineObject;
                    polygon.IsClosed = true;
                    polygon.FillRule = AnnFillRule.Nonzero;
                }

                autoObj = _annAutomationManager.FindObjectById(AnnObject.ClosedCurveObjectId);
                if (autoObj != null && autoObj.ObjectTemplate != null)
                {
                    AnnCurveObject closedCurve = autoObj.ObjectTemplate as AnnCurveObject;
                    closedCurve.IsClosed = true;
                    closedCurve.FillRule = AnnFillRule.Nonzero;
                }
                // Group
                autoObj = _annAutomationManager.FindObjectById(AnnObject.GroupObjectId);
                if (autoObj != null)
                {
                    ObjectContextMenu menu = new ObjectContextMenu();

                    menu = autoObj.ContextMenu as ObjectContextMenu;
                    if (menu != null)
                    {
                        menu.MenuItems.RemoveAt(16); //Ungroup
                        menu.MenuItems.RemoveAt(15); //Group
                        menu.MenuItems.RemoveAt(14); //Separator
                        menu.MenuItems.RemoveAt(13); //Unlock
                        menu.MenuItems.RemoveAt(12); //Lock
                        menu.MenuItems.RemoveAt(11); //Separator
                        menu.MenuItems.RemoveAt(10); //Reverse
                        menu.MenuItems.RemoveAt(9);  //Flip
                        menu.MenuItems.RemoveAt(8);  //Separator
                    }


                    if (menu != null)
                    {
                        // Remove the 'Control Points' item
                        menu.MenuItems.RemoveAt(8);
                        menu.MenuItems.RemoveAt(7);
                    }
                }
            }
        }