void PnlInfo_Paint(object sender, PaintEventArgs e)
{
// +------------------------------------------------------+
// | Data |
// |------------------- ----------------------------------+
// | Period | Bars | From | Until | Cover | % | Label |
// |------------------------------------------------------+
//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;
string FF = Data.FF; // Format modifier to print the numbers
int border = 2;
int xp0 = border;
int xp1 = 80;
int xp2 = 140;
int xp3 = 200;
int xp4 = 260;
int xp5 = 320;
int xp6 = 370;
int xp7 = pnl.ClientSize.Width - border;
Size size = new Size(xp7 - xp0, 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 - 0, 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("Intrabar Data");
float captionWidth = Math.Min(pnlInfo.ClientSize.Width, xp7 - xp0);
float captionTextWidth = g.MeasureString(stringCaptionText, fontInfo).Width;
float captionTextX = Math.Max((captionWidth - captionTextWidth) / 2f, 0);
PointF pfCaptionText = new PointF(captionTextX, 0);
SizeF sfCaptionText = new SizeF(captionWidth - captionTextX, infoRowHeight);
rectfCaption = new RectangleF(pfCaptionText, sfCaptionText);
Brush brush = new SolidBrush(LayoutColors.ColorCaptionText);
// First caption row
g.DrawString(stringCaptionText, fontInfo, brush, rectfCaption, stringFormatCaption);
// Second title row
g.DrawString(Language.T("Period"), fontInfo, brush, (xp1 + xp0) / 2, infoRowHeight, sf);
g.DrawString(Language.T("Bars"), fontInfo, brush, (xp2 + xp1) / 2, infoRowHeight, sf);
g.DrawString(Language.T("From"), fontInfo, brush, (xp3 + xp2) / 2, infoRowHeight, sf);
g.DrawString(Language.T("Until"), fontInfo, brush, (xp4 + xp3) / 2, infoRowHeight, sf);
g.DrawString(Language.T("Coverage"), fontInfo, brush, (xp5 + xp4) / 2, infoRowHeight, sf);
g.DrawString("%", fontInfo, brush, (xp6 + xp5) / 2, infoRowHeight, sf);
g.DrawString(Language.T("Label"), fontInfo, brush, (xp7 + xp6) / 2, infoRowHeight, sf);
brush = new SolidBrush(LayoutColors.ColorControlText);
int allPeriods = Enum.GetValues(typeof(DataPeriods)).Length;
for (int iPeriod = 0; iPeriod <= allPeriods; iPeriod++)
{
int y = (iPeriod + 2) * infoRowHeight;
Point point = new Point(xp0, y);
if (iPeriod % 2f != 0)
g.FillRectangle(new SolidBrush(LayoutColors.ColorEvenRowBack), new Rectangle(point, size));
}
// Tick statistics
if (isTickDataFile)
{
g.DrawString(Language.T("Tick"), fontInfo, brush, (xp1 + xp0) / 2, 2 * infoRowHeight, sf);
if (Data.IsTickData && Configs.UseTickData)
{
int firstBarWithTicks = -1;
int lastBarWithTicks = -1;
int tickBars = 0;
for (int b = 0; b < Data.Bars; b++)
{
if (firstBarWithTicks == -1 && Data.TickData[b] != null)
firstBarWithTicks = b;
if (Data.TickData[b] != null)
{
lastBarWithTicks = b;
tickBars++;
}
}
double percentage = 100d * tickBars / Data.Bars;
int y = 2 * infoRowHeight;
string ticks = (Data.Ticks > 999999) ? (Data.Ticks / 1000).ToString() + "K" : Data.Ticks.ToString();
g.DrawString(ticks, fontInfo, brush, (xp2 + xp1) / 2, y, sf);
g.DrawString((firstBarWithTicks + 1).ToString(), fontInfo, brush, (xp3 + xp2) / 2, y, sf);
g.DrawString((lastBarWithTicks + 1).ToString(), fontInfo, brush, (xp4 + xp3) / 2, y, sf);
g.DrawString(tickBars.ToString(), fontInfo, brush, (xp5 + xp4) / 2, y, sf);
g.DrawString(percentage.ToString("F2"), fontInfo, brush, (xp6 + xp5) / 2, y, sf);
RectangleF rectf = new RectangleF(xp6 + 10, y + 4, xp7 - xp6 - 20, 9);
Data.GradientPaint(g, rectf, Data.PeriodColor[DataPeriods.min1], 60);
rectf = new RectangleF(xp6 + 10, y + 7, xp7 - xp6 - 20, 3);
Data.GradientPaint(g, rectf, Data.PeriodColor[DataPeriods.day], 60);
}
}
for (int iPeriod = 0; iPeriod < allPeriods; iPeriod++)
{
int startY = isTickDataFile ? 3 : 2;
int y = (iPeriod + startY) * infoRowHeight;
Point point = new Point(xp0, y);
DataPeriods period = (DataPeriods)Enum.GetValues(typeof(DataPeriods)).GetValue(iPeriod);
int intraBars = Data.IntraBars == null || !Data.IsIntrabarData ? 0 : Data.IntraBars[iPeriod];
int fromBar = 0;
int untilBar = 0;
int coveredBars = 0;
double percentage = 0;
bool isMultyAreas = false;
if (intraBars > 0)
{
bool isFromBarFound = false;
bool isUntilBarFound = false;
untilBar = Data.Bars;
for (int bar = 0; bar < Data.Bars; bar++)
{
if (!isFromBarFound && Data.IntraBarsPeriods[bar] == period)
{
fromBar = bar;
isFromBarFound = true;
}
if (isFromBarFound && !isUntilBarFound &&
(Data.IntraBarsPeriods[bar] != period || bar == Data.Bars - 1))
{
if (bar < Data.Bars - 1)
{
isUntilBarFound = true;
untilBar = bar;
}
else
{
untilBar = Data.Bars;
}
coveredBars = untilBar - fromBar;
}
if (isFromBarFound && isUntilBarFound && Data.IntraBarsPeriods[bar] == period)
{
isMultyAreas = true;
coveredBars++;
}
}
if (isFromBarFound)
{
percentage = 100d * coveredBars / Data.Bars;
fromBar++;
}
else
{
fromBar = 0;
untilBar = 0;
coveredBars = 0;
percentage = 0;
}
}
else if (period == Data.Period)
{
intraBars = Data.Bars;
fromBar = 1;
untilBar = Data.Bars;
coveredBars = Data.Bars;
percentage = 100;
}
g.DrawString(Data.DataPeriodToString(period), fontInfo, brush, (xp1 + xp0) / 2, y, sf);
if (coveredBars > 0 || period == Data.Period)
{
g.DrawString(intraBars.ToString(), fontInfo, brush, (xp2 + xp1) / 2, y, sf);
g.DrawString(fromBar.ToString(), fontInfo, brush, (xp3 + xp2) / 2, y, sf);
g.DrawString(untilBar.ToString(), fontInfo, brush, (xp4 + xp3) / 2, y, sf);
g.DrawString(coveredBars.ToString() + (isMultyAreas ? "*" : ""), fontInfo, brush, (xp5 + xp4) / 2, y, sf);
g.DrawString(percentage.ToString("F2"), fontInfo, brush, (xp6 + xp5) / 2, y, sf);
RectangleF rectf = new RectangleF(xp6 + 10, y + 4, xp7 - xp6 - 20, 9);
Data.GradientPaint(g, rectf, Data.PeriodColor[period], 60);
}
}
Pen penLine = new Pen(LayoutColors.ColorJournalLines);
g.DrawLine(penLine, xp1, 2 * infoRowHeight, xp1, pnl.ClientSize.Height);
g.DrawLine(penLine, xp2, 2 * infoRowHeight, xp2, pnl.ClientSize.Height);
g.DrawLine(penLine, xp3, 2 * infoRowHeight, xp3, pnl.ClientSize.Height);
g.DrawLine(penLine, xp4, 2 * infoRowHeight, xp4, pnl.ClientSize.Height);
g.DrawLine(penLine, xp5, 2 * infoRowHeight, xp5, pnl.ClientSize.Height);
g.DrawLine(penLine, xp6, 2 * infoRowHeight, xp6, pnl.ClientSize.Height);
// 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;
}