Example #1
0
        public void UpdateSettings(ISettingsCollection settings, IVersionControl versionControl)
        {
            //AppSettings
            settings.AppSettings.AlertWhenNotRunning   = AlertWhenIdle;
            settings.AppSettings.AlertTimeMilliseconds = AlertMinutes * 60 * 1000;
            settings.AppSettings.KeepTimersForDays     = KeepTimersForDays;
            settings.AppSettings.AutoUpdate            = AutoUpdate;
            settings.AppSettings.UsageTracking         = AllowTracking;
            settings.AppSettings.TargetLogPerDay       = new TimeSpan(TargetHoursPerDay, TargetMinutesPerDay, 0);
            settings.AppSettings.ExportDays            = WorkingDays.Where(x => x.IsChecked).Select(x => x.DayOfWeek).ToList();
            settings.AppSettings.StartOfWeek           = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), StartOfWeek, true);

            //UI Settings
            settings.UiSettings.Theme  = Theme.Name;
            settings.UiSettings.Accent = Accent.Name;
            if (versionControl.IsAutomatedDeploy)
            {
                if (StartOnBoot)
                {
                    var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "Gallifrey", $"{versionControl.AppName}.appref-ms");
                    registryKey.SetValue(versionControl.AppName, path);
                }
                else
                {
                    registryKey.DeleteValue(versionControl.AppName, false);
                }
            }

            //Jira Settings
            if (settings.JiraConnectionSettings.JiraUrl != JiraUrl ||
                settings.JiraConnectionSettings.JiraUsername != JiraUsername ||
                settings.JiraConnectionSettings.JiraPassword != JiraPassword)
            {
                JiraSettingsChanged = true;
            }
            else if (string.IsNullOrWhiteSpace(JiraUrl) || string.IsNullOrWhiteSpace(JiraUsername) || string.IsNullOrWhiteSpace(JiraPassword))
            {
                JiraSettingsChanged = true;
            }

            settings.JiraConnectionSettings.JiraUrl      = JiraUrl;
            settings.JiraConnectionSettings.JiraUsername = JiraUsername;
            settings.JiraConnectionSettings.JiraPassword = JiraPassword;

            //Export Settings
            settings.ExportSettings.ExportPrompt.OnAddIdle         = ExportPrompts.First(x => x.Key == "Idle").IsChecked;
            settings.ExportSettings.ExportPrompt.OnManualAdjust    = ExportPrompts.First(x => x.Key == "Manual").IsChecked;
            settings.ExportSettings.ExportPrompt.OnStop            = ExportPrompts.First(x => x.Key == "Stop").IsChecked;
            settings.ExportSettings.ExportPrompt.OnCreatePreloaded = ExportPrompts.First(x => x.Key == "Pre").IsChecked;
            settings.ExportSettings.ExportPromptAll       = ExportAll;
            settings.ExportSettings.DefaultRemainingValue = SelectedRemainingAdjustmentValue.Remaining;
            settings.ExportSettings.ExportCommentPrefix   = CommentPrefix;
            settings.ExportSettings.EmptyExportComment    = DefaultComment;
        }
Example #2
0
        public void UpdateSettings(ISettingsCollection settings)
        {
            //AppSettings
            settings.AppSettings.AlertWhenNotRunning   = AlertWhenIdle;
            settings.AppSettings.AlertTimeMilliseconds = AlertMinutes * 60 * 1000;
            settings.AppSettings.KeepTimersForDays     = KeepTimersForDays;
            settings.AppSettings.AutoUpdate            = AutoUpdate;
            settings.AppSettings.UsageTracking         = AllowTracking;
            settings.AppSettings.TargetLogPerDay       = new TimeSpan(TargetHoursPerDay, TargetMinutesPerDay, 0);
            settings.AppSettings.ExportDays            = WorkingDays.Where(x => x.IsChecked).Select(x => x.DayOfWeek);
            settings.AppSettings.StartOfWeek           = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), StartOfWeek, true);

            //UI Settings
            settings.UiSettings.Theme = Theme;

            //Jira Settings
            if (settings.JiraConnectionSettings.JiraUrl != JiraUrl ||
                settings.JiraConnectionSettings.JiraUsername != JiraUsername ||
                settings.JiraConnectionSettings.JiraPassword != JiraPassword)
            {
                JiraSettingsChanged = true;
            }

            settings.JiraConnectionSettings.JiraUrl      = JiraUrl;
            settings.JiraConnectionSettings.JiraUsername = JiraUsername;
            settings.JiraConnectionSettings.JiraPassword = JiraPassword;

            //Export Settings
            settings.ExportSettings.ExportPrompt.OnAddIdle         = ExportPrompts.First(x => x.Key == "Idle").IsChecked;
            settings.ExportSettings.ExportPrompt.OnManualAdjust    = ExportPrompts.First(x => x.Key == "Manual").IsChecked;
            settings.ExportSettings.ExportPrompt.OnStop            = ExportPrompts.First(x => x.Key == "Stop").IsChecked;
            settings.ExportSettings.ExportPrompt.OnCreatePreloaded = ExportPrompts.First(x => x.Key == "Pre").IsChecked;
            settings.ExportSettings.ExportPromptAll       = ExportAll;
            settings.ExportSettings.DefaultRemainingValue = SelectedRemainingAdjustmentValue.Remaining;
            settings.ExportSettings.ExportCommentPrefix   = CommentPrefix;
            settings.ExportSettings.EmptyExportComment    = DefaultComment;
        }
