1
1
mirror of https://github.com/dgis/xsddiagram.git synced 2024-08-17 06:20:23 +03:00

Test the addition of the descriptions in the diagram.

This commit is contained in:
dgis 2015-10-01 23:05:38 +02:00
parent 49548a9dbb
commit ec646e9654

View File

@ -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)
{