Microsoft guy gets an iPhone [0]

by Administrator 15. December 2008 05:31

So, this weekend involved a road trip to Missouri for some family business - namely seeing my grandfather while he's still see-able.  A fringe benefit of making this trip was that my mother had received an iPhone from my uncle (confused yet?) and she didn't want to pay for the data plan.  So, guess who has an iPhone now?

I bleed Microsoft red.  I chuckle at the fantastic claims of Mac addicts.  Still, I've seen the iPhone in action and it seemed to be a nice little device. 

Inflammatory statement #1: Unlike many of the Microsoft-hating Mac-worshipers and Java fiends, I still have a solid core of objective thought and rational epistemology.  By this I mean merely to say that I'm not going to forego what may be a really nice gadget just because Apple makes it.

First Impressions

Obviously the thing is sexy.  It's curvy; it's sleek; it's reassuringly heavy for such a small and fragile looking item.  The sexiness is the first clue that this is a different thing made for different people than, say, my AT&T Tilt.  I can't remove or replace the battery.  I don't see a place to add a storage card.  I can't insert my SIM card without surgical tools.  Apple does not make products for "Tweakers".  This is meant to be a "finished product"; future be damned.  Still, towards this goal it's clear the device isn't cheap.  It's got 16gb of internal storage and feels like it's well made. 

From initially playing around, it seems easy enough to find settings and launch programs.  Like Windows Mobile, it takes some getting used to not needing to "close" a program, just hit the Square button to return home and move on to the next thing.  While I maintain I'm objective in terms of technology, I can't claim to be objective in terms of Gadget Discoverability.  I have used far too many gadgets for far too long and written too much software to have a good sense of how usable the Average Dude would find the iPhone, but I expect it's very usable.

Since this was "gently used" before landing in my hands, the first thing I did was look into some kind of Ultimate Cold Boot so I didn't have to manually remove my uncle's bizarre mix of Dragonball Z soundtracks and bad 80s metal or contacts and text messages.  To my delight there is in fact a "Totally erase everything" button, which I did.

Setting Up

I have become very dependant upon Outlook synchronization for my Tilt (and 3 smartphones before that) so I did make sure there was some way to sync Outlook contacts & calendar to this thing before accepting it.  This is done through iTunes.

Huh? iTunes?

Yes, Outlook synchronization on vista is accomplished via iTunes.  I'm not sure why this would be.  Is iTunes the only foothold Apple has on Windows?  Are they trying to trick me into using iTunes?  Do they assume anyone with an iPhone must be using Vista only because of some dire need and they're trying to supply a pleasant all-in-phone experience?  I'm not sure.  What I am sure of is this is where my double-standard detector started going apeshit.  This "Duh, you need to have iTunes to move contacts to your phone" type of thing is precisely the sort of behavior that Microsoft has routinely been crucified for no matter what explanation is offered.  I chuckled to myself, chose not to go to the iTunes store on launch, and plugged in the iPhone.

I was greeting with an appropriate settings screen asking me when and what and how much I wanted to move from Outlook to the iPhone.  I expected as much based on Active Sync Mobile Device Center and chose not to move anything yet until I'd felt my way around.  I also see that I need to download a new iPhone software version which is not surprising since my family elders previously owned this gadget.  I was shocked and amazed at how long it took me to grab this and maybe I'm mentally fried from the long car ride today but it wasn't easy to see where I could find the download status of this 250MB update.  I've managed to have two glasses of wine and write this entire article up to this point while waiting for something to happen.   I just downloaded 67MB of iTunes and I'd say this was about 10x slower byte for byte.

I now have a progress bar on the iPhone.  It's moving as slow as paint drying but I've done phone updates before so this comes as no surprise.

On to the past

While I wait on the update, some more early impressions. 

From my hotel in SmallTown, USA I was able to get on WiFi and mess around with this thing even though I had not yet moved a SIM card to it.  Based on the commercials, two things immediately struck me.  First, even on 10MB WiFi, the thing is not remotely as fast as you see on TV.  This, in fact, resulted in a huge "truth in advertising" lawsuit in the UK when a magazine showed that what takes 20 seconds on TV in fact takes nearly 3 minutes with a 3G iPhone.  Here in America, though, Apple can do no wrong so I doubt any such challenges are coming.  The second thing I noticed was that I expected nearly everything to respond with screen orientation changes when I tilted the thing, but found only Safari gratifies this and only after thinking about it for a while. 

