public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying UploadAction...", string.Format("UploadAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); if (LatestScreenshot == null) { Trace.WriteLine("Latest Screenshot is null, continuing...", string.Format("UploadAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); return(null); } var ActiveService = Configuration.UploadServices.FirstOrDefault(u => u.isActive); if (ActiveService == null) { Trace.WriteLine("No active upload service has been configured", string.Format("UploadAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); MessageBox.Show(Program.Preview, "You must configure an upload service before uploading any screenshots.", "Upload a screenshot", MessageBoxButtons.OK, MessageBoxIcon.Information); return(null); } ActiveService.UploadStarted += Program.Preview.UploadStarted; ActiveService.UploadProgress += Program.Preview.UploadProgress; ActiveService.UploadEnded += Program.Preview.UploadEnded; Task.WaitAll(ActiveService.Upload(LatestScreenshot).ContinueWith(t => { ActiveService.UploadStarted -= Program.Preview.UploadStarted; ActiveService.UploadProgress -= Program.Preview.UploadProgress; ActiveService.UploadEnded -= Program.Preview.UploadEnded; return(LatestScreenshot); })); return(LatestScreenshot); }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying DeleteAction...", string.Format("DeleteAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); if (LatestScreenshot == null) { Trace.WriteLine("Latest Screenshot is null, continuing...", string.Format("DeleteAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); return null; } Trace.WriteLine("Deleting current image...", string.Format("DeleteAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); var i = Program.History.IndexOf(LatestScreenshot); Program.History.Remove(LatestScreenshot); if (File.Exists(LatestScreenshot.InternalFileName)) File.Delete(LatestScreenshot.InternalFileName); if (Program.History.Count == 0) { Trace.WriteLine("This image was the last image, closing preview...", string.Format("DeleteAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); Program.Preview.FadeClose(); return null; } else { Trace.WriteLine("Previewing previous image...", string.Format("DeleteAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); i += i < Program.History.Count ? 0 : -1; Program.Preview.Show(Program.History[i]); return Program.History[i]; } }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying ApplyEditAction...", string.Format("ApplyEditAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); if (LatestScreenshot == null) { Trace.WriteLine("Latest Screenshot is null, continuing...", string.Format("ApplyEditAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); return null; } switch (this.DefaultBorderRounding) { case ApplyEditsAction.ApplicationMode.Automatic: LatestScreenshot.withBorderRounding = !LatestScreenshot.isMaximized && LatestScreenshot.isRounded && !(FMUtils.WinApi.Helper.OperatingSystem == FMUtils.WinApi.Helper.OperatingSystems.Win8); break; case ApplyEditsAction.ApplicationMode.On: LatestScreenshot.withBorderRounding = true; break; case ApplyEditsAction.ApplicationMode.Off: LatestScreenshot.withBorderRounding = false; break; } switch (this.DefaultBorderShadow) { case ApplyEditsAction.ApplicationMode.Automatic: LatestScreenshot.withBorderShadow = !LatestScreenshot.isMaximized; break; case ApplyEditsAction.ApplicationMode.On: LatestScreenshot.withBorderShadow = true; break; case ApplyEditsAction.ApplicationMode.Off: LatestScreenshot.withBorderShadow = false; break; } switch (this.ShowMouseCursor) { case ApplyEditsAction.ApplicationMode.Automatic: LatestScreenshot.withCursor = LatestScreenshot.CompositionRect.Contains(LatestScreenshot.CursorLocation); break; case ApplyEditsAction.ApplicationMode.On: LatestScreenshot.withCursor = true; break; case ApplyEditsAction.ApplicationMode.Off: LatestScreenshot.withCursor = false; break; } return LatestScreenshot; }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { if (Configuration.PreviewDelayTime != 0 && Program.History.Count > 0 && LatestScreenshot != null) Program.Preview.Show(LatestScreenshot); return LatestScreenshot; }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying UploadAction...", string.Format("UploadAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); if (LatestScreenshot == null) { Trace.WriteLine("Latest Screenshot is null, continuing...", string.Format("UploadAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); return null; } var ActiveService = Configuration.UploadServices.FirstOrDefault(u => u.isActive); if (ActiveService == null) { Trace.WriteLine("No active upload service has been configured", string.Format("UploadAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); MessageBox.Show(Program.Preview, "You must configure an upload service before uploading any screenshots.", "Upload a screenshot", MessageBoxButtons.OK, MessageBoxIcon.Information); return null; } ActiveService.UploadStarted += Program.Preview.UploadStarted; ActiveService.UploadProgress += Program.Preview.UploadProgress; ActiveService.UploadEnded += Program.Preview.UploadEnded; Task.WaitAll(ActiveService.Upload(LatestScreenshot).ContinueWith(t => { ActiveService.UploadStarted -= Program.Preview.UploadStarted; ActiveService.UploadProgress -= Program.Preview.UploadProgress; ActiveService.UploadEnded -= Program.Preview.UploadEnded; return LatestScreenshot; })); return LatestScreenshot; }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { if (Program.isTakingScrollingScreenshot) Program.timelapse.Add(new ExtendedScreenshot()); return LatestScreenshot; }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Program.isTakingScrollingScreenshot = true; Program.timelapse.Clear(); Program.timelapse.Add(new ExtendedScreenshot()); return LatestScreenshot; }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { if (Configuration.PreviewDelayTime != 0 && Program.History.Count > 0 && LatestScreenshot != null) { Program.Preview.Show(LatestScreenshot); } return(LatestScreenshot); }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Program.isTakingScrollingScreenshot = true; Program.timelapse.Clear(); Program.timelapse.Add(new ExtendedScreenshot()); return(LatestScreenshot); }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { if (Program.isTakingScrollingScreenshot) { Program.timelapse.Add(new ExtendedScreenshot()); } return(LatestScreenshot); }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying HidePreviewAction...", string.Format("Program.Program_ShowPreviewEvent [{0}]", System.Threading.Thread.CurrentThread.Name)); //todo: if LatestScreenshot == Preview Active Screenshot? Program.Preview.FadeClose(); return(LatestScreenshot); }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying HidePreviewAction...", string.Format("Program.Program_ShowPreviewEvent [{0}]", System.Threading.Thread.CurrentThread.Name)); //todo: if LatestScreenshot == Preview Active Screenshot? Program.Preview.FadeClose(); return LatestScreenshot; }
public override bool Upload(UploadService activeService, ExtendedScreenshot screenshot) { if (InProgress) return false; Trace.WriteLine("Starting upload process...", string.Format("FormsUploader.Upload [{0}]", System.Threading.Thread.CurrentThread.Name)); this.ActiveService = activeService; this.InProgress = true; OnUploadStarted(new EventArgs()); try { using (var wc = new WebClient()) { wc.UploadProgressChanged += UploadProgressChanged; wc.UploadValuesCompleted += UploadValuesCompleted; var bg = new BackgroundWorker(); bg.DoWork += (o, a) => { Trace.WriteLine("Starting stream conversion... ", string.Format("FormsUploader.Upload.DoWork [{0}]", System.Threading.Thread.CurrentThread.Name)); var ImageData = string.Empty; using (var ms = screenshot.EditedScreenshotPNGImageStream()) ImageData = Convert.ToBase64String(ms.ToArray()); var CurrentUploadValues = new NameValueCollection(); foreach (var k in activeService.UploadValues.AllKeys.ToList()) CurrentUploadValues.Add(k, activeService.UploadValues[k].Replace("%i", ImageData)); Trace.WriteLine("Stream conversion complete.", string.Format("FormsUploader.Upload.DoWork [{0}]", System.Threading.Thread.CurrentThread.Name)); Trace.WriteLine("Starting async upload...", string.Format("FormsUploader.Upload.DoWork [{0}]", System.Threading.Thread.CurrentThread.Name)); wc.UploadValuesAsync(new Uri(activeService.EndpointUrl), CurrentUploadValues); Trace.WriteLine("Upload start complete.", string.Format("FormsUploader.Upload.DoWork [{0}]", System.Threading.Thread.CurrentThread.Name)); }; bg.RunWorkerAsync(); } return true; } catch (Exception ex) { Trace.WriteLine(string.Format("Exception occurred during upload: {0}", ex.GetBaseException()), string.Format("FormsUploader.Upload [{0}]", System.Threading.Thread.CurrentThread.Name)); InProgress = false; OnUploadEnded(new UploaderEndedEventArgs(ex.GetBaseException())); return false; } }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying ClipboardAction...", string.Format("ClipboardAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); if (LatestScreenshot == null) { Trace.WriteLine("Latest Screenshot is null, continuing...", string.Format("ClipboardAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); return(null); } var set = new Action(() => { switch (this.ClipboardMode) { case Modes.Copy: if (this.Content == ":image") { Clipboard.SetImage(LatestScreenshot.ComposedScreenshotImage); } else if (!string.IsNullOrEmpty(this.Content)) { var text = Helper.ExpandParameters(this.Content, LatestScreenshot); if (!string.IsNullOrEmpty(text)) { Clipboard.SetText(text, TextDataFormat.UnicodeText); } } break; } }); if (Program.Preview.InvokeRequired) { var tcs = new TaskCompletionSource <object>(); Program.Preview.BeginInvoke(new MethodInvoker(() => { set(); tcs.SetResult(null); })); Task.WaitAll(tcs.Task); } else { set(); } return(LatestScreenshot); }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying ClipboardAction...", string.Format("ClipboardAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); if (LatestScreenshot == null) { Trace.WriteLine("Latest Screenshot is null, continuing...", string.Format("ClipboardAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); return null; } var set = new Action(() => { switch (this.ClipboardMode) { case Modes.Copy: if (this.Content == ":image") { Clipboard.SetImage(LatestScreenshot.ComposedScreenshotImage); } else if (!string.IsNullOrEmpty(this.Content)) { var text = Helper.ExpandParameters(this.Content, LatestScreenshot); if (!string.IsNullOrEmpty(text)) { Clipboard.SetText(text, TextDataFormat.UnicodeText); } } break; } }); if (Program.Preview.InvokeRequired) { var tcs = new TaskCompletionSource<object>(); Program.Preview.BeginInvoke(new MethodInvoker(() => { set(); tcs.SetResult(null); })); Task.WaitAll(tcs.Task); } else { set(); } return LatestScreenshot; }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { if (!this.UseRegionSelector) { if (this.Region.IsEmpty) { return(LatestScreenshot); } LatestScreenshot = new ExtendedScreenshot(this.Region); Program.History.Add(LatestScreenshot); return(LatestScreenshot); } Trace.WriteLine("Opening region selector...", string.Format("TakeRegionScreenshotAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); var t = new TaskCompletionSource <object>(); var fceh = new FormClosingEventHandler((s, e) => { Trace.WriteLine("Closed region selector.", string.Format("TakeRegionScreenshotAction.Invoke.FormClosed [{0}]", System.Threading.Thread.CurrentThread.Name)); Program.Selector.Hide(); e.Cancel = true; if (Program.Selector.DialogResult == DialogResult.OK && !Program.Selector.SnapshotRectangle.IsEmpty) { LatestScreenshot = new ExtendedScreenshot(Program.Selector.SnapshotRectangle); Program.History.Add(LatestScreenshot); Program.Preview.GroomBackForwardIcons(); } t.SetResult(null); }); Program.Selector.FormClosing += fceh; Program.Selector.BeginInvoke(new MethodInvoker(() => Program.Selector.Show())); Task.WaitAll(t.Task); Program.Selector.FormClosing -= fceh; return(LatestScreenshot); }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { try { LatestScreenshot = new ExtendedScreenshot(this.Method, this.SolidGlass); Program.History.Add(LatestScreenshot); Program.Preview.GroomBackForwardIcons(); } catch (Exception e) { Trace.WriteLine(string.Format("Exception in TakeForegroundScreenshot: {0}", e.GetBaseException()), string.Format("Program.DoActionItem [{0}]", System.Threading.Thread.CurrentThread.Name)); ReportListener reporter = Trace.Listeners.Cast<TraceListener>().Where(tl => tl is ReportListener).FirstOrDefault() as ReportListener; File.WriteAllText(Path.Combine(Configuration.LocalPath, "report.txt"), string.Join("\n", reporter.Messages.Select(m => string.Format("{0} {1}: {2}", m.Timestamp, m.Category, m.Message)).ToArray())); } return LatestScreenshot; }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { try { LatestScreenshot = new ExtendedScreenshot(this.Method, this.SolidGlass); Program.History.Add(LatestScreenshot); Program.Preview.GroomBackForwardIcons(); } catch (Exception e) { Trace.WriteLine(string.Format("Exception in TakeForegroundScreenshot: {0}", e.GetBaseException()), string.Format("Program.DoActionItem [{0}]", System.Threading.Thread.CurrentThread.Name)); ReportListener reporter = Trace.Listeners.Cast <TraceListener>().Where(tl => tl is ReportListener).FirstOrDefault() as ReportListener; File.WriteAllText(Path.Combine(Configuration.LocalPath, "report.txt"), string.Join("\n", reporter.Messages.Select(m => string.Format("{0} {1}: {2}", m.Timestamp, m.Category, m.Message)).ToArray())); } return(LatestScreenshot); }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { if (!this.UseRegionSelector) { if (this.Region.IsEmpty) return LatestScreenshot; LatestScreenshot = new ExtendedScreenshot(this.Region); Program.History.Add(LatestScreenshot); return LatestScreenshot; } Trace.WriteLine("Opening region selector...", string.Format("TakeRegionScreenshotAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); var t = new TaskCompletionSource<object>(); var fceh = new FormClosingEventHandler((s, e) => { Trace.WriteLine("Closed region selector.", string.Format("TakeRegionScreenshotAction.Invoke.FormClosed [{0}]", System.Threading.Thread.CurrentThread.Name)); Program.Selector.Hide(); e.Cancel = true; if (Program.Selector.DialogResult == DialogResult.OK && !Program.Selector.SnapshotRectangle.IsEmpty) { LatestScreenshot = new ExtendedScreenshot(Program.Selector.SnapshotRectangle); Program.History.Add(LatestScreenshot); Program.Preview.GroomBackForwardIcons(); } t.SetResult(null); }); Program.Selector.FormClosing += fceh; Program.Selector.BeginInvoke(new MethodInvoker(() => Program.Selector.Show())); Task.WaitAll(t.Task); Program.Selector.FormClosing -= fceh; return LatestScreenshot; }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying RunAction...", string.Format("RunAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); if (LatestScreenshot == null) { Trace.WriteLine("Latest Screenshot is null, continuing...", string.Format("RunAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); return(null); } if (!File.Exists(LatestScreenshot.InternalFileName)) { Directory.CreateDirectory(Path.GetDirectoryName(LatestScreenshot.InternalFileName)); LatestScreenshot.ComposedScreenshotImage.Save(LatestScreenshot.InternalFileName, ImageFormat.Png); } var parameters = Helper.ExpandParameters(this.Parameters, LatestScreenshot); var working = Environment.ExpandEnvironmentVariables(Helper.ExpandParameters(this.WorkingDirectory, LatestScreenshot)); switch (this.Mode) { case RunAction.Modes.ShellVerb: { Windowing.ShellExecute(IntPtr.Zero, this.ShellVerb, LatestScreenshot.InternalFileName, parameters, working, Windowing.ShowCommands.SW_NORMAL); } break; case RunAction.Modes.FilePath: { var psi = new ProcessStartInfo(Environment.ExpandEnvironmentVariables(Helper.ExpandParameters(this.ApplicationPath, LatestScreenshot)), parameters) { UseShellExecute = false, WorkingDirectory = working, CreateNoWindow = this.HideCommandPrompt, }; Process.Start(psi); } break; } return(LatestScreenshot); }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying HeartAction...", string.Format("HeartAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); if (LatestScreenshot == null) { Trace.WriteLine("Latest Screenshot is null, continuing...", string.Format("DeleteAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); return null; } switch (this.HeartMode) { case HeartAction.Modes.Toggle: LatestScreenshot.isFlagged = !LatestScreenshot.isFlagged; break; case HeartAction.Modes.On: LatestScreenshot.isFlagged = true; break; case HeartAction.Modes.Off: LatestScreenshot.isFlagged = false; break; } Program.Preview.GroomHeartIcon(); return LatestScreenshot; }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying ApplyEditAction...", string.Format("ApplyEditAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); if (LatestScreenshot == null) { Trace.WriteLine("Latest Screenshot is null, continuing...", string.Format("ApplyEditAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); return(null); } switch (this.DefaultBorderRounding) { case ApplyEditsAction.ApplicationMode.Automatic: LatestScreenshot.withBorderRounding = !LatestScreenshot.isMaximized && LatestScreenshot.isRounded && !(FMUtils.WinApi.Helper.OperatingSystem == FMUtils.WinApi.Helper.OperatingSystems.Win8); break; case ApplyEditsAction.ApplicationMode.On: LatestScreenshot.withBorderRounding = true; break; case ApplyEditsAction.ApplicationMode.Off: LatestScreenshot.withBorderRounding = false; break; } switch (this.DefaultBorderShadow) { case ApplyEditsAction.ApplicationMode.Automatic: LatestScreenshot.withBorderShadow = !LatestScreenshot.isMaximized; break; case ApplyEditsAction.ApplicationMode.On: LatestScreenshot.withBorderShadow = true; break; case ApplyEditsAction.ApplicationMode.Off: LatestScreenshot.withBorderShadow = false; break; } switch (this.ShowMouseCursor) { case ApplyEditsAction.ApplicationMode.Automatic: LatestScreenshot.withCursor = LatestScreenshot.CompositionRect.Contains(LatestScreenshot.CursorLocation); break; case ApplyEditsAction.ApplicationMode.On: LatestScreenshot.withCursor = true; break; case ApplyEditsAction.ApplicationMode.Off: LatestScreenshot.withCursor = false; break; } return(LatestScreenshot); }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying HeartAction...", string.Format("HeartAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); if (LatestScreenshot == null) { Trace.WriteLine("Latest Screenshot is null, continuing...", string.Format("DeleteAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); return(null); } switch (this.HeartMode) { case HeartAction.Modes.Toggle: LatestScreenshot.isFlagged = !LatestScreenshot.isFlagged; break; case HeartAction.Modes.On: LatestScreenshot.isFlagged = true; break; case HeartAction.Modes.Off: LatestScreenshot.isFlagged = false; break; } Program.Preview.GroomHeartIcon(); return(LatestScreenshot); }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying DeleteAction...", string.Format("DeleteAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); if (LatestScreenshot == null) { Trace.WriteLine("Latest Screenshot is null, continuing...", string.Format("DeleteAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); return(null); } Trace.WriteLine("Deleting current image...", string.Format("DeleteAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); var i = Program.History.IndexOf(LatestScreenshot); Program.History.Remove(LatestScreenshot); if (File.Exists(LatestScreenshot.InternalFileName)) { File.Delete(LatestScreenshot.InternalFileName); } if (Program.History.Count == 0) { Trace.WriteLine("This image was the last image, closing preview...", string.Format("DeleteAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); Program.Preview.FadeClose(); return(null); } else { Trace.WriteLine("Previewing previous image...", string.Format("DeleteAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); i += i < Program.History.Count ? 0 : -1; Program.Preview.Show(Program.History[i]); return(Program.History[i]); } }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { if (!Program.isTakingScrollingScreenshot) return null; Program.isTakingScrollingScreenshot = false; Bitmap final = null; Bitmap b = new Bitmap(Program.timelapse.First().BaseScreenshotImage.Width, Program.timelapse.First().BaseScreenshotImage.Height * Program.timelapse.Count); Graphics g = Graphics.FromImage(b); int yoffset = 0; int working_height = 0; int ignore_header = 100; int ignore_footer = 10; var offsets = new Dictionary<int, int>(); //foreach (var ss in timelapse) for (int c = 0; c < Program.timelapse.Count; c++) { var debug = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), @"prosnap-debug"); if (Directory.Exists(debug)) { Program.timelapse[c].BaseScreenshotImage.Save(Path.Combine(debug, @"ss-" + c + ".png"), ImageFormat.Png); } if (c == 0) { g.DrawImageUnscaled(Program.timelapse[c].BaseScreenshotImage, new Point(0, 0)); working_height = Program.timelapse[c].BaseScreenshotImage.Height; offsets.Add(c, Program.timelapse[c].BaseScreenshotImage.Height); } else { int old_yoffset = yoffset; yoffset = GetYOffset(Program.timelapse[c - 1].BaseScreenshotImage, Program.timelapse[c].BaseScreenshotImage, ignore_header, ignore_footer, old_yoffset, working_height, c); offsets.Add(c, yoffset); int sum = 0; if (offsets.Count > 0) for (int k = offsets.First().Key; k <= offsets.Last().Key; k++) sum += offsets[k]; working_height = sum; g.DrawImage(Program.timelapse[c].BaseScreenshotImage, new RectangleF(0, working_height - (Program.timelapse[c].BaseScreenshotImage.Height - ignore_header), Program.timelapse[c].BaseScreenshotImage.Width, Program.timelapse[c].BaseScreenshotImage.Height - ignore_header), new RectangleF(0, ignore_header, Program.timelapse[c].BaseScreenshotImage.Width, Program.timelapse[c].BaseScreenshotImage.Height - ignore_header), GraphicsUnit.Pixel); } g.Flush(); g.Save(); final = new Bitmap(b.Width, working_height); Graphics gfinal = Graphics.FromImage(final); gfinal.DrawImage(b, new Rectangle(0, 0, final.Width, final.Height), new Rectangle(0, 0, b.Width, working_height), GraphicsUnit.Pixel); gfinal.Flush(); gfinal.Save(); if (Directory.Exists(debug)) { final.Save(Path.Combine(debug, @"final-" + c + ".png"), System.Drawing.Imaging.ImageFormat.Png); } } Program.timelapse.First().ReplaceWithBitmap(final); Program.History.Add(Program.timelapse.First()); Program.Preview.GroomBackForwardIcons(); return Program.timelapse.First(); }
public UploaderEndedEventArgs(ExtendedScreenshot screenshot) { this.Screenshot = screenshot; }
public UploaderProgressEventArgs(ExtendedScreenshot screenshot, long percent) { this.Screenshot = screenshot; this.Percent = percent; }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { if (!Program.isTakingScrollingScreenshot) { return(null); } Program.isTakingScrollingScreenshot = false; Bitmap final = null; Bitmap b = new Bitmap(Program.timelapse.First().BaseScreenshotImage.Width, Program.timelapse.First().BaseScreenshotImage.Height *Program.timelapse.Count); Graphics g = Graphics.FromImage(b); int yoffset = 0; int working_height = 0; int ignore_header = 100; int ignore_footer = 10; var offsets = new Dictionary <int, int>(); //foreach (var ss in timelapse) for (int c = 0; c < Program.timelapse.Count; c++) { var debug = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), @"prosnap-debug"); if (Directory.Exists(debug)) { Program.timelapse[c].BaseScreenshotImage.Save(Path.Combine(debug, @"ss-" + c + ".png"), ImageFormat.Png); } if (c == 0) { g.DrawImageUnscaled(Program.timelapse[c].BaseScreenshotImage, new Point(0, 0)); working_height = Program.timelapse[c].BaseScreenshotImage.Height; offsets.Add(c, Program.timelapse[c].BaseScreenshotImage.Height); } else { int old_yoffset = yoffset; yoffset = GetYOffset(Program.timelapse[c - 1].BaseScreenshotImage, Program.timelapse[c].BaseScreenshotImage, ignore_header, ignore_footer, old_yoffset, working_height, c); offsets.Add(c, yoffset); int sum = 0; if (offsets.Count > 0) { for (int k = offsets.First().Key; k <= offsets.Last().Key; k++) { sum += offsets[k]; } } working_height = sum; g.DrawImage(Program.timelapse[c].BaseScreenshotImage, new RectangleF(0, working_height - (Program.timelapse[c].BaseScreenshotImage.Height - ignore_header), Program.timelapse[c].BaseScreenshotImage.Width, Program.timelapse[c].BaseScreenshotImage.Height - ignore_header), new RectangleF(0, ignore_header, Program.timelapse[c].BaseScreenshotImage.Width, Program.timelapse[c].BaseScreenshotImage.Height - ignore_header), GraphicsUnit.Pixel); } g.Flush(); g.Save(); final = new Bitmap(b.Width, working_height); Graphics gfinal = Graphics.FromImage(final); gfinal.DrawImage(b, new Rectangle(0, 0, final.Width, final.Height), new Rectangle(0, 0, b.Width, working_height), GraphicsUnit.Pixel); gfinal.Flush(); gfinal.Save(); if (Directory.Exists(debug)) { final.Save(Path.Combine(debug, @"final-" + c + ".png"), System.Drawing.Imaging.ImageFormat.Png); } } Program.timelapse.First().ReplaceWithBitmap(final); Program.History.Add(Program.timelapse.First()); Program.Preview.GroomBackForwardIcons(); return(Program.timelapse.First()); }
public Task<UploaderEndedEventArgs> Upload(ExtendedScreenshot screenshot) { Trace.WriteLine("Starting upload process...", string.Format("MultipartFormDataUploadService.Upload [{0}]", System.Threading.Thread.CurrentThread.Name)); var t = new TaskCompletionSource<UploaderEndedEventArgs>(); try { using (var wc = new WebClient()) { wc.UploadProgressChanged += (s, e) => { this.UploadProgress(this, new UploaderProgressEventArgs(screenshot, (e.BytesSent * 100) / e.TotalBytesToSend)); }; wc.UploadValuesCompleted += (s, e) => { Trace.WriteLine("Upload complete.", string.Format("MultipartFormDataUploadService.Upload [{0}]", System.Threading.Thread.CurrentThread.Name)); XmlDocument ResponseDoc = new XmlDocument(); ResponseDoc.Load(new MemoryStream(e.Result)); ResponseDoc.Save(Configuration.LocalPath + @"\response.txt"); XmlNodeList ImageLink = ResponseDoc.SelectNodes(this.ImageLinkXPath); screenshot.Remote.ImageLink = ImageLink.Count > 0 ? ImageLink[0].InnerText : null; XmlNodeList DeleteLink = ResponseDoc.SelectNodes(this.DeleteLinkXPath); screenshot.Remote.DeleteLink = DeleteLink.Count > 0 ? DeleteLink[0].InnerText : null; var result = new UploaderEndedEventArgs(screenshot); this.UploadEnded(this, result); t.SetResult(result); }; Trace.WriteLine("Starting stream conversion... ", string.Format("MultipartFormDataUploadService.Upload [{0}]", System.Threading.Thread.CurrentThread.Name)); var ImageData = string.Empty; using (var ms = screenshot.EditedScreenshotPNGImageStream()) ImageData = Convert.ToBase64String(ms.ToArray()); var CurrentUploadValues = new NameValueCollection(); foreach (var k in this.UploadValues.AllKeys.ToList()) CurrentUploadValues.Add(k, this.UploadValues[k].Replace("%i", ImageData)); Trace.WriteLine("Stream conversion complete.", string.Format("MultipartFormDataUploadService.Upload [{0}]", System.Threading.Thread.CurrentThread.Name)); Trace.WriteLine("Starting upload...", string.Format("MultipartFormDataUploadService.Upload [{0}]", System.Threading.Thread.CurrentThread.Name)); wc.UploadValuesAsync(new Uri(this.EndpointUrl), CurrentUploadValues); this.UploadStarted(this, new UploaderProgressEventArgs(screenshot, 0)); } } catch (Exception ex) { Trace.WriteLine(string.Format("Exception occurred during upload: {0}", ex.GetBaseException()), string.Format("MultipartFormDataUploadService.Upload [{0}]", System.Threading.Thread.CurrentThread.Name)); var result = new UploaderEndedEventArgs(ex.GetBaseException()); this.UploadEnded(this, result); t.SetResult(result); } return t.Task; }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { return LatestScreenshot; }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying RunAction...", string.Format("RunAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); if (LatestScreenshot == null) { Trace.WriteLine("Latest Screenshot is null, continuing...", string.Format("RunAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); return null; } if (!File.Exists(LatestScreenshot.InternalFileName)) { Directory.CreateDirectory(Path.GetDirectoryName(LatestScreenshot.InternalFileName)); LatestScreenshot.ComposedScreenshotImage.Save(LatestScreenshot.InternalFileName, ImageFormat.Png); } var parameters = Helper.ExpandParameters(this.Parameters, LatestScreenshot); var working = Environment.ExpandEnvironmentVariables(Helper.ExpandParameters(this.WorkingDirectory, LatestScreenshot)); switch (this.Mode) { case RunAction.Modes.ShellVerb: { Windowing.ShellExecute(IntPtr.Zero, this.ShellVerb, LatestScreenshot.InternalFileName, parameters, working, Windowing.ShowCommands.SW_NORMAL); } break; case RunAction.Modes.FilePath: { var psi = new ProcessStartInfo(Environment.ExpandEnvironmentVariables(Helper.ExpandParameters(this.ApplicationPath, LatestScreenshot)), parameters) { UseShellExecute = false, WorkingDirectory = working, CreateNoWindow = this.HideCommandPrompt, }; Process.Start(psi); } break; } return LatestScreenshot; }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying SaveAction...", string.Format("SaveAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); if (LatestScreenshot == null) { Trace.WriteLine("Latest Screenshot is null, continuing...", string.Format("SaveAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); return(null); } if (this.Prompt) { Trace.WriteLine(string.Format("Prompting for save: {0}", this.Prompt), string.Format("SaveAction.Invoke Save [{0}]", System.Threading.Thread.CurrentThread.Name)); var save = new Action(() => { Program.Preview.isSaveDialogOpen = true; var SaveDialog = new SaveFileDialog() { Filter = Configuration.FileDialogFilter, FilterIndex = Configuration.DefaultFilterIndex + 1, }; if (string.IsNullOrEmpty(LatestScreenshot.SavedFileName)) { SaveDialog.FileName = Environment.ExpandEnvironmentVariables(Helper.ExpandParameters(Configuration.DefaultFileName, LatestScreenshot)); } else { SaveDialog.FileName = Path.GetFileName(LatestScreenshot.SavedFileName); SaveDialog.InitialDirectory = Path.GetDirectoryName(LatestScreenshot.SavedFileName); } if (SaveDialog.ShowDialog(Program.Preview) == DialogResult.OK) { LatestScreenshot.ComposedScreenshotImage.Save(SaveDialog.FileName, Helper.ExtToImageFormat(Path.GetExtension(SaveDialog.FileName))); LatestScreenshot.SavedFileName = SaveDialog.FileName; } Program.Preview.isSaveDialogOpen = false; }); if (Program.Preview.InvokeRequired) { var t = new TaskCompletionSource <object>(); Program.Preview.BeginInvoke(new MethodInvoker(() => { save(); t.SetResult(null); })); Task.WaitAll(t.Task); } else { save(); } return(LatestScreenshot); } string FileName = Environment.ExpandEnvironmentVariables(Helper.ExpandParameters(this.FilePath, LatestScreenshot)); if (string.IsNullOrEmpty(FileName)) { MessageBox.Show(string.Format("There was a problem saving your screenshot:\r\n\r\n{0}", "No file name has been provided."), "ProSnap", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } try { var dir = Path.GetDirectoryName(FileName); if (!Directory.Exists(dir)) { Trace.WriteLine("Attempting to create directory...", string.Format("Program.DoActionItem Save [{0}]", System.Threading.Thread.CurrentThread.Name)); Directory.CreateDirectory(dir); } LatestScreenshot.ComposedScreenshotImage.Save(FileName, Helper.ExtToImageFormat(Path.GetExtension(FileName))); LatestScreenshot.SavedFileName = FileName; } catch (Exception e) { MessageBox.Show(string.Format("There was a problem saving your screenshot:\r\n\r\n{0}", e.GetBaseException().Message), "ProSnap", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } return(LatestScreenshot); }
public Task <UploaderEndedEventArgs> Upload(ExtendedScreenshot screenshot) { Trace.WriteLine("Starting upload process...", string.Format("MultipartFormDataUploadService.Upload [{0}]", System.Threading.Thread.CurrentThread.Name)); var t = new TaskCompletionSource <UploaderEndedEventArgs>(); try { using (var wc = new WebClient()) { wc.UploadProgressChanged += (s, e) => { this.UploadProgress(this, new UploaderProgressEventArgs(screenshot, (e.BytesSent * 100) / e.TotalBytesToSend)); }; wc.UploadValuesCompleted += (s, e) => { Trace.WriteLine("Upload complete.", string.Format("MultipartFormDataUploadService.Upload [{0}]", System.Threading.Thread.CurrentThread.Name)); XmlDocument ResponseDoc = new XmlDocument(); ResponseDoc.Load(new MemoryStream(e.Result)); ResponseDoc.Save(Configuration.LocalPath + @"\response.txt"); XmlNodeList ImageLink = ResponseDoc.SelectNodes(this.ImageLinkXPath); screenshot.Remote.ImageLink = ImageLink.Count > 0 ? ImageLink[0].InnerText : null; XmlNodeList DeleteLink = ResponseDoc.SelectNodes(this.DeleteLinkXPath); screenshot.Remote.DeleteLink = DeleteLink.Count > 0 ? DeleteLink[0].InnerText : null; var result = new UploaderEndedEventArgs(screenshot); this.UploadEnded(this, result); t.SetResult(result); }; Trace.WriteLine("Starting stream conversion... ", string.Format("MultipartFormDataUploadService.Upload [{0}]", System.Threading.Thread.CurrentThread.Name)); var ImageData = string.Empty; using (var ms = screenshot.EditedScreenshotPNGImageStream()) ImageData = Convert.ToBase64String(ms.ToArray()); var CurrentUploadValues = new NameValueCollection(); foreach (var k in this.UploadValues.AllKeys.ToList()) { CurrentUploadValues.Add(k, this.UploadValues[k].Replace("%i", ImageData)); } Trace.WriteLine("Stream conversion complete.", string.Format("MultipartFormDataUploadService.Upload [{0}]", System.Threading.Thread.CurrentThread.Name)); Trace.WriteLine("Starting upload...", string.Format("MultipartFormDataUploadService.Upload [{0}]", System.Threading.Thread.CurrentThread.Name)); wc.UploadValuesAsync(new Uri(this.EndpointUrl), CurrentUploadValues); this.UploadStarted(this, new UploaderProgressEventArgs(screenshot, 0)); } } catch (Exception ex) { Trace.WriteLine(string.Format("Exception occurred during upload: {0}", ex.GetBaseException()), string.Format("MultipartFormDataUploadService.Upload [{0}]", System.Threading.Thread.CurrentThread.Name)); var result = new UploaderEndedEventArgs(ex.GetBaseException()); this.UploadEnded(this, result); t.SetResult(result); } return(t.Task); }
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { return(LatestScreenshot); }
public abstract bool Upload(UploadService activeService, ExtendedScreenshot screenshot);
public ExtendedScreenshot Invoke(ExtendedScreenshot LatestScreenshot) { Trace.WriteLine("Applying SaveAction...", string.Format("SaveAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); if (LatestScreenshot == null) { Trace.WriteLine("Latest Screenshot is null, continuing...", string.Format("SaveAction.Invoke [{0}]", System.Threading.Thread.CurrentThread.Name)); return null; } if (this.Prompt) { Trace.WriteLine(string.Format("Prompting for save: {0}", this.Prompt), string.Format("SaveAction.Invoke Save [{0}]", System.Threading.Thread.CurrentThread.Name)); var save = new Action(() => { Program.Preview.isSaveDialogOpen = true; var SaveDialog = new SaveFileDialog() { Filter = Configuration.FileDialogFilter, FilterIndex = Configuration.DefaultFilterIndex + 1, }; if (string.IsNullOrEmpty(LatestScreenshot.SavedFileName)) { SaveDialog.FileName = Environment.ExpandEnvironmentVariables(Helper.ExpandParameters(Configuration.DefaultFileName, LatestScreenshot)); } else { SaveDialog.FileName = Path.GetFileName(LatestScreenshot.SavedFileName); SaveDialog.InitialDirectory = Path.GetDirectoryName(LatestScreenshot.SavedFileName); } if (SaveDialog.ShowDialog(Program.Preview) == DialogResult.OK) { LatestScreenshot.ComposedScreenshotImage.Save(SaveDialog.FileName, Helper.ExtToImageFormat(Path.GetExtension(SaveDialog.FileName))); LatestScreenshot.SavedFileName = SaveDialog.FileName; } Program.Preview.isSaveDialogOpen = false; }); if (Program.Preview.InvokeRequired) { var t = new TaskCompletionSource<object>(); Program.Preview.BeginInvoke(new MethodInvoker(() => { save(); t.SetResult(null); })); Task.WaitAll(t.Task); } else { save(); } return LatestScreenshot; } string FileName = Environment.ExpandEnvironmentVariables(Helper.ExpandParameters(this.FilePath, LatestScreenshot)); if (string.IsNullOrEmpty(FileName)) MessageBox.Show(string.Format("There was a problem saving your screenshot:\r\n\r\n{0}", "No file name has been provided."), "ProSnap", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); try { var dir = Path.GetDirectoryName(FileName); if (!Directory.Exists(dir)) { Trace.WriteLine("Attempting to create directory...", string.Format("Program.DoActionItem Save [{0}]", System.Threading.Thread.CurrentThread.Name)); Directory.CreateDirectory(dir); } LatestScreenshot.ComposedScreenshotImage.Save(FileName, Helper.ExtToImageFormat(Path.GetExtension(FileName))); LatestScreenshot.SavedFileName = FileName; } catch (Exception e) { MessageBox.Show(string.Format("There was a problem saving your screenshot:\r\n\r\n{0}", e.GetBaseException().Message), "ProSnap", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1); } return LatestScreenshot; }