Пример #1
0
        public void SelectRangeMethod()
        {
            ArrayList list            = new ArrayList();
            SelectedDatesCollection s = new SelectedDatesCollection(list);

            s.Add(DateTime.Today);
            s.Add(DateTime.Today);
            // Internally clears the list
            s.SelectRange(new DateTime(2000, 1, 1), new DateTime(2001, 1, 1));

            Assert.AreEqual(367, s.Count, "A1");
        }
        private void SelectRange(DateTime dateFrom, DateTime dateTo)
        {
            Debug.Assert(dateFrom <= dateTo, "Bad Date Range");

            // see if this range differs in any way from the current range
            // these checks will determine this because the colleciton is sorted
            TimeSpan ts = dateTo - dateFrom;
            SelectedDatesCollection selectedDates = Control.SelectedDates;

            if (selectedDates.Count != ts.Days + 1 ||
                selectedDates[0] != dateFrom ||
                selectedDates[selectedDates.Count - 1] != dateTo)
            {
                selectedDates.SelectRange(dateFrom, dateTo);
                Control.RaiseSelectionChangedEvent();
            }
        }