/// <summary> /// Paints the journal /// </summary> protected override void OnPaint(PaintEventArgs e) { base.OnPaint(e); if (ClientSize.Width == 0 || ClientSize.Height == 0) { return; } var bitmap = new Bitmap(ClientSize.Width, ClientSize.Height); Graphics g = Graphics.FromImage(bitmap); int hScroll = -HScrollBar.Value; var sf = new StringFormat { Alignment = StringAlignment.Center }; // Caption background var rectCaption = new RectangleF(0, 0, ClientSize.Width, 2 * rowHeight); Data.GradientPaint(g, rectCaption, LayoutColors.ColorCaptionBack, LayoutColors.DepthCaption); var font = new Font(Font.FontFamily, 9); Color colorBack = LayoutColors.ColorControlBack; var brushCaptionText = new SolidBrush(LayoutColors.ColorCaptionText); var brushEvenRowBack = new SolidBrush(LayoutColors.ColorEvenRowBack); var brushSelectedRowBack = new SolidBrush(LayoutColors.ColorSelectedRowBack); var brushSelectedRowText = new SolidBrush(LayoutColors.ColorSelectedRowText); var brushRowText = new SolidBrush(LayoutColors.ColorControlText); var brushWarningBack = new SolidBrush(LayoutColors.ColorWarningRowBack); var brushWarningText = new SolidBrush(LayoutColors.ColorWarningRowText); var penLines = new Pen(LayoutColors.ColorJournalLines); var penBorder = new Pen(Data.GetGradientColor(LayoutColors.ColorCaptionBack, -LayoutColors.DepthCaption), Border); // Print the journal caption string unit = Configs.AccountInMoney ? " [" + Configs.AccountCurrency + "]" : " [" + Language.T("points") + "]"; string accUnit = " [" + Configs.AccountCurrency + "]"; g.SetClip(new RectangleF(Border, 0, ClientSize.Width - 2 * Border, 2 * rowHeight)); g.DrawString(Language.T("Market Data"), font, brushCaptionText, hScroll + (xScaled[8] + xScaled[0]) / 2, 0, sf); g.DrawString(Language.T("Summary") + unit, font, brushCaptionText, hScroll + (xScaled[14] + xScaled[8]) / 2, 0, sf); g.DrawString(Language.T("Account") + unit, font, brushCaptionText, hScroll + (xScaled[16] + xScaled[14]) / 2, 0, sf); g.DrawString(Language.T("Margin") + accUnit, font, brushCaptionText, hScroll + (xScaled[18] + xScaled[16]) / 2, 0, sf); g.DrawString(Language.T("Backtest"), font, brushCaptionText, hScroll + (xScaled[19] + xScaled[18]) / 2, 0, sf); if (Configs.AccountInMoney) { for (int i = 0; i < columns; i++) { g.DrawString(titlesInMoney[i], font, brushCaptionText, hScroll + (xScaled[i] + xScaled[i + 1]) / 2, rowHeight, sf); } } else { for (int i = 0; i < columns; i++) { g.DrawString(titlesInPoints[i], font, brushCaptionText, hScroll + (xScaled[i] + xScaled[i + 1]) / 2, rowHeight, sf); } } g.ResetClip(); var rectField = new RectangleF(Border, 2 * rowHeight, ClientSize.Width - 2 * Border, ClientSize.Height - 2 * rowHeight - Border); g.FillRectangle(new SolidBrush(colorBack), rectField); var size = new Size(ClientSize.Width - VScrollBar.Width - 2 * Border, rowHeight); // Prints the journal data for (int bar = firstBar; bar < firstBar + shownBars; bar++) { int y = (bar - firstBar + 2) * rowHeight; var point = new Point(Border, y); // Even row if (Math.Abs((bar - firstBar) % 2f - 0) > 0.0001) { g.FillRectangle(brushEvenRowBack, new Rectangle(point, size)); } // Warning row bool isWarningRow = false; if (journalData[bar - firstBar, columns - 1] == Language.T("Ambiguous")) { g.FillRectangle(brushWarningBack, new Rectangle(point, size)); isWarningRow = true; } // Selected row Brush brush; if (bar - firstBar == selectedRow) { g.FillRectangle(brushSelectedRowBack, new Rectangle(point, size)); brush = brushSelectedRowText; } else { brush = isWarningRow ? brushWarningText : brushRowText; } int index = bar - firstBar; // Draw the position icon int imgY = y + (int)Math.Floor((rowHeight - 16) / 2.0); g.DrawImage(positionIcons[index], hScroll + 2, imgY, 16, 16); // Prints the data g.DrawString(journalData[index, 0], font, brush, hScroll + (16 + xScaled[1]) / 2, (index + 2) * rowHeight, sf); for (int i = 1; i < columns; i++) { g.DrawString(journalData[index, i], font, brush, hScroll + (xScaled[i] + xScaled[i + 1]) / 2, (index + 2) * rowHeight, sf); } } // Vertical grid lines for (int i = 1; i < columns; i++) { if (i == 8 || i == 14 || i == 16 || i == 18) { var rectSeparator = new RectangleF(xScaled[i] + hScroll, (float)(rowHeight / 2.0), 1, (float)(3 * rowHeight / 2.0)); Data.GradientPaint(g, rectSeparator, LayoutColors.ColorCaptionBack, -2 * LayoutColors.DepthCaption); } g.DrawLine(penLines, xScaled[i] + hScroll, 2 * rowHeight, xScaled[i] + hScroll, ClientSize.Height); } // Borders 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); DIBSection.DrawOnPaint(e.Graphics, bitmap, Width, Height); OnSelectedBarChange(new EventArgs()); }