protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
int scrll = -hScrollBar.Value;
bool isWarning = false;
Brush brush = Brushes.Red;
Size size = new Size(ClientSize.Width, rowHeight);
StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center;
// Caption background
RectangleF rectfCaption = new RectangleF(0, 0, ClientSize.Width, 2 * rowHeight);
Data.GradientPaint(g, rectfCaption, LayoutColors.ColorCaptionBack, LayoutColors.DepthCaption);
// Print the journal caption
string stringCaptionText = Language.T("Journal by Positions") + (Configs.AccountInMoney ? " [" + Configs.AccountCurrency + "]" : " [" + Language.T("pips") + "]");
g.DrawString(stringCaptionText, font, brushCaptionText, new RectangleF(Point.Empty, size), sf);
g.SetClip(new RectangleF(border, rowHeight, ClientSize.Width - 2 * border, rowHeight));
if (Configs.AccountInMoney)
{
g.DrawString(asTitlesMoney[0], font, brushCaptionText, scrll + (aiX[0] + aiX[1]) / 2, rowHeight, sf);
for (int i = 1; i < columns; i++)
g.DrawString(asTitlesMoney[i], font, brushCaptionText, scrll + (aiX[i] + aiX[i + 1]) / 2, rowHeight, sf);
}
else
{
g.DrawString(asTitlesPips[0], font, brushCaptionText, scrll + (aiX[0] + aiX[1]) / 2, rowHeight, sf);
for (int i = 1; i < columns; i++)
g.DrawString(asTitlesPips[i], font, brushCaptionText, scrll + (aiX[i] + aiX[i + 1]) / 2, rowHeight, sf);
}
g.ResetClip();
// Paints the journal's data field
RectangleF rectField = new RectangleF(border, 2 * rowHeight, ClientSize.Width - 2 * border, ClientSize.Height - 2 * rowHeight - border);
g.FillRectangle(new SolidBrush(colorBack), rectField);
size = new Size(ClientSize.Width - vScrollBar.Width - 2 * border, rowHeight);
// Prints the journal data
for (int pos = firstPos; pos < firstPos + shownPos; pos++)
{
int y = (pos - firstPos + 2) * rowHeight;
Point point = new Point(border, y);
// Even row
if ((pos - firstPos) % 2f != 0)
g.FillRectangle(brushEvenRowBack, new Rectangle(point, size));
// Warning row
if (asJournalData[pos - firstPos, columns - 1] == Language.T("Ambiguous"))
{
g.FillRectangle(brushWarningBack, new Rectangle(point, size));
isWarning = true;
}
else
{
isWarning = false;
}
// Selected row
if (pos - firstPos == selectedRow)
{
g.FillRectangle(brushSelectedRowBack, new Rectangle(point, size));
brush = brushSelectedRowText;
}
else
{
brush = isWarning ? brushWarningText : brushRowText;
}
// Draw the position icon
int iImgY = y + (int)Math.Floor((rowHeight - 16) / 2.0);
g.DrawImage(aiPositionIcons[pos - firstPos], scrll + 2, iImgY, 16, 16);
// Prints the data
g.DrawString(asJournalData[pos - firstPos, 0], font, brush, scrll + (16 + aiX[1]) / 2, (pos - firstPos + 2) * rowHeight, sf);
for (int i = 1; i < columns; i++)
g.DrawString(asJournalData[pos - firstPos, i], font, brush, scrll + (aiX[i] + aiX[i + 1]) / 2, (pos - firstPos + 2) * rowHeight, sf);
}
//g.DrawLine(penLines, 0, iRowHeight, ClientSize.Width, iRowHeight);
for (int i = 1; i < columns; i++)
g.DrawLine(penLines, aiX[i] + scrll, 2 * rowHeight, aiX[i] + scrll, ClientSize.Height);
// Border
g.DrawLine(penBorder, 1, 2 * rowHeight, 1, ClientSize.Height);
g.DrawLine(penBorder, ClientSize.Width - border + 1, 2 * rowHeight, ClientSize.Width - border + 1, ClientSize.Height);
g.DrawLine(penBorder, 0, ClientSize.Height - border + 1, ClientSize.Width, ClientSize.Height - border + 1);
OnSelectedBarChange(new EventArgs());
return;
}