Saturday, September 26, 2009

Google App Engine for JAVA Local Data Viewer!

I've been screaming like a sissy for a local Data Viewer since I put my hands on the Google App Engine. Turns out it has been there for a while (definitely not from the beginning) but I didn't know. It can be accessed when you're running the development server locally from the following URL (assuming you're running the default setup):


You can browse your data and delete records but for the time being (at least on Java App Engine) edit operations are not supported, so don't bin just yet your dirty little hacks (a bunch of servlets in my case) for local development.

Friday, September 4, 2009

How to set WPF ListView or ScrollViewer Scrollbar width

A pretty common dirty hack to modify the scrollbars width is to set the OS value for scrollbars width to whatever you need in your app - this obviously sucks as not only your application will be affected.

In WPF you can override scrollbars width in both ListView and ScrollViewer controls pretty easily with the following XAML markup.

1) Include mscorlib with the sys prefix (or whatever prefix you want) in the page declaration:

<Page x:Class="AtlasPrototype.VehicleIdHistory"
DataContext="{Binding RelativeSource={RelativeSource Self}}"

2) Override vertical scrollbar width resource for the ScrollViewer (exact same for a ListView):

<sys:Double x:Key="{x:Static SystemParameters.VerticalScrollBarWidthKey}">60</sys:Double>
<-- other stuff -->

Sounds all cool and easy but I had to beg work hard on stackoverflow to get this figured out. Show due Respect.

Thursday, September 3, 2009

How to check if WPF is using Hardware or Software Rendering?

In general, software rendering will usually kick-in if your machine doesn't support DirectX or if the drivers installed are not working correctly (for whatever reason). WPF is entirely built on Direct3D, and software rendering means your WPF app will run painfully slow.

In borderline scenarios, such as running on portable device where hardware capability is constrained, you might find yourself in a bit of a mexican standoff situation where you don't know if the bottleneck is the hardware itself or the problem is just that hardware acceleration is not working and the system falls back to software rendering. So, how do you check if software rendering is kicking in?

You can do this from code querying the RenderCapability.Tier property, as follows:
//shifting some 16 bits will do the trick
int renderCapabilityTier = (RenderCapability.Tier >> 16);
The int above can have three possible values:
  • 0 --> you're screwed - no hardware acceleration
  • 1 --> you're half screwed - you got some hardware acceleration
  • 2 --> you're good to go with full blown hardware acceleration
You might also wanna run the DirectX diagnostic tool (just run dxdiag.exe) to double check the state of your hardware acceleration (check the display tab) and, since we are at it, the new WPF profiler.