mirror of
https://github.com/dgis/xsddiagram.git
synced 2024-08-17 06:20:23 +03:00
Improve the documentation layout on the diagram.
This commit is contained in:
parent
5b15fdea88
commit
becafdae90
@ -437,21 +437,6 @@ namespace XSDDiagram.Rendering
|
||||
{
|
||||
string fontName = "Arial"; // "Verdana"; // "Arial";
|
||||
|
||||
//if (_font != null)
|
||||
//{
|
||||
// _font.Dispose();
|
||||
//}
|
||||
//if (_smallFont != null)
|
||||
//{
|
||||
// _smallFont.Dispose();
|
||||
//}
|
||||
//if (_documentationFont != null)
|
||||
//{
|
||||
// _documentationFont.Dispose();
|
||||
//}
|
||||
//_font = new Font(fontName, 10.0f * (float)Math.Pow(_scale, 2.0), FontStyle.Bold, GraphicsUnit.Pixel);
|
||||
//_smallFont = new Font(fontName, 9.0f * (float)Math.Pow(_scale, 2.0), GraphicsUnit.Pixel);
|
||||
//_documentationFont = new Font(fontName, 10.0f * (float)Math.Pow(_scale, 2.0), GraphicsUnit.Pixel);
|
||||
if (_font == null)
|
||||
{
|
||||
_font = new Font(fontName, 10.0f, FontStyle.Bold, GraphicsUnit.Pixel);
|
||||
|
@ -159,18 +159,19 @@ namespace XSDDiagram.Rendering
|
||||
Rectangle scaledElementBox = drawingItem.ScaleRectangle(drawingItem.ElementBox);
|
||||
|
||||
// Draw the children lines
|
||||
if (drawingItem.ShowChildElements)
|
||||
if (drawingItem.ShowChildElements && drawingItem.ChildElements.Count > 0)
|
||||
{
|
||||
Pen foregroundInheritPen = new Pen(foreground);
|
||||
foregroundInheritPen.StartCap = LineCap.Round;
|
||||
foregroundInheritPen.EndCap = LineCap.Round;
|
||||
|
||||
if (drawingItem.ChildElements.Count == 1)
|
||||
bool showDocumentation = (drawingItem.Diagram.ShowDocumentation && drawingItem.DocumentationBox != null);
|
||||
if (drawingItem.ChildElements.Count == 1 && !showDocumentation)
|
||||
{
|
||||
int parentMidleY = drawingItem.ScaleInt(drawingItem.Location.Y + drawingItem.Size.Height / 2);
|
||||
_graphics.DrawLine(foregroundInheritPen, drawingItem.ScaleInt(drawingItem.Location.X + drawingItem.Size.Width), parentMidleY, drawingItem.ScaleInt(drawingItem.ChildElements[0].Location.X), parentMidleY);
|
||||
}
|
||||
else if (drawingItem.ChildElements.Count > 1)
|
||||
else if (drawingItem.ChildElements.Count > 1 || showDocumentation)
|
||||
{
|
||||
DiagramItem firstElement = drawingItem.ChildElements[0];
|
||||
DiagramItem lastElement = drawingItem.ChildElements[drawingItem.ChildElements.Count - 1];
|
||||
@ -497,10 +498,6 @@ namespace XSDDiagram.Rendering
|
||||
stringFormatText.Trimming = StringTrimming.EllipsisCharacter;
|
||||
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);
|
||||
Rectangle scaledDocumentationBox = drawingItem.ScaleRectangle(drawingItem.DocumentationBox);
|
||||
if (drawingItem.Diagram.ShowBoundingBox)
|
||||
{
|
||||
|
@ -468,7 +468,7 @@ namespace XSDDiagram.Rendering
|
||||
return _diagram.ScaleRectangle(rectangle);
|
||||
}
|
||||
|
||||
public string GetTextDocumentation()
|
||||
public string GetTextDocumentation(bool autoWrap = false)
|
||||
{
|
||||
string text = null;
|
||||
XMLSchema.annotated annotated = this.TabSchema as XMLSchema.annotated;
|
||||
|
@ -114,16 +114,17 @@ namespace XSDDiagram.Rendering
|
||||
Rectangle scaledElementBox = drawingItem.ScaleRectangle(drawingItem.ElementBox);
|
||||
|
||||
// Draw the children lines
|
||||
if (drawingItem.ShowChildElements)
|
||||
if (drawingItem.ShowChildElements && drawingItem.ChildElements.Count > 0)
|
||||
{
|
||||
if (drawingItem.ChildElements.Count == 1)
|
||||
bool showDocumentation = (drawingItem.Diagram.ShowDocumentation && drawingItem.DocumentationBox != null);
|
||||
if (drawingItem.ChildElements.Count == 1 && !showDocumentation)
|
||||
{
|
||||
int parentMidleY = drawingItem.ScaleInt(drawingItem.Location.Y + drawingItem.Size.Height / 2);
|
||||
this.SVGLine(foregroundRoundPen,
|
||||
drawingItem.ScaleInt(drawingItem.Location.X + drawingItem.Size.Width),
|
||||
parentMidleY, drawingItem.ScaleInt(drawingItem.ChildElements[0].Location.X), parentMidleY);
|
||||
}
|
||||
else if (drawingItem.ChildElements.Count > 1)
|
||||
else if (drawingItem.ChildElements.Count > 1 || showDocumentation)
|
||||
{
|
||||
DiagramItem firstElement = drawingItem.ChildElements[0];
|
||||
DiagramItem lastElement = drawingItem.ChildElements[drawingItem.ChildElements.Count - 1];
|
||||
@ -461,6 +462,22 @@ namespace XSDDiagram.Rendering
|
||||
new Rectangle(scaledElementBox.X, scaledElementBox.Y, scaledElementBox.Width, scaledElementBox.Height));
|
||||
}
|
||||
|
||||
// Draw Documentation
|
||||
if (drawingItem.Diagram.ShowDocumentation && drawingItem.DocumentationBox != null)
|
||||
{
|
||||
string text = drawingItem.GetTextDocumentation();
|
||||
if (text != null)
|
||||
{
|
||||
//stringFormatText.Trimming = StringTrimming.EllipsisCharacter;
|
||||
Rectangle scaledDocumentationBox = drawingItem.ScaleRectangle(drawingItem.DocumentationBox);
|
||||
string style = String.Format(
|
||||
"font-family:{0};font-size:{1}pt;fill:{2};font-weight:bold;text-anchor:start;dominant-baseline:central;inline-size={3}",
|
||||
drawingItem.DocumentationFont.Name, drawingItem.DocumentationFont.Size * fontScale, foregroundColor, scaledDocumentationBox.Width);
|
||||
SVGText(text, style,
|
||||
new Rectangle(scaledDocumentationBox.X, scaledDocumentationBox.Y, scaledDocumentationBox.Width, scaledDocumentationBox.Height));
|
||||
}
|
||||
}
|
||||
|
||||
// Draw occurences small text
|
||||
if (drawingItem.MaxOccurrence > 1 || drawingItem.MaxOccurrence == -1)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user