Ejemplo n.º 1
0
        public void Monthly_FirstSaturday_MonthlyPeriod_1()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);

            wdc.GetModel().Scheduled.Type = ScheduleDefinition.ScheduleType.Monthly;
            wdc.GetModel().Scheduled.MonthlyPeriod.Period = 1;
            wdc.GetModel().Scheduled.StartDate = new DateTime(2019, 2, 1);
            wdc.GetModel().Scheduled.MonthlyPeriod.Type = ScheduleDefinition.Monthly.ScheduleType.First;
            wdc.GetModel().Scheduled.MonthlyPeriod.WeekDay = DayOfWeek.Saturday;

            var controller = wdc.GetScheduleController();
            var days       = controller.GetScheduledDays();
        }
        public WashingDayDefinitionHomeControl(WashingDayEditorController controller, HairAppBl.Interfaces.IHairBl hairbl) : base(controller, hairbl)
        {
            var c = new ScheduleController(controller.GetModel().Scheduled);
            var t = c.Time2NextCareDay(ScheduleController.GetToday());

            //StartCareDay
            var startImage = new Image {
                Source = "start.png", HeightRequest = 22
            };

            var startCareDayTab = new TapGestureRecognizer();

            startCareDayTab.Tapped += (s, e) => {
                StartCareDay?.Invoke(this, new WashingDayCellEventArgs(controller));
            };
            startImage.GestureRecognizers.Add(startCareDayTab);

            if (t == 0)
            {
                HeaderExtensionRight = startImage;
            }

            var text = AppResources.Today;

            if (t > 0)
            {
                text = AppResources.InDays.Replace("{count}", t.ToString());
            }
            HeaderExtensionLeft = new Label
            {
                Text = text
            };
        }
Ejemplo n.º 3
0
        public void GetScheduledDays_Period2()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);

            wdc.GetModel().Scheduled.WeeklyPeriod.Period = 2;
            wdc.GetModel().Scheduled.WeeklyPeriod.WeekDays = new System.Collections.Generic.List <DayOfWeek>
            {
                DayOfWeek.Monday,
            };
            wdc.GetModel().Scheduled.StartDate = new DateTime(2019, 2, 5);

            var res = wdc.GetScheduledDays();

            Assert.True(ScheduleController.IsSameDay(res[0], new DateTime(2019, 2, 11)));
            Assert.True(ScheduleController.IsSameDay(res[1], new DateTime(2019, 2, 25)));
        }
Ejemplo n.º 4
0
        public void Monthly_SecondSaturday_BeforeStart_MonthlyPeriod_2()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);

            wdc.GetModel().Scheduled.Type = ScheduleDefinition.ScheduleType.Monthly;
            wdc.GetModel().Scheduled.MonthlyPeriod.Period = 2;
            wdc.GetModel().Scheduled.StartDate = new DateTime(2019, 2, 23);
            wdc.GetModel().Scheduled.MonthlyPeriod.Type = ScheduleDefinition.Monthly.ScheduleType.First;
            wdc.GetModel().Scheduled.MonthlyPeriod.WeekDay = DayOfWeek.Saturday;

            var controller = wdc.GetScheduleController();
            var days       = controller.GetScheduledDays();

            Assert.AreEqual(new DateTime(2019, 3, 2), days[0]);
            Assert.AreEqual(new DateTime(2019, 5, 4), days[1]);
        }
Ejemplo n.º 5
0
        public void Time2CareDay_is0()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);

            wdc.GetModel().Scheduled.WeeklyPeriod.WeekDays = new System.Collections.Generic.List <DayOfWeek>
            {
                DayOfWeek.Sunday,
                DayOfWeek.Thursday
            };
            wdc.GetModel().Scheduled.WeeklyPeriod.Period = 2;
            wdc.GetModel().Scheduled.StartDate = new DateTime(2019, 2, 5);

            var controller = wdc.GetScheduleController();


            Assert.AreEqual(0, controller.Time2NextCareDay(new DateTime(2019, 2, 7)));
        }
