public void Init(ScreenShotImageConverter cf, bool enabled, string inputfolder, ScreenShotConverter.InputTypes it, string outputfolder)
        {
            comboBoxFileNameFormat.Items.AddRange(ScreenShotImageConverter.FileNameFormats);
            comboBoxFileNameFormat.SelectedIndex = cf.FileNameFormat;
            extCheckBoxEnabled.Checked           = enabled;
            comboBoxOutputAs.Items.AddRange(Enum.GetNames(typeof(ScreenShotImageConverter.OutputTypes)));
            comboBoxOutputAs.SelectedIndex = (int)cf.OutputFileExtension;
            comboBoxScanFor.Items.AddRange(Enum.GetNames(typeof(ScreenShotConverter.InputTypes)));
            comboBoxScanFor.SelectedIndex = (int)it;
            initialssfolder       = textBoxScreenshotsDir.Text = inputfolder;
            textBoxOutputDir.Text = outputfolder;
            comboBoxSubFolder.Items.AddRange(ScreenShotImageConverter.SubFolderSelections);
            comboBoxSubFolder.SelectedIndex = cf.FolderNameFormat;
            string[] opt = new string[] { "Off", "Crop", "Resize" };
            extComboBoxConvert1.Items.AddRange(opt);
            extComboBoxConvert2.Items.AddRange(opt);

            extCheckBoxHiRes.Checked = cf.HighRes;

            extComboBoxClipboard.Items.Add(ScreenShotImageConverter.ClipboardOptions.NoCopy.ToString().SplitCapsWordFull());
            extComboBoxClipboard.Items.Add(ScreenShotImageConverter.ClipboardOptions.CopyMaster.ToString().SplitCapsWordFull());
            extComboBoxClipboard.Items.Add(ScreenShotImageConverter.ClipboardOptions.CopyImage1.ToString().SplitCapsWordFull());
            extComboBoxClipboard.Items.Add(ScreenShotImageConverter.ClipboardOptions.CopyImage2.ToString().SplitCapsWordFull());
            extComboBoxClipboard.SelectedIndex = (int)cf.ClipboardOption;

            extComboBoxConvert1.SelectedIndex = (int)cf.CropResizeImage1;
            extComboBoxConvert2.SelectedIndex = (int)cf.CropResizeImage2;

            OriginalImageDirectory = cf.OriginalImageOptionDirectory;

            extComboBoxOriginalImageSel.Items.Add(ScreenShotImageConverter.OriginalImageOptions.Leave.ToString());
            extComboBoxOriginalImageSel.Items.Add(ScreenShotImageConverter.OriginalImageOptions.Delete.ToString());
            extComboBoxOriginalImageSel.Items.Add(ScreenShotImageConverter.OriginalImageOptions.Move.ToString() + "->" + OriginalImageDirectory);
            extComboBoxOriginalImageSel.SelectedIndex = (int)cf.OriginalImageOption;

            extCheckBoxKeepMasterConvertedImage.Checked = cf.KeepMasterConvertedImage;

            numericUpDownTop1.Value    = cf.CropResizeArea1.Top;
            numericUpDownLeft1.Value   = cf.CropResizeArea1.Left;
            numericUpDownWidth1.Value  = cf.CropResizeArea1.Width;
            numericUpDownHeight1.Value = cf.CropResizeArea1.Height;

            extNumericUpDownTop2.Value    = cf.CropResizeArea2.Top;
            extNumericUpDownLeft2.Value   = cf.CropResizeArea2.Left;
            extNumericUpDownWidth2.Value  = cf.CropResizeArea2.Width;
            extNumericUpDownHeight2.Value = cf.CropResizeArea2.Height;

            SetNumEnabled();

            extComboBoxConvert1.SelectedIndexChanged += (s, e) => { SetNumEnabled(); };
            extComboBoxConvert2.SelectedIndexChanged += (s, e) => { SetNumEnabled(); };

            UpdateExample();

            BaseUtils.Translator.Instance.Translate(this);

            label_index.Text = this.Text;
        }
