diff --git a/XSDDiagrams/Rendering/DiagramGdiRenderer.cs b/XSDDiagrams/Rendering/DiagramGdiRenderer.cs index c9591c0..0f465b4 100644 --- a/XSDDiagrams/Rendering/DiagramGdiRenderer.cs +++ b/XSDDiagrams/Rendering/DiagramGdiRenderer.cs @@ -14,6 +14,7 @@ using System; using System.Drawing; using System.Drawing.Imaging; using System.Drawing.Drawing2D; +using System.Text.RegularExpressions; namespace XSDDiagram.Rendering { @@ -484,6 +485,46 @@ namespace XSDDiagram.Rendering _graphics.DrawString(drawingItem.Name, drawingItem.Font, foreground, new RectangleF(scaledElementBox.X, scaledElementBox.Y, scaledElementBox.Width, scaledElementBox.Height), stringFormatText); } + // Draw Documentation + + 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) + { + string text = null; + XMLSchema.documentation documentation = o as XMLSchema.documentation; + if (documentation.Any != null && documentation.Any.Length > 0) + { + 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; + } + if (text != null) + { + StringFormat stringFormatText = new StringFormat(); + stringFormatText.Alignment = StringAlignment.Near; + stringFormatText.LineAlignment = StringAlignment.Near; + stringFormatText.FormatFlags |= StringFormatFlags.NoClip; //MONOFIX + _graphics.DrawString(text, drawingItem.Font, foreground + , new RectangleF(scaledElementBox.X - drawingItem.Diagram.Scale * 5.0f, scaledElementBox.Y + scaledElementBox.Height + drawingItem.Diagram.Scale * 12.0f + , scaledElementBox.Width + drawingItem.Diagram.Scale * 10.0f, 2.0f * scaledElementBox.Height) + , stringFormatText); + } + break; + } + } + } + // Draw occurences small text if (drawingItem.MaxOccurrence > 1 || drawingItem.MaxOccurrence == -1) {