Exemple #1
0
        private void screenshotUpload()
        {
            if (!isConnected)
            {
                return;
            }

            try
            {
                string subPath = "\\Screenshots\\" + DateTime.Now.ToString("dd-MM-yyyy");
                if (!Directory.Exists(Application.StartupPath + subPath))
                {
                    Directory.CreateDirectory(Application.StartupPath + subPath);
                }

                string fileName = Application.StartupPath + subPath + "\\Jtag_" + RandomString(10);
                string bmpPath  = fileName + ".bmp";
                xbox.ScreenShot(bmpPath);

                string pngPath = fileName + ".png";
                Bitmap bmp     = new Bitmap(bmpPath);
                ImageExtensions.SavePng(bmp, pngPath, 85L);

                using (var w = new WebClient())
                {
                    string clientIdPath1 = Application.StartupPath + "\\Tools\\imgur_clientid.txt";
                    string clientID      = File.ReadAllText(clientIdPath1);
                    w.Headers.Add("Authorization", "Client-ID " + clientID);
                    var values = new NameValueCollection
                    {
                        {
                            "image", Convert.ToBase64String(File.ReadAllBytes(@pngPath))
                        }
                    };

                    byte[] response = w.UploadValues("https://api.imgur.com/3/upload.xml", values);

                    string res   = XDocument.Load(new MemoryStream(response)).ToString();
                    var    xdoc  = XDocument.Load(new StringReader(res));
                    var    imgur = xdoc.Descendants("data").Select(x => new {
                        Link = x.Element("link").Value,
                    }).FirstOrDefault();

                    MessageBox.Show(imgur.Link + " has been copied to your clipboard!");
                    Clipboard.SetText(imgur.Link);

                    //MessageBox.Show(XDocument.Load(new MemoryStream(response)).ToString()); testing
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Exemple #2
0
 public static void MakeScreenshot(string filename)
 {
     jtag.ScreenShot(filename);
 }