VintaSoft Imaging .NET SDK 10.1
Vintasoft.Imaging.Wpf.UI.VisualTools Namespace / WpfTextSelectionTool Class
Members Example



In This Topic
    WpfTextSelectionTool Class
    In This Topic
    A visual tool that allows to select and search text on PDF or DOCX page in image viewer.
    Object Model
    WpfTextSelectionTool ClassIObjectClipboard InterfaceCopyItemUIAction ClassDeselectAllItemsUIAction ClassTextRegion ClassTextRegionSymbol ClassWpfImageViewer ClassSelectAllItemsUIAction ClassTextRegion ClassTextRegionFormatter Class
    Syntax
    'Declaration
     
    <DefaultPropertyAttribute("Content")>
    <ContentPropertyAttribute("Content")>
    <LocalizabilityAttribute(LocalizationCategory.None, Readability=Readability.Unreadable)>
    <StyleTypedPropertyAttribute(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)>
    <XmlLangPropertyAttribute("Language")>
    <UsableDuringInitializationAttribute(True)>
    <RuntimeNamePropertyAttribute("Name")>
    <UidPropertyAttribute("Uid")>
    <TypeDescriptionProviderAttribute(MS.Internal.ComponentModel.DependencyObjectProvider)>
    <NameScopePropertyAttribute("NameScope", System.Windows.NameScope)>
    Public Class WpfTextSelectionTool 
       Inherits WpfVisualTool
       Implements Vintasoft.Imaging.UIActions.ISupportUIActions 
    [DefaultProperty("Content")]
    [ContentProperty("Content")]
    [Localizability(LocalizationCategory.None, Readability=Readability.Unreadable)]
    [StyleTypedProperty(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)]
    [XmlLangProperty("Language")]
    [UsableDuringInitialization(true)]
    [RuntimeNameProperty("Name")]
    [UidProperty("Uid")]
    [TypeDescriptionProvider(MS.Internal.ComponentModel.DependencyObjectProvider)]
    [NameScopeProperty("NameScope", System.Windows.NameScope)]
    public class WpfTextSelectionTool : WpfVisualTool, Vintasoft.Imaging.UIActions.ISupportUIActions  
    [DefaultProperty("Content")]
    [ContentProperty("Content")]
    [Localizability(LocalizationCategory.None, Readability=Readability.Unreadable)]
    [StyleTypedProperty(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)]
    [XmlLangProperty("Language")]
    [UsableDuringInitialization(true)]
    [RuntimeNameProperty("Name")]
    [UidProperty("Uid")]
    [TypeDescriptionProvider(MS.Internal.ComponentModel.DependencyObjectProvider)]
    [NameScopeProperty("NameScope", System.Windows.NameScope)]
    public __gc class WpfTextSelectionTool : public WpfVisualTool, Vintasoft.Imaging.UIActions.ISupportUIActions  
    [DefaultProperty("Content")]
    [ContentProperty("Content")]
    [Localizability(LocalizationCategory.None, Readability=Readability.Unreadable)]
    [StyleTypedProperty(Property="FocusVisualStyle", StyleTargetType=System.Windows.Controls.Control)]
    [XmlLangProperty("Language")]
    [UsableDuringInitialization(true)]
    [RuntimeNameProperty("Name")]
    [UidProperty("Uid")]
    [TypeDescriptionProvider(MS.Internal.ComponentModel.DependencyObjectProvider)]
    [NameScopeProperty("NameScope", System.Windows.NameScope)]
    public ref class WpfTextSelectionTool : public WpfVisualTool, Vintasoft.Imaging.UIActions.ISupportUIActions  
    Example
    This example shows how to search text in document loaded into WPF image viewer.
    Public Partial Class TextSelectionWindow
        Inherits System.Windows.Window
        ' ...
        Private _imageViewer As Vintasoft.Imaging.Wpf.UI.WpfImageViewer = Nothing
        Private _textSelectionTool As Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool = Nothing
                
                
                
        Public Sub New()
            ' ...
                
            ' create the text selection tool
            _textSelectionTool = New Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool(New System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(56, 0, 0, 255)))
                
            ' subscribe to the text selection tool events
            AddHandler _textSelectionTool.SelectionChanged, New System.EventHandler(AddressOf _textSelectionTool_SelectionChanged)
                
            ' set the text selection tool as the current tool in image viewer
            _imageViewer.VisualTool = _textSelectionTool
        End Sub
                
                
                
        '  Handles the TextSelectionTool.Selection event.
        Private Sub _textSelectionTool_SelectionChanged(sender As Object, e As System.EventArgs)
            ' if text selection is not empty
            If _textSelectionTool.SelectedRegion IsNot Nothing AndAlso Not _textSelectionTool.SelectedRegion.IsEmpty Then
                ' show the text selection content
                System.Windows.MessageBox.Show(_textSelectionTool.SelectedRegion.TextContent)
            End If
        End Sub
                
    End Class
    public partial class TextSelectionWindow : System.Windows.Window
    {
        // ...
        Vintasoft.Imaging.Wpf.UI.WpfImageViewer _imageViewer = null;
        Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool _textSelectionTool = null;
                
                
                
        public TextSelectionWindow()
        {
            // ...
                
            // create the text selection tool
            _textSelectionTool = new Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool(
                new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromArgb(56, 0, 0, 255)));
                
            // subscribe to the text selection tool events
            _textSelectionTool.SelectionChanged += new System.EventHandler(_textSelectionTool_SelectionChanged);
                
            // set the text selection tool as the current tool in image viewer
            _imageViewer.VisualTool = _textSelectionTool;
        }
                
                
                
        //  Handles the TextSelectionTool.Selection event.
        private void _textSelectionTool_SelectionChanged(object sender, System.EventArgs e)
        {
            // if text selection is not empty
            if (_textSelectionTool.SelectedRegion != null && !_textSelectionTool.SelectedRegion.IsEmpty)
                // show the text selection content
                System.Windows.MessageBox.Show(_textSelectionTool.SelectedRegion.TextContent);
        }
                
    }
    Inheritance Hierarchy

    System.Object
       System.Windows.Threading.DispatcherObject
          System.Windows.DependencyObject
             System.Windows.Media.Visual
                System.Windows.UIElement
                   System.Windows.FrameworkElement
                      System.Windows.Controls.Control
                         System.Windows.Controls.ContentControl
                            Vintasoft.Imaging.Wpf.UI.VisualTools.WpfVisualTool
                               Vintasoft.Imaging.Wpf.UI.VisualTools.WpfTextSelectionTool

    Requirements

    Target Platforms: .NET 6; .NET 5; .NET Core 3.1; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also