void OnSettings(bool open, Toggl.Settings settings)
 {
     if (InvokeRequired)
     {
         Invoke((MethodInvoker)delegate { OnSettings(open, settings); });
         return;
     }
     mustSaveProxySettings = false;
     mustSaveSettings = false;
     loading = true;
     try
     {
         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;
         checkBoxIdleDetection.Checked = settings.UseIdleDetection;
         checkBoxRecordTimeline.Checked = settings.RecordTimeline;
         checkBoxOnTop.Checked = settings.OnTop;
         checkBoxRemindToTrackTime.Checked = settings.Reminder;
     }
     finally
     {
         loading = false;
     }
     if (open)
     {
         Show();
         BringToFront();
     }
 }
Esempio n. 2
0
        private void onDisplayUpdateDownloadState(string version, Toggl.DownloadStatus status)
        {
            if (this.TryBeginInvoke(this.onDisplayUpdateDownloadState, version, status))
                return;

            string format;
            switch (status)
            {
                case Toggl.DownloadStatus.Started:
                {
                    format = "Downloading version {0}";
                    this.restartButton.Visibility = Visibility.Collapsed;
                    break;
                }
                case Toggl.DownloadStatus.Done:
                {
                    format = "Version {0} available,\nrestart Toggl Desktop to upgrade.";
                    this.restartButton.IsEnabled = true;
                    this.restartButton.Visibility = Visibility.Visible;
                    break;
                }
                default:
                    throw new ArgumentOutOfRangeException("status", status, null);
            }

            this.updateText.Text = string.Format(format, version);
            this.updateText.Visibility = Visibility.Visible;
        }
Esempio n. 3
0
        private void onOnlineState(Toggl.OnlineState state)
        {
            if (this.TryBeginInvoke(this.onOnlineState, state))
                return;

            this.onlineState = state;
            this.update();
        }
        private void onDisplaySyncState(Toggl.SyncState state)
        {
            if (this.TryBeginInvoke(this.onDisplaySyncState, state))
                return;

            this.syncState = state;
            this.update();
        }
        internal void Setup(Toggl.TimeEntry item)
        {
            TimeEntry = item;

            labelDescription.Text = TimeEntry.Description;
            labelProject.ForeColor = ColorTranslator.FromHtml(TimeEntry.Color);
            labelProject.Text = TimeEntry.ProjectAndTaskLabel;
            labelDuration.Text = TimeEntry.Duration;
            labelBillable.Visible = TimeEntry.Billable;
            labelTag.Visible = (TimeEntry.Tags != null && TimeEntry.Tags.Length > 0);
        }
 public void PopupInput(Toggl.TimeEntry te)
 {
     if (te.GUID == editForm.GUID) {
     editForm.ClosePopup();
     return;
     }
     editForm.reset();
     setEditFormLocation();
     editForm.GUID = te.GUID;
     editForm.Show();
     timeEntryListViewController.HighlightEntry(te.GUID);
 }
Esempio n. 7
0
        private void onRunningTimerState(Toggl.TogglTimeEntryView te)
        {
            if (this.TryBeginInvoke(this.onRunningTimerState, te))
                return;

            using (Performance.Measure("timer responding to OnRunningTimerState"))
            {
                this.runningTimeEntry = te;
                this.setUIToRunningState(te);
                this.secondsTimer.IsEnabled = true;
            }
        }
        private void onTimeEntryEditor(bool open, Toggl.TogglTimeEntryView te, string focusedFieldName)
        {
            if (this.TryBeginInvoke(this.onTimeEntryEditor, open, te, focusedFieldName))
                return;

            using (Performance.Measure("highlighting cell in list"))
            {
                this.highlightEntry(te.GUID);
                if (open)
                {
                    this.Entries.HighlightKeyboard(te.GUID);
                }
            }
        }
        void OnUpdate(bool open, Toggl.Update view)
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker)delegate { OnUpdate(open, view); });
                return;
            }

            updateURL = view.URL;

            comboBoxChannel.Tag = "ignore";
            try
            {
                comboBoxChannel.Text = view.UpdateChannel;
            }
            finally
            {
                comboBoxChannel.Tag = null;
            }

            if (view.IsChecking)
            {
                buttonCheckingForUpdate.Enabled = false;
                comboBoxChannel.Enabled = false;
                buttonCheckingForUpdate.Text = "Checking for update..";
                return;
            }

            comboBoxChannel.Enabled = true;

            if (view.IsUpdateAvailable)
            {
                buttonCheckingForUpdate.Text = string.Format(
                    "Click here to download update! {0}", view.Version);
                buttonCheckingForUpdate.Enabled = true;
            }
            else
            {
                buttonCheckingForUpdate.Text = "TogglDesktop is up to date.";
                buttonCheckingForUpdate.Enabled = false;
            }
        }
        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 onTimeEntryEditor(bool open, Toggl.TogglTimeEntryView te, string focusedFieldName)
        {
            if (this.TryBeginInvoke(this.onTimeEntryEditor, open, te, focusedFieldName))
                return;

            if (!this.Owner.IsVisible)
                return;
            
            using (Performance.Measure("opening edit popup"))
            {
                if (this.skipAnimation)
                {
                    this.stopAnimationOpen();
                }
                else
                {
                    this.startAnimationOpen();
                }

                this.Show();
                this.EditView.FocusField(focusedFieldName);
            }
        }
