Example #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;
        }
        public AutomationManagerHelper(AnnAutomationManager manager)
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }

            _manager = manager;

            // listen to CurrentObjectIdChanged, to draw the desired object
            _manager.CurrentObjectIdChanged += new EventHandler(_manager_CurrentObjectIdChanged);
            // listen to UserModeChanged , to show and hide the toolbar.
            _manager.UserModeChanged += new EventHandler(_manager_UserModeChanged);

            // create ToolTip
            _toolTip = new ToolTip();
            _toolTip.ToolTipTitle = "LEAD Technologies, Inc";

            // Attach new WinForms rendering engine to the manager
            if (_manager.RenderingEngine == null)
            {
                _manager.RenderingEngine = new AnnWinFormsRenderingEngine();
            }

            // Initialize our context menus
            _rubberStampContextMenu = new RubberStampContextMenu();

            UpdateAutomationObjects();

            // Load the resources (images and rubber stamps)
            _manager.Resources = Tools.LoadResources();
        }
Example #3
0
        public CurrentObjectDialog(AnnAutomationManager automationManager)
        {
            if (automationManager == null)
            {
                throw new ArgumentNullException("automationManager");
            }

            InitializeComponent();
            _automationManager = automationManager;
        }
Example #4
0
 private static void RemoveObject(AnnAutomationManager automationManager, int objectId)
 {
     for (int i = 0; i < automationManager.Objects.Count; i++)
     {
         if (automationManager.Objects[i].Id == objectId)
         {
             automationManager.Objects.RemoveAt(i);
             return;
         }
     }
 }
Example #5
0
        private void InitAutomationManager()
        {
            _annManager = new AnnAutomationManager();

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

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

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

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

            this.Controls.Add(_automationHelper.ToolBar);

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

            _automation = new AnnAutomation(_annManager, _viewer);

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

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

            annAutText.ObjectTemplate.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("Red"), annLength);
            _automation.Active = true;
        }
Example #6
0
        private void ApplyCalibrate()
        {
            if (_isPixelUnit)
            {
                _polyRulerObject.MeasurementUnit = AnnUnit.SmartEnglish;
            }

            // the method _polyRulerObject.GetRulerLength() , gets the ruler length in AnnUnit.Unit so we need to convert it to current _polyRulerObject.MeasurementUnit with no calibration ratio
            LeadLengthD lengthInUnits = _polyRulerObject.GetRulerLength(1);

            double sourceLength = AnnUnitConverter.Convert(lengthInUnits.Value, AnnUnit.Unit, _polyRulerObject.MeasurementUnit);

            double destLength = 1;

            // check if the entered value is Number
            if (!double.TryParse(_txtRulerLength.Text, out destLength))
            {
                throw new Exception("Invalid Ruler Length Value");
            }

            if (sourceLength != 0 && destLength != 0)
            {
                AnnUnit destUnit = (AnnUnit)Enum.Parse(typeof(AnnUnit), _comboMesurementUnit.SelectedItem.ToString());

                if (_cboxApplyToAllRulers.Checked)
                {
                    _mapper.Calibrate(LeadLengthD.Create(sourceLength), _polyRulerObject.MeasurementUnit, LeadLengthD.Create(destLength), destUnit);

                    AnnAutomationManager manager = _automation.Manager;

                    //update all exisiting rulers to have the new calibration measurement unit
                    foreach (AnnObject annObject in _automation.Container.Children)
                    {
                        AnnPolyRulerObject polyRuler = annObject as AnnPolyRulerObject;
                        if (polyRuler != null)
                        {
                            polyRuler.MeasurementUnit = destUnit;
                        }
                    }
                }
                else
                {
                    _polyRulerObject.Calibrate(LeadLengthD.Create(sourceLength), _polyRulerObject.MeasurementUnit, LeadLengthD.Create(destLength), destUnit);
                }

                _polyRulerObject.MeasurementUnit = destUnit;
            }

            if (_isPixelUnit)
            {
                _polyRulerObject.MeasurementUnit = AnnUnit.Pixel;
            }
        }
