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); } }
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); }