Esempio n. 12
0
        internal void Display(Toggl.TimeEntry item)
        {
            GUID = item.GUID;

            labelDescription.Text = item.Description;
            labelProject.ForeColor = ColorTranslator.FromHtml(item.Color);
            labelProject.Text = item.ProjectLabel;
            labelClient.Text = item.ClientLabel;
            labelTask.Text = item.TaskLabel;
            labelDuration.Text = item.Duration;
            labelBillable.Visible = item.Billable;
            labelTag.Visible = (item.Tags != null && item.Tags.Length > 0);

            if (item.IsHeader)
            {
                labelFormattedDate.Text = item.DateHeader;
                labelDateDuration.Text = item.DateDuration;
                Height = headerPanel.Height + panel.Height;
                panel.Top = headerPanel.Bottom;
                header = true;
            }
            else
            {
                Height = panel.Height;
                panel.Top = 0;
                header = false;
            }
            headerPanel.Visible = item.IsHeader;
            toolTip.SetToolTip(labelDescription, item.Description);
            toolTip.SetToolTip(labelTask, item.ProjectAndTaskLabel);
            toolTip.SetToolTip(labelProject, item.ProjectAndTaskLabel);
            toolTip.SetToolTip(labelClient, item.ProjectAndTaskLabel);
            if (labelTag.Visible)
            {
                toolTip.SetToolTip(labelTag, item.Tags.Replace("|", ", "));
            }
        }
        void OnSettings(bool open, Toggl.Settings settings)
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker)delegate { OnSettings(open, settings); });
                return;
            }
            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;
            checkBoxIdleDetection.Checked = settings.UseIdleDetection;
            checkBoxRecordTimeline.Checked = settings.RecordTimeline;
            checkBoxOnTop.Checked = settings.OnTop;
            checkBoxRemindToTrackTime.Checked = settings.Reminder;

            if (open)
            {
                Show();
                TopMost = true;
            }
        }
Esempio n. 14
0
        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.enablePomodoroBreakCheckBox.IsChecked = settings.PomodoroBreak;
            this.pomodoroBreakTimerDuration.Text       = settings.PomodoroBreakMinutes.ToString();

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

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

            this.onStopEntryCheckBox.IsChecked     = settings.StopEntryOnShutdownSleep;
            this.launchOnStartupCheckBox.IsChecked = Utils.GetLaunchOnStartupRegistry();

            #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 void passwordForgotTextField_LinkClicked_1(object sender, LinkLabelLinkClickedEventArgs e)
 {
     Toggl.PasswordForgot();
 }
        void OnTimeEntryEditor(
            bool open,
            Toggl.TimeEntry te,
            string focused_field_name)
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker)delegate { OnTimeEntryEditor(open, te, focused_field_name); });
                return;
            }

            timeEntry = te;
            if (!open)
            {
                return;
            }
            resetForms();
            if (GUID == te.GUID)
            {
                return;
            }
            GUID = te.GUID;

            checkBoxBillable.Visible = te.CanSeeBillable;

            checkBoxBillable.Tag = this;
            try
            {
                checkBoxBillable.Checked = te.Billable;
            }
            finally
            {
                checkBoxBillable.Tag = null;
            }

            if (!te.CanAddProjects)
            {
                this.linkAddProject.Visible = !te.CanAddProjects;
            }

            if (!comboBoxDescription.Focused)
            {
                comboBoxDescription.Text = te.Description;
            }
            if (!comboBoxProject.Focused)
            {
                comboBoxProject.Text = te.ProjectAndTaskLabel;
            }
            if (!textBoxDuration.Focused)
            {
                textBoxDuration.Text = te.Duration;
            }
            if (!textBoxStartTime.Focused)
            {
                textBoxStartTime.Text = te.StartTimeString;
            }
            if (!textBoxEndTime.Focused)
            {
                textBoxEndTime.Text = te.EndTimeString;
            }
            if (!dateTimePickerStartDate.Focused)
            {
                dateTimePickerStartDate.Value = Toggl.DateTimeFromUnix(te.Started);
            }

            this.panelStartEndTime.Visible = !timeEntry.DurOnly;
            if (timeEntry.DurOnly)
            {
                panelBottom.Height = 150;
            } else {
                panelBottom.Height = 175;
            }

            if (te.UpdatedAt >= 0)
            {
                DateTime updatedAt = Toggl.DateTimeFromUnix(te.UpdatedAt);
                toolStripStatusLabelLastUpdate.Text = "Last update: " + updatedAt.ToString();
                toolStripStatusLabelLastUpdate.Visible = true;
            }
            else
            {
                toolStripStatusLabelLastUpdate.Visible = false;
            }
            textBoxEndTime.Enabled = (te.DurationInSeconds >= 0);

            for (int i = 0; i < this.checkedListBoxTags.Items.Count; i++)
            {
                this.checkedListBoxTags.SetItemChecked(i, false);
            }

            if ( te.Tags != null) {
                string[] tags = te.Tags.Split('|');

                // Tick selected Tags
                for (int i = 0; i < tags.Length; i++)
                {
                    int index = this.checkedListBoxTags.Items.IndexOf(tags[i]);
                    if (index != -1)
                    {
                        this.checkedListBoxTags.SetItemChecked(index, true);
                    }
                }

            }
        }
 protected override void onIconButtonClick(object sender, RoutedEventArgs e)
 {
     Toggl.OpenInBrowser();
 }