Speaking of Safari, this is one of the places where this device shines.  While there's certainly no reason for me to run Safari on my desktop, the rendering and scaling of web content on the iPhone is top notch so far.  I just re-did my blog skin with a lot of painful CSS work to appease both Firefox 2 and IE7, and was very pleased to see DamonPayne.com show up perfectly on the iPhone.  The previous owner did not have DamonPayne.com bookmarked (WTF? Does he live under a rock?)  so getting there involved some typing.  As someone who's used and evaluated eleventeen-brazilian mobile devices in the past ten years I was pleasantly surprised at the near-usability of the on-screen keyboard.  Tactile-response is still king in my book but the iPhone keyboard was tolerable.

Back to Freedom Zero

My iPhone has finally updated itself and, though I have been playing with the damned thing for two days with no SIM card in it, I am now met with a screen which won't let me do anything until I insert a SIM card.  Jeff Atwood's Freedom Zero post is appropriate here.  It's getting late and I need my beloved Tilt for meetings tomorrow, so I'll try quitting the Tilt cold-turkey tomorrow afternoon and see what happens.

My wife is drooling over my Tilt (she has various Medical software for WinMobile) and my Zune so I need to make this transition happen stat.  I haven't told her she's not getting the Zune because I'll use iTunes when it's the last way to listen to music on planet earth.  One thing at a time.

Tags:

Argentum Tela Design Surface[18]

by Administrator 12. December 2008 00:26

The AGT (Argentum Tela) series of articles is an effort to do two things. Usually an idea is presented only in its finished form. The first goal is to do some Reality Blogging, to show an idea evolve over time without pulling any punches. The second goal, and the example vehicle for the evolution aspect, is an extensible Design Surface for Silverlight similar to what we have in Visual Studio 2008. This type of application has all sorts of interesting uses. My example is a Home Theater layout tool. Read the entire saga: http://www.damonpayne.com/2008/09/14/RunTimeIsDesignTimeForAGT0.aspx

Yes, I changed the name of the article.  Here at the 19th step, I decided to ditch the old tagline.

Visual and Code Refactoring

After letting Property Editing sit for too long, I have a list of questions to answer and things I've been meaning to fix or refactor.  I publish these Refactoring articles as part of the Reality Blogging commitment but also in case some of the random code is useful to anyone.  Let's get started.

 

Visual Lasso

I don't know why I had a corner radius on the Visual Lasso, I was probably suffering from some Web2.0itus which I am now over.  I change this and changed the colors:

Vision18

The lasso was also crashable by drawing diagonally until the lasso size would involve negative numbers.  This is fixed.

 

Some Questions

I have gotten some questions from interested parties, which I'll answer here.

  • How about a better constructor for LogMessage?
    • Sure.  More constructors provided
  • Where is IDragDropmanager.RemoveDropTarget?
    • Missing.  I can be very focused trying to get these articles out sometimes.  This has been added.
  • In Page.xaml.cs in the example application, why are you resolving IRegionManager when the Page is the IRegionManager implementation?
    • Force of habit, and I was unsure how I was going to leave that.  And there's nothing wrong with talking to yourself using a Contract...
  • Why are the names inconsistent between IPageView and RootPresenter ?
    • Shameful inconsistency.  IPageView has been renamed to IRootView.
  • Why are the names of the Region Controls in Page.xaml not the same as the Regions themselves?
    • More inconsistency.  They are all named XXXRegion now.  As I looked at this I also wondered why I was using Canvas and not a ContentPresenter, possibly something to do with how much ContentPresenter was chaning in Beta2-->RC0.  At any rate, the regions have good names and I've switched to ContentPresenter.
  • In IRegionManager, what is the difference between RootVisual and TopLevelContainer?  Why do you need both of them?
    • RootVisual is meant so that IRegionManager could provide something to System.Windows.Application.RootVisual, and matches its type of UIElement.  I could probably rename this to ApplicationRootVisual since that is the only reason to have this.  TopLevelContainer is used as the main Playground of services that need to do something visually, like DragDropManager.  This isn't as bad as it first seems, for example the built-in "Popup" class must do something very similar.  Comments have been added.

The Border on DesignSite

When is five minus five not zero?  When you have applied a RenderTransform to a FrameworkElement.  For the border on DesignSite, I would move the control by the border thickness (5px) when I would hide or show the border.  Once you have applied a RenderTransform, though, changing a Canvas.XXXProperty by 5px no longer means 5px.  I fixed this by using a transparent and normal border rather than by changing the border thickness from 0 to 5 to show selection.

 

