Exemple #1
0
        private void OnHotKeyPush(object sender, EventArgs e)
        {
            timer.Enabled = false;
            WindowModel.ClearRect();

            var mouse = new MouseModel();
            int x     = mouse.Position.X;
            int y     = mouse.Position.Y;

            // Capture window where cursor points
            WindowModel w   = WindowModel.FindByPosition(x, y);
            Bitmap      bmp = w.CaptureWindow();

            // Send capture image to server
            using (var stream = new MemoryStream())
            {
                // Make http content object from capture image
                bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
                stream.Position = 0;
                HttpContent content = new StreamContent(stream);

                using (var client = new HttpClient())
                    using (var formData = new MultipartFormDataContent())
                    {
                        formData.Add(content, "screenshot", "screenshot.png");
                        formData.Add(new StringContent(w.WindowTitle), "title");

                        var response = client.PostAsync(this.CaptureUploadUrl, formData).Result;
                        if (!response.IsSuccessStatusCode)
                        {
                            throw new Exception("Sending captured image failed");
                        }
                    }
            }

            Finish();
        }
Exemple #2
0
 public void Dispose()
 {
     WindowModel.ClearRect();
     hotKey.Dispose();
     timer.Enabled = false;
 }