Esempio n. 18
0
        public static void Shutdown(int exitCode)
        {
            Toggl.Clear();

            Environment.Exit(exitCode);
        }
Esempio n. 19
0
        private void onRunningTimerState(Toggl.TogglTimeEntryView te)
        {
            if (this.TryBeginInvoke(this.onRunningTimerState, te))
                return;

            this.updateTracking(te);
        }
 private void ButtonBase_OnClick(object sender, RoutedEventArgs e)
 {
     Toggl.OpenInBrowser(Url);
     CloseWithAnimation();
     Toggl.TrackClickActionButtonInAppMessage();
 }
 private void onLoginButtonClick(object sender, RoutedEventArgs e)
 {
     Toggl.OpenInBrowser();
 }
 private static void onLogout(object sender, RoutedEventArgs e)
 {
     Toggl.Logout();
 }
 private void CloseButton_OnClick(object sender, RoutedEventArgs e)
 {
     CloseWithAnimation();
     Toggl.TrackClickCloseButtonInAppMessage();
 }
Esempio n. 24
0
        private void updateTracking(Toggl.TogglTimeEntryView? timeEntry)
        {
            var tracking = timeEntry != null;

            this.isTracking = tracking;

            if (tracking)
            {
                var description = timeEntry.Value.Description;

                if (string.IsNullOrEmpty(description))
                {
                    this.Title = "Toggl Desktop";
                    this.runningMenuText.Text = "Timer is tracking";
                    this.trackingTitle = "";
                }
                else
                {
                    this.Title = description + " - Toggl Desktop";
                    this.runningMenuText.Text = description;
                    this.trackingTitle = description + " - ";
                }


                if(this.isInManualMode)
                    this.setManualMode(false);
            }
            else
            {
                this.runningMenuText.Text = "Timer is not tracking";
                this.Title = "Toggl Desktop";
                this.taskbarIcon.ToolTipText = "Toggl Desktop";
            }

            this.updateStatusIcons(true);
            this.SetIconState(tracking);
        }
Esempio n. 25
0
        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);
        }
Esempio n. 26
0
        private void onOnlineState(Toggl.OnlineState state)
        {
            if (this.TryBeginInvoke(this.onOnlineState, state))
                return;

            this.updateStatusIcons(state == Toggl.OnlineState.Online);
        }
Esempio n. 27
0
 static Toggl()
 {
     UpdateService = new UpdateService(Toggl.IsUpdateCheckDisabled(), Toggl.UpdatesPath);
 }
Esempio n. 28
0
 private void onHeaderClick(object sender, RoutedEventArgs e)
 {
     this.IsCollapsed = !this.IsCollapsed;
     Toggl.ViewTimeEntryList();
 }
Esempio n. 29
0
        public void UpdateReleaseChannel()
        {
            var channel = Toggl.UpdateChannel();

            this.releaseChannelComboBox.SelectedValue = channel;
        }
        private void selectClient(Toggl.TogglGenericView item)
        {
            this.selectedClientGUID = item.GUID;
            this.selectedClientId = item.ID;
            this.selectedClientName = item.Name;
            this.clientTextBox.SetText(item.Name);

            if (item.WID != 0)
            {
                this.selectedWorkspaceId = item.WID;
                this.selectedWorkspaceName = this.workspaces.First(ws => ws.ID == item.WID).Name;
                this.workspaceTextBox.SetText(this.selectedWorkspaceName);
            }
        }
