private void btnStartTask_Click(object sender, RoutedEventArgs e)
        {
            TaskLeaveTime         = new TimeSpan(0, 25, 0);
            LabelTimer.Foreground = new SolidColorBrush(Colors.Yellow);
            LabelTimer.Content    = "25:00";

            // 任务停止
            if (TaskTimer.IsEnabled)
            {
                TaskTimer.Stop();
                btnStartTask.Content = "开始";

                if ((CurrentTaskStatus == TaskStatus.TaskRunning) &&
                    (CurrentSelectIndex != -1))
                {
                    if (DateTime.Now > CurrentTaskBeginTime.AddMinutes(5))
                    {
                        // Update Item to Calender
                        OutlookTaskManager.UpdateTaskCalendar(
                            TaskListData[CurrentSelectIndex],
                            CurrentTaskBeginTime,
                            DateTime.Now);
                    }
                }

                btnSynch.IsEnabled = true;
                CurrentTaskStatus  = TaskStatus.TaskStop;
            }
            else if (CurrentSelectIndex != -1)
            {
                TaskTimer.Start();
                btnStartTask.Content = "结束";
                CurrentTaskStatus    = TaskStatus.TaskRunning;
                btnSynch.IsEnabled   = false;
                TaskTimerLableSB.Stop();
                CurrentTaskBeginTime = DateTime.Now;

                SoundPlayer player = new SoundPlayer(Pomodairo.Properties.Resources.ticking);
                player.Play();
            }
        }
        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);
        }