コード例 #1
0
 void DisplayTimeEntryEditor(
     KopsikApi.KopsikTimeEntryViewItem te,
     string focused_field_name)
 {
     if (InvokeRequired)
     {
         Invoke((MethodInvoker) delegate { DisplayTimeEntryEditor(te, focused_field_name); });
         return;
     }
     GUID = te.GUID;
     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 = KopsikApi.DateTimeFromUnix(te.Started);
     }
     checkBoxBillable.Tag = this;
     try
     {
         checkBoxBillable.Checked = te.Billable;
     }
     finally
     {
         checkBoxBillable.Tag = null;
     }
     if (te.UpdatedAt >= 0)
     {
         DateTime updatedAt = KopsikApi.DateTimeFromUnix(te.UpdatedAt);
         toolStripStatusLabelLastUpdate.Text    = updatedAt.ToString();
         toolStripStatusLabelLastUpdate.Visible = true;
     }
     else
     {
         toolStripStatusLabelLastUpdate.Visible = false;
     }
     textBoxEndTime.Enabled = (te.DurationInSeconds >= 0);
 }
コード例 #2
0
        void DisplayTimeEntryEditor(
            KopsikApi.KopsikTimeEntryViewItem te,
            string focused_field_name)
        {
            timeEntry = te;
            if (InvokeRequired)
            {
                Invoke((MethodInvoker) delegate { DisplayTimeEntryEditor(te, focused_field_name); });
                return;
            }
            GUID = te.GUID;

            Boolean can_see_billable = false;

            if (!KopsikApi.kopsik_user_can_see_billable_flag(KopsikApi.ctx, GUID, ref can_see_billable))
            {
                return;
            }
            checkBoxBillable.Visible = can_see_billable;

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

            Boolean can_add_projects = false;

            if (!KopsikApi.kopsik_user_can_add_projects(KopsikApi.ctx, timeEntry.WID, ref can_add_projects))
            {
                return;
            }
            if (!can_add_projects)
            {
                this.linkAddProject.Visible = !can_add_projects;
            }

            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 = KopsikApi.DateTimeFromUnix(te.Started);
            }

            this.textBoxEndTime.Visible = !timeEntry.DurOnly;

            if (te.UpdatedAt >= 0)
            {
                DateTime updatedAt = KopsikApi.DateTimeFromUnix(te.UpdatedAt);
                toolStripStatusLabelLastUpdate.Text    = 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);
                    }
                }
            }
        }