~Creative Commons

Since I had to choose from a list of licenses on Codeplex (I chose MS-PL) I am removing the creative commons snippets from the code as I see them.

 

Clipping

The Canvas does not clip its children.  This means you can drag controls all over the place outside of the Design surface which is obviously undesirable.

Refactor: I extracted a MouseMoveSelection method and made it virtual so the logic was not totally hidden inside an EventHandler.  This method ultimately calls MoveSelection

I needed to make a decision here, to either create a class that extends Canvas or Panel and does perform some form of clipping on its Children, or to simply implement boundaries within the DesignSurface class.  For now I went with enforcing the bounds in code and snapping the selection back to a valid value.

Floating Properties

I went back and finished implementing my original intention for the PropertyGrid, namely that it would float around with the selection and not be statically docked to the right of the surface.

Refactor: I had a TODO item to un-hack the relationship between IDesigner and DesignSite.  Since IDesigner defines a Surface property of type Canvas this was mostly already done.  DesignSite.DesignParent is now of type IDesigner.

Refactor: Some methods, like GetSelectionBounds(), seemed to belong more on IDesigner than DesignSite after the above change was made.

What I sought to do next was pretty vanilla: if IDesignEditorService.Visual currently had a parent, I would remove it from its parent and add it to IDesigner.Surface or IRegionManager.TopLevelContainer in a location close to the right bounds of the current selection.  Control.Parent and VisualTreeHelper.GetParent both have a return type of DependencyObject.  It seems there is no generic way to remove a FrameworkElement from its visual parent.

DamonPayne.AG.IoC.ControlExtensions  now has a RemoveFromParent() extension method.

The PropertyGrid now floats around to be close to the current selection.

Vision19

 

Bigger Surface

In order to set things up for some future articles, I have change the default size of the DesignSurface and the sample application.  Yes, this means it won't fit on a 1024x768 screen, which apparently some people still have even in this late hour.  We'll fix this in a future article but for now I wanted more room to play.

 

A better Toolbox

The way gestures worked in the toolbox had been bothering me, and I thought I could make it better looking anyway, a little more like Visio perhaps.  I nearly introduced an external dependency on the Silverlight Toolkit, but wanted to see how to do this myself instead.  Given the amount of space I'm working with, I needed to add some more furniture.  I have created an area rug, which I feel really ties the room together.

I created a Control extending Panel, WrapLayoutPanel, to property postion them items in my new and improved toolbox.  The MSDN documentation for MeasureOverride and ArrangeOverride was simple, but surprisingly helpful.

Here's the new and improved toolbox:

Vision20

 

  Conclusion

I've finally gotten around to fixing a number of things that have been bothering me, and I think the application looks a little better too.  I am having a hard time deciding what to do next, and I'm afraid the next two installments are not going to be very sexy, but will be very necessary to tie all the concepts together.

The changes in this article are published as version 0.7.18, Codeplex change set 8710.  While things are still very rough, I did go ahead and make this the default public release on Codeplex.

The live demo has been updated at http://www.damonpayne.com/agt

Tags:

Reggie Burnett speaks out on Entity Framework support

by Administrator 6. December 2008 17:37

Reggie Burnett of MySQL fame has finally spoken out on the oft-promised, never-delivered Entity Framework support coming in the 6.0 version of MySQL connector .NET.  You can comment here.

I wanted to post this as I am sure there are many people here who feel like they have been mislead. I can assure you that you have not been intentionally mislead. The 6.0 release that will have entity framework support was supposed to be out over 1 month ago. It was been delayed mainly for licensing reasons. There is a large chunk of code that we are planning to include in that release that is licensed as MS-PL and the MS-PL is not compatible with the GPL. I have some program managers and our legal department working on it and hope we can find an answer very soon.
I am very sorry for the delay and appreciate your patience. I am very committed to the .NET/Mono community and have been given full support from Sun. I have also been told that I will perhaps be getting some additional developer support in the near future. That will certainly help to speed things up.
Again, I apologize for the delay. I am not trying to duck your questions in this forum but have just been working hard on the 6.0 release. Even with the delay I think everyone will be pleased with it. The main features are:
1. Completely rewritten visual studio integration with improved table editing including change script generation
2. Improved performance of the connector in many scenarios (faster than libmysql in some cases). This is a _very_ big deal.
3. Entity framework support