Esempio n. 31
0
 private void openTos(object sender, System.Windows.Navigation.RequestNavigateEventArgs e)
 {
     Toggl.OpenToS();
 }
Esempio n. 32
0
        private void onTimeEntryEditor(bool open, Toggl.TogglTimeEntryView timeEntry, string focusedFieldName)
        {
            if (this.TryBeginInvoke(this.onTimeEntryEditor, open, timeEntry, focusedFieldName))
            {
                return;
            }

            using (Performance.Measure("filling edit view from OnTimeEntryEditor"))
            {
                this.dateSet = false;
                if (timeEntry.Locked)
                {
                    open = true;
                    this.contentGrid.IsEnabled = false;
                    this.contentGrid.Opacity   = 0.75;
                }
                else
                {
                    this.contentGrid.IsEnabled = true;
                    this.contentGrid.Opacity   = 1;
                }

                var keepNewProjectModeOpen =
                    !open &&
                    this.isInNewProjectMode &&
                    this.hasTimeEntry() &&
                    this.timeEntry.GUID == timeEntry.GUID &&
                    this.timeEntry.PID == timeEntry.PID &&
                    this.timeEntry.WID == timeEntry.WID &&
                    timeEntry.CanAddProjects;

                if (!keepNewProjectModeOpen && this.hasTimeEntry() && this.isInNewProjectMode)
                {
                    this.confirmNewProject();
                }

                var isDifferentTimeEntry = this.timeEntry.GUID != timeEntry.GUID;

                this.timeEntry = timeEntry;

                var isCurrentlyRunning = timeEntry.DurationInSeconds < 0;

                this.endTimeTextBox.IsEnabled  = !isCurrentlyRunning;
                this.startDatePicker.IsEnabled = !isCurrentlyRunning;

                setText(this.descriptionTextBox, timeEntry.Description, open);
                setTime(this.durationTextBox, timeEntry.Duration, open);
                setTime(this.startTimeTextBox, timeEntry.StartTimeString, open);
                setTime(this.endTimeTextBox, timeEntry.EndTimeString, open);
                this.startDatePicker.SelectedDate = Toggl.DateTimeFromUnix(timeEntry.Started);
                if (isDifferentTimeEntry)
                {
                    this.clearUndoHistory();
                }

                if (isCurrentlyRunning)
                {
                    this.endTimeTextBox.Text = "";
                }

                this.billableCheckBox.ShowOnlyIf(timeEntry.CanSeeBillable);
                this.billableCheckBox.IsChecked = timeEntry.Billable;

                if (timeEntry.UpdatedAt > 0)
                {
                    var updatedAt = Toggl.DateTimeFromUnix(timeEntry.UpdatedAt);
                    this.lastUpdatedText.Text = "Last update " + updatedAt.ToShortDateString() + " at " +
                                                updatedAt.ToLongTimeString();
                    this.lastUpdatedText.Visibility = Visibility.Visible;
                }
                else
                {
                    this.lastUpdatedText.Visibility = Visibility.Collapsed;
                }

                if (open || !this.tagList.IsKeyboardFocusWithin)
                {
                    this.tagList.Clear(open);
                    if (timeEntry.Tags != null)
                    {
                        this.tagList.AddTags(timeEntry.Tags.Split(new[] { Toggl.TagSeparator },
                                                                  StringSplitOptions.RemoveEmptyEntries));
                    }
                    this.updateTagListEmptyText();
                }

                if (!keepNewProjectModeOpen)
                {
                    if (this.isInNewProjectMode)
                    {
                        this.disableNewProjectMode();
                    }

                    this.projectColorSelector.SelectedColor = timeEntry.Color;

                    setText(this.projectTextBox, timeEntry.ProjectLabel, timeEntry.TaskLabel, open);
                    setText(this.clientTextBox, timeEntry.ClientLabel, open);

                    this.selectedWorkspaceId   = timeEntry.WID;
                    this.selectedWorkspaceName = timeEntry.WorkspaceName;
                    this.reloadWorkspaceClients(timeEntry.WID);

                    if (timeEntry.CanAddProjects)
                    {
                        this.newProjectButton.Visibility            = Visibility.Visible;
                        this.projectAddButtonColumn.Width           = GridLength.Auto;
                        this.projectAddButtonColumn.SharedSizeGroup = "AddButtons";
                    }
                    else
                    {
                        this.newProjectButton.Visibility            = Visibility.Hidden;
                        this.projectAddButtonColumn.Width           = new GridLength(0);
                        this.projectAddButtonColumn.SharedSizeGroup = null;
                    }
                }
                this.dateSet = true;
            }
        }
Esempio n. 33
0
 private void onSyncButtonClick(object sender, RoutedEventArgs e)
 {
     Toggl.Sync();
 }
