• Products
  • Download
  • Purchase
  • Support
  • Company
Actipro Software company logo
Twitter Follow Actipro RSS Subscribe (RSS Feed)

The Actipro Blog

Tag Cloud

  • aero
  • blog
  • docking
  • editors
  • gauge
  • intelliprompt
  • navigation
  • propertygrid
  • ribbon
  • shared library
  • silverlight
  • syntaxeditor
  • themes
  • views
  • winforms
  • wpf

Latest Twitter News

November 21, 2011 at 11:14 AM
#WPF Studio 2011.2 is out now! Includes enhanced themes for native WPF conrtols and new SyntaxEditor features. http://t.co/uEMCaGPG

September 26, 2011 at 1:25 PM
If you'd like to see our #WPF / #Silverlight SyntaxEditor code editor control ported to Metro, provide feedback here: http://t.co/xXBNIDTi

September 15, 2011 at 8:31 PM
If you want to see SyntaxEditor eventually show up in Win8's #xaml UI, be sure to add your support to this MS thread: http://t.co/FBjz6TuC

August 15, 2011 at 1:47 PM
New SyntaxEditor IntelliPrompt parameter info feature docs/samples ready for the 2011.2 #WPF and #Silverlight releases. http://t.co/ezoYIjv

August 2, 2011 at 2:40 PM
First look at new automated IntelliPrompt parameter info coming to our C#/VB editor control in #WPF / #Silverlight http://t.co/CUz6O1T

Twitter Follow us on Twitter

Month List

  • 2012
    • February (3)
    • January (2)
  • 2011
    • December (2)
    • November (7)
    • October (2)
    • September (1)
    • August (5)
    • July (3)
    • June (6)
    • May (5)
    • April (8)
    • March (4)
    • February (5)
    • January (9)
  • 2010
    • December (9)
    • November (10)
    • October (4)
    • September (8)
    • August (12)
    • July (9)
    • June (7)
    • May (6)
    • April (7)
    • March (6)
    • February (6)
    • January (4)
  • 2009
    • December (2)
    • November (2)
    • October (12)
    • September (3)
    • August (11)
    • July (10)
    • June (6)
    • May (3)
    • April (7)
    • March (6)
    • February (8)
    • January (10)
  • 2008
    • December (10)
    • November (2)
    • October (3)
    • September (5)
    • August (5)
    • July (8)
    • June (4)
    • May (4)
    • April (10)
    • March (8)
    • February (1)
    • January (2)

Category List

  • RSS feed for ActiproActipro (289)
  • RSS feed for Blog SummaryBlog Summary (13)
  • RSS feed for GeneralGeneral (34)
  • RSS feed for In developmentIn development (150)
  • RSS feed for New featuresNew features (140)
  • RSS feed for New productNew product (30)
  • RSS feed for PromotionPromotion (2)
  • RSS feed for SilverlightSilverlight (71)
  • RSS feed for Tips and tricksTips and tricks (4)
  • RSS feed for Visual Studio 2008Visual Studio 2008 (2)
  • RSS feed for Windows FormsWindows Forms (20)
  • RSS feed for Windows VistaWindows Vista (10)
  • RSS feed for WPFWPF (235)
  • RSS feed for XAMLXAML (23)

About Us

Actipro Software is a leading provider of .NET user interface controls for the WPF, Silverlight, and WinForms frameworks, and is most well-known for their SyntaxEditor syntax-highlighting code editor control.

Please take some time to learn more about us and our product offerings.

SyntaxEditor for WPF - Custom search pattern formats

April 6, 2009 at 2:28 AM
by Bill Henning (Actipro)

Based on some of the feedback we got from our last blog post on find/replace functionality, we’ve implemented a new extensibility feature in SyntaxEditor for WPF: custom search pattern formats. 

What is a search pattern format?

A search pattern format is a syntax for entering how to find and replace text within a document.  SyntaxEditor for WPF ships with three built-in formats:

  • Normal is a plain text find and replace format.
  • Regular Expression use regular expressions to match find text, and uses regular expression replace pattern syntax to allow for replacements at different matched capture points in the find pattern.
  • Wildcard uses simple wildcard search patterns to match text.

These three options are available from static properties on the SearchPatternProviders class.  They all implement the ISearchPatternProvider interface.

How to use them?

All find/replace operations take an ISearchOptions instance.  One of the properties on that interface is called PatternProvider.  You can pass any instance of ISearchPatternProvider to that property to indicate how to interpret the find and replace patterns.

The find/replace UI control that was introduced in the previous post lets the end user choose which pattern provider to use.

Now for the neat part, you as a developer can make custom search pattern providers if you wish to support a custom pattern format.  And the find/replace UI control can include your custom providers in the drop-down list.

Implementing a custom ISearchPatternProvider

The ISearchPatternProvider interface has several members.  One is a string Key that identifies it.  Another is a more verbose Description that can be displayed in user interfaces.  Then there are two methods that must be implemented:

   1: /// <summary>
   2: /// Returns the regular expression match pattern to use for find operations, 
   3: /// based on the supplied pattern that uses this provider.
   4: /// </summary>
   5: /// <param name="pattern">The pattern to convert using this provider.</param>
   6: /// <returns>The regular expression match pattern to use for 
   7: /// find operations.</returns>
   8: string GetFindPattern(string pattern);
   9:  
  10: /// <summary>
  11: /// Returns the regular expression match pattern to use for replace operations, 
  12: /// based on the supplied pattern that uses this provider.
  13: /// </summary>
  14: /// <param name="pattern">The pattern to convert using this provider.</param>
  15: /// <returns>The regular expression match pattern to use for 
  16: /// replace operations.</returns>
  17: string GetReplacePattern(string pattern);

The core search code uses our built-in regular expression engine to perform searching.  Therefore search patterns to our search code must be provided in regular expression syntax.

So what ISearchPatternProvider’s two methods do is provide a conversion from your custom pattern format to a regular expression equivalent.  Regular expression substitutions are fully supported too if you wish.

An example

Say that you make a custom pattern format where the find text is normal text except that the _ character has been changed to mean any digit character.

To accomplish this, you’d make a custom ISearchPatternProvider that implements a GetFindPattern method that regular expression escapes all the normal text, except converts the _ character instances to [0-9], which means any digit.

Therefore once implemented, if the end user chooses your custom pattern provider and they use this find pattern:

$_.__

The result of your GetFindPattern conversion to regular expression format would be:

\$[0-9]\.[0-9][0-9]

This would match any $ character followed by a single digit, then a period, then two more digits.

Of course that is a simple sample, but you could easily create your own robust format.  This sort of extensibility functionality is what you’ll find throughout the SyntaxEditor for WPF product.

Tags: wpf, syntaxeditor
Filed under: Actipro, In development, WPF
Submit to DotNetKicks...
Permalink | Comments (1)

Related posts

SyntaxEditor for WPF - Two additional search pattern providers addedWe’re on the home stretch, finalizing the features that will be available for the public beta ...Actipro SyntaxEditor for WPF and Editors for WPF are released SyntaxEditor for WPF with a custom theme loaded Yesterday evening we published WP...SyntaxEditor for WPF - Context-based custom classificationOne highly requested feature over the years has been to allow a way to customize or alter the highli...

Comments

August 18, 2009 at 08:04  

trackback

Actipro Blog 2009 Q2 posting summary

Actipro Blog 2009 Q2 posting summary

The Actipro Blog - WPF and WinForms Development

Comments are closed
Copyright © 1999-2012 Actipro Software LLC. All rights reserved.
Home Actipro Software | Products | Download | Contact Us