Ejemplo n.º 1
0
        public void Upgrade()
        {
            try
            {
                if (Settings.VersionManager.IsOldAppVersion(AppCodename, AppVersion))
                {
                    Log.Write("An old version of Auto Screen Capture was detected. Attempting upgrade");

                    SettingCollection oldUserSettings = (SettingCollection)this.MemberwiseClone();
                    oldUserSettings._settingList = new List <Setting>(_settingList);

                    Settings.VersionManager.OldUserSettings = oldUserSettings;

                    if (Settings.VersionManager.Versions.Get("Clara", "2.1.8.2") != null && string.IsNullOrEmpty(AppCodename) && string.IsNullOrEmpty(AppVersion))
                    {
                        Log.Write("Accurate version information could not be found so assuming upgrade from 2.1.8.2");

                        // Go through the old settings and get the old values from them to be used for the new settings.

                        // 2.1 used a setting named "Interval", but 2.2 uses "IntScreenCaptureInterval".
                        if (KeyExists("Interval"))
                        {
                            SetValueByKey("IntScreenCaptureInterval",
                                          Convert.ToInt32(GetByKey("Interval", 60000, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "CaptureLimit", but 2.2 uses "IntCaptureLimit".
                        if (KeyExists("CaptureLimit"))
                        {
                            SetValueByKey("IntCaptureLimit",
                                          Convert.ToInt32(GetByKey("CaptureLimit", 0, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "CaptureLimitCheck", but 2.2 uses "BoolCaptureLimit".
                        if (KeyExists("CaptureLimitCheck"))
                        {
                            SetValueByKey("BoolCaptureLimit",
                                          Convert.ToBoolean(GetByKey("CaptureLimitCheck", false, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "TakeInitialScreenshotCheck", but 2.2 uses "BoolTakeInitialScreenshot".
                        if (KeyExists("TakeInitialScreenshotCheck"))
                        {
                            SetValueByKey("BoolTakeInitialScreenshot",
                                          Convert.ToBoolean(GetByKey("TakeInitialScreenshotCheck", false, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "ShowSystemTrayIcon", but 2.2 uses "BoolShowSystemTrayIcon".
                        if (KeyExists("ShowSystemTrayIcon"))
                        {
                            SetValueByKey("BoolShowSystemTrayIcon",
                                          Convert.ToBoolean(GetByKey("ShowSystemTrayIcon", true, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "CaptureStopAtCheck", but 2.2 uses "BoolCaptureStopAt".
                        if (KeyExists("CaptureStopAtCheck"))
                        {
                            SetValueByKey("BoolCaptureStopAt",
                                          Convert.ToBoolean(GetByKey("CaptureStopAtCheck", false, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "CaptureStartAtCheck", but 2.2 uses "BoolCaptureStartAt".
                        if (KeyExists("CaptureStartAtCheck"))
                        {
                            SetValueByKey("BoolCaptureStartAt",
                                          Convert.ToBoolean(GetByKey("CaptureStartAtCheck", false, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "CaptureOnSundayCheck", but 2.2 uses "BoolCaptureOnSunday".
                        if (KeyExists("CaptureOnSundayCheck"))
                        {
                            SetValueByKey("BoolCaptureOnSunday",
                                          Convert.ToBoolean(GetByKey("CaptureOnSundayCheck", false, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "CaptureOnMondayCheck", but 2.2 uses "BoolCaptureOnMonday".
                        if (KeyExists("CaptureOnMondayCheck"))
                        {
                            SetValueByKey("BoolCaptureOnMonday",
                                          Convert.ToBoolean(GetByKey("CaptureOnMondayCheck", false, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "CaptureOnTuesdayCheck", but 2.2 uses "BoolCaptureOnTuesday".
                        if (KeyExists("CaptureOnTuesdayCheck"))
                        {
                            SetValueByKey("BoolCaptureOnTuesday",
                                          Convert.ToBoolean(GetByKey("CaptureOnTuesdayCheck", false, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "CaptureOnWednesdayCheck", but 2.2 uses "BoolCaptureOnWednesday".
                        if (KeyExists("CaptureOnWednesdayCheck"))
                        {
                            SetValueByKey("BoolCaptureOnWednesday",
                                          Convert.ToBoolean(GetByKey("CaptureOnWednesdayCheck", false, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "CaptureOnThursdayCheck", but 2.2 uses "BoolCaptureOnThursday".
                        if (KeyExists("CaptureOnThursdayCheck"))
                        {
                            SetValueByKey("BoolCaptureOnThursday",
                                          Convert.ToBoolean(GetByKey("CaptureOnThursdayCheck", false, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "CaptureOnFridayCheck", but 2.2 uses "BoolCaptureOnFriday".
                        if (KeyExists("CaptureOnFridayCheck"))
                        {
                            SetValueByKey("BoolCaptureOnFriday",
                                          Convert.ToBoolean(GetByKey("CaptureOnFridayCheck", false, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "CaptureOnSaturdayCheck", but 2.2 uses "BoolCaptureOnSaturday".
                        if (KeyExists("CaptureOnSaturdayCheck"))
                        {
                            SetValueByKey("BoolCaptureOnSaturday",
                                          Convert.ToBoolean(GetByKey("CaptureOnSaturdayCheck", false, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "CaptureOnTheseDaysCheck", but 2.2 uses "BoolCaptureOnTheseDays".
                        if (KeyExists("CaptureOnTheseDaysCheck"))
                        {
                            SetValueByKey("BoolCaptureOnTheseDays",
                                          Convert.ToBoolean(GetByKey("CaptureOnTheseDaysCheck", false, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "CaptureStopAtValue", but 2.2 uses "DateTimeCaptureStopAt".
                        if (KeyExists("CaptureStopAtValue"))
                        {
                            SetValueByKey("DateTimeCaptureStopAt",
                                          Convert.ToDateTime(GetByKey("CaptureStopAtValue", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 0, 0), createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "CaptureStartAtValue", but 2.2 uses "DateTimeCaptureStartAt".
                        if (KeyExists("CaptureStartAtValue"))
                        {
                            SetValueByKey("DateTimeCaptureStartAt",
                                          Convert.ToDateTime(GetByKey("CaptureStartAtValue", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 0, 0), createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "LockScreenCaptureSession", but 2.2 uses "BoolLockScreenCaptureSession".
                        if (KeyExists("LockScreenCaptureSession"))
                        {
                            SetValueByKey("BoolLockScreenCaptureSession",
                                          Convert.ToBoolean(GetByKey("LockScreenCaptureSession", false, createKeyIfNotFound: false).Value));
                        }

                        // 2.1 used a setting named "Passphrase", but 2.2 uses "StringPassphrase".
                        if (KeyExists("Passphrase"))
                        {
                            SetValueByKey("StringPassphrase",
                                          GetByKey("Passphrase", string.Empty, createKeyIfNotFound: false).Value.ToString());
                        }

                        // 2.1 used a setting named "DaysOldWhenRemoveSlides", but 2.2 uses "IntKeepScreenshotsForDays".
                        if (KeyExists("DaysOldWhenRemoveSlides"))
                        {
                            SetValueByKey("IntKeepScreenshotsForDays",
                                          Convert.ToInt32(
                                              GetByKey("DaysOldWhenRemoveSlides", 30, createKeyIfNotFound: false).Value));
                        }

                        // Remove the old settings.
                        // When upgrading from 2.1 to 2.2 we should end up with about 20 settings instead of 60
                        // because 2.1 was limited to using Screen 1, Screen 2, Screen 3, Screen 4, and Active Window
                        // so there were settings dedicated to all the properties associated with them (such as Name, X, Y, Width, and Height).
                        RemoveByKey("CaptureLimit");
                        RemoveByKey("CaptureLimitCheck");
                        RemoveByKey("TakeInitialScreenshotCheck");
                        RemoveByKey("ShowSystemTrayIcon");
                        RemoveByKey("CaptureStopAtCheck");
                        RemoveByKey("CaptureStartAtCheck");
                        RemoveByKey("CaptureOnSundayCheck");
                        RemoveByKey("CaptureOnMondayCheck");
                        RemoveByKey("CaptureOnTuesdayCheck");
                        RemoveByKey("CaptureOnWednesdayCheck");
                        RemoveByKey("CaptureOnThursdayCheck");
                        RemoveByKey("CaptureOnFridayCheck");
                        RemoveByKey("CaptureOnSaturdayCheck");
                        RemoveByKey("CaptureOnTheseDaysCheck");
                        RemoveByKey("CaptureStopAtValue");
                        RemoveByKey("CaptureStartAtValue");
                        RemoveByKey("LockScreenCaptureSession");
                        RemoveByKey("Passphrase");
                        RemoveByKey("ScreenshotsDirectory");
                        RemoveByKey("ScheduleImageFormat");
                        RemoveByKey("SlideSkip");
                        RemoveByKey("ImageResolutionRatio");
                        RemoveByKey("ImageFormatFilter");
                        RemoveByKey("ImageFormatFilterIndex");
                        RemoveByKey("Interval");
                        RemoveByKey("SlideshowDelay");
                        RemoveByKey("SlideSkipCheck");
                        RemoveByKey("Screen1X");
                        RemoveByKey("Screen1Y");
                        RemoveByKey("Screen1Width");
                        RemoveByKey("Screen1Height");
                        RemoveByKey("Screen2X");
                        RemoveByKey("Screen2Y");
                        RemoveByKey("Screen2Width");
                        RemoveByKey("Screen2Height");
                        RemoveByKey("Screen3X");
                        RemoveByKey("Screen3Y");
                        RemoveByKey("Screen3Width");
                        RemoveByKey("Screen3Height");
                        RemoveByKey("Screen4X");
                        RemoveByKey("Screen4Y");
                        RemoveByKey("Screen4Width");
                        RemoveByKey("Screen4Height");
                        RemoveByKey("Screen1Name");
                        RemoveByKey("Screen2Name");
                        RemoveByKey("Screen3Name");
                        RemoveByKey("Screen4Name");
                        RemoveByKey("Screen5Name");
                        RemoveByKey("Macro");
                        RemoveByKey("JpegQualityLevel");
                        RemoveByKey("DaysOldWhenRemoveSlides");
                        RemoveByKey("CaptureScreen1");
                        RemoveByKey("CaptureScreen2");
                        RemoveByKey("CaptureScreen3");
                        RemoveByKey("CaptureScreen4");
                        RemoveByKey("CaptureActiveWindow");
                        RemoveByKey("AutoReset");
                        RemoveByKey("Mouse");
                        RemoveByKey("StartButtonImageFormat");
                        RemoveByKey("Schedule");
                        RemoveByKey("DeleteScreenshotsOlderThanDays");
                        RemoveByKey("ScreenshotDelay");
                    }

                    Log.Write("Upgrade completed.");

                    // Now that we've upgraded all the settings we should save them to disk.
                    Save();
                }
            }
            catch (Exception ex)
            {
                Log.Write("SettingCollection::Upgrade", ex);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Loads the image schedules from the schedules.xml file.
        /// </summary>
        public bool LoadXmlFileAndAddSchedules()
        {
            try
            {
                if (FileSystem.FileExists(FileSystem.SchedulesFile))
                {
                    Log.WriteDebugMessage("Schedules file \"" + FileSystem.SchedulesFile + "\" found. Attempting to load XML document");

                    XmlDocument xDoc = new XmlDocument();
                    xDoc.Load(FileSystem.SchedulesFile);

                    Log.WriteDebugMessage("XML document loaded");

                    AppVersion  = xDoc.SelectSingleNode("/autoscreen").Attributes["app:version"]?.Value;
                    AppCodename = xDoc.SelectSingleNode("/autoscreen").Attributes["app:codename"]?.Value;

                    XmlNodeList xSchedules = xDoc.SelectNodes(SCHEDULE_XPATH);

                    foreach (XmlNode xSchedule in xSchedules)
                    {
                        Schedule      schedule = new Schedule();
                        XmlNodeReader xReader  = new XmlNodeReader(xSchedule);

                        while (xReader.Read())
                        {
                            if (xReader.IsStartElement() && !xReader.IsEmptyElement)
                            {
                                switch (xReader.Name)
                                {
                                case SCHEDULE_NAME:
                                    xReader.Read();
                                    schedule.Name = xReader.Value;
                                    break;

                                case SCHEDULE_ACTIVE:
                                    xReader.Read();
                                    schedule.Active = Convert.ToBoolean(xReader.Value);
                                    break;

                                case SCHEDULE_MODE_ONETIME:
                                    xReader.Read();
                                    schedule.ModeOneTime = Convert.ToBoolean(xReader.Value);
                                    break;

                                case SCHEDULE_MODE_PERIOD:
                                    xReader.Read();
                                    schedule.ModePeriod = Convert.ToBoolean(xReader.Value);
                                    break;

                                case SCHEDULE_CAPTUREAT:
                                    xReader.Read();
                                    schedule.CaptureAt = Convert.ToDateTime(xReader.Value);
                                    break;

                                case SCHEDULE_STARTAT:
                                    xReader.Read();
                                    schedule.StartAt = Convert.ToDateTime(xReader.Value);
                                    break;

                                case SCHEDULE_STOPAT:
                                    xReader.Read();
                                    schedule.StopAt = Convert.ToDateTime(xReader.Value);
                                    break;

                                case SCHEDULE_SCREEN_CAPTURE_INTERVAL:
                                    xReader.Read();
                                    schedule.ScreenCaptureInterval = Convert.ToInt32(xReader.Value);
                                    break;

                                case SCHEDULE_MONDAY:
                                    xReader.Read();
                                    schedule.Monday = Convert.ToBoolean(xReader.Value);
                                    break;

                                case SCHEDULE_TUESDAY:
                                    xReader.Read();
                                    schedule.Tuesday = Convert.ToBoolean(xReader.Value);
                                    break;

                                case SCHEDULE_WEDNESDAY:
                                    xReader.Read();
                                    schedule.Wednesday = Convert.ToBoolean(xReader.Value);
                                    break;

                                case SCHEDULE_THURSDAY:
                                    xReader.Read();
                                    schedule.Thursday = Convert.ToBoolean(xReader.Value);
                                    break;

                                case SCHEDULE_FRIDAY:
                                    xReader.Read();
                                    schedule.Friday = Convert.ToBoolean(xReader.Value);
                                    break;

                                case SCHEDULE_SATURDAY:
                                    xReader.Read();
                                    schedule.Saturday = Convert.ToBoolean(xReader.Value);
                                    break;

                                case SCHEDULE_SUNDAY:
                                    xReader.Read();
                                    schedule.Sunday = Convert.ToBoolean(xReader.Value);
                                    break;

                                case SCHEDULE_NOTES:
                                    xReader.Read();
                                    schedule.Notes = xReader.Value;
                                    break;
                                }
                            }
                        }

                        xReader.Close();

                        // Change the data for each Schedule that's being loaded if we've detected that
                        // the XML document is from an older version of the application.
                        if (Settings.VersionManager.IsOldAppVersion(AppCodename, AppVersion))
                        {
                            Log.WriteDebugMessage("An old version of the schedules.xml file was detected. Attempting upgrade to new schema.");

                            Version v2300         = Settings.VersionManager.Versions.Get(Settings.CODENAME_BOOMBAYAH, Settings.CODEVERSION_BOOMBAYAH);
                            Version v2319         = Settings.VersionManager.Versions.Get(Settings.CODENAME_BOOMBAYAH, "2.3.1.9");
                            Version configVersion = Settings.VersionManager.Versions.Get(AppCodename, AppVersion);

                            if (v2300 != null && configVersion != null && configVersion.VersionNumber < v2300.VersionNumber)
                            {
                                Log.WriteDebugMessage("Dalek 2.2.4.6 or older detected");

                                // This is a new property for Schedule that was introduced in 2.3.0.0
                                // so any version before 2.3.0.0 needs to have it during an upgrade.
                                schedule.Active = true;
                            }

                            if (v2319 != null && configVersion != null && configVersion.VersionNumber < v2319.VersionNumber)
                            {
                                Log.WriteDebugMessage("Boombayah 2.3.1.8 or older detected");

                                // A new property for Schedule introduced in 2.3.1.9
                                schedule.ScreenCaptureInterval = Convert.ToInt32(Settings.User.GetByKey("ScreenCaptureInterval", DefaultSettings.ScreenCaptureInterval).Value);
                            }
                        }

                        if (!string.IsNullOrEmpty(schedule.Name))
                        {
                            Add(schedule);
                        }
                    }

                    if (Settings.VersionManager.IsOldAppVersion(AppCodename, AppVersion))
                    {
                        Log.WriteDebugMessage("Schedules file detected as an old version");
                        SaveToXmlFile();
                    }
                }
                else
                {
                    Log.WriteDebugMessage("WARNING: Unable to load schedules");

                    // If we can't find the schedules.xml file we'll need to have a "Special Schedule" schedule created to be compatible with old commands like -startat and -stopat.
                    Log.WriteDebugMessage("Creating default Special Schedule for use with command line arguments such as -startat and -stopat");

                    DateTime dtNow = DateTime.Now;

                    Schedule specialSchedule = new Schedule()
                    {
                        Name                  = SpecialScheduleName,
                        Active                = false,
                        ModeOneTime           = true,
                        ModePeriod            = false,
                        CaptureAt             = dtNow,
                        StartAt               = dtNow,
                        StopAt                = dtNow,
                        ScreenCaptureInterval = DefaultSettings.ScreenCaptureInterval,
                        Notes                 = "This schedule is used for the command line arguments -captureat, -startat, and -stopat."
                    };

                    if (Settings.VersionManager != null && Settings.VersionManager.OldUserSettings != null)
                    {
                        // If we're importing the schedule settings from a previous version of Auto Screen Capture we'll need to update the "Special Schedule" and enable it.
                        SettingCollection oldUserSettings = Settings.VersionManager.OldUserSettings;

                        bool captureStartAt = Convert.ToBoolean(oldUserSettings.GetByKey("BoolCaptureStartAt", DefaultSettings.BoolCaptureStartAt).Value);
                        bool captureStopAt  = Convert.ToBoolean(oldUserSettings.GetByKey("BoolCaptureStopAt", DefaultSettings.BoolCaptureStopAt).Value);

                        DateTime dtStartAt = Convert.ToDateTime(oldUserSettings.GetByKey("DateTimeCaptureStartAt", DefaultSettings.DateTimeCaptureStartAt).Value);
                        DateTime dtStopAt  = Convert.ToDateTime(oldUserSettings.GetByKey("DateTimeCaptureStopAt", DefaultSettings.DateTimeCaptureStopAt).Value);

                        // Days
                        bool captureOnTheseDays = Convert.ToBoolean(oldUserSettings.GetByKey("BoolCaptureOnTheseDays", DefaultSettings.BoolCaptureOnTheseDays).Value);
                        bool sunday             = Convert.ToBoolean(oldUserSettings.GetByKey("BoolCaptureOnSunday", DefaultSettings.BoolCaptureOnSunday).Value);
                        bool monday             = Convert.ToBoolean(oldUserSettings.GetByKey("BoolCaptureOnMonday", DefaultSettings.BoolCaptureOnMonday).Value);
                        bool tuesday            = Convert.ToBoolean(oldUserSettings.GetByKey("BoolCaptureOnTuesday", DefaultSettings.BoolCaptureOnTuesday).Value);
                        bool wednesday          = Convert.ToBoolean(oldUserSettings.GetByKey("BoolCaptureOnWednesday", DefaultSettings.BoolCaptureOnWednesday).Value);
                        bool thursday           = Convert.ToBoolean(oldUserSettings.GetByKey("BoolCaptureOnThursday", DefaultSettings.BoolCaptureOnThursday).Value);
                        bool friday             = Convert.ToBoolean(oldUserSettings.GetByKey("BoolCaptureOnFriday", DefaultSettings.BoolCaptureOnFriday).Value);
                        bool saturday           = Convert.ToBoolean(oldUserSettings.GetByKey("BoolCaptureOnSaturday", DefaultSettings.BoolCaptureOnSaturday).Value);

                        specialSchedule.ModeOneTime = false;
                        specialSchedule.ModePeriod  = true;

                        if (captureStartAt)
                        {
                            specialSchedule.Active  = true;
                            specialSchedule.StartAt = dtStartAt;
                        }

                        if (captureStopAt)
                        {
                            specialSchedule.Active = true;
                            specialSchedule.StopAt = dtStopAt;
                        }

                        if (captureOnTheseDays)
                        {
                            specialSchedule.Sunday    = sunday;
                            specialSchedule.Monday    = monday;
                            specialSchedule.Tuesday   = tuesday;
                            specialSchedule.Wednesday = wednesday;
                            specialSchedule.Thursday  = thursday;
                            specialSchedule.Friday    = friday;
                            specialSchedule.Saturday  = saturday;
                        }
                    }

                    Add(specialSchedule);

                    SaveToXmlFile();
                }

                return(true);
            }
            catch (Exception ex)
            {
                Log.WriteExceptionMessage("ScheduleCollection::LoadXmlFileAndAddSchedules", ex);

                return(false);
            }
        }
Ejemplo n.º 3
0
        private static void CheckAndCreateFiles()
        {
            if (string.IsNullOrEmpty(FileSystem.CommandFile))
            {
                FileSystem.CommandFile = FileSystem.DefaultCommandFile;

                FileSystem.AppendToFile(FileSystem.ConfigFile, "\nCommandFile=" + FileSystem.DefaultCommandFile);

                if (!FileSystem.FileExists(FileSystem.DefaultCommandFile))
                {
                    FileSystem.CreateFile(FileSystem.DefaultCommandFile);
                }
            }

            if (string.IsNullOrEmpty(FileSystem.ApplicationSettingsFile))
            {
                FileSystem.ApplicationSettingsFile = FileSystem.DefaultApplicationSettingsFile;

                FileSystem.AppendToFile(FileSystem.ConfigFile, "\nApplicationSettingsFile=" + FileSystem.DefaultApplicationSettingsFile);

                if (!FileSystem.DirectoryExists(FileSystem.DefaultSettingsFolder))
                {
                    FileSystem.CreateDirectory(FileSystem.DefaultSettingsFolder);
                }

                SettingCollection applicationSettingsCollection = new SettingCollection
                {
                    Filepath = FileSystem.ApplicationSettingsFile
                };

                applicationSettingsCollection.Save();
            }

            if (string.IsNullOrEmpty(FileSystem.UserSettingsFile))
            {
                FileSystem.UserSettingsFile = FileSystem.DefaultUserSettingsFile;

                FileSystem.AppendToFile(FileSystem.ConfigFile, "\nUserSettingsFile=" + FileSystem.DefaultUserSettingsFile);

                if (!FileSystem.DirectoryExists(FileSystem.DefaultSettingsFolder))
                {
                    FileSystem.CreateDirectory(FileSystem.DefaultSettingsFolder);
                }

                SettingCollection userSettingsCollection = new SettingCollection
                {
                    Filepath = FileSystem.ApplicationSettingsFile
                };

                userSettingsCollection.Save();
            }

            if (string.IsNullOrEmpty(FileSystem.ScreenshotsFile))
            {
                ImageFormatCollection imageFormatCollection = new ImageFormatCollection();
                ScreenCollection      screenCollection      = new ScreenCollection();

                ScreenshotCollection screenshotCollection = new ScreenshotCollection(imageFormatCollection, screenCollection);
                screenshotCollection.SaveToXmlFile(0);
            }

            if (string.IsNullOrEmpty(FileSystem.EditorsFile))
            {
                // Loading the editor collection will automatically create the default editors and add them to the collection.
                EditorCollection editorCollection = new EditorCollection();
                editorCollection.LoadXmlFileAndAddEditors();
            }

            if (string.IsNullOrEmpty(FileSystem.RegionsFile))
            {
                RegionCollection regionCollection = new RegionCollection();
                regionCollection.SaveToXmlFile();
            }

            if (string.IsNullOrEmpty(FileSystem.ScreensFile))
            {
                // Loading the screen collection will automatically create the available screens and add them to the collection.
                ScreenCollection screenCollection = new ScreenCollection();
                screenCollection.LoadXmlFileAndAddScreens(new ImageFormatCollection());
            }

            if (string.IsNullOrEmpty(FileSystem.TriggersFile))
            {
                // Loading triggers will automatically create the default triggers and add them to the collection.
                TriggerCollection triggerCollection = new TriggerCollection();
                triggerCollection.LoadXmlFileAndAddTriggers();
            }

            if (string.IsNullOrEmpty(FileSystem.TagsFile))
            {
                // Loading tags will automatically create the default tags and add them to the collection.
                TagCollection tagCollection = new TagCollection();
                tagCollection.LoadXmlFileAndAddTags();
            }

            if (string.IsNullOrEmpty(FileSystem.SchedulesFile))
            {
                // Loading schedules will automatically create the default schedules and add them to the collection.
                ScheduleCollection scheduleCollection = new ScheduleCollection();
                scheduleCollection.LoadXmlFileAndAddSchedules();
            }
        }
Ejemplo n.º 4
0
        public static void Initialize()
        {
            _versionCollection = new VersionCollection();

            // This version.
            _versionCollection.Add(new Version(ApplicationCodename, ApplicationVersion, isCurrentVersion: true));

            // Older versions should be listed here.
            _versionCollection.Add(new Version("Clara", "2.1.8.2"));

            Application          = new SettingCollection();
            Application.Filepath = FileSystem.SettingsFolder + FileSystem.ApplicationSettingsFile;

            User          = new SettingCollection();
            User.Filepath = FileSystem.SettingsFolder + FileSystem.UserSettingsFile;

            // Construct the version manager using the version collection and setting collection (containing the user's settings) we just prepared.
            VersionManager = new VersionManager(_versionCollection, User);

            if (!Directory.Exists(FileSystem.SettingsFolder))
            {
                Directory.CreateDirectory(FileSystem.SettingsFolder);
            }

            if (Application != null)
            {
                if (File.Exists(Application.Filepath))
                {
                    Application.Load();

                    Application.GetByKey("Name", defaultValue: Settings.ApplicationName).Value       = ApplicationName;
                    Application.GetByKey("Version", defaultValue: Settings.ApplicationVersion).Value = ApplicationVersion;

                    Application.Save();
                }
                else
                {
                    Application.Add(new Setting("Name", ApplicationName));
                    Application.Add(new Setting("Version", ApplicationVersion));
                    Application.Add(new Setting("DebugMode", false));

                    Application.Save();
                }
            }

            if (User != null && !File.Exists(User.Filepath))
            {
                User.Add(new Setting("IntScreenCaptureInterval", 60000));
                User.Add(new Setting("IntCaptureLimit", 0));
                User.Add(new Setting("BoolCaptureLimit", false));
                User.Add(new Setting("BoolTakeInitialScreenshot", false));
                User.Add(new Setting("BoolShowSystemTrayIcon", true));
                User.Add(new Setting("BoolCaptureStopAt", false));
                User.Add(new Setting("BoolCaptureStartAt", false));
                User.Add(new Setting("BoolCaptureOnSunday", false));
                User.Add(new Setting("BoolCaptureOnMonday", false));
                User.Add(new Setting("BoolCaptureOnTuesday", false));
                User.Add(new Setting("BoolCaptureOnWednesday", false));
                User.Add(new Setting("BoolCaptureOnThursday", false));
                User.Add(new Setting("BoolCaptureOnFriday", false));
                User.Add(new Setting("BoolCaptureOnSaturday", false));
                User.Add(new Setting("BoolCaptureOnTheseDays", false));
                User.Add(new Setting("DateTimeCaptureStopAtValue", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 0, 0)));
                User.Add(new Setting("DateTimeCaptureStartAtValue", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 0, 0)));
                User.Add(new Setting("BoolLockScreenCaptureSession", false));
                User.Add(new Setting("StringPassphrase", string.Empty));
                User.Add(new Setting("IntKeepScreenshotsForDays", 30));
                User.Add(new Setting("StringScreenshotLabel", string.Empty));

                User.Save();
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new version collection and populates it with all the various versions of the application.
        /// </summary>
        public static void Initialize()
        {
            _versionCollection = new VersionCollection
            {
                // This version.
                new Version(ApplicationCodename, ApplicationVersion, isCurrentVersion: true),

                // Older versions should be listed here.
                // WARNING: Never have any of the individual numbers go beyond 9 unless you want to break the upgrade system! This was an issue introduced in 2.2.0.10.
                new Version(CODENAME_CLARA, "2.1.8.2"),     // "Clara"; the last version in the 2.1 "macro" series. This includes the large user.xml file fix (2.1.7.9), "the handle is invalid" fix when Windows is locked (2.1.8.0), and the removal of the "start when Windows starts" feature (2.1.8.1); because anti-virus software falsely flags the application as a virus if we do that.
                new Version(CODENAME_DALEK, "2.2.0.0"),     // "Dalek"; support for unlimited number of screens. This was a huge release with the most commits ever in the application's history.
                new Version(CODENAME_DALEK, "2.2.0.1"),     // Fixed bug with empty window title which resulted in image files remaining after cleanup.
                new Version(CODENAME_DALEK, "2.2.0.2"),     // Application no longer stops current screen capture session if the directory root does not exist or the drive is not ready. This ensures that the current screen capture session will continue even if the drive being referenced is not available for some reason. Useful if you usually save screen images to an external drive but then disconnect from it and want to continue using the laptop's internal drive. Reintroduced the thread for saving screenshots and the lock on xDoc
                new Version(CODENAME_DALEK, "2.2.0.3"),     // Active window title is retrieved earlier for less chance in having different titles in different screenshot objects despite being in the same screen capture cycle. Some code cleanup. Documentation being added. Fixed a racing condition issue with KeepScreenshotsForDays and Save in ScreenshotCollection
                new Version(CODENAME_DALEK, "2.2.0.4"),     // Expanded scope of lock around screenshot list
                new Version(CODENAME_DALEK, "2.2.0.5"),     // Old screenshots are deleted and unsaved screenshots are saved within the same timer
                new Version(CODENAME_DALEK, "2.2.0.6"),     // An existing label can now be selected from a drop down list of available labels and applying a label to each screenshot is now determined by a checkbox value
                new Version(CODENAME_DALEK, "2.2.0.7"),     // Process Name introduced. Can now filter by an application's process name. Fixed upgrade path from old versions. Removed -debug command line argument. ScreenCapture Count is now reduced whenever there is no image available to capture or active window title is empty to hopefully make the count more accurate when using the count tag. Logging removed in TakeScreenshot and ScreenCapture Save methods to save on disk space when DebugMode enabled
                new Version(CODENAME_DALEK, "2.2.0.8"),     // New macro tags for getting the name of the currently logged in user and the name of the machine being used
                new Version(CODENAME_DALEK, "2.2.0.9"),     // Fixed upgrade path from older versions
                new Version(CODENAME_DALEK, "2.2.0.10"),    // Fixed bug with count value when display is not available
                new Version(CODENAME_DALEK, "2.2.0.11"),    // The %screen% tag has been re-introduced to represent the screen number. Fixed bug with taskbar not being captured. Fixed bug with JPEG quality and resolution ratio
                new Version(CODENAME_DALEK, "2.2.0.12"),    // Fixed bug with JPEG quality
                new Version(CODENAME_DALEK, "2.2.0.13"),    // Fixed null reference error when multiple application instances are started.
                new Version(CODENAME_DALEK, "2.2.0.14"),    // Introduced a new tag that gets the title of the active window. Also added a new method method in MacroParser that strips away characters that are invalid in Windows filenames (except for the backslash character since we use that for the directory path).
                new Version(CODENAME_DALEK, "2.2.0.15"),    // Strip out backslash if it's in the active window title.
                new Version(CODENAME_DALEK, "2.2.0.16"),    // Maintenance timer is turned on when interface is hidden and turned on when interface is shown.
                new Version(CODENAME_DALEK, "2.2.0.17"),    // Replaced -lock command line argument with -passphrase and added logic around hashing the passphrase given from the command line.
                new Version(CODENAME_DALEK, "2.2.0.18"),    // Performance improvements when saving screenshot references to screenshots.xml file.
                new Version(CODENAME_DALEK, "2.2.0.19"),    // Fixing system tray icon messages when mouse hovers over icon during maintenance. Also attempting to fix bug with collection being modified when browsing screenshots.
                new Version(CODENAME_DALEK, "2.2.0.20"),    // Tab pages now auto-scroll.
                new Version(CODENAME_DALEK, "2.2.0.21"),    // Configure drop down menu finished.
                new Version(CODENAME_DALEK, "2.2.0.22"),    // Fixed scheduled start time when running from command line.
                new Version(CODENAME_DALEK, "2.2.1.0"),     // Logging is now an application setting and DebugMode has become verbose logging. I've also fixed a few issues when running -config from the command line.
                new Version(CODENAME_DALEK, "2.2.1.1"),     // You can now add Batch Scripts, PowerShell Scripts, and any type of file for an Editor. Also removed the "Show system tray icon" option.
                new Version(CODENAME_DALEK, "2.2.1.2"),     // Fixed a bug with saving passphrase and hiding system tray icon during command line execution.
                new Version(CODENAME_DALEK, "2.2.2.0"),     // Completed work on Email Screenshot. Also included EmailScreenshot action for Triggers and added confirmation dialog boxes when emailing a screenshot from the interface and removing a screen or region. Email icon image added to Email button.
                new Version(CODENAME_DALEK, "2.2.2.1"),     // Fixed a few bugs.
                new Version(CODENAME_DALEK, "2.2.2.2"),     // Fixed bug with passphrase hash that was being hashed through old version detection by accident.
                new Version(CODENAME_DALEK, "2.2.2.3"),     // Moved default location of autoscreen.conf file.
                new Version(CODENAME_DALEK, "2.2.2.4"),     // Macro tags %machine% and %user% can now be used in folder paths and all paths of the autoscreen.conf file.
                new Version(CODENAME_DALEK, "2.2.2.5"),     // Fixed bug with upgrade system.
                new Version(CODENAME_DALEK, "2.2.2.6"),     // Fixed upgrade system. For real this time.
                new Version(CODENAME_DALEK, "2.2.2.7"),     // Make sure we do not check the drive information if the path is a shared network path.
                new Version(CODENAME_DALEK, "2.2.2.8"),     // Fixed an issue with displaying a screenshot preview.
                new Version(CODENAME_DALEK, "2.2.2.9"),     // Double click system tray icon to show or hide interface. Fixed issue with having backslash characters in name and any invalid Windows characters in path.
                new Version(CODENAME_DALEK, "2.2.3.0"),     // Apply Label system tray icon menu lists available labels.
                new Version(CODENAME_DALEK, "2.2.3.1"),     // Apply Label is made invisible when screen capture session is locked. Fixed bug with parsing command line arguments.
                new Version(CODENAME_DALEK, "2.2.3.2"),     // Apply Label fixed to show labels whenever the system tray icon menu is opened.
                new Version(CODENAME_DALEK, "2.2.4.6"),     // System tray icon turns green when screen capture session is running. Tags are now user-defined and have their own module.
                new Version(CODENAME_DALEK, "2.2.5.0"),     // A version that was never released. This was to make startup speed faster but major features implemented for the application (such as Schedules and controlling a running instance of the application from the command line) deserved 2.2.5.0 to become 2.3.0.0! Boombayah!
                new Version(CODENAME_BOOMBAYAH, "2.3.0.0"), // Faster startup, commands can be issued to a running instance, multiple schedules, more trigger conditions and trigger actions, and help tips in the help bar.
                new Version(CODENAME_BOOMBAYAH, "2.3.0.1"), // Fixed bug with FilenameLengthLimit application setting.
                new Version(CODENAME_BOOMBAYAH, "2.3.0.2"), // Keyboard Shortcuts implemented.
                new Version(CODENAME_BOOMBAYAH, "2.3.0.3"), // Fixed bug when creating a new Trigger.
                new Version(CODENAME_BOOMBAYAH, "2.3.0.4"), // StopOnLowDiskError setting implemented.
                new Version(CODENAME_BOOMBAYAH, "2.3.0.5"), // Fixed bug with upgrade path. Changed target profile to be .NET 4 instead of .NET Client 4.
                new Version(CODENAME_BOOMBAYAH, "2.3.0.6"), // Fixed interface issues with Windows 10 DPI scaling.
                new Version(CODENAME_BOOMBAYAH, "2.3.0.7"), // Fixed bug with a timed Trigger that needed to reset the timer when changing the screen capture interval.
                new Version(CODENAME_BOOMBAYAH, "2.3.0.8"), // Fixed DPI Awareness OS Version check.
                new Version(CODENAME_BOOMBAYAH, "2.3.0.9"), // Removed font changes for DPI Awareness.
                new Version(CODENAME_BOOMBAYAH, "2.3.1.0"), // Truncates long file paths.
                new Version(CODENAME_BOOMBAYAH, "2.3.1.1"), // ActiveWindowTitleLengthLimit application setting implemented.
                new Version(CODENAME_BOOMBAYAH, "2.3.1.2"), // Snagit Editor introduced as a new default image editor if available.
                new Version(CODENAME_BOOMBAYAH, "2.3.1.3"), // Fixed bug with new Editor throwing null reference exception on changing its properties because Notes was null.
                new Version(CODENAME_BOOMBAYAH, "2.3.1.4"), // ExitOnError set to True by default.
                new Version(CODENAME_BOOMBAYAH, "2.3.1.5"), // Region Select / Auto Save implemented.
                new Version(CODENAME_BOOMBAYAH, "2.3.1.6"), // Region Select Edit implemented and fixed bug with ViewId for new Screens and Regions.
                new Version(CODENAME_BOOMBAYAH, "2.3.1.7"), // OptimizeScreenCapture implemented.
                new Version(CODENAME_BOOMBAYAH, "2.3.1.8"), // Region Select implemented for Regions.
                new Version(CODENAME_BOOMBAYAH, "2.3.1.9"), // Schedules can now have their own interval set for them separate from the main interval. Also fixed bug with screen capture duration info.
                new Version(CODENAME_BOOMBAYAH, "2.3.2.0"), // Region Select Auto Save region is created if the regions.xml file is not found so you can view screenshots taken with Region Select Auto Save.
                new Version(CODENAME_BOOMBAYAH, "2.3.2.1"), // Fixed bug with inactive schedules that should not perform any actions when inactive.
                new Version(CODENAME_BOOMBAYAH, "2.3.2.2"), // Information Window implemented.
                new Version(CODENAME_BOOMBAYAH, "2.3.2.3"), // Information Window renamed to Show Screen Capture Status
                new Version(CODENAME_BOOMBAYAH, "2.3.2.4"), // ListboxScreenshots sorted.
                new Version(CODENAME_BOOMBAYAH, "2.3.2.5"), // Macro tag expressions can now parse date time format.
                new Version(CODENAME_BOOMBAYAH, "2.3.2.6"), // "Time of Day" Tag is now "Time Range" Tag. Also implemented "Day/Time" Trigger.
                new Version(CODENAME_BOOMBAYAH, "2.3.2.7"), // Quarter Year tag implemented.
                new Version(CODENAME_BOOMBAYAH, "2.3.2.8"), // Changelog added to About Auto Screen Capture window. Fixed bug with hidden system tray icon so no notification balloon appears when system tray icon is hidden.
                new Version(CODENAME_BOOMBAYAH, "2.3.2.9")  // Application Focus implemented for Screen.
            };

            Application = new SettingCollection
            {
                Filepath = FileSystem.ApplicationSettingsFile
            };

            User = new SettingCollection
            {
                Filepath = FileSystem.UserSettingsFile
            };

            // Construct the version manager using the version collection and setting collection (containing the user's settings) we just prepared.
            VersionManager = new VersionManager(_versionCollection, User);

            if (Application != null && !string.IsNullOrEmpty(Application.Filepath))
            {
                if (FileSystem.FileExists(Application.Filepath))
                {
                    Application.Load();

                    Application.GetByKey("Name", DefaultSettings.ApplicationName).Value       = ApplicationName;
                    Application.GetByKey("Version", DefaultSettings.ApplicationVersion).Value = ApplicationVersion;

                    if (!Application.KeyExists("DebugMode"))
                    {
                        Application.Add(new Setting("DebugMode", DefaultSettings.DebugMode));
                    }

                    if (!Application.KeyExists("ExitOnError"))
                    {
                        Application.Add(new Setting("ExitOnError", DefaultSettings.ExitOnError));
                    }

                    if (!Application.KeyExists("Logging"))
                    {
                        Application.Add(new Setting("Logging", DefaultSettings.Logging));
                    }

                    if (!Application.KeyExists("EmailServerHost"))
                    {
                        Application.Add(new Setting("EmailServerHost", DefaultSettings.EmailServerHost));
                    }

                    if (!Application.KeyExists("EmailServerPort"))
                    {
                        Application.Add(new Setting("EmailServerPort", DefaultSettings.EmailServerPort));
                    }

                    if (!Application.KeyExists("EmailServerEnableSSL"))
                    {
                        Application.Add(new Setting("EmailServerEnableSSL", DefaultSettings.EmailServerEnableSSL));
                    }

                    if (!Application.KeyExists("EmailClientUsername"))
                    {
                        Application.Add(new Setting("EmailClientUsername", DefaultSettings.EmailClientUsername));
                    }

                    if (!Application.KeyExists("EmailClientPassword"))
                    {
                        Application.Add(new Setting("EmailClientPassword", DefaultSettings.EmailClientPassword));
                    }

                    if (!Application.KeyExists("EmailMessageFrom"))
                    {
                        Application.Add(new Setting("EmailMessageFrom", DefaultSettings.EmailMessageFrom));
                    }

                    if (!Application.KeyExists("EmailMessageTo"))
                    {
                        Application.Add(new Setting("EmailMessageTo", DefaultSettings.EmailMessageTo));
                    }

                    if (!Application.KeyExists("EmailMessageCC"))
                    {
                        Application.Add(new Setting("EmailMessageCC", DefaultSettings.EmailMessageCC));
                    }

                    if (!Application.KeyExists("EmailMessageBCC"))
                    {
                        Application.Add(new Setting("EmailMessageBCC", DefaultSettings.EmailMessageBCC));
                    }

                    if (!Application.KeyExists("EmailMessageSubject"))
                    {
                        Application.Add(new Setting("EmailMessageSubject", DefaultSettings.EmailMessageSubject));
                    }

                    if (!Application.KeyExists("EmailMessageBody"))
                    {
                        Application.Add(new Setting("EmailMessageBody", DefaultSettings.EmailMessageBody));
                    }

                    if (!Application.KeyExists("EmailPrompt"))
                    {
                        Application.Add(new Setting("EmailPrompt", DefaultSettings.EmailPrompt));
                    }

                    if (!Application.KeyExists("LowDiskPercentageThreshold"))
                    {
                        Application.Add(new Setting("LowDiskPercentageThreshold", DefaultSettings.LowDiskPercentageThreshold));
                    }

                    if (!Application.KeyExists("ScreenshotsLoadLimit"))
                    {
                        Application.Add(new Setting("ScreenshotsLoadLimit", DefaultSettings.ScreenshotsLoadLimit));
                    }

                    if (!Application.KeyExists("AutoStartFromCommandLine"))
                    {
                        Application.Add(new Setting("AutoStartFromCommandLine", DefaultSettings.AutoStartFromCommandLine));

                        // If this is a version before 2.3.0.0 then set this setting to true because
                        // starting a screen capture session was the old behaviour when running autoscreen.exe
                        // from the command line.
                        if (VersionManager.IsOldAppVersion(Application.AppCodename, Application.AppVersion))
                        {
                            Version v2300         = VersionManager.Versions.Get(CODENAME_BOOMBAYAH, "2.3.0.0");
                            Version configVersion = VersionManager.Versions.Get(Application.AppCodename, Application.AppVersion);

                            if (v2300 != null && configVersion != null && configVersion.VersionNumber < v2300.VersionNumber)
                            {
                                Application.GetByKey("AutoStartFromCommandLine", DefaultSettings.AutoStartFromCommandLine).Value = true;
                            }
                        }
                    }

                    if (!Application.KeyExists("ShowStartupError"))
                    {
                        Application.Add(new Setting("ShowStartupError", DefaultSettings.ShowStartupError));
                    }

                    if (!Application.KeyExists("FilepathLengthLimit"))
                    {
                        Application.Add(new Setting("FilepathLengthLimit", DefaultSettings.FilepathLengthLimit));
                    }

                    if (!Application.KeyExists("StopOnLowDiskError"))
                    {
                        Application.Add(new Setting("StopOnLowDiskError", DefaultSettings.StopOnLowDiskError));
                    }

                    if (!Application.KeyExists("ActiveWindowTitleLengthLimit"))
                    {
                        Application.Add(new Setting("ActiveWindowTitleLengthLimit", DefaultSettings.ActiveWindowTitleLengthLimit));
                    }

                    if (!Application.KeyExists("OptimizeScreenCapture"))
                    {
                        Application.Add(new Setting("OptimizeScreenCapture", DefaultSettings.OptimizeScreenCapture));
                    }
                }
                else
                {
                    Application.Add(new Setting("Name", ApplicationName));
                    Application.Add(new Setting("Version", ApplicationVersion));
                    Application.Add(new Setting("DebugMode", DefaultSettings.DebugMode));
                    Application.Add(new Setting("ExitOnError", DefaultSettings.ExitOnError));
                    Application.Add(new Setting("Logging", DefaultSettings.Logging));
                    Application.Add(new Setting("EmailServerHost", DefaultSettings.EmailServerHost));
                    Application.Add(new Setting("EmailServerPort", DefaultSettings.EmailServerPort));
                    Application.Add(new Setting("EmailServerEnableSSL", DefaultSettings.EmailServerEnableSSL));
                    Application.Add(new Setting("EmailClientUsername", DefaultSettings.EmailClientUsername));
                    Application.Add(new Setting("EmailClientPassword", DefaultSettings.EmailClientPassword));
                    Application.Add(new Setting("EmailMessageFrom", DefaultSettings.EmailMessageFrom));
                    Application.Add(new Setting("EmailMessageTo", DefaultSettings.EmailMessageTo));
                    Application.Add(new Setting("EmailMessageCC", DefaultSettings.EmailMessageCC));
                    Application.Add(new Setting("EmailMessageBCC", DefaultSettings.EmailMessageBCC));
                    Application.Add(new Setting("EmailMessageSubject", DefaultSettings.EmailMessageSubject));
                    Application.Add(new Setting("EmailMessageBody", DefaultSettings.EmailMessageBody));
                    Application.Add(new Setting("EmailPrompt", DefaultSettings.EmailPrompt));
                    Application.Add(new Setting("LowDiskPercentageThreshold", DefaultSettings.LowDiskPercentageThreshold));
                    Application.Add(new Setting("ScreenshotsLoadLimit", DefaultSettings.ScreenshotsLoadLimit));
                    Application.Add(new Setting("AutoStartFromCommandLine", DefaultSettings.AutoStartFromCommandLine));
                    Application.Add(new Setting("ShowStartupError", DefaultSettings.ShowStartupError));
                    Application.Add(new Setting("FilepathLengthLimit", DefaultSettings.FilepathLengthLimit));
                    Application.Add(new Setting("StopOnLowDiskError", DefaultSettings.StopOnLowDiskError));
                    Application.Add(new Setting("ActiveWindowTitleLengthLimit", DefaultSettings.ActiveWindowTitleLengthLimit));
                    Application.Add(new Setting("OptimizeScreenCapture", DefaultSettings.OptimizeScreenCapture));
                }

                Application.Save();
            }

            if (User != null && !string.IsNullOrEmpty(User.Filepath) && !FileSystem.FileExists(User.Filepath))
            {
                User.Add(new Setting("ScreenCaptureInterval", DefaultSettings.ScreenCaptureInterval));
                User.Add(new Setting("CaptureLimit", DefaultSettings.CaptureLimit));
                User.Add(new Setting("CaptureLimitCheck", DefaultSettings.CaptureLimitCheck));
                User.Add(new Setting("TakeInitialScreenshot", DefaultSettings.TakeInitialScreenshot));
                User.Add(new Setting("ShowSystemTrayIcon", DefaultSettings.ShowSystemTrayIcon));
                User.Add(new Setting("Passphrase", DefaultSettings.Passphrase));
                User.Add(new Setting("KeepScreenshotsForDays", DefaultSettings.KeepScreenshotsForDays));
                User.Add(new Setting("ScreenshotLabel", DefaultSettings.ScreenshotLabel));
                User.Add(new Setting("ApplyScreenshotLabel", DefaultSettings.ApplyScreenshotLabel));
                User.Add(new Setting("DefaultEditor", DefaultSettings.DefaultEditor));
                User.Add(new Setting("FirstRun", DefaultSettings.FirstRun));
                User.Add(new Setting("StartScreenCaptureCount", DefaultSettings.StartScreenCaptureCount));
                User.Add(new Setting("ActiveWindowTitleCaptureCheck", DefaultSettings.ActiveWindowTitleCaptureCheck));
                User.Add(new Setting("ActiveWindowTitleCaptureText", DefaultSettings.ActiveWindowTitleCaptureText));
                User.Add(new Setting("UseKeyboardShortcuts", DefaultSettings.UseKeyboardShortcuts));
                User.Add(new Setting("KeyboardShortcutStartScreenCaptureModifier1", DefaultSettings.KeyboardShortcutStartScreenCaptureModifier1));
                User.Add(new Setting("KeyboardShortcutStartScreenCaptureModifier2", DefaultSettings.KeyboardShortcutStartScreenCaptureModifier2));
                User.Add(new Setting("KeyboardShortcutStartScreenCaptureKey", DefaultSettings.KeyboardShortcutStartScreenCaptureKey));
                User.Add(new Setting("KeyboardShortcutStopScreenCaptureModifier1", DefaultSettings.KeyboardShortcutStopScreenCaptureModifier1));
                User.Add(new Setting("KeyboardShortcutStopScreenCaptureModifier2", DefaultSettings.KeyboardShortcutStopScreenCaptureModifier2));
                User.Add(new Setting("KeyboardShortcutStopScreenCaptureKey", DefaultSettings.KeyboardShortcutStopScreenCaptureKey));
                User.Add(new Setting("KeyboardShortcutCaptureNowArchiveModifier1", DefaultSettings.KeyboardShortcutCaptureNowArchiveModifier1));
                User.Add(new Setting("KeyboardShortcutCaptureNowArchiveModifier2", DefaultSettings.KeyboardShortcutCaptureNowArchiveModifier2));
                User.Add(new Setting("KeyboardShortcutCaptureNowArchiveKey", DefaultSettings.KeyboardShortcutCaptureNowArchiveKey));
                User.Add(new Setting("KeyboardShortcutCaptureNowEditModifier1", DefaultSettings.KeyboardShortcutCaptureNowEditModifier1));
                User.Add(new Setting("KeyboardShortcutCaptureNowEditModifier2", DefaultSettings.KeyboardShortcutCaptureNowEditModifier2));
                User.Add(new Setting("KeyboardShortcutCaptureNowEditKey", DefaultSettings.KeyboardShortcutCaptureNowEditKey));
                User.Add(new Setting("KeyboardShortcutRegionSelectClipboardModifier1", DefaultSettings.KeyboardShortcutRegionSelectClipboardModifier1));
                User.Add(new Setting("KeyboardShortcutRegionSelectClipboardModifier2", DefaultSettings.KeyboardShortcutRegionSelectClipboardModifier2));
                User.Add(new Setting("KeyboardShortcutRegionSelectClipboardKey", DefaultSettings.KeyboardShortcutRegionSelectClipboardKey));
                User.Add(new Setting("AutoSaveFolder", DefaultSettings.AutoSaveFolder));
                User.Add(new Setting("AutoSaveMacro", DefaultSettings.AutoSaveMacro));
                User.Add(new Setting("KeyboardShortcutRegionSelectAutoSaveModifier1", DefaultSettings.KeyboardShortcutRegionSelectAutoSaveModifier1));
                User.Add(new Setting("KeyboardShortcutRegionSelectAutoSaveModifier2", DefaultSettings.KeyboardShortcutRegionSelectAutoSaveModifier2));
                User.Add(new Setting("KeyboardShortcutRegionSelectAutoSaveKey", DefaultSettings.KeyboardShortcutRegionSelectAutoSaveKey));
                User.Add(new Setting("KeyboardShortcutRegionSelectEditModifier1", DefaultSettings.KeyboardShortcutRegionSelectEditModifier1));
                User.Add(new Setting("KeyboardShortcutRegionSelectEditModifier2", DefaultSettings.KeyboardShortcutRegionSelectEditModifier2));
                User.Add(new Setting("KeyboardShortcutRegionSelectEditKey", DefaultSettings.KeyboardShortcutRegionSelectEditKey));

                User.Save();
            }

            Log.DebugMode      = Convert.ToBoolean(Application.GetByKey("DebugMode", DefaultSettings.DebugMode).Value);
            Log.LoggingEnabled = Convert.ToBoolean(Application.GetByKey("Logging", DefaultSettings.Logging).Value);
        }
Ejemplo n.º 6
0
        public static void Initialize()
        {
            Application          = new SettingCollection();
            Application.Filepath = FileSystem.SettingsFolder + FileSystem.ApplicationSettingsFile;

            User          = new SettingCollection();
            User.Filepath = FileSystem.SettingsFolder + FileSystem.UserSettingsFile;

            if (!Directory.Exists(FileSystem.SettingsFolder))
            {
                Directory.CreateDirectory(FileSystem.SettingsFolder);
            }

            if (Application != null)
            {
                if (File.Exists(Application.Filepath))
                {
                    Application.Load();

                    Application.GetByKey("Name", defaultValue: Settings.ApplicationName).Value       = ApplicationName;
                    Application.GetByKey("Version", defaultValue: Settings.ApplicationVersion).Value = ApplicationVersion;

                    Application.Save();
                }
                else
                {
                    Application.Add(new Setting("Name", ApplicationName));
                    Application.Add(new Setting("Version", ApplicationVersion));
                    Application.Add(new Setting("DebugMode", false));

                    Application.Save();
                }
            }

            if (User != null)
            {
                if (File.Exists(User.Filepath))
                {
                    User.Load();
                }
                else
                {
                    User.Add(new Setting("ScheduleImageFormat", "JPEG"));
                    User.Add(new Setting("SlideSkip", 10));
                    User.Add(new Setting("CaptureLimit", 0));
                    User.Add(new Setting("ImageResolutionRatio", 100));
                    User.Add(new Setting("Interval", 60000));
                    User.Add(new Setting("SlideshowDelay", 1000));
                    User.Add(new Setting("SlideSkipCheck", false));
                    User.Add(new Setting("CaptureLimitCheck", false));
                    User.Add(new Setting("TakeInitialScreenshotCheck", false));
                    User.Add(new Setting("ShowSystemTrayIcon", true));
                    User.Add(new Setting("CaptureStopAtCheck", false));
                    User.Add(new Setting("CaptureStartAtCheck", false));
                    User.Add(new Setting("CaptureOnSundayCheck", false));
                    User.Add(new Setting("CaptureOnMondayCheck", false));
                    User.Add(new Setting("CaptureOnTuesdayCheck", false));
                    User.Add(new Setting("CaptureOnWednesdayCheck", false));
                    User.Add(new Setting("CaptureOnThursdayCheck", false));
                    User.Add(new Setting("CaptureOnFridayCheck", false));
                    User.Add(new Setting("CaptureOnSaturdayCheck", false));
                    User.Add(new Setting("CaptureOnTheseDaysCheck", false));
                    User.Add(new Setting("CaptureStopAtValue", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 0, 0)));
                    User.Add(new Setting("CaptureStartAtValue", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 0, 0)));
                    User.Add(new Setting("LockScreenCaptureSession", false));
                    User.Add(new Setting("StartButtonImageFormat", "JPEG"));
                    User.Add(new Setting("Passphrase", string.Empty));

                    User.Save();
                }
            }
        }
Ejemplo n.º 7
0
        public static void Initialize()
        {
            _versionCollection = new VersionCollection();

            // This version.
            _versionCollection.Add(new Version(ApplicationCodename, ApplicationVersion, isCurrentVersion: true));

            // Older versions should be listed here.
            _versionCollection.Add(new Version(CODENAME_CLARA, "2.1.8.2"));  // Last version that introduced the Macro concept
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.0"));  // Support for unlimited number of screens
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.1"));  // Fixed empty window title bug
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.2"));  // Continue screen capture session when drive not available
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.3"));  // Changes to how we save screenshots
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.4"));  // More changes to how we save screenshots
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.5"));  // Fixes the changes to how we save screenshots
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.6"));  // Can now select an existing label when applying a label
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.7"));  // Fixed upgrade path from old versions. Can now filter by Process Name
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.8"));  // Introduced %user% and %machine% macro tags
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.9"));  // Fixed upgrade path from older versions
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.10")); // Fixed bug with %count% tag value when display is not available
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.11")); // %screen% tag re-introduced
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.12")); // Fixed bug with JPEG quality
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.13")); // Fixed null reference when application starts at startup from Windows Startup folder
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.14")); // Introduced %title% tag
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.15")); // Strip out backslash if it's in the active window title
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.16")); // Stop timerPerformMaintenance when window is open and start it again when window is closed
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.17")); // Passphrase is now hashed
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.18")); // Performance improvement with writing screenshot references to screenshots.xml

            Application          = new SettingCollection();
            Application.Filepath = FileSystem.SettingsFolder + FileSystem.ApplicationSettingsFile;

            User          = new SettingCollection();
            User.Filepath = FileSystem.SettingsFolder + FileSystem.UserSettingsFile;

            // Construct the version manager using the version collection and setting collection (containing the user's settings) we just prepared.
            VersionManager = new VersionManager(_versionCollection, User);

            if (!Directory.Exists(FileSystem.SettingsFolder))
            {
                Directory.CreateDirectory(FileSystem.SettingsFolder);
            }

            if (Application != null)
            {
                if (File.Exists(Application.Filepath))
                {
                    Application.Load();

                    Application.GetByKey("Name", defaultValue: Settings.ApplicationName).Value       = ApplicationName;
                    Application.GetByKey("Version", defaultValue: Settings.ApplicationVersion).Value = ApplicationVersion;

                    Application.Save();
                }
                else
                {
                    Application.Add(new Setting("Name", ApplicationName));
                    Application.Add(new Setting("Version", ApplicationVersion));
                    Application.Add(new Setting("DebugMode", false));

                    Application.Save();
                }
            }

            if (User != null && !File.Exists(User.Filepath))
            {
                User.Add(new Setting("IntScreenCaptureInterval", 60000));
                User.Add(new Setting("IntCaptureLimit", 0));
                User.Add(new Setting("BoolCaptureLimit", false));
                User.Add(new Setting("BoolTakeInitialScreenshot", false));
                User.Add(new Setting("BoolShowSystemTrayIcon", true));
                User.Add(new Setting("BoolCaptureStopAt", false));
                User.Add(new Setting("BoolCaptureStartAt", false));
                User.Add(new Setting("BoolCaptureOnSunday", false));
                User.Add(new Setting("BoolCaptureOnMonday", false));
                User.Add(new Setting("BoolCaptureOnTuesday", false));
                User.Add(new Setting("BoolCaptureOnWednesday", false));
                User.Add(new Setting("BoolCaptureOnThursday", false));
                User.Add(new Setting("BoolCaptureOnFriday", false));
                User.Add(new Setting("BoolCaptureOnSaturday", false));
                User.Add(new Setting("BoolCaptureOnTheseDays", false));
                User.Add(new Setting("DateTimeCaptureStopAtValue", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 0, 0)));
                User.Add(new Setting("DateTimeCaptureStartAtValue", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 0, 0)));
                User.Add(new Setting("StringPassphrase", string.Empty));
                User.Add(new Setting("IntKeepScreenshotsForDays", 30));
                User.Add(new Setting("StringScreenshotLabel", string.Empty));
                User.Add(new Setting("BoolApplyScreenshotLabel", false));

                User.Save();
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        ///
        /// </summary>
        public static void Initialize()
        {
            _versionCollection = new VersionCollection();

            // This version.
            _versionCollection.Add(new Version(ApplicationCodename, ApplicationVersion, isCurrentVersion: true));

            // Older versions should be listed here.
            // WARNING: Never have any of the individual numbers go beyond 9 unless you want to break the upgrade system! This was an issue introduced in 2.2.0.10.
            _versionCollection.Add(new Version(CODENAME_CLARA, "2.1.8.2"));  // "Clara"; the last version in the 2.1 "macro" series. This includes the large user.xml file fix (2.1.7.9), "the handle is invalid" fix when Windows is locked (2.1.8.0), and the removal of the "start when Windows starts" feature (2.1.8.1); because anti-virus software falsely flags the application as a virus if we do that.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.0"));  // "Dalek"; support for unlimited number of screens. This was a huge release with the most commits ever in the application's history.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.1"));  // Fixed bug with empty window title which resulted in image files remaining after cleanup.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.2"));  // Application no longer stops current screen capture session if the directory root does not exist or the drive is not ready. This ensures that the current screen capture session will continue even if the drive being referenced is not available for some reason. Useful if you usually save screen images to an external drive but then disconnect from it and want to continue using the laptop's internal drive. Reintroduced the thread for saving screenshots and the lock on xDoc
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.3"));  // Active window title is retrieved earlier for less chance in having different titles in different screenshot objects despite being in the same screen capture cycle. Some code cleanup. Documentation being added. Fixed a racing condition issue with KeepScreenshotsForDays and Save in ScreenshotCollection
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.4"));  // Expanded scope of lock around screenshot list
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.5"));  // Old screenshots are deleted and unsaved screenshots are saved within the same timer
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.6"));  // An existing label can now be selected from a drop down list of available labels and applying a label to each screenshot is now determined by a checkbox value
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.7"));  // Process Name introduced. Can now filter by an application's process name. Fixed upgrade path from old versions. Removed -debug command line argument. ScreenCapture Count is now reduced whenever there is no image available to capture or active window title is empty to hopefully make the count more accurate when using the count tag. Logging removed in TakeScreenshot and ScreenCapture Save methods to save on disk space when DebugMode enabled
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.8"));  // New macro tags for getting the name of the currently logged in user and the name of the machine being used
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.9"));  // Fixed upgrade path from older versions
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.10")); // Fixed bug with count value when display is not available
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.11")); // The %screen% tag has been re-introduced to represent the screen number. Fixed bug with taskbar not being captured. Fixed bug with JPEG quality and resolution ratio
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.12")); // Fixed bug with JPEG quality
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.13")); // Fixed null reference error when multiple application instances are started.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.14")); // Introduced a new tag that gets the title of the active window. Also added a new method method in MacroParser that strips away characters that are invalid in Windows filenames (except for the backslash character since we use that for the directory path).
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.15")); // Strip out backslash if it's in the active window title.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.16")); // Maintenance timer is turned on when interface is hidden and turned on when interface is shown.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.17")); // Replaced -lock command line argument with -passphrase and added logic around hashing the passphrase given from the command line.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.18")); // Performance improvements when saving screenshot references to screenshots.xml file.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.19")); // Fixing system tray icon messages when mouse hovers over icon during maintenance. Also attempting to fix bug with collection being modified when browsing screenshots.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.20")); // Tab pages now auto-scroll.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.21")); // Configure drop down menu finished.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.0.22")); // Fixed scheduled start time when running from command line.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.1.0"));  // Logging is now an application setting and DebugMode has become verbose logging. I've also fixed a few issues when running -config from the command line.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.1.1"));  // You can now add Batch Scripts, PowerShell Scripts, and any type of file for an Editor. Also removed the "Show system tray icon" option.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.1.2"));  // Fixed a bug with saving passphrase and hiding system tray icon during command line execution.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.2.0"));  // Completed work on Email Screenshot. Also included EmailScreenshot action for Triggers and added confirmation dialog boxes when emailing a screenshot from the interface and removing a screen or region. Email icon image added to Email button.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.2.1"));  // Fixed a few bugs.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.2.2"));  // Fixed bug with passphrase hash that was being hashed through old version detection by accident.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.2.3"));  // Moved default location of autoscreen.conf file.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.2.4"));  // Macro tags %machine% and %user% can now be used in folder paths and all paths of the autoscreen.conf file.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.2.5"));  // Fixed bug with upgrade system.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.2.6"));  // Fixed upgrade system. For real this time.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.2.7"));  // Make sure we do not check the drive information if the path is a shared network path.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.2.8"));  // Fixed an issue with displaying a screenshot preview.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.2.9"));  // Double click system tray icon to show or hide interface. Fixed issue with having backslash characters in name and any invalid Windows characters in path.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.3.0"));  // Apply Label system tray icon menu lists available labels.
            _versionCollection.Add(new Version(CODENAME_DALEK, "2.2.3.1"));  // Apply Label is made invisible when screen capture session is locked. Fixed bug with parsing command line arguments.

            Application = new SettingCollection
            {
                Filepath = FileSystem.ApplicationSettingsFile
            };

            User = new SettingCollection
            {
                Filepath = FileSystem.UserSettingsFile
            };

            // Construct the version manager using the version collection and setting collection (containing the user's settings) we just prepared.
            VersionManager = new VersionManager(_versionCollection, User);

            if (Application != null && !string.IsNullOrEmpty(Application.Filepath))
            {
                if (File.Exists(Application.Filepath))
                {
                    Application.Load();

                    Application.GetByKey("Name", defaultValue: Settings.ApplicationName).Value       = ApplicationName;
                    Application.GetByKey("Version", defaultValue: Settings.ApplicationVersion).Value = ApplicationVersion;

                    if (!Application.KeyExists("DebugMode"))
                    {
                        Application.Add(new Setting("DebugMode", false));
                    }

                    if (!Application.KeyExists("ExitOnError"))
                    {
                        Application.Add(new Setting("ExitOnError", false));
                    }

                    if (!Application.KeyExists("Logging"))
                    {
                        Application.Add(new Setting("Logging", false));
                    }

                    if (!Application.KeyExists("EmailServerHost"))
                    {
                        Application.Add(new Setting("EmailServerHost", string.Empty));
                    }

                    if (!Application.KeyExists("EmailServerPort"))
                    {
                        Application.Add(new Setting("EmailServerPort", 587));
                    }

                    if (!Application.KeyExists("EmailServerEnableSSL"))
                    {
                        Application.Add(new Setting("EmailServerEnableSSL", true));
                    }

                    if (!Application.KeyExists("EmailClientUsername"))
                    {
                        Application.Add(new Setting("EmailClientUsername", string.Empty));
                    }

                    if (!Application.KeyExists("EmailClientPassword"))
                    {
                        Application.Add(new Setting("EmailClientPassword", string.Empty));
                    }

                    if (!Application.KeyExists("EmailMessageFrom"))
                    {
                        Application.Add(new Setting("EmailMessageFrom", string.Empty));
                    }

                    if (!Application.KeyExists("EmailMessageTo"))
                    {
                        Application.Add(new Setting("EmailMessageTo", string.Empty));
                    }

                    if (!Application.KeyExists("EmailMessageCC"))
                    {
                        Application.Add(new Setting("EmailMessageCC", string.Empty));
                    }

                    if (!Application.KeyExists("EmailMessageBCC"))
                    {
                        Application.Add(new Setting("EmailMessageBCC", string.Empty));
                    }

                    if (!Application.KeyExists("EmailMessageSubject"))
                    {
                        Application.Add(new Setting("EmailMessageSubject", string.Empty));
                    }

                    if (!Application.KeyExists("EmailMessageBody"))
                    {
                        Application.Add(new Setting("EmailMessageBody", string.Empty));
                    }
                }
                else
                {
                    Application.Add(new Setting("Name", ApplicationName));
                    Application.Add(new Setting("Version", ApplicationVersion));
                    Application.Add(new Setting("DebugMode", false));
                    Application.Add(new Setting("Logging", false));
                    Application.Add(new Setting("EmailServerHost", string.Empty));
                    Application.Add(new Setting("EmailServerPort", 587));
                    Application.Add(new Setting("EmailServerEnableSSL", true));
                    Application.Add(new Setting("EmailClientUsername", string.Empty));
                    Application.Add(new Setting("EmailClientPassword", string.Empty));
                    Application.Add(new Setting("EmailMessageFrom", string.Empty));
                    Application.Add(new Setting("EmailMessageTo", string.Empty));
                    Application.Add(new Setting("EmailMessageCC", string.Empty));
                    Application.Add(new Setting("EmailMessageBCC", string.Empty));
                    Application.Add(new Setting("EmailMessageSubject", string.Empty));
                    Application.Add(new Setting("EmailMessageBody", string.Empty));
                }

                Application.Save();
            }

            if (User != null && !string.IsNullOrEmpty(User.Filepath) && !File.Exists(User.Filepath))
            {
                User.Add(new Setting("IntScreenCaptureInterval", 60000));
                User.Add(new Setting("IntCaptureLimit", 0));
                User.Add(new Setting("BoolCaptureLimit", false));
                User.Add(new Setting("BoolTakeInitialScreenshot", false));
                User.Add(new Setting("BoolShowSystemTrayIcon", true));
                User.Add(new Setting("BoolCaptureStopAt", false));
                User.Add(new Setting("BoolCaptureStartAt", false));
                User.Add(new Setting("BoolCaptureOnSunday", false));
                User.Add(new Setting("BoolCaptureOnMonday", false));
                User.Add(new Setting("BoolCaptureOnTuesday", false));
                User.Add(new Setting("BoolCaptureOnWednesday", false));
                User.Add(new Setting("BoolCaptureOnThursday", false));
                User.Add(new Setting("BoolCaptureOnFriday", false));
                User.Add(new Setting("BoolCaptureOnSaturday", false));
                User.Add(new Setting("BoolCaptureOnTheseDays", false));
                User.Add(new Setting("DateTimeCaptureStopAtValue", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 17, 0, 0)));
                User.Add(new Setting("DateTimeCaptureStartAtValue", new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, 8, 0, 0)));
                User.Add(new Setting("StringPassphrase", string.Empty));
                User.Add(new Setting("IntKeepScreenshotsForDays", 30));
                User.Add(new Setting("StringScreenshotLabel", string.Empty));
                User.Add(new Setting("BoolApplyScreenshotLabel", false));

                User.Save();
            }

            Log.DebugMode = Convert.ToBoolean(Application.GetByKey("DebugMode", defaultValue: false).Value);
            Log.Enabled   = Convert.ToBoolean(Application.GetByKey("Logging", defaultValue: false).Value);
        }