That's good news!  Working for corporations with legal departments often means being extremely careful of what one says in the public forum so I'm willing to give Reggie the benefit of the doubt for his radio silence on certain topics.   This means I can actually start moving ahead on some personal projects of mine that use MySQL for $$ reasons.  MySQL should be ready to rock before I am done fighting with CSS.

Tags:

On The Market

by Administrator 5. December 2008 20:22

I have removed my previous comments regarding certain events.

Myself as well as some other folks, were impacted by a reorganization.

At this point I'm looking to start networking; I'm looking for my next opportunity.  I have posted my resume below.  If you need a Software Architect, technical team lead, or a Web/Silverlight/WPF/WinForms/parallelism/Mobile developer I'm available in January.

I am also collecting the personal contact information of my current teammates in order to hopefully help them make connections.  If you are looking for some great graphic designers, a Scrum Master, support & fulfillment personnel, or expert LAMP-stack developers, I can put you in touch with some great folks that I can vouch for.

Resume posted here.

Tags:

MSDN DevCon

by Administrator 4. December 2008 20:23

I will be at the "Mini PDC" MSDN developer conference on January 13th in Chicago, IL. 

http://msdndevcon.com/Pages/Chicago.aspx

It looks like I know several of the speakers and some of the content has likely already been seen online, but I'm eager to see this stuff in person and getting Windows 7 Beta is worth the train ride down!  The PDC was huge this year and it's nice to have a chance to hit the highlights.

I'm thinking a reservation at Fogo de Chão will be in order for after the show...

Tags:

Run time is design time for AGT[17]

by Administrator 2. December 2008 21:57

The AGT (Argentum Tela) series of articles is an effort to do two things. Usually an idea is presented only in its finished form. The first goal is to do some Reality Blogging, to show an idea evolve over time without pulling any punches. The second goal, and the example vehicle for the evolution aspect, is an extensible Design Surface for Silverlight similar to what we have in Visual Studio 2008. This type of application has all sorts of interesting uses. My example is a Home Theater layout tool. Read the entire saga: http://www.damonpayne.com/2008/09/14/RunTimeIsDesignTimeForAGT0.aspx

 

Finishing Property Editing

In the last article, I mentioned the need for some more complex test cases to use to help determine when Property Editing was done.  I could see that too much logic was living in EditServiceHelper and that the editing of properties for multiple items at once was going to become very difficult.  It has been far longer than I intended since the last article (user group presentations, etc.) and there's a lot of cool stuff we can get to after we get Property Editing working the rest of the way so let's get to it.

A Better Example

A much better example was required right off the bat.  This required some more up front thought and setup.  Each Property potentially has a Display Visual and an Edit Visual, and in some cases these may be the same instance.  I need to test some reasonable scenarios:

  1. If multiple items are selected that happen to have a Property with the same name and of the same type and with the same Editors we can edit this Property for all selected items with a single Edit Visual even if the items are not of the same Type.  Only the lowest common denominator of Properties should display.
  2. Basic edit scenarios: an Enum Property is editable in a ComboBox, a string Property is Editable in a TextBox, and so forth.
  3. In some cases the Display Visual will be a custom IDesignablePropertyVisualizer Type which should support some kind of Binding so it auto-updates when edited.
  4. In some cases the Edit Visual will be a custom IDesignablePropertyEditor Type which should support binding as well as setting the value to the actual object on loss of focus or Enter key.
  5. Refactor: It seems clear at this point that since I'm heavily using Bindings, IValueConverter will come in handy, so this has been added to DesignablePropertyDescriptor.

