1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
public ChartWindow() //ça c'est le form
{
InitializeComponent();
this.SetStyle(ControlStyles.ResizeRedraw | ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint | ControlStyles.DoubleBuffer,true);
}
private void panel1_Paint(Object sender, PaintEventArgs e) //ça c'est le
{
Pen pn = new Pen(Color.Blue, axeSize);
Point Origin = new Point(this.panel1.Left, this.panel1.Top);
Graphics g = e.Graphics;
g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
/*Bitmap drawing = null;
drawing = new Bitmap(this.panel1.Width, this.panel1.Height, e.Graphics);
Graphics g = Graphics.FromImage(drawing);*/
//g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
/*****Méthodes permettant de tracer le graphique *****/
_charts[0].setSize(this.panel1.Width-1, this.panel1.Height-1);
_charts[0].setChartArea(this.panel1.Region);
drawChart(_charts[0], g);
/*******************************************/
/*if (forceRedraw)
{
Bitmap bitmapTemp = new Bitmap(this.ClientSize.Width,
this.ClientSize.Height);
using (Graphics g2 = Graphics.FromImage(bitmapTemp))
{
drawChart(_charts[0], g2, this.panel1.Width-1, this.panel1.Height-1);
forceRedraw = false;
}
e.Graphics.DrawImage(bitmapTemp, 0,0);
bitmapTemp.Dispose();
bitmapTemp = null;
}
g.Clear(this.BackColor);
forceRedraw = false;*/
if (bIsZoomActive) //variable permettant de savoir si l'on est entrain de tracer le fameux rectangle
{
int xmin, ymin, xmax, ymax;
if (mouseDownPosition.X < mousePosition.X)
{
// variables globales instanciées dans les mouse events
xmin = mouseDownPosition.X;
xmax = mousePosition.X;
}
else
{
xmin = mousePosition.X;
xmax = mouseDownPosition.X;
}
if (mouseDownPosition.Y < mousePosition.Y)
{
ymin = mouseDownPosition.Y;
ymax = mousePosition.Y;
}
else
{
ymin = mousePosition.Y;
ymax = mouseDownPosition.Y;
}
g.DrawRectangle(pn, xmin, ymin, xmax-xmin, ymax-ymin);
}
/*e.Graphics.DrawImageUnscaled(drawing, 0, 0);
g.Dispose();*/
} |
Partager