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

- Improve the documentation location on the diagram.

- Fix bug when zooming the fonts.
This commit is contained in:
dgis 2016-02-18 23:00:59 +01:00
parent b1995c0683
commit 7f5a677588
6 changed files with 67 additions and 16 deletions

View File

@ -131,6 +131,7 @@ version 0.18 (Not released yet)
- Fix a bug when printing with margin!
- On Linux with Mono, the horizontal and vertical scrollbars should now appear.
- Fix an UTF8 bug when downloading from a URL.
- Fix bug when zooming the fonts.
version 0.17 (2015-09-02)
- Add CSV and TXT output rendering following the Christian's idea.

Binary file not shown.

Binary file not shown.

View File

@ -25,10 +25,14 @@ namespace XSDDiagram.Rendering
private Size _size;
private Size _padding;
private float _scale;
private float _lastScale;
private Font _font;
private Font _fontScaled;
private Font _smallFont;
private Font _smallFontScaled;
private Font _documentationFont;
private Font _documentationFontScaled;
private Rectangle _boundingBox;
private DiagramAlignement _alignement;
@ -44,12 +48,13 @@ namespace XSDDiagram.Rendering
public Diagram()
{
_scale = 1.0f;
_size = new Size(100, 100);
_padding = new Size(10, 10);
_boundingBox = Rectangle.Empty;
_alignement = DiagramAlignement.Center;
_rootElements = new List<DiagramItem>();
_scale = 1.0f;
_lastScale = 1.0f;
_size = new Size(100, 100);
_padding = new Size(10, 10);
_boundingBox = Rectangle.Empty;
_alignement = DiagramAlignement.Center;
_rootElements = new List<DiagramItem>();
_elementsByName = new Dictionary<string, XSDObject>(StringComparer.OrdinalIgnoreCase);
}
@ -66,8 +71,11 @@ namespace XSDDiagram.Rendering
public bool ShowDocumentation { get { return _showDocumentation; } set { _showDocumentation = value; } }
public Font Font { get { return _font; } set { _font = value; } }
public Font FontScaled { get { return _fontScaled; } set { _fontScaled = value; } }
public Font SmallFont { get { return _smallFont; } set { _smallFont = value; } }
public Font SmallFontScaled { get { return _smallFontScaled; } set { _smallFontScaled = value; } }
public Font DocumentationFont { get { return _documentationFont; } set { _documentationFont = value; } }
public Font DocumentationFontScaled { get { return _documentationFontScaled; } set { _documentationFontScaled = value; } }
public IDictionary<string, XSDObject> ElementsByName { get { return _elementsByName; } set { _elementsByName = value; } }
public List<DiagramItem> RootElements { get { return _rootElements; } }
@ -444,13 +452,24 @@ namespace XSDDiagram.Rendering
//_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);
float fontScale = (float)Math.Pow(_scale, 2.0);
if (_font == null)
_font = new Font(fontName, 10.0f * fontScale, FontStyle.Bold, GraphicsUnit.Pixel);
if (_smallFont == null)
_smallFont = new Font(fontName, 9.0f * fontScale, GraphicsUnit.Pixel);
if (_documentationFont == null)
_documentationFont = new Font(fontName, 10.0f * fontScale, GraphicsUnit.Pixel);
{
_font = new Font(fontName, 10.0f, FontStyle.Bold, GraphicsUnit.Pixel);
_smallFont = new Font(fontName, 9.0f, GraphicsUnit.Pixel);
_documentationFont = new Font(fontName, 10.0f, GraphicsUnit.Pixel);
}
if (_fontScaled == null || _lastScale != _scale)
{
//float fontScale = (float)Math.Pow(_scale, 2.0);
float fontScale = _scale;
if (_fontScaled != null) _fontScaled.Dispose();
_fontScaled = new Font(fontName, 10.0f * fontScale, FontStyle.Bold, GraphicsUnit.Pixel);
if (_smallFontScaled != null) _smallFontScaled.Dispose();
_smallFontScaled = new Font(fontName, 9.0f * fontScale, GraphicsUnit.Pixel);
if (_documentationFontScaled != null) _documentationFontScaled.Dispose();
_documentationFontScaled = new Font(fontName, 10.0f * fontScale, GraphicsUnit.Pixel);
_lastScale = _scale;
}
foreach (DiagramItem element in _rootElements)
element.GenerateMeasure(g);

View File

