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

The Actipro Blog

Tag Cloud

  • blog
  • docking
  • editors
  • intelliprompt
  • micro charts
  • navigation
  • propertygrid
  • ribbon
  • shared library
  • silverlight
  • syntaxeditor
  • themes
  • views
  • web site
  • winforms
  • winrt
  • wpf

Latest Twitter News

May 14, 2012 at 2:50 PM
IntelliPrompt code snippet features have been added to our VS-like code editor control for #WPF and #Silverlight. http://t.co/1IchOJrr

May 10, 2012 at 9:40 PM
Our new Micro Charts control products for #WPF and #Silverlight are out now. Come build some dashboards with them! http://t.co/EEERvff0

May 7, 2012 at 6:47 AM
Today we look at bar charts, for our upcoming #WPF, #Silverlight, and #WinRT Micro Charts product. http://t.co/gxHuPS6B

May 4, 2012 at 6:25 AM
See a gallery of micro area charts in our upcoming release for #WPF, #Silverlight, and #WinRT. http://t.co/qDXGwW8B

May 3, 2012 at 6:32 AM
See a variety of line charts that are easy to make with our upcoming #WPF, #Silverlight, #WinRT Micro Charts product. http://t.co/mbkX6tJd

Twitter Follow us on Twitter

Month List

  • 2012
    • May (9)
    • April (6)
    • March (11)
    • February (11)
    • 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 (321)
  • RSS feed for Blog SummaryBlog Summary (15)
  • RSS feed for GeneralGeneral (43)
  • RSS feed for In developmentIn development (164)
  • RSS feed for New featuresNew features (155)
  • RSS feed for New productNew product (38)
  • RSS feed for PromotionPromotion (2)
  • RSS feed for SilverlightSilverlight (90)
  • RSS feed for Tips and tricksTips and tricks (4)
  • RSS feed for Visual Studio 2008Visual Studio 2008 (2)
  • RSS feed for Windows FormsWindows Forms (22)
  • RSS feed for Windows VistaWindows Vista (10)
  • RSS feed for WinRTWinRT (9)
  • RSS feed for WPFWPF (257)
  • 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 completion list item matching algorithms

February 19, 2009 at 8:38 PM
by Bill Henning (Actipro)

Last week we discussed the concept of prioritized item matching algorithms and yesterday I talked about completion list matched text highlights.

We already have four matching algorithms in place for the default completion list implementation, two of which can be toggled on/off via options.  All the matching algorithms simply implement an interface.

Now wouldn’t it be neat if you could write your own customized matching algorithm? 

Well you can with SyntaxEditor, and it’s so easy too!

A SQL example

Let’s assume you are showing a list of SQL data objects and you want to implement a custom matcher that uses a regular expression to match
any item that has the typed text appearing after a "." or "_" character.  The default starts-with matcher should also be used to match text at the start of each item.

To start you’d make a custom class that inherits our RegexCompletionItemMatcherBase class.

   1: public class CustomCompletionItemMatcher : RegexCompletionItemMatcherBase {
   2:     ...

Next you’d override a GetRegex method to return the Regex to use.

   1: protected override Regex GetRegex(string text) {
   2:     // Make sure the text to highlight is surrounded with parenthesis 
   3:     //   so that SyntaxEditor can locate the captures
   4:     return new Regex(String.Format("[\\._]({0})", Regex.Escape(text)), 
   5:         RegexOptions.IgnoreCase | RegexOptions.Singleline);
   6: }

That’s it!  The RegexCompletionItemMatcherBase base class has all the code in it to automatically match items and highlight matched text based on your Regex.

Here’s what the list looks like at run-time:

CustomMatcher

The custom item matcher in action, with results highlighted

Note that since we typed an L, the LOCATION.ID item was selected.  However you can see that CUSTOMER.LAST_NAME and EMPLOYEE.LAST_NAME also had their L characters highlighted that occurred after a period.  EMPLOYEE.CELL_NUMBER has L characters in it too but our algorithm didn’t match it because the L came after a letter and not a period or underscore.

More advanced implementations

While it is likely that the Regex-based item matcher will provide all the functionality you need for a custom item matcher implementation, sometimes you may require additional logic.  No problem, there is a more low-level CompletionItemMatcherBase base class that lets you implement any sort of logic you desire to match items and return highlighted ranges over item text.  All the base classes implement the ICompletionItemMatcher interface.

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

Related posts

SyntaxEditor for WPF - Advanced completion list filteringWe’re currently working on implementing completion lists in SyntaxEditor for WPF.  Comple...SyntaxEditor for WPF - Completion list matching algorithms“IntelliPrompt completion list” week continues with today’s hot new feature: match...SyntaxEditor for WPF - Completion list text insertionWe’re sad to be ending SyntaxEditor “completion list” blog post week today. :)&nbs...

Comments

February 19, 2009 at 10:01  

Jesper

I love this stuff. Keep it coming.

Jesper

February 21, 2009 at 14:55  

Mike Strobel

Love the possibilities!  Keep the blog posts coming Smile.

Mike Strobel

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