void OnTimeEntryAutocomplete(IntPtr first)
        {
            List <KopsikApi.KopsikAutocompleteItem> list =
                KopsikApi.ConvertToAutocompleteList(first);

            DisplayTimeEntryAutocomplete(list);
        }
示例#2
0
        private void MainWindowController_Load(object sender, EventArgs e)
        {
            troubleBox.BackColor = Color.FromArgb(239, 226, 121);

            Utils.LoadWindowLocation(this);

            KopsikApi.OnApp              += OnApp;
            KopsikApi.OnError            += OnError;
            KopsikApi.OnUpdate           += OnUpdate;
            KopsikApi.OnLogin            += OnLogin;
            KopsikApi.OnTimeEntryList    += OnTimeEntryList;
            KopsikApi.OnTimeEntryEditor  += OnTimeEntryEditor;
            KopsikApi.OnOnlineState      += OnOnlineState;
            KopsikApi.OnReminder         += OnReminder;
            KopsikApi.OnURL              += OnURL;
            KopsikApi.OnTimerState       += OnTimerState;
            KopsikApi.OnSettings         += OnSettings;
            KopsikApi.OnIdleNotification += OnIdleNotification;

            if (!KopsikApi.Start(TogglDesktop.Program.Version()))
            {
                MessageBox.Show("Missing callback. See the log file for details");
                TogglDesktop.Program.Shutdown(1);
            }
        }
示例#3
0
 private void comboBoxChannel_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (null == comboBoxChannel.Tag)
     {
         KopsikApi.kopsik_set_update_channel(KopsikApi.ctx, comboBoxChannel.Text);
     }
 }
