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; }; }
private void InitClass( ) { _viewer = new ImageViewer(); _automationControl = new ImageViewerAutomationControl(); _automationControl.ImageViewer = _viewer; _viewer.Dock = DockStyle.Fill; _viewer.BorderStyle = BorderStyle.None; Controls.Add(_viewer); _viewer.BringToFront(); _viewer.MouseMove += new MouseEventHandler(_viewer_MouseMove); _viewer.KeyDown += new KeyEventHandler(_viewer_KeyDown); _viewer.UseDpi = false; _viewer.Focus(); }
private void InitClass() { #if !USE_ImageViewerAutomationControl _viewer = new ImageViewer(); var automationControl = new ImageViewerAutomationControl(); automationControl.ImageViewer = _viewer; _automationControl = automationControl; #else _viewer = new AutomationImageViewer(); _automationControl = _viewer; #endif _viewer.BorderStyle = BorderStyle.None; Controls.Add(_viewer); _viewer.BringToFront(); _viewer.MouseMove += new MouseEventHandler(_viewer_MouseMove); _viewer.KeyDown += new KeyEventHandler(_viewer_KeyDown); _viewer.UseDpi = false; _viewer.Focus(); _viewer.TransformChanged += new EventHandler(_viewer_TransformChanged); }
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)); } }