/// <summary>
        /// The main window for the application's interface.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            _timerRepeatScreenshots          = new System.Timers.Timer(1000);
            _timerRepeatScreenshots.Elapsed += _timerRepeatScreenshots_Elapsed;

            // We check the given date and time every second.
            // If they match with the current date/time then we take a screenshot.
            // We also use this timer elapsed method for updating the screenshot preview window (if it's visible).
            _timerScheduledScreenshots          = new System.Timers.Timer(1000);
            _timerScheduledScreenshots.Elapsed += _timerScheduledScreenshots_Elapsed;

            // The various forms to construct.
            _help              = new Help();
            _screenCapture     = new ScreenCapture();
            _screenshotPreview = new ScreenshotPreview();
            _settings          = new Settings(_screenCapture, _screenshotPreview);

            // The regular expression to use for checking against the provided time in the Time text field.
            // (format must be HH:mm:ss)
            _rgxTime = new Regex(@"^\d{2}:\d{2}:\d{2}$");

            _settings.comboBoxFormat.Items.Add("BMP");
            _settings.comboBoxFormat.Items.Add("EMF");
            _settings.comboBoxFormat.Items.Add("GIF");
            _settings.comboBoxFormat.Items.Add("JPEG");
            _settings.comboBoxFormat.Items.Add("PNG");
            _settings.comboBoxFormat.Items.Add("TIFF");
            _settings.comboBoxFormat.Items.Add("WMF");

            _settings.comboBoxFormat.SelectedIndex = 3; // JPEG is the default image format

            _settings.Date.SelectedDate = DateTime.Now.Date;

            _settings.textBoxMacro.Text = AppDomain.CurrentDomain.BaseDirectory + "screenshot.%format%";

            _timerScheduledScreenshots.Start();

            Visibility = (Visibility)ParseCommandLineArguments();
        }
Beispiel #2
0
        public Settings(ScreenCapture screenCapture, ScreenshotPreview screenshotPreview)
        {
            InitializeComponent();

            _screenCapture         = screenCapture;
            this.screenshotPreview = screenshotPreview;

            _lightGreen    = new SolidColorBrush(Colors.LightGreen);
            _lightYellow   = new SolidColorBrush(Colors.LightYellow);
            _paleVioletRed = new SolidColorBrush(Colors.PaleVioletRed);

            CheckRegex();

            textBoxDelayBefore.Text = "0";
            textBoxDelayAfter.Text  = "0";

            buttonRefreshProcessList_Click(null, null);

            // Microsoft Paint
            if (File.Exists(@"C:\Windows\System32\mspaint.exe"))
            {
                textBoxExecutablePath.Text      = @"C:\Windows\System32\mspaint.exe";
                textBoxExecutableArguments.Text = "%filepath%";
            }

            // Snagit Editor
            if (File.Exists(@"C:\Program Files\TechSmith\Snagit 2020\SnagitEditor.exe"))
            {
                textBoxExecutablePath.Text      = @"C:\Program Files\TechSmith\Snagit 2020\SnagitEditor.exe";
                textBoxExecutableArguments.Text = "%filepath%";
            }

            // ShareX Image Editor
            if (File.Exists(@"C:\Program Files\ShareX\ShareX.exe"))
            {
                textBoxExecutablePath.Text      = @"C:\Program Files\ShareX\ShareX.exe";
                textBoxExecutableArguments.Text = "-ImageEditor %filepath%";
            }
        }