I am making an application in C # using Windows Form and I use an UserControl to draw a 3D graph. I use the Paint method to call the routines that draw the graph. First I call a routine that creates several GraphicsPath with the points the graph, then I call a routine that fills these GraphicsPath with differents tones giving the impression of 3D.
But when I minimize the application the areas that were filled loose fill and when I minimize again the fill back . How do I not miss the fill of graph each new called the Paint method. Below I put a part of my code if anyone can help me I thank you.
Paint method of the UserControl
private void wucGraficoBarras3D_Paint(object sender, PaintEventArgs e)
{
oCriarGrafico.OGrafico = e.Graphics;
oCriarGrafico.CriarCaminhosEstrutura();
oCriarGrafico.PreencherEstrutura();
}
Method that creates GraphicsPath with points
public void CriarCaminhosEstrutura()
{
PointF[] pontosBaseS = {new PointF(0.00f, 0.00f), new PointF(14.14f, -14.14f),
new PointF(294.14f, -14.14f), new PointF(280.00f, 0.00f)};
GraphicsPath caminhoBaseF = new GraphicsPath();
oGrafico.TranslateTransform(origemX, origemY);
caminhoBaseF.AddLines(pontosBaseF);
caminhoBaseF.CloseFigure();
}
Method that fills the GraphicsPath with various shades
public void PreencherEstrutura()
{
mistura.Factors = fatoresBlend;
mistura.Positions = posicoesBlend;
pontoInicialEstruturaBlend = new PointF(0.00f, 4.00f);
pontoFinalEstruturaBlend = new PointF(280.00f, 4.00f);
corEstrutura1 = Color.FromArgb(255, Color.DarkGray);
corEstrutura2 = Color.FromArgb(255, Color.Gray);
LinearGradientBrush escovaEstrutura = new LinearGradientBrush(pontoInicialEstruturaBlend,
pontoFinalEstruturaBlend, corEstrutura1, corEstrutura2);
escovaEstrutura.Blend = mistura;
oGrafico.FillPath(escovaEstrutura, caminhoBaseF);
}