من کد زیر رو گیر اوردم برای شات گرفتن از صفحه سایت ولی نمیدونم برای ایچاد وقفه در عکس گرفتنم به کدام قسمتش باید برم کد وقفه رو بزنم من میخوام صفحه به صورت کامل لود شه سپس شات بگیره خودش به صورت پیش فرض 2 ثاتنیس فکر کنم ممنون میشم کمکم کنید
public ActionResult Save()
{
var url = "http://www.mehryabi.com";
FileContentResult result = null;
Bitmap bitmap = null;
var thread = new Thread(
() =>
{
bitmap = ExportUrlToImage(url, 1280, 1024);
});
thread.SetApartmentState(ApartmentState.STA); //Set the thread to STA
thread.Start();
thread.Join();
if (bitmap != null)
{
using (var memstream = new MemoryStream())
{
bitmap.Save(memstream, ImageFormat.Jpeg);
result = this.File(memstream.GetBuffer(), "image/jpeg");
}
//string f = "/images/links/";
//var rnd = Guid.NewGuid() + ".png";
//var path = Path.Combine(Server.MapPath("~") + f + rnd);
//bitmap.Save(path , ImageFormat.Png);
}
return result;
}
private Bitmap ExportUrlToImage(string url, int width, int height)
{
// Load the webpage into a WebBrowser control
WebBrowser wb = new WebBrowser();
wb.ScrollBarsEnabled = true;
wb.AllowNavigation = true;
wb.Width = 1024;
wb.Height = 768;
wb.Navigate(url);
while (wb.ReadyState != WebBrowserReadyState.Complete)
{
Application.DoEvents();
}
// Set the size of the WebBrowser control
wb.Width = width;
wb.Height = height;
Bitmap bitmap = new Bitmap(wb.Width, wb.Height);
wb.DrawToBitmap(bitmap, new System.Drawing.Rectangle(0, 0, wb.Width, wb.Height));
wb.Dispose();
return bitmap;
}