Example #3
0
        public void UpdateSettings(ISettingsCollection settings, IVersionControl versionControl)
        {
            //AppSettings
            settings.AppSettings.AlertWhenNotRunning           = AlertWhenIdle;
            settings.AppSettings.AlertTimeMilliseconds         = AlertWhenIdle ? (int)TimeSpan.FromMinutes((AlertMinutes ?? 1)).TotalMilliseconds : 0;
            settings.AppSettings.TrackIdleTime                 = TrackIdle;
            settings.AppSettings.IdleTimeThresholdMilliseconds = TrackIdle ? (int)TimeSpan.FromMinutes((TrackIdleThresholdMinutes ?? 1)).TotalMilliseconds : 0;
            settings.AppSettings.TrackLockTime                 = TrackLock;
            settings.AppSettings.LockTimeThresholdMilliseconds = TrackLock ? (int)TimeSpan.FromMinutes((TrackLockThresholdMinutes ?? 1)).TotalMilliseconds : 0;
            settings.AppSettings.KeepTimersForDays             = KeepTimersForDays ?? 7;
            settings.AppSettings.AutoUpdate      = AutoUpdate;
            settings.AppSettings.TargetLogPerDay = new TimeSpan(TargetHoursPerDay ?? 0, TargetMinutesPerDay ?? 0, 0);
            settings.AppSettings.ExportDays      = WorkingDays.Where(x => x.IsChecked).Select(x => x.DayOfWeek).ToList();
            settings.AppSettings.StartOfWeek     = (DayOfWeek)Enum.Parse(typeof(DayOfWeek), StartOfWeek, true);
            settings.AppSettings.DefaultTimers   = DefaultTimers.Split(',').SelectMany(x => x.Split(' ')).Where(x => !string.IsNullOrWhiteSpace(x)).ToList();

            if (settings.AppSettings.UsageTracking != AllowTracking)
            {
                settings.AppSettings.UsageTracking = AllowTracking;
                if (!AllowTracking)
                {
                    TrackingOptOut = true;
                }
            }

            //UI Settings
            settings.UiSettings.Theme  = Theme.Name;
            settings.UiSettings.Accent = Accent.Name;
            if (versionControl.IsAutomatedDeploy)
            {
                if (StartOnBoot)
                {
                    var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "Gallifrey", $"{versionControl.AppName}.appref-ms");
                    registryKey.SetValue(versionControl.AppName, path);
                }
                else
                {
                    registryKey.DeleteValue(versionControl.AppName, false);
                }
            }
            settings.UiSettings.TopMostOnFlyoutOpen = TopMostOnFlyoutOpen;

            //Jira Settings
            if (settings.JiraConnectionSettings.JiraUrl != JiraUrl ||
                settings.JiraConnectionSettings.JiraUsername != JiraUsername ||
                settings.JiraConnectionSettings.JiraPassword != JiraPassword ||
                settings.JiraConnectionSettings.UseTempo != UseTempo)
            {
                JiraSettingsChanged = true;
            }
            else if (string.IsNullOrWhiteSpace(JiraUrl) || string.IsNullOrWhiteSpace(JiraUsername) || string.IsNullOrWhiteSpace(JiraPassword))
            {
                JiraSettingsChanged = true;
            }

            settings.JiraConnectionSettings.JiraUrl      = JiraUrl;
            settings.JiraConnectionSettings.JiraUsername = JiraUsername;
            settings.JiraConnectionSettings.JiraPassword = JiraPassword;
            settings.JiraConnectionSettings.UseTempo     = UseTempo;

            //Export Settings
            settings.ExportSettings.ExportPrompt.OnAddIdle         = ExportPrompts.First(x => x.Key == "Locked").IsChecked&& !TrackingOnly;
            settings.ExportSettings.ExportPrompt.OnManualAdjust    = ExportPrompts.First(x => x.Key == "Manual").IsChecked&& !TrackingOnly;
            settings.ExportSettings.ExportPrompt.OnStop            = ExportPrompts.First(x => x.Key == "Stop").IsChecked&& !TrackingOnly;
            settings.ExportSettings.ExportPrompt.OnCreatePreloaded = ExportPrompts.First(x => x.Key == "Pre").IsChecked&& !TrackingOnly;
            settings.ExportSettings.ExportPromptAll       = ExportAll;
            settings.ExportSettings.DefaultRemainingValue = SelectedRemainingAdjustmentValue.Remaining;
            settings.ExportSettings.ExportCommentPrefix   = CommentPrefix;
            settings.ExportSettings.EmptyExportComment    = DefaultComment;
            settings.ExportSettings.TrackingOnly          = TrackingOnly;
        }