Beispiel #1
0
        private AnnAutomationObject CreateIntersectionPoint()
        {
            AnnAutomationObject automationObj = new AnnAutomationObject();

            AnnIntersectionPointObject annIntersectionPointObject = new AnnIntersectionPointObject();

            automationObj.Id               = annIntersectionPointObject.Id;
            automationObj.Name             = "Intersection Point";
            automationObj.DrawDesignerType = typeof(AnnTwoLinesDrawer);
            automationObj.EditDesignerType = typeof(AnnTwoLinesEditer);
            automationObj.RunDesignerType  = typeof(AnnRunDesigner);
            automationObj.ObjectTemplate   = annIntersectionPointObject;

            IAnnObjectRenderer renderer = new AnnIntersectionObjectRenderer();

            renderer.LocationsThumbStyle     = CreateLocationThumbStyle();
            renderer.RotateCenterThumbStyle  = CreateRotateCenterThumbStyle();
            renderer.RotateGripperThumbStyle = CreateRotateGripperThumbStyle();

            automationObj.Renderer = renderer;

            CreateToolBarItem(automationObj, "IntersectionPoint");

            return(automationObj);
        }
Beispiel #2
0
        private static void CreateToolBarItem(AnnAutomationObject annAutomationObject, string resourceName)
        {
            string toolbarImageResourceName = string.Format("Resources.ToolBar.{0}.png", resourceName);

            annAutomationObject.ToolBarImage       = new Bitmap(typeof(AnnMedicalPack), toolbarImageResourceName);
            annAutomationObject.ToolBarToolTipText = annAutomationObject.Name;
        }
Beispiel #3
0
        private AnnAutomationObject CreateNorberg()
        {
            AnnAutomationObject automationObj = new AnnAutomationObject();

            AnnNorbergObject annCobbAngleObject = new AnnNorbergObject();

            automationObj.Id               = annCobbAngleObject.Id;
            automationObj.Name             = "Norberg";
            automationObj.DrawDesignerType = typeof(AnnNorbergDrawer);
            automationObj.EditDesignerType = typeof(AnnPolylineEditDesigner);
            automationObj.RunDesignerType  = typeof(AnnRunDesigner);
            automationObj.ObjectTemplate   = annCobbAngleObject;

            IAnnObjectRenderer renderer = new AnnNorbergObjectRenderer();

            renderer.LocationsThumbStyle     = CreateLocationThumbStyle();
            renderer.RotateCenterThumbStyle  = CreateRotateCenterThumbStyle();
            renderer.RotateGripperThumbStyle = CreateRotateGripperThumbStyle();

            automationObj.Renderer = renderer;

            CreateToolBarItem(automationObj, "Norberg");

            return(automationObj);
        }
Beispiel #4
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 #5
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;
        }
 // 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 #7
0
        void automation_ToolTip(object sender, AnnToolTipEventArgs e)
        {
            if (e.AnnotationObject != null)
            {
                AnnTextObject text        = e.AnnotationObject as AnnTextObject;
                string        toolTipText = string.Empty;

                if (text != null)
                {
                    toolTipText = text.Text;
                }
                else
                {
                    AnnPolyRulerObject ruler = e.AnnotationObject as AnnPolyRulerObject;
                    if (ruler != null)
                    {
                        if (ruler.MeasurementUnit == AnnUnit.Pixel)
                        {
                            LeadLengthD lengthInUnits  = ruler.GetRulerLength(1);
                            double      lengthInPixels = Automation.Container.Mapper.LengthFromContainerCoordinates(lengthInUnits, AnnFixedStateOperations.Scrolling | AnnFixedStateOperations.Zooming);
                            toolTipText = string.Format("{0} {1}", Math.Round(lengthInPixels, 2), ruler.UnitsAbbreviation[AnnUnit.Pixel]);
                        }
                        else
                        {
                            toolTipText = ruler.GetRulerLengthAsString(Automation.Container.Mapper.CalibrationScale);
                        }
                    }
                    else
                    {
                        AnnRichTextObject richText = e.AnnotationObject as AnnRichTextObject;
                        if (richText != null)
                        {
                            toolTipText = richText.ToString();
                        }
                        else
                        {
                            AnnStickyNoteObject stickyNote = e.AnnotationObject as AnnStickyNoteObject;
                            if (stickyNote != null)
                            {
                                toolTipText = stickyNote.Metadata[AnnObject.ContentMetadataKey];
                            }
                            else
                            {
                                AnnAutomationObject annAutomationObject = MainForm.ManagerHelper.AutomationManager.FindObjectById(e.AnnotationObject.Id);
                                toolTipText = annAutomationObject.Name;
                            }
                        }
                    }
                }

                MainForm.ManagerHelper.SetToolTip(_viewer, toolTipText);
            }
            else
            {
                MainForm.ManagerHelper.SetToolTip(null, string.Empty);
            }
        }
