Shape Simplification...

Coordinator
Nov 18, 2008 at 9:39 PM
First of all I love the shape layer architecture we have.  In many ways it is very simple & elegant.  However, there is one are has me wondering about simplification.  It is the Shape / ShapeVisual relationship.  So currently Shape inherits just from System.Object and contains a 1:1 reference to it's visual counterpart (a FrameworkElement).  As a DBA 1:1 always raise a red flag, and it makes me think we could collapse and simplify by having the Shape inherit from directly from FrameworkElement.  This could  simplify a lot.  MouseEvents could be handled right off the shape object.  Shape should still be fully extensible via subclassing and templates. 

Thoughts?
Coordinator
Nov 19, 2008 at 12:48 PM
Makes sense...by definition, Shape has a visual aspect, so it would make sense to make it inherit from FrameworkElement. This would also give up a little more flexibility to leverage all the functionality that FrameworkElement gives us (RenderTransform, Depedency Properties, Control Templates, Styles, etc).
Coordinator
Nov 19, 2008 at 12:53 PM
Thought you'd have some good input.  I noticed that you had even changed the reference of PushPin to PushPinVisual from UserControl to FrameworkElement.  This now seems like the logical next step.
Coordinator
Nov 20, 2008 at 2:58 AM
After looking at it, we would probably want to have Shape inherit from either Control or ContentControl so that derived classes could set the DefaultStyleKey property.
Coordinator
Nov 20, 2008 at 4:37 AM
I am with you.  It does need to be Control for Template purposes.  I am about to do a bombshell check in for this change.  This change was more pervasive than I anticipated, so let me know if you find anything out of whack.  Thanks, Rick.
Nov 20, 2008 at 3:21 PM
There is no more PushPinVisual property on the Pushpin class.  So how do I implement custom controls?
Coordinator
Nov 20, 2008 at 5:04 PM
To customize the visual, you apply a your own custom Style Templates to the control.  This is pretty much the best practice since all the System.Windows.Controls use this "Lookless" approach and it provides the best flexibility.  With this approach, you have the ability to create whatever visual look you desire without having to modifiy DeepEarth directly.  There are several ways to apply a custom template, but ultimately, all mechanisms everntually will set the ControlTemplate and optionally the Style property of a control.  One useful mechanism DeepEarth provides to set a default Style on a ShapeLayer is by setting the StyleTemplate prop on the ShapeLayer.  Check out Prototype.GeoServices.GeocodeFind for an example.  Here is the code excerpt:
resultsShapeLayer.StyleTemplate = (Style)this.Resources["PushPinArrow"];
Team. We could probably use more examples of templating.  One idea is to demonstrate templates in the Route example.  Let's say we create for a Green (start) and Red (end) pushpins template.  We could then use these as a cool way to show the route endpoints.  I don't want to bogart all the fun stuff, so anyone what to take this on?