Ejemplo n.º 2
0
        public ScreenShotConverter()
        {
            converter = new ScreenShotImageConverter();

            string screenshotsDirdefault = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures), "Frontier Developments", "Elite Dangerous");
            string outputDirdefault      = Path.Combine(screenshotsDirdefault, "Converted");

            InputFolder = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString("ImageHandlerScreenshotsDir", screenshotsDirdefault);
            if (!Directory.Exists(InputFolder))
            {
                InputFolder = screenshotsDirdefault;
            }

            OutputFolder = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingString("ImageHandlerOutputDir", outputDirdefault);
            if (!Directory.Exists(OutputFolder))
            {
                OutputFolder = outputDirdefault;
            }

            AutoConvert = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingBool("ImageHandlerAutoconvert", false);
            converter.RemoveOriginal  = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingBool("checkBoxRemove", false);
            converter.HighRes         = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingBool("checkBoxHires", false);
            converter.CopyToClipboard = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingBool("ImageHandlerClipboard", false);

            try
            {       // just in case
                if (EliteDangerousCore.DB.UserDatabase.Instance.KeyExists("ImageHandlerCropImage"))
                {
                    converter.CropResizeImage1 = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingBool("ImageHandlerCropImage", false) ? ScreenShotImageConverter.CropResizeOptions.Crop : ScreenShotImageConverter.CropResizeOptions.Off;
                    EliteDangerousCore.DB.UserDatabase.Instance.DeleteKey("ImageHandlerCropImage");
                }
                else
                {
                    converter.CropResizeImage1 = (ScreenShotImageConverter.CropResizeOptions)EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("ImageHandlerCropResizeImage1", 0);
                }

                converter.CropResizeImage2 = (ScreenShotImageConverter.CropResizeOptions)EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("ImageHandlerCropResizeImage2", 0);
                converter.CropResizeArea1  = new Rectangle(EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("ImageHandlerCropLeft", 0), EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("ImageHandlerCropTop", 0),
                                                           EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("ImageHandlerCropWidth", 1920), EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("ImageHandlerCropHeight", 1024));
                converter.CropResizeArea2 = new Rectangle(EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("ImageHandlerCropLeft2", 0), EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("ImageHandlerCropTop2", 0),
                                                          EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("ImageHandlerCropWidth2", 1920), EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("ImageHandlerCropHeight2", 1024));

                InputFileExtension            = (InputTypes)EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("comboBoxScanFor", 0);
                converter.OutputFileExtension = (ScreenShotImageConverter.OutputTypes)EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("ImageHandlerFormatNr", 0);

                converter.KeepMasterConvertedImage = EliteDangerousCore.DB.UserDatabase.Instance.GetSettingBool("ImageHandlerKeepFullSized", false);
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception " + ex.ToString());
            }

            converter.FileNameFormat   = Math.Min(Math.Max(0, EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("comboBoxFileNameFormat", 0)), ScreenShotImageConverter.FileNameFormats.Length - 1);
            converter.FolderNameFormat = Math.Min(Math.Max(0, EliteDangerousCore.DB.UserDatabase.Instance.GetSettingInt("comboBoxSubFolder", 0)), ScreenShotImageConverter.SubFolderSelections.Length - 1);
        }
Ejemplo n.º 3
0
        public void Init(ScreenShotImageConverter cf, string inputfolder, ScreenShotConverter.InputTypes it, string outputfolder)
        {
            comboBoxOutputAs.Items.AddRange(Enum.GetNames(typeof(ScreenShotImageConverter.OutputTypes)));
            comboBoxOutputAs.SelectedIndex = (int)cf.OutputFileExtension;
            comboBoxScanFor.Items.AddRange(Enum.GetNames(typeof(ScreenShotConverter.InputTypes)));
            comboBoxScanFor.SelectedIndex = (int)it;
            initialssfolder       = textBoxScreenshotsDir.Text = inputfolder;
            textBoxOutputDir.Text = outputfolder;
            comboBoxSubFolder.Items.AddRange(ScreenShotImageConverter.SubFolderSelections);
            comboBoxSubFolder.SelectedIndex = cf.FolderNameFormat;
            comboBoxFileNameFormat.Items.AddRange(ScreenShotImageConverter.FileNameFormats);
            comboBoxFileNameFormat.SelectedIndex = cf.FileNameFormat;
            string[] opt = new string[] { "Off", "Crop", "Resize" };
            extComboBoxConvert1.Items.AddRange(opt);
            extComboBoxConvert2.Items.AddRange(opt);

            extCheckBoxHiRes.Checked    = cf.HighRes;
            extCheckBoxCopyClip.Checked = cf.CopyToClipboard;

            extComboBoxConvert1.SelectedIndex = (int)cf.CropResizeImage1;
            extComboBoxConvert2.SelectedIndex = (int)cf.CropResizeImage2;

            extCheckBoxRemoveOriginal.Checked           = cf.RemoveOriginal;
            extCheckBoxKeepMasterConvertedImage.Checked = cf.KeepMasterConvertedImage;

            numericUpDownTop1.Value    = cf.CropResizeArea1.Top;
            numericUpDownLeft1.Value   = cf.CropResizeArea1.Left;
            numericUpDownWidth1.Value  = cf.CropResizeArea1.Width;
            numericUpDownHeight1.Value = cf.CropResizeArea1.Height;

            extNumericUpDownTop2.Value    = cf.CropResizeArea2.Top;
            extNumericUpDownLeft2.Value   = cf.CropResizeArea2.Left;
            extNumericUpDownWidth2.Value  = cf.CropResizeArea2.Width;
            extNumericUpDownHeight2.Value = cf.CropResizeArea2.Height;

            SetNumEnabled();

            extComboBoxConvert1.SelectedIndexChanged += (s, e) => { SetNumEnabled(); };
            extComboBoxConvert2.SelectedIndexChanged += (s, e) => { SetNumEnabled(); };

            textBoxFileNameExample.Text = ScreenShotImageConverter.CreateFileName("Sol", "Earth", "HighResScreenshot_0000.bmp", comboBoxFileNameFormat.SelectedIndex, extCheckBoxHiRes.Checked, DateTime.Now);

            BaseUtils.Translator.Instance.Translate(this);

            label_index.Text = this.Text;
        }
