// ========================================
 // method
 // ========================================
 public void ClearCondition()
 {
     _timeSpanTargetKind       = TimeSpanTargetKind.None;
     _isRecentTimeSpanSelected = false;
     _isTimeSpanSelected       = false;
     UpdateText();
 }
        private MemoDateKind ToMemoDateKind(TimeSpanTargetKind kind)
        {
            switch (kind)
            {
            case TimeSpanTargetKind.Modified: {
                return(MemoDateKind.Modified);
            }

            case TimeSpanTargetKind.Created: {
                return(MemoDateKind.Created);
            }

            case TimeSpanTargetKind.Accessed: {
                return(MemoDateKind.Accessed);
            }
            }

            throw new ArgumentException("kind");
        }
        private string ToString(TimeSpanTargetKind kind)
        {
            switch (kind)
            {
            case TimeSpanTargetKind.None: {
                return("");
            }

            case TimeSpanTargetKind.Modified: {
                return("更新");
            }

            case TimeSpanTargetKind.Created: {
                return("作成");
            }

            case TimeSpanTargetKind.Accessed: {
                return("アクセス");
            }
            }

            throw new ArgumentException("kind");
        }
        private void ShowTimeSpanPickForm()
        {
            using (var dialog = new TimeSpanPickForm()) {
                var picker = dialog.TimeSpanPicker;
                picker.TargetKind = _timeSpanTargetKind;
                if (_isRecentTimeSpanSelected)
                {
                    if (_recentTimeSpan.Day > 0)
                    {
                        picker.IsRecentDayChecked = true;
                        picker.RecentDay          = _recentTimeSpan.Day;
                    }
                    else if (_recentTimeSpan.Week > 0)
                    {
                        picker.IsRecentWeekChecked = true;
                        picker.RecentWeek          = _recentTimeSpan.Week;
                    }
                    else if (_recentTimeSpan.Month > 0)
                    {
                        picker.IsRecentMonthChecked = true;
                        picker.RecentMonth          = _recentTimeSpan.Month;
                    }
                }
                else if (_isTimeSpanSelected)
                {
                    picker.IsDateChecked = true;
                    picker.FromDate      = _timeSpan.FromDate;
                    picker.ToDate        = _timeSpan.ToDate;
                }

                if (dialog.ShowDialog(MemopadApplication.Instance.MainForm) == DialogResult.OK)
                {
                    var oldCursor = Cursor.Current;
                    try {
                        Cursor.Current = Cursors.WaitCursor;

                        _isRecentTimeSpanSelected = false;
                        _isTimeSpanSelected       = false;

                        _timeSpanTargetKind = picker.TargetKind;
                        if (picker.TargetKind != TimeSpanTargetKind.None)
                        {
                            if (picker.IsRecentDayChecked)
                            {
                                _isRecentTimeSpanSelected = true;
                                _recentTimeSpan           = new MemoRecentTimeSpan();
                                _recentTimeSpan.DateKind  = ToMemoDateKind(picker.TargetKind);
                                _recentTimeSpan.Day       = picker.RecentDay;
                            }
                            else if (picker.IsRecentWeekChecked)
                            {
                                _isRecentTimeSpanSelected = true;
                                _recentTimeSpan           = new MemoRecentTimeSpan();
                                _recentTimeSpan.DateKind  = ToMemoDateKind(picker.TargetKind);
                                _recentTimeSpan.Week      = picker.RecentWeek;
                            }
                            else if (picker.IsRecentMonthChecked)
                            {
                                _isRecentTimeSpanSelected = true;
                                _recentTimeSpan           = new MemoRecentTimeSpan();
                                _recentTimeSpan.DateKind  = ToMemoDateKind(picker.TargetKind);
                                _recentTimeSpan.Month     = picker.RecentMonth;
                            }
                            else if (picker.IsDateChecked)
                            {
                                _isTimeSpanSelected = true;
                                _timeSpan           = new MemoTimeSpan();
                                _timeSpan.DateKind  = ToMemoDateKind(picker.TargetKind);
                                _timeSpan.FromDate  = picker.FromDate;
                                _timeSpan.ToDate    = picker.ToDate;
                            }
                        }

                        OnValueChanged();
                    } finally {
                        Cursor.Current = oldCursor;
                    }
                    UpdateText();
                }
            }
        }