コード例 #1
0
        public void OptionFlipping()
        {
            RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel();

            model.Query = new Query("some more");
            model.FindOptions.IgnoreWhitespaceCharacters = false;
            List <Run> runs = new List <Run>();

            runs.Add(new Run("some more"));
            Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer container = new Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer(runs);

            model.FindText(container);
            model.SelectNextMatch();
            Assert.AreEqual(model.CurrentMatch.AbsoluteEnd, 9);
            Assert.AreEqual(model.CurrentMatch.AbsoluteStart, 0);



            model.FindOptions.IgnoreWhitespaceCharacters = true;
            model.FindOptions.IgnoreWhitespaceCharacters = false;

            model.Query.QueryText = "some more ";
            model.FindText(container);
            model.SelectNextMatch();


            model.Query.QueryText = "some more";
            model.FindText(container);
            model.SelectNextMatch();
            Assert.AreEqual(model.CurrentMatch.AbsoluteEnd, 9);
            Assert.AreEqual(model.CurrentMatch.AbsoluteStart, 0);
        }
コード例 #2
0
        public void Match_Wildcard_Replace2()
        {
            List <Run> runs = new List <Run>();

            runs.Add(new Run("TextBox search word"));
            runs.Add(new Run("TextBox"));
            runs.Add(new Run("TextBox"));
            runs.Add(new Run("Hello"));
            runs.Add(new Run("here is some more"));
            runs.Add(new Run("and some more"));

            RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel();

            model.FindOptions.UseWildcards = true;
            Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer container = new Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer(runs);
            model.Query = new Query("r*");
            model.FindText(container);


            model.SelectNextMatch();
            Assert.AreEqual("r", model.CurrentMatch.Text);
            Assert.AreEqual(runs[0], model.CurrentMatch.Run);
            //model.ReplaceMatch("   ");
            model.ReplaceAllMatches("   ");

            Assert.AreEqual("TextBox sea   ch wo   d", runs[0].Text);
        }
コード例 #3
0
        public void Match_Wildcard_Replace()
        {
            List <Run> runs = new List <Run>();

            runs.Add(new Run("1aa1 2222 1aa1"));
            runs.Add(new Run("3333 4444"));
            runs.Add(new Run("5555 6666"));
            runs.Add(new Run("7777 8888"));
            runs.Add(new Run("9999 aaaa"));

            RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel();

            model.FindOptions.UseWildcards = true;
            Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer container = new Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer(runs);
            model.Query = new Query("1*1");
            model.FindText(container /*, new Query("33([0-9])3")*/);


            model.SelectNextMatch();
            Assert.AreEqual("1aa1", model.CurrentMatch.Text);
            Assert.AreEqual(runs[0], model.CurrentMatch.Run);
            model.ReplaceMatch("abcdefg");

            Assert.AreEqual("abcdefg 2222 1aa1", runs[0].Text);


            Assert.AreEqual(runs[0], model.CurrentMatch.Run);
            model.ReplaceMatch("abcdefg");
            Assert.AreEqual("abcdefg 2222 abcdefg", runs[0].Text);
        }
コード例 #4
0
        public void Match_Regex_Replace()
        {
            List <Run> runs = GetTestRuns();
            RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel();

            model.FindOptions.UseRegularExpressions = true;
            Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer container = new Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer(runs);
            model.Query = new Query("33([0-9])3");
            model.FindText(container /*, new Query("33([0-9])3")*/);


            model.SelectNextMatch();
            Assert.AreEqual(runs[1], model.CurrentMatch.Run);
            model.ReplaceMatch("xx$1");

            Assert.AreEqual("xx3 4444", runs[1].Text);

            //also need to fix single line tb when highlight goes outside of box width
        }
コード例 #5
0
        public void FindDoubleSpace()
        {
            RapidFindReplaceControlViewModel finder = new RapidFindReplaceControlViewModel();

            System.Collections.Generic.List <Run> runs = new System.Collections.Generic.List <Run>(5);
            //FindRuns(content.Blocks, runs);
            runs.Add(new Run("a  a"));
            runs.Add(new Run("T"));

            RunCollectionContainer coll = new RunCollectionContainer(runs);


            finder.Query = new Query("  ");
            finder.FindText(coll);

            finder.SelectNextMatch();


            Assert.AreEqual(1, finder.CurrentMatch.AbsoluteStart);
            Assert.AreEqual(3, finder.CurrentMatch.AbsoluteEnd);
        }
コード例 #6
0
        public void Match_Standard_Replace()
        {
            List <Run> runs = GetTestRuns();
            RapidFindReplaceControlViewModel model = new RapidFindReplaceControlViewModel();

            Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer container = new Keyoti.RapidFindReplace.WPF.FindHandlers.RunCollectionContainer(runs);
            model.Query = new Query("1111");
            model.FindText(container /*, new Query("33([0-9])3")*/);


            model.SelectNextMatch();
            Assert.AreEqual(runs[0], model.CurrentMatch.Run);
            model.ReplaceMatch("1");

            Assert.AreEqual("1 2222 1111", runs[0].Text);

            model.ReplaceMatch("1");

            Assert.AreEqual("1 2222 1", runs[0].Text);

            //also need to fix single line tb when highlight goes outside of box width
        }