// called thru CallWithConverter in UI main class to give us a ScreenShotImageConverter // fileid may not be the whole name if picked up thru ss system - like \EDPICTURES\ // ss is not null if it was a screenshot // return if original is left in place private bool ProcessScreenshot(string filenamepart, JournalScreenshot ss, ScreenShotImageConverter cp) { System.Diagnostics.Debug.Assert(System.Windows.Forms.Application.MessageLoop); // UI thread var r = getcurinfo(); string sysname = (ss == null ? r.Item1 : ss.System) ?? "Unknown"; string bodyname = (ss == null ? r.Item2 : ss.Body) ?? "Unknown"; string cmdrname = (ss == null ? r.Item3 : EDCommander.GetCommander(ss.CommanderId)?.Name) ?? "Unknown"; System.Diagnostics.Debug.WriteLine("Process {0} s={1} b={2} c={3}", filenamepart, sysname, bodyname, cmdrname); try { string filein = TryGetScreenshot(filenamepart, out Bitmap bmp, out DateTime timestamputc); if (filein != null) { // return input filename now, output filename and size var fs = cp.Convert(bmp, filein, timestamputc, outputfolder, bodyname, sysname, cmdrname, logit); if (fs != null) { OnScreenshot?.Invoke(fs.Item1, fs.Item2, fs.Item3, ss); } return(cp.OriginalImageOption == ScreenShotImageConverter.OriginalImageOptions.Leave); } else { logit(string.Format("Failed to read screenshot {0}", filenamepart)); } } catch (Exception ex) { System.Diagnostics.Trace.WriteLine("Exception watcher: " + ex.Message); System.Diagnostics.Trace.WriteLine("Trace: " + ex.StackTrace); logit("Error in executing image conversion, try another screenshot, check output path settings. (Exception ".T(EDTx.ScreenshotDirectoryWatcher_Excp) + ex.Message + ")"); } return(false); }
// called thru CalLWithConverter in UI main class to give us a ScreenShotImageConverter // fileid may not be the whole name if picked up thru ss system - like \EDPICTURES\ private void ProcessScreenshot(string filenamepart, string sysname, string bodyname, string cmdrname, ScreenShotImageConverter cp) { System.Diagnostics.Debug.Assert(System.Windows.Forms.Application.MessageLoop); // UI thread var r = getcurinfo(); if (sysname == null) // fill in if required { sysname = r.Item1 ?? "Unknown"; } if (bodyname == null) { bodyname = r.Item2 ?? "Unknown"; } if (cmdrname == null) { cmdrname = r.Item3 ?? "Unknown"; } System.Diagnostics.Debug.WriteLine("Process {0} s={1} b={2} c={3}", filenamepart, sysname, bodyname, cmdrname); try { if (TryGetScreenshot(filenamepart, out Bitmap bmp, out string filepath, out DateTime timestamp)) { var fs = cp.Convert(bmp, filepath, outputfolder, timestamp, logit, bodyname, sysname, cmdrname); if (fs.Item1 != null) { OnScreenshot?.Invoke(fs.Item1, fs.Item2); } } else { logit(string.Format("Failed to read screenshot {0}", filenamepart)); } }
private void ConvertCompleted(string infile, string outfile, Size sz, JournalEvents.JournalScreenshot ss) // Called by the watcher when a convert had completed, in UI thread { System.Diagnostics.Debug.Assert(Application.MessageLoop); OnScreenshot?.Invoke(infile, outfile, sz, ss); }