Example #7
0
        private static AnnAutomationObject GetAutomationObject(AnnAutomationManager automationManager, int id)
        {
            foreach (AnnAutomationObject obj in automationManager.Objects)
            {
                if (obj.Id == id)
                {
                    return(obj);
                }
            }

            return(null);
        }
Example #8
0
        private void InitAnnotations()
        {
            _annAutomationManager = new AnnAutomationManager
            {
                RestrictDesigners   = true,
                EditObjectAfterDraw = false
            };
            _annAutomationManager.CreateDefaultObjects();

            // Only show the selector and redaction.  Remove the other objects.
            for (var count = 0; count < _annAutomationManager.Objects.Count; count++)
            {
                var id = _annAutomationManager.Objects[count].Id;
                if (id == AnnObject.RedactionObjectId || id == AnnObject.SelectObjectId)
                {
                    continue;
                }
                _annAutomationManager.Objects.RemoveAt(count);
                count--;
            }

            _automationManagerHelper = new AutomationManagerHelper(_annAutomationManager);
            _automationManagerHelper.CreateToolBar();
            panel1.Controls.Add(_automationManagerHelper.ToolBar);

            _automationControl = new ImageViewerAutomationControl {
                ImageViewer = _imageViewer
            };

            _imageViewer.InteractiveModes.BeginUpdate();
            _imageViewer.InteractiveModes.Add(new AutomationInteractiveMode {
                AutomationControl = _automationControl
            });
            _imageViewer.InteractiveModes.EndUpdate();

            _annAutomation = new AnnAutomation(_annAutomationManager, _automationControl)
            {
                Active = true
            };

            _imageViewer.ItemChanged += (s, e) =>
            {
                if (_annAutomation == null)
                {
                    return;
                }
                _annAutomation.Container.Size =
                    _annAutomation.Container.Mapper.SizeToContainerCoordinates(_imageViewer.ImageSize.ToLeadSizeD());
                _imageViewer.Zoom(ControlSizeMode.Fit, 1, LeadPoint.Empty);
                _annAutomationManager.CurrentObjectId = AnnObject.RedactionObjectId;
            };
        }
Example #9
0
        private void SetupAnnotations(RasterImage image)
        {
            // create and setup the automation manager
            annAutomationManager = new AnnAutomationManager();
            _annotationsHelper   = new AutomationManagerHelper(annAutomationManager);
            annAutomationManager.CreateDefaultObjects();
            //Run mode to prevent editing of annotations
            annAutomationManager.UserMode = AnnUserMode.Render;

            masterSheetViewer.Image = image;

            automation        = new AnnAutomation(annAutomationManager, masterSheetViewer);
            automation.Active = true;

            automation.Container.Children.Clear();

            annotationField             = new AnnHiliteObject();
            annotationField.HiliteColor = "Green";
            automation.Container.Children.Add(annotationField);
        }
Example #10
0
        private void SetupAnnotations()
        {
            // create and setup the automation manager
            annAutomationManager = new AnnAutomationManager();
            _annotationsHelper   = new AutomationManagerHelper(annAutomationManager);
            annAutomationManager.CreateDefaultObjects();
            //Run mode to prevent editing of annotations
            annAutomationManager.UserMode = AnnUserMode.Run;

            //Create dummy image to init automation
            RasterImage img = new RasterImage(RasterMemoryFlags.Conventional, 1, 1, 1, RasterByteOrder.Bgr, RasterViewPerspective.TopLeft, null, IntPtr.Zero, 0);

            img.XResolution         = 150;
            img.YResolution         = 150;
            _filledFormViewer.Image = img;

            automation              = new AnnAutomation(annAutomationManager, _filledFormViewer);
            automation.Active       = true;
            _filledFormViewer.Image = null;
        }
        public AutomationManagerHelper(AnnAutomationManager manager)
        {
            if (manager == null)
            {
                throw new ArgumentNullException("manager");
            }

            _manager = manager;


            // Attach new WinForms rendering engine to the manager
            if (_manager.RenderingEngine == null)
            {
                _manager.RenderingEngine = new AnnDrawRenderingEngine();
            }

            UpdateAutomationObjects();

            // Load the resources (images and rubber stamps)
            _manager.Resources = Tools.LoadResources();
        }
