Improvements to the WPF Snoop Utility

I made a couple of improvements to the WPF Snoop utility that I posted a while ago.  (as before, this is an update to the original created and posted by Peter Blois, with his permission)

Property Filter ComboBox info now comes from config

After publishing the last version with property filter support, I continue to get suggestions from people using the tool for other properties and groups that should be included.  This is obviously begging for the data to be based on configuration, so I dove in and made it so.

It’s not as straight forward as a simple app.config setting, since the code that displays the property grid and needs to know about those property filter groups is running within the process space of the EXE that you’re snooping.  So you still edit the config file that’s in the directory where have snoop.exe installed, but at runtime, the config is read “remotely” from the snooped EXE.

To add/edit property filters, edit snoop.exe.config.  The layout looks like this:

<PropertyFilters>        <add DisplayName="Layout"         PropertyNames="width,height,actual,margin,padding,canvas,align" />        <add DisplayName="Grid/Dock"         PropertyNames="grid,dock" />        <add DisplayName="Color"         PropertyNames="color,background,foreground,borderbrush,fill,stroke" />        <add DisplayName="ItemsControl"         PropertyNames="items,selected" />        <add DisplayName="Text"        PropertyNames="font,align,trim,wrap" /></PropertyFilters>

 

The comma-separated values in the PropertyNames attribute are split and used as case-insensitive substring searches.

Mouse Wheel Property Editing

I just finished a WPF project where we used Visual Studio 2010, and it required lots of WPF canvas layout.  Normally I would fire up Expression Blend to lay things out exactly where I want them, and be done.  Unfortunately, Blend 3 does not (yet) like VS 2010 project files.  So this made for a very tedious couple months of run-time adjustments of elements.  I would run the app, and use Snoop to adjust Canvas.Left/Top, Margin, Width/Height, etc, each time, typing in a new value, seeing the changes in the app.  UGH.

So that was the motivation for this new feature.  Now when you select a property in the property grid, for fields that support discrete changes to their values, you will see an additional copy of the current value in the right edge of the current value column.  The great thing about this copy of the property’s value is that you can mouse wheel over them to CHANGE THE PROPERTY VALUE!

MouseWheelEditing_4CE25570

There are many data types supported:  the obvious int, double, and boolean; and then maybe not so obvious.  Data types supported:

  • Int32
  • Double

(For the above numeric types, the default is to change the value by 1.  Hold down SHIFT while wheeling to change by 10, hold down CTRL while wheeling to change by 0.1)

  • Boolean
  • Thickness
  • Brush
  • Visibility
  • Horizontal/VerticalAlignment

For the “multi-part” data types (Thickness and Brush), you can change individual parts of the property by mouse-wheeling over just that part.

So this ends up giving me a run-time design experience where I can quickly tweak layout and style without a bunch of text typing / editing.

(Thanks to my co-worker Brad, who tested this version and blew it up when trying to mouse-wheel edit a LinearGradientBrush background.  Types that derive from supported types (i.e. GradientBrush from Brush) that are not supported are listed in the config file and can not be edited with the mouse wheel.  In the case of GradientBrush, you CAN delve into the GradientBrush, to the GradientStops, use the Indexer feature added last time, and then adjust the color or offset of an individual stop at runtime!!)

The Bits

The binaries – one folder for 32-bit and one for 64-bit.

The source code for the solution.

Give it a try!  Hope you like it.

One thought on “Improvements to the WPF Snoop Utility

  1. Pingback: InterKnowlogy Blogs » Blog Archive » Snoop 2.7.0

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>