Ejemplo n.º 4
0
        // 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);
        }
 private void UpdateExample()
 {
     textBoxFileNameExample.Text = Path.Combine(ScreenShotImageConverter.SubFolder(comboBoxSubFolder.SelectedIndex, OutputFolder, "Sol", "Jameson", DateTime.Now),
                                                ScreenShotImageConverter.CreateFileName("Sol", "Earth", "HighResScreenshot_0000.bmp", comboBoxFileNameFormat.SelectedIndex, extCheckBoxHiRes.Checked, DateTime.Now) + "." + comboBoxOutputAs.Text);
 }
Ejemplo n.º 6
0
        private void ProcessFilesystemEvent(object sender, System.IO.FileSystemEventArgs e, ScreenShotImageConverter cp) // on UI thread
        {
            System.Diagnostics.Debug.Assert(System.Windows.Forms.Application.MessageLoop);

            if (e.FullPath.ToLowerInvariant().EndsWith(".bmp"))     // cause its a frontier bmp file..
            {
                System.Diagnostics.Debug.WriteLine("File watch start a timer to wait for SS entry");

                System.Timers.Timer t = new System.Timers.Timer(watchdelay);  // use a timer since we can set it up slowly before we start it
                t.Elapsed         += T_Elapsed;
                filewatchTimers[t] = e.FullPath;
                t.Start();
            }
            else
            {
                string name = Path.GetFileName(e.FullPath);
                ProcessScreenshot(e.FullPath, null, cp);
            }
        }
Ejemplo n.º 7
0
        // 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));
                }
            }
Ejemplo n.º 8
0
        private void ProcessFilesystemEvent(object sender, System.IO.FileSystemEventArgs e, ScreenShotImageConverter cp) // on UI thread
        {
            System.Diagnostics.Debug.Assert(System.Windows.Forms.Application.MessageLoop);

            if (e.FullPath.ToLowerInvariant().EndsWith(".bmp"))     // cause its a frontier bmp file..
            {
                if (!ScreenshotTimers.ContainsKey(e.FullPath))      // just double check against repeated file watcher fires
                {
                    System.Diagnostics.Debug.WriteLine("File watch start a timer to wait for SS entry");
                    System.Threading.Timer timer = new System.Threading.Timer(s => TimeOutForFileWatcher(e.FullPath), null, 5000, System.Threading.Timeout.Infinite);

                    if (!ScreenshotTimers.TryAdd(e.FullPath, timer))
                    {
                        timer.Dispose();
                    }
                }
            }
            else
            {
                if (!JournalScreenshotted.ContainsKey(Path.GetFileName(e.FullPath)))        // just make sure in case the order is wrong
                {
                    System.Diagnostics.Debug.WriteLine("Not a .bmp, not been journal screenshotted, go");
                    ProcessScreenshot(e.FullPath, null, null, null, cp);
                }
                else
                {
                    System.Diagnostics.Debug.WriteLine("Journal screenshot already did this one");
                }
            }
        }
Ejemplo n.º 9
0
 private void extCheckBoxHiRes_CheckedChanged(object sender, EventArgs e)
 {
     textBoxFileNameExample.Text = ScreenShotImageConverter.CreateFileName("Sol", "Earth", "HighResScreenshot_0000.bmp", comboBoxFileNameFormat.SelectedIndex, extCheckBoxHiRes.Checked, DateTime.Now);
 }