Esempio n. 34
0
        private void onTimeEntryEditor(bool open, Toggl.TogglTimeEntryView te, string focusedFieldName)
        {
            if (this.TryBeginInvoke(this.onTimeEntryEditor, open, te, focusedFieldName))
                return;

            this.updateEditPopupLocation(true);
        }
 private void selectProject(Toggl.TogglAutocompleteView? item)
 {
     var project = item ?? default(Toggl.TogglAutocompleteView);
     this.selectedProject = project;
     this.projectTextBox.SetText(project.ProjectLabel, project.TaskLabel);
     this.projectColorCircle.Background = Utils.ProjectColorBrushFromString(project.ProjectColor);
     this.projectTextBox.CaretIndex = this.projectTextBox.Text.Length;
 }
Esempio n. 36
0
 private void onForgotPasswordButtonClick(object sender, RoutedEventArgs e)
 {
     Toggl.PasswordForgot();
 }
Esempio n. 37
0
 public void MoveToDay(DateTime date)
 {
     Toggl.SetTimeEntryDate(this.guid, date);
 }
        void OnRunningTimerState(Toggl.TimeEntry te)
        {
            if (InvokeRequired)
            {
            Invoke((MethodInvoker)delegate {
                OnRunningTimerState(te);
            });
            return;
            }
            isTracking = true;
            enableMenuItems();
            updateStatusIcons(true);

            string newText = "Toggl Desktop";
            if (te.Description.Length > 0) {
            runningToolStripMenuItem.Text = te.Description.Replace("&", "&&");
            newText = te.Description + " - Toggl Desktop";
            }
            else
            {
            runningToolStripMenuItem.Text = "Timer is tracking";
            }
            if (newText.Length > 63)
            {
            newText = newText.Substring(0, 60) + "...";
            }
            Text = newText;
            if (trayIcon != null)
            {
            trayIcon.Text = Text;
            }
            updateResizeHandleBackground();
        }
Esempio n. 39
0
        private void onTimeEntryEditor(bool open, Toggl.TogglTimeEntryView timeEntry, string focusedFieldName)
        {
            if (this.TryBeginInvoke(this.onTimeEntryEditor, open, timeEntry, focusedFieldName))
            {
                return;
            }

            using (Performance.Measure("filling edit view from OnTimeEntryEditor"))
            {
                this.dateSet = false;
                if (timeEntry.Locked)
                {
                    open = true;
                    this.contentGrid.IsEnabled = false;
                    this.contentGrid.Opacity   = 0.75;
                }
                else
                {
                    this.contentGrid.IsEnabled = true;
                    this.contentGrid.Opacity   = 1;
                }

                var keepNewProjectModeOpen =
                    !open &&
                    this.isInNewProjectMode &&
                    this.hasTimeEntry() &&
                    this.timeEntry.GUID == timeEntry.GUID &&
                    this.timeEntry.PID == timeEntry.PID &&
                    this.timeEntry.WID == timeEntry.WID &&
                    timeEntry.CanAddProjects;

                if (!keepNewProjectModeOpen && this.hasTimeEntry() && this.isInNewProjectMode)
                {
                    this.confirmNewProject();
                }

                var isDifferentTimeEntry = this.timeEntry.GUID != timeEntry.GUID;

                this.timeEntry = timeEntry;

                var isCurrentlyRunning = timeEntry.DurationInSeconds < 0;

                this.endTimeTextBox.IsEnabled  = !isCurrentlyRunning;
                this.startDatePicker.IsEnabled = !isCurrentlyRunning;

                var startDateTime = Toggl.DateTimeFromUnix(timeEntry.Started);
                var endDateTime   = Toggl.DateTimeFromUnix(timeEntry.Ended);

                setText(this.descriptionTextBox, timeEntry.Description, open);
                setTime(this.durationTextBox, timeEntry.Duration, open);
                setTime(this.startTimeTextBox, timeEntry.StartTimeString, open);
                this.startTimeTextBox.ToolTip = startDateTime.ToString("T", CultureInfo.CurrentCulture);
                setTime(this.endTimeTextBox, timeEntry.EndTimeString, open);
                this.endTimeTextBox.ToolTip       = endDateTime.ToString("T", CultureInfo.CurrentCulture);
                this.startDatePicker.SelectedDate = startDateTime;
                if (isDifferentTimeEntry)
                {
                    this.clearUndoHistory();
                }

                if (isCurrentlyRunning)
                {
                    this.endTimeTextBox.Text = "";
                }

                this.billableCheckBox.ShowOnlyIf(timeEntry.CanSeeBillable);
                this.billableCheckBox.IsChecked = timeEntry.Billable;

                if (open || !this.tagList.IsKeyboardFocusWithin)
                {
                    this.tagList.Clear(open);
                    if (timeEntry.Tags != null)
                    {
                        this.tagList.AddTags(timeEntry.Tags.Split(new[] { Toggl.TagSeparator },
                                                                  StringSplitOptions.RemoveEmptyEntries));
                    }
                }

                if (!keepNewProjectModeOpen)
                {
                    if (this.isInNewProjectMode)
                    {
                        this.createProjectPopup.IsOpen = false;
                        this.disableNewProjectMode();
                    }

                    this.selectedProjectColorCircle.Background = Utils.ProjectColorBrushFromString(timeEntry.Color);

                    setText(this.projectTextBox, timeEntry.ProjectLabel, timeEntry.TaskLabel, open);
                    projectTextBox.DataContext = timeEntry.ToProjectLabelViewModel();

                    setText(this.clientTextBox, timeEntry.ClientLabel, open);

                    this.selectedWorkspaceId = timeEntry.WID;
                    this.reloadWorkspaceClients(timeEntry.WID);

                    this.projectAutoComplete.ActionButtonText =
                        timeEntry.CanAddProjects
                            ? "Create a new project"
                            : string.Empty;
                }
                this.dateSet = true;
            }
        }
 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();
 }
