Exemple #1
0
        private void tbTime_TextChanged(object sender, EventArgs e)
        {
            // Ignore if programatically changing value (from timer)
            if (ignoreTextChange)
            {
                return;
            }

            TimeSpan time = JiraHelpers.JiraTimeToTimeSpan(tbTime.Text);

            if (time.TotalMilliseconds == 0)
            {
                return;
            }

            TimerState state = WatchTimer.GetState();

            state.TotalTime = time;
            state.StartTime = DateTime.Now;
            WatchTimer.SetState(state);
        }
Exemple #2
0
        public void PostAndReset()
        {
            using (var worklogForm = new WorklogForm(WatchTimer.GetInitialStartTime(), WatchTimer.TimeElapsedNearestMinute, Comment, EstimateUpdateMethod, EstimateUpdateValue))
            {
                UpdateRemainingEstimate(worklogForm);
                var formResult = worklogForm.ShowDialog(this);
                if (formResult == DialogResult.OK)
                {
                    Comment = worklogForm.Comment.Trim();
                    EstimateUpdateMethod = worklogForm.estimateUpdateMethod;
                    EstimateUpdateValue  = worklogForm.EstimateValue;

                    PostAndReset(cbJira.Text, worklogForm.InitialStartTime, WatchTimer.TimeElapsedNearestMinute, Comment, EstimateUpdateMethod, EstimateUpdateValue);
                }
                else if (formResult == DialogResult.Yes)
                {
                    Comment = string.Format("{0}:{1}{2}", DateTime.Now.ToString("g"), Environment.NewLine, worklogForm.Comment.Trim());
                    EstimateUpdateMethod = worklogForm.estimateUpdateMethod;
                    EstimateUpdateValue  = worklogForm.EstimateValue;
                    UpdateOutput();
                }
            }
        }
Exemple #3
0
        public MainForm()
        {
            settings = Settings.Instance;
            if (!settings.Load())
            {
                MessageBox.Show(string.Format("An error occurred while loading settings for Jira StopWatch. Your configuration file has most likely become corrupted.{0}{0}And older configuration file has been loaded instead, so please verify your settings.", Environment.NewLine), "Jira StopWatch");
            }

            Logger.Instance.LogfilePath = Path.Combine(Application.UserAppDataPath, "jirastopwatch.log");
            Logger.Instance.Enabled     = settings.LoggingEnabled;

            restRequestFactory    = new RestRequestFactory();
            jiraApiRequestFactory = new JiraApiRequestFactory(restRequestFactory);

            restClientFactory         = new RestClientFactory();
            restClientFactory.BaseUrl = this.settings.JiraBaseUrl;

            jiraApiRequester = new JiraApiRequester(restClientFactory, jiraApiRequestFactory);

            jiraClient = new JiraClient(jiraApiRequestFactory, jiraApiRequester);

            InitializeComponent();

            pMain.HorizontalScroll.Maximum = 0;
            pMain.AutoScroll             = false;
            pMain.VerticalScroll.Visible = false;
            pMain.AutoScroll             = true;

            Text = string.Format("{0} {1}", Application.ProductName, Application.ProductVersion);

            cbFilters.DropDownStyle = ComboBoxStyle.DropDownList;
            cbFilters.DisplayMember = "Name";

            ticker = new Timer();
            // First run should be almost immediately after start
            ticker.Interval = firstDelay;
            ticker.Tick    += ticker_Tick;

            idleTicker          = new Timer();
            idleTicker.Interval = idleCheckInterval;
            idleTicker.Tick    += idle_Tick;

            runningTicker          = new Timer();
            runningTicker.Interval = runningCheckInterval;
            runningTicker.Tick    += running_Tick;

            backupTicker          = new Timer();
            backupTicker.Interval = backupCheckInterval;
            backupTicker.Tick    += backup_Tick;

            backupTimer = new WatchTimer();

            // load backup timer state
            TimerState backupTimerState = new TimerState
            {
                TotalTime = settings.BackupTimer
            };

            backupTimer.SetState(backupTimerState);

            UpdateBackupTime();
        }
Exemple #4
0
 public void Pause()
 {
     WatchTimer.Pause();
     UpdateOutput();
 }
Exemple #5
0
 public void Start()
 {
     WatchTimer.Start();
     UpdateOutput();
 }