Exemple #1
0
        public void BordersTests(TimeScaleLessThanDay scale)
        {
            int      count = 1000;
            DateTime date  = scale.GetPrevDate(DateTime.Now);

            DateTime[] borders = new DateTime[count];
            for (int i = 0; i < count; i++)
            {
                borders[i] = date;
                DateTime prevDate = date;
                date = scale.GetNextDate(prevDate);
                DateTime prevDate2 = scale.GetPrevDate(date);
                System.Diagnostics.Debug.Assert(prevDate2 == prevDate, String.Format("step {0}: {1} = scale.GetPrevDate({2}). Cant return to prevDate!", i, prevDate2, date));
                if (scale.StartTime > date.TimeOfDay || date.TimeOfDay > scale.EndTime)
                {
                    System.Diagnostics.Debug.Assert(date == borders[i], String.Format("step {0}: {1} = scale.GetNextDate({2}). Borders fail!", i, date, borders[i]));
                }
            }
            for (int i = count - 1; i >= 0; i--)
            {
                DateTime prevDate = date;
                date = scale.GetPrevDate(prevDate);
                System.Diagnostics.Debug.Assert(date == borders[i], String.Format("step {0}: {1} = scale.GetPrevDate({2}). Expected {3}", i, date, prevDate, borders[i]));
            }
        }
        private void HideWeekends(bool hide)
        {
            TimeScaleCollection scales = schedulerControl1.TimelineView.Scales;

            if (hide)
            {
                scales.BeginUpdate();
                try {
                    scales.Clear();
                    scales.Add(new TimeScaleMonth());
                    TimeScaleWorkWeekDay customWorkWeekScale    = new TimeScaleWorkWeekDay();
                    TimeScaleLessThanDay customTimeScaleHour    = new TimeScaleLessThanDay(TimeSpan.FromHours(1));
                    TimeScaleLessThanDay customTimeScaleMinutes = new TimeScaleLessThanDay(TimeSpan.FromMinutes(30));
                    customWorkWeekScale.Width    = 125;
                    customTimeScaleHour.Width    = 125;
                    customTimeScaleMinutes.Width = 125;
                    scales.Add(customWorkWeekScale);
                    scales.Add(customTimeScaleHour);
                    scales.Add(customTimeScaleMinutes);
                }
                finally {
                    scales.EndUpdate();
                }

                checkEdit2.Enabled = true;
            }
            else
            {
                scales.BeginUpdate();
                try {
                    scales.Clear();
                    scales.Add(new TimeScaleMonth());
                    TimeScaleDay dayScale = new TimeScaleDay();
                    scales.Add(dayScale);
                    TimeScaleHour hourScale = new TimeScaleHour();
                    hourScale.Width = 125;
                    scales.Add(hourScale);
                }
                finally {
                    scales.EndUpdate();
                }

                checkEdit2.Enabled = false;
            }
        }