Esempio n. 41
0
        public static void LoadWindowLocation(Window mainWindow, EditViewPopup editPopup, MiniTimerWindow miniTimer)
        {
            if (editPopup != null)
            {
                var editWidth = Toggl.GetEditViewWidth();
                if (editWidth > 0 && editWidth < int.MaxValue)
                {
                    editPopup.Width = editWidth;
                }
                else
                {
                    editPopup.Width = editPopup.MinWidth;
                }
            }
            if (Toggl.GetWindowMaximized())
            {
                mainWindow.WindowState = WindowState.Maximized;
            }
            else if (Toggl.GetWindowMinimized())
            {
                mainWindow.WindowState = WindowState.Minimized;
            }

            long x = 0, y = 0, h = 0, w = 0;

            if (Toggl.WindowSettings(ref x, ref y, ref h, ref w) &&
                ValidateWindowSettings(x, y, h, w))
            {
                mainWindow.Left   = x;
                mainWindow.Top    = y;
                mainWindow.Width  = w;
                mainWindow.Height = h;
                Toggl.Debug("Retrieved window location and size ({0}x{1} by {2}x{3})", x, y, w, h);
            }
            else
            {
                mainWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
                mainWindow.Width  = 300;
                mainWindow.Height = 458;
                Toggl.Debug("Failed to retrieve window location and size. Setting the default size.");
            }

            // First try to shift the window onto the bounding box of visible screens
            if (ShiftWindowOntoVisibleArea(mainWindow))
            {
                Toggl.Debug("Shifted main window onto visible area");
            }
            // Then handle the case where the window is in the bounding box but not on any of the screens
            if (!VisibleOnAnyScreen(mainWindow))
            {
                var location = Screen.PrimaryScreen.WorkingArea.Location;
                mainWindow.Left = location.X;
                mainWindow.Top  = location.Y;
                Toggl.Debug("Force moved window to primary screen");
            }

            if (miniTimer != null)
            {
                x = Toggl.GetMiniTimerX();
                y = Toggl.GetMiniTimerY();
                w = Toggl.GetMiniTimerW();
                if (ValidateMiniTimerWindowSettings(x, y, w))
                {
                    miniTimer.Left  = x;
                    miniTimer.Top   = y;
                    miniTimer.Width = w;
                    Toggl.Debug("Retrieved mini timer location ({0}x{1} by {2})", x, y, w);
                }
                else
                {
                    const int defaultX     = 0;
                    const int defaultY     = 0;
                    const int defaultWidth = 360;
                    miniTimer.Left  = defaultX;
                    miniTimer.Top   = defaultY;
                    miniTimer.Width = defaultWidth;
                    Toggl.Debug($"Set default mini-timer position and size: ({defaultX}x{defaultY} by {defaultWidth}");
                }

                CheckMinitimerVisibility(miniTimer);
            }
        }
 void OnTimeEntryEditor(
     bool open,
     Toggl.TimeEntry te,
     string focused_field_name)
 {
     if (InvokeRequired)
     {
     Invoke((MethodInvoker)delegate {
         OnTimeEntryEditor(open, te, focused_field_name);
     });
     return;
     }
     if (open)
     {
     contentPanel.Controls.Remove(loginViewController);
     MinimumSize = new Size(230, 86);
     timeEntryEditViewController.FocusField(focused_field_name);
     PopupInput(te);
     }
     timeEntryListViewController.HighlightEntry(te.GUID);
 }
 private void linkLabelPreferences_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     Toggl.EditPreferences();
 }
        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
        }
