Page 1 of 1

ModelDrawer removing

Posted: Thu Mar 22, 2012 3:17 pm
by Peter Prins
I noticed that you can add any object to the ModelDrawer, and it figures out itself whether it actually has a way to draw that object. However this advantage is kind of mitigated by the fact that the removal of objects will simply crash if the object has no drawing type. So I added this simple change to the ModelDrawer that makes it just that bit easier to use:

Code: Select all

/// <summary>
/// Removes an object from the drawer, if it exists.
/// </summary>
/// <param name="objectToRemove">Object to remove.</param>
public void Remove(object objectToRemove)
{
    try
    {
        Remove(displayObjects[objectToRemove]);
        displayObjects.Remove(objectToRemove);
    }
    catch (KeyNotFoundException) { }
}

Re: ModelDrawer removing

Posted: Thu Mar 22, 2012 10:39 pm
by Norbo
Thanks for the suggestion. The latest development version now returns a bool representing whether or not the instance had an associated display object upon removal.