Beispiel #8
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 #9
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;
            }
        }
Beispiel #10
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 #11
0
        private void _okButton_Click(object sender, EventArgs e)
        {
            AnnAutomationObject automationObject = _objectComboBox.SelectedItem as AnnAutomationObject;

            if (automationObject != null)
            {
                this.ObjectId = automationObject.Id;
            }

            if (this.ObjectId == AnnObject.RubberStampObjectId)
            {
                this.RubberStampType = ((RubberStampItem)_typeComboBox.SelectedItem).RubberStampType;
            }
        }
Beispiel #12
0
 void _annAutomation_OnShowContextMenu(object sender, AnnAutomationEventArgs e)
 {
     if (e != null && e.Object != null)
     {
         AnnAutomationObject annAutomationObject = e.Object as AnnAutomationObject;
         if (annAutomationObject != null)
         {
             ContextMenu menu = annAutomationObject.ContextMenu as ContextMenu;
             if (menu != null)
             {
                 menu.Show(this, _rasterImageViewer.PointToClient(Cursor.Position));
             }
         }
     }
 }
Beispiel #13
0
        public AnnObjectTreeNode(AnnObject annObject, AutomationTreeNode treeParentNode, AnnAutomation automation, AutomationObjectsListControl tree) : base(tree)
        {
            InitializeComponent();

            if (annObject == null)
            {
                throw new ArgumentNullException("annObject");
            }
            if (annObject.Id == AnnObject.SelectObjectId || annObject.Id == AnnObject.None)
            {
                throw new ArgumentException("Cannot create this item with a selection or none annotation object", "annObject");
            }

            if (treeParentNode == null)
            {
                throw new ArgumentNullException("treeParentNode");
            }
            if (automation == null)
            {
                throw new ArgumentNullException("automation");
            }

            _annObject  = annObject;
            _automation = automation;

            _tbComment.Visible = _annObject.SupportsContent;

            AnnAutomationObject automationObject = _automation.Manager.FindObjectById(_annObject.Id);

            if (automationObject != null)
            {
                _lblObjectName.Text = automationObject.Name;
                _pbObjetIcon.Image  = automationObject.ToolBarImage as Image;
            }
            else
            {
                _lblObjectName.Text = _annObject.FriendlyName;
                _pbObjetIcon.Image  = null;
            }

            UpdateMetadata();

            Width          = Tree.TreeRootNode.Width - Margin.Left;
            TreeParentNode = treeParentNode;
            IsExpanded     = false;
            GetReviews(AnnObject, this, AnnObject.Reviews);
        }
        // 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 #15
0
        private AnnAutomationObject CreateSnapPoint()
        {
            AnnAutomationObject automationObj    = new AnnAutomationObject();
            AnnMidlineObject    annMidlineObject = new AnnMidlineObject();

            annMidlineObject.SetId(annMidlineObject.Id - 1);
            automationObj.Id               = annMidlineObject.Id;
            automationObj.Name             = "SnapPoint";
            automationObj.DrawDesignerType = typeof(AnnSnapPointDrawer);
            automationObj.EditDesignerType = typeof(AnnSnapPointEditor);
            automationObj.RunDesignerType  = typeof(AnnRunDesigner);
            automationObj.ObjectTemplate   = annMidlineObject;

            IAnnObjectRenderer renderer = new AnnMidlineObjectRenderer();

            renderer.LocationsThumbStyle = CreateLocationThumbStyle();
            automationObj.Renderer       = renderer;

            return(automationObj);
        }
