Beispiel #1
0
        //gets text within selected area
        private string GetText()
        {
            double top    = _selectionRect.Top;
            double bottom = _selectionRect.Bottom;
            double left   = _selectionRect.Left;
            double right  = _selectionRect.Right;

            double lastBaseline = 0;
            double baseline     = 0;
            double lastHeight   = 0;
            double height       = 0;

            int       nChildren = _page.Children.Count;
            ArrayList ranges    = new ArrayList(); //text ranges in area

            FixedNode[] nodesInLine = _panel.FixedContainer.FixedTextBuilder.GetFirstLine(_pageIndex);

            while (nodesInLine != null && nodesInLine.Length > 0)
            {
                TextPositionPair textRange = null; //current text range

                foreach (FixedNode node in nodesInLine)
                {
                    Glyphs g = _page.GetGlyphsElement(node);
                    if (g != null)
                    {
                        int  begin, end; //first and last index in range
                        bool includeEnd; //is the end of this glyphs included in selection?
                        if (IntersectGlyphs(g, top, left, bottom, right, out begin, out end, out includeEnd, out baseline, out height))
                        {
                            if (textRange == null || begin > 0)
                            {
                                //begin new text range
                                textRange       = new TextPositionPair();
                                textRange.first = _GetTextPosition(node, begin);
                                ranges.Add(textRange);
                            }

                            textRange.second = _GetTextPosition(node, end);

                            if (!includeEnd)
                            {
                                // so future textRanges aren't concatenated with this one
                                textRange = null;
                            }
                        }
                        else
                        {
                            //this Glyphs completely outside selected region
                            textRange = null;
                        }
                        lastBaseline = baseline;
                        lastHeight   = height;
                    }
                }
                int count = 1;
                nodesInLine = _panel.FixedContainer.FixedTextBuilder.GetNextLine(nodesInLine[0], true, ref count);
            }

            string text = "";

            foreach (TextPositionPair range in ranges)
            {
                Debug.Assert(range.first != null && range.second != null);
                text = text + TextRangeBase.GetTextInternal(range.first, range.second) + "\r\n"; //CRLF
            }

            return(text);
        }
        //gets text within selected area 
        private string GetText() 
        {
            double top = _selectionRect.Top; 
            double bottom = _selectionRect.Bottom;
            double left = _selectionRect.Left;
            double right = _selectionRect.Right;
 
            double lastBaseline = 0;
            double baseline = 0; 
            double lastHeight = 0; 
            double height = 0;
 
            int nChildren = _page.Children.Count;
            ArrayList ranges = new ArrayList(); //text ranges in area

            FixedNode[] nodesInLine = _panel.FixedContainer.FixedTextBuilder.GetFirstLine(_pageIndex); 

            while (nodesInLine != null && nodesInLine.Length > 0) 
            { 
                TextPositionPair textRange = null; //current text range
 
                foreach (FixedNode node in nodesInLine)
                {
                    Glyphs g = _page.GetGlyphsElement(node);
                    if (g != null) 
                    {
                        int begin, end; //first and last index in range 
                        bool includeEnd; //is the end of this glyphs included in selection? 
                        if (IntersectGlyphs(g, top, left, bottom, right, out begin, out end, out includeEnd, out baseline, out height))
                        { 
                            if (textRange == null || begin > 0)
                            {
                                //begin new text range
                                textRange = new TextPositionPair(); 
                                textRange.first = _GetTextPosition(node, begin);
                                ranges.Add(textRange); 
                            } 

                            textRange.second = _GetTextPosition(node, end); 

                            if (!includeEnd)
                            {
                                // so future textRanges aren't concatenated with this one 
                                textRange = null;
                            } 
                        } 
                        else
                        { 
                            //this Glyphs completely outside selected region
                            textRange = null;
                        }
                        lastBaseline = baseline; 
                        lastHeight = height;
                    } 
                } 
                int count = 1;
                nodesInLine = _panel.FixedContainer.FixedTextBuilder.GetNextLine(nodesInLine[0], true, ref count); 
            }

            string text = "";
            foreach (TextPositionPair range in ranges) 
            {
                Debug.Assert(range.first != null && range.second != null); 
                text = text + TextRangeBase.GetTextInternal(range.first, range.second) + "\r\n"; //CRLF 
            }
 
            return text;
        }