Esempio n. 1
0
        AnnLayer CreateLayer(string layerName)
        {
            AnnLayer layer = AnnLayer.Create(layerName);

            _automation.Container.Layers.Add(layer);
            _containerNode.Nodes.Add(new LayerNode(layer, _layerContextMenu));

            return(layer);
        }
Esempio n. 2
0
        private void menuItem_Click(object sender, EventArgs e)
        {
            if (_layerNode == null)
            {
                return;
            }

            LayerMenuItem mi = sender as LayerMenuItem;

            if (mi != null)
            {
                if (mi.Id == AddLayer)
                {
                    if (mi.Parent != null)
                    {
                        AnnLayer newLayer = AnnLayer.Create("Layer");
                        _layerNode.Nodes.Add(new LayerNode(newLayer, this));
                        if (_layerNode.Tag != null && string.Compare((string)_layerNode.Tag, "Container") == 0)
                        {
                            _automation.AddLayer(null, newLayer);
                        }
                        else
                        {
                            _automation.AddLayer(_layerNode.Layer, newLayer);
                        }
                    }
                }
                else if (mi.Id == DeleteLayer)
                {
                    _automation.DeleteLayer(_layerNode.Layer, false);
                    _layerNode.Parent.Nodes.Remove(_layerNode);
                }
                else if (mi.Id == BringToFirstId)
                {
                    _automation.BringLayerToFront(true);
                }
                else if (mi.Id == BringToFrontId)
                {
                    _automation.BringLayerToFront(false);
                }
                else if (mi.Id == SendToBackId)
                {
                    _automation.SendLayerToBack(false);
                }
                else if (mi.Id == SendToLastId)
                {
                    _automation.SendLayerToBack(true);
                }
            }

            if (_automation != null)
            {
                _automation.Invalidate(LeadRectD.Empty);
            }
        }
Esempio n. 3
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);
        }