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

            //Loop through each character, and place a box over item
            for (var i = start; i < end; ++i)
            {
                var text  = i > 0 ? new string(new [] { textView.TextSnapshot[i - 1], textView.TextSnapshot[i] }) : textView.TextSnapshot[i].ToString();
                var @char = textView.TextSnapshot[i];
                var index = text.Length - 1;
                if (matchingPredicate(text, @char, index))
                {
                    var span = new SnapshotSpan(textView.TextSnapshot, Span.FromBounds(i, i + 1));

                    var g = textViewLines.GetMarkerGeometry(span);
                    if (g != null)
                    {
                        // save the location of this letterTofind to jump to later
                        var key = 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);

                        aceLayer.AddAdornment(AdornmentPositioningBehavior.TextRelative, span, null, letterReference, null);
                    }
                }
            }
        }
Exemple #2
0
        public void if_found_location_IsGreater_than_offsetKeyof_B_Then_Limit_dictionary()
        {
            // one more than z
            var foundKeyLocations = CreateLocations(26 * 26 + 1);

            var letterDictionary = new LetterReferenceDictionary(foundKeyLocations.Count);

            foreach (var keyLocation in foundKeyLocations)
            {
                letterDictionary.AddSpan(keyLocation);
            }
            Assert.AreEqual(1, letterDictionary.GetLetterPosition("A"));
            Assert.AreEqual('B', letterDictionary.OffsetKey);
            Assert.AreEqual("BZ", letterDictionary.LastKey);
        }
Exemple #3
0
        public void if_found_locations_than_Z_then_A_Z()
        {
            //26 is a-z
            var foundKeyLocations = CreateLocations(26);

            var letterDictionary = new LetterReferenceDictionary(foundKeyLocations.Count);

            foreach (var keyLocation in foundKeyLocations)
            {
                letterDictionary.AddSpan(keyLocation);
            }

            Assert.AreEqual(1, letterDictionary.GetLetterPosition("A"));
            Assert.AreEqual(2, letterDictionary.GetLetterPosition("B"));
            Assert.AreEqual(26, letterDictionary.GetLetterPosition("Z"));
        }
Exemple #4
0
        public void if_found_locations_greater_than_z_then_ZA()
        {
            // one more than z
            var foundKeyLocations = CreateLocations(27);

            var letterDictionary = new LetterReferenceDictionary(foundKeyLocations.Count);

            foreach (var keyLocation in foundKeyLocations)
            {
                letterDictionary.AddSpan(keyLocation);
            }

            Assert.AreEqual(1, letterDictionary.GetLetterPosition("A"));
            Assert.AreEqual(25, letterDictionary.GetLetterPosition("ZA"));
            Assert.AreEqual(26, letterDictionary.GetLetterPosition("ZB"));
            Assert.AreEqual(27, letterDictionary.GetLetterPosition("ZC"));
        }
Exemple #5
0
        public void if_found_location_78_then_X()
        {
            // one more than z
            var foundKeyLocations = CreateLocations(26 * 3 + 1);

            var letterDictionary = new LetterReferenceDictionary(foundKeyLocations.Count);

            foreach (var keyLocation in foundKeyLocations)
            {
                letterDictionary.AddSpan(keyLocation);
            }
            Assert.AreEqual(1, letterDictionary.GetLetterPosition("A"));
            Assert.AreEqual(23, letterDictionary.GetLetterPosition("ZA")); // would have been x
            Assert.AreEqual(24, letterDictionary.GetLetterPosition("ZB"));
            Assert.AreEqual(51, letterDictionary.GetLetterPosition("YC"));
            Assert.AreEqual(75, letterDictionary.GetLetterPosition("XA"));
            Assert.AreEqual(76, letterDictionary.GetLetterPosition("XB"));
        }
Exemple #6
0
        public void if_found_location_53_then_YB()
        {
            // one more than z
            var foundKeyLocations = CreateLocations(53);

            var letterDictionary = new LetterReferenceDictionary(foundKeyLocations.Count);

            foreach (var keyLocation in foundKeyLocations)
            {
                letterDictionary.AddSpan(keyLocation);
            }

            Assert.AreEqual(1, letterDictionary.GetLetterPosition("A"));
            Assert.AreEqual(24, letterDictionary.GetLetterPosition("ZA"));
            Assert.AreEqual(25, letterDictionary.GetLetterPosition("ZB"));
            Assert.AreEqual(26, letterDictionary.GetLetterPosition("ZC"));
            Assert.AreEqual(50, letterDictionary.GetLetterPosition("YA"));
            Assert.AreEqual(51, letterDictionary.GetLetterPosition("YB"));
            Assert.AreEqual(52, letterDictionary.GetLetterPosition("YC"));
            Assert.AreEqual(53, letterDictionary.GetLetterPosition("YD"));
            Assert.AreEqual("YD", letterDictionary.LastKey);
        }