Esempio n. 1
0
        private void AddLayerNode(AnnLayer layer, LayerNode parent)
        {
            LayerNode layerNode = new LayerNode(layer, _layerContextMenu);

            parent.Nodes.Add(layerNode);
            AddLayersNodes(layer.Layers, layerNode);
        }
Esempio n. 2
0
        private void _tvLayers_AfterCheck(object sender, TreeViewEventArgs e)
        {
            LayerNode node = e.Node as LayerNode;

            if (e.Action != TreeViewAction.Unknown && node != null)
            {
                if (node == _containerNode)
                {
                    _automation.Container.IsVisible = node.Checked;
                }
                else
                {
                    if (node.Layer != null)
                    {
                        node.Layer.IsVisible = node.Checked;
                    }
                }

                AnnEditDesigner editDesigner = _automation.CurrentDesigner as AnnEditDesigner;
                if (editDesigner != null)
                {
                    editDesigner.End();
                }
                _automation.Invalidate(LeadRectD.Empty);
            }
        }
Esempio n. 3
0
 private void AddLayersNodes(AnnLayerCollection layers, LayerNode parent)
 {
     if (layers != null && layers.Count > 0)
     {
         foreach (AnnLayer layer in layers)
         {
             AddLayerNode(layer, parent);
         }
     }
 }
Esempio n. 4
0
        private void _tvLayers_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
        {
            LayerNode node = e.Node as LayerNode;

            if (node != null)
            {
                if (node != _containerNode)
                {
                    _automation.SelectLayer(node.Layer);
                }
                else
                {
                    _automation.SelectLayer(null);
                }
            }
        }
Esempio n. 5
0
        private void _tvLayers_MouseUp(object sender, MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Right)
            {
                // Point where the mouse is clicked.
                Point point = new Point(e.X, e.Y);

                // Get the node that the user has clicked.
                LayerNode node = _tvLayers.GetNodeAt(point) as LayerNode;
                if (node != null)
                {
                    _layerContextMenu.Attach(node, _automation);
                    _layerContextMenu.Show(this, point);
                }
            }
        }
Esempio n. 6
0
 public void Detach()
 {
     _layerNode  = null;
     _automation = null;
 }
Esempio n. 7
0
 public void Attach(LayerNode layerNode, AnnAutomation automation)
 {
     _layerNode  = layerNode;
     _automation = automation;
 }
Esempio n. 8
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);
        }