internal void AddSelectedObject(AnnObjectTreeNode node)
        {
            node.IsSelected = true;
            node.Invalidate();
            SelectedItems.Add(node);
            AnnObjectCollection annObjects = new AnnObjectCollection();

            foreach (AnnObjectTreeNode item in SelectedItems)
            {
                annObjects.Add(item.AnnObject);
            }
            if (_imageViewer != null && _automation != null)
            {
                var invalidRect = LeadRectD.Empty;
                foreach (AnnObject annObject in annObjects)
                {
                    if (annObject != null)
                    {
                        invalidRect = LeadRectD.UnionRects(invalidRect, _automation.GetObjectInvalidateRect(annObject));
                    }
                }
                _automation.ActiveContainer = ((PageTreeNode)node.TreeParentNode).AnnContainer;
                _automation.SelectObjects(annObjects);
                _imageViewer.EnsureBoundsVisible(invalidRect);
            }
        }
예제 #2
0
        public OmrSensitivityDialog(MainForm mainForm, AnnObjectCollection omrFields)
        {
            InitializeComponent();

            _mainForm  = mainForm;
            _omrFields = omrFields;
        }
예제 #3
0
        private void _tbComment_TextChanged(object sender, EventArgs e)
        {
            bool hasChanged = false;
            Dictionary <string, string> metadata = _annObject.Metadata;

            if (metadata.ContainsKey(AnnObject.ContentMetadataKey))
            {
                string oldValue = metadata[AnnObject.ContentMetadataKey];
                if (string.Compare(oldValue, _tbComment.Text, StringComparison.OrdinalIgnoreCase) != 0)
                {
                    metadata[AnnObject.ContentMetadataKey] = _tbComment.Text;
                    hasChanged = true;
                }
            }

            if (hasChanged && _automation != null)
            {
                AnnObjectCollection modifiedObjects = new AnnObjectCollection();
                modifiedObjects.Add(_annObject);

                this.Tree.BeginIgnoreChanged();
                try
                {
                    _automation.InvokeAfterObjectChanged(modifiedObjects, AnnObjectChangedType.Metadata);
                }
                finally
                {
                    this.Tree.EndIgnoreChanged();
                }
            }
        }
예제 #4
0
        public void UpdateTextObject()
        {
            if (_textObject == null)
            {
                return;
            }

            _textObject.Text = this.Text;
            if (_automation != null)
            {
                AnnObjectCollection annObjects = new AnnObjectCollection();
                annObjects.Add(_textObject);
                _automation.InvokeObjectModified(annObjects, AnnObjectChangedType.Text);
                _automation.InvokeAfterObjectChanged(annObjects, AnnObjectChangedType.Text);
            }
        }
        protected override void OnSelectedIndexChanged(EventArgs e)
        {
            if (_ignoreSelectionChanged > 0)
            {
                return;
            }

            // Update our list
            var selectedIndicies = this.SelectedIndices;

            foreach (int index in selectedIndicies)
            {
                if (!_trackSelection.Contains(index))
                {
                    _trackSelection.Add(index);
                }
            }

            foreach (int index in new List <int>(_trackSelection))
            {
                if (!selectedIndicies.Contains(index))
                {
                    _trackSelection.Remove(index);
                }
            }

            // _trackSelection contains the current selected items in chronological order
            // make sure all objects are in the same container
            if (_trackSelection.Count > 1 && _automation != null)
            {
                var firstItem = this.Items[_trackSelection[0]] as AutomationSimpleObjectsListItem;
                var lastItem  = this.Items[_trackSelection[_trackSelection.Count - 1]] as AutomationSimpleObjectsListItem;

                if (firstItem.AnnContainer != lastItem.AnnContainer)
                {
                    // Unselect all but last object
                    _ignoreSelectionChanged++;
                    this.ClearSelected();
                    this.SelectedItems.Add(lastItem);
                    _ignoreSelectionChanged--;
                }
            }

            // Select the objects in the automation
            if (_automation != null && _ignoreAutomationSelected == 0)
            {
                var          annObjects   = new AnnObjectCollection();
                AnnContainer annContainer = null;
                foreach (var index in _trackSelection)
                {
                    var item = this.Items[index] as AutomationSimpleObjectsListItem;
                    annObjects.Add(item.AnnObject);
                    if (annContainer == null)
                    {
                        annContainer = item.AnnContainer;
                    }
                }

                if (annContainer != null && annContainer != _automation.ActiveContainer)
                {
                    _automation.ActiveContainer = annContainer;
                }

                _automation.SelectObjects(annObjects);

                if (_imageViewer != null)
                {
                    var invalidRect = LeadRectD.Empty;
                    foreach (var annObject in annObjects)
                    {
                        if (annObject != null)
                        {
                            invalidRect = LeadRectD.UnionRects(invalidRect, _automation.GetObjectInvalidateRect(annObject));
                        }
                    }

                    _imageViewer.EnsureBoundsVisible(invalidRect);
                }
            }

            base.OnSelectedIndexChanged(e);
        }
예제 #6
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);
        }