Пример #1
0
        public void FirstDayOfWeekTest()
        {
            SchedulerDisplayInfo target = new SchedulerDisplayInfo(new CultureInfo("en-US"));
            try
            {
                target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

                PreparePropertyChangedTest();
                target.FirstDayOfWeek = DayOfWeek.Monday;
                Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'FirstDayOfWeek' changing to Monday.");

                PreparePropertyChangedTest();
                target.FirstDayOfWeek = DayOfWeek.Tuesday;
                Assert.IsTrue(NotifiedProperties.Contains("FirstDayOfWeek"), "PropertyChanged event wasn't raised on property 'FirstDayOfWeek' changing to Tuesday.");

                PreparePropertyChangedTest();
                target.FirstDayOfWeek = DayOfWeek.Tuesday;
                Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'FirstDayOfWeek' changing to Tuesday.");

                PreparePropertyChangedTest();
                target.FirstDayOfWeek = DayOfWeek.Wednesday;
                Assert.IsTrue(NotifiedProperties.Contains("FirstDayOfWeek"), "PropertyChanged event wasn't raised on property 'FirstDayOfWeek' changing to Wednesday.");
            }
            finally
            {
                target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged);
            }
        }
Пример #2
0
 public SchedulerMonthModel(SchedulerDisplayInfo displayInfo, DateTime today)
     : base(displayInfo)
 {
     weeks = new SchedulerWeekModel[6];
     for (int i = 0; i < 6; i++)
         weeks[i] = new SchedulerWeekModel(displayInfo, today, DisplayedDays.Week);
 }
Пример #3
0
        public void CalendarWeekRuleTest()
        {
            SchedulerDisplayInfo target = new SchedulerDisplayInfo(new CultureInfo("en-US"));
            try
            {
                target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

                PreparePropertyChangedTest();
                target.CalendarWeekRule = CalendarWeekRule.FirstDay;
                Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'CalendarWeekRule' changing to FirstDay.");

                PreparePropertyChangedTest();
                target.CalendarWeekRule = CalendarWeekRule.FirstFourDayWeek;
                Assert.IsTrue(NotifiedProperties.Contains("CalendarWeekRule"), "PropertyChanged event wasn't raised on property 'CalendarWeekRule' changing to FirstFourDayWeek.");

                PreparePropertyChangedTest();
                target.CalendarWeekRule = CalendarWeekRule.FirstFourDayWeek;
                Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'CalendarWeekRule' changing to FirstFourDayWeek.");

                PreparePropertyChangedTest();
                target.CalendarWeekRule = CalendarWeekRule.FirstFullWeek;
                Assert.IsTrue(NotifiedProperties.Contains("CalendarWeekRule"), "PropertyChanged event wasn't raised on property 'CalendarWeekRule' changing to FirstFullWeek.");
            }
            finally
            {
                target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged);
            }
        }
Пример #4
0
 public SchedulerMonthModel(SchedulerDisplayInfo displayInfo, DateTime today)
     : base(displayInfo)
 {
     weeks = new SchedulerWeekModel[6];
     for (int i = 0; i < 6; i++)
     {
         weeks[i] = new SchedulerWeekModel(displayInfo, today, DisplayedDays.Week);
     }
 }
Пример #5
0
        public SchedulerWeekModel(SchedulerDisplayInfo displayInfo, DateTime today, DisplayedDays displayedDays)
            : base(displayInfo)
        {
            this.displayedDays = displayedDays;

            days = new SchedulerDayModel[(int)displayedDays];
            for (int i = 0; i < days.Length; i++)
                days[i] = new SchedulerDayModel(displayInfo, today);
        }
Пример #6
0
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            DateTime             date        = (DateTime)values[0];
            SchedulerDisplayInfo displayInfo = (SchedulerDisplayInfo)values[1];

            if (displayInfo.WorkingDays[(int)date.DayOfWeek])
            {
                return((2 * displayInfo.WorkingHoursFrom.Hours) + (displayInfo.WorkingHoursFrom.Minutes / 30));
            }
            return(24); // 00:00 - 12:00
        }
Пример #7
0
        public SchedulerWeekModel(SchedulerDisplayInfo displayInfo, DateTime today, DisplayedDays displayedDays)
            : base(displayInfo)
        {
            this.displayedDays = displayedDays;

            days = new SchedulerDayModel[(int)displayedDays];
            for (int i = 0; i < days.Length; i++)
            {
                days[i] = new SchedulerDayModel(displayInfo, today);
            }
        }