Example #12
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);
        }
Example #13
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);
        }
Example #14
0
        private void IntializeAnnContainer()
        {
             SuspendLayout();

            imageViewer = new RasterImageViewer();
             imageViewer.Dock = DockStyle.Fill;
             imageViewer.EnableScrollingInterface = true;
             this.imageViewer.KeyDown += new System.Windows.Forms.KeyEventHandler(this.imageViewer_KeyDown);
             this.imageViewer.DoubleClick += new System.EventHandler(this.imageViewer_Clicked);
            // this.imageViewer.MouseMove += new System.Windows.Forms.MouseEventHandler(this._viewer_MouseMove);
             
             this.Controls.Add(imageViewer);

            

            _automationManager = new AnnAutomationManager();
            _annAutomation = new AnnAutomation(_automationManager, this.imageViewer);
            _annAutomation.Active = true;
            this.imageViewer.BringToFront();
            
            //imageViewer.
            
           
      
            _codec = new RasterCodecs();
            CodecsTxtLoadOptions txtOption = _codec.Options.Txt.Load;
            txtOption.Enabled = true;

            _automationManager.RasterCodecs = _codec;
            _automationManager.RedactionRealizePassword = "";
            _automationManager.CreateDefaultObjects();
            CustomizeObjectProperty();

             
            PropertyForm propForm = new PropertyForm();
            
            _automationManager.ObjectPropertiesDialogType = propForm.GetType();
         //   _automationManager.ObjectPropertiesDialogType = null;
            AddCheckMark(_automationManager);

            _automationManager.CreateToolBar();
            _automationManager.ToolBar.BringToFront();
            imageToolBar = new ImageToolBar();
            this.imageToolBar.TifEditor = this;
            toolBar = imageToolBar.GetExtendedToolBar(_automationManager.ToolBar);
            toolBar.Dock = DockStyle.Bottom;

            this.Controls.Add(_automationManager.ToolBar);




            topToolBar = imageToolBar.AddCustomToolBar(topToolBar);

            
            imageToolBar.UpdateToolBar();
            ResumeLayout();

            RasterPaintProperties prop = imageViewer.PaintProperties;
           // prop.PaintDisplayMode |= RasterPaintDisplayModeFlags.ScaleToGray | RasterPaintDisplayModeFlags.Bicubic;
            prop.PaintDisplayMode = RasterPaintDisplayModeFlags.ScaleToGray;
            imageViewer.PaintProperties = prop;
            

            
            InitialzeEdit();


        }
