public void GenerateMeasure(Graphics g)
{
if (_parent != null)
_depth = _parent.Depth + 1;
if (_itemType == DiagramItemType.group)
{
_size = new Size(40, 20);
}
//else
// size = new Size(50, 25);
if (_name.Length > 0)
{
SizeF sizeF = g.MeasureString(_name, Font);
//MONOFIX size = sizeF.ToSize();
_size = new Size((int)sizeF.Width, (int)sizeF.Height);
_size = _size + new Size(2 * Margin.Width + (_hasChildElements ? ChildExpandButtonSize : 0), 2 * Margin.Height);
}
int childBoundingBoxHeight = 0;
int childBoundingBoxWidth = 0;
if (_showChildElements)
{
// Measure the children
foreach (DiagramItem element in _childElements)
{
//MONOFIX GenerateMeasure not supported???
element.GenerateMeasure(g);
childBoundingBoxWidth = Math.Max(childBoundingBoxWidth, element.BoundingBox.Size.Width);
childBoundingBoxHeight += element.BoundingBox.Size.Height;
}
}
_boundingBox.Width = _size.Width + 2 * _padding.Width + childBoundingBoxWidth;
_boundingBox.Height = Math.Max(_size.Height + 2 * _padding.Height, childBoundingBoxHeight);
if (_diagram.ShowDocumentation)
{
string text = GetTextDocumentation();
if (text != null)
{
if (_size.Width < _documentationMinWidth)
{
int widthOffset = _documentationMinWidth - _size.Width;
_size.Width += widthOffset;
_boundingBox.Width += widthOffset;
}
SizeF sizeF = g.MeasureString(text, DocumentationFont);
double documentationWidth = Math.Max(1.0, _size.Width + _padding.Width); // * 2.0);
double documentationHeight = (Math.Ceiling(sizeF.Width / documentationWidth) + 1.8) * sizeF.Height;
_documentationBox = new Rectangle(new Point(0, 0), new Size((int)documentationWidth, (int)documentationHeight));
_boundingBox.Height = Math.Max(_size.Height + 2 * _padding.Height + _documentationBox.Height + 2 * _padding.Height, childBoundingBoxHeight);
}
}
_elementBox = new Rectangle(new Point(0, 0), _size - new Size(_hasChildElements ? _childExpandButtonSize / 2 : 0, 0));
if (_hasChildElements)
{
_childExpandButtonBox.X = _elementBox.Width - _childExpandButtonSize / 2;
_childExpandButtonBox.Y = (_elementBox.Height - _childExpandButtonSize) / 2;
_childExpandButtonBox.Width = _childExpandButtonSize;
_childExpandButtonBox.Height = _childExpandButtonSize;
}
}