private Settings createSettingsFromUI()
        {
            var settings = new Toggl.TogglSettingsView
            {
                #region general

                UseIdleDetection = isChecked(this.idleDetectionCheckBox),
                IdleMinutes      = toULong(this.idleDetectionDurationTextBox.Text),

                RecordTimeline = isChecked(this.recordTimelineCheckBox),
                OnTop          = isChecked(this.onTopCheckBox),

                Pomodoro        = isChecked(this.enablePomodoroCheckBox),
                PomodoroMinutes = toULong(this.pomodoroTimerDuration.Text),

                #endregion

                #region proxy

                AutodetectProxy = isChecked(this.useSystemProxySettingsCheckBox),
                UseProxy        = isChecked(this.useProxyCheckBox),
                ProxyHost       = this.proxyHostTextBox.Text,
                ProxyPort       = toULong(this.proxyPortTextBox.Text),
                ProxyUsername   = this.proxyUsernameTextBox.Text,
                ProxyPassword   = this.proxyPasswordBox.Password,

                #endregion

                #region auto tracker

                Autotrack = isChecked(this.enableAutotrackerCheckbox),

                #endregion

                #region reminder

                Reminder        = isChecked(this.remindToTrackCheckBox),
                ReminderMinutes = toULong(this.remindToTrackIntervalTextBox.Text),
                RemindStarts    = this.reminderStartTimeTextBox.Text,
                RemindEnds      = this.reminderEndTimeTextBox.Text,

                RemindMon = isChecked(this.remindOnMondayTextBox),
                RemindTue = isChecked(this.remindOnTuesdayTextBox),
                RemindWed = isChecked(this.remindOnWednesdayTextBox),
                RemindThu = isChecked(this.remindOnThursdayTextBox),
                RemindFri = isChecked(this.remindOnFridayTextBox),
                RemindSat = isChecked(this.remindOnSaturdayTextBox),
                RemindSun = isChecked(this.remindOnSundayTextBox),

                #endregion
            };

            return(new Settings
            {
                TogglSettings = settings,
                DefaultProject = this.selectedDefaultProject,
                KeepEndTimeFixed = isChecked(this.keepEndTimeFixedCheckbox),
            });
        }
        private void onSettings(bool open, Toggl.TogglSettingsView settings)
        {
            if (this.TryBeginInvoke(this.onSettings, open, settings))
            {
                return;
            }

            this.setGlobalShortcutsFromSettings();
            this.idleDetectionTimer.IsEnabled = settings.UseIdleDetection;
            this.Topmost = settings.OnTop;
            this.SetManualMode(settings.ManualMode, true);
        }
Example #3
0
        void OnSettings(bool open, Toggl.TogglSettingsView settings)
        {
            if (this.TryBeginInvoke(this.OnSettings, open, settings))
            {
                return;
            }

            remainOnTop = settings.OnTop;
            setWindowPos();
            timerIdleDetection.Enabled = settings.UseIdleDetection;
            setGlobalShortCutKeys();
        }
