private void SetContent(DocObject obj, string content)
{
string s = System.IO.Path.GetDirectoryName(Application.ExecutablePath) + "\\content\\ifc-styles.css";
string header = "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"><link rel=\"stylesheet\" type=\"text/css\" href=\"" + s + "\"></head><body>";
string footer = "</body></html>";
// replace images to use hard-coded paths
if (content != null)
{
int i = content.Length - 1;
while (i > 0)
{
i = content.LastIndexOf("<img src=\"", i - 1);
if (i >= 0)
{
int j = content.IndexOf(">", i + 1);
int t = content.IndexOf("\"", i + 10);
if (j >= 0 && t >= 0)
{
string imgold = content.Substring(i + 10, t - i - 10);
imgold = imgold.Substring(imgold.LastIndexOf('/') + 1);
string imgnew = Properties.Settings.Default.InputPathGeneral + "\\" + imgold;
if (obj is DocExample)
{
imgnew = Properties.Settings.Default.InputPathExamples + "\\" + imgold;
}
content = content.Substring(0, i + 10) + imgnew + content.Substring(t);
}
}
}
}
this.webBrowser.Navigate("about:blank");
this.webBrowser.DocumentText = header + content + footer;
if (obj != null)
{
// edit overall text
this.textBoxHTML.Text = obj.Documentation;// content;
}
this.textBoxHTML.Tag = obj; // remember tag to ensure we update regardless of tree state
if (obj is DocTemplateDefinition)
{
DocTemplateDefinition docTemplate = (DocTemplateDefinition)obj;
Dictionary<string, DocObject> mapEntity = new Dictionary<string, DocObject>();
Dictionary<string, string> mapSchema = new Dictionary<string, string>();
BuildMaps(mapEntity, mapSchema);
this.ctlConcept.Map = mapEntity;
this.ctlConcept.Project = this.m_project;
this.ctlConcept.Template = docTemplate;
/*
this.ctlRules.Project = this.m_project;
this.ctlRules.BaseTemplate = this.treeView.SelectedNode.Parent.Tag as DocTemplateDefinition;
this.ctlRules.Template = docTemplate;
this.ctlOperators.Project = this.m_project;
this.ctlOperators.Template = docTemplate;
this.ctlOperators.Rule = null;
*/
this.ctlInheritance.Visible = false;
this.ctlCheckGrid.Visible = false;
this.ctlExpressG.Visible = false;
this.ctlConcept.Visible = true;
}
else if (obj is DocModelView)
{
// for now, always refresh -- future: check for changes
DocModelView docView = (DocModelView)obj;
docView.Filter(null);
this.ctlInheritance.Project = this.m_project;
this.ctlInheritance.ModelView = docView;
if (!String.IsNullOrEmpty(docView.RootEntity))
{
this.ctlInheritance.Entity = this.m_project.GetDefinition(docView.RootEntity) as DocEntity;
}
else
{
this.ctlInheritance.Entity = this.m_project.GetDefinition("IfcRoot") as DocEntity;
}
this.ctlInheritance.Visible = true;
this.ctlExpressG.Visible = false;
this.ctlCheckGrid.Visible = false;
this.ctlConcept.Visible = false;
}
else if(obj is DocSection)
{
this.ctlInheritance.Project = this.m_project;
this.ctlInheritance.ModelView = null;
this.ctlInheritance.Entity = this.m_project.GetDefinition("IfcRoot") as DocEntity;
this.ctlInheritance.Visible = false;
this.ctlExpressG.Visible = false;
this.ctlCheckGrid.Visible = false;
this.ctlConcept.Visible = false;
}
else if (obj is DocExchangeDefinition)
{
DocExchangeDefinition docExchange = (DocExchangeDefinition)obj;
DocModelView docView = (DocModelView)this.treeView.SelectedNode.Parent.Tag;
this.ctlCheckGrid.CheckGridSource = new CheckGridExchange(docExchange, docView, this.m_project);
this.ctlInheritance.Visible = false;
this.ctlCheckGrid.Visible = true;
this.ctlExpressG.Visible = false;
this.ctlConcept.Visible = false;
}
else if (obj is DocConceptRoot)
{
DocConceptRoot docRoot = (DocConceptRoot)obj;
DocModelView docView = null;
foreach (DocModelView eachView in this.m_project.ModelViews)
{
if (eachView.ConceptRoots.Contains(docRoot))
{
docView = eachView;
break;
}
}
Dictionary<string, DocObject> mapEntity = new Dictionary<string, DocObject>();
Dictionary<string, string> mapSchema = new Dictionary<string, string>();
BuildMaps(mapEntity, mapSchema);
this.ctlConcept.Map = mapEntity;
this.ctlConcept.Project = this.m_project;
this.ctlConcept.Template = null;
this.ctlConcept.ConceptRoot = docRoot;
this.ctlInheritance.Visible = false;
this.ctlCheckGrid.Visible = false;
this.ctlExpressG.Visible = false;
this.ctlConcept.Visible = true;
#if false // requirements view -- move into separate view mode in future
this.ctlCheckGrid.CheckGridSource = new CheckGridEntity(docRoot, docView, this.m_project, mapEntity);
this.ctlCheckGrid.Visible = true;
this.ctlExpressG.Visible = false;
this.splitContainerConcept.Visible = false;
#endif
}
else if (obj is DocTemplateUsage)
{
DocTemplateUsage docUsage = (DocTemplateUsage)obj;
TreeNode tnParent = this.treeView.SelectedNode.Parent;
while(tnParent.Tag is DocTemplateUsage)
{
tnParent = tnParent.Parent;
}
DocConceptRoot docRoot = (DocConceptRoot)tnParent.Tag;
DocModelView docView = null;
foreach (DocModelView eachView in this.m_project.ModelViews)
{
if (eachView.ConceptRoots.Contains(docRoot))
{
docView = eachView;
break;
}
}
Dictionary<string, DocObject> mapEntity = new Dictionary<string, DocObject>();
Dictionary<string, string> mapSchema = new Dictionary<string, string>();
BuildMaps(mapEntity, mapSchema);
this.ctlConcept.Map = mapEntity;
this.ctlConcept.Project = this.m_project;
this.ctlConcept.Template = docUsage.Definition;
this.ctlConcept.ConceptRoot = null;
this.ctlInheritance.Visible = false;
this.ctlCheckGrid.Visible = false;
this.ctlExpressG.Visible = false;
this.ctlConcept.Visible = true;
/*
this.ctlOperators.Template = null;
this.ctlParameters.Project = this.m_project;
this.ctlParameters.ConceptRoot = docRoot;
this.ctlParameters.ConceptLeaf = docUsage;
*/
#if false // requirements view -- move into separate view mode in future
this.ctlCheckGrid.CheckGridSource = new CheckGridConcept(docUsage.Definition, docView, this.m_project);
this.ctlCheckGrid.Visible = true;
this.ctlExpressG.Visible = false;
this.splitContainerConcept.Visible = false;
#endif
}
else if (obj is DocSchema)
{
Dictionary<string, DocObject> mapEntity = new Dictionary<string, DocObject>();
Dictionary<string, string> mapSchema = new Dictionary<string, string>();
BuildMaps(mapEntity, mapSchema);
this.ctlExpressG.Map = mapEntity;
this.ctlExpressG.Schema = (DocSchema)obj;
this.ctlExpressG.Selection = null;
this.ctlExpressG.Visible = true;
this.ctlInheritance.Visible = false;
this.ctlCheckGrid.Visible = false;
this.ctlConcept.Visible = false;
}
else if(obj is DocDefinition)
{
// determine schema from parent node
TreeNode tn = this.treeView.SelectedNode;
while(!(tn.Tag is DocSchema))
{
tn = tn.Parent;
}
DocSchema docSchema = (DocSchema)tn.Tag;
Dictionary<string, DocObject> mapEntity = new Dictionary<string, DocObject>();
Dictionary<string, string> mapSchema = new Dictionary<string, string>();
BuildMaps(mapEntity, mapSchema);
if (docSchema != null)
{
this.ctlExpressG.Map = mapEntity;
this.ctlExpressG.Schema = docSchema;
this.ctlExpressG.Selection = (DocDefinition)obj;
this.ctlExpressG.Visible = true;
}
this.ctlInheritance.Visible = false;
this.ctlCheckGrid.Visible = false;
this.ctlConcept.Visible = false;
}
else if (obj is DocAttribute || obj is DocWhereRule || obj is DocUniqueRule || obj is DocConstant || obj is DocSchemaRef || obj is DocSelectItem)
{
// determine schema from parent node
TreeNode tn = this.treeView.SelectedNode;
while (!(tn.Tag is DocSchema))
{
tn = tn.Parent;
}
DocSchema docSchema = (DocSchema)tn.Tag;
Dictionary<string, DocObject> mapEntity = new Dictionary<string, DocObject>();
Dictionary<string, string> mapSchema = new Dictionary<string, string>();
BuildMaps(mapEntity, mapSchema);
if (docSchema != null)
{
this.ctlExpressG.Map = mapEntity;
this.ctlExpressG.Schema = docSchema;
this.ctlExpressG.Selection = obj;
this.ctlExpressG.Visible = true;
}
this.ctlInheritance.Visible = false;
this.ctlCheckGrid.Visible = false;
this.ctlConcept.Visible = false;
}
else if (obj == null && this.treeView.SelectedNode != null && this.treeView.SelectedNode.Parent != null && this.treeView.SelectedNode.Parent.Tag is DocSchema)
{
// check if parent node is schema (intermediate node for organization)
Dictionary<string, DocObject> mapEntity = new Dictionary<string, DocObject>();
Dictionary<string, string> mapSchema = new Dictionary<string, string>();
BuildMaps(mapEntity, mapSchema);
this.ctlExpressG.Map = mapEntity;
this.ctlExpressG.Schema = (DocSchema)this.treeView.SelectedNode.Parent.Tag;
this.ctlExpressG.Selection = null;
this.ctlExpressG.Visible = true;
this.ctlInheritance.Visible = false;
this.ctlCheckGrid.Visible = false;
this.ctlConcept.Visible = false;
}
else
{
this.ctlInheritance.Visible = false;
this.ctlExpressG.Visible = false;
this.ctlCheckGrid.Visible = false;
this.ctlConcept.Visible = false;
}
}