Forex_Strategy_Builder.Journal_Ord.OnPaint C# (CSharp) Method

OnPaint() protected method

Paints the journal
protected OnPaint ( PaintEventArgs e ) : void
e PaintEventArgs
return void
        protected override void OnPaint(PaintEventArgs e)
        {
            Graphics g = e.Graphics;

            // Caption background
            RectangleF rectfCaption = new RectangleF(0, 0, ClientSize.Width, 2 * rowHeight);
            Data.GradientPaint(g, rectfCaption, LayoutColors.ColorCaptionBack, LayoutColors.DepthCaption);

            StringFormat sf = new StringFormat();
            sf.Alignment = StringAlignment.Center;
            int  iHScrll = -hScrollBar.Value;
            Size size    = new Size(btnToggleJournal.Left, rowHeight);

            // Print the journal caption
            string stringCaptionText = Language.T("Orders During the Bar") + (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)
                for (int i = 0; i < columns; i++)
                    g.DrawString(asTitlesMoney[i], font, brushCaptionText, iHScrll + (aiX[i] + aiX[i + 1]) / 2, rowHeight, sf);
            else
                for (int i = 0; i < columns; i++)
                    g.DrawString(asTitlesPips[i], font, brushCaptionText, iHScrll + (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 ord = firstOrd; ord < firstOrd + shownOrd; ord++)
            {
                int row = ord - firstOrd;
                int y = (row + 2) * rowHeight;
                Point point = new Point(border, y);

                // Even row
                if (row % 2f != 0)
                    g.FillRectangle(brushEvenRowBack, new Rectangle(point, size));

                // Draw the position icon
                int iImgY = y + (int)Math.Floor((rowHeight - 16) / 2.0);
                g.DrawImage(aiOrderIcons[row], iHScrll + 2, iImgY, 16, 16);

                // Prints the data
                g.DrawString(asJournalData[row, 0], font, brushRowText, iHScrll + (16 + aiX[1]) / 2, (row + 2) * rowHeight, sf);
                for (int i = 1; i < columns; i++)
                {
                    if(i == columns - 1)
                        g.DrawString(asJournalData[row, i], font, brushRowText, iHScrll + aiX[i], (row + 2) * rowHeight);
                    else
                        g.DrawString(asJournalData[row, i], font, brushRowText, iHScrll + (aiX[i] + aiX[i + 1]) / 2, (row + 2) * rowHeight, sf);
                }
            }

            //g.DrawLine(penLines, 0, iRowHeight, ClientSize.Width, iRowHeight);
            for (int i = 1; i < columns; i++)
                g.DrawLine(penLines, aiX[i] + iHScrll, 2 * rowHeight, aiX[i] + iHScrll, 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);

            return;
        }