private void btnInterruption_Click(object sender, RoutedEventArgs e) { if (CurrentSelectIndex != -1) { TaskListData[CurrentSelectIndex].TaskTimeInterrupt++; TaskGrid.ItemsSource = null; TaskGrid.ItemsSource = TaskListData; OneNoteTaskManager.UpdateTaskItem(TaskListData[CurrentSelectIndex]); } }
private void doTaskTimerTick(object sender, EventArgs e) { switch (CurrentTaskStatus) { case TaskStatus.TaskRunning: { if (TaskLeaveTime.TotalSeconds > 0) { if (TaskLeaveTime.TotalSeconds == 60) { LabelTimer.Foreground = new SolidColorBrush(Colors.Red); } TaskLeaveTime = TaskLeaveTime.Subtract(new TimeSpan(0, 0, 1)); } else { CurrentTaskStatus = TaskStatus.TaskRest; LabelTimer.Foreground = new SolidColorBrush(Color.FromRgb(0, 255, 0)); CurrentRestCount++; CurrentRestTime = CurrentRestCount % 4 == 0 ? 20 : 5; CurrentRestTime *= 60; TaskListData[CurrentSelectIndex].TaskTimeUsage++; // Update OneNote data OneNoteTaskManager.UpdateTaskItem(TaskListData[CurrentSelectIndex]); TaskGrid.ItemsSource = null; TaskGrid.ItemsSource = TaskListData; LabelTask.Content = String.Format("{0}({1}/{2})", TaskListData[CurrentSelectIndex].TaskName, TaskListData[CurrentSelectIndex].TaskTimeUsage, TaskListData[CurrentSelectIndex].TaskTimeEdit); SoundPlayer player = new SoundPlayer(Pomodairo.Properties.Resources.alarm); player.Play(); TaskTimerLableSB.RepeatBehavior = new RepeatBehavior(20); TaskTimerLableSB.Begin(); TaskTimer.Stop(); // Update Item to Calender OutlookTaskManager.UpdateTaskCalendar( TaskListData[CurrentSelectIndex], DateTime.Now.AddMinutes(-25), DateTime.Now); // 闪烁窗口 //WindowExtensions.FlashWindow(Application.Current.MainWindow, 10); if (this.WindowState == WindowState.Minimized) { this.WindowState = WindowState.Normal; } } } break; case TaskStatus.TaskRest: { if (TaskLeaveTime.TotalSeconds < CurrentRestTime) { TaskLeaveTime = TaskLeaveTime.Add(new TimeSpan(0, 0, 1)); } else { CurrentTaskStatus = TaskStatus.TaskStop; // 动画效果 TaskTimerLableSB.RepeatBehavior = new RepeatBehavior(50); TaskTimerLableSB.Begin(); } } break; case TaskStatus.TaskStop: { TaskTimer.Stop(); btnStartTask.Content = "开始"; btnNext.Visibility = Visibility.Visible; btnSynch.IsEnabled = true; } break; } LabelTimer.Content = String.Format("{0:D2}:{1:D2}", TaskLeaveTime.Minutes, TaskLeaveTime.Seconds); }