Пример #8
0
        public SchedulerViewModel(IEnumerable <Occurrence> occurrences, CultureInfo cultureInfo, bool initializeViewModel, bool initilizeTimer)
        {
            this.occurrences = occurrences;

            displayInfo = new SchedulerDisplayInfo(cultureInfo);

            if (initializeViewModel)
            {
                SetNowAndToday();
                selectedDate = today;
                InitializeViewModel(DisplayMode.Week, today);
            }

            if (initilizeTimer)
            {
                timer          = new Timer(60000); // each minute
                timer.Elapsed += new ElapsedEventHandler(TimerElapsed);
                timer.Start();
            }
        }
Пример #9
0
        public SchedulerViewModel(IEnumerable<Occurrence> occurrences, CultureInfo cultureInfo, bool initializeViewModel, bool initilizeTimer)
        {
            this.occurrences = occurrences;

            displayInfo = new SchedulerDisplayInfo(cultureInfo);

            if (initializeViewModel)
            {
                SetNowAndToday();
                selectedDate = today;
                InitializeViewModel(DisplayMode.Week, today);
            }

            if (initilizeTimer)
            {
                timer = new Timer(60000); // each minute
                timer.Elapsed += new ElapsedEventHandler(TimerElapsed);
                timer.Start();
            }
        }
Пример #10
0
 public SchedulerBaseModel(SchedulerDisplayInfo displayInfo)
 {
     this.displayInfo = displayInfo;
 }
Пример #11
0
 public SchedulerDayModel(SchedulerDisplayInfo displayInfo, DateTime today)
     : base(displayInfo)
 {
     this.today = today.Date;
 }
Пример #12
0
 public SchedulerBaseModel(SchedulerDisplayInfo displayInfo)
 {
     this.displayInfo = displayInfo;
 }
Пример #13
0
        public void WorkingHoursToTest()
        {
            SchedulerDisplayInfo target = new SchedulerDisplayInfo(new CultureInfo("en-US"));
            try
            {
                target.PropertyChanged += new PropertyChangedEventHandler(OnPropertyChanged);

                PreparePropertyChangedTest();
                target.WorkingHoursTo = new TimeSpan(17, 0, 0);
                Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'WorkingHoursTo' changing to 17:0:0.");

                PreparePropertyChangedTest();
                target.WorkingHoursTo = new TimeSpan(16, 0, 0);
                Assert.IsTrue(NotifiedProperties.Contains("WorkingHoursTo"), "PropertyChanged event wasn't raised on property 'WorkingHoursTo' changing to 16:0:0.");

                PreparePropertyChangedTest();
                target.WorkingHoursTo = new TimeSpan(16, 0, 0);
                Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'WorkingHoursTo' changing to 16:0:0.");

                PreparePropertyChangedTest();
                target.WorkingHoursTo = new TimeSpan(15, 0, 0);
                Assert.IsTrue(NotifiedProperties.Contains("WorkingHoursTo"), "PropertyChanged event wasn't raised on property 'WorkingHoursTo' changing to 15:0:0.");

                PreparePropertyChangedTest();
                target.WorkingHoursTo = new TimeSpan(7, 59, 59);
                Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'WorkingHoursTo' changing to 7:59:59.");

                PreparePropertyChangedTest();
                target.WorkingHoursTo = new TimeSpan(24, 0, 1);
                Assert.IsTrue(NotifiedProperties.Count == 0, "PropertyChanged event was incorectly raised on property 'WorkingHoursTo' changing to 24:0:1.");
            }
            finally
            {
                target.PropertyChanged -= new PropertyChangedEventHandler(OnPropertyChanged);
            }
        }
Пример #14
0
 public void WorkingDaysTest()
 {
     SchedulerDisplayInfo target = new SchedulerDisplayInfo(new CultureInfo("en-US"));
     Assert.IsTrue(target.WorkingDays.Length == 7, "'WorkingDays' array must have 7 items.");
 }
Пример #15
0
 public SchedulerDayModel(SchedulerDisplayInfo displayInfo, DateTime today)
     : base(displayInfo)
 {
     this.today = today.Date;
 }
Пример #16
0
 public void MyTestInitialize()
 {
     displayInfo = new SchedulerDisplayInfo(new CultureInfo("en-US"));
     date = new DateTime(2010, 1, 1);
 }