I have panel and various controls on it. I would like to save an image of this panel into a file, how can I do this ?
Ineed to do something like screenshot, but I need just image of certain panel in my application and I want to do this on a button click in my app.
Best regards, Primoz
EDIT: I also draw on this panel using this code
Graphics g = chartTemperature.CreateGraphics();
g.DrawLine(p, prevPoint, e.Location);
prevPoint = e.Location;
But then I don't get this into image. Why, and how to fix this ?
EDIT 2:
namespace Grafi
{
public partial class Form1 : Form
{
bool isDrawing = false;
Point prevPoint;
public Form1()
{
InitializeComponent();
}
private void chartTemperature_MouseDown(object sender, MouseEventArgs e)
{
isDrawing = true;
prevPoint = e.Location;
}
private void chartTemperature_MouseMove(object sender, MouseEventArgs e)
{
Pen p = new Pen(Color.Red, 2);
if (isDrawing)
{
Graphics g = chartTemperature.CreateGraphics();
g.DrawLine(p, prevPoint, e.Location);
prevPoint = e.Location;
numOfMouseEvents = 0;
}
p.Dispose();
}
private void chartTemperature_MouseUp(object sender, MouseEventArgs e)
{
isDrawing = false;
}
}
}
This is my drawing code to draw a custom line onto a Chart. Can you please help me to do it proper way ?