Example #15
0
        protected override void OnLoad(EventArgs e)
        {
            if (!DesignMode)
            {
                _automationManager             = new AnnAutomationManager();
                _automationManager.GroupsRoles = _groupsRoles;
                _automationManager.RedactionRealizePassword = string.Empty;
                _automationManager.CreateDefaultObjects();
                _managerHelper = new AutomationManagerHelper(_automationManager);

                _managerHelper.CreateToolBar();
                tabControl1.TabPages[1].Controls.Add(_managerHelper.ToolBar);

                _imageViewer          = new AutomationImageViewer();
                _imageViewer.KeyDown += new KeyEventHandler(_imageViewer_KeyDown);
                tabControl1.TabPages[1].Controls.Add(_imageViewer);

                _managerHelper.ToolBar.Dock       = DockStyle.Right;
                _managerHelper.ToolBar.AutoSize   = false;
                _managerHelper.ToolBar.Appearance = ToolBarAppearance.Flat;
                _managerHelper.ToolBar.BringToFront();

                _imageViewer.Dock   = DockStyle.Fill;
                _imageViewer.UseDpi = false;
                _imageViewer.ImageHorizontalAlignment = Leadtools.Controls.ControlAlignment.Center;
                _imageViewer.ImageBorderColor         = Color.Black;
                _imageViewer.ImageBorderThickness     = 1;
                _imageViewer.BringToFront();

                AutomationInteractiveMode automationInteractiveMode = new AutomationInteractiveMode();
                automationInteractiveMode.MouseButtons = MouseButtons.Left | MouseButtons.Right;
                _imageViewer.InteractiveModes.Add(automationInteractiveMode);

                using (RasterCodecs codec = new RasterCodecs())
                {
                    _imageViewer.Image = codec.Load(DemosGlobal.ImagesFolder + @"\ocr1.tif");
                    _imageViewer.Zoom(Leadtools.Controls.ControlSizeMode.FitWidth, 1, LeadPoint.Empty);
                }

                _automation = new AnnAutomation(_automationManager, _imageViewer);

                // Update the container size
                _automation.Container.Size = _automation.Container.Mapper.SizeToContainerCoordinates(LeadSizeD.Create(_imageViewer.Image.ImageWidth, _imageViewer.Image.ImageHeight));

                _automation.EditText               += new EventHandler <AnnEditTextEventArgs>(automation_EditText);
                _automation.OnShowContextMenu      += new EventHandler <AnnAutomationEventArgs>(automation_OnShowContextMenu);
                _automation.OnShowObjectProperties += new EventHandler <AnnAutomationEventArgs>(automation_OnShowObjectProperties);
                _automation.LockObject             += new EventHandler <AnnLockObjectEventArgs>(automation_LockObject);
                _automation.UnlockObject           += new EventHandler <AnnLockObjectEventArgs>(automation_UnlockObject);
                _automation.SetCursor              += new EventHandler <AnnCursorEventArgs>(automation_SetCursor);
                _automation.RestoreCursor          += new EventHandler(automation_RestoreCursor);

                FlipReverseText(_automationManager.RenderingEngine, true);
                _automation.Active = true;

                _chkLstGroups.CheckOnClick = true;
                _chkLstGroups.ItemCheck   += new ItemCheckEventHandler(_chkLstGroups_ItemCheck);
                _chkLstGroups.Enabled      = _lstUsers.Items.Count > 0 && _lstUsers.SelectedIndex >= 0;

                _chkLstRoles.CheckOnClick = true;
                _chkLstRoles.ItemCheck   += new ItemCheckEventHandler(_chkLstRoles_ItemCheck);
                _chkLstRoles.Items.Add(new CheckRoleItem(AnnRoles.View));
                _chkLstRoles.Items.Add(new CheckRoleItem(AnnRoles.ViewAll));
                _chkLstRoles.Items.Add(new CheckRoleItem(AnnRoles.Edit));
                _chkLstRoles.Items.Add(new CheckRoleItem(AnnRoles.EditAll));
                _chkLstRoles.Items.Add(new CheckRoleItem(CustomRoles.RulersOnly));

                _lstGroups.SelectedIndexChanged += new EventHandler(_lstGroups_SelectedIndexChanged);

                _chkLstRoles.Enabled            = _lstGroups.Items.Count > 0 && _lstGroups.SelectedIndex >= 0;
                _lstUsers.SelectedIndexChanged += new EventHandler(_lstUsers_SelectedIndexChanged);
                _groupsRoles.GenerateRole      += new EventHandler <AnnOperationInfoEventArgs>(_groupsRoles_GenerateRole);

                AnnRoles medicalRoles = new AnnRoles();
                medicalRoles.Add(CustomRoles.RulersOnly);
                AddGroup(_groupsRoles, "Medical", medicalRoles);

                AnnRoles documentRoles = new AnnRoles();
                documentRoles.Add(AnnRoles.View);
                documentRoles.Add(AnnRoles.Edit);

                AddGroup(_groupsRoles, "Document", documentRoles);

                AnnRoles adminRoles = new AnnRoles();
                adminRoles.Add(AnnRoles.EditAll);
                AddGroup(_groupsRoles, "Admins", adminRoles);

                AnnRoles guestRoles = new AnnRoles();
                guestRoles.Add(AnnRoles.ViewAll);
                AddGroup(_groupsRoles, "Guests", guestRoles);

                AddUser(_groupsRoles, "Medical", "MedicalUser");
                AddUser(_groupsRoles, "Document", "DocumentUser");
                AddUser(_groupsRoles, "Guests", "Guest");
                AddUser(_groupsRoles, "Admins", "Admin");
                OnResize(EventArgs.Empty);
            }

            base.OnLoad(e);
        }
