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); }
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); } } } }
void OnTimeEntryEditor( bool open, Toggl.TimeEntry te, string focused_field_name) { if (InvokeRequired) { Invoke((MethodInvoker)delegate { OnTimeEntryEditor(open, te, focused_field_name); }); return; } // // Custom Combobox Buttons // this.projectButton.Height = this.projectButton.Width = this.descriptionButton.Height = this.descriptionButton.Width = this.comboBoxDescription.Height - 2; this.projectButton.Left = this.descriptionButton.Left = this.comboBoxProject.Left + this.comboBoxProject.Width - 1 - this.projectButton.Width; this.descriptionButton.Top = this.comboBoxDescription.Top + 1; this.projectButton.Top = this.comboBoxProject.Top + 1; timeEntry = te; panelBillable.Visible = te.CanSeeBillable; checkBoxBillable.Tag = this; try { checkBoxBillable.Checked = te.Billable; } finally { checkBoxBillable.Tag = null; } if (!te.CanAddProjects) { linkAddProject.Visible = !te.CanAddProjects; } if (open) { comboBoxDescription.ResetListBox(); comboBoxProject.ResetListBox(); comboBoxDescription.Text = te.Description; comboBoxProject.Text = te.ProjectAndTaskLabel; textBoxDuration.Text = te.Duration; textBoxStartTime.Text = te.StartTimeString; textBoxEndTime.Text = te.EndTimeString; dateTimePickerStartDate.Value = Toggl.DateTimeFromUnix(te.Started); } else { 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); } } panelStartEndTime.Visible = !timeEntry.DurOnly; if (timeEntry.DurOnly) { panelDateTag.Top = panelDuration.Top + panelDuration.Height; } else { panelDateTag.Top = panelStartEndTime.Top + panelStartEndTime.Height; } panelDateTag.Height = panelBottom.Height - panelDateTag.Top; 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); if (!checkedListBoxTags.Focused || open) { for (int i = 0; i < checkedListBoxTags.Items.Count; i++) { 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 = checkedListBoxTags.Items.IndexOf(tags[i]); if (index != -1) { checkedListBoxTags.SetItemChecked(index, true); } } } } }