private void treeViewProperty_AfterSelect(object sender, TreeViewEventArgs e) { DocObject docObj = this.treeViewProperty.SelectedNode.Tag as DocObject; if (docObj != null) { if (docObj is DocPropertySet) { this.textBoxType.Text = ((DocPropertySet)docObj).PropertySetType; } else if (docObj is DocProperty) { DocProperty docProp = (DocProperty)docObj; this.textBoxType.Text = docProp.PropertyType + ": " + docProp.PrimaryDataType + " / " + docProp.SecondaryDataType; } this.textBoxDescription.Text = docObj.Documentation; } else if (this.treeViewProperty.SelectedNode.Parent != null && this.treeViewProperty.SelectedNode.Parent.Tag is DocProperty) { DocProperty docProp = (DocProperty)this.treeViewProperty.SelectedNode.Parent.Tag; this.textBoxType.Text = docProp.PropertyType + ": " + docProp.PrimaryDataType + " / " + docProp.SecondaryDataType; this.textBoxDescription.Text = docProp.Documentation; } this.buttonOK.Enabled = (this.treeViewProperty.CheckBoxes || this.SelectedProperty != null || (this.m_entity == null && this.SelectedPropertySet != null)); }
public void StripWikiTags(string text, ref DocObject doc, string wikipediaTitle) { if (String.IsNullOrEmpty(text)) { return; } try { StringBuilder sb = new StringBuilder(text); sb.Replace("'''", ""); sb.Replace("''", ""); StripTag4(ref sb, "[[", "]]"); StripTag(ref sb, "<!--", "-->"); ExtractOfficial(ref sb, ref doc.linkList, "{{dmoz|"); ExtractOfficial(ref sb, ref doc.linkList, "{{URL|"); ExtractOfficial(ref sb, ref doc.linkList, "{{Official website|"); ExtractLinks(ref sb, ref doc.linkList, wikipediaTitle); ExtractVCite(ref sb, ref doc.linkList, wikipediaTitle); StripTag(ref sb, "{|", "|}"); StripTag(ref sb, "{{", "}}"); StripTag(ref sb, "<", ">"); StripTag2(ref sb, "=="); StripTag3(ref sb, "*"); StripTag3(ref sb, "#"); doc.text = DocObject.CleanStringWikipedia(sb.ToString()); } catch (Exception e) { Trace.WriteLine(DateTime.UtcNow.ToString() + " " + "StripWikiTags: " + e.Message); } }
public HttpResponseMessage SignUp([FromUri] string role, [FromBody] DocObject body) { if (role != "500" && role != "400" && role != "302") { DataObject err = new DataObject(); err.data = "10101"; return(Request.CreateResponse(HttpStatusCode.OK, err)); } else if (role == "302") { DataObject err = new DataObject(); err.data = "10103"; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } else if (role == "400") { DataObject err = new DataObject(); err.data = "10104"; return(Request.CreateResponse(HttpStatusCode.BadRequest, err)); } else { Error err = new Error(); err.message = "系统维护中"; return(Request.CreateResponse(HttpStatusCode.InternalServerError, err)); } }
private void WriteItem(System.IO.StreamWriter writer, DocObject docEntity, int level, string topLevelName) { for (int i = 0; i < level; i++) { writer.Write(topLevelName + "."); } writer.Write(docEntity.Name); if (this.m_locales != null) { foreach (string locale in this.m_locales) { string localname = ""; string localdesc = ""; foreach (DocLocalization docLocal in docEntity.Localization) { if (docLocal.Locale.StartsWith(locale)) { localname = docLocal.Name; localdesc = docLocal.Documentation; break; } } writer.Write("\t"); writer.Write(localname); writer.Write("\t"); writer.Write(localdesc); } } writer.WriteLine(); }
static void GetNodes(DocObject doc, ref List <XmlNode> nodeList) { string[] xml = doc.Lines.ToArray(); for (int i = 0; i < xml.Length; i++) { //New node detected if (xml[i].Contains("<w:p w") && !xml[i].Contains("/>")) { //Create node with type var node = new XmlNode(string.Empty, string.Empty); while (!xml[i].Contains("</w:p>")) { i++; if (xml[i].Contains("<w:pStyle")) { node.Type = GetType(xml[i], "\""); } if (xml[i].Contains("<w:t")) { node.Value += GetValue(xml[i], "<w:t"); } } nodeList.Add(node); } } }
public HttpResponseMessage Put(string id, [FromBody] DocObject body) { if (id != "500" && id != "404" && id != "400") { Error err = new Error(); err.message = "更新成功"; return(Request.CreateResponse(HttpStatusCode.OK, err)); } else if (id == "400") { // log exception here return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, "资料格式有误") ); } else if (id == "404") { // log exception here return(Request.CreateErrorResponse(HttpStatusCode.NotFound, "查无此用户") ); } else { // log exception here return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "系统维护中") ); } }
private void CtlExpressG_DragDrop(object sender, DragEventArgs e) { DocEntity docEnt = e.Data.GetData(typeof(DocEntity)) as DocEntity; if (docEnt != null) { e.Effect = DragDropEffects.Move; if (!String.IsNullOrEmpty(docEnt.BaseDefinition)) { DocObject docBase = null; if (this.m_map.TryGetValue(docEnt.BaseDefinition, out docBase)) { if (docBase is DocEntity) { DocEntity docEntBase = (DocEntity)docBase; //...docEntBase. } } } foreach (DocAttribute docAttr in docEnt.Attributes) { //111docAttr. } } }
private void WriteItem(System.IO.StreamWriter writer, DocObject docEntity, DocObject docParent) { if (docParent != null) { writer.Write(docParent.Name + "."); } writer.Write(docEntity.Name); if (this.m_locales != null) { foreach (string locale in this.m_locales) { string localname = ""; string localdesc = ""; if (this.m_locales.Length == 1 && this.m_locales[0] == "iv") { // invariant localname = docEntity.Name; localdesc = docEntity.Documentation; } else { foreach (DocLocalization docLocal in docEntity.Localization) { if (docLocal.Locale.StartsWith(locale)) { localname = docLocal.Name; localdesc = docLocal.Documentation; break; } } } // cleanup -- remove return characters and tabs for compatibility with if (localname != null) { localname = localname.Replace("\r", ""); localname = localname.Replace("\n", ""); localname = localname.Replace("\t", ""); } if (localdesc != null) { localdesc = localdesc.Replace("\r", ""); localdesc = localdesc.Replace("\n", ""); localdesc = localdesc.Replace("\t", ""); } writer.Write("\t"); writer.Write(localname); writer.Write("\t"); writer.Write(localdesc); } } writer.WriteLine(); }
public DocObject CrawlWikipediaEntry(object WikipediaEntry) { try { WikipediaEntryObject we = (WikipediaEntryObject)WikipediaEntry; string text; DateTime date; XElement el3 = we.el.Element("{" + we.el.Name.Namespace + "}revision"); if (el3 != null) { XElement el4 = el3.Element("{" + we.el.Name.Namespace + "}timestamp"); if (el4 != null) { date = TimeZoneToUtc(el4.Value, "en"); } else { date = DateTime.UtcNow; } XElement el5 = el3.Element("{" + we.el.Name.Namespace + "}text"); if (el5 != null) { text = el5.Value; } else { text = ""; } } else { date = DateTime.UtcNow; text = ""; } DocObject doc = new DocObject(); //internal links //external links //image links StripWikiTags(text, ref doc, we.title); doc.url = we.url; //title rewriting doc.title = we.title + " - Wikipedia";; doc.docDate = date; doc.domain = Url2domain(doc.url); return(doc); } catch (Exception e9) { Trace.WriteLine(DateTime.UtcNow.ToString() + " " + "CrawlWikipediaEntry: " + e9.Message); return(null); } }
private void LoadTemplates(List <DocTemplateDefinition> list) { foreach (DocTemplateDefinition docTemplate in list) { #if false bool include = false; // check for inheritance DocObject docApplicableEntity = null; if (this.m_entity == null) { include = true; } else if (docTemplate.Type != null && m_map.TryGetValue(docTemplate.Type, out docApplicableEntity) && docApplicableEntity is DocEntity) { // check for inheritance DocEntity docBase = this.m_entity; while (docBase != null) { if (docBase == docApplicableEntity) { include = true; break; } if (docBase.BaseDefinition == null) { break; } DocObject docEach = null; if (this.m_map.TryGetValue(docBase.BaseDefinition, out docEach)) { docBase = (DocEntity)docEach; } else { docBase = null; } } } else if (docTemplate.Type == null) { // recurse LoadTemplates(docTemplate.Templates); } if (include) { LoadTemplate(null, docTemplate); } #endif LoadTemplate(null, docTemplate); } }
public CheckGridEntity(DocConceptRoot docRoot, DocModelView docView, DocProject docProject, Dictionary <string, DocObject> map) { this.m_root = docRoot; this.m_view = docView; this.m_project = docProject; this.m_listTemplate = new List <DocTemplateDefinition>(); List <DocTemplateDefinition> listTemplate = docProject.GetTemplateList(); //... filter out templates to only those that apply to entity... foreach (DocTemplateDefinition docTemplate in listTemplate) { if (docTemplate.Rules != null && docTemplate.Rules.Count > 0) // don't include abstract/organizational templates { bool include = false; // check for inheritance DocObject docApplicableEntity = null; if (docTemplate.Type != null && map.TryGetValue(docTemplate.Type, out docApplicableEntity) && docApplicableEntity is DocEntity) { // check for inheritance DocEntity docBase = docRoot.ApplicableEntity; while (docBase != null) { if (docBase == docApplicableEntity) { include = true; break; } if (docBase.BaseDefinition == null) { break; } DocObject docEach = null; if (map.TryGetValue(docBase.BaseDefinition, out docEach)) { docBase = (DocEntity)docEach; } else { docBase = null; } } } if (include) { this.m_listTemplate.Add(docTemplate); } } } }
// version for computer interpretable listing public string FormatSelectFull(DocSelect docSelect, Dictionary <string, DocObject> map, Dictionary <DocObject, bool> included, bool fullListing) { StringBuilder sb = new StringBuilder(); sb.AppendLine("ifc:" + docSelect.Name); sb.AppendLine("\trdf:type owl:Class ;"); if (!fullListing) { //possibly add the individuals here as a union sb.AppendLine("\towl:equivalentClass"); sb.AppendLine("\t\t["); sb.AppendLine("\t\t\trdf:type owl:Class ;"); sb.AppendLine("\t\t\towl:unionOf "); sb.AppendLine("\t\t\t\t( "); // entities foreach (DocSelectItem docItem in docSelect.Selects) { DocObject mapDef = null; if (map.TryGetValue(docItem.Name, out mapDef)) { if (included == null || included.ContainsKey(mapDef)) { sb.AppendLine("\t\t\t\t\tifc:" + docItem.Name + " "); } } } //close unionof sb.AppendLine("\t\t\t\t) "); sb.AppendLine("\t\t] ; "); } sb.AppendLine("\trdfs:subClassOf expr:SELECT ."); sb.AppendLine(); // add members of SELECT as subclasses if (fullListing) { foreach (DocSelectItem docItem in docSelect.Selects) { DocObject mapDef = null; if (map.TryGetValue(docItem.Name, out mapDef)) { if (included == null || included.ContainsKey(mapDef)) { sb.AppendLine("ifc:" + docItem.Name); sb.AppendLine("\trdfs:subClassOf ifc:" + docSelect.Name + " ."); sb.AppendLine(); } } } } return(sb.ToString()); }
public List <DocObject> SelectDocFile(ref ProgressBar pb) { pb.Value = 0; string outputDir = "C:\\Users\\" + Environment.UserName + "\\Desktop\\output\\"; var filesToDelete = new List <string>(); var openFileDialog = new OpenFileDialog(); var docObjects = new List <DocObject>(); //Properties of the OpenFileDialog openFileDialog.InitialDirectory = "C:\\Users\\" + Environment.UserName + "\\"; openFileDialog.Filter = "Word Documents (*.docx)|*.docx|Word Documents (*.doc)|*.doc|All files (*.*)|*.*"; openFileDialog.RestoreDirectory = true; openFileDialog.DefaultExt = ".docx"; openFileDialog.Multiselect = true; openFileDialog.ReadOnlyChecked = false; //Adding the files to the list if (openFileDialog.ShowDialog() == true) { double valueIncrement = 100 / openFileDialog.FileNames.Length; for (int i = 0; i < openFileDialog.FileNames.Length; i++) { //Creating the output directory if (!Directory.Exists(outputDir)) { Directory.CreateDirectory(outputDir); } //Creating a filename and a temp output file string fileName = "TempDocument" + i + ".docx"; string outputFile = outputDir + fileName + ".zip"; string extractionFolder = outputDir + "ExtractedFile" + i; filesToDelete.Add(outputFile); filesToDelete.Add(extractionFolder); ClearOutput(fileName, outputFile, extractionFolder, i, openFileDialog); ZipFile.ExtractToDirectory(outputFile, extractionFolder); Beautify(extractionFolder); var docObject = new DocObject(new List <string>(), ""); ReadXml(extractionFolder, ref docObject); docObjects.Add(docObject); DeleteTempFiles(filesToDelete); pb.Value += valueIncrement; } } return(docObjects); }
public void ReadXml(string extractionFolder, ref DocObject docObject) { //which is the xml file that stores the word xml markup using (var reader = new StreamReader(extractionFolder + "\\word\\document.xml")) { while (!reader.EndOfStream) { string line = reader.ReadLine(); docObject.Lines.Add(line); reader.Read(); } reader.Close(); } }
private void WriteList(System.IO.StreamWriter writer, SortedList <string, DocObject> sortlist) { foreach (string key in sortlist.Keys) { DocObject docEntity = sortlist[key]; WriteItem(writer, docEntity, 0, docEntity.Name); if (docEntity is DocEntity) { DocEntity docEnt = (DocEntity)docEntity; foreach (DocAttribute docAttr in docEnt.Attributes) { WriteItem(writer, docAttr, 1, docEntity.Name); } } else if (docEntity is DocEnumeration) { DocEnumeration docEnum = (DocEnumeration)docEntity; foreach (DocConstant docConst in docEnum.Constants) { WriteItem(writer, docConst, 1, docEntity.Name); } } else if (docEntity is DocPropertySet) { DocPropertySet docPset = (DocPropertySet)docEntity; foreach (DocProperty docProp in docPset.Properties) { WriteItem(writer, docProp, 1, docEntity.Name); } } else if (docEntity is DocPropertyEnumeration) { DocPropertyEnumeration docPE = (DocPropertyEnumeration)docEntity; foreach (DocPropertyConstant docPC in docPE.Constants) { WriteItem(writer, docPC, 1, docEntity.Name); } } else if (docEntity is DocQuantitySet) { DocQuantitySet docQset = (DocQuantitySet)docEntity; foreach (DocQuantity docQuan in docQset.Quantities) { WriteItem(writer, docQuan, 1, docEntity.Name); } } } }
public void flush() { System.Console.WriteLine("FLSH!!!!!!!!!"); string tag = this.obj.dicTag ["tag"]; System.Globalization.TextInfo tf = new System.Globalization.CultureInfo("en-US", false).TextInfo; string className = "Novel." + tf.ToTitleCase(tag) + "Component"; Debug.Log(className); //Novel.Bg_removeComponent AbstractComponent test = new Novel.Bg_removeComponent(); Debug.Log(test); Debug.Log(test.GetType().FullName); className = test.GetType().FullName; //リフレクションで動的型付け Type masterType = Type.GetType(className); Debug.Log(masterType); AbstractComponent cmp; cmp = (AbstractComponent)Activator.CreateInstance(masterType); this.obj.dicParamDefault = cmp.originalParam; Dictionary <string, string> tmpDic = new Dictionary <string, string> (); List <string> l = cmp.arrayVitalParam; for (var i = 0; i < l.Count; i++) { string vital = l [i]; tmpDic [vital] = "yes"; } this.obj.dicParamVital = tmpDic; //必須パラメータとかデフォルト値を取得 this.arrDoc.Add(this.obj); this.obj = new DocObject(); this.status = ""; }
private void SetContent(DocObject obj) { 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>"; this.webBrowser.Navigate("about:blank"); if (obj != null) { this.webBrowser.DocumentText = header + obj.Documentation + footer; } else { this.webBrowser.DocumentText = String.Empty; } }
private void ctlConcept_SelectionChanged(object sender, EventArgs e) { if (this.ctlConcept.CurrentAttribute != null) { SetContent(this.ctlConcept.CurrentAttribute); } else if (this.ctlConcept.Selection is DocModelRuleEntity) { DocModelRuleEntity dmr = (DocModelRuleEntity)this.ctlConcept.Selection; DocObject obj = null; this.m_map.TryGetValue(dmr.Name, out obj); this.SetContent(obj); } else { DocTemplateDefinition dtd = (DocTemplateDefinition)this.treeView.SelectedNode.Tag; this.SetContent(dtd); } }
static DocObject GetDocObject(string path) { var docObject = new DocObject(); docObject.Lines = new List <string>(); using (var reader = new StreamReader(path)) { while (!reader.EndOfStream) { string line = reader.ReadLine(); docObject.Lines.Add(line); } reader.Close(); } docObject.Path = path; return(docObject); }
private void treeViewProperty_AfterSelect(object sender, TreeViewEventArgs e) { DocObject docObj = this.treeViewProperty.SelectedNode.Tag as DocObject; if (docObj != null) { if (docObj is DocQuantitySet) { this.textBoxType.Text = "QSET_OCCURRENCEDRIVEN"; } else if (docObj is DocQuantity) { DocQuantity docProp = (DocQuantity)docObj; this.textBoxType.Text = docProp.QuantityType.ToString(); } this.textBoxDescription.Text = docObj.Documentation; } this.buttonOK.Enabled = (this.treeViewProperty.CheckBoxes || (this.treeViewProperty.SelectedNode != null && this.treeViewProperty.SelectedNode.Tag is DocQuantity)); }
private void CtlExpressG_MouseUp(object sender, MouseEventArgs e) { if (e.Button != System.Windows.Forms.MouseButtons.Left) { return; } this.m_mousedown = false; if (this.m_selection == null && this.m_toolmode == ToolMode.Move && this.m_multiselect.Count > 0) { this.m_selection = this.m_multiselect[0]; if (this.SelectionChanged != null) { this.SelectionChanged(this, EventArgs.Empty); } } if (this.m_selection != null && this.m_highlight != null && this.m_toolmode == ToolMode.Link) { if (this.LinkOperation != null) { // special case for linking entities for subtypes EventArgs args = EventArgs.Empty; if (this.Cursor == Cursors.UpArrow && (this.m_selection is DocEntity || this.m_selection is DocDefinitionRef) && this.m_highlight is DocEntity) { //... also need to determine if referenced type is an entity args = null; } this.LinkOperation(this, args); } this.Redraw(); } this.Invalidate(); }
public void Save() { SortedList <string, DocDefined> mapDefined = new SortedList <string, DocDefined>(this); SortedList <string, DocEnumeration> mapEnum = new SortedList <string, DocEnumeration>(this); SortedList <string, DocSelect> mapSelect = new SortedList <string, DocSelect>(this); SortedList <string, DocEntity> mapEntity = new SortedList <string, DocEntity>(this); SortedList <string, DocFunction> mapFunction = new SortedList <string, DocFunction>(this); SortedList <string, DocGlobalRule> mapRule = new SortedList <string, DocGlobalRule>(this); SortedList <string, DocObject> mapGeneral = new SortedList <string, DocObject>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { if (this.m_included == null || this.m_included.ContainsKey(docSchema)) { foreach (DocType docType in docSchema.Types) { if (this.m_included == null || this.m_included.ContainsKey(docType)) { if (docType is DocDefined) { if (!mapDefined.ContainsKey(docType.Name)) { mapDefined.Add(docType.Name, (DocDefined)docType); } } else if (docType is DocEnumeration) { mapEnum.Add(docType.Name, (DocEnumeration)docType); } else if (docType is DocSelect) { mapSelect.Add(docType.Name, (DocSelect)docType); } if (!mapGeneral.ContainsKey(docType.Name)) { mapGeneral.Add(docType.Name, docType); } } } foreach (DocEntity docEnt in docSchema.Entities) { if (this.m_included == null || this.m_included.ContainsKey(docEnt)) { if (!mapEntity.ContainsKey(docEnt.Name)) { mapEntity.Add(docEnt.Name, docEnt); } if (!mapGeneral.ContainsKey(docEnt.Name)) { mapGeneral.Add(docEnt.Name, docEnt); } } } foreach (DocFunction docFunc in docSchema.Functions) { if ((this.m_included == null || this.m_included.ContainsKey(docFunc)) && !mapFunction.ContainsKey(docFunc.Name)) { mapFunction.Add(docFunc.Name, docFunc); } } foreach (DocGlobalRule docRule in docSchema.GlobalRules) { if (this.m_included == null || this.m_included.ContainsKey(docRule)) { mapRule.Add(docRule.Name, docRule); } } } } } string dirpath = System.IO.Path.GetDirectoryName(this.m_filename); if (!System.IO.Directory.Exists(dirpath)) { System.IO.Directory.CreateDirectory(dirpath); } using (System.IO.StreamWriter writer = new System.IO.StreamWriter(this.m_filename)) { if (writer.BaseStream.CanSeek) { writer.BaseStream.SetLength(0); } string schemaid = this.m_project.GetSchemaIdentifier(); string org = "buildingSMART International Limited"; writer.Write("" + "(*\r\n" + "Copyright by:\r\n" + org + ", 1996-" + DateTime.UtcNow.Year + "\r\n" + "\r\n" + "Any technical documentation made available by " + org + "\r\n" + "is the copyrighted work of " + org + " and is owned by the \r\n" + org + ". It may be photocopied, used in software development, \r\n" + "or translated into another computer language without prior written consent from \r\n" + org + " provided that full attribution is given. \r\n" + "Prior written consent is required if changes are made to the technical specification.\r\n" + "\r\n" + "This material is delivered to you as is and " + org + " makes \r\n" + "no warranty of any kind with regard to it, including, but not limited to, the implied \r\n" + "warranties as to its accuracy or fitness for a particular purpose. Any use of the \r\n" + "technical documentation or the information contained therein is at the risk of the user. \r\n" + "Documentation may include technical or other inaccuracies or typographical errors. \r\n" + org + " shall not be liable for errors contained therein or \r\n" + "for incidental consequential damages in connection with the furnishing, performance or use \r\n" + "of the material. The information contained in this document is subject to change without notice.\r\n" + "\r\n" + "Issue date:\r\n" + DateTime.Today.ToLongDateString() + "\r\n" + //"December 27, 2012\r\n" + "\r\n" + "*)\r\n" + "\r\n"); writer.WriteLine("SCHEMA " + schemaid.ToUpper() + ";"); writer.WriteLine(); // stripped optional applicable if MVD is used if (this.m_included != null) { writer.WriteLine("TYPE IfcStrippedOptional = BOOLEAN;"); writer.WriteLine("END_TYPE;"); writer.WriteLine(); } // defined types foreach (DocDefined docDef in mapDefined.Values) { writer.Write("TYPE "); writer.Write(docDef.Name); writer.Write(" = "); if (docDef.Aggregation != null) { WriteExpressAggregation(writer, docDef.Aggregation); } writer.Write(docDef.DefinedType); string length = ""; if (docDef.Length > 0) { length = "(" + docDef.Length.ToString() + ")"; } else if (docDef.Length < 0) { int len = -docDef.Length; length = "(" + len.ToString() + ") FIXED"; } writer.Write(length); writer.WriteLine(";"); if (docDef.WhereRules.Count > 0) { writer.WriteLine(" WHERE"); foreach (DocWhereRule where in docDef.WhereRules) { writer.Write("\t"); writer.Write(where.Name); writer.Write(" : "); writer.Write(MakeLongFormExpression(where.Expression, schemaid)); writer.WriteLine(";"); } } writer.WriteLine("END_TYPE;"); writer.WriteLine(); } // enumerations foreach (DocEnumeration docEnum in mapEnum.Values) { writer.Write("TYPE "); writer.Write(docEnum.Name); writer.Write(" = ENUMERATION OF"); writer.WriteLine(); for (int i = 0; i < docEnum.Constants.Count; i++) { DocConstant docConst = docEnum.Constants[i]; if (i == 0) { writer.Write("\t("); } else { writer.Write("\t,"); } writer.Write(docConst.Name); if (i == docEnum.Constants.Count - 1) { writer.WriteLine(");"); } else { writer.WriteLine(); } } writer.WriteLine("END_TYPE;"); writer.WriteLine(); } // selects foreach (DocSelect docSelect in mapSelect.Values) { writer.Write("TYPE "); writer.Write(docSelect.Name); writer.Write(" = SELECT"); writer.WriteLine(); SortedList <string, DocSelectItem> sortSelect = new SortedList <string, DocSelectItem>(this); foreach (DocSelectItem docSelectItem in docSelect.Selects) { if (!sortSelect.ContainsKey(docSelectItem.Name)) { sortSelect.Add(docSelectItem.Name, docSelectItem); } else { this.ToString(); } } int nSelect = 0; for (int i = 0; i < sortSelect.Keys.Count; i++) { DocSelectItem docConst = sortSelect.Values[i]; DocObject docRefEnt = null; if (mapGeneral.TryGetValue(docConst.Name, out docRefEnt)) { if (this.m_included == null || this.m_included.ContainsKey(docRefEnt)) { if (nSelect == 0) { writer.Write("\t("); } else { writer.WriteLine(); writer.Write("\t,"); } nSelect++; writer.Write(docConst.Name); } } } writer.WriteLine(");"); writer.WriteLine("END_TYPE;"); writer.WriteLine(); } // entities foreach (DocEntity docEntity in mapEntity.Values) { writer.Write("ENTITY "); writer.Write(docEntity.Name); if ((docEntity.IsAbstract())) { writer.WriteLine(); writer.Write(" ABSTRACT"); } // build up list of subtypes from other schemas SortedList <string, DocEntity> subtypes = new SortedList <string, DocEntity>(this); // sort to match Visual Express foreach (DocEntity eachent in mapEntity.Values) { if (eachent.BaseDefinition != null && eachent.BaseDefinition.Equals(docEntity.Name)) { subtypes.Add(eachent.Name, eachent); } } if (subtypes.Count > 0) { StringBuilder sb = new StringBuilder(); // Capture all subtypes, not just those within schema int countsub = 0; foreach (string ds in subtypes.Keys) { DocEntity refent = subtypes[ds]; if (this.m_included == null || this.m_included.ContainsKey(refent)) { countsub++; if (sb.Length != 0) { sb.Append("\r\n ,"); } sb.Append(ds); } } if (!docEntity.IsAbstract()) { writer.WriteLine(); } if (countsub > 1 || this.m_oneof) { writer.Write(" SUPERTYPE OF (ONEOF\r\n (" + sb.ToString() + "))"); } else if (countsub == 1) { writer.Write(" SUPERTYPE OF (" + sb.ToString() + ")"); } } if (docEntity.BaseDefinition != null) { writer.WriteLine(); writer.Write(" SUBTYPE OF ("); writer.Write(docEntity.BaseDefinition); writer.Write(")"); } writer.WriteLine(";"); // direct attributes bool hasinverse = false; bool hasderived = false; foreach (DocAttribute attr in docEntity.Attributes) { if (attr.Inverse == null && attr.Derived == null) { writer.Write("\t"); writer.Write(attr.Name); writer.Write(" : "); if (attr.IsOptional) { writer.Write("OPTIONAL "); } WriteExpressAggregation(writer, attr); if (this.m_included == null || this.m_included.ContainsKey(attr)) { writer.Write(attr.DefinedType); } else { writer.Write("IfcStrippedOptional"); } writer.WriteLine(";"); } else if (attr.Inverse != null && attr.Derived == null) { DocObject docref = null; if (mapGeneral.TryGetValue(attr.DefinedType, out docref)) { if (this.m_included == null || this.m_included.ContainsKey(docref)) { hasinverse = true; } } } else if (attr.Derived != null) { hasderived = true; } } // derived attributes if (hasderived) { writer.WriteLine(" DERIVE"); foreach (DocAttribute attr in docEntity.Attributes) { if (attr.Derived != null) { // determine the superclass having the attribute DocEntity found = null; DocEntity super = docEntity; while (super != null && found == null && super.BaseDefinition != null) { super = mapEntity[super.BaseDefinition] as DocEntity; if (super != null) { foreach (DocAttribute docattr in super.Attributes) { if (docattr.Name.Equals(attr.Name)) { // found class found = super; break; } } } } writer.Write("\t"); if (found != null) { // overridden attribute writer.Write("SELF\\"); writer.Write(found.Name); writer.Write("."); } writer.Write(attr.Name); writer.Write(" : "); WriteExpressAggregation(writer, attr); writer.Write(attr.DefinedType); writer.Write(" := "); writer.Write(attr.Derived); writer.WriteLine(";"); } } } // inverse attributes if (hasinverse) { writer.WriteLine(" INVERSE"); foreach (DocAttribute attr in docEntity.Attributes) { if (attr.Inverse != null && attr.Derived == null) { DocObject docref = null; if (mapGeneral.TryGetValue(attr.DefinedType, out docref)) { if (this.m_included == null || this.m_included.ContainsKey(docref)) { writer.Write("\t"); writer.Write(attr.Name); writer.Write(" : "); WriteExpressAggregation(writer, attr); writer.Write(attr.DefinedType); writer.Write(" FOR "); writer.Write(attr.Inverse); writer.WriteLine(";"); } } } } } // unique rules if (docEntity.UniqueRules.Count > 0) { writer.WriteLine(" UNIQUE"); foreach (DocUniqueRule where in docEntity.UniqueRules) { writer.Write("\t"); writer.Write(where.Name); writer.Write(" : "); foreach (DocUniqueRuleItem ruleitem in where.Items) { if (ruleitem != where.Items[0]) { writer.Write(", "); } writer.Write(ruleitem.Name); } writer.WriteLine(";"); } } // where rules if (docEntity.WhereRules.Count > 0) { writer.WriteLine(" WHERE"); foreach (DocWhereRule where in docEntity.WhereRules) { writer.Write("\t"); writer.Write(where.Name); writer.Write(" : "); writer.Write(MakeLongFormExpression(where.Expression, schemaid)); writer.WriteLine(";"); } } writer.WriteLine("END_ENTITY;"); writer.WriteLine(); } // functions foreach (DocFunction docFunction in mapFunction.Values) { writer.Write("FUNCTION "); writer.WriteLine(docFunction.Name); writer.WriteLine(MakeLongFormExpression(docFunction.Expression, schemaid)); writer.WriteLine("END_FUNCTION;"); writer.WriteLine(); } // rules foreach (DocGlobalRule docRule in mapRule.Values) { writer.Write("RULE "); writer.Write(docRule.Name); writer.WriteLine(" FOR"); writer.Write("\t("); writer.Write(docRule.ApplicableEntity); writer.WriteLine(");"); writer.WriteLine(docRule.Expression); // where writer.WriteLine(" WHERE"); foreach (DocWhereRule docWhere in docRule.WhereRules) { writer.Write(" "); writer.Write(docWhere.Name); writer.Write(" : "); writer.Write(MakeLongFormExpression(docWhere.Expression, schemaid)); writer.WriteLine(";"); } writer.WriteLine("END_RULE;"); writer.WriteLine(); } writer.WriteLine("END_SCHEMA;"); } }
/// <summary> /// Recursively searches tree for item and selects it /// </summary> /// <param name="node"></param> /// <param name="selection"></param> private void UpdateTreeSelection(TreeNode node, DocObject selection) { if (node.Tag == selection) { this.treeView.SelectedNode = node; return; } foreach (TreeNode child in node.Nodes) { UpdateTreeSelection(child, selection); } }
private SEntity Pick(Point pt, out int iAttr, out DocAttribute docAttribute, out Rectangle rc) { docAttribute = null; iAttr = -1; rc = new Rectangle(); foreach (Rectangle rect in this.m_hitmap.Keys) { if (rect.Contains(pt)) { rc = rect; iAttr = (pt.Y - rc.Top) / FormatPNG.CY - 1; SEntity sel = this.m_hitmap[rc]; if (sel is DocTemplateDefinition) { return(sel); } else { DocModelRuleEntity ruleEntity = sel as DocModelRuleEntity; DocEntity docEntity = null; if (ruleEntity != null) { DocObject docObjRef = null; if (this.m_template != null && !String.IsNullOrEmpty(this.m_template.Code)) { foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { if (docSchema.Name.Equals(this.m_template.Code, StringComparison.OrdinalIgnoreCase)) { docObjRef = docSchema.GetDefinition(ruleEntity.Name); break; } } } } if (docObjRef == null) { docObjRef = this.m_project.GetDefinition(ruleEntity.Name); } if (docObjRef is DocEntity) { docEntity = (DocEntity)docObjRef; List <DocAttribute> listAttr = new List <DocAttribute>(); FormatPNG.BuildAttributeList(docEntity, listAttr, this.m_project); if (iAttr >= 0 && iAttr < listAttr.Count) { docAttribute = listAttr[iAttr]; foreach (DocModelRule ruleAttr in ruleEntity.Rules) { if (ruleAttr is DocModelRuleAttribute && ruleAttr.Name.Equals(docAttribute.Name)) { return(ruleAttr); } } } } } else if (this.m_template != null) { docEntity = this.m_project.GetDefinition(this.m_template.Type) as DocEntity; List <DocAttribute> listAttr = new List <DocAttribute>(); FormatPNG.BuildAttributeList(docEntity, listAttr, this.m_project); if (iAttr >= 0 && iAttr < listAttr.Count) { docAttribute = listAttr[iAttr]; if (this.m_template.Rules != null) { foreach (DocModelRule ruleAttr in this.m_template.Rules) { if (ruleAttr is DocModelRuleAttribute && ruleAttr.Name.Equals(docAttribute.Name)) { return(ruleAttr); } } } } } } return(sel); } } return(null); }
private void CtlExpressG_MouseDown(object sender, MouseEventArgs e) { if (e.Button != System.Windows.Forms.MouseButtons.Left) return; bool multi = ((System.Windows.Forms.Control.ModifierKeys & Keys.Control) == Keys.Control); this.m_mousedown = true; this.m_ptDown = e.Location; if (!multi) { this.m_multiselect.Clear(); } this.Selection = this.Pick(e.Location, out this.m_lineselection, out this.m_handle); UpdateCursor(this.m_handle); m_pointmap.Clear(); if (this.m_selection is DocDefinition) { DocDefinition docDef = (DocDefinition)this.Selection; m_pointmap.Add(docDef, new PointF((float)docDef.DiagramRectangle.X, (float)docDef.DiagramRectangle.Y)); m_selectionsize = new SizeF((float)docDef.DiagramRectangle.Width, (float)docDef.DiagramRectangle.Height); } if (multi && this.Selection is DocDefinition) { DocDefinition docDef = (DocDefinition)this.Selection; if(!this.m_multiselect.Contains(docDef)) { this.m_multiselect.Add(docDef); } } this.Invalidate(); }
SEntity m_instance; // optional instance to highlight //public FormProperties(DocObject docObject, DocObject docParent, DocProject docProject) : this() public void Init(DocObject[] path, DocProject docProject) { TabPage tabpageExist = this.tabControl.SelectedTab; this.tabControl.TabPages.Clear(); this.m_path = path; if (this.m_path == null) { return; } this.m_loadall = true; this.m_target = path[path.Length-1]; if (path.Length > 1) { this.m_parent = path[path.Length - 2]; } this.m_project = docProject; this.m_map = new Dictionary<string, DocObject>(); DocObject docObject = this.m_target; this.toolStripButtonTranslationRemove.Enabled = false; // build map foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { if(!this.m_map.ContainsKey(docEntity.Name)) { this.m_map.Add(docEntity.Name, docEntity); } } foreach (DocType docType in docSchema.Types) { if(!this.m_map.ContainsKey(docType.Name)) { this.m_map.Add(docType.Name, docType); } } } } // General pages applies to all definitions this.tabControl.TabPages.Add(this.tabPageGeneral); this.textBoxGeneralName.Enabled = false; this.textBoxGeneralName.Text = docObject.Name; this.textBoxGeneralDescription.Text = docObject.Documentation; this.listViewLocale.Items.Clear(); foreach (DocLocalization docLocal in docObject.Localization) { ListViewItem lvi = new ListViewItem(); lvi.Tag = docLocal; lvi.Text = docLocal.Locale; lvi.SubItems.Add(docLocal.Name); lvi.SubItems.Add(docLocal.Documentation); this.listViewLocale.Items.Add(lvi); } this.tabControl.TabPages.Add(this.tabPageIdentity); this.textBoxIdentityUuid.Text = docObject.Uuid.ToString(); this.textBoxIdentityCode.Text = docObject.Code; this.textBoxIdentityVersion.Text = docObject.Version; this.comboBoxIdentityStatus.Text = docObject.Status; this.textBoxIdentityAuthor.Text = docObject.Author; this.textBoxIdentityOwner.Text = docObject.Owner; this.textBoxIdentityCopyright.Text = docObject.Copyright; if (docObject is DocModelView) { this.tabControl.TabPages.Add(this.tabPageView); DocModelView docView = (DocModelView)docObject; this.checkBoxViewIncludeAll.Checked = docView.IncludeAllDefinitions; this.textBoxViewRoot.Text = docView.RootEntity; if (docView.BaseView != null) { this.textBoxViewBase.Text = docView.BaseView; try { Guid guidView = new Guid(docView.BaseView); DocModelView docViewBase = this.m_project.GetView(guidView); if (docViewBase != null) { this.textBoxViewBase.Text = docViewBase.Name; } } catch { } } else { this.textBoxViewBase.Text = string.Empty; } this.textBoxViewXsdNamespace.Text = docView.XsdUri; if (docView.XsdFormats != null) { foreach (DocXsdFormat docFormat in docView.XsdFormats) { ListViewItem lvi = new ListViewItem(); lvi.Tag = docFormat; lvi.Text = docFormat.Entity; lvi.SubItems.Add(docFormat.Attribute); lvi.SubItems.Add(docFormat.XsdFormat.ToString()); lvi.SubItems.Add(docFormat.XsdTagless.ToString()); this.listViewViewXsd.Items.Add(lvi); } } } else if (docObject is DocExchangeDefinition) { this.tabControl.TabPages.Add(this.tabPageExchange); DocExchangeDefinition docExchange = (DocExchangeDefinition)docObject; this.checkBoxExchangeImport.Checked = ((docExchange.Applicability & DocExchangeApplicabilityEnum.Import) != 0); this.checkBoxExchangeExport.Checked = ((docExchange.Applicability & DocExchangeApplicabilityEnum.Export) != 0); if (docExchange.Icon != null) { try { this.panelIcon.BackgroundImage = Image.FromStream(new System.IO.MemoryStream(docExchange.Icon)); } catch { } } else { this.panelIcon.BackgroundImage = null; } this.comboBoxExchangeClassProcess.Text = docExchange.ExchangeClass; this.comboBoxExchangeClassSender.Text = docExchange.SenderClass; this.comboBoxExchangeClassReceiver.Text = docExchange.ReceiverClass; } else if (docObject is DocTemplateDefinition) { this.tabControl.TabPages.Add(this.tabPageTemplate); DocTemplateDefinition docTemplate = (DocTemplateDefinition)docObject; this.tabControl.TabPages.Add(this.tabPageOperations); this.tabControl.TabPages.Add(this.tabPageUsage); this.listViewUsage.Items.Clear(); // usage from other templates foreach(DocTemplateDefinition docTemp in this.m_project.Templates) { InitUsageFromTemplate(docTemp, docTemplate); } // usage from model views foreach (DocModelView docView in this.m_project.ModelViews) { foreach (DocConceptRoot docRoot in docView.ConceptRoots) { foreach (DocTemplateUsage docUsage in docRoot.Concepts) { if (docUsage.Definition == docTemplate) { DocObject[] usagepath = new DocObject[] { docRoot.ApplicableEntity, docRoot, docUsage }; ListViewItem lvi = new ListViewItem(); lvi.Tag = usagepath; lvi.Text = docView.Name; lvi.SubItems.Add(docRoot.ApplicableEntity.Name); this.listViewUsage.Items.Add(lvi); } } } } this.ctlRules.Project = this.m_project; this.ctlRules.BaseTemplate = this.m_parent as DocTemplateDefinition; this.ctlRules.Template = docTemplate; this.ctlOperators.Project = this.m_project; this.ctlOperators.Template = docTemplate; this.ctlOperators.Rule = null; } else if (docObject is DocConceptRoot) { this.tabControl.TabPages.Add(this.tabPageConceptRoot); DocConceptRoot docRoot = (DocConceptRoot)docObject; //DocEntity docEntity = (DocEntity)this.m_parent; DocEntity docEntity = docRoot.ApplicableEntity; DocModelView docView = null; foreach (DocModelView docViewEach in this.m_project.ModelViews) { if (docViewEach.ConceptRoots.Contains(docRoot)) { docView = docViewEach; break; } } DocModelView[] listViews = docProject.GetViewInheritance(docView); ; // find all inherited concepts List<DocTemplateDefinition> listTemplate = new List<DocTemplateDefinition>(); Dictionary<DocTemplateDefinition, DocEntity> mapTemplate = new Dictionary<DocTemplateDefinition, DocEntity>(); Dictionary<DocTemplateDefinition, DocModelView> mapView = new Dictionary<DocTemplateDefinition, DocModelView>(); while (docEntity != null) { foreach (DocModelView docSuperView in listViews) { foreach (DocConceptRoot docRootEach in docSuperView.ConceptRoots) { if (docRootEach.ApplicableEntity == docEntity) { foreach (DocTemplateUsage docConcept in docRootEach.Concepts) { if (docConcept.Definition != null) { if (listTemplate.Contains(docConcept.Definition)) { listTemplate.Remove(docConcept.Definition); } listTemplate.Insert(0, docConcept.Definition); mapTemplate[docConcept.Definition] = docEntity; mapView[docConcept.Definition] = docSuperView; } } } } } // recurse upwards docEntity = this.m_project.GetDefinition(docEntity.BaseDefinition) as DocEntity; } this.listViewConceptRoot.Items.Clear(); foreach (DocTemplateDefinition dtd in listTemplate) { ListViewItem lvi = new ListViewItem(); lvi.Tag = dtd; lvi.Text = dtd.Name; DocEntity docTemplateEntity = mapTemplate[dtd]; lvi.SubItems.Add(docTemplateEntity.Name); DocModelView docTemplateView = mapView[dtd]; lvi.SubItems.Add(docTemplateView.Name); // find local override if any lvi.ImageIndex = 3; foreach (DocTemplateUsage docConcept in docRoot.Concepts) { if(docConcept.Definition == dtd) { UpdateConceptInheritance(lvi, docConcept); break; } } this.listViewConceptRoot.Items.Add(lvi); } } else if (docObject is DocTemplateUsage) { this.tabControl.TabPages.Add(this.tabPageConcept); this.tabControl.TabPages.Add(this.tabPageRequirements); DocTemplateUsage docUsage = (DocTemplateUsage)docObject; this.ctlParameters.Project = this.m_project; this.ctlParameters.ConceptRoot = this.m_path[3] as DocConceptRoot; this.ctlParameters.ConceptItem = this.ctlParameters.ConceptRoot; this.ctlParameters.ConceptLeaf = docUsage; this.LoadModelView(); } else if (docObject is DocSchema) { DocSchema docSchema = (DocSchema)docObject; } else if (docObject is DocEntity) { DocEntity docEntity = (DocEntity)docObject; this.tabControl.TabPages.Add(this.tabPageEntity); this.textBoxEntityBase.Text = docEntity.BaseDefinition; this.checkBoxEntityAbstract.Checked = docEntity.IsAbstract(); } else if(docObject is DocDefined) { DocDefined docDefined = (DocDefined)docObject; this.textBoxAttributeType.Text = docDefined.DefinedType; this.tabControl.TabPages.Add(this.tabPageAttribute); this.labelAttributeInverse.Visible = false; this.textBoxAttributeInverse.Visible = false; this.buttonAttributeInverse.Visible = false; this.checkBoxAttributeOptional.Visible = false; this.checkBoxXsdTagless.Visible = false; this.labelAttributeXsdFormat.Visible = false; this.comboBoxAttributeXsdFormat.Visible = false; this.LoadAttributeCardinality(); } else if (docObject is DocAttribute) { DocAttribute docAttribute = (DocAttribute)docObject; this.tabControl.TabPages.Add(this.tabPageAttribute); this.textBoxAttributeType.Text = docAttribute.DefinedType; this.textBoxAttributeInverse.Text = docAttribute.Inverse; this.textBoxAttributeDerived.Text = docAttribute.Derived; this.checkBoxAttributeOptional.Checked = docAttribute.IsOptional; if (docAttribute.XsdTagless != null) { if(docAttribute.XsdTagless == true) { this.checkBoxXsdTagless.CheckState = CheckState.Checked; } else { this.checkBoxXsdTagless.CheckState = CheckState.Unchecked; } } else { this.checkBoxXsdTagless.CheckState = CheckState.Indeterminate; } this.comboBoxAttributeXsdFormat.SelectedItem = docAttribute.XsdFormat.ToString(); this.LoadAttributeCardinality(); } else if (docObject is DocConstraint) { DocConstraint docConstraint = (DocConstraint)docObject; this.tabControl.TabPages.Add(this.tabPageExpression); this.textBoxExpression.Text = docConstraint.Expression; } else if (docObject is DocPropertySet) { this.tabControl.TabPages.Add(this.tabPagePropertySet); DocPropertySet docPset = (DocPropertySet)docObject; this.LoadApplicability(); this.comboBoxPsetType.Text = docPset.PropertySetType; } else if (docObject is DocProperty) { this.tabControl.TabPages.Add(this.tabPageProperty); DocProperty docProp = (DocProperty)docObject; this.comboBoxPropertyType.Text = docProp.PropertyType.ToString(); this.textBoxPropertyData.Text = docProp.PrimaryDataType; if (!String.IsNullOrEmpty(docProp.SecondaryDataType)) { string[] enumhost = docProp.SecondaryDataType.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (enumhost.Length == 2) { string[] enumvals = enumhost[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); this.textBoxPropertyData.Text = enumhost[0]; this.listViewPropertyEnums.Items.Clear(); foreach (string eachenum in enumvals) { ListViewItem lvi = new ListViewItem(); lvi.Tag = eachenum; lvi.Text = eachenum; this.listViewPropertyEnums.Items.Add(lvi); } } } } else if (docObject is DocQuantitySet) { this.tabControl.TabPages.Add(this.tabPagePropertySet); this.LoadApplicability(); this.comboBoxPsetType.Enabled = false; } else if (docObject is DocQuantity) { this.tabControl.TabPages.Add(this.tabPageQuantity); DocQuantity docProp = (DocQuantity)docObject; this.comboBoxQuantityType.Text = docProp.QuantityType.ToString(); } else if (docObject is DocExample) { this.tabControl.TabPages.Add(this.tabPagePropertySet); this.tabControl.TabPages.Add(this.tabPageExample); this.LoadApplicability(); this.comboBoxPsetType.Enabled = false; this.buttonApplicabilityAddTemplate.Visible = true; DocExample docExample = (DocExample)docObject; if (docExample.File != null) { this.textBoxExample.Text = Encoding.ASCII.GetString(docExample.File); this.buttonExampleClear.Enabled = true; } else { this.textBoxExample.Text = String.Empty; this.buttonExampleClear.Enabled = false; } this.checkedListBoxExampleViews.Items.Clear(); foreach (DocModelView docView in this.m_project.ModelViews) { this.checkedListBoxExampleViews.Items.Add(docView, (docExample.Views.Contains(docView))); } } else if(docObject is DocChangeAction) { this.tabControl.TabPages.Add(this.tabPageChange); DocChangeAction docChange = (DocChangeAction)docObject; this.toolStripButtonChangeSPF.Checked = docChange.ImpactSPF; this.toolStripButtonChangeXML.Checked = docChange.ImpactXML; switch(docChange.Action) { case DocChangeActionEnum.NOCHANGE: this.toolStripComboBoxChange.SelectedIndex = 0; break; case DocChangeActionEnum.ADDED: this.toolStripComboBoxChange.SelectedIndex = 1; break; case DocChangeActionEnum.DELETED: this.toolStripComboBoxChange.SelectedIndex = 2; break; case DocChangeActionEnum.MODIFIED: this.toolStripComboBoxChange.SelectedIndex = 3; break; case DocChangeActionEnum.MOVED: this.toolStripComboBoxChange.SelectedIndex = 4; break; } this.listViewChange.Items.Clear(); foreach(DocChangeAspect docAspect in docChange.Aspects) { ListViewItem lvi = new ListViewItem(); lvi.Text = docAspect.Aspect.ToString(); lvi.SubItems.Add(docAspect.OldValue); lvi.SubItems.Add(docAspect.NewValue); this.listViewChange.Items.Add(lvi); } } if (tabpageExist != null && this.tabControl.TabPages.Contains(tabpageExist)) { this.tabControl.SelectedTab = tabpageExist; } this.m_loadall = false; }
private g SaveDefinition(DocObject docObj, string displayname) { g group = new g(); group.id = docObj.Name; DocDefinition docDef = docObj as DocDefinition; if (docDef == null || docDef.DiagramRectangle == null) { return(group); } double x = docDef.DiagramRectangle.X * CtlExpressG.Factor; double y = docDef.DiagramRectangle.Y * CtlExpressG.Factor; double cx = docDef.DiagramRectangle.Width * CtlExpressG.Factor; double cy = docDef.DiagramRectangle.Height * CtlExpressG.Factor; rect r = new rect(); r.x = x.ToString(); r.y = y.ToString(); r.width = cx.ToString(); r.height = cy.ToString(); r.stroke = "black"; group.rect.Add(r); text t = new text(); t.x = (x + cx * 0.5).ToString(); t.y = (y + cy * 0.5).ToString(); t.fill = "black"; t.alignment_baseline = "middle"; t.text_anchor = "middle"; t.font_size = "10"; t.font_family = "Arial, Helvetica, sans-serif"; if (displayname != null) { t.value = displayname; } else { t.value = docDef.Name; } group.text.Add(t); if (this.m_format == DiagramFormat.UML) { y += 10; group.fill = "lightyellow"; t.y = y.ToString(); t.alignment_baseline = "top"; t.font_weight = "bold"; t.value = docDef.Name; // separator line y += 2; List <DocPoint> listPoint = new List <DocPoint>(); listPoint.Add(new DocPoint(x / CtlExpressG.Factor, y / CtlExpressG.Factor)); listPoint.Add(new DocPoint((x + cx) / CtlExpressG.Factor, y / CtlExpressG.Factor)); SaveLine(group, listPoint, null, false); y += 2; // add attributes if (docDef is DocDefinitionRef) { DocDefinitionRef docDefRef = (DocDefinitionRef)docDef; DocObject docObjRef = this.m_project.GetDefinition(docDefRef.Name); if (docObjRef is DocEntity) { DocEntity docEnt = (DocEntity)docObjRef; foreach (DocAttribute docAtt in docEnt.Attributes) { if (docAtt.Derived == null && docAtt.Inverse == null) { DocObject docAttrType = this.m_project.GetDefinition(docAtt.DefinedType); // include native types, enumerations, and defined types if (docAttrType == null || docAttrType is DocEnumeration || docAttrType is DocDefined) { y += 12; string agg = "[1]"; if (docAtt.AggregationType != 0) { string lower = docAtt.AggregationLower; string upper = docAtt.AggregationUpper; if (String.IsNullOrEmpty(lower)) { lower = "0"; } if (String.IsNullOrEmpty(upper) || upper == "0") { upper = "*"; } agg = "[" + lower + ".." + upper + "]"; } else if (docAtt.IsOptional) { agg = "[0..1]"; } text ta = new text(); ta.x = (x + 4).ToString(); ta.y = y.ToString(); ta.fill = "black"; ta.alignment_baseline = "top"; ta.text_anchor = "start"; ta.font_size = "9"; ta.font_family = "Arial, Helvetica, sans-serif"; ta.value = docAtt.Name + agg + " : " + docAtt.DefinedType; group.text.Add(ta); } } } // UML only (not in original EXPRESS-G diagrams) foreach (DocAttributeRef docAttrRef in docDefRef.AttributeRefs) { DocAttribute docAtt = docAttrRef.Attribute; //if (docAtt.Inverse == null) { //... also need to capture attribute name... //DrawLine(g, Pens.Black, docAttrRef.DiagramLine, format); SaveLine(group, docAttrRef.DiagramLine, null, false); // draw diamond at beginning of line #if false /// not yet correct if (this.m_format == DiagramFormat.UML) { DocPoint ptHead = docAttrRef.DiagramLine[0]; DocPoint ptNext = docAttrRef.DiagramLine[1]; double ux = ptNext.X - ptHead.X; double uy = ptNext.Y - ptHead.Y; double uv = Math.Sqrt(ux * ux + uy * uy); ux = ux / uv; uy = uy / uv; DocPoint ptR = new DocPoint(ptHead.X + uy * 8, ptHead.Y + ux * 8); DocPoint ptF = new DocPoint(ptHead.X + ux * 16, ptHead.Y + uy * 8); DocPoint ptL = new DocPoint(ptHead.X + uy * 8, ptHead.Y - ux * 8); List <DocPoint> listP = new List <DocPoint>(); listP.Add(ptHead); listP.Add(ptR); listP.Add(ptF); listP.Add(ptL); listP.Add(ptHead); SaveLine(group, listP, null, false); } #endif if (docAtt.Name == "Items") { docAtt.ToString(); } string agg = "[1]"; if (docAtt.AggregationType != 0) { string lower = docAtt.AggregationLower; string upper = docAtt.AggregationUpper; if (String.IsNullOrEmpty(lower)) { lower = "0"; } if (String.IsNullOrEmpty(upper)) { upper = "*"; } agg = "[" + lower + ".." + upper + "]"; } else if (docAtt.IsOptional) { agg = "[0..1]"; } double ty = docAttrRef.DiagramLine[0].Y * CtlExpressG.Factor; if (docAttrRef.DiagramLine[1].Y > docAttrRef.DiagramLine[0].Y) { ty -= 10; } else { ty += 10; } text tr = new text(); tr.x = (docAttrRef.DiagramLine[0].X * CtlExpressG.Factor + 4).ToString(); tr.y = (ty).ToString(); tr.fill = "black"; tr.alignment_baseline = "top"; tr.text_anchor = "start"; tr.font_size = "9"; tr.font_family = "Arial, Helvetica, sans-serif"; tr.value = docAtt.Name + agg; group.text.Add(tr); } } } } } else { if (docDef is DocEntity) { group.fill = "yellow"; } else if (docDef is DocType) { group.fill = "green"; } else if (docDef is DocPageTarget) { group.fill = "blue"; r.rx = "10"; r.ry = "10"; } else if (docDef is DocPageSource) { group.fill = "silver"; r.rx = "10"; r.ry = "10"; } else { group.fill = "grey"; } } return(group); }
/// <summary> /// Sets content to web browser and text editing /// </summary> /// <param name="content"></param> 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; } }
private static string FormatAttribute(DocEntity docEntity, DocAttribute docAttr, Dictionary <string, DocObject> map) { DocObject mapDef = null; map.TryGetValue(docAttr.DefinedType, out mapDef); StringBuilder sb = new StringBuilder(); sb.Append("\t\t\t\t\t<xs:element"); sb.Append(" name=\""); sb.Append(docAttr.Name); sb.Append("\""); if ((docAttr.AggregationType == 0 && mapDef is DocEntity) || docAttr.XsdFormat == DocXsdFormatEnum.Attribute) { sb.Append(" type=\""); sb.Append(ToXsdType(docAttr.DefinedType)); sb.Append("\""); } if (docAttr.IsOptional || mapDef is DocEntity && (docAttr.GetAggregation() == DocAggregationEnum.NONE || docAttr.GetAggregationNestingLower() == 1 && docAttr.GetAggregationNestingUpper() == 1) || docAttr.Inverse != null) { sb.Append(" nillable=\"true\""); } if (docAttr.IsOptional || docAttr.Inverse != null || IsAttributeOverridden(docEntity, docAttr, map))// || (docAttr.GetAggregation() == DocAggregationEnum.SET && docAttr.GetAggregationNestingLower() == 0))// || docAttr.XsdFormat == DocXsdFormatEnum.Attribute) { sb.Append(" minOccurs=\"0\""); } if (docAttr.AggregationType != 0 && docAttr.XsdFormat == DocXsdFormatEnum.Attribute) { sb.Append(" maxOccurs=\"1\""); } if (mapDef is DocSelect || (docAttr.AggregationType != 0 && docAttr.XsdFormat != DocXsdFormatEnum.Attribute)) // added { sb.Append(">"); sb.AppendLine(); sb.Append("\t\t\t\t\t\t<xs:complexType>"); sb.AppendLine(); if (mapDef is DocSelect) { sb.Append("\t\t\t\t\t\t\t<xs:group ref=\""); } else { sb.Append("\t\t\t\t\t\t\t<xs:sequence>"); sb.AppendLine(); sb.Append("\t\t\t\t\t\t\t\t<xs:element ref=\""); } string xsdtype = ToXsdType(docAttr.DefinedType); if (mapDef == null) { xsdtype = xsdtype.Replace("xs:", "ifc:") + "-wrapper"; } else if (docAttr.XsdFormat == DocXsdFormatEnum.Element && (mapDef is DocDefined || mapDef is DocEnumeration)) { xsdtype += "-wrapper"; } sb.Append(xsdtype); sb.Append("\""); if (docAttr.AggregationType != 0) { int agglower = docAttr.GetAggregationNestingLower(); if (agglower != 1 || docAttr.AggregationAttribute != null) // was 1 { sb.Append(" minOccurs=\""); sb.Append(docAttr.GetAggregationNestingLower()); sb.Append("\""); } string maxoccurs = "unbounded"; if (!String.IsNullOrEmpty(docAttr.AggregationUpper) && docAttr.AggregationUpper != "0" && docAttr.AggregationUpper != "?") { maxoccurs = docAttr.GetAggregationNestingUpper().ToString(); } sb.Append(" maxOccurs=\""); sb.Append(maxoccurs); sb.Append("\""); } sb.Append("/>"); sb.AppendLine(); if (!(mapDef is DocSelect)) { sb.Append("\t\t\t\t\t\t\t</xs:sequence>"); sb.AppendLine(); } if (docAttr.AggregationType != 0) { sb.Append("\t\t\t\t\t\t\t<xs:attribute ref=\"ifc:itemType\" fixed=\""); sb.Append(xsdtype); sb.Append("\"/>"); sb.AppendLine(); sb.Append("\t\t\t\t\t\t\t<xs:attribute ref=\"ifc:cType\" fixed=\""); DocAttribute docAggregation = docAttr; while (docAggregation != null) { // nested collections if (docAggregation != docAttr) { sb.Append(" "); } sb.Append(docAggregation.GetAggregation().ToString().ToLower()); if ((docAggregation.AggregationFlag & 2) != 0) { sb.Append("-unique"); } // next docAggregation = docAggregation.AggregationAttribute; } sb.Append("\"/>"); sb.AppendLine(); sb.Append("\t\t\t\t\t\t\t<xs:attribute ref=\"ifc:arraySize\" use=\"optional\"/>"); sb.AppendLine(); } sb.Append("\t\t\t\t\t\t</xs:complexType>"); sb.AppendLine(); sb.Append("\t\t\t\t\t</xs:element>"); sb.AppendLine(); } else { sb.Append("/>"); sb.AppendLine(); } return(sb.ToString()); }
public void Save() { string xmlns = "http://www.buildingsmart-tech.org/ifcXML/IFC4/final"; if (this.m_views != null && this.m_views.Length == 1 && !String.IsNullOrEmpty(this.m_views[0].Code)) { DocModelView docView = this.m_views[0]; if (!String.IsNullOrEmpty(docView.XsdUri)) { xmlns = docView.XsdUri; } else if (!String.IsNullOrEmpty(docView.Code)) { xmlns = "http://www.buildingsmart-tech.org/ifcXML/MVD4/" + docView.Code; } } // build map of types Dictionary <string, DocObject> map = new Dictionary <string, DocObject>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEnt in docSchema.Entities) { if (!map.ContainsKey(docEnt.Name)) { map.Add(docEnt.Name, docEnt); } } foreach (DocType docType in docSchema.Types) { if (!map.ContainsKey(docType.Name)) { map.Add(docType.Name, docType); } } } } SortedList <string, DocDefined> mapDefined = new SortedList <string, DocDefined>(this); SortedList <string, DocEnumeration> mapEnum = new SortedList <string, DocEnumeration>(this); SortedList <string, DocSelect> mapSelect = new SortedList <string, DocSelect>(this); SortedList <string, DocEntity> mapEntity = new SortedList <string, DocEntity>(this); SortedList <string, DocFunction> mapFunction = new SortedList <string, DocFunction>(this); SortedList <string, DocGlobalRule> mapRule = new SortedList <string, DocGlobalRule>(this); SortedList <string, string> sort = new SortedList <string, string>(new FormatXSD(null)); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { if (this.m_included == null || this.m_included.ContainsKey(docSchema)) { foreach (DocType docType in docSchema.Types) { if (this.m_included == null || this.m_included.ContainsKey(docType)) { if (docType is DocDefined) { if (!mapDefined.ContainsKey(docType.Name)) { mapDefined.Add(docType.Name, (DocDefined)docType); } } else if (docType is DocEnumeration) { mapEnum.Add(docType.Name, (DocEnumeration)docType); } else if (docType is DocSelect) { mapSelect.Add(docType.Name, (DocSelect)docType); } } } foreach (DocEntity docEnt in docSchema.Entities) { if (this.m_included == null || this.m_included.ContainsKey(docEnt)) { if (!mapEntity.ContainsKey(docEnt.Name)) { mapEntity.Add(docEnt.Name, docEnt); } // check for any attributes that are lists of value types requiring wrapper, e.g. IfcTextFontName foreach (DocAttribute docAttr in docEnt.Attributes) { DocObject docObjRef = null; if (docAttr.DefinedType != null && docAttr.GetAggregation() != DocAggregationEnum.NONE && map.TryGetValue(docAttr.DefinedType, out docObjRef) && docObjRef is DocDefined && docAttr.XsdFormat == DocXsdFormatEnum.Element && !(docAttr.XsdTagless == true) && !sort.ContainsKey(docAttr.DefinedType)) { sort.Add(docAttr.DefinedType, docAttr.DefinedType); } } } } foreach (DocFunction docFunc in docSchema.Functions) { if ((this.m_included == null || this.m_included.ContainsKey(docFunc)) && !mapFunction.ContainsKey(docFunc.Name)) { mapFunction.Add(docFunc.Name, docFunc); } } foreach (DocGlobalRule docRule in docSchema.GlobalRules) { if (this.m_included == null || this.m_included.ContainsKey(docRule)) { mapRule.Add(docRule.Name, docRule); } } } } } using (System.IO.StreamWriter writer = new System.IO.StreamWriter(this.m_filename)) { writer.WriteLine("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); writer.WriteLine("<xs:schema xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" " + "xmlns:ifc=\"" + xmlns + "\" " + "targetNamespace=\"" + xmlns + "\" " + "elementFormDefault=\"qualified\" attributeFormDefault=\"unqualified\" >"); WriteResource(writer, "IfcDoc.xsd1.txt"); // Entities writer.WriteLine("\t<!-- element and complex type declarations (for ENTITY definitions) -->"); foreach (DocEntity docEntity in mapEntity.Values) { writer.Write(FormatEntity(docEntity, map, this.m_included)); } // Selects writer.WriteLine("\t<!-- group declarations (for SELECT data type definitions) -->"); foreach (DocSelect docSelect in mapSelect.Values) { writer.Write(FormatSelect(docSelect, map, this.m_included)); } // Enumerations writer.WriteLine("\t<!-- enumeration type declarations (for ENUMERATION data type definitions) -->"); foreach (DocEnumeration docEnum in mapEnum.Values) { writer.Write(FormatEnum(docEnum)); } // Defined Types writer.WriteLine("\t<!-- simple type declarations (for TYPE defined data type definitions) -->"); foreach (DocDefined docDefined in mapDefined.Values) { writer.Write(FormatDefinedSimple(docDefined)); } WriteResource(writer, "IfcDoc.xsd2.txt"); // sort selects alphabetically Queue <DocSelectItem> queue = new Queue <DocSelectItem>(); foreach (DocSelect docSelect in mapSelect.Values) { foreach (DocSelectItem docSelItem in docSelect.Selects) { queue.Enqueue(docSelItem); } } List <DocDefined> listWrapper = new List <DocDefined>(); // keep track of wrapped types while (queue.Count > 0) { DocSelectItem docItem = queue.Dequeue(); DocObject mapDef = null; if (map.TryGetValue(docItem.Name, out mapDef)) { if (mapDef is DocSelect) { // expand each DocSelect docSub = (DocSelect)mapDef; foreach (DocSelectItem dsi in docSub.Selects) { queue.Enqueue(dsi); } } else if (!sort.ContainsKey(docItem.Name)) { if (this.m_included == null || this.m_included.ContainsKey(mapDef)) { sort.Add(docItem.Name, docItem.Name); } } } } writer.WriteLine("\t<!-- base global wrapper declaration for atomic simple types (for embeded base schema definitions) -->"); foreach (string docItem in sort.Values) { DocObject mapDef = null; if (map.TryGetValue(docItem, out mapDef) && mapDef is DocType) { if (this.m_included == null || this.m_included.ContainsKey(mapDef)) { writer.Write(FormatTypeWrapper((DocType)mapDef, map)); } } } writer.WriteLine("</xs:schema>"); } }
//public FormProperties(DocObject docObject, DocObject docParent, DocProject docProject) : this() public FormProperties(DocObject[] path, DocProject docProject) : this() { this.ctlProperties.Init(path, docProject); }
/// <summary> /// Helper function to populate attributes /// </summary> /// <param name="mvd"></param> /// <param name="doc"></param> private static void ImportMvdObject(Element mvd, DocObject doc) { doc.Name = mvd.Name; doc.Uuid = mvd.Uuid; doc.Version = mvd.Version; doc.Owner = mvd.Owner; doc.Status = mvd.Status; doc.Copyright = mvd.Copyright; doc.Code = mvd.Code; doc.Author = mvd.Author; if (mvd.Definitions != null) { foreach (Definition def in mvd.Definitions) { if (def != null) { // base definition if (def.Body != null) { doc.Documentation = def.Body.Content; } if (def.Links != null) { foreach (Link link in def.Links) { DocLocalization loc = new DocLocalization(); doc.Localization.Add(loc); loc.Name = link.Title; loc.Documentation = link.Content; loc.Category = (DocCategoryEnum)Enum.Parse(typeof(DocCategoryEnum), link.Category.ToString()); loc.Locale = link.Lang; loc.URL = link.Href; } } } } } }
/// <summary> /// Helper function to populate attributes /// </summary> /// <param name="mvd"></param> /// <param name="doc"></param> private static void ExportMvdObject(Element mvd, DocObject doc, bool documentation) { mvd.Name = EnsureValidString(doc.Name); mvd.Uuid = doc.Uuid; mvd.Version = EnsureValidString(doc.Version); mvd.Owner = EnsureValidString(doc.Owner); mvd.Status = EnsureValidString(doc.Status); mvd.Copyright = EnsureValidString(doc.Copyright); mvd.Code = EnsureValidString(doc.Code); mvd.Author = EnsureValidString(doc.Author); #if false // why? if(mvd.Name == null) { mvd.Name = String.Empty; } #endif if (documentation && doc.Documentation != null) { Definition mvdDef = new Definition(); mvdDef.Body = new Body(); mvdDef.Body.Content = doc.Documentation; mvd.Definitions = new List<Definition>(); mvd.Definitions.Add(mvdDef); if (doc.Localization != null && doc.Localization.Count > 0) { mvdDef.Links = new List<Link>(); foreach (DocLocalization docLocal in doc.Localization) { Link mvdLink = new Link(); mvdDef.Links.Add(mvdLink); mvdLink.Title = docLocal.Name; mvdLink.Content = docLocal.Documentation; mvdLink.Lang = docLocal.Locale; mvdLink.Href = docLocal.URL; mvdLink.Category = (CategoryEnum)(int)docLocal.Category; } } } }
private void toolStripMenuItemEditPaste_Click(object sender, EventArgs e) { if (this.treeView.Focused) { DocObject docSelect = this.treeView.SelectedNode.Tag as DocObject; if (docSelect is DocSection && this.m_clipboard is DocSchema && this.m_clipboardNode.Parent.Tag is DocSection) { DocSchema docSchema = (DocSchema)this.m_clipboard; DocSection docSectionNew = (DocSection)docSelect; DocSection docSectionOld = (DocSection)this.m_clipboardNode.Parent.Tag; docSectionOld.Schemas.Remove(docSchema); docSectionNew.Schemas.Add(docSchema); this.m_clipboardNode.Remove(); TreeNode tnSchema = this.LoadNode(this.treeView.SelectedNode, docSchema, docSchema.Name, true); this.treeView.SelectedNode = tnSchema; LoadNodeSchema(tnSchema, docSchema); } else if (docSelect is DocSchema && this.m_clipboard is DocPropertySet) { DocSchema schemaNew = (DocSchema)docSelect; DocPropertySet psetOld = (DocPropertySet)this.m_clipboard; if (this.m_clipboardCut) { if (this.m_clipboardNode.Parent.Parent.Tag is DocSchema) { DocSchema schemaOld = (DocSchema)this.m_clipboardNode.Parent.Parent.Tag; schemaOld.PropertySets.Remove(psetOld); schemaNew.PropertySets.Add(psetOld); this.m_clipboardNode.Remove(); this.m_clipboardNode = null; this.m_clipboard = null; this.m_clipboardCut = false; this.treeView.SelectedNode = this.LoadNode(this.treeView.SelectedNode.Nodes[4], psetOld, psetOld.Name, false); } } else { // TODO... } } else if (docSelect is DocPropertySet && this.m_clipboard is DocProperty) { DocPropertySet psetNew = (DocPropertySet)docSelect; DocProperty propOld = (DocProperty)this.m_clipboard; if (this.m_clipboardCut) { if (this.m_clipboardNode.Parent.Tag is DocPropertySet) { DocPropertySet psetOld = (DocPropertySet)this.m_clipboardNode.Parent.Tag; psetOld.Properties.Remove(propOld); psetNew.Properties.Add(propOld); this.m_clipboardNode.Remove(); this.m_clipboardNode = null; this.m_clipboard = null; this.m_clipboardCut = false; this.treeView.SelectedNode = this.LoadNode(this.treeView.SelectedNode, propOld, propOld.Name, false); } } else { DocProperty propNew = new DocProperty(); propNew.Name = propOld.Name; propNew.Documentation = propOld.Documentation; propNew.PropertyType = propOld.PropertyType; propNew.PrimaryDataType = propOld.PrimaryDataType; propNew.SecondaryDataType = propOld.SecondaryDataType; foreach(DocLocalization localOld in propOld.Localization) { DocLocalization localNew = new DocLocalization(); localNew.Name = localOld.Name; localNew.Documentation = localOld.Documentation; localNew.Category = localOld.Category; localNew.Locale = localOld.Locale; localNew.URL = localOld.URL; propNew.Localization.Add(localNew); } this.treeView.SelectedNode = this.LoadNode(this.treeView.SelectedNode, propNew, propNew.Name, false); } } else if (docSelect is DocConceptRoot && this.m_clipboard is DocTemplateUsage) { DocConceptRoot docRoot = (DocConceptRoot)docSelect; DocTemplateUsage docSource = (DocTemplateUsage)this.m_clipboard; DocTemplateUsage docTarget = new DocTemplateUsage(); docRoot.Concepts.Add(docTarget); CopyTemplateUsage(docSource, docTarget); this.treeView.SelectedNode = LoadNode(this.treeView.SelectedNode, docTarget, docTarget.Name, false); } else if (docSelect is DocModelView && this.m_clipboard is DocExchangeDefinition) { DocModelView docView = (DocModelView)docSelect; DocExchangeDefinition docSource = (DocExchangeDefinition)this.m_clipboard; DocExchangeDefinition docTarget = new DocExchangeDefinition(); docView.Exchanges.Add(docTarget); docTarget.Name = docSource.Name; docTarget.Documentation = docSource.Documentation; docTarget.Author = docSource.Author; docTarget.Copyright = docSource.Copyright; docTarget.Owner = docSource.Owner; docTarget.Icon = docSource.Icon; // copy entity requirements if in same view if (docView.Exchanges.Contains(docSource)) { foreach (DocConceptRoot docRoot in docView.ConceptRoots) { foreach (DocTemplateUsage docConcept in docRoot.Concepts) { List<DocExchangeItem> listNew = new List<DocExchangeItem>(); foreach (DocExchangeItem docSourceER in docConcept.Exchanges) { if (docSourceER.Exchange == docSource) { DocExchangeItem docTargetER = new DocExchangeItem(); docTargetER.Exchange = docTarget; docTargetER.Applicability = docSourceER.Applicability; docTargetER.Requirement = docSourceER.Requirement; listNew.Add(docTargetER); } } foreach (DocExchangeItem docTargetER in listNew) { docConcept.Exchanges.Add(docTargetER); } } } } this.treeView.SelectedNode = LoadNode(this.treeView.SelectedNode, docTarget, docTarget.Name, false); } } else { this.textBoxHTML.Paste(); } }
private void LoadFile(string filename) { this.SetCurrentFile(filename); this.m_lastid = 0; this.m_instances.Clear(); this.m_mapTree.Clear(); this.m_clipboard = null; this.m_project = null; string ext = System.IO.Path.GetExtension(this.m_file).ToLower(); try { switch (ext) { case ".ifcdoc": using (FormatSPF format = new FormatSPF(this.m_file, SchemaDOC.Types, this.m_instances)) { format.Load(); } break; case ".mdb": using (FormatMDB format = new FormatMDB(this.m_file, SchemaDOC.Types, this.m_instances)) { format.Load(); } break; } } catch (Exception x) { MessageBox.Show(this, x.Message, "Error", MessageBoxButtons.OK); // force new as state is now invalid this.m_modified = false; this.toolStripMenuItemFileNew_Click(this, EventArgs.Empty); return; } List<SEntity> listDelete = new List<SEntity>(); List<DocTemplateDefinition> listTemplate = new List<DocTemplateDefinition>(); // get the project, determine the next OID to use foreach (SEntity o in this.m_instances.Values) { if (o is DocProject) { this.m_project = (DocProject)o; } else if (o is DocEntity) { DocEntity docent = (DocEntity)o; #if false // files before V5.3 had Description field; no longer needed so use regular Documentation field again. if (docent._Description != null) { docent.Documentation = docent._Description; docent._Description = null; } #endif } else if(o is DocAttribute) { #if false // files before V8.7 didn't have nullable tagless DocAttribute docAttr = (DocAttribute)o; if (docAttr.XsdTagless == false) { docAttr.XsdTagless = null; } #endif } else if (o is DocExchangeDefinition) { // files before V4.9 had Description field; no longer needed so use regular Documentation field again. DocExchangeDefinition docexchange = (DocExchangeDefinition)o; if (docexchange._Description != null) { docexchange.Documentation = docexchange._Description; docexchange._Description = null; } } else if (o is DocTemplateDefinition) { // files before V5.0 had Description field; no longer needed so use regular Documentation field again. DocTemplateDefinition doctemplate = (DocTemplateDefinition)o; if (doctemplate._Description != null) { doctemplate.Documentation = doctemplate._Description; doctemplate._Description = null; } listTemplate.Add((DocTemplateDefinition)o); } // ensure all objects have valid guid if (o is DocObject) { DocObject docobj = (DocObject)o; if (docobj.Uuid == Guid.Empty) { docobj.Uuid = Guid.NewGuid(); } #if false // ensure any image references are in lowercase if(docobj.Documentation != null && docobj.Documentation.Length > 0) { int i = 0; while (i != -1) { i = docobj.Documentation.IndexOf("../figures/", i + 1); if(i != -1) { int start = i + 11; int end = docobj.Documentation.IndexOf('"', start); if(end > start) { string strold = docobj.Documentation.Substring(start, end - start); string strnew = strold.ToLower(); docobj.Documentation = docobj.Documentation.Substring(0, start) + strnew + docobj.Documentation.Substring(end); System.Diagnostics.Debug.WriteLine(strnew); } } } } #endif } if (o.OID > this.m_lastid) { this.m_lastid = o.OID; } } if (this.m_project == null) { MessageBox.Show(this, "File is invalid; no project is defined.", "Error", MessageBoxButtons.OK); return; } // now capture any template definitions (upgrade in V3.5) foreach (DocModelView docModelView in this.m_project.ModelViews) { if (docModelView.ConceptRoots == null) { // must convert to new format docModelView.ConceptRoots = new List<DocConceptRoot>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { if (docEntity.__Templates != null) { foreach (DocTemplateUsage docTemplateUsage in docEntity.__Templates) { // must generate or use existing concept root DocConceptRoot docConceptRoot = null; foreach (DocConceptRoot eachConceptRoot in docModelView.ConceptRoots) { if (eachConceptRoot.ApplicableEntity == docEntity) { docConceptRoot = eachConceptRoot; break; } } if (docConceptRoot == null) { docConceptRoot = new DocConceptRoot(); docConceptRoot.ApplicableEntity = docEntity; docModelView.ConceptRoots.Add(docConceptRoot); } docConceptRoot.Concepts.Add(docTemplateUsage); } } } } } } } #if false // temp fixup foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { //docSchema.PropertyEnums.Sort(); foreach (DocPropertyEnumeration docEnum in docSchema.PropertyEnums) { foreach(DocPropertyConstant docConst in docEnum.Constants) { docConst.Name = docConst.Name.ToUpper(); // ensure uppercase throughout switch(docConst.Name) { case "OTHER": docConst.RegisterLocalization("en", "(other)", "Value is not listed."); break; case "NOTKNOWN": docConst.RegisterLocalization("en", "(unknown)", "Value is unknown."); break; case "UNSET": docConst.RegisterLocalization("en", "(unset)", "Value has not been specified."); break; } } } } } #endif #if false // ensure property enumerations are defined (upgrade to V5.8) and provide localizations Dictionary<string, DocPropertyEnumeration> mapEnums = new Dictionary<string, DocPropertyEnumeration>(); foreach(DocSection docSection in this.m_project.Sections) { foreach(DocSchema docSchema in docSection.Schemas) { foreach(DocType docType in docSchema.Types) { EnsureLocalized(docType); } foreach(DocEntity docEntity in docSchema.Entities) { EnsureLocalized(docEntity); } foreach(DocFunction docFunction in docSchema.Functions) { EnsureLocalized(docFunction); } foreach(DocGlobalRule docRule in docSchema.GlobalRules) { EnsureLocalized(docRule); } foreach(DocPropertySet docPset in docSchema.PropertySets) { EnsureLocalized(docPset); foreach(DocProperty docProp in docPset.Properties) { EnsureLocalized(docProp); if (docProp.PropertyType == DocPropertyTemplateTypeEnum.P_ENUMERATEDVALUE) { // temporary migration string match = "PEnum_Status:"; if (docProp.SecondaryDataType.StartsWith(match)) { docProp.SecondaryDataType = "PEnum_ElementStatus:" + docProp.SecondaryDataType.Substring(match.Length); } string[] enumhost = docProp.SecondaryDataType.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries); if (enumhost.Length == 2) { string enumname = enumhost[0]; DocPropertyEnumeration docEnum = null; if (docProp.PrimaryDataType != null && !mapEnums.TryGetValue(enumname, out docEnum)) { docEnum = new DocPropertyEnumeration(); docEnum.Name = enumname; docSchema.PropertyEnums.Add(docEnum); mapEnums.Add(docEnum.Name, docEnum); string[] enumvals = enumhost[1].Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string val in enumvals) { DocPropertyConstant docConstant = new DocPropertyConstant(); docConstant.Name = val; docEnum.Constants.Add(docConstant); // localize constant StringBuilder sb = new StringBuilder(); // if constant is entirely uppercase, then convert such that only first character is uppercase for (int i = 0; i < val.Length; i++ ) { char ch = val[i]; if (ch == '_') { ch = ' '; } else if (Char.IsUpper(ch) && i > 0 && !Char.IsUpper(val[i - 1])) { sb.Append(" "); } else if(Char.IsUpper(ch) && i > 0 && Char.IsUpper(val[i-1])) { ch = Char.ToLower(ch); } sb.Append(ch); } // find description for constant string doc = null; int iDoc = docProp.Documentation.IndexOf(docConstant.Name + ":"); if(iDoc > 0) { int iTail = docProp.Documentation.IndexOfAny(new char[] { '.', ';', '\r', '\n'}, iDoc+1); if (iTail == -1) { iTail = docProp.Documentation.Length; } doc = docProp.Documentation.Substring(iDoc + docConstant.Name.Length + 2, iTail - iDoc - docConstant.Name.Length - 2); } docConstant.RegisterLocalization("en", sb.ToString(), doc); } } } } } } foreach(DocQuantitySet docQset in docSchema.QuantitySets) { EnsureLocalized(docQset); foreach(DocQuantity docQuantiy in docQset.Quantities) { EnsureLocalized(docQuantiy); } } } } #endif #if false // temp: garbage collection for files that didn't clean up properly StringBuilder sb = new StringBuilder(); this.m_project.Mark(); List<SEntity> collect = new List<SEntity>(); foreach (SEntity o in this.m_instances.Values) { if(!o.Existing) { collect.Add(o); } } for (int i = collect.Count - 1; i >= 0; i--) { SEntity ent = collect[i]; if(!ent.Existing) { sb.AppendLine("#" + ent.OID + "=" + ent.GetType().Name + ";"); this.m_instances.Remove(ent.OID); } } string sss = sb.ToString(); #endif // now clear out the lists going forward. LoadTree(); }
/// <summary> /// Temporary routine for providing English localization for definition /// </summary> /// <param name="def"></param> private static void EnsureLocalized(DocObject def) { string locale = "en"; DocLocalization docLocal = def.GetLocalization(locale); if (docLocal != null) return; docLocal = def.RegisterLocalization(locale, null, null); string name = def.Name; // strip off prefix (Ifc, Pset_, Qto_) if (name.StartsWith("Ifc")) { name = name.Substring(3); } else if (name.StartsWith("Pset_")) { name = name.Substring(5); } else if (name.StartsWith("Qto_")) { name = name.Substring(4); } // if all caps (e.g. enum constants), then make first capital and rest lowercase // insert spaces before any capitalized word StringBuilder sb = new StringBuilder(); for (int i = 0; i < name.Length; i++) { char ch = name[i]; if (Char.IsUpper(ch) && i > 0 && !Char.IsUpper(name[i - 1])) { sb.Append(" "); } sb.Append(ch); } docLocal.Name = sb.ToString(); }
/// <summary> /// Updates content containing figure references /// </summary> /// <param name="html">Content to parse</param> /// <param name="figurenumber">Last figure number; returns updated last figure number</param> /// <param name="tablenumber">Last table number; returns updated last table number</param> /// <returns>Updated content</returns> private static string UpdateNumbering(string html, List<ContentRef> listFigures, List<ContentRef> listTables, DocObject target) { if (html == null) return null; html = UpdateNumbering(html, "Figure", "figure", listFigures, target); html = UpdateNumbering(html, "Table", "table", listTables, target); return html; }
/// <summary> /// Navigates to item in tree corresponding to object /// </summary> /// <param name="docObj"></param> private void Navigate(TreeNode tn, DocObject docObj) { if (tn == null) { foreach(TreeNode sub in this.treeView.Nodes) { Navigate(sub, docObj); } return; } if (tn.Tag == docObj) { this.treeView.SelectedNode = tn; return; } foreach(TreeNode sub in tn.Nodes) { Navigate(sub, docObj); } }
/// <summary> /// Updates numbering of figures or tables within HTML text /// </summary> /// <param name="html">The existing HTML</param> /// <param name="tag">The caption to find -- either 'Figure' or 'Table'</param> /// <param name="style">The style to find -- either 'figure' or 'table'</param> /// <param name="listRef">List of items where numbering begins and items are added.</param> /// <returns>The new HTML with figures or numbers updated</returns> private static string UpdateNumbering(string html, string tag, string style, List<ContentRef> listRef, DocObject target) { List<int> list = new List<int>(); // first get numbers of existing figures (must be unique within page) int index = 0; for (int count = 0; ; count++) { index = html.IndexOf("<p class=\"" + style + "\">", index); if (index == -1) break; // <p class="figure">Figure 278 — Circle geometry</p> // <p class="table">Table 278 — Circle geometry</p> // get the existing figure number, add it to list int head = index + 13 + tag.Length * 2; // was 25 int tail = html.IndexOf(" —", index); if (tail > head) { string exist = html.Substring(head, tail - head); int result = 0; if (Int32.TryParse(exist, out result)) { list.Add(result); int endcaption = html.IndexOf("<", tail); string figuretext = html.Substring(tail + 9, endcaption - tail - 9); listRef.Add(new ContentRef(figuretext, target)); } } index++; } // renumber in two phases (to avoid renumbering same) // now renumber for (int i = 0; i < list.Count; i++) { string captionold = tag + " " + list[i].ToString();// +" "; string captionnew = tag + "#" + (listRef.Count + i + 1).ToString();// +" "; // handle cases of space, comma, and period following figure reference html = html.Replace(captionold + " ", captionnew + " "); html = html.Replace(captionold + ",", captionnew + ","); html = html.Replace(captionold + ".", captionnew + "."); } // then replace all html = html.Replace(tag + "#", tag + " "); //itemnumber += list.Count; return html; }
private void CtlExpressG_MouseUp(object sender, MouseEventArgs e) { if (e.Button != System.Windows.Forms.MouseButtons.Left) return; this.m_mousedown = false; if(this.m_selection == null && this.m_toolmode == ToolMode.Move && this.m_multiselect.Count > 0) { this.m_selection = this.m_multiselect[0]; if(this.SelectionChanged != null) { this.SelectionChanged(this, EventArgs.Empty); } } if (this.m_selection != null && this.m_highlight != null && this.m_toolmode == ToolMode.Link) { if (this.LinkOperation != null) { // special case for linking entities for subtypes EventArgs args = EventArgs.Empty; if(this.Cursor == Cursors.UpArrow && (this.m_selection is DocEntity || this.m_selection is DocDefinitionRef) && this.m_highlight is DocEntity) { //... also need to determine if referenced type is an entity args = null; } this.LinkOperation(this, args); } this.Redraw(); } this.Invalidate(); }
public DocObject Page; // relative link to reference public ContentRef(string caption, DocObject page) { this.Caption = caption; this.Page = page; }
private void InitUsageFromTemplateRule(DocTemplateDefinition docTemp, DocTemplateDefinition docSource, DocModelRule docRule) { if (docRule is DocModelRuleEntity) { DocModelRuleEntity docRuleEntity = (DocModelRuleEntity)docRule; if (docRuleEntity.References.Contains(docSource)) { DocObject[] usagepath = new DocObject[] { docTemp }; ListViewItem lvi = new ListViewItem(); lvi.Tag = usagepath; lvi.Text = "[Template]"; lvi.SubItems.Add(docTemp.Name); this.listViewUsage.Items.Add(lvi); } } // recurse foreach(DocModelRule docInner in docRule.Rules) { InitUsageFromTemplateRule(docTemp, docSource, docInner); } }
private static string FormatDiagram(DocProject docProject, DocObject def, DocModelView docView, List<ContentRef> listFigures, Dictionary<string, DocObject> mapEntity, Dictionary<string, string> mapSchema) { // return if nothing to generate if (def is DocTemplateDefinition) { DocTemplateDefinition dtd = (DocTemplateDefinition)def; if (dtd.Rules == null || dtd.Rules.Count == 0) return null; } else if (def is DocEntity) { } else { return null; } // create the figure file string filename = MakeLinkName(def) + ".png"; Dictionary<Rectangle, DocModelRule> layout = new Dictionary<Rectangle, DocModelRule>(); if (!Properties.Settings.Default.SkipDiagrams) { try { if (def is DocTemplateDefinition) { System.IO.Directory.CreateDirectory(Properties.Settings.Default.OutputPath + "\\schema\\templates\\diagrams"); using (Image image = IfcDoc.Format.PNG.FormatPNG.CreateTemplateDiagram((DocTemplateDefinition)def, mapEntity, layout, docProject, null)) { if (image != null) { string filepath = Properties.Settings.Default.OutputPath + "\\schema\\templates\\diagrams\\" + filename; image.Save(filepath, System.Drawing.Imaging.ImageFormat.Png); } } } else if (def is DocEntity) // no longer used directly; now for each model view in annex D { System.IO.Directory.CreateDirectory(Properties.Settings.Default.OutputPath + "\\diagrams\\" + MakeLinkName(docView)); using (Image image = IfcDoc.Format.PNG.FormatPNG.CreateConceptDiagram((DocEntity)def, docView, mapEntity, layout, docProject, null)) { string filepath = Properties.Settings.Default.OutputPath + "\\diagrams\\" + MakeLinkName(docView) + "\\" + filename; image.Save(filepath, System.Drawing.Imaging.ImageFormat.Png); } } } catch { } } // 2. figure StringBuilder sb = new StringBuilder(); if (def is DocTemplateDefinition) { listFigures.Add(new ContentRef(def.Name + " instance diagram", def)); // Per ISO guidelines, all figures must be referenced from text. sb.Append("<p class=\"fig-ref\">Figure "); sb.Append(listFigures.Count); sb.Append(" illustrates an instance diagram.</p>\r\n"); } // include the figure with formatting below per ISO sb.Append("<table><tr><td><img alt=\""); sb.Append(def.Name); if (def is DocTemplateDefinition) { sb.Append("\" src=\"./diagrams/"); } else { sb.Append("\" src=\"../../../diagrams/"); sb.Append(MakeLinkName(docView)); sb.Append("/"); } sb.Append(filename); sb.Append("\" usemap=\"#f"); sb.Append(listFigures.Count.ToString()); sb.Append("\">"); sb.Append("<map name=\"f"); sb.Append(listFigures.Count.ToString()); sb.Append("\">"); foreach (Rectangle rc in layout.Keys) { DocModelRule rule = layout[rc]; DocObject ruleObject = null; string strschema = null; string typename = null; if (rule != null) { typename = rule.Name; } else if (def is DocTemplateDefinition) { DocTemplateDefinition dtd = (DocTemplateDefinition)def; typename = dtd.Type; } else if (def is DocObject) { typename = def.Name; } if (mapEntity.TryGetValue(typename, out ruleObject) && mapSchema.TryGetValue(typename, out strschema)) { // hyperlink to IFC entity // replace it with hyperlink string relative = @"../"; if (def is DocEntity) { relative = "../../../schema/"; } string hyperlink = relative + strschema.ToLower() + @"/lexical/" + ruleObject.Name.ToLower() + ".htm"; int indent = 0; sb.Append("<area shape=\"rect\" coords=\""); sb.Append(rc.Left + indent); sb.Append(","); sb.Append(rc.Top + indent); sb.Append(","); sb.Append(rc.Right + indent); sb.Append(","); sb.Append(rc.Bottom + indent); sb.Append("\" href=\""); sb.Append(hyperlink); sb.Append("\" alt=\""); sb.Append(ruleObject.Name); sb.Append("\" />"); } } sb.Append("</map>"); // number figures in templates, but not annex if (def is DocTemplateDefinition) { sb.Append("</td></tr>"); sb.Append("<tr><td><p class=\"figure\">Figure "); sb.Append(listFigures.Count); sb.Append(" — "); sb.Append(def.Name); sb.Append("</p></td></tr>"); } sb.Append("</table>\r\n"); sb.AppendLine(); return sb.ToString(); }
public Compiler(DocProject project, DocModelView[] views, DocExchangeDefinition exchange, bool psets) { this.m_project = project; this.m_views = views; this.m_exchange = exchange; this.m_psets = psets; // version needs to be included for extracting XML namespace (Major.Minor.Addendum.Corrigendum) string version = project.GetSchemaVersion(); ConstructorInfo conContract = (typeof(AssemblyVersionAttribute).GetConstructor(new Type[] { typeof(string) })); CustomAttributeBuilder cabAssemblyVersion = new CustomAttributeBuilder(conContract, new object[] { version }); string schemaid = project.GetSchemaIdentifier(); string assembly = "buildingSmart." + schemaid; string module = assembly + ".dll"; this.m_rootnamespace = assembly + "."; this.m_assembly = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(assembly), AssemblyBuilderAccess.RunAndSave, new CustomAttributeBuilder[] { cabAssemblyVersion }); this.m_module = this.m_assembly.DefineDynamicModule(module, module); this.m_definitions = new Dictionary <string, DocObject>(); this.m_types = new Dictionary <string, Type>(); this.m_fields = new Dictionary <Type, Dictionary <string, FieldInfo> >(); this.m_templates = new Dictionary <DocTemplateDefinition, MethodInfo>(); this.m_namespaces = new Dictionary <string, string>(); Dictionary <DocObject, bool> included = null; if (this.m_views != null) { included = new Dictionary <DocObject, bool>(); foreach (DocModelView docView in this.m_views) { this.m_project.RegisterObjectsInScope(docView, included); } } if (psets) { foreach (DocPropertyEnumeration docPropEnum in project.PropertyEnumerations) { DocEnumeration docType = docPropEnum.ToEnumeration(); if (!this.m_definitions.ContainsKey(docType.Name)) { this.m_definitions.Add(docType.Name, docType); } } } foreach (DocSection docSection in project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { if (included == null || included.ContainsKey(docEntity)) { if (!this.m_definitions.ContainsKey(docEntity.Name)) { this.m_definitions.Add(docEntity.Name, docEntity); this.m_namespaces.Add(docEntity.Name, docSchema.Name); } } } foreach (DocType docType in docSchema.Types) { if (included == null || included.ContainsKey(docType)) { if (!this.m_definitions.ContainsKey(docType.Name)) { this.m_definitions.Add(docType.Name, docType); this.m_namespaces.Add(docType.Name, docSchema.Name); } } } } } // second pass: if (psets) { foreach (DocSection docSection in project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocPropertySet docPset in docSchema.PropertySets) { DocEntity docType = docPset.ToEntity(this.m_definitions); if (!this.m_definitions.ContainsKey(docType.Name)) { this.m_definitions.Add(docType.Name, docType); this.m_namespaces.Add(docType.Name, docSchema.Name); } } foreach (DocQuantitySet docQset in docSchema.QuantitySets) { DocEntity docType = docQset.ToEntity(this.m_definitions); if (!this.m_definitions.ContainsKey(docType.Name)) { this.m_definitions.Add(docType.Name, docType); this.m_namespaces.Add(docType.Name, docSchema.Name); } } } } } // first register types and fields foreach (string key in this.m_definitions.Keys) { Type typereg = RegisterType(key); // localization -- use custom attributes for now -- ideal way would be to use assembly resources, though has bugs in .net 4.0 if (typereg is TypeBuilder) { TypeBuilder tb = (TypeBuilder)typereg; DocObject docObj = this.m_definitions[key]; foreach (DocLocalization docLocal in docObj.Localization) { CustomAttributeBuilder cab = docLocal.ToCustomAttributeBuilder(); if (cab != null) { tb.SetCustomAttribute(cab); } } } } // now register template functions (may depend on fields existing) // find associated ConceptRoot for model view, define validation function if (this.m_views != null) { foreach (DocModelView view in this.m_views) { string viewname = view.Code; foreach (DocConceptRoot root in view.ConceptRoots) { Type tOpen = null; if (this.m_types.TryGetValue(root.ApplicableEntity.Name, out tOpen) && tOpen is TypeBuilder) { TypeBuilder tb = (TypeBuilder)tOpen; // new: generate type for concept root //if (view.Name != null && root.Name != null) { /* * string typename = this.m_rootnamespace + "." + view.Name.Replace(" ", "_") + "." + root.Name.Replace(" ", "_"); * //Type tbConceptRoot = RegisterType(typename); * TypeBuilder tbRoot = this.m_module.DefineType(typename, attr, typebase); */ // add typebuilder to map temporarily in case referenced by an attribute within same class or base class //this.m_types.Add(typename, tb); foreach (DocTemplateUsage concept in root.Concepts) { CompileConcept(concept, view, tb); } } } } } } //Dictionary<string, Stream> mapResStreams = new Dictionary<string, Stream>(); //Dictionary<string, ResXResourceWriter> mapResources = new Dictionary<string, ResXResourceWriter>(); // seal types once all are built List <TypeBuilder> listBase = new List <TypeBuilder>(); foreach (string key in this.m_definitions.Keys) { Type tOpen = this.m_types[key]; while (tOpen is TypeBuilder) { listBase.Add((TypeBuilder)tOpen); tOpen = tOpen.BaseType; } // seal in base class order for (int i = listBase.Count - 1; i >= 0; i--) { Type tClosed = listBase[i].CreateType(); this.m_types[tClosed.Name] = tClosed; } listBase.Clear(); // record bindings DocDefinition docDef = this.m_definitions[key] as DocDefinition; if (docDef != null) { docDef.RuntimeType = this.m_types[key]; if (docDef is DocEntity) { DocEntity docEnt = (DocEntity)docDef; foreach (DocAttribute docAttr in docEnt.Attributes) { docAttr.RuntimeField = docDef.RuntimeType.GetProperty(docAttr.Name); } } #if false // bug in .net framework 4.0+ -- can't read resources dynamically defined // capture localization foreach (DocLocalization docLocal in docDef.Localization) { if (!String.IsNullOrEmpty(docLocal.Locale)) { string major = docLocal.Locale.Substring(0, 2).ToLower(); ResXResourceWriter reswriter = null; if (!mapResources.TryGetValue(major, out reswriter)) { MemoryStream stream = new MemoryStream(); mapResStreams.Add(major, stream); reswriter = new ResXResourceWriter(stream); mapResources.Add(major, reswriter); } ResXDataNode node = new ResXDataNode(docDef.Name, docLocal.Name); node.Comment = docLocal.Documentation; reswriter.AddResource(node); } } #endif } } #if false foreach (string locale in mapResStreams.Keys) { ResXResourceWriter writer = mapResources[locale]; writer.Generate(); Stream stream = mapResStreams[locale]; stream.Seek(0, SeekOrigin.Begin); m_module.DefineManifestResource("Resources." + locale + ".resx", stream, ResourceAttributes.Public); } #endif }
private void CtlExpressG_MouseMove(object sender, MouseEventArgs e) { this.m_ptMove = e.Location; if (this.m_mousedown && this.m_toolmode == ToolMode.Move) { UpdateCursor(this.m_handle); Point ptLocation = e.Location; if (ptLocation.X < 0) ptLocation.X = 0; if (ptLocation.Y < 0) ptLocation.Y = 0; if (this.m_lineselection != null && this.m_selection is DocDefinition) { // moving tree node DocPoint docPoint = m_lineselection.DiagramLine[m_lineselection.DiagramLine.Count - 1]; docPoint.X = (ptLocation.X - this.AutoScrollPosition.X) / Factor; docPoint.Y = (ptLocation.Y - this.AutoScrollPosition.Y) / Factor; // layout the owning element LayoutDefinition((DocDefinition)this.m_selection); // layout lines to all subtypes foreach (DocLine docSub in this.m_lineselection.Tree) { LayoutNode(this.m_lineselection, docSub); } this.Redraw(); } else if (this.m_selection is DocDefinition) { float dx = (float)(ptLocation.X - this.m_ptDown.X); float dy = (float)(ptLocation.Y - this.m_ptDown.Y); // move or resize the object... DocDefinition docSelection = (DocDefinition)this.m_selection; if (this.m_pointmap.ContainsKey(docSelection)) { PointF ptSelection = this.m_pointmap[docSelection]; if ((this.m_handle & ResizeHandle.North) != 0) { double yTail = docSelection.DiagramRectangle.Y + docSelection.DiagramRectangle.Height; docSelection.DiagramRectangle.Y = ptSelection.Y + dy / Factor; docSelection.DiagramRectangle.Height = yTail - docSelection.DiagramRectangle.Y; } else if ((this.m_handle & ResizeHandle.South) != 0) { docSelection.DiagramRectangle.Height = m_selectionsize.Height + dy / Factor; } if ((this.m_handle & ResizeHandle.West) != 0) { double xTail = docSelection.DiagramRectangle.X + docSelection.DiagramRectangle.Width; docSelection.DiagramRectangle.X = ptSelection.X + dx / Factor; docSelection.DiagramRectangle.Width = xTail - docSelection.DiagramRectangle.X; } else if ((this.m_handle & ResizeHandle.East) != 0) { docSelection.DiagramRectangle.Width = m_selectionsize.Width + dx / Factor; } if (this.m_handle == ResizeHandle.Move) { docSelection.DiagramRectangle.X = ptSelection.X + dx / Factor; docSelection.DiagramRectangle.Y = ptSelection.Y + dy / Factor; } else { if(docSelection.DiagramRectangle.Width < 64) { docSelection.DiagramRectangle.Width = 64; } if (docSelection.DiagramRectangle.Height < 64) { docSelection.DiagramRectangle.Height = 64; } } if (this.m_selection is DocDefinition) { LayoutDefinition((DocDefinition)this.m_selection); } } this.Redraw(); } else if(this.m_selection == null) { // draw box and highlight multiple within region this.m_multiselect.Clear(); Rectangle rc = CreateNormalizedRectangle(this.m_ptDown, this.m_ptMove); foreach(DocEntity docEntity in this.m_schema.Entities) { SelectWithinRectangle(docEntity, rc); } foreach (DocType docType in this.m_schema.Types) { SelectWithinRectangle(docType, rc); } foreach (DocPrimitive docType in this.m_schema.Primitives) { SelectWithinRectangle(docType, rc); } foreach (DocPageTarget docTarget in this.m_schema.PageTargets) { SelectWithinRectangle(docTarget, rc); foreach(DocPageSource docSource in docTarget.Sources) { SelectWithinRectangle(docSource, rc); } } foreach(DocSchemaRef docSchemaRef in this.m_schema.SchemaRefs) { foreach(DocDefinitionRef docRef in docSchemaRef.Definitions) { SelectWithinRectangle(docRef, rc); } } // don't select comments this.Invalidate(); } } else { ResizeHandle handle = ResizeHandle.None; DocObject highlight = this.Pick(e.Location, out this.m_linehighlight, out handle); if (this.m_highlight != highlight) { this.m_highlight = highlight; this.Invalidate(); } if (this.m_mousedown && this.m_toolmode == ToolMode.Link) { this.Invalidate(); } UpdateCursor(handle); } }
private void LoadFile(string filename) { this.SetCurrentFile(filename); this.m_lastid = 0; this.m_instances.Clear(); this.m_mapTree.Clear(); this.m_clipboard = null; this.m_project = null; List<DocChangeAction> listChange = new List<DocChangeAction>(); //temp string ext = System.IO.Path.GetExtension(this.m_file).ToLower(); try { switch (ext) { case ".ifcdoc": using (FormatSPF format = new FormatSPF(this.m_file, SchemaDOC.Types, this.m_instances)) { format.Load(); } break; #if MDB case ".mdb": using (FormatMDB format = new FormatMDB(this.m_file, SchemaDOC.Types, this.m_instances)) { format.Load(); } break; #endif } } catch (Exception x) { MessageBox.Show(this, x.Message, "Error", MessageBoxButtons.OK); // force new as state is now invalid this.m_modified = false; this.toolStripMenuItemFileNew_Click(this, EventArgs.Empty); return; } List<SEntity> listDelete = new List<SEntity>(); List<DocTemplateDefinition> listTemplate = new List<DocTemplateDefinition>(); // get the project, determine the next OID to use foreach (SEntity o in this.m_instances.Values) { if (o is DocProject) { this.m_project = (DocProject)o; } else if (o is DocEntity) { DocEntity docent = (DocEntity)o; #if false // files before V5.3 had Description field; no longer needed so use regular Documentation field again. if (docent._Description != null) { docent.Documentation = docent._Description; docent._Description = null; } #endif } else if(o is DocAttribute) { #if false // files before V8.7 didn't have nullable tagless DocAttribute docAttr = (DocAttribute)o; if (docAttr.XsdTagless == false) { docAttr.XsdTagless = null; } #endif } else if(o is DocSchema) { DocSchema docSchema = (DocSchema)o; // renumber page references foreach (DocPageTarget docTarget in docSchema.PageTargets) { int page = docSchema.GetDefinitionPageNumber(docTarget); int item = docSchema.GetPageTargetItemNumber(docTarget); docTarget.Name = page + "," + item + " " + docTarget.Definition.Name; foreach(DocPageSource docSource in docTarget.Sources) { docSource.Name = docTarget.Name; } } } else if (o is DocExchangeDefinition) { // files before V4.9 had Description field; no longer needed so use regular Documentation field again. DocExchangeDefinition docexchange = (DocExchangeDefinition)o; if (docexchange._Description != null) { docexchange.Documentation = docexchange._Description; docexchange._Description = null; } } else if (o is DocTemplateDefinition) { // files before V5.0 had Description field; no longer needed so use regular Documentation field again. DocTemplateDefinition doctemplate = (DocTemplateDefinition)o; if (doctemplate._Description != null) { doctemplate.Documentation = doctemplate._Description; doctemplate._Description = null; } listTemplate.Add((DocTemplateDefinition)o); } else if(o is DocChangeAction) { // tempdebug -- delete old change actions -- need to clean up //o.Delete(); listChange.Add((DocChangeAction)o); } // ensure all objects have valid guid if (o is DocObject) { DocObject docobj = (DocObject)o; if (docobj.Uuid == Guid.Empty) { docobj.Uuid = Guid.NewGuid(); } #if false // ensure any image references are in lowercase if(docobj.Documentation != null && docobj.Documentation.Length > 0) { int i = 0; while (i != -1) { i = docobj.Documentation.IndexOf("../figures/", i + 1); if(i != -1) { int start = i + 11; int end = docobj.Documentation.IndexOf('"', start); if(end > start) { string strold = docobj.Documentation.Substring(start, end - start); string strnew = strold.ToLower(); docobj.Documentation = docobj.Documentation.Substring(0, start) + strnew + docobj.Documentation.Substring(end); System.Diagnostics.Debug.WriteLine(strnew); } } } } #endif } if (o.OID > this.m_lastid) { this.m_lastid = o.OID; } } if (this.m_project == null) { MessageBox.Show(this, "File is invalid; no project is defined.", "Error", MessageBoxButtons.OK); return; } //tempcleanip //for (int i = listChange.Count - 1; i >= 0;i-- ) { //listChange[i].Delete(); } // now capture any template definitions (upgrade in V3.5) foreach (DocModelView docModelView in this.m_project.ModelViews) { if (docModelView.ConceptRoots == null) { // must convert to new format docModelView.ConceptRoots = new List<DocConceptRoot>(); foreach (DocSection docSection in this.m_project.Sections) { foreach (DocSchema docSchema in docSection.Schemas) { foreach (DocEntity docEntity in docSchema.Entities) { if (docEntity.__Templates != null) { foreach (DocTemplateUsage docTemplateUsage in docEntity.__Templates) { // must generate or use existing concept root DocConceptRoot docConceptRoot = null; foreach (DocConceptRoot eachConceptRoot in docModelView.ConceptRoots) { if (eachConceptRoot.ApplicableEntity == docEntity) { docConceptRoot = eachConceptRoot; break; } } if (docConceptRoot == null) { docConceptRoot = new DocConceptRoot(); docConceptRoot.ApplicableEntity = docEntity; docModelView.ConceptRoots.Add(docConceptRoot); } docConceptRoot.Concepts.Add(docTemplateUsage); } } } } } } } // upgrade to Publications (V9.6) if (this.m_project.Annotations.Count == 4) { this.m_project.Publications.Clear(); DocAnnotation docCover = this.m_project.Annotations[0]; DocAnnotation docContents = this.m_project.Annotations[1]; DocAnnotation docForeword = this.m_project.Annotations[2]; DocAnnotation docIntro = this.m_project.Annotations[3]; DocPublication docPub = new DocPublication(); docPub.Name = "Default"; docPub.Documentation = docCover.Documentation; docPub.Owner = docCover.Owner; docPub.Author = docCover.Author; docPub.Code = docCover.Code; docPub.Copyright = docCover.Copyright; docPub.Status = docCover.Status; docPub.Version = docCover.Version; docPub.Annotations.Add(docForeword); docPub.Annotations.Add(docIntro); this.m_project.Publications.Add(docPub); docCover.Delete(); docContents.Delete(); this.m_project.Annotations.Clear(); } LoadTree(); }
private void toolStripMenuItemFileNew_Click(object sender, EventArgs e) { if (!PromptSave()) return; this.SetCurrentFile(null); this.m_lastid = 0; this.m_instances.Clear(); this.m_mapTree.Clear(); this.m_clipboard = null; // init defaults this.m_project = new DocProject(); this.m_project.Annexes[1].Code = "IFC4"; // schema id LoadTree(); }
public static string FormatTypeWrapper(DocType docDefined, Dictionary <string, DocObject> map) { StringBuilder sb = new StringBuilder(); // wrapper /* * <xs:element name="IfcPressureMeasure-wrapper" nillable="true"> * <xs:complexType> * <xs:simpleContent> * <xs:extension base="ifc:IfcPressureMeasure"> * <xs:attributeGroup ref="ifc:instanceAttributes"/> * </xs:extension> * </xs:simpleContent> * </xs:complexType> * </xs:element> */ bool complex = false; if (docDefined is DocDefined) { DocDefined docDef = (DocDefined)docDefined; DocObject docobj = null; if (docDef.DefinedType != null && map.TryGetValue(docDef.DefinedType, out docobj) && docobj is DocEntity) { complex = true; } } sb.Append("\t<xs:element name=\""); sb.Append(docDefined.Name); sb.Append("-wrapper\" nillable=\"true\">"); sb.AppendLine(); sb.AppendLine("\t\t<xs:complexType>"); if (complex) { sb.AppendLine("\t\t\t<xs:complexContent>"); } else { sb.AppendLine("\t\t\t<xs:simpleContent>"); } sb.Append("\t\t\t\t<xs:extension base=\""); sb.Append(ToXsdType(docDefined.Name)); sb.AppendLine("\">"); sb.AppendLine("\t\t\t\t\t<xs:attributeGroup ref=\"ifc:instanceAttributes\"/>"); sb.AppendLine("\t\t\t\t</xs:extension>"); if (complex) { sb.AppendLine("\t\t\t</xs:complexContent>"); } else { sb.AppendLine("\t\t\t</xs:simpleContent>"); } sb.AppendLine("\t\t</xs:complexType>"); sb.Append("\t</xs:element>"); sb.AppendLine(); return(sb.ToString()); }
private void ClipboardCopy(bool cut) { if (this.treeView.Focused) { // restore state if (this.m_clipboardNode != null) { this.m_clipboardNode.ForeColor = Color.Black; } this.m_clipboardNode = this.treeView.SelectedNode; this.m_clipboard = this.treeView.SelectedNode.Tag as DocObject; this.m_clipboardCut = cut; if (this.m_clipboardCut) { this.m_clipboardNode.ForeColor = Color.Gray; } // update view state (may be impacted by what is on the clipboard) this.TreeView_AfterSelect(this, new TreeViewEventArgs(this.treeView.SelectedNode, TreeViewAction.Unknown)); } }
public static string FormatEntity(DocEntity docEntity, Dictionary <string, DocObject> map, Dictionary <DocObject, bool> included) { string basetype = docEntity.BaseDefinition; if (String.IsNullOrEmpty(basetype)) { basetype = "Entity"; } StringBuilder sb = new StringBuilder(); // if any derived attributes, then must use intermediate type bool hasderivedattributes = false; foreach (DocAttribute docAttr in docEntity.Attributes) { if (docAttr.Derived != null && docAttr.Inverse == null) { // determine the superclass having the attribute DocEntity found = null; DocEntity super = docEntity; while (super != null && found == null && super.BaseDefinition != null) { super = map[super.BaseDefinition] as DocEntity; if (super != null) { foreach (DocAttribute docattrSuper in super.Attributes) { if (docattrSuper.Name.Equals(docAttr.Name)) { // found class found = super; break; } } } } if (found != null) { hasderivedattributes = true; } break; } } if (hasderivedattributes) { sb.Append("\t<xs:complexType name=\""); sb.Append(docEntity.Name); sb.Append("-temp\" abstract=\"true\">"); sb.AppendLine(); sb.Append("\t\t<xs:complexContent>"); sb.AppendLine(); sb.Append("\t\t\t<xs:restriction base=\"ifc:"); sb.Append(docEntity.BaseDefinition); sb.Append("\">"); sb.AppendLine(); // restate non-derived attributes at superclass, if any List <DocAttribute> listRestate = new List <DocAttribute>(); DocEntity docSuper = map[docEntity.BaseDefinition] as DocEntity; foreach (DocAttribute docAttrSuper in docSuper.Attributes) { // check if attribute not derived by us bool derived = false; foreach (DocAttribute docAttrThis in docEntity.Attributes) { if (docAttrSuper.Name.Equals(docAttrThis.Name)) { derived = true; break; } } if (!derived) { DocObject mapDef = null; if ((docAttrSuper.Inverse == null /* || docAttrSuper.XsdFormat == DocXsdFormatEnum.Element || docAttrSuper.XsdFormat == DocXsdFormatEnum.Attribute*/) && docAttrSuper.Derived == null && (map.TryGetValue(docAttrSuper.DefinedType, out mapDef) || docAttrSuper.DefinedType.StartsWith("BINARY"))) { if (mapDef is DocEntity || mapDef is DocSelect) { listRestate.Add(docAttrSuper); } } } } if (listRestate.Count > 0) { sb.AppendLine("\t\t\t\t<xs:sequence>"); foreach (DocAttribute docAttr in listRestate) { string formatAttr = FormatAttribute(docEntity, docAttr, map); sb.Append(formatAttr); } sb.Append("\t\t\t\t</xs:sequence>"); } else { sb.Append("\t\t\t\t<xs:sequence/>"); } sb.AppendLine(); sb.Append("\t\t\t</xs:restriction>"); sb.AppendLine(); sb.Append("\t\t</xs:complexContent>"); sb.AppendLine(); sb.Append("\t</xs:complexType>"); sb.AppendLine(); } sb.Append("\t<xs:element"); sb.Append(" name=\""); sb.Append(docEntity.Name); sb.Append("\" type=\"ifc:"); sb.Append(docEntity.Name); sb.Append("\""); if (docEntity.IsAbstract()) { sb.Append(" abstract=\"true\""); } sb.Append(" substitutionGroup=\"ifc:"); sb.Append(basetype); sb.Append("\" nillable=\"true\""); sb.Append("/>"); sb.AppendLine(); sb.Append("\t<xs:complexType name=\""); sb.Append(docEntity.Name); sb.Append("\""); if (docEntity.IsAbstract()) { sb.Append(" abstract=\"true\""); } sb.Append(">"); sb.AppendLine(); sb.Append("\t\t<xs:complexContent>"); sb.AppendLine(); sb.Append("\t\t\t<xs:extension base=\"ifc:"); if (hasderivedattributes) { sb.Append(docEntity.Name); sb.Append("-temp"); } else { sb.Append(basetype); } sb.Append("\""); bool hascontent = false; // attributes for entities bool hassequence = false; foreach (DocAttribute docAttr in docEntity.Attributes) { if (included == null || included.ContainsKey(docAttr)) { if (docAttr.XsdFormat != DocXsdFormatEnum.Hidden && !(docAttr.XsdTagless == true) && docAttr.DefinedType != null) { DocObject mapDef = null; map.TryGetValue(docAttr.DefinedType, out mapDef); if ((docAttr.Inverse == null || docAttr.XsdFormat == DocXsdFormatEnum.Element || docAttr.XsdFormat == DocXsdFormatEnum.Attribute) && docAttr.Derived == null) { if (mapDef is DocEntity || mapDef is DocSelect || docAttr.XsdFormat == DocXsdFormatEnum.Element || docAttr.DefinedType.StartsWith("BINARY")) { if (!hascontent) { sb.Append(">"); sb.AppendLine(); hascontent = true; } if (!hassequence) { sb.AppendLine("\t\t\t\t<xs:sequence>"); hassequence = true; } string formatAttr = FormatAttribute(docEntity, docAttr, map); sb.Append(formatAttr); } } } } } if (hassequence) { sb.AppendLine("\t\t\t\t</xs:sequence>"); } // then attributes for value types foreach (DocAttribute docAttr in docEntity.Attributes) { if (included == null || included.ContainsKey(docAttr)) { if (docAttr.XsdFormat != DocXsdFormatEnum.Hidden && docAttr.DefinedType != null)// && docAttr.XsdFormat != DocXsdFormatEnum.Element*/) { DocObject mapDef = null; if ((docAttr.Inverse == null || docAttr.XsdFormat == DocXsdFormatEnum.Attribute) && docAttr.Derived == null && (docAttr.XsdFormat != DocXsdFormatEnum.Element || docAttr.XsdTagless == true)) { if ((map.TryGetValue(docAttr.DefinedType, out mapDef) == false && !docAttr.DefinedType.StartsWith("BINARY")) || (mapDef is DocDefined || mapDef is DocEnumeration || docAttr.XsdTagless == true /* || docAttr.XsdFormat == DocXsdFormatEnum.Attribute*/)) { if (mapDef == null || (included == null || included.ContainsKey(mapDef))) { if (!hascontent) { sb.Append(">"); sb.AppendLine(); hascontent = true; } // encode value types as attributes sb.Append("\t\t\t\t<xs:attribute"); sb.Append(" name=\""); sb.Append(docAttr.Name); sb.Append("\""); if (docAttr.AggregationType == 0) { sb.Append(" type=\""); if (mapDef is DocDefined && ((DocDefined)mapDef).Aggregation != null) { sb.Append("ifc:List-" + docAttr.DefinedType); } else { sb.Append(ToXsdType(docAttr.DefinedType)); } sb.Append("\""); if (true) // all attributes optional in XSD? docAttr.IsOptional()) { sb.Append(" use=\"optional\""); } sb.Append("/>"); } else { if (true) // all attributes optional in XSD? docAttr.IsOptional()) { sb.Append(" use=\"optional\""); } sb.Append(">"); sb.AppendLine(); sb.AppendLine("\t\t\t\t\t<xs:simpleType>"); sb.AppendLine("\t\t\t\t\t\t<xs:restriction>"); sb.AppendLine("\t\t\t\t\t\t\t<xs:simpleType>"); sb.Append("\t\t\t\t\t\t\t\t<xs:list itemType=\""); sb.Append(ToXsdType(docAttr.DefinedType)); sb.Append("\"/>"); sb.AppendLine(); sb.AppendLine("\t\t\t\t\t\t\t</xs:simpleType>"); if (docAttr.Name.Equals("OffsetValues")) { sb.ToString(); } int iLower = docAttr.GetAggregationNestingLower(); int iUpper = docAttr.GetAggregationNestingUpper(); // minimum if (docAttr.GetAggregation() == DocAggregationEnum.ARRAY) { iLower = iUpper; } if (iLower != -1 && iLower != 1) { sb.Append("\t\t\t\t\t\t\t<xs:minLength value=\""); sb.Append(iLower); sb.Append("\"/>"); sb.AppendLine(); } if (iUpper != 0) { sb.Append("\t\t\t\t\t\t\t<xs:maxLength value=\""); sb.Append(iUpper); sb.Append("\"/>"); sb.AppendLine(); } sb.AppendLine("\t\t\t\t\t\t</xs:restriction>"); sb.AppendLine("\t\t\t\t\t</xs:simpleType>"); sb.Append("\t\t\t\t</xs:attribute>"); } sb.AppendLine(); } } } } } } if (hascontent) { sb.Append("\t\t\t</xs:extension>"); sb.AppendLine(); } else { sb.Append("/>"); sb.AppendLine(); } sb.Append("\t\t</xs:complexContent>"); sb.AppendLine(); sb.Append("\t</xs:complexType>"); sb.AppendLine(); return(sb.ToString()); }
private static void BuildExampleList(List<DocExample> listExample, DocExample docExample, DocObject docObject, Dictionary<DocObject, bool> included) { // check for view reference if (included != null) { bool viewref = false; foreach (DocModelView docView in docExample.Views) { if (included.ContainsKey(docView)) { viewref = true; break; } } if (!viewref) return; } if (docExample.ApplicableType != null) { string[] types = docExample.ApplicableType.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); foreach (string type in types) { string[] parts = type.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries); if (parts.Length >= 1) { if (parts[0].Equals(docObject.Name)) { listExample.Add(docExample); } } } } // templates if (docExample.ApplicableTemplates != null && docObject is DocTemplateDefinition) { if (docExample.ApplicableTemplates.Contains((DocTemplateDefinition)docObject)) { listExample.Add(docExample); } } // recurse foreach (DocExample docSub in docExample.Examples) { BuildExampleList(listExample, docSub, docObject, included); } }
public static string FormatSelect(DocSelect docSelect, Dictionary <string, DocObject> map, Dictionary <DocObject, bool> included) { StringBuilder sb = new StringBuilder(); sb.Append("\t<xs:group name=\""); sb.Append(docSelect.Name); sb.Append("\">"); sb.AppendLine(); sb.Append("\t\t<xs:choice>"); sb.AppendLine(); Queue <DocSelectItem> queue = new Queue <DocSelectItem>(); foreach (DocSelectItem docItem in docSelect.Selects) { queue.Enqueue(docItem); } // sort selects alphabetically SortedList <string, DocSelectItem> sort = new SortedList <string, DocSelectItem>(new FormatXSD(null)); while (queue.Count > 0) { DocSelectItem docItem = queue.Dequeue(); DocObject mapDef = null; if (map.TryGetValue(docItem.Name, out mapDef)) { if (mapDef is DocSelect) { // expand each DocSelect docSub = (DocSelect)mapDef; foreach (DocSelectItem dsi in docSub.Selects) { queue.Enqueue(dsi); } } else if ((included == null || included.ContainsKey(mapDef)) && !sort.ContainsKey(docItem.Name)) { //TODO: if abstract entity, then go through subtypes... sort.Add(docItem.Name, docItem); } } } // resolve selects into final elements // first entities, then wrappers // entities foreach (DocSelectItem docItem in sort.Values) { DocObject mapDef = null; if (map.TryGetValue(docItem.Name, out mapDef)) { if (included == null || included.ContainsKey(mapDef)) { sb.Append("\t\t\t<xs:element ref=\"ifc:"); sb.Append(docItem.Name); if (mapDef is DocDefined || mapDef is DocEnumeration) { sb.Append("-wrapper"); } sb.Append("\"/>"); sb.AppendLine(); } } } sb.Append("\t\t</xs:choice>"); sb.AppendLine(); sb.Append("\t</xs:group>"); sb.AppendLine(); return(sb.ToString()); }
/// <summary> /// If matching figure exists, generates HTML including the figure and increments the figure count. /// </summary> /// <param name="docProject">The project</param> /// <param name="definition">Object for which to find figure.</param> /// <param name="dtd">Optional template for which to find figure.</param> /// <param name="caption">Caption of definition used in determining figure caption, e.g. 'Beam'</param> /// <param name="listFigures">List of figures for determining numbering; appended as applicable by function.</param> /// <returns></returns> private static string FormatFigure(DocProject docProject, DocObject definition, DocTemplateDefinition dtd, string caption, List<ContentRef> listFigures) { string title = null; string desc = null; if (!String.IsNullOrEmpty(caption)) { title = caption; desc = caption.Substring(0, 1).ToUpper() + caption.Substring(1); } else { title = "<i>" + definition.Name + "</i>"; desc = title; } StringBuilder sb = new StringBuilder(); if (definition is DocDefinition) //TODO: property set figures { DocSchema docSchema = docProject.GetSchemaOfDefinition((DocDefinition)definition); string filename = MakeLinkName(definition); if (dtd != null) { filename += "-" + MakeLinkName(dtd); } filename += ".png"; string filepath = Properties.Settings.Default.OutputPath + @"\figures\" + filename; if (System.IO.File.Exists(filepath)) { listFigures.Add(new ContentRef(desc, definition)); // "Sensor", "Port Use Definition" ==> "Sensor Port Use" string figuredef = "usage"; if (dtd != null) { figuredef = dtd.Name.ToLower(); } // Per ISO guidelines, all figures must be referenced from text. sb.Append("<p>Figure "); sb.Append(listFigures.Count); sb.Append(" illustrates "); sb.Append(title.ToLower()); sb.Append(" "); sb.Append(figuredef.ToLower()); sb.Append(".</p>\r\n"); // include the figure with formatting below per ISO sb.Append("<table><tr><td><img src=\"../../../figures/"); sb.Append(filename); sb.Append("\" alt=\""); sb.Append(figuredef); sb.Append("\"></td></tr><tr><td><p class=\"figure\">Figure "); sb.Append(listFigures.Count); sb.Append(" — "); sb.Append(desc); sb.Append(" "); sb.Append(figuredef); sb.Append("</p></td></tr></table>\r\n"); sb.AppendLine(); } } return sb.ToString(); }
/// <summary> /// Generates HTTP-compatible name for object /// </summary> /// <param name="docobj"></param> /// <returns></returns> public static string MakeLinkName(DocObject docobj) { if (docobj.Name == null) return docobj.Uuid.ToString(); StringBuilder sb = new StringBuilder(); for (int i = 0; i < docobj.Name.Length; i++ ) { Char ch = docobj.Name[i]; if ((ch >= 'A' && ch <= 'Z') || (ch >= 'a' && ch <= 'z') || (ch >= '0' && ch <= '9') || ch == '-' || ch == '_') { sb.Append(ch); } else if (ch == ' ') { sb.Append('-'); } } return sb.ToString().ToLower(); }
public void flush(){ System.Console.WriteLine ("FLSH!!!!!!!!!"); string tag = this.obj.dicTag ["tag"]; System.Globalization.TextInfo tf = new System.Globalization.CultureInfo ("en-US", false).TextInfo; string className = "Novel." + tf.ToTitleCase (tag) + "Component"; Debug.Log (className); //Novel.Bg_removeComponent AbstractComponent test = new Novel.Bg_removeComponent (); Debug.Log (test); Debug.Log (test.GetType ().FullName); className = test.GetType ().FullName; //リフレクションで動的型付け Type masterType = Type.GetType (className); Debug.Log (masterType); AbstractComponent cmp; cmp = (AbstractComponent)Activator.CreateInstance (masterType); this.obj.dicParamDefault = cmp.originalParam; Dictionary<string,string> tmpDic = new Dictionary<string,string> (); List<string> l = cmp.arrayVitalParam; for (var i = 0; i < l.Count; i++) { string vital = l [i]; tmpDic [vital] = "yes"; } this.obj.dicParamVital = tmpDic; //必須パラメータとかデフォルト値を取得 this.arrDoc.Add (this.obj); this.obj = new DocObject (); this.status = ""; }