Example #16
0
 /// <summary>
 /// Called by the main form to tie the automation manager to the object in the viewer control
 /// </summary>
 public void SetAutomation(AnnAutomationManager automationManager, AnnAutomation automation)
 {
     _automationManager = automationManager;
     _automation        = automation;
 }
Example #17
0
        private void IntializeAnnContainer()
        {
            SuspendLayout();

            imageViewer      = new RasterImageViewer();
            imageViewer.Dock = DockStyle.Fill;
            imageViewer.EnableScrollingInterface = true;
            this.imageViewer.KeyDown            += new System.Windows.Forms.KeyEventHandler(this.imageViewer_KeyDown);
            this.imageViewer.DoubleClick        += new System.EventHandler(this.imageViewer_Clicked);
            // this.imageViewer.MouseMove += new System.Windows.Forms.MouseEventHandler(this._viewer_MouseMove);

            this.Controls.Add(imageViewer);



            _automationManager    = new AnnAutomationManager();
            _annAutomation        = new AnnAutomation(_automationManager, this.imageViewer);
            _annAutomation.Active = true;
            this.imageViewer.BringToFront();

            //imageViewer.



            _codec = new RasterCodecs();
            CodecsTxtLoadOptions txtOption = _codec.Options.Txt.Load;

            txtOption.Enabled = true;

            _automationManager.RasterCodecs             = _codec;
            _automationManager.RedactionRealizePassword = "";
            _automationManager.CreateDefaultObjects();
            CustomizeObjectProperty();


            PropertyForm propForm = new PropertyForm();

            _automationManager.ObjectPropertiesDialogType = propForm.GetType();
            //   _automationManager.ObjectPropertiesDialogType = null;
            AddCheckMark(_automationManager);

            _automationManager.CreateToolBar();
            _automationManager.ToolBar.BringToFront();
            imageToolBar = new ImageToolBar();
            this.imageToolBar.TifEditor = this;
            toolBar      = imageToolBar.GetExtendedToolBar(_automationManager.ToolBar);
            toolBar.Dock = DockStyle.Bottom;

            this.Controls.Add(_automationManager.ToolBar);



            topToolBar = imageToolBar.AddCustomToolBar(topToolBar);


            imageToolBar.UpdateToolBar();
            ResumeLayout();

            RasterPaintProperties prop = imageViewer.PaintProperties;

            // prop.PaintDisplayMode |= RasterPaintDisplayModeFlags.ScaleToGray | RasterPaintDisplayModeFlags.Bicubic;
            prop.PaintDisplayMode       = RasterPaintDisplayModeFlags.ScaleToGray;
            imageViewer.PaintProperties = prop;



            InitialzeEdit();
        }
Example #18
0
        private void Form1_Load(object sender, EventArgs e)
        {
            viewer      = new ImageViewer();
            viewer.Dock = DockStyle.Fill;

            automationControl             = new ImageViewerAutomationControl();
            automationControl.ImageViewer = viewer;

            ScreenCaptureEngine.Startup();
            scEngine.CaptureInformation += new EventHandler <ScreenCaptureInformationEventArgs>(scEngine_CaptureInformation);
            ScreenCaptureOptions captureOptions = scEngine.CaptureOptions;

            captureOptions.Hotkey   = Keys.None;
            scEngine.CaptureOptions = captureOptions;

            // initialize a new RasterCodecs object
            RasterCodecs codecs = new RasterCodecs();

            // load the main image into the viewer
            viewer.Image = codecs.Load(@"C:\Users\Public\Documents\LEADTOOLS Images\OCR1.TIF");
            viewer.Zoom(ControlSizeMode.FitAlways, 1.0, viewer.DefaultZoomOrigin);

            // initialize the interactive mode for the viewer
            AutomationInteractiveMode automationInteractiveMode = new AutomationInteractiveMode();

            automationInteractiveMode.AutomationControl = automationControl;

            // add the interactive mode to the viewer
            viewer.InteractiveModes.BeginUpdate();
            viewer.InteractiveModes.Add(automationInteractiveMode);
            viewer.InteractiveModes.EndUpdate();

            if (viewer.Image != null)
            {
                // create and set up the automation manager
                annAutomationManager = new AnnAutomationManager();
                annAutomationManager.RestrictDesigners   = true;
                annAutomationManager.EditObjectAfterDraw = false;

                // Instruct the manager to create all of the default automation objects.
                annAutomationManager.CreateDefaultObjects();

                AnnObservableCollection <AnnAutomationObject> annObservable = annAutomationManager.Objects;
                foreach (AnnAutomationObject annObject in annObservable)
                {
                    if (annObject.Id != AnnObject.SelectObjectId)
                    {
                        //  annObservable.Remove(annObject);
                        // annAutomationManager.Objects.Remove(annObject);
                    }
                }


                // initialize the manager helper and create the toolbar and add it then the viewer to the controls
                AutomationManagerHelper managerHelper = new AutomationManagerHelper(annAutomationManager);
                managerHelper.CreateToolBar();
                managerHelper.ToolBar.Dock = DockStyle.Right;
                Controls.Add(managerHelper.ToolBar);
                Controls.Add(viewer);


                // set up the automation (it will create the container as well)
                automation              = new AnnAutomation(annAutomationManager, automationControl);
                automation.EditContent += new EventHandler <AnnEditContentEventArgs>(automation_EditContent);
                // set this automation as the active one
                automation.Active = true;

                //set the size of the container to the size of the viewer
                automation.Container.Size = automation.Container.Mapper.SizeToContainerCoordinates(LeadSizeD.Create(viewer.Image.ImageWidth, viewer.Image.ImageHeight));
            }
        }
