views:

16

answers:

1

Trying to accomplish:

I want to change the image property of a bound tree node when the value of an enumerated property changes on the bound object.

Bound Object is representation of an airfield or vehicle base in a game. The object has a property of Type which is an enumerated value type: SmallAirfield, MediumAirField, LargeAirField, Port, AirCraftCarrier

The object being inspected is displayed and edited in a property grid...

The extended/node in the tree exposes an Image Property

When the user changes the enumerated value of the Type of base this is...I want to update the image of the tree node...

Thus, I am trying to bind dissimilar value types...

In other words, if the user changes the airbase type to aircraft carrier, I want to change the little image to the aircraft carrier image...

I do not want to include/expose an image property in the object representation of airbase object...

How can I bind the image property of type Image to my enumerated airfield Type property of the airfield object?

I hope that makes sense?

Carson

A: 

foreach (Field f in fields) {

if (f.CurrentOwner == country)
{

    addNode = node.Add(node.Key + f.ID, f.ID);
    addNode.Tag = f;
    addNode.DataBindings.Add("Text", f, "ID");
    /// HERE IS WHERE I WOULD BIND THE IMAGE OF THE NODE TO THE 
    /// TO TYPE OF FIELD....
    switch (f.Type)
    {
        case BaseType.Airfield:
            fieldNode.Image = ((Icon)Scenario.Properties.Resources.Pony).ToBitmap();
            break;
        case BaseType.Carrier:
            fieldNode.Image = ((Icon)Scenario.Properties.Resources.CV).ToBitmap();
            break;
        case BaseType.Port:
            fieldNode.Image = ((Icon)Scenario.Properties.Resources.Tiger).ToBitmap();
            break;
        case BaseType.VBase:
            fieldNode.Image = ((Icon)Scenario.Properties.Resources.Tiger).ToBitmap();
            break;
    }
}

}

Carson Wales
that of course wont compile because I was messing around with upcasting to a different node type...addNode is fieldNode...sorry for the lameness
Carson Wales