public void DeleteModel(XmlElement modelData)
{
//When there is a Redo operation, model is removed from
//the workspace but the model is "not disposed" from memory.
//Identified this when redo operation is performed on groups
ModelBase model = GetModelForElement(modelData);
if (model is NoteModel)
{
var note = model as NoteModel;
RemoveNote(note);
note.Dispose();
}
else if (model is AnnotationModel)
{
RemoveGroup(model);
}
else if (model is PresetModel)
{
RemovePreset(model as PresetModel);
}
else if (model is ConnectorModel)
{
var connector = model as ConnectorModel;
connector.Delete();
}
else if (model is NodeModel)
{
RemoveAndDisposeNode(model as NodeModel);
}
else
{
// If it gets here we obviously need to handle it.
throw new InvalidOperationException(string.Format(
"Unhandled type: {0}", model.GetType()));
}
}