public string GetTextDocumentation() { string text = null; XMLSchema.annotated annotated = this.TabSchema as XMLSchema.annotated; if (annotated != null && annotated.annotation != null) { text = DiagramHelpers.GetAnnotationText(annotated.annotation); //foreach (object o in annotated.annotation.Items) //{ // if (o is XMLSchema.documentation) // { // XMLSchema.documentation documentation = o as XMLSchema.documentation; // if (documentation.Any != null && documentation.Any.Length > 0 && documentation.Any[0].Value != null) // { // text = documentation.Any[0].Value; // text = text.Replace("\n", " "); // text = text.Replace("\t", " "); // text = text.Replace("\r", ""); // text = Regex.Replace(text, " +", " "); // text = text.Trim(); // } // else if (documentation.source != null) // { // text = documentation.source; // } // // break; // } //} } return(text); }
public static AttachSides GetAttachmentSidesForConnection(Rect fromRect, Rect toRect) { double angle = DiagramHelpers.GetAngleBetweenRects(fromRect, toRect); if (angle > 320 || angle < 40) { return(new AttachSides(AttachDirection.Right, AttachDirection.Left)); } if (angle >= 40 && angle < 140) { return(new AttachSides(AttachDirection.Top, AttachDirection.Bottom)); } if (angle >= 140 && angle < 220) { return(new AttachSides(AttachDirection.Left, AttachDirection.Right)); } if (angle >= 220) { return(new AttachSides(AttachDirection.Bottom, AttachDirection.Top)); } return(new AttachSides(AttachDirection.Top, AttachDirection.Top)); }
/// <summary> /// Renders the specified drawing item. /// </summary> /// <param name="drawingItem">The drawing item.</param> public override void Render(DiagramItem drawingItem) { string type = ""; if (drawingItem.TabSchema is XMLSchema.element) { type = "element"; } else if (drawingItem.TabSchema is XMLSchema.simpleType) { type = "simpleType"; } else if (drawingItem.TabSchema is XMLSchema.complexType) { type = "complexType"; } string occurences = String.Format("{0}..", drawingItem.MinOccurrence) + (drawingItem.MaxOccurrence == -1 ? "∞" : string.Format("{0}", drawingItem.MaxOccurrence)); if (type.Length > 0) { string path = '/' + drawingItem.Name; DiagramItem parentElement = drawingItem.Parent; while (parentElement != null) { //if (parentElement.ItemType == DiagramItemType.element && !string.IsNullOrEmpty(parentElement.Name)) if ((type == "element" || type == "simpleType" || type == "complexType") && !string.IsNullOrEmpty(parentElement.Name)) { path = '/' + parentElement.Name + path; } parentElement = parentElement.Parent; } // Get the comment/documentation string comment = ""; XMLSchema.annotated annotated = drawingItem.TabSchema as XMLSchema.annotated; if (annotated != null && annotated.annotation != null) { foreach (object o in annotated.annotation.Items) { if (o is XMLSchema.documentation) { XMLSchema.documentation documentation = o as XMLSchema.documentation; if (documentation.Any != null && documentation.Any.Length > 0 && documentation.Any[0].Value != null) { string text = documentation.Any[0].Value; text = text.Replace("\n", " "); text = text.Replace("\t", " "); text = text.Replace("\r", ""); text = Regex.Replace(text, " +", " "); text = text.Trim(); comment = text; } else if (documentation.source != null) { comment = documentation.source; } break; } } } //bool lastChild = drawingItem.Parent.ChildElements[drawingItem.Parent.ChildElements.Count - 1] == drawingItem; // Output the item string t; XMLSchema.element el; for (int i = 0; i < _finalTextOutputFields.Count; i++) { el = drawingItem.TabSchema as XMLSchema.element; if (el != null) { string et = "" + el.type; if (et == "") { t = "[none]"; } else { t = et.Substring(et.LastIndexOf(':') + 1); if (t == "") { t = "[none]"; } } } else { t = "[none]"; } if (i > 0) { _writer.Write(_fieldSeparator); } string field = _finalTextOutputFields[i]; switch (field) { case "PATH": _writer.Write(path); break; case "NAME": _writer.Write(drawingItem.Name); break; case "TYPE": _writer.Write(type); break; case "NAMESPACE": _writer.Write(drawingItem.NameSpace); break; case "COMMENT": _writer.Write(comment); break; case "SEQ": _writer.Write(occurences); break; case "LASTCHILD": _writer.Write(this.iteratingLastChild ? "1" : "0"); break; case "XSDTYPE": _writer.Write(t); break; } } _writer.WriteLine(); // Output the item attributes if (this.Schema != null && this.DisplayAttributes) { string nameSpace = drawingItem.NameSpace; if (annotated != null) { // Attributes enumeration List <XSDAttribute> listAttributes = DiagramHelpers.GetAnnotatedAttributes(this.Schema, annotated, nameSpace); listAttributes.Reverse(); for (int a = 0; a < listAttributes.Count; a++) { XSDAttribute xsdAttribute = listAttributes[a]; if (xsdAttribute != null) { string commentAttribute = ""; XMLSchema.attribute attribute = xsdAttribute.Tag; if (attribute != null && attribute.annotation != null) { commentAttribute = DiagramHelpers.GetAnnotationText(attribute.annotation); } for (int i = 0; i < _finalTextOutputFields.Count; i++) { if (i > 0) { _writer.Write(_fieldSeparator); } string field = _finalTextOutputFields[i]; switch (field) { case "PATH": _writer.Write(path + "@" + xsdAttribute.Name); break; case "NAME": _writer.Write(drawingItem.Name + "@" + xsdAttribute.Name); break; case "TYPE": _writer.Write(xsdAttribute.Type); break; case "NAMESPACE": _writer.Write(xsdAttribute.NameSpace); break; case "COMMENT": _writer.Write(commentAttribute); break; } } _writer.WriteLine(); } //this.listViewAttributes.Items.Add(new ListViewItem(new string[] { attribute.Name, attribute.Type, attribute.Use, attribute.DefaultValue, s })).Tag = attribute; } } } //// Draw the inheritor line //if (drawingItem.InheritFrom != null) //{ //} //switch (drawingItem.ItemType) //{ // case DiagramItemType.element: // break; // case DiagramItemType.type: // break; // case DiagramItemType.group: // { // // Draw the main shape following the min/max occurences // // Draw the group type // switch (drawingItem.GroupType) // { // case DiagramItemGroupType.Sequence: break; // case DiagramItemGroupType.Choice: break; // case DiagramItemGroupType.All: break; // } // break; // } //} //// Draw text //if (drawingItem.Name.Length > 0) //{ // //drawingItem.Name; //} //// Draw occurences small text //if (drawingItem.MaxOccurrence > 1 || drawingItem.MaxOccurrence == -1) {} //// Draw type //if (drawingItem.IsSimpleContent) {} //// Draw reference arrow //if (drawingItem.IsReference) {} } // Draw children expand box if (drawingItem.HasChildElements && drawingItem.ShowChildElements) { int c = 0; foreach (DiagramItem element in drawingItem.ChildElements) { this.iteratingLastChild = drawingItem.ChildElements.Count == ++c; this.Render(element); //_writer.WriteLine(); } } }