예제 #1
0
 void OnSettings(bool open, Toggl.Settings settings)
 {
     if (InvokeRequired)
     {
         Invoke((MethodInvoker) delegate { OnSettings(open, settings); });
         return;
     }
     remainOnTop = settings.OnTop;
     setWindowPos();
     timerIdleDetection.Enabled = settings.UseIdleDetection;
     setGlobalShortCutKeys();
 }
예제 #2
0
        private Toggl.Settings createSettingsFromUI()
        {
            var settings = new Toggl.Settings
            {
                #region general

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

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

                #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 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 settings;
        }
예제 #3
0
        void OnSettings(bool open, Toggl.Settings settings)
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker) delegate { OnSettings(open, settings); });
                return;
            }

            checkBoxUseSystemProxySettings.Checked = settings.AutodetectProxy;

            groupBoxProxySettings.Enabled  = settings.UseProxy;
            checkBoxUseProxy.Checked       = settings.UseProxy;
            textBoxProxyHost.Text          = settings.ProxyHost;
            textBoxProxyPort.Text          = settings.ProxyPort.ToString();
            textBoxProxyUsername.Text      = settings.ProxyUsername;
            textBoxProxyPassword.Text      = settings.ProxyPassword;
            checkBoxRecordTimeline.Checked = settings.RecordTimeline;
            checkBoxOnTop.Checked          = settings.OnTop;

            checkBoxIdleDetection.Checked = settings.UseIdleDetection;
            textBoxIdleMinutes.Text       = settings.IdleMinutes.ToString();
            textBoxIdleMinutes.Enabled    = checkBoxIdleDetection.Checked;

            checkBoxRemindToTrackTime.Checked = settings.Reminder;
            textBoxReminderMinutes.Text       = settings.ReminderMinutes.ToString();
            textBoxReminderMinutes.Enabled    = checkBoxRemindToTrackTime.Checked;

            // Load shortcuts
            try
            {
                string keyCode = Properties.Settings.Default.ShowKey;
                if (keyCode != "" && keyCode != null)
                {
                    TogglDesktop.ModifierKeys modifiers =
                        Properties.Settings.Default.ShowModifiers;
                    btnRecordShowHideShortcut.Text = keyEventToString(modifiers, keyCode);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Could not load show hotkey: ", e);
            }

            try
            {
                string keyCode = Properties.Settings.Default.StartKey;
                if (keyCode != "" && keyCode != null)
                {
                    TogglDesktop.ModifierKeys modifiers =
                        Properties.Settings.Default.StartModifiers;
                    btnRecordStartStopShortcut.Text = keyEventToString(modifiers, keyCode);
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Could not load start hotkey: ", e);
            }

            if (open)
            {
                Show();
                TopMost = true;
            }
        }
예제 #4
0
        private void buttonSave_Click(object sender, EventArgs e)
        {
            ulong port = 0;

            if (!ulong.TryParse(textBoxProxyPort.Text, out port))
            {
                port = 0;
            }

            ulong idleMinutes = 0;

            ulong.TryParse(textBoxIdleMinutes.Text, out idleMinutes);

            ulong reminderMinutes = 0;

            ulong.TryParse(textBoxReminderMinutes.Text, out reminderMinutes);

            Toggl.Settings settings = new Toggl.Settings();

            settings.AutodetectProxy = checkBoxUseSystemProxySettings.Checked;

            settings.UseProxy      = checkBoxUseProxy.Checked;
            settings.ProxyPort     = port;
            settings.ProxyHost     = textBoxProxyHost.Text;
            settings.ProxyUsername = textBoxProxyUsername.Text;
            settings.ProxyPassword = textBoxProxyPassword.Text;

            settings.OnTop = checkBoxOnTop.Checked;

            settings.Reminder        = checkBoxRemindToTrackTime.Checked;
            settings.ReminderMinutes = reminderMinutes;

            settings.UseIdleDetection = checkBoxIdleDetection.Checked;
            settings.IdleMinutes      = idleMinutes;

            settings.MenubarTimer = true;
            settings.DockIcon     = true;

            settings.RecordTimeline = checkBoxRecordTimeline.Checked;

            // Save shortcut keys

            if (btnRecordShowHideShortcut.Tag != null)
            {
                Utils.SetShortcutForShow((KeyEventArgs)btnRecordShowHideShortcut.Tag);
            }
            if (btnClearShowHideShortcut.Tag != null)
            {
                Utils.SetShortcutForShow(null);
            }

            if (btnRecordStartStopShortcut.Tag != null)
            {
                Utils.SetShortcutForStart((KeyEventArgs)btnRecordStartStopShortcut.Tag);
            }
            if (btnClearStartStopTimer.Tag != null)
            {
                Utils.SetShortcutForStart(null);
            }

            if (!Toggl.SetSettings(settings))
            {
                return;
            }

            Close();
        }