In order to test all of this I'll make the following changes:

  • Couch and Chair will get a Softness property of type Double which I'll edit with a custom slider.  This should work for single or multi selection. (Tests #1, #4)
  • Softness will be displayed with a custom "volume style" Visualizer (Tests #3)
  • The Color property of Chair & Couch will get a Converter that displays a Color name instead of the hex value as shown in the previous article. (Tests #1, #2, #5)

Beyond this, we'll simply need to think about the various "basic" edit scenarios to support, like editing boolean values with a radio button or checkbox.  I've added "Editors" and "Visualizers" namespaces to the DamonPayne.HTLayout project and created the requisite implementations.

 

PropertyGridModel

The various private fields I had been adding to PropertyGrid for keeping track of various states and such clearly needed to be moved to a single class which I now call PropertyGridModel.  All of the methods are virtual to allow enterprising developers to easily tweak behavior.  The public interface for PropertyGridModel :

/// <summary>
/// What are we editing?
/// </summary>
public virtual List<IDesignableControl> Selection { get; set; }
/// <summary>
/// Properties common across the entire Selection
/// </summary>
/// <param name="props"></param>
public virtual void SetProperties(List<DesignablePropertyDescriptor> props)

 

/// <summary>
/// Only 1 property is editing at a time
/// </summary>
public FrameworkElement CurrentEditElement { get; set; }
public virtual void SetDisplayElement(DesignablePropertyDescriptor d, FrameworkElement fe)...
public virtual FrameworkElement GetDisplayElement(DesignablePropertyDescriptor d)...
public virtual List<FrameworkElement> GetAllDisplayElements()...
public virtual void SetEditElement(DesignablePropertyDescriptor d, FrameworkElement fe) ...
public virtual FrameworkElement GetEditElement(DesignablePropertyDescriptor d)...
public virtual DesignablePropertyDescriptor GetDescriptorForEditElement(FrameworkElement fe)...
public virtual DesignablePropertyDescriptor GetDescriptorForDisplayElement(FrameworkElement fe)...
/// <summary>
/// Remove everything from the Model
/// </summary>
public virtual void Reset()...

 

EditServiceHelper

I continued by overhauling the EditServiceHelper class.  I realized my notion of the TypeDescriptor-like functionality of this class was not fully baked, but sitting down to look at it the second time a much more cohesive purpose coalesced.  I also made sure to pull in the concepts of IDesignablePropertyEditor and IDesignablePropertyVisualizer right away.  I'm only going to show the Display path and no the Edit path here for brevity, they are very similar.

In a static constructor we set up some defaults, this will be expanding as I go.

AddDefaultDisplayor(typeof(string), typeof(TextBlock));
AddDefaultDisplayor(typeof(Color), typeof(TextBlock));
AddDefaultEditor(typeof(string), typeof(TextBox));
AddDefaultEditor(typeof(Color), typeof(ComboBox));
AddBasicBindableDisplayType(typeof(TextBlock), TextBlock.TextProperty);
AddBasicBindableEditType(typeof(TextBox), TextBox.TextProperty);
AddBasicBindableEditType(typeof(ComboBox), ComboBox.SelectedItemProperty);

These are all public static methods in case someone needs to expand this faster than I get to it.

Client code (PropertyGrid) will call GetDisplayInstance to get some type of Visual that can be used to represent the value of a single property

public static FrameworkElement GetDisplayInstance(IDesignableControl instance, DesignablePropertyDescriptor desc)
{
    //if null we try to find a default, otherwise see if we can do a binding anyway using the override
    if (null == desc.DisplayType || _basicBindableDisplayTypes.ContainsKey(desc.DisplayType))
    {
        Type displayType = _displayors[desc.PropertyInfo.PropertyType];
        FrameworkElement displayInstance = null;
        if (null != displayType)
        {
            displayInstance = (FrameworkElement)Activator.CreateInstance(displayType);
            SetupDisplayInstanceBinding(instance, desc, displayInstance);
        }
        return displayInstance;
    }
    else if (desc.DisplayType.ImplementsInterface(typeof(IDesignablePropertyVisualizer)))
    {
        var visualizer = (IDesignablePropertyVisualizer)Activator.CreateInstance(desc.DisplayType);
        visualizer.Initialize(instance, desc);
        return visualizer.Visual;
    }
    return null;
}

First check defaults, then check special overrides, then ultimately give up.  ImplementsInterface is an extension method in the DamonPayne.AGT.IoC project.  SetupDisplayInstanceBinding handles the rest of the work which is fairly simple with the help of Silverlight Binding.

protected static void SetupDisplayInstanceBinding(IDesignableControl instance, 
    DesignablePropertyDescriptor desc, FrameworkElement display)
{
    if (_basicBindableDisplayTypes.ContainsKey(display.GetType()))
    {                
        var dProp = _basicBindableDisplayTypes[display.GetType()];
        Binding b = new Binding(desc.PropertyInfo.Name);
        b.Converter = desc.Converter;
        b.Mode = BindingMode.TwoWay;
        b.Source = instance;
        display.SetBinding(dProp, b);
    }
}

How might a custom Property Visualizer work?  Take a look at part of the code behind for displaying the "softness" property of Couches & Chairs:

public double Softness
{
    get { return (double)GetValue(SoftnessProperty); }
    set { SetValue(SoftnessProperty, value); }
}

// Using a DependencyProperty as the backing store for Softness.  This enables animation, styling, binding, etc...
public static readonly DependencyProperty SoftnessProperty =
    DependencyProperty.Register("Softness", typeof(double), typeof(SoftnessVisualizer), new PropertyMetadata(SoftnessChanged));

public static void SoftnessChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
{
    if(obj is SoftnessVisualizer)
    {
        ((SoftnessVisualizer)obj).ScaleSoftness();
    }
}

protected void ScaleSoftness()
{
    if (Softness > 0.0)
    {
        VisualScale.ScaleX = Softness;
        VisualTranslate.X = 10 * Softness;
    }
    else
    {
        VisualScale.ScaleX = 1.0;
        VisualTranslate.X = 0.0;
    }
}

/// <summary>
/// We know we're just for softness!
/// </summary>
/// <param name="instance"></param>
/// <param name="desc"></param>
public void Initialize(DamonPayne.AGT.Design.IDesignableControl instance, DamonPayne.AGT.Design.Types.DesignablePropertyDescriptor desc)
{
    if (null != instance)
    {
        Binding b = new Binding("Softness");
        b.Converter = desc.Converter;
        b.Mode = BindingMode.TwoWay;
        b.Source = instance;
        SetBinding(SoftnessVisualizer.SoftnessProperty, b);
    }
}

The visual representation of softness here is a triangle that I am stretching based on Softness but that's not important.  In Initialize we set up a binding to the particular Property we care about which handles keeping in sync with the underlying object.  Using a changed callback for the Softness DependencyProperty allows us to tweak the UI if an editor changes this value in some fashion.

You can see here that I am making a heavy dependence on System.Windows.Data.Binding concepts which in turn means DependencyProperties.  This is OK as far as I'm concerned.  The Binding in Silverlight/WPF is the Data Binding you've always wished you had.  It is awesome.  It is likely going to be used frequently and you should learn it, love it, learn where it breaks down, and return to loving it.

 

The PropertyGrid logic is now fairly simple and just swaps an Edit Visual out for a Display Visual when the Display Visual is clicked on.

 

The ColorConverter I wrote may be helpful as well...

public class ColorConverter : IValueConverter
{

    static ColorConverter()
    {
        _colorNameToColor = new Dictionary<string, Color>();
        _colorToName = new Dictionary<Color, string>();
        Type cType = typeof(System.Windows.Media.Colors);
        PropertyInfo[] colors = cType.GetProperties(BindingFlags.Public | BindingFlags.Static);
        foreach (var propInfo in colors)
        {
            var c = (Color)propInfo.GetValue(null,null);
            _colorNameToColor.Add(propInfo.Name, c);
            _colorToName.Add(c, propInfo.Name);
        }
    }

    private static Dictionary<string, Color> _colorNameToColor;
    private static Dictionary<Color, string> _colorToName;


    public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (value is Color)
        {
            Color src = (Color)value;
            if (targetType == typeof(string))
            {
                if (_colorToName.ContainsKey(src))
                {
                    return _colorToName[src];
                }
                else
                {
                    return src.ToString();
                }
            }
        }
        return null;
    }

    public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
    {
        if (value is string)
        {
            string src = value.ToString();
            if (targetType == typeof(Color))
            {
                if (_colorNameToColor.ContainsKey(src))
                {
                    return _colorNameToColor[src];
                }
            }
        }

        return null;
    }
}

How does it look?

I needed to create some better visuals than the placeholders I had at the end of the previous article.  The default ControlTemplate for PropertyGrid now looks like this with a Chair selected.  Click on any image for the larger version.

Vision14

Note my special visualizer (I am no artist) for Softness.  When I select Softness, I get a custom Editor as well:

 Vision15

With a chair, a couch, and a Dummy Button selected, the only Property they have in common is Name, so only name shows up in the grid:

Vision16

Couches and Chairs have lots in common, so I could edit the Color of them all at once:

Vision17

 

Unit Tests

Jeff Wilcox released a full Silverlight 2 version of his Silverlight Unit Test Framework, so the AGT Solution has been updated to use this.  I have yet to find new Templates, so the Templates still say Beta and the default test project has to be tweaked slightly.  This is extremely handy for things like IValueConverters, and I will be greatly increasing test coverage in the future.

Conclusion

So, we've got Property Editing working now and this is starting to look like a real Design Time Environment.

The source code is checked into Codeplex as downloadable Change Set 8353 here.  I have also created a 0.7.17.2 "Planning" source drop on Codeplex.

 

The Live Demo has been updated at http://www.damonpayne.com/agt/

 

In the next article, we will be going through some refactoring items and some questions that I've been meaning to get to.

Tags:

Silverlight 2 Catastrophic Failure During Binding

by Administrator 2. December 2008 16:55

Catastrophic Failure is such an excellent error message, but I often have to wonder if it's necessary.  Include my favorite "unknown error" in there as well.  It seems that often enough the implementers of Silverlight 2 ought to know what the error is enough to give me a more meaningful error message?  Suppose you were implementing some generic binding code:

protected static void SetupDisplayInstanceBinding(IDesignableControl instance, 
    DesignablePropertyDescriptor desc, FrameworkElement display)
{
    if (_basicBindableDisplayTypes.ContainsKey(display.GetType()))
    {                
        var dProp = _basicBindableDisplayTypes[display.GetType()];
        Binding b = new Binding(desc.PropertyInfo.Name);
        b.Converter = desc.Converter;
        b.Mode = BindingMode.TwoWay;
        b.Source = instance;
        display.SetBinding(dProp, b);
    }
}

Now, suppose dProp returns TextBox.TextProperty but display is of type TextBlock - I am constantly mixing those two.  The call to display.SetBinding(dProp, b); will cause the Catastrophic Failure.  Why couldn't it say "The DependencyProperty is not an Attached Property and does not belong to type TextBlock" or something like that?

Tags:

There's Something Wrong with the Old School

by Administrator 2. December 2008 14:22

The Terski got me into Seth Godin maybe a month ago.  Good stuff.  Marketing and Excellence in Business are becoming increasingly relevant to those who wish to get beyond Code Monkey status.  Not that there's anything wrong with being a code monkey.

While discussing one of Seth's recent posts with a co-worker, he made the simple observation that

"There's something wrong with the old school."

There's something wrong with the old school.  No shit.  He was talking about the music industry.  The auto manufacturers come to mind too.  So does the entire Real Estate industry.  So do a lot of things.

It should be pretty obvious to any reader that I'm in favor of laissez faire capitalism, and yet for a while I've been meaning to write something on what is wrong with business in America right now.  No, it's not greed.  It's not that there's not enough regulation.  It's not that there's not enough skilled workers in America.

Our corporate culture is in some ways broken.  I think there is a lack of vision, an out of touch quality, a laziness and a weakness in the leadership of many of America's big businesses.  In the past 20 years, more and more of us look at Dilbert and our first reaction is not to laugh, but to see reflections of our own work day in the pointy haired boss.

Out of Touch to the point of insanity

I'm still driving my Subaru WRX that I got in 2001.  It's a great car.  By the end of 2002, Subaru was importing around 10,000 of these per year.  This car is very Japanese, it's a 2.0 liter turbo-charged all wheel drive four door that's fun to drive and practical enough for me; I get around 27mpg.  Detroit's answer to the WRX and to the Lancer Evolution and the other cars that followed was more or less that Americans don't want cars like this.  Americans want Corvettes and Mustangs and SUVs.  Yet, the WRX, the WRX STi, the Lancer Evolution, the Nissan GT-R, and others show that Americans clearly do want cars like this.  The Ironic Icing on the Cake of Incompetency is that if you look at the overseas offerings from companies like Ford you'll find (wait for it) things like an all wheel drive turbo-charged car that sure looks fun to drive.

Instead of thinking and doing, Detroit spends their time and money lobbying the government to take choices away from you, to making sure the law protects them from having to change with the times and with consumers' wants.  Our engineers and workers are great, our leadership is killing us.

The music industry couldn't be more out of touch.  I don't think I even need to expand this point?

Status Quo vs. Innovation

As Seth pointed out in the already referenced story, a business with a strong brand will ultimately find itself with two choices.  It can use this brand to build the Next Big Thing or it can do its best to keep the Next Big Thing from happening.  Think about how hard the Music and Movie "content" industry has fought digital distribution.  Their price for losing this battle is that Apple Computers, of all people, is considered by many insiders to be "calling the shots in the music industry".

My favorite example in this realm is the Real Estate industry.  If you've ever bought or sold a house you probably have a vague notion that there is this thing called an MLS (Multiple Listing System) and this group called the National Association of Realtors.  Getting your home on the MLS means that if there's a buyer for your home, they'll find it.  You pay a 6% commission for this service.  Some brokers will work harder than others to sell your house, but you're really paying a fee to get into the MLS. 

From my point of view, the National Association of Realtors has spent most of their time in the past 20 years protecting this 6% commission model under the ostensible banner of "protecting consumers".  They even got laws passed in some states making it a legal fact that brokers had to charge a 6% commission.  Then Buyers Agents came along, representing the home buyer in this important transaction and they wanted part of the commission.  Then The Internet came along and companies sprang up who would charge a much smaller fee (less than $1,000) to get your home into the MLS (the most valuable thing a seller can do) but leaving you to do the work of actually showing your house to sellers.  The NAR and many local MLS franchises went to work outlawing the operations of these companies in order to protect the Old Guard and had a degree of success until the DOJ got involved. 

The net worth of most Americans is tied up in the value of their homes.  Suppose you have no debts and no assets but you managed to put 20% down on a $300,000 home.  Your net worth would be $60,000.  Commission on selling the home would be $18,000, or nearly a third of your net worth.  Despite how infrequently you sell your home, why would you want to give a significant portion of your net worth to brokers if there's a good alternative?

The Realtors had a captive and grateful audience.  They could have become the Internet Real Estate solution for brokers.  Instead, they tried to stuff the genie back into the bottle, they tried to hinder the online business models of their members in order to protect the status quo.  Brokers instead had to go outside the MLS, they had to pay technology companies to build their websites, to build the systems they use to communicate with their buyers and sellers, the systems that show homes on Google Base and other content aggregators.  The MLSs left this money on the table, and now they've lost it forever and they can expect to see themselves slowly decline in relevance.

Culture of Fear and Stagnation

There is an underlying current of fear and stagnation in many American businesses, especially the larger ones.  Managers and executives do not take risks.  They don't learn new things.  They spend their days solidifying their own power.  They have to force their employees to be at their desks between 8am and 4pm rather than advocate virtual offices because otherwise they'd have no idea how much work their employees were doing!  Your manager probably does not reward risk taking because their manager probably does not reward their risk taking and all the way up to the top.

Chances are your manager has been in his or her job longer than you, and they've got a career path to protect.  How much of the upper management at your company has been there longer than five years?  Longer than ten?  Is the company you work for providing incentive for and rewarding good behavior or are they rewarding people who Do Their Time and erect walls around their Empire?  When was the last time you saw an announcement go out in your company saying "Damon took a risk and he failed, but ultimately it was a good risk that could have payed off big for this firm" ?  You've probably never heard that at work.  You've probably at some time worked for a business that claims to to desire one kind of behavior but clearly rewards the opposite.

If your manager is new, are they shaking things up, bringing in new ideas and processes?  Or are they tripping over themselves in their hurry to appease the old guard?  How many of the policies you're supposed to be following at work are there because your manager/company is a afraid of being spied on, afraid of competition, afraid of being sued, afraid of having to change.

Does your manager reward smart risk?  Do they do the right thing even if it means putting their empire at risk?  Do they trust you to do your job once you've proven trust-worthy?  Do they try to give you what you need to be successful?  Be sure to tell them you notice.

What's the Answer?

None of this is to say that young people have all the answers, that "thinking outside the box" is always what's called for, or that all of our corporate leadership are frightened little empire builders.  My own manager is almost too future-looking sometimes.

Companies and individuals, big and small, are shaking things up.  Apple is forcing the music industry to change.  Tesla Motors is close to proving Detroit wrong.  Southwest is growing while other airlines flounder.  Despite ever-increasing regulation and taxes, America is still the most free nation in the world and that means opportunity.  What can you do?

  • Don't do business with dinosaurs if you can help it.  Don't reward bad behavior.  When something new comes along that shows that someone "gets it", do business with them instead if you can. 
  • Don't break the law or act unethically.  On some level, I think we all know that intellectual property is still property.  It costs millions of dollars to make a movie, so don't pirate them.  When breaking the law is your protest, the response is all too often more laws and less freedom.
  • Don't work for dinosaurs.  This might be the hardest one to follow, and will in fact not be a real option to many of us.  Still, if you're a top performer, chances are you can work elsewhere even in the worst economy.  Work for someone who gets it, or start your own business.
  • Encourage those who show good leadership when you see it in action.  Some Project Managers are only able to walk around and ask you what the percent complete on a task is.  When you encounter the ones who are really providing guidance and removing barriers so the project gets done make sure they know you get it.

Shake things up.  Do better.  Succeed.  There's something wrong with the old school.

Tags:

About the author

Damon Payne is a Microsoft MVP specializing in Smart Client solution architecture. 

INETA Community Speakers Program

Month List

Page List

flickr photostream