public void Start(string Filename, long Filesize, bool DisplaySpeed) { this.reset(); if (Filesize == 0) { return; } if (!appSettings.GetBool("ProgressBar")) { return; } this.Form = new FormProgressBar(appSettings); this.Form.FormClosing += new FormClosingEventHandler(cancelUpload); new Thread(new ThreadStart(delegate { this.filename = Filename; this.filesize = (int)Filesize; //TODO: Handle Filesize > int.MaxValue this.showSpeed = DisplaySpeed; this.updateStatus(0); Application.Run(this.Form); })).Start(); }
private void reset() { if (this.Form != null && !this.Form.IsDisposed) { this.Form.Close(); } this.Form = null; this.filename = ""; this.filesize = 0; this.lastLocation = 0; this.speedTimer = new Stopwatch(); this.speedTimer.Start(); this.done = false; this.Canceled = false; }
/// <summary> /// Shows a progressbar window. /// </summary> /// <param name="Filename">The filename</param> /// <param name="Filesize">The filesize</param> /// <param name="DisplaySpeed">Whether or not to display the speed</param> public void Start(string Filename, long Filesize, bool DisplaySpeed) { Addon.SetShortcuts(false); this.reset(); if (Filesize == 0) return; if (!appSettings.GetBool("ProgressBar")) { return; } this.Form = new FormProgressBar(appSettings); this.Form.FormClosing += new FormClosingEventHandler(cancelUpload); new Thread(new ThreadStart(delegate { this.filename = Filename; this.filesize = (int)Filesize; //TODO: Handle Filesize > int.MaxValue this.showSpeed = DisplaySpeed; this.updateStatus(0); Application.Run(this.Form); })).Start(); }
/// <summary> /// Takes a screenshot on the device via adb, then pulls the screenshot to a temporary file and returns the filename to it. /// </summary> /// <param name="strDevice">The device serial number to use.</param> /// <returns>Path to a temporary png file of the screenshot.</returns> public static string PullScreenshot(string strDevice) { if (!AllOK()) { return ""; } FormProgressBar pb = new FormProgressBar(null); pb.Text = "Taking Android screenshot..."; pb.progressBar.Value = 0; pb.Show(); string strAndroidPath = TempPath + "ClipuploadScreenshot.png"; Process.Start(new ProcessStartInfo("adb.exe", "-s " + strDevice + " shell screencap -p \"" + strAndroidPath + "\"") { UseShellExecute = false, CreateNoWindow = true }).WaitForExit(); pb.progressBar.Value = 51; pb.progressBar.Value = 50; Application.DoEvents(); string strTempFile = Path.GetTempFileName() + "_ClipuploadScreenshot.png"; Process.Start(new ProcessStartInfo("adb.exe", "-s " + strDevice + " pull \"" + strAndroidPath + "\" \"" + strTempFile + "\"") { UseShellExecute = false, CreateNoWindow = true }).WaitForExit(); pb.Close(); return strTempFile; }
/// <summary> /// Pull the last recorded video capture mp4 from the device to a temporary file and returns the filename to it. /// </summary> /// <returns>Path to a temporary mp4 file of the video.</returns> public static string PullRecording(string strDevice) { if (adbRecording != null) { throw new Exception("Still recording."); } // have to wait for half a second to make sure the device has properly closed the file Thread.Sleep(500); FormProgressBar pb = new FormProgressBar(null); pb.Text = "Pulling Android video..."; pb.progressBar.Value = 0; pb.Show(); string strAndroidPath = TempPath + "ClipuploadVideo.mp4"; string strTempFile = Path.GetTempFileName() + "_ClipuploadVideo.mp4"; Process.Start(new ProcessStartInfo("adb.exe", "-s " + strDevice + " pull \"" + strAndroidPath + "\" \"" + strTempFile + "\"") { UseShellExecute = false, CreateNoWindow = true }).WaitForExit(); pb.Close(); return strTempFile; }