<MyNamespace:FooTextBox x:Name="fooTextBox" Grid.Row="1"/>
<StackPanel Grid.Row="2" Orientation="Horizontal">
<TextBlock Text="{Binding Selection,ElementName=fooTextBox,Converter={StaticResource TextRangeConverter}}" Margin="10,0,0,0"/>
- <TextBlock Text="FindPattern" Margin="10,0,0,0"/>
+ <TextBlock Text="Find" Margin="10,0,0,0"/>
<TextBox Name="FindPattern" Width="100"/>
- <TextBlock Text="ReplaceAll" Margin="10,0,0,0"/>
+ <TextBlock Text="Replace" Margin="10,0,0,0"/>
<TextBox Name="ReplacePattern" Width="100"/>
+ <Button Name="Find" Content="Find" Click="Find_Click" Margin="10,0,0,0"/>
<Button Name="ReplaceAll" Content="ReplaceAll" Click="ReplaceAll_Click" Margin="10,0,0,0"/>
</StackPanel>
</Grid>
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;
}
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
{