Beispiel #16
0
        private AnnAutomationObject CreateParallelLines()
        {
            AnnAutomationObject    automationObj          = new AnnAutomationObject();
            AnnParallelLinesObject annParallelLinesObject = new AnnParallelLinesObject();

            automationObj.Id               = annParallelLinesObject.Id;
            automationObj.Name             = "Two Parallel Lines";
            automationObj.DrawDesignerType = typeof(AnnParallelLinesDrawer);
            automationObj.EditDesignerType = typeof(AnnParallelLinesEditor);
            automationObj.RunDesignerType  = typeof(AnnRunDesigner);
            automationObj.ObjectTemplate   = annParallelLinesObject;

            IAnnObjectRenderer renderer = new AnnParallelLinesObjectRenderer();

            renderer.LocationsThumbStyle = CreateLocationThumbStyle();

            automationObj.Renderer = renderer;

            return(automationObj);
        }
Beispiel #17
0
        private AnnAutomationObject CreateMidline()
        {
            AnnAutomationObject automationObj    = new AnnAutomationObject();
            AnnMidlineObject    annMidlineObject = new AnnMidlineObject();

            automationObj.Id               = annMidlineObject.Id;
            automationObj.Name             = "MidLine";
            automationObj.DrawDesignerType = typeof(AnnTwoLinesDrawer);
            automationObj.EditDesignerType = typeof(AnnTwoLinesEditer);
            automationObj.RunDesignerType  = typeof(AnnRunDesigner);
            automationObj.ObjectTemplate   = annMidlineObject;

            IAnnObjectRenderer renderer = new AnnMidlineObjectRenderer();

            renderer.LocationsThumbStyle     = CreateLocationThumbStyle();
            renderer.RotateCenterThumbStyle  = CreateRotateCenterThumbStyle();
            renderer.RotateGripperThumbStyle = CreateRotateGripperThumbStyle();

            automationObj.Renderer = renderer;

            return(automationObj);
        }
Beispiel #18
0
 void _automation_OnShowContextMenu(object sender, AnnAutomationEventArgs e)
 {
     if (e != null && e.Object != null)
     {
         _rasterImageViewer.AutomationInvalidate(LeadRectD.Empty);
         AnnAutomationObject annAutomationObject = e.Object as AnnAutomationObject;
         if (annAutomationObject != null)
         {
             ObjectContextMenu menu = annAutomationObject.ContextMenu as ObjectContextMenu;
             if (menu != null)
             {
                 menu.Automation = sender as AnnAutomation;
                 menu.Show(this, RasterImageViewer.PointToClient(Cursor.Position));
             }
         }
     }
     else
     {
         ManagerContextMenu defaultMenu = new ManagerContextMenu();
         defaultMenu.Automation = sender as AnnAutomation;
         defaultMenu.Show(this, _rasterImageViewer.PointToClient(Cursor.Position));
     }
 }