Ejemplo n.º 6
0
        public void GetScheduledDays_Period2_twoDays()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);

            wdc.GetModel().Scheduled.WeeklyPeriod.WeekDays = new System.Collections.Generic.List <DayOfWeek>
            {
                DayOfWeek.Sunday,
                DayOfWeek.Thursday
            };
            wdc.GetModel().Scheduled.WeeklyPeriod.Period = 2;
            wdc.GetModel().Scheduled.StartDate = new DateTime(2019, 2, 5);

            var res = wdc.GetScheduledDays();


            Assert.True(ScheduleController.ContainsDay(res, new DateTime(2019, 2, 7)));
            Assert.True(ScheduleController.ContainsDay(res, new DateTime(2019, 2, 10)));
            Assert.True(ScheduleController.ContainsDay(res, new DateTime(2019, 2, 21)));
            Assert.True(ScheduleController.ContainsDay(res, new DateTime(2019, 2, 24)));
        }
Ejemplo n.º 7
0
        public void GetScheduledDays_CheckOtherWeekDay()
        {
            WashingDayDefinition wd = new WashingDayDefinition();
            AlarmController      ac = new AlarmController(null, null, null);

            WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac);

            wdc.GetModel().Scheduled.WeeklyPeriod.WeekDays = new System.Collections.Generic.List <DayOfWeek>
            {
                DayOfWeek.Sunday
            };

            var res = wdc.GetScheduledDays();

            Assert.AreEqual(DayOfWeek.Sunday, res[0].DayOfWeek);
            Assert.AreEqual(DayOfWeek.Sunday, res[1].DayOfWeek);
        }
        public WashingDayDefinitionControl(WashingDayEditorController controller, HairAppBl.Interfaces.IHairBl hairbl) : base(hairbl)
        {
            this.WdController = controller;
            var def = WdController.GetModel();

            HeaderName = def.Name;
            Color      = def.ItemColor;

            var descriptionLabel = Common.GetCalendarDetailsRow("description.png", new Label
            {
                Text      = def.Description,
                FontSize  = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
                IsVisible = !String.IsNullOrWhiteSpace(def.Description)
            }, hairbl);

            descriptionLabel.IsVisible = !String.IsNullOrWhiteSpace(def.Description);

            var scheduleLabel = Common.GetCalendarDetailsRow("schedule.png", new Label
            {
                Text     = WdController.GetSchedule(),
                FontSize = Device.GetNamedSize(NamedSize.Small, typeof(Label)),
            }, hairbl);


            var editLabel = new Label
            {
                Text  = AppResources.Edit,
                Style = (Style)hairbl.Resources["DetailsActionLabel"]
            };

            var editControl = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    new Image
                    {
                        Source = "edit.png",
                        Style  = (Style)hairbl.Resources["DetailsActionImage"]
                    },
                    editLabel
                }
            };
            var editClicked = new TapGestureRecognizer();

            editClicked.Tapped += EditButton_Clicked;

            editControl.GestureRecognizers.Add(editClicked);

            var deleteLabel = new Label
            {
                Text  = AppResources.Remove,
                Style = (Style)hairbl.Resources["DetailsActionLabel"]
            };

            var deleteControl = new StackLayout
            {
                Orientation = StackOrientation.Horizontal,
                Children    =
                {
                    new Image
                    {
                        Source = "remove.png",
                        Style  = (Style)hairbl.Resources["DetailsActionImage"]
                    },
                    deleteLabel
                }
            };
            var deleteClicked = new TapGestureRecognizer();

            deleteClicked.Tapped += DeleteButton_Clicked;

            deleteControl.GestureRecognizers.Add(deleteClicked);

            var routineList = new StackLayout
            {
                Orientation = StackOrientation.Vertical,
            };

            var listContainer = Common.GetCalendarDetailsRow("list.png", routineList, hairbl);

            foreach (var r in def.Routines)
            {
                routineList.Children.Add(new Label {
                    Text = WdController.GetRoutineById(r).Name
                });
            }

            DetailsContent.Add(descriptionLabel);
            DetailsContent.Add(scheduleLabel);
            DetailsContent.Add(listContainer);
            DetailsContent.Add(new StackLayout
            {
                Orientation       = StackOrientation.Horizontal,
                HorizontalOptions = LayoutOptions.Center,
                Spacing           = 30,
                Children          =
                {
                    editControl, deleteControl
                }
            });
        }