I am creating a plugin for an application that works with the concept of families. Each family belongs to a family category, and each family contains FamilySymbols. Good tree structure:
- FamilyCategory (Doors)
- Family (external doors)
- FamilySymbol (Door 2000x1000)
- FamilySymbol (Door 2000x900)
- Family (garage door)
- FamilySymbol (Door 2000x2000)
- FamilySymbol (Door 2100x2000)
- FamilyCategory (Windows)
- Family (Single Windows)
- FamilySymbol (Window 1000x1400)
- FamilySymbol (Window 800x1400)
- Family (Double Windows)
- FamilySymbol (Window 2000x1400)
- FamilySymbol (window 2100x1400)
TreeView, . , FamilyCategory. , TreeNode FamilyCategory, , node. node , .
, Exists false.
foreach (Family family in families)
{
string familyCategoryName = family.FamilyCategory.Name;
bool categoryExists = treeView.Nodes.ContainsKey(familyCategoryName);
if (categoryExists)
{
categoryNode = treeView.Nodes[familyCategoryName];
}
else
{
categoryNode = new TreeNode(familyCategoryName);
treeView.Nodes.Add(categoryNode);
}
TreeNode familyNode = new TreeNode(family.Name);
categoryNode.Nodes.Add(familyNode);
foreach (FamilySymbol familySymbol in family.Symbols)
{
familyNode.Nodes.Add(familySymbol.Name);
}
}
?