Esempio n. 45
0
 private void onStartButtonClick(object sender, RoutedEventArgs e)
 {
     this.icon.CloseBalloon();
     Toggl.Start("", "", this.taskId, this.projectId, null, null);
     this.mainWindow.ShowOnTop();
 }
Esempio n. 46
0
 private void emptyLabel_Click(object sender, EventArgs e)
 {
     Toggl.OpenInBrowser();
 }
 private void onEmptyListTextClick(object sender, RoutedEventArgs e)
 {
     Toggl.OpenInBrowser();
 }
Esempio n. 48
0
 public ProjectInfo(Toggl.TogglAutocompleteView item)
 {
     this.projectId = item.ProjectID;
     this.taskId = item.TaskID;
 }
 private void TextBlock_MouseDown(object sender, MouseButtonEventArgs e)
 {
     Toggl.FullSync();
 }
 private void comboBoxChannel_SelectedIndexChanged(object sender, EventArgs e)
 {
     Toggl.SetUpdateChannel(comboBoxChannel.Text);
 }
Esempio n. 51
0
        private void onManualAddButtonClick(object sender, RoutedEventArgs e)
        {
            var guid = Toggl.Start("", "0", 0, 0, "", "", IsMiniTimer);

            Toggl.Edit(guid, false, Toggl.Duration);
        }
        internal void initAndCheck()
        {
            string channel = Toggl.UpdateChannel();

            comboBoxChannel.SelectedIndex = comboBoxChannel.Items.IndexOf(channel);
        }
Esempio n. 53
0
        static void Main()
        {
            Win32.AttachConsole(Win32.ATTACH_PARENT_PROCESS);

            using (Mutex mutex = new Mutex(false, "Global\\" + Environment.UserName + "_" + appGUID))
            {
                if (!mutex.WaitOne(0, false))
                {
                    // See if we get hold of the other process.
                    // If we do, activate it's window and exit.
                    Process   current   = Process.GetCurrentProcess();
                    Process[] instances = Process.GetProcessesByName(current.ProcessName);
                    foreach (Process p in instances)
                    {
                        if (p.Id != current.Id)
                        {
                            // gotcha
                            IntPtr hWnd = p.MainWindowHandle;
                            if (hWnd == IntPtr.Zero)
                            {
                                hWnd = Win32.SearchForWindow(current.ProcessName, "Toggl Desktop");
                            }

                            Win32.ShowWindow(hWnd, Win32.SW_RESTORE);
                            Win32.SetForegroundWindow(hWnd);

                            return;
                        }
                    }

                    // If not, print an error message and exit.
                    System.Windows.MessageBox.Show("Another copy of Toggl Desktop is already running." +
                                                   Environment.NewLine + "This copy will now quit.");
                    return;
                }

                Toggl.InitialiseLog();

                bugsnag = new Bugsnag.Clients.BaseClient("2a46aa1157256f759053289f2d687c2f");

#if INVS
                bugsnag.Config.ReleaseStage = "development";
#else
                bugsnag.Config.ReleaseStage = "production";
#endif

                Toggl.OnLogin += delegate(bool open, UInt64 user_id)
                {
                    uid = user_id;
                };

                Toggl.OnError += delegate(string errmsg, bool user_error)
                {
                    Toggl.Debug(errmsg);
                    try
                    {
                        if (!user_error && bugsnag.Config.ReleaseStage != "development")
                        {
                            notifyBugsnag(new Exception(errmsg));
                        }
                    }
                    catch (Exception ex)
                    {
                        Toggl.Debug("Could not check if can notify bugsnag: " + ex);
                    }
                };

                Application.ThreadException += Application_ThreadException;
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly;

                new App().Run();
            }
        }
Esempio n. 54
0
 private void saveTags()
 {
     Toggl.SetTimeEntryTags(this.timeEntry.GUID, this.tagList.Tags.ToList());
 }
Esempio n. 55
0
        private void setUIToRunningState(Toggl.TogglTimeEntryView item)
        {
            this.resetUIState(true);

            this.descriptionLabel.Text = item.Description == "" ? "(no description)" : item.Description;
            this.projectLabel.Text = string.IsNullOrEmpty(item.ClientLabel) ? item.ProjectLabel : "• " + item.ProjectLabel;
            setOptionalTextBlockText(this.clientLabel, item.ClientLabel);
            setOptionalTextBlockText(this.taskLabel, string.IsNullOrEmpty(item.TaskLabel) ? "" : item.TaskLabel + " -");

            this.timeDisplayGrid.ToolTip = "started at " + item.StartTimeString;

            this.projectLabel.Foreground = Utils.ProjectColorBrushFromString(item.Color);

            this.billabeIcon.ShowOnlyIf(item.Billable);
            this.tagsIcon.ShowOnlyIf(!string.IsNullOrEmpty(item.Tags));

            if (!string.IsNullOrEmpty(item.ProjectLabel))
                this.projectGridRow.Height = new GridLength(1, GridUnitType.Star);

            this.setRunningDurationLabels();
        }