Example #19
0
        private void InitAnnotations()
        {
            try
            {
                _annAutomationManager = AnnAutomationManager.Create(new AnnWinFormsRenderingEngine());
                _annotationsHelper    = new AutomationManagerHelper(_annAutomationManager);

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

                _annAutomationManager.CreateDefaultObjects();

                _annAutomation = new AnnAutomation(_annAutomationManager, _rasterImageViewer);
                _annAutomation.OnShowContextMenu      += new EventHandler <AnnAutomationEventArgs>(_automation_OnShowContextMenu);
                _annAutomation.OnShowObjectProperties += new EventHandler <AnnAutomationEventArgs>(automation_OnShowObjectProperties);
                _annAutomation.Container.Children.CollectionChanged += new EventHandler <AnnNotifyCollectionChangedEventArgs>(Children_CollectionChanged);
                _annAutomation.AfterObjectChanged          += new EventHandler <AnnAfterObjectChangedEventArgs>(automation_AfterObjectChanged);
                _annAutomation.UndoRedoChanged             += new EventHandler(automation_UndoRedoChanged);
                _annAutomation.LockObject                  += _annAutomation_LockObject;
                _annAutomation.UnlockObject                += _annAutomation_UnlockObject;
                _annAutomation.Active                       = true;
                automationInteractiveMode.AutomationControl = _rasterImageViewer;

                // Remove the following automation objects since we will not use them in this
                // demo
                RemoveObject(_annAutomationManager, AnnObject.HotspotObjectId);
                RemoveObject(_annAutomationManager, AnnObject.FreehandHotspotObjectId);
                RemoveObject(_annAutomationManager, AnnObject.ButtonObjectId);
                RemoveObject(_annAutomationManager, AnnObject.AudioObjectId);
                RemoveObject(_annAutomationManager, AnnObject.EncryptObjectId);
                RemoveObject(_annAutomationManager, AnnObject.PointObjectId);
                RemoveObject(_annAutomationManager, AnnObject.RedactionObjectId);
                RemoveObject(_annAutomationManager, AnnObject.TextRollupObjectId);

                // Remove the Flip, reverse, lock, unlock items from the PopUp menus
                // and remove the "Control Points' item form the dfault menu
                CustomizeAutomationMenu();


                // Disable the rotation points
                foreach (AnnAutomationObject autObj in _annAutomationManager.Objects)
                {
                    autObj.UseRotateThumbs = false;
                }

                _annotationsHelper.CreateToolBar();

                ToolBar tb = _annotationsHelper.ToolBar;
                tb.AutoSize = true;
                tb.Dock     = DockStyle.Right;
                this.Controls.Add(tb);
                tb.BringToFront();
                tb.Appearance = ToolBarAppearance.Flat;

                _rasterImageViewer.BringToFront();
            }
            catch (Exception ex)
            {
                Messager.ShowError(this, ex);
            }
        }