示例#4
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            if (buttonStart.Text == "Start")
            {
                string description = comboBoxDescription.Text;
                if (defaultDescription == description)
                {
                    description = "";
                }

                string duration = textBoxDuration.Text;
                if (defaultDuration == duration)
                {
                    duration = "";
                }

                KopsikApi.kopsik_start(KopsikApi.ctx,
                                       description,
                                       duration,
                                       task_id,
                                       project_id);
            }
            else
            {
                KopsikApi.kopsik_stop(KopsikApi.ctx);
            }
        }
        void OnProjectAutocomplete(IntPtr first)
        {
            List <KopsikApi.KopsikAutocompleteItem> list =
                KopsikApi.ConvertToAutocompleteList(first);

            DisplayProjectAutocomplete(list);
        }
 void DisplaySettings(bool open, KopsikApi.KopsikSettingsViewItem settings)
 {
     if (InvokeRequired)
     {
         Invoke((MethodInvoker)delegate { DisplaySettings(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;
         checkBoxIgnoreCert.Checked = settings.IgnoreCert;
     }
     finally
     {
         loading = false;
     }
     if (open)
     {
         Show();
         BringToFront();
     }
 }
示例#7
0
        private void timerIdleDetection_Tick(object sender, EventArgs e)
        {
            int           idleTime      = 0;
            LASTINPUTINFO lastInputInfo = new LASTINPUTINFO();

            lastInputInfo.cbSize = Marshal.SizeOf(lastInputInfo);
            lastInputInfo.dwTime = 0;

            int envTicks = Environment.TickCount;

            if (GetLastInputInfo(out lastInputInfo))
            {
                int lastInputTick = lastInputInfo.dwTime;
                idleTime = envTicks - lastInputTick;
            }

            int idle_seconds = 0;

            if (idleTime > 0)
            {
                idle_seconds = idleTime / 1000;
            }
            else
            {
                idle_seconds = idleTime;
            }

            if (idle_seconds < 0)
            {
                idle_seconds = 0;
            }

            KopsikApi.kopsik_set_idle_seconds(KopsikApi.ctx, (ulong)idle_seconds);
        }
示例#8
0
 private void buttonSend_Click(object sender, EventArgs e)
 {
     if (comboBoxTopic.SelectedIndex == 0)
     {
         comboBoxTopic.Focus();
         return;
     }
     if (richTextBoxContents.TextLength == 0)
     {
         richTextBoxContents.Focus();
         return;
     }
     if (!KopsikApi.kopsik_feedback_send(KopsikApi.ctx,
                                         comboBoxTopic.Text,
                                         richTextBoxContents.Text,
                                         openFileDialog.FileName))
     {
         return;
     }
     MessageBox.Show("Your feedback was sent successfully.", "Thank you!");
     comboBoxTopic.SelectedIndex = 0;
     richTextBoxContents.Clear();
     openFileDialog.Reset();
     Close();
 }
 private void checkBoxBillable_CheckedChanged(object sender, EventArgs e)
 {
     if (null == checkBoxBillable.Tag)
     {
         KopsikApi.kopsik_set_time_entry_billable(KopsikApi.ctx,
                                                  GUID, checkBoxBillable.Checked);
     }
 }
 private void textBoxDuration_Leave(object sender, EventArgs e)
 {
     if (timeEntry.Equals(null))
     {
         Console.WriteLine("Cannot apply duration change. this.TimeEntry is null");
         return;
     }
     KopsikApi.kopsik_set_time_entry_duration(KopsikApi.ctx, GUID, this.textBoxDuration.Text);
 }
        private void buttonDelete_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show("Delete time entry?", "Please confirm",
                                              MessageBoxButtons.YesNo, MessageBoxIcon.Question);

            if (DialogResult.Yes == dr)
            {
                KopsikApi.kopsik_delete_time_entry(KopsikApi.ctx, GUID);
            }
        }
示例#12
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);
 }
        private void comboBoxProject_SelectedIndexChanged(object sender, EventArgs e)
        {
            object o = comboBoxProject.SelectedItem;

            if (null == o)
            {
                return;
            }
            KopsikApi.KopsikAutocompleteItem item = (KopsikApi.KopsikAutocompleteItem)o;
            KopsikApi.kopsik_set_time_entry_project(KopsikApi.ctx,
                                                    GUID, 0, item.ProjectID, "");
        }
        private DateTime parseTime(TextBox field)
        {
            DateTime date    = this.dateTimePickerStartDate.Value;
            int      hours   = 0;
            int      minutes = 0;

            if (!KopsikApi.kopsik_parse_time(field.Text, ref hours, ref minutes))
            {
                return(date);
            }

            return(date.Date + new TimeSpan(hours, minutes, 0));
        }
        private void clearCacheToolStripMenuItem_Click(object sender, EventArgs e)
        {
            DialogResult dr = MessageBox.Show(
                "This will remove your Toggl user data from this PC and log you out of the Toggl Desktop app. " +
                "Any unsynced data will be lost." +
                Environment.NewLine + "Do you want to continue?",
                "Clear Cache",
                MessageBoxButtons.OKCancel, MessageBoxIcon.Question);

            if (DialogResult.Yes == dr)
            {
                KopsikApi.kopsik_clear_cache(KopsikApi.ctx);
            }
        }
 private bool saveSettings()
 {
     if (loading || !mustSaveSettings)
     {
         return(true);
     }
     return(KopsikApi.kopsik_set_settings(KopsikApi.ctx,
                                          checkBoxIdleDetection.Checked,
                                          true,
                                          true,
                                          checkBoxOnTop.Checked,
                                          checkBoxRemindToTrackTime.Checked,
                                          checkBoxIgnoreCert.Checked));
 }
示例#17
0
 private void loginButton_Click(object sender, EventArgs e)
 {
     if (0 == email.Text.Length)
     {
         email.Focus();
         return;
     }
     if (0 == password.Text.Length)
     {
         password.Focus();
         return;
     }
     KopsikApi.kopsik_login(KopsikApi.ctx, email.Text, password.Text);
     password.Clear();
 }
        private void applyTimeChange(TextBox textbox)
        {
            DateTime date          = this.parseTime(textbox);
            String   iso8601String = date.ToString("yyyy-MM-ddTHH:mm:sszzz");
            String   utf8String    = this.getUTF8String(iso8601String);

            if (textbox == this.textBoxStartTime)
            {
                KopsikApi.kopsik_set_time_entry_start_iso_8601(KopsikApi.ctx, timeEntry.GUID, utf8String);
            }
            else if (textbox == this.textBoxEndTime)
            {
                KopsikApi.kopsik_set_time_entry_end_iso_8601(KopsikApi.ctx, timeEntry.GUID, utf8String);
            }
        }
        private void checkedListBoxTags_Leave(object sender, EventArgs e)
        {
            String tags = "";

            foreach (object item in this.checkedListBoxTags.CheckedItems)
            {
                if (tags.Length > 0)
                {
                    tags += "|";
                }
                tags += item.ToString();
            }

            KopsikApi.kopsik_set_time_entry_tags(KopsikApi.ctx, this.getUTF8String(timeEntry.GUID), this.getUTF8String(tags));
        }
        private void comboBoxDescription_SelectedIndexChanged(object sender, EventArgs e)
        {
            object o = comboBoxDescription.SelectedItem;

            if (o == null)
            {
                return;
            }
            KopsikApi.KopsikAutocompleteItem item = (KopsikApi.KopsikAutocompleteItem)o;
            comboBoxDescription.Text = item.Description;
            KopsikApi.kopsik_set_time_entry_project(KopsikApi.ctx,
                                                    GUID,
                                                    item.TaskID,
                                                    item.ProjectID,
                                                    null);
        }
