Good evening,
People would like a help, with a doubt, well I'm developing an application, in which the user chooses 5 dates of any useful days of the month, and generates a differentiated chart with the quote of each day, right, that graph (Triangles and Lines) is done from the Paint Event, which has an if that only expects a true value for a bool to do the forms, when the user chooses the dates and clicks the "Generate" button was for the panel I have tried to set the visible line to be within the if line, but I want to set the visible line inside the if paint did not work either. If anyone knows why this happens, and show me how to fix thank you
Print: link
private void btGerarGraficos_Click(object sender, EventArgs e)
{
listaPETR3 = acessar.carregarPregoes(cbData1.Text, cbData2.Text, cbData3.Text, cbData4.Text, cbData5.Text, "PETR3");
listaPETR4 = acessar.carregarPregoes(cbData1.Text, cbData2.Text, cbData3.Text, cbData4.Text, cbData5.Text, "PETR4");
GerarGraficosCandles();
CriarPontosTriangulos();
pnlConfigurarDatas.Visible = false;
if (checkPETR3.Checked)
{
drawPETR3Banco = true;
}
if (checkPETR4.Checked)
{
drawPETR4Banco = true;
}
}
private void chartPETR4_Paint_Banco(object sender, PaintEventArgs e)
{
if (drawPETR4Banco)
{
double posiX, open, close, max, min;
for (int i = 0; i < 5; i++)
{
i++;
posiX = chartPETR4.ChartAreas["areaTriangulo4"].AxisX.ValueToPixelPosition(i);
i--;
open = chartPETR4.ChartAreas["areaTriangulo4"].AxisY.ValueToPixelPosition(listaPETR4[i].Abertura);
close = chartPETR4.ChartAreas["areaTriangulo4"].AxisY.ValueToPixelPosition(listaPETR4[i].Fechamento);
max = chartPETR4.ChartAreas["areaTriangulo4"].AxisY.ValueToPixelPosition(listaPETR4[i].Maximo);
min = chartPETR4.ChartAreas["areaTriangulo4"].AxisY.ValueToPixelPosition(listaPETR4[i].Minimo);
if (listaPETR4[i].Abertura < listaPETR4[i].Fechamento)
{
Point[] posicoes = {
new Point(Convert.ToInt32(posiX) - 20, Convert.ToInt32(open)),
new Point(Convert.ToInt32(posiX) + 20, Convert.ToInt32(open)),
new Point(Convert.ToInt32(posiX) + 20, Convert.ToInt32(close))
};
e.Graphics.DrawLine(p, Convert.ToInt32(posiX), Convert.ToInt32(min), Convert.ToInt32(posiX), Convert.ToInt32(max));
e.Graphics.FillPolygon(bVerde, posicoes);
}
else if (listaPETR4[i].Abertura > listaPETR4[i].Fechamento)
{
Point[] posicoes = {
new Point(Convert.ToInt32(posiX) + 20, Convert.ToInt32(close)),
new Point(Convert.ToInt32(posiX) - 20, Convert.ToInt32(open)),
new Point(Convert.ToInt32(posiX) - 20, Convert.ToInt32(close))
};
e.Graphics.DrawLine(p, Convert.ToInt32(posiX), Convert.ToInt32(min), Convert.ToInt32(posiX), Convert.ToInt32(max));
e.Graphics.FillPolygon(bVermelho, posicoes);
}
}
chartPETR4.Invalidate(true);
}
}