private void UpdateTreeValidationNode(TreeNode tn)
{
if (tn.Tag is DocTemplateDefinition)
{
#if true
DocTemplateDefinition dtd = (DocTemplateDefinition)tn.Tag;
if (dtd.Validation == null)
{
tn.BackColor = Color.Empty;
}
else if(dtd.Validation.Value)
{
tn.BackColor = Color.Lime;
}
else
{
tn.BackColor = Color.Red;
}
#endif
}
else if (tn.Tag is DocTemplateUsage)
{
DocTemplateUsage docUsage = (DocTemplateUsage)tn.Tag;
if (docUsage.Validation != null)
{
TreeNode tnTest = tn.Parent;
while (tnTest.Tag is DocTemplateUsage)
{
tnTest = tnTest.Parent;
}
bool alltrue = true;
DocEntity docEntity = (DocEntity)tnTest.Parent.Tag;
DocSchema docSchema = this.m_project.GetSchemaOfDefinition(docEntity);
if (docUsage.Definition.Name.Contains("053") && docEntity.Name.Equals("IfcWall"))
{
this.ToString();
}
if (docSchema != null && this.m_formatTest != null)
{
string typename = docSchema.Name + "." + docEntity.Name;
Type typeFilter = this.m_assembly.GetType(typename);
if (typeFilter != null)
{
foreach (SEntity entity in this.m_formatTest.Instances.Values)
{
if (typeFilter.IsInstanceOfType(entity))
{
bool? result = docUsage.GetResultForObject(entity);
if (result != null && !result.Value)
{
alltrue = false;
break;
}
}
}
}
}
if (alltrue)
{
tn.BackColor = Color.Lime;
}
else
{
tn.BackColor = Color.Red;
}
}
else
{
tn.BackColor = Color.Empty;
}
#if false
if (dtd.Validation == null)
{
tn.BackColor = Color.Empty;
}
else if (dtd.Validation.Value)
{
tn.BackColor = Color.Lime;
}
else
{
tn.BackColor = Color.Red;
}
#endif
}
foreach (TreeNode sub in tn.Nodes)
{
UpdateTreeValidationNode(sub);
}
}