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);
            }
        }
        public override LeadRectD GetInvalidateRect(AnnContainerMapper mapper, IAnnObjectRenderer renderer)
        {
            LeadRectD invalidateRect = base.GetInvalidateRect(mapper, renderer);

            // Add angle label to the invalidate rect
            IAnnLabelRenderer labelRenderer = renderer.LabelRenderer;

            if (labelRenderer != null && labelRenderer.RenderingEngine != null && Labels.ContainsKey("CobbAngle"))
            {
                AnnLabel  label       = Labels["CobbAngle"];
                LeadRectD lablebounds = labelRenderer.GetBounds(mapper, label, FixedStateOperations);
                invalidateRect = LeadRectD.UnionRects(lablebounds, invalidateRect);
            }

            return(invalidateRect);
        }
Ejemplo n.º 3
0
        protected override LeadRectD GetBoundingRectangle()
        {
            LeadRectD rc = base.GetBoundingRectangle();

            double radius = _intersectionPointRadius.Value;

            if (!(double.IsInfinity(radius) || (double.IsInfinity(radius))))
            {
                if (!_intersectionPoint.IsEmpty && _intersectionInsideContainer)
                {
                    LeadRectD intersectionBounds = LeadRectD.Create(_intersectionPoint.X - radius, _intersectionPoint.Y - radius, radius * 2, radius * 2);
                    rc = LeadRectD.UnionRects(rc, intersectionBounds);
                }
            }

            return(rc);
        }
Ejemplo n.º 4
0
        public override LeadRectD GetInvalidateRect(AnnContainerMapper mapper, IAnnObjectRenderer renderer)
        {
            LeadRectD invalidate = GetBoundingRectangle();

            if (_linesAsRulers)
            {
                int linesCount = Points.Count / 2;

                for (int i = 0; i < linesCount; ++i)
                {
                    AnnPolyRulerObject ruler = new AnnPolyRulerObject();
                    ruler.Points.Clear();
                    ruler.Points.Add(Points[2 * i]);
                    ruler.Points.Add(Points[2 * i + 1]);
                    invalidate = LeadRectD.UnionRects(invalidate, ruler.GetInvalidateRect(mapper, renderer));
                }
            }

            invalidate = LeadRectD.UnionRects(base.GetInvalidateRect(mapper, renderer), invalidate);

            return(invalidate);
        }
Ejemplo n.º 5
0
        public void BuildWords()
        {
            var characterIndex = 0;
            var characterCount = _characters.Count;

            var words             = new List <DocumentWord>();
            var lastReverseWord   = false;
            var startReverseIndex = -1;

            // Loop through all the characters
            while (characterIndex < characterCount)
            {
                // Find the total bounding rectangle, begin and end index of the next word
                var  wordBounds          = LeadRectD.Empty;
                var  beginCharacterIndex = characterIndex;
                bool reverseWord         = false;

                // Loop till we reach the EndOfWord of EndOfLine
                var more      = true;
                var character = new DocumentCharacter();
                while (more && characterIndex < characterCount)
                {
                    character = _characters[characterIndex];

                    // Add the bounding rectangle of this character
                    var characterBounds = character.Bounds;

                    if (wordBounds.IsEmpty)
                    {
                        wordBounds = characterBounds;
                    }
                    else
                    {
                        wordBounds = LeadRectD.UnionRects(wordBounds, characterBounds);
                    }

                    more = characterIndex < characterCount &&
                           (character.Positions & DocumentCharacterPositions.EndOfWord) != DocumentCharacterPositions.EndOfWord &&
                           (character.Positions & DocumentCharacterPositions.EndOfLine) != DocumentCharacterPositions.EndOfLine;

                    characterIndex++;

                    if (character.Direction == SvgCharacterDirection.RightToLeft)
                    {
                        reverseWord = true;
                    }
                }

                // From the begin and end index, collect the characters into a string
                var sb = new StringBuilder();
                for (var i = beginCharacterIndex; i < characterIndex; i++)
                {
                    sb.Append(_characters[i].Code);
                }

                var word = new DocumentWord();
                word.Value  = sb.ToString();
                word.Bounds = wordBounds;
                word.FirstCharacterIndex = beginCharacterIndex;
                word.LastCharacterIndex  = characterIndex - 1;

                if (reverseWord)
                {
                    char[] charArray  = word.Value.ToCharArray();
                    int    startIndex = 0;
                    for (int i = 0; i < charArray.Length; i++)
                    {
                        int nextIndex = i + 1;
                        if (_characters[i + word.FirstCharacterIndex].Direction == SvgCharacterDirection.RightToLeft &&
                            (nextIndex >= charArray.Length ||
                             _characters[nextIndex + word.FirstCharacterIndex].Direction == SvgCharacterDirection.LeftToRight))
                        {
                            Array.Reverse(charArray, startIndex, nextIndex - startIndex);
                            startIndex = i;
                        }
                    }

                    word.Value = new string(charArray);
                }


                if (lastReverseWord && reverseWord)
                {
                    startReverseIndex = startReverseIndex == -1 ? words.Count - 1: startReverseIndex;
                    words.Insert(startReverseIndex, word);
                }
                else
                {
                    if (startReverseIndex != -1)
                    {
                        ReverseCharacterPositions(words[startReverseIndex].LastCharacterIndex, words[words.Count - 1].LastCharacterIndex);
                        startReverseIndex = -1;
                    }
                    words.Add(word);
                }

                lastReverseWord = reverseWord && (character.Positions & DocumentCharacterPositions.EndOfLine) != DocumentCharacterPositions.EndOfLine;
            }

            if (startReverseIndex != -1)
            {
                ReverseCharacterPositions(words[startReverseIndex].LastCharacterIndex, words[words.Count - 1].LastCharacterIndex);
            }

            _words = words;
        }
        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);
        }