示例#21
0
 private void timerRunningDuration_Tick(object sender, EventArgs e)
 {
     if (duration_in_seconds >= 0)
     {
         // Timer is not running
         return;
     }
     const int duration_len = 20;
     StringBuilder sb = new StringBuilder(duration_len);
     KopsikApi.kopsik_format_duration_in_seconds_hhmmss(
         duration_in_seconds, sb, duration_len);
     string s = sb.ToString();
     if (s != linkLabelDuration.Text) {
         linkLabelDuration.Text = s;
     }
 }
示例#22
0
        private void googleLogin()
        {
            UserCredential credential = GoogleWebAuthorizationBroker.AuthorizeAsync(
                new ClientSecrets
            {
                ClientId     = "426090949585-uj7lka2mtanjgd7j9i6c4ik091rcv6n5.apps.googleusercontent.com",
                ClientSecret = "6IHWKIfTAMF7cPJsBvoGxYui"
            },
                new[] {
                Oauth2Service.Scope.UserinfoEmail,
                Oauth2Service.Scope.UserinfoProfile
            },
                "user",
                CancellationToken.None,
                null).Result;

            KopsikApi.kopsik_google_login(KopsikApi.ctx, credential.Token.AccessToken);
            credential.RevokeTokenAsync(CancellationToken.None).Wait();
        }