Beispiel #19
0
        private void AddCheckMark(AnnAutomationManager _annAutomation)
        {
            AnnAutomationObject annObject = new AnnAutomationObject();

            annObject.Id = AnnAutomationManager.UserObjectId;

            annObject.Name = _CHECK_MARK_NAME;

            PictureObject annStamp = new PictureObject();

            annStamp.Pen         = new AnnPen(Color.Beige, new AnnLength(2, AnnUnit.Pixel));
            annStamp.Brush       = new AnnSolidBrush(Color.Yellow);
            annStamp.Name        = _CHECK_MARK_NAME;
            annStamp.NameVisible = false;

            annObject.DrawDesignerType = typeof(AnnRectangleDrawDesigner);
            annObject.EditDesignerType = typeof(AnnRectangleEditDesigner);
            annObject.RunDesignerType  = typeof(AnnRunDesigner);


            annObject.Object = annStamp;

            Image image = Image.FromHbitmap(ImageEdit.check.GetHbitmap());

            Bitmap btmp = new Bitmap(image);

            using (Graphics g = Graphics.FromImage(btmp))
            {
                g.FillRectangle(Brushes.Magenta, 0, 0, 16, 16);
                // g.DrawImage(image,0,0,16,16);
            }

            annObject.ToolBarImage       = image;
            annObject.ToolBarToolTipText = "Check Mark";
            _annAutomation.Objects.Add(annObject);
        }
Beispiel #20
0
        void automation_OnShowContextMenu(object sender, AnnAutomationEventArgs e)
        {
            AnnObject annEditObject = _automation.CurrentEditObject;

            if (e != null)
            {
                AnnAutomationObject annAutomationObject = e.Object;
                if (annAutomationObject != null)
                {
                    _imageViewer.AutomationInvalidate(LeadRectD.Empty);

                    ContextMenu contextMenu = annAutomationObject.ContextMenu as ContextMenu;
                    if (annAutomationObject != null && contextMenu != null)
                    {
                        ObjectContextMenu menu  = annAutomationObject.ContextMenu as ObjectContextMenu;
                        AnnLayer          layer = annEditObject.Layer;
                        if (menu != null)
                        {
                            if (layer != null && !layer.IsVisible)
                            {
                                return;
                            }

                            menu.Automation = sender as AnnAutomation;
                            contextMenu.Show(this, _imageViewer.PointToClient(Cursor.Position));
                        }
                    }
                }
            }
            else
            {
                ManagerContextMenu defaultMenu = new ManagerContextMenu();
                defaultMenu.Automation = sender as AnnAutomation;
                defaultMenu.Show(this, _imageViewer.PointToClient(Cursor.Position));
            }
        }
Beispiel #21
0
        private void AddCheckMark(AnnAutomationManager _annAutomation)
        {

            AnnAutomationObject annObject = new AnnAutomationObject();

            annObject.Id = AnnAutomationManager.UserObjectId;

            annObject.Name = _CHECK_MARK_NAME;

            PictureObject annStamp = new PictureObject();
            
            annStamp.Pen = new AnnPen(Color.Beige, new AnnLength(2, AnnUnit.Pixel));
            annStamp.Brush = new AnnSolidBrush(Color.Yellow);
            annStamp.Name = _CHECK_MARK_NAME;
            annStamp.NameVisible = false;
            
            annObject.DrawDesignerType = typeof(AnnRectangleDrawDesigner);
            annObject.EditDesignerType = typeof(AnnRectangleEditDesigner);
            annObject.RunDesignerType = typeof(AnnRunDesigner);


            annObject.Object = annStamp;
            
            Image image = Image.FromHbitmap(ImageEdit.check.GetHbitmap());
                
            Bitmap btmp = new Bitmap(image);
            using (Graphics g = Graphics.FromImage(btmp))
            {
                g.FillRectangle(Brushes.Magenta,0,0,16,16);
               // g.DrawImage(image,0,0,16,16);
            }
            
            annObject.ToolBarImage = image;
            annObject.ToolBarToolTipText = "Check Mark";
            _annAutomation.Objects.Add(annObject);
        }
