/// <summary>
 /// 刷新方块颜色
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Refresh_Click(object sender, RoutedEventArgs e)
 {
     /*
      * _rectangleRegisteTable 已在 ResetRectangleColor() 内部重新初始化,
      * 这里无需再次执行 _rectangleRegisteTable = new HashSet<Rectangle>()
      */
     ResetRectangle();
     DrawRectangleColor(_model?.GroupDateTimesByTotal(), true);
     Blink.BlinkedRectangles.Clear();
 }
        /// <summary>
        /// 打开文件选取器
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void OpenFileButtonAsync_Click(object sender, RoutedEventArgs e)
        {
            FileOpenPicker openPicker = new FileOpenPicker {
                ViewMode = PickerViewMode.Thumbnail,
                SuggestedStartLocation = PickerLocationId.ComputerFolder
            };

            openPicker.FileTypeFilter.Add(".txt");
            openPicker.FileTypeFilter.Add(".mast");

            _file = await openPicker.PickSingleFileAsync();

            if (_file != null)
            {
                ProgressBoard progressBoard = new ProgressBoard();
                ProgressBoard.SlideOn(CurrentRectanglesCanvas, progressBoard);
                ResetRectangle();  // 每次选择文件之后都要重置方块颜色

                Windows.Storage.AccessCache.StorageApplicationPermissions.FutureAccessList.Add(_file);
                string text = await FileIO.ReadTextAsync(_file);

                try {
                    IEnumerable <string> lines = DatetimeParser.SplitByLine(text);
                    _model = new StatistTotalByDateTimeModel(lines);
                    ExtendStackCanvasByFilterOldRecorders(EarlierThanEarliestRectangle(_model.ToStatistTotalByDateTimeArray().ToList(), _earliestRectangle), _earliestRectangle);
                    ProgressBoard.CancelOn(CurrentRectanglesCanvas, progressBoard);
                    foreach (Canvas canvas in StackCanvas.Children)
                    {
                        ProgressBoard.SlideOn(canvas, new ProgressBoard());
                    }
                    TioSalamanca[] res = _model.GroupDateTimesByTotal();
#if DEBUG
                    for (int level = 0; level < res.Length; level++)
                    {
                        Debug.WriteLine($"level: {level + 1}");
                        Debug.WriteLine($"  List res[{level}]:");
                        foreach (var group in res[level])
                        {
                            Debug.WriteLine($"    Total: {group.Key}");
                            foreach (var item in group)
                            {
                                Debug.WriteLine($"      {item}");
                            }
                        }
                    }
#endif
                    DrawRectangleColor(res, false);
                }
                catch (ArgumentException err) {
                    PopErrorDialogAsync(err.Message);
                }
                _saveMode = SaveMode.OrginalFile; // 表示当前的操作基于磁盘上已有的文件
            }
        }