Saturday, December 31, 2005

I created a custom Arc shape a little while back, it's a helpful class that I use for random stuff such as progress controls and time displays.

Source Code

When I was making this, the first problem I ran into was that the geometry is set to fill the shape, but if the arc is something like 45 degrees, then the center would be in the lower left corner and the shape stretched to fill the entire area. Not good. I found just the method to that I needed to override to fix this, but lo and behold, it was internal. In fact, Ellipse overrides four (4!) internal methods.

Internal methods piss me off. Big time. Nothing says 'Design Flaw' like Shape's CacheDefiningGeometry call- virtual with no implementation meaning it's intended to be overriden, but internal.

I'll skip the angry email I sent out to the PM in charge of the area and the response that caused me to completely flip, instead just mention that I have an incredibly lame hack of an invisible diagonal line across the geometry to keep it's size.

Anyways, if you're looking for some tricks on how to use DependencyProperties, how to invalidate your visuals and how to override base functionality, this code may be helpful.
My favorite suggestion dialog in VisualStudio 2005- displayed when a NullReferenceException is thrown:

Now whenever we hit crashes in Sparkle, the question is always 'Did you try using the "new" keyword?'. I'm glad the tip is there, I would have never thought to try that otherwise.