Example #4
0
        private static HttpClientFactory HttpClientFactoryFromProxySettings(Toggl.TogglSettingsView settings)
        {
            var proxyHttpClientFactory = new ProxySupportedHttpClientFactory
            {
                UseProxy = settings.UseProxy
            };

            if (settings.AutodetectProxy)
            {
                proxyHttpClientFactory.Proxy = WebRequest.DefaultWebProxy;
            }
            else if (settings.UseProxy)
            {
                var proxy = new WebProxy(settings.ProxyHost + ":" + settings.ProxyPort, true);
                if (!string.IsNullOrEmpty(settings.ProxyUsername))
                {
                    proxy.Credentials = new NetworkCredential(settings.ProxyUsername, settings.ProxyPassword);
                }
                proxyHttpClientFactory.Proxy = proxy;
            }

            return(proxyHttpClientFactory);
        }
        private void onSettings(bool open, Toggl.TogglSettingsView settings)
        {
            if (this.TryBeginInvoke(this.onSettings, open, settings))
            {
                return;
            }

            if (this.isSaving)
            {
                return;
            }

            using (Performance.Measure("filling settings from OnSettings"))
            {
                this.updateUI(settings);
                this.selectDefaultProjectFromSettings();
            }

            if (open)
            {
                this.Show();
                this.Activate();
            }
        }
        private void updateUI(Toggl.TogglSettingsView settings)
        {
            #region general

            this.idleDetectionCheckBox.IsChecked   = settings.UseIdleDetection;
            this.idleDetectionDurationTextBox.Text = settings.IdleMinutes.ToString();

            this.enablePomodoroCheckBox.IsChecked = settings.Pomodoro;
            this.pomodoroTimerDuration.Text       = settings.PomodoroMinutes.ToString();

            this.recordTimelineCheckBox.IsChecked = settings.RecordTimeline;
            this.onTopCheckBox.IsChecked          = settings.OnTop;

            this.keepEndTimeFixedCheckbox.IsChecked = Toggl.GetKeepEndTimeFixed();

            #endregion

            #region proxy

            this.useNoProxyRadioButton.IsChecked          = true;
            this.useSystemProxySettingsCheckBox.IsChecked = settings.AutodetectProxy;
            this.useProxyCheckBox.IsChecked = settings.UseProxy;
            this.proxyHostTextBox.Text      = settings.ProxyHost;
            this.proxyPortTextBox.Text      = settings.ProxyPort.ToString();
            this.proxyUsernameTextBox.Text  = settings.ProxyUsername;
            this.proxyPasswordBox.Password  = settings.ProxyPassword;

            #endregion

            #region reminder

            this.remindToTrackCheckBox.IsChecked   = settings.Reminder;
            this.remindToTrackIntervalTextBox.Text = settings.ReminderMinutes.ToString();
            this.reminderStartTimeTextBox.Text     = settings.RemindStarts;
            this.reminderEndTimeTextBox.Text       = settings.RemindEnds;

            this.remindOnMondayTextBox.IsChecked    = settings.RemindMon;
            this.remindOnTuesdayTextBox.IsChecked   = settings.RemindTue;
            this.remindOnWednesdayTextBox.IsChecked = settings.RemindWed;
            this.remindOnThursdayTextBox.IsChecked  = settings.RemindThu;
            this.remindOnFridayTextBox.IsChecked    = settings.RemindFri;
            this.remindOnSaturdayTextBox.IsChecked  = settings.RemindSat;
            this.remindOnSundayTextBox.IsChecked    = settings.RemindSun;

            #endregion

            #region auto tracker

            this.enableAutotrackerCheckbox.IsChecked = settings.Autotrack;

            #endregion

            #region global shortcuts

            trySetHotKey(
                Toggl.GetKeyShow,
                Toggl.GetKeyModifierShow,
                this.showHideShortcutRecorder
                );
            trySetHotKey(
                Toggl.GetKeyStart,
                Toggl.GetKeyModifierStart,
                this.continueStopShortcutRecorder
                );

            this.shortcutErrorText.Text = "";

            #endregion
        }
        private Settings createSettingsFromUI()
        {
            var settings = new Toggl.TogglSettingsView
            {
                #region general

                UseIdleDetection = isChecked(this.idleDetectionCheckBox),
                IdleMinutes = toULong(this.idleDetectionDurationTextBox.Text),

                RecordTimeline = isChecked(this.recordTimelineCheckBox),
                OnTop = isChecked(this.onTopCheckBox),

                Pomodoro = isChecked(this.enablePomodoroCheckBox),
                PomodoroMinutes = toULong(this.pomodoroTimerDuration.Text),

                #endregion

                #region proxy

                AutodetectProxy = isChecked(this.useSystemProxySettingsCheckBox),
                UseProxy = isChecked(this.useProxyCheckBox),
                ProxyHost = this.proxyHostTextBox.Text,
                ProxyPort = toULong(this.proxyPortTextBox.Text),
                ProxyUsername = this.proxyUsernameTextBox.Text,
                ProxyPassword = this.proxyPasswordBox.Password,

                #endregion

                #region auto tracker

                Autotrack = isChecked(this.enableAutotrackerCheckbox),

                #endregion

                #region reminder

                Reminder = isChecked(this.remindToTrackCheckBox),
                ReminderMinutes = toULong(this.remindToTrackIntervalTextBox.Text),
                RemindStarts = this.reminderStartTimeTextBox.Text,
                RemindEnds = this.reminderEndTimeTextBox.Text,

                RemindMon = isChecked(this.remindOnMondayTextBox),
                RemindTue = isChecked(this.remindOnTuesdayTextBox),
                RemindWed = isChecked(this.remindOnWednesdayTextBox),
                RemindThu = isChecked(this.remindOnThursdayTextBox),
                RemindFri = isChecked(this.remindOnFridayTextBox),
                RemindSat = isChecked(this.remindOnSaturdayTextBox),
                RemindSun = isChecked(this.remindOnSundayTextBox),

                #endregion
            };

            return new Settings
            {
                TogglSettings = settings,
                DefaultProject = this.selectedDefaultProject,
                KeepEndTimeFixed = isChecked(this.keepEndTimeFixedCheckbox),
            };
        }
Example #8
0
 private void onSettings(bool open, Toggl.TogglSettingsView settings)
 {
     this.httpClientFactory = HttpClientFactoryFromProxySettings(settings);
 }