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);
            }
        }
Ejemplo n.º 2
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();
                }
            }
        }
Ejemplo n.º 3
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);
        }