• 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 adds robust hit testing features

August 26, 2009 at 10:07 AM
by Bill Henning (Actipro)

The lastest build of SyntaxEditor for WPF added a very robust hit testing feature.  This is something that has been in the WinForms version for SyntaxEditor for a while and has been highly requested by our WPF customers.

The feature allows you to provide a Point (generally a mouse location) and SyntaxEditor returns detailed information about what is under the Point.  You can get offsets, text positions (line/col), text, tokens, etc. 

How does it work?

A hit test can be performed by first obtaining a Point relative to the SyntaxEditor's coordinates and then calling the SyntaxEditor.HitTest method.  This method returns an object of type IHitTestResult.

   1: IHitTestResult result = editor.HitTest(Mouse.GetPosition(editor));

The hit test result

The IHitTestResult object contains information about exactly what is at the location being hit tested.  It has a Type property that provides a high-level categorization about the result, such as does the result specify the location was over a character in the text area, over a margin, over a splitter or scrollbar, etc.

A VisualElement property provides a reference to the FrameworkElement that was used as the result.  So if the location was over a ScrollBar, that is what would be returned in this property.

When the location is over an IEditorView, that view is returned in the View property.  If the location is over a margin in the view, the related IEditorViewMargin is returned in the Margin property.

If the location is over a character in a view’s text area, the Offset and Position properties are filled in with the exact position of the character within the view’s Snapshot (also made available in the result).  If the location is not directly over a character (such as when it is over a margin), the Offset and Position of the closest character is returned.  The Type property can be used to determine if the location was over a character or not.

There also is a helpful GetReader method that returns an ITextSnapshotReader initialized to the Offset.  This allows you to instantly get the character at the offset, or get the token there.  You can navigate around the Snapshot’s text/tokens using the reader.

The new hit testing QuickStart

We’ve added a QuickStart to demo the new hit testing feature.  As you move the mouse over anything in the SyntaxEditor instance (splitters, scollbars, margins, text area, etc.), the TextBox below it displays details about the hit test result.

HitTesting

In the screenshot above, the mouse cursor is over the r in the word QuickStart on line #7.  The hit test information is telling us the snapshot version at the time of the hit test, which view it’s over, the offset and text position (both zero-based), the character, and information about the token that contains the offset.

Summary

As you can see, we’ve built this hit testing mechanism so that the result gives you everything you need to know about what is at a particular location.  It is extremely useful for reacting to mouse move or hover events.

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

Related posts

WPF Studio integrates with and adds features to the official Microsoft WPF DataGridIn the most recent WPF Studio 2009.1 builds, we've integrated with and enhanced Microsoft's open sou...WPF Studio 2009.1 build 503 adds major new SyntaxEditor and Docking/MDI featuresWPF Studio build 503 was just released and includes a lot of updates to our WPF products, some being...SyntaxEditor for WPF’s MGrammar add-on adds AST construction and error reporting featuresSyntaxEditor for WPF, our syntax-highlighting code editor control, has just made some big improvemen...

Comments

October 1, 2009 at 09:41  

trackback

Actipro Blog 2009 Q3 posting summary

Actipro Blog 2009 Q3 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