Beispiel #22
0
        public ReviewTreeNode(AnnObject annObject, IList <AnnReview> reviews, AnnReview reply, AutomationTreeNode treeParentNode, AnnAutomation automation, AutomationObjectsListControl tree) : base(tree)
        {
            InitializeComponent();
            if (annObject == null)
            {
                throw new ArgumentNullException("annObject");
            }
            if (annObject.Id == AnnObject.SelectObjectId || annObject.Id == AnnObject.None)
            {
                throw new ArgumentException("Cannot create this item with a selection or none annotation object", "annObject");
            }
            if (reviews == null)
            {
                throw new ArgumentNullException("reviews");
            }
            if (reply == null)
            {
                throw new ArgumentNullException("reply");
            }
            if (automation == null)
            {
                throw new ArgumentNullException("automation");
            }
            _annObject  = annObject;
            _automation = automation;
            _reviews    = reviews;
            _reply      = reply;
            AnnAutomationObject automationObject = _automation.Manager.FindObjectById(_annObject.Id);

            if (automationObject != null)
            {
                _lblObjectName.Text = automationObject.Name;
            }
            else
            {
                _lblObjectName.Text = _annObject.FriendlyName;
            }
            _pbObjetIcon.Image = _replyImage;

            if (!String.IsNullOrEmpty(_reply.Author))
            {
                _lblAuthor.Text = _reply.Author;
            }

            string date = _reply.Date.ToString();

            if (!String.IsNullOrEmpty(date))
            {
                _lblDate.Text = date;
            }

            string status = _reply.Status;

            if (!String.IsNullOrEmpty(status))
            {
                _lblDate.Text = status + ": " + _lblDate.Text;
            }

            foreach (ToolStripMenuItem item in _miSetStatus.DropDownItems)
            {
                item.Checked = (item.Text == status);
            }

            if (!String.IsNullOrEmpty(_reply.Comment))
            {
                _tbComment.Text = _reply.Comment;
            }

            _cbChecked.Checked = _reply.IsChecked;

            TreeParentNode = treeParentNode;
            IsExpanded     = false;
            Width          = Tree.TreeRootNode.Width - Margin.Left;
        }
Beispiel #23
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);
                    }
                }
            }
        }
        private void AddObjectToToolBar(AnnAutomationObject automationObject, int index)
        {
            if (automationObject == null || this.ToolBar == null)
            {
                return;
            }

            var toolBar = this.ToolBar;

            var toolbarImage = automationObject.ToolBarImage as Image;

            if (toolBar.ImageList != null && toolBar.ImageList.Images.Count == 0 && toolbarImage != null)
            {
                toolBar.ImageList.ImageSize = new Size(toolbarImage.Width, toolbarImage.Height);

                var bitsPerPixel = Image.GetPixelFormatSize(toolbarImage.PixelFormat);
                if (bitsPerPixel <= 4)
                {
                    toolBar.ImageList.ColorDepth = ColorDepth.Depth4Bit;
                }
                else if (bitsPerPixel <= 8)
                {
                    toolBar.ImageList.ColorDepth = ColorDepth.Depth8Bit;
                }
                else if (bitsPerPixel <= 16)
                {
                    toolBar.ImageList.ColorDepth = ColorDepth.Depth16Bit;
                }
                else if (bitsPerPixel <= 24)
                {
                    toolBar.ImageList.ColorDepth = ColorDepth.Depth24Bit;
                }
                else
                {
                    toolBar.ImageList.ColorDepth = ColorDepth.Depth32Bit;
                }

                var bitmap = toolbarImage as Bitmap;
                if (bitmap != null && toolBar.ImageList.ColorDepth != ColorDepth.Depth32Bit)
                {
                    toolBar.ImageList.TransparentColor = bitmap.GetPixel(0, 0);
                }
            }

            if (toolbarImage != null)
            {
                toolBar.ImageList.Images.Add(toolbarImage);
                var button = new ToolBarButton();
                button.Style       = ToolBarButtonStyle.ToggleButton;
                button.ImageIndex  = index;
                button.ToolTipText = automationObject.ToolBarToolTipText;
                button.Tag         = automationObject.Id;
                if (automationObject.Id == AnnObject.RubberStampObjectId)
                {
                    button.Style = ToolBarButtonStyle.DropDownButton;
                }

                if (automationObject.Id == _manager.CurrentObjectId)
                {
                    button.Pushed = true;
                }

                toolBar.Buttons.Add(button);
            }
        }