示例#23
0
 private void googleLoginTextField_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
 {
     try
     {
         googleLogin();
     }
     catch (AggregateException ex)
     {
         if (ex.InnerException != null &&
             ex.InnerException.Message.Contains("access_denied"))
         {
             KopsikApi.NewError("Login process was canceled", true);
         }
         else
         {
             KopsikApi.NewError(ex.Message, false);
         }
     }
 }
        private bool saveProxySettings()
        {
            if (loading || !mustSaveProxySettings)
            {
                return(true);
            }
            ulong port = 0;

            if (!ulong.TryParse(textBoxProxyPort.Text, out port))
            {
                port = 0;
            }
            return(KopsikApi.kopsik_set_proxy_settings(KopsikApi.ctx,
                                                       checkBoxUseProxy.Checked,
                                                       textBoxProxyHost.Text,
                                                       port,
                                                       textBoxProxyUsername.Text,
                                                       textBoxProxyPassword.Text));
        }
        void DisplayUpdate(bool open, KopsikApi.KopsikUpdateViewItem view)
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker)delegate { DisplayUpdate(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 MainWindowController_Load(object sender, EventArgs e)
        {
            troubleBox.BackColor = Color.FromArgb(239, 226, 121);

            loadWindowLocation();

            KopsikApi.OnError           += OnError;
            KopsikApi.OnUpdate          += OnUpdate;
            KopsikApi.OnLogin           += OnLogin;
            KopsikApi.OnTimeEntryList   += OnTimeEntryList;
            KopsikApi.OnTimeEntryEditor += OnTimeEntryEditor;
            KopsikApi.OnOnlineState     += OnOnlineState;
            KopsikApi.OnReminder        += OnReminder;
            KopsikApi.OnURL             += OnURL;

            if (!KopsikApi.Start())
            {
                MessageBox.Show("Missing callback. See the log file for details");
                shutdown();
            }
        }
        private void timerRunningDuration_Tick(object sender, EventArgs e)
        {
            if (timeEntry.Equals(null) || timeEntry.DurationInSeconds >= 0)
            {
                return;
            }
            if (textBoxDuration.Focused)
            {
                return;
            }
            const int     duration_len = 20;
            StringBuilder sb           = new StringBuilder(duration_len);

            KopsikApi.kopsik_format_duration_in_seconds_hhmmss(
                timeEntry.DurationInSeconds, sb, duration_len);
            string s = sb.ToString();

            if (s != textBoxDuration.Text)
            {
                textBoxDuration.Text = s;
            }
        }
        void DisplayRunningTimerState(KopsikApi.KopsikTimeEntryViewItem te)
        {
            if (InvokeRequired)
            {
                Invoke((MethodInvoker)delegate { DisplayRunningTimerState(te); });
                return;
            }
            duration_in_seconds = te.DurationInSeconds;

            timerRunningDuration.Enabled = true;

            buttonStart.Text = "Stop";

            linkLabelDescription.Top = comboBoxDescription.Top;
            linkLabelDescription.Left = comboBoxDescription.Left;
            linkLabelDescription.Text = te.Description;
            if (linkLabelDescription.Text == "")
            {
                linkLabelDescription.Text = "(no description)";
            }
            linkLabelDescription.Visible = true;

            comboBoxDescription.Visible = false;
            comboBoxDescription.Text = "";

            linkLabelDuration.Top = textBoxDuration.Top;
            linkLabelDuration.Left = textBoxDuration.Left;
            linkLabelDuration.Text = te.Duration;
            linkLabelDuration.Visible = true;

            textBoxDuration.Visible = false;
            textBoxDuration.Text = "";

            linkLabelProject.Text = te.ProjectAndTaskLabel;
            linkLabelProject.Visible = true;
            task_id = 0;
            project_id = 0;
        }
示例#29
0
 internal void Setup(KopsikApi.KopsikTimeEntryViewItem item)
 {
     this.TimeEntry = item;
     this.Render();
 }
 void OnSettings(bool open, ref KopsikApi.KopsikSettingsViewItem settings)
 {
     KopsikApi.KopsikSettingsViewItem copy = settings;
     DisplaySettings(open, copy);
 }
 void OnUpdate(bool open, ref KopsikApi.KopsikUpdateViewItem view)
 {
     DisplayUpdate(open, view);
 }
示例#32
0
 private void TimeEntryCell_MouseClick(object sender, MouseEventArgs e)
 {
     KopsikApi.kopsik_edit(KopsikApi.ctx, TimeEntry.GUID, false, "");
 }
 void DisplayTimeEntryEditor(
     bool open,
     KopsikApi.KopsikTimeEntryViewItem te,
     string focused_field_name)
 {
     if (InvokeRequired)
     {
         Invoke((MethodInvoker)delegate { DisplayTimeEntryEditor(open, te, focused_field_name); });
         return;
     }
     if (open)
     {
         Controls.Remove(loginViewController);
         Controls.Remove(timeEntryListViewController);
         Controls.Add(timeEntryEditViewController);
         timeEntryEditViewController.SetAcceptButton(this);
         timeEntryEditViewController.SetFocus(focused_field_name);
     }
 }
 void DisplaySettings(KopsikApi.KopsikSettingsViewItem view)
 {
     if (InvokeRequired)
     {
         Invoke((MethodInvoker)delegate { DisplaySettings(view); });
         return;
     }
     this.TopMost = view.OnTop;
     timerIdleDetection.Enabled = view.UseIdleDetection;
 }
 void OnWorkspaceSelect(ref KopsikApi.KopsikViewItem first)
 {
     List<KopsikApi.KopsikViewItem> list = KopsikApi.ConvertToViewItemList(ref first);
     DisplayWorkspaceSelect(list);
 }
示例#36
0
 private void labelProject_Click(object sender, EventArgs e)
 {
     KopsikApi.kopsik_edit(KopsikApi.ctx, TimeEntry.GUID, false, KopsikApi.Project);
 }
 void OnTimeEntryList(bool open, ref KopsikApi.KopsikTimeEntryViewItem te)
 {
     List<KopsikApi.KopsikTimeEntryViewItem> list = KopsikApi.ConvertToTimeEntryList(ref te);
     DisplayTimeEntryList(open, list);
 }
 void DisplayUpdate(bool open, KopsikApi.KopsikUpdateViewItem view)
 {
     if (InvokeRequired)
     {
         Invoke((MethodInvoker)delegate { DisplayUpdate(open, view); });
         return;
     }
     // FIXME:
 }
 void OnSettings(bool open,
     ref KopsikApi.KopsikSettingsViewItem settings)
 {
     KopsikApi.KopsikSettingsViewItem view = settings;
     DisplaySettings(view);
 }
 void DisplayUpdate(bool open, KopsikApi.KopsikUpdateViewItem view)
 {
     if (InvokeRequired)
     {
         Invoke((MethodInvoker)delegate { DisplayUpdate(open, view); });
         return;
     }
     if (open)
     {
         aboutWindowController.Show();
         aboutWindowController.BringToFront();
     }
     if (!view.IsUpdateAvailable)
     {
         return;
     }
     if (isUpgradeDialogVisible || aboutWindowController.Visible)
     {
         return;
     }
     isUpgradeDialogVisible = true;
     DialogResult dr = MessageBox.Show(
         "There's a new version of this app available (" + view.Version + ")." +
         Environment.NewLine + "Proceed with the download?",
         "New version available",
         MessageBoxButtons.YesNo, MessageBoxIcon.Question);
     isUpgradeDialogVisible = false;
     if (DialogResult.Yes == dr)
     {
         Process.Start(view.URL);
     }
 }
 void OnTimeEntryEditor(
     bool open,
     ref KopsikApi.KopsikTimeEntryViewItem te,
     string focused_field_name)
 {
     DisplayTimeEntryEditor(open, focused_field_name);
 }
 void DisplayTimeEntryEditor(
     bool open,
     KopsikApi.KopsikTimeEntryViewItem te,
     string focused_field_name)
 {
     if (InvokeRequired)
     {
         Invoke((MethodInvoker)delegate { DisplayTimeEntryEditor(open, 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.Checked = te.Billable;
     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);
 }
 void OnClientSelect(ref KopsikApi.KopsikViewItem first)
 {
     List<KopsikApi.KopsikViewItem> list = KopsikApi.ConvertToViewItemList(ref first);
     DisplayClientSelect(list);
 }
示例#44
0
 public static List<KopsikApi.KopsikTimeEntryViewItem> ConvertToTimeEntryList(
     ref KopsikApi.KopsikTimeEntryViewItem first)
 {
     List<KopsikApi.KopsikTimeEntryViewItem> list =
         new List<KopsikApi.KopsikTimeEntryViewItem>();
     if (Object.ReferenceEquals(null, first))
     {
         return list;
     }
     KopsikApi.KopsikTimeEntryViewItem n = first;
     while (true)
     {
         list.Add(n);
         if (n.Next == IntPtr.Zero)
         {
             break;
         }
         n = (KopsikApi.KopsikTimeEntryViewItem)Marshal.PtrToStructure(
             n.Next, typeof(KopsikApi.KopsikTimeEntryViewItem));
     };
     return list;
 }
 void OnProjectAutocomplete(ref KopsikApi.KopsikAutocompleteItem first)
 {
     List<KopsikApi.KopsikAutocompleteItem> list =
         KopsikApi.ConvertToAutocompleteList(ref first);
     DisplayProjectAutocomplete(list);
 }
        void OnTimeEntryList(bool open, IntPtr first)
        {
            List <KopsikApi.KopsikTimeEntryViewItem> list = KopsikApi.ConvertToTimeEntryList(first);

            DisplayTimeEntryList(open, list);
        }
 void OnTags(ref KopsikApi.KopsikViewItem first)
 {
     List<KopsikApi.KopsikViewItem> list = KopsikApi.ConvertToViewItemList(ref first);
     DisplayTags(list);
 }
示例#48
0
 private void labelDuration_Click(object sender, EventArgs e)
 {
     KopsikApi.kopsik_edit(KopsikApi.ctx, TimeEntry.GUID, false, KopsikApi.Duration);
 }
 void OnTimeEntryAutocomplete(ref KopsikApi.KopsikAutocompleteItem first)
 {
     List<KopsikApi.KopsikAutocompleteItem> list =
         KopsikApi.ConvertToAutocompleteList(ref first);
     DisplayTimeEntryAutocomplete(list);
 }
示例#50
0
 private void labelContinue_Click(object sender, EventArgs e)
 {
     KopsikApi.kopsik_continue(KopsikApi.ctx, TimeEntry.GUID);
 }
        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);
                    }
                }

            }
        }