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
        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. 3
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. 4
0
        AnnRectangleObject CreateRectangle(LeadRectD rect, AnnBrush brush, AnnLayer layer)
        {
            AnnRectangleObject annRectObject = new AnnRectangleObject();

            annRectObject.Rect          = rect;
            annRectObject.Fill          = brush;
            annRectObject.Stroke.Stroke = AnnSolidColorBrush.Create("yellow");
            _automation.Container.Children.Add(annRectObject);
            layer.Children.Add(annRectObject);

            return(annRectObject);
        }
Esempio n. 5
0
        protected override void OnPopup(EventArgs e)
        {
            AnnLayer parentLayer = _layerNode.Layer.Parent;
            bool     isContainer = _layerNode.Tag != null && string.Compare((string)_layerNode.Tag, "Container") == 0;

            LayerMenuItem mi = GetMenuItem(DeleteLayer);

            if (mi != null)
            {
                mi.Enabled = !isContainer;
            }

            mi = GetMenuItem(BringToFrontId);
            if (mi != null)
            {
                mi.Enabled = _automation.CanBringLayerToFront;
            }

            mi = GetMenuItem(SendToBackId);
            if (mi != null)
            {
                mi.Enabled = _automation.CanSendLayerToBack;
            }

            mi = GetMenuItem(BringToFirstId);
            if (mi != null)
            {
                mi.Enabled = _automation.CanBringLayerToFirst;
            }

            mi = GetMenuItem(SendToLastId);
            if (mi != null)
            {
                mi.Enabled = _automation.CanSendLayerToLast;
            }

            base.OnPopup(e);
        }
Esempio n. 6
0
        void automation_OnShowContextMenu(object sender, AnnAutomationEventArgs e)
        {
            AnnObject annEditObject = _automation.CurrentEditObject;

            if (e != null)
            {
                AnnAutomationObject annAutomationObject = e.Object;
                if (annAutomationObject != null)
                {
                    _imageViewer.AutomationInvalidate(LeadRectD.Empty);

                    ContextMenu contextMenu = annAutomationObject.ContextMenu as ContextMenu;
                    if (annAutomationObject != null && contextMenu != null)
                    {
                        ObjectContextMenu menu  = annAutomationObject.ContextMenu as ObjectContextMenu;
                        AnnLayer          layer = annEditObject.Layer;
                        if (menu != null)
                        {
                            if (layer != null && !layer.IsVisible)
                            {
                                return;
                            }

                            menu.Automation = sender as AnnAutomation;
                            contextMenu.Show(this, _imageViewer.PointToClient(Cursor.Position));
                        }
                    }
                }
            }
            else
            {
                ManagerContextMenu defaultMenu = new ManagerContextMenu();
                defaultMenu.Automation = sender as AnnAutomation;
                defaultMenu.Show(this, _imageViewer.PointToClient(Cursor.Position));
            }
        }
Esempio n. 7
0
 public LayerNode(AnnLayer layer, ContextMenu menu)
     : base(string.Format("{0} #{1}", layer.Name, (_count++).ToString()))
 {
     Init(layer, menu);
 }
Esempio n. 8
0
 public LayerNode(AnnLayer layer, ContextMenu menu, bool increment)
     : base(increment ? string.Format("{0} #{1}", layer.Name, (_count++).ToString()) : layer.Name)
 {
     Init(layer, menu);
 }
Esempio n. 9
0
 void Init(AnnLayer layer, ContextMenu menu)
 {
     _layer      = layer;
     ContextMenu = null;
     Checked     = layer.IsVisible;
 }
Esempio n. 10
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);
        }