コード例 #1
0
        private void CreateVisualsForLetter(ITextViewLine line)
        {
            //grab a reference to the lines in the current TextView
            IWpfTextViewLineCollection textViewLines = this.textView.TextViewLines;
            int start = line.Start;
            int end   = line.End;

            //Loop through each character, and place a box over item
            for (int i = start; (i < end); ++i)
            {
                if (this.textView.TextSnapshot[i].ToString().ToLower() == this.letter)
                {
                    var span = new SnapshotSpan(this.textView.TextSnapshot, Span.FromBounds(i, i + 1));

                    Geometry g = textViewLines.GetMarkerGeometry(span);
                    if (g != null)
                    {
                        // save the location of this letterTofind to jump to later
                        string key = this.letterLocationSpans.AddSpan(span.Start);


                        // Align the image with the top of the bounds of the text geometry
                        var letterReference = new LetterReference(key, g.Bounds, 12);
                        Canvas.SetLeft(letterReference, g.Bounds.Left);
                        Canvas.SetTop(letterReference, g.Bounds.Top);

                        this.aceLayer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, letterReference, null);
                    }
                }
            }
        }
コード例 #2
0
        public void UpdateLetter(string ch)
        {
            for (int i = 0; i < this.aceLayer.Elements.Count; i++)
            {
                //
                if (this.aceLayer.Elements[i].Adornment is LetterReference == false)
                {
                    continue;
                }

                LetterReference letterReference = (LetterReference)this.aceLayer.Elements[i].Adornment;
                letterReference.UpdateHighlight(ch);
            }
        }