OSDN Git Service

Testプロジェクトで最初に見つかった文字を選択する機能を追加した
[fooeditengine/FooEditEngine.git] / WPF / Test / MainWindow.xaml.cs
index 58464a7..e812e3f 100644 (file)
@@ -8,6 +8,7 @@
 
 You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
  */
+using System.Collections.Generic;
 using System.Text;
 using System.Windows;
 using System.Windows.Controls;
@@ -242,6 +243,20 @@ namespace Test
             }
             this.fooTextBox.Refresh();
         }
+
+        private void Find_Click(object sender, RoutedEventArgs e)
+        {
+            this.fooTextBox.Document.SetFindParam(this.FindPattern.Text, false, System.Text.RegularExpressions.RegexOptions.None);
+            var it = this.fooTextBox.Document.Find();
+            it.MoveNext();
+            if (it.Current != null)
+            {
+                SearchResult sr = it.Current;
+                this.fooTextBox.JumpCaret(sr.Start);
+                this.fooTextBox.Selection = new FooEditEngine.TextRange(sr.Start, sr.End - sr.Start + 1);
+                this.fooTextBox.Refresh();
+            }
+        }
     }
     public class TextRangeConveter : System.Windows.Data.IValueConverter
     {