Esempio n. 56
0
 private void billableCheckBox_OnClick(object sender, RoutedEventArgs e)
 {
     Toggl.SetTimeEntryBillable(this.timeEntry.GUID, this.billableCheckBox.IsChecked ?? false);
 }
        private void onTimeEntryEditor(bool open, Toggl.TogglTimeEntryView timeEntry, string focusedFieldName)
        {
            if (this.TryBeginInvoke(this.onTimeEntryEditor, open, timeEntry, focusedFieldName))
                return;

            using (Performance.Measure("filling edit view from OnTimeEntryEditor"))
            {
                var keepNewProjectModeOpen =
                    !open
                    && this.isInNewProjectMode
                    && this.hasTimeEntry()
                    && this.timeEntry.GUID == timeEntry.GUID
                    && this.timeEntry.PID == timeEntry.PID
                    && this.timeEntry.WID == timeEntry.WID
                    && timeEntry.CanAddProjects;

                if (!keepNewProjectModeOpen && this.hasTimeEntry() && this.isInNewProjectMode)
                {
                    this.confirmNewProject();
                }

                this.timeEntry = timeEntry;

                var isCurrentlyRunning = timeEntry.DurationInSeconds < 0;

                this.endTimeTextBox.IsEnabled = !isCurrentlyRunning;

                setText(this.descriptionTextBox, timeEntry.Description, open);
                setTime(this.durationTextBox, timeEntry.Duration, open);
                setTime(this.startTimeTextBox, timeEntry.StartTimeString, open);
                setTime(this.endTimeTextBox, timeEntry.EndTimeString, open);
                this.startDatePicker.SelectedDate = Toggl.DateTimeFromUnix(timeEntry.Started);

                if (isCurrentlyRunning)
                {
                    this.endTimeTextBox.Text = "";
                }

                this.billableCheckBox.ShowOnlyIf(timeEntry.CanSeeBillable);
                this.billableCheckBox.IsChecked = timeEntry.Billable;

                if (timeEntry.UpdatedAt > 0)
                {
                    var updatedAt = Toggl.DateTimeFromUnix(timeEntry.UpdatedAt);
                    this.lastUpdatedText.Text = "Last update " + updatedAt.ToShortDateString() + " at " +
                                                updatedAt.ToLongTimeString();
                    this.lastUpdatedText.Visibility = Visibility.Visible;
                }
                else
                {
                    this.lastUpdatedText.Visibility = Visibility.Collapsed;
                }

                if (open || !this.tagList.IsKeyboardFocusWithin)
                {
                    this.tagList.Clear(open);
                    if (timeEntry.Tags != null)
                        this.tagList.AddTags(timeEntry.Tags.Split(new[] {Toggl.TagSeparator},
                            StringSplitOptions.RemoveEmptyEntries));
                    this.updateTagListEmptyText();
                }

                if (!keepNewProjectModeOpen)
                {
                    if (this.isInNewProjectMode)
                        this.disableNewProjectMode();

                    this.projectColorSelector.SelectedColor = timeEntry.Color;

                    setText(this.projectTextBox, timeEntry.ProjectLabel, timeEntry.TaskLabel, open);
                    setText(this.clientTextBox, timeEntry.ClientLabel, open);

                    this.selectedWorkspaceId = timeEntry.WID;
                    this.selectedWorkspaceName = timeEntry.WorkspaceName;

                    if (timeEntry.CanAddProjects)
                    {
                        this.newProjectButton.Visibility = Visibility.Visible;
                        this.projectAddButtonColumn.Width = GridLength.Auto;
                        this.projectAddButtonColumn.SharedSizeGroup = "AddButtons";
                    }
                    else
                    {
                        this.newProjectButton.Visibility = Visibility.Hidden;
                        this.projectAddButtonColumn.Width = new GridLength(0);
                        this.projectAddButtonColumn.SharedSizeGroup = null;
                    }
                }
            }
        }
Esempio n. 58
0
 private void close()
 {
     Toggl.ViewTimeEntryList();
 }
        private void selectWorkspace(Toggl.TogglGenericView item)
        {
            if (this.selectedWorkspaceId != item.ID && !this.isInNewClientMode)
            {
                this.selectClient(new Toggl.TogglGenericView());
            }

            this.selectedWorkspaceId = item.ID;
            this.selectedWorkspaceName = item.Name;
            this.workspaceTextBox.SetText(item.Name);
        }
        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;
            }
        }