private void btnDelete_Click(object sender, EventArgs e) { var node = trvExtensions.SelectedNode; if (node != null) { var ext = node.Tag as IFeatureSourceExtension; var join = node.Tag as IAttributeRelation; var calc = node.Tag as ICalculatedProperty; if (ext != null) { _fs.RemoveExtension(ext); OnResourceChanged(); trvExtensions.Nodes.Remove(node); } else if (join != null) { //Disassociate from parent ext = node.Parent.Tag as IFeatureSourceExtension; if (ext != null) { ext.RemoveRelation(join); OnResourceChanged(); node.Parent.Nodes.Remove(node); } } else if (calc != null) { //Disassociate from parent ext = node.Parent.Tag as IFeatureSourceExtension; if (ext != null) { ext.RemoveCalculatedProperty(calc); OnResourceChanged(); node.Parent.Nodes.Remove(node); } } } }