Example #20
0
        protected override void OnLoad(EventArgs e)
        {
            if (!DesignMode)
            {
                _automationManager = AnnAutomationManager.Create(new AnnWinFormsRenderingEngine());

                _automationManager.RedactionRealizePassword = string.Empty;
                _automationManager.CreateDefaultObjects();

                _managerHelper = new AutomationManagerHelper(_automationManager);
                _managerHelper.CreateToolBar();
                FlipReverseText(_automationManager.RenderingEngine, true);

                _managerHelper.ToolBar.Dock       = DockStyle.Right;
                _managerHelper.ToolBar.AutoSize   = false;
                _managerHelper.ToolBar.Width      = 100;
                _managerHelper.ToolBar.Appearance = ToolBarAppearance.Normal;
                this.Controls.Add(_managerHelper.ToolBar);
                _managerHelper.ToolBar.BringToFront();

                _imageViewer          = new AutomationImageViewer();
                _imageViewer.KeyDown += new KeyEventHandler(_imageViewer_KeyDown);
                _imageViewer.Dock     = DockStyle.Fill;
                this.Controls.Add(_imageViewer);
                _imageViewer.BringToFront();

                AutomationInteractiveMode automationInteractiveMode = new AutomationInteractiveMode();
                automationInteractiveMode.MouseButtons = MouseButtons.Left | MouseButtons.Right;
                _imageViewer.InteractiveModes.Add(automationInteractiveMode);

                _imageViewer.UseDpi = false;

                _imageViewer.Zoom(Leadtools.Controls.ControlSizeMode.FitWidth, 1, LeadPoint.Empty);
                _imageViewer.ImageHorizontalAlignment = Leadtools.Controls.ControlAlignment.Center;
                _imageViewer.ImageBorderColor         = Color.Black;
                _imageViewer.BorderStyle          = BorderStyle.Fixed3D;
                _imageViewer.ImageBorderThickness = 1;

                using (RasterCodecs codec = new RasterCodecs())
                {
                    _imageViewer.Image = codec.Load(DemosGlobal.ImagesFolder + @"\ocr1.tif");
                    _imageViewer.AutomationDataProvider = new RasterImageAutomationDataProvider(_imageViewer.Image);
                }

                _automation = new AnnAutomation(_automationManager, _imageViewer);

                // Update the container size
                _automation.Container.Size = _automation.Container.Mapper.SizeToContainerCoordinates(LeadSizeD.Create(_imageViewer.Image.ImageWidth, _imageViewer.Image.ImageHeight));

                _automation.EditText               += new EventHandler <AnnEditTextEventArgs>(automation_EditText);
                _automation.OnShowContextMenu      += new EventHandler <AnnAutomationEventArgs>(automation_OnShowContextMenu);
                _automation.OnShowObjectProperties += new EventHandler <AnnAutomationEventArgs>(automation_OnShowObjectProperties);
                _automation.LockObject             += new EventHandler <AnnLockObjectEventArgs>(automation_LockObject);
                _automation.UnlockObject           += new EventHandler <AnnLockObjectEventArgs>(automation_UnlockObject);
                _automation.SetCursor              += new EventHandler <AnnCursorEventArgs>(automation_SetCursor);
                _automation.RestoreCursor          += new EventHandler(automation_RestoreCursor);

                _automation.Active = true;

                _tvLayers.BeginUpdate();
                _tvLayers.HideSelection = false;
                AnnLayer            layer    = AnnLayer.Create("Container");
                AnnObjectCollection children = _automation.Container.Children;
                foreach (AnnObject annObject in children)
                {
                    layer.Children.Add(annObject);
                }

                _containerNode     = new LayerNode(layer, null, false);
                _containerNode.Tag = "Container";

                _tvLayers.Nodes.Add(_containerNode);
                _tvLayers.EndUpdate();
                CreateDefaultLayers();
                OnResize(EventArgs.Empty);
            }

            base.OnLoad(e);
        }