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
| private void BtCaptureEcran_Click(object sender, EventArgs e)
{
Bitmap b = new Bitmap(SystemInformation.VirtualScreen.Width, SystemInformation.VirtualScreen.Height);
Graphics g = Graphics.FromImage(b);
g.CopyFromScreen(0, 0, 0, 0, b.Size);
g.Dispose();
b.MakeTransparent();
Screen = b;
b.Save("Image ", ImageFormat.Jpeg);
//Enregistrement de la capture sur le bureau
try
{
String DirectorySaveTested = DirectorySaveCapture;
while (System.IO.Directory.Exists(DirectorySaveTested))
{
DirectorySaveTested = DirectorySaveCapture + cpt;
cpt++;
}
System.IO.Directory.CreateDirectory(DirectorySaveTested);
FileSave = Path.Combine(DirectorySaveTested, "Image.jpg");
b.Save(FileSave);
this.TemoinCaptureEcran.BackColor = System.Drawing.Color.Green;
}
catch (Exception ex)
{
MessageBox.Show("L'accès à l'ecriture sur le bureau est impossible.", ex.GetType().ToString());
}
finally
{
this.BtCaptureEcran.Enabled = false;
this.TemoinCaptureEcran.BackColor = System.Drawing.Color.Red;
}
} |
Partager