/// <summary> /// Paints panel pnlInfo /// </summary> void PnlInfo_Paint(object sender, PaintEventArgs e) { // ---------------------------------------------------------------------+ // | Way points description | // |--------------------------------------------------------------------+ // | Number | Description | Price | Direction | Lots | Position | Order | // |--------------------------------------------------------------------+ //xp0 xp1 xp2 xp3 xp4 xp5 xp6 xp7 Graphics g = e.Graphics; g.Clear(LayoutColors.ColorControlBack); if (!Data.IsData || !Data.IsResult) { return; } Panel pnl = (Panel)sender; Brush brush = Brushes.White; string FF = Data.FF; // Format modifier to print the floats Size size = new Size(aiX[columns] - aiX[0], infoRowHeight); StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center; sf.LineAlignment = StringAlignment.Near; // Caption background PointF pntStart = new PointF(0, 0); SizeF szfCaption = new Size(pnl.ClientSize.Width, 2 * infoRowHeight); RectangleF rectfCaption = new RectangleF(pntStart, szfCaption); Data.GradientPaint(g, rectfCaption, LayoutColors.ColorCaptionBack, LayoutColors.DepthCaption); // Caption Text StringFormat stringFormatCaption = new StringFormat(); stringFormatCaption.LineAlignment = StringAlignment.Center; stringFormatCaption.Trimming = StringTrimming.EllipsisCharacter; stringFormatCaption.FormatFlags = StringFormatFlags.NoWrap; stringFormatCaption.Alignment = StringAlignment.Near; string stringCaptionText = Language.T("Way Points Description"); float fCaptionWidth = (float)Math.Min(pnlInfo.ClientSize.Width, aiX[columns] - aiX[0]); float fCaptionTextWidth = g.MeasureString(stringCaptionText, fontInfo).Width; float fCaptionTextX = (float)Math.Max((fCaptionWidth - fCaptionTextWidth) / 2f, 0); PointF pfCaptionText = new PointF(fCaptionTextX, 0); SizeF sfCaptionText = new SizeF(fCaptionWidth - fCaptionTextX, infoRowHeight); rectfCaption = new RectangleF(pfCaptionText, sfCaptionText); // First caption raw g.DrawString(stringCaptionText, fontInfo, brushCaptionText, rectfCaption, stringFormatCaption); // Second caption raw for (int i = 0; i < columns; i++) { g.DrawString(asTitles[i], fontInfo, brushCaptionText, (aiX[i] + aiX[i + 1]) / 2, infoRowHeight, sf); } brush = new SolidBrush(LayoutColors.ColorControlText); for (int pnt = 0; pnt < Backtester.WayPoints(bar); pnt++) { int y = (pnt + 2) * infoRowHeight; Point point = new Point(aiX[0], y); // Even row if (pnt % 2f != 0) { g.FillRectangle(brushEvenRow, new Rectangle(point, size)); } int positionNumber = Backtester.WayPoint(bar, pnt).PosNumb; WayPointType wpType = Backtester.WayPoint(bar, pnt).WPType; PosDirection posDirection = Backtester.PosFromNumb(positionNumber).PosDir; double posLots = Backtester.PosFromNumb(positionNumber).PosLots; int ordNumber = Backtester.WayPoint(bar, pnt).OrdNumb; g.DrawString((pnt + 1).ToString(), fontInfo, brush, (aiX[0] + aiX[1]) / 2, y, sf); g.DrawString(Language.T(Way_Point.WPTypeToString(wpType)), fontInfo, brush, aiX[1] + 2, y); g.DrawString(Backtester.WayPoint(bar, pnt).Price.ToString(FF), fontInfo, brush, (aiX[3] + aiX[2]) / 2, y, sf); if (positionNumber > -1) { g.DrawString(Language.T(posDirection.ToString()), fontInfo, brush, (aiX[4] + aiX[3]) / 2, y, sf); g.DrawString(posLots.ToString(), fontInfo, brush, (aiX[5] + aiX[4]) / 2, y, sf); g.DrawString((positionNumber + 1).ToString(), fontInfo, brush, (aiX[6] + aiX[5]) / 2, y, sf); } if (ordNumber > -1) { g.DrawString((ordNumber + 1).ToString(), fontInfo, brush, (aiX[7] + aiX[6]) / 2, y, sf); } } // Vertical lines Pen penLine = new Pen(LayoutColors.ColorJournalLines); for (int i = 1; i < columns; i++) { g.DrawLine(penLine, aiX[i], 2 * infoRowHeight, aiX[i], ClientSize.Height - border); } // Border Pen penBorder = new Pen(Data.GetGradientColor(LayoutColors.ColorCaptionBack, -LayoutColors.DepthCaption), border); g.DrawLine(penBorder, 1, 2 * infoRowHeight, 1, pnl.ClientSize.Height); g.DrawLine(penBorder, pnl.ClientSize.Width - border + 1, 2 * infoRowHeight, pnl.ClientSize.Width - border + 1, pnl.ClientSize.Height); g.DrawLine(penBorder, 0, pnl.ClientSize.Height - border + 1, pnl.ClientSize.Width, pnl.ClientSize.Height - border + 1); return; }
/// <summary> /// Sets the journal columns with. /// </summary> private void SetJournalPoints() { columns = 7; aiColumnX = new int[8]; aiX = new int[8]; Graphics g = CreateGraphics(); asTitles = new string[7] { Language.T("Number"), Language.T("Description"), Language.T("Price"), Language.T("Direction"), Language.T("Lots"), Language.T("Position"), Language.T("Order") }; string longestDescription = ""; foreach (WayPointType wpType in Enum.GetValues(typeof(WayPointType))) { if (g.MeasureString(Language.T(Way_Point.WPTypeToString(wpType)), fontInfo).Width > g.MeasureString(longestDescription, fontInfo).Width) { longestDescription = Language.T(Way_Point.WPTypeToString(wpType)); } } string longestDirection = ""; foreach (PosDirection posDir in Enum.GetValues(typeof(PosDirection))) { if (g.MeasureString(Language.T(posDir.ToString()), fontInfo).Width > g.MeasureString(longestDirection, fontInfo).Width) { longestDirection = Language.T(posDir.ToString()); } } asContent = new string[7] { "99", longestDescription, "99.99999", longestDirection, "99999", "99999", "99999", }; aiColumnX[0] = border; for (int i = 0; i < columns; i++) { aiColumnX[i + 1] = aiColumnX[i] + (int)Math.Max(g.MeasureString(asContent[i], fontInfo).Width, g.MeasureString(asTitles[i], fontInfo).Width) + 4; } szPrice = g.MeasureString("9.9999", fontInfo).ToSize(); g.Dispose(); return; }