示例#1
0
        private string GetTimeDisplayString()
        {
            string   _timeInterval  = string.Empty;
            DateTime _startDateTime = UnSortedFilesUC.Current.Rt.DateTimeCache[Event[0].taken_time];
            DateTime _endDateTime   = UnSortedFilesUC.Current.Rt.DateTimeCache[Event[Event.Count - 1].taken_time];

            if (UnSortedFilesUC.Current.GroupingEventInterval < 24 * 60)
            {
                if (Event.Count == 1) //只有一筆事件
                {
                    _timeInterval = _startDateTime.ToString("yyyy/MM/dd dddd HH:mm");
                }
                else
                {
                    if (_startDateTime.ToString("yyyy/MM/dd") == _endDateTime.ToString("yyyy/MM/dd")) //同一天
                    {
                        _timeInterval = _startDateTime.ToString("yyyy/MM/dd dddd HH:mm") + " - " + _endDateTime.ToString("HH:mm");
                    }
                    else
                    {
                        _timeInterval = _startDateTime.ToString("yyyy/MM/dd dddd HH:mm") + " - " + _endDateTime.ToString("yyyy/MM/dd dddd HH:mm");
                    }
                }
            }

            if (UnSortedFilesUC.Current.GroupingEventInterval == UnSortedFilesUC.BY_DAY)
            {
                _timeInterval = _startDateTime.ToString("yyyy/MM/dd dddd");
            }

            if (UnSortedFilesUC.Current.GroupingEventInterval == UnSortedFilesUC.BY_WEEK)
            {
                DateTime _startOfWeek = UnSortedFilesUC.StartOfWeek(_startDateTime);
                DateTime _endOfWeek   = _startOfWeek.AddDays(6);

                _timeInterval = _startOfWeek.ToString("yyyy/MM/dd") + " - " +
                                ((_startOfWeek.Year != _endOfWeek.Year) ? _endOfWeek.ToString("yyyy/MM/dd") : _endOfWeek.ToString("MM/dd"));
            }

            if (UnSortedFilesUC.Current.GroupingEventInterval == UnSortedFilesUC.BY_MONTH)
            {
                _timeInterval = _startDateTime.ToString("yyyy/MM");
            }

            return(_timeInterval);
        }
示例#2
0
        private void By_Day(int dayType)
        {
            Dictionary <string, List <FileChange> > _day_Files = new Dictionary <string, List <FileChange> >();

            Events = new List <List <FileChange> >();

            foreach (FileChange _item in RtData.file_changes)
            {
                DateTime _dt = DateTimeCache[_item.taken_time];

                string _by = string.Empty;

                if (dayType == UnSortedFilesUC.BY_DAY)
                {
                    _by = _dt.ToString("yyyy-MM-dd");
                }

                if (dayType == UnSortedFilesUC.BY_WEEK)
                {
                    _by = UnSortedFilesUC.StartOfWeek(_dt).ToString("yyyy-MM-dd");
                }

                if (dayType == UnSortedFilesUC.BY_MONTH)
                {
                    _by = _dt.ToString("yyyy-MM");
                }

                if (!_day_Files.ContainsKey(_by))
                {
                    _day_Files.Add(_by, new List <FileChange>());
                }

                _day_Files[_by].Add(_item);
            }

            _day_Files.Keys.ToList().Sort();

            foreach (string _day in _day_Files.Keys)
            {
                Events.Add(_day_Files[_day]);
            }
        }