private void setUIToRunningState(Toggl.TogglTimeEntryView item) { this.resetUIState(true); this.timeEntryLabel.ViewModel = item.ToTimeEntryLabelViewModel(); this.durationLabel.Text = Toggl.FormatDurationInSecondsHHMMSS(item.DurationInSeconds); this.durationPanel.ToolTip = "started at " + item.StartTimeString; }
void OnRunningTimerState(Toggl.TogglTimeEntryView te) { if (this.TryBeginInvoke(this.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(); }
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(); // focus field only if the edit popup was just open if (open) { this.EditView.FocusField(focusedFieldName); } } }
private void onRunningTimerState(Toggl.TogglTimeEntryView te) { if (this.TryBeginInvoke(this.onRunningTimerState, te)) { return; } this.updateTracking(te); }
private void onTimeEntryEditor(bool open, Toggl.TogglTimeEntryView te, string focusedFieldName) { if (this.TryBeginInvoke(this.onTimeEntryEditor, open, te, focusedFieldName)) { return; } this.updateEditPopupLocation(true); }
private void onLogin(bool open, ulong userId) { if (this.TryBeginInvoke(this.onLogin, open, userId)) return; this.timeEntry = new Toggl.TogglTimeEntryView(); this.projects = null; this.clients = null; this.workspaces = null; }
private void onLogin(bool open, ulong userId) { if (this.TryBeginInvoke(this.onLogin, open, userId)) { return; } this.timeEntry = new Toggl.TogglTimeEntryView(); this.projects = null; this.clients = null; this.workspaces = null; }
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.Entries.SelectEntry(te.GUID); } }
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 onStoppedTimerState() { if (this.TryBeginInvoke(this.onStoppedTimerState)) return; using (Performance.Measure("timer responding to OnStoppedTimerState")) { this.secondsTimer.IsEnabled = false; this.setUIToStoppedState(); this.runningTimeEntry = default(Toggl.TogglTimeEntryView); } }
public void PopupInput(Toggl.TogglTimeEntryView te) { if (te.GUID == editForm.GUID) { editForm.ClosePopup(); return; } editForm.reset(); setEditFormLocation(); editForm.GUID = te.GUID; editForm.Show(); timeEntryListViewController.HighlightEntry(te.GUID); }
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 onStoppedTimerState() { if (this.TryBeginInvoke(this.onStoppedTimerState)) { return; } using (Performance.Measure("timer responding to OnStoppedTimerState")) { this.secondsTimer.IsEnabled = false; this.setUIToStoppedState(); this.runningTimeEntry = default(Toggl.TogglTimeEntryView); } }
private void setupGroupedMode(Toggl.TogglTimeEntryView item) { String groupItemsText = ""; String groupIcon = "group_icon_closed.png"; Color backColor = idleBackColor; Color color = defaultForegroundColor; int lead = 16; Visibility visibility = Visibility.Collapsed; group = item.Group; groupName = item.GroupName; groupOpen = item.GroupOpen; SubItem = (item.GroupItemCount > 0 && item.GroupOpen && !item.Group); // subitem that is open if (SubItem) { lead = 26; backColor = subItemBackColor; color = (Color)ColorConverter.ConvertFromString("#FF696969"); } if (item.Group) { if (item.GroupOpen) { // Change group icon to green arrow groupIcon = "group_icon_open.png"; } else { // Show count groupItemsText = Convert.ToString(item.GroupItemCount); } visibility = Visibility.Visible; } labelDescription.Foreground = new System.Windows.Media.SolidColorBrush(color); labelDuration.Foreground = new System.Windows.Media.SolidColorBrush(color); this.EntryBackColor = backColor; this.groupItemsBack.Visibility = visibility; groupItems.Text = groupItemsText; this.groupImage.Source = new BitmapImage(new Uri("pack://application:,,,/TogglDesktop;component/Resources/" + groupIcon)); // leading margin descriptionGrid.Margin = new Thickness(lead, 0, 0, 0); }
public void Display(Toggl.TogglTimeEntryView item, TimeEntryCellDayHeader dayHeader) { this.guid = item.GUID; this.DayHeader = dayHeader; this.labelDescription.Text = item.Description == "" ? "(no description)" : item.Description; var projectColorBrush = Utils.ProjectColorBrushFromString(item.Color); this.projectColor.Fill = projectColorBrush; this.labelProject.Foreground = projectColorBrush; this.labelProject.Text = item.ClientLabel.IsNullOrEmpty() ? item.ProjectLabel : "• " + item.ProjectLabel; setOptionalTextBlockText(this.labelClient, item.ClientLabel); setOptionalTextBlockText(this.labelTask, item.TaskLabel.IsNullOrEmpty() ? "" : item.TaskLabel + " -"); this.labelDuration.Text = item.Duration; this.billabeIcon.ShowOnlyIf(item.Billable); this.confirmlessDelete = (item.Description.Length == 0 && item.DurationInSeconds < 15 && item.PID == 0); if (string.IsNullOrEmpty(item.Tags)) { this.tagsIcon.Visibility = Visibility.Collapsed; } else { this.tagsIcon.Visibility = Visibility.Visible; this.tagsCount.Text = item.Tags.CountSubstrings(Toggl.TagSeparator).ToString(); } this.projectRow.Height = item.ProjectLabel == "" ? new GridLength(0) : GridLength.Auto; this.entrySeperator.ShowOnlyIf(!item.IsHeader); this.entryHoverColor = hoverColor; this.EntryBackColor = idleBackColor; this.unsyncedIcon.ShowOnlyIf(item.Unsynced); this.lockedIcon.ShowOnlyIf(item.Locked); this.updateToolTips(item); this.setupGroupedMode(item); }
void OnTimeEntryEditor( bool open, Toggl.TogglTimeEntryView te, string focused_field_name) { if (this.TryBeginInvoke(this.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 renderTimeEntryList(List <Toggl.TogglTimeEntryView> list) { var previousCount = this.entries.Children.Count; var newCount = list.Count; using (Performance.Measure("rendering time entry list, previous count: {0}, new count: {1}", previousCount, newCount)) { emptyLabel.Visible = (list.Count == 0); this.cellsByGUID.Clear(); int maxCount = list.Count; for (int i = 0; i < maxCount; i++) { Toggl.TogglTimeEntryView te = list[i]; WPF.TimeEntryCell cell = null; if (entries.Children.Count > i) { cell = (TogglDesktop.WPF.TimeEntryCell)entries.Children[i]; } if (cell == null) { cell = new WPF.TimeEntryCell(); entries.Children.Add(cell); } cell.Display(te); this.cellsByGUID.Add(te.GUID, cell); } if (entries.Children.Count > list.Count) { entries.Children.RemoveRange(list.Count, entries.Children.Count - list.Count); } entries.Dispatcher.Invoke(() => { }, DispatcherPriority.Render); entriesHost.Invalidate(); this.refreshHighlight(); } }
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(); }
private void updateToolTips(Toggl.TogglTimeEntryView item) { setToolTipIfNotEmpty(this.labelDescription, this.descriptionToolTip, item.Description); setToolTipIfNotEmpty(this.labelTask, this.taskProjectClientToolTip, item.ProjectAndTaskLabel); setToolTipIfNotEmpty(this.labelProject, this.taskProjectClientToolTip, item.ProjectAndTaskLabel); setToolTipIfNotEmpty(this.labelClient, this.taskProjectClientToolTip, item.ProjectAndTaskLabel); if (item.DurOnly) { this.labelDuration.ToolTip = null; } else { this.labelDuration.ToolTip = this.durationToolTip; this.durationToolTip.Content = item.StartTimeString + " - " + item.EndTimeString; } if (this.tagsIcon.Visibility == Visibility.Visible) { this.tagsToolTip.Content = item.Tags.Replace(Toggl.TagSeparator, ", "); this.tagsIcon.ToolTip = this.tagsToolTip; } }
public static DateTime EndTime(this Toggl.TogglTimeEntryView te) => Toggl.DateTimeFromUnix(te.Ended);
public static DateTime StartTime(this Toggl.TogglTimeEntryView te) => Toggl.DateTimeFromUnix(te.Started);
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; } } } }
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.AdaptedProjectColorBrushFromString(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; } }
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; } }
public static bool ConfirmlessDelete(this Toggl.TogglTimeEntryView timeEntry) { return(IsDurationLessThan15Seconds(timeEntry.DurationInSeconds)); }