API ASP.NET do GrabzIt também suporta eventos, abaixo está um exemplo de designação de um manipulador para o ScreenShotComplete
evento antes da captura de tela. Depois que a captura de tela for concluída, o código dentro do grabzIt_ScreenShotComplete
método é chamado.
private GrabzItClient grabzIt = GrabzItClient.Create("Sign in to view your Application Key", "Sign in to view your Application Secret")%>"); protected void btnSubmit_Click(object sender, EventArgs e) { grabzIt.ScreenShotComplete += grabzIt_ScreenShotComplete; grabzIt.URLToImage("https://www.tesla.com"); //The below line specifies the GrabzIt.ashx handler inside the GrabzIt.dll grabzIt.Save(HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + HttpContext.Current.Request.ApplicationPath + "GrabzIt.ashx"); } //The event method saves the screenshot protected void grabzIt_ScreenShotComplete(object sender, ScreenShotEventArgs result) { GrabzItFile file = grabzIt.GetResult(result.ID); file.Save(Server.MapPath("~/results/"+result.Filename)); }
Por fim, configure o web.config para que GrabzIt.ashx points para o treinador incorporado no GrabzIt DLL. Se isso não for feito corretamente, o ScreenShotComplete
evento não será acionado.
Lembre-se disso ligue de volta não funcionará se o seu aplicativo estiver localizado no host local.
<httpHandlers> <add verb="*" path="GrabzIt.ashx" type="GrabzIt.Handler, GrabzIt" /> </httpHandlers>