void UpdateRectanglePositioning()
{
// calc char size
SizeF charSize = this.CreateGraphics().MeasureString("A", Font, 100, _stringFormat);
_charSize = new SizeF((float)Math.Ceiling(charSize.Width), (float)Math.Ceiling(charSize.Height));
// calc content bounds
_recContent = ClientRectangle;
_recContent.X += _recBorderLeft;
_recContent.Y += _recBorderTop;
_recContent.Width -= _recBorderRight + _recBorderLeft;
_recContent.Height -= _recBorderBottom + _recBorderTop;
if (_vScrollBarVisible)
{
_recContent.Width -= _vScrollBar.Width;
_vScrollBar.Left = _recContent.X + _recContent.Width;
_vScrollBar.Top = _recContent.Y;
_vScrollBar.Height = _recContent.Height;
}
int marginLeft = 4;
// calc line info bounds
if (_lineInfoVisible)
{
_recLineInfo = new Rectangle(_recContent.X + marginLeft,
_recContent.Y,
(int)(_charSize.Width * 10),
_recContent.Height);
}
else
{
_recLineInfo = Rectangle.Empty;
_recLineInfo.X = marginLeft;
}
// calc hex bounds and grid
_recHex = new Rectangle(_recLineInfo.X + _recLineInfo.Width,
_recLineInfo.Y,
_recContent.Width - _recLineInfo.Width,
_recContent.Height);
if (UseFixedBytesPerLine)
{
SetHorizontalByteCount(_bytesPerLine);
_recHex.Width = (int)Math.Floor(((double)_iHexMaxHBytes) * _charSize.Width * 3 + (2 * _charSize.Width));
}
else
{
int hmax = (int)Math.Floor((_recHex.Width - (_vScrollBarVisible ? _vScrollBar.Width : 0)) / (double)_charSize.Width);
if (hmax > 1)
{
if (_stringViewVisible)
{
SetHorizontalByteCount((int)Math.Floor((double)hmax / 4) );
_recHex.Width = (int)Math.Floor(((double)_iHexMaxHBytes) * _charSize.Width * 3 + (2 * _charSize.Width));
}
else
{
SetHorizontalByteCount((int)Math.Floor((double)hmax / 3));
}
}
else
SetHorizontalByteCount(hmax);
}
if (_stringViewVisible)
{
_recStringView = new Rectangle(_recHex.X + _recHex.Width,
_recHex.Y,
(int)(_charSize.Width * _iHexMaxHBytes),
_recHex.Height);
}
else
{
_recStringView = Rectangle.Empty;
}
int vmax = (int)Math.Floor(_recHex.Height / (double)_charSize.Height);
SetVerticalByteCount(vmax);
_iHexMaxBytes = _iHexMaxHBytes * _iHexMaxVBytes;
UpdateScrollSize();
}