@ -482,7 +482,7 @@ namespace XSDDiagram.Rendering
stringFormatText.Alignment = StringAlignment.Center;
stringFormatText.LineAlignment = StringAlignment.Center;
stringFormatText.FormatFlags |= StringFormatFlags.NoClip; //MONOFIX
_graphics.DrawString(drawingItem.Name, drawingItem.Font, foreground, new RectangleF(scaledElementBox.X, scaledElementBox.Y, scaledElementBox.Width, scaledElementBox.Height), stringFormatText);
_graphics.DrawString(drawingItem.Name, drawingItem.FontScaled, foreground, new RectangleF(scaledElementBox.X, scaledElementBox.Y, scaledElementBox.Width, scaledElementBox.Height), stringFormatText);
}
// Draw Documentation
@ -494,6 +494,7 @@ namespace XSDDiagram.Rendering
StringFormat stringFormatText = new StringFormat();
stringFormatText.Alignment = StringAlignment.Near;
stringFormatText.LineAlignment = StringAlignment.Near;
stringFormatText.Trimming = StringTrimming.EllipsisCharacter;
stringFormatText.FormatFlags |= StringFormatFlags.NoClip; //MONOFIX
//_graphics.DrawString(text, drawingItem.Font, foreground
@ -507,7 +508,7 @@ namespace XSDDiagram.Rendering
_graphics.FillRectangle(new SolidBrush(Color.FromArgb(color, 255 - color, color)), scaledDocumentationBox);
_graphics.DrawRectangle(foregroundPen, scaledDocumentationBox);
}
_graphics.DrawString(text, drawingItem.DocumentationFont, foreground
_graphics.DrawString(text, drawingItem.DocumentationFontScaled, foreground
, new RectangleF(scaledDocumentationBox.X, scaledDocumentationBox.Y, scaledDocumentationBox.Width, scaledDocumentationBox.Height)
, stringFormatText);
}
@ -525,7 +526,7 @@ namespace XSDDiagram.Rendering
PointF pointOccurences = new PointF();
pointOccurences.X = drawingItem.Diagram.Scale * (drawingItem.Location.X + drawingItem.Size.Width - 10);
pointOccurences.Y = drawingItem.Diagram.Scale * (drawingItem.Location.Y + drawingItem.Size.Height + 10);
_graphics.DrawString(occurences, drawingItem.SmallFont, foreground, pointOccurences, stringFormatOccurences);
_graphics.DrawString(occurences, drawingItem.SmallFontScaled, foreground, pointOccurences, stringFormatOccurences);
}
// Draw type

View File

@ -266,6 +266,13 @@ namespace XSDDiagram.Rendering
return _diagram.Font;
}
}
public Font FontScaled
{
get
{
return _diagram.FontScaled;
}
}
public Font SmallFont
{
@ -274,6 +281,14 @@ namespace XSDDiagram.Rendering
return _diagram.SmallFont;
}
}
public Font SmallFontScaled
{
get
{
return _diagram.SmallFontScaled;
}
}
public Font DocumentationFont
{
get
@ -281,6 +296,13 @@ namespace XSDDiagram.Rendering
return _diagram.DocumentationFont;
}
}
public Font DocumentationFontScaled
{
get
{
return _diagram.DocumentationFontScaled;
}
}
public Point Location
{
@ -523,7 +545,15 @@ namespace XSDDiagram.Rendering
double documentationWidth = Math.Max(1.0, _size.Width + _padding.Width * 2.0);
double documentationHeight = (Math.Ceiling(sizeF.Width / documentationWidth) + 1) * sizeF.Height;
_documentationBox = new Rectangle(new Point(0, 0), new Size((int)documentationWidth, (int)documentationHeight));
_boundingBox.Height += (_diagram.Alignement == DiagramAlignement.Center ? 2 : 1) *_documentationBox.Height + 2 * _padding.Height;
//_boundingBox.Height += (_diagram.Alignement == DiagramAlignement.Center ? 2 : 1) * _documentationBox.Height + 2 * _padding.Height;
//if(_diagram.Alignement == DiagramAlignement.Center)
//{
// _boundingBox.Height = Math.Max(_size.Height + 2 * _padding.Height + 2 * _documentationBox.Height + 2 * _padding.Height, childBoundingBoxHeight);
//}
//else
{
_boundingBox.Height = Math.Max(_size.Height + 2 * _padding.Height + _documentationBox.Height + 2 * _padding.Height, childBoundingBoxHeight);
}
}
}