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 }; }
public void RoutineCanBeAdded_Order_is_correct() { WashingDayDefinition wd = new WashingDayDefinition(); AlarmController ac = new AlarmController(null, null, null); WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac); wdc.AddRoutine(allRoutines[5]); wdc.AddRoutine(allRoutines[1]); wdc.AddRoutine(allRoutines[2]); wdc.AddRoutine(allRoutines[4]); wdc.AddRoutine(allRoutines[3]); string sortOrder = ""; foreach (var item in wdc.GetRoutineDefinitions()) { sortOrder += item.Name; } Assert.AreEqual(wdc.GetRoutineDefinitions()[0], allRoutines[5], sortOrder); Assert.AreEqual(wdc.GetRoutineDefinitions()[1], allRoutines[1], sortOrder); Assert.AreEqual(wdc.GetRoutineDefinitions()[2], allRoutines[2], sortOrder); Assert.AreEqual(wdc.GetRoutineDefinitions()[3], allRoutines[4], sortOrder); Assert.AreEqual(wdc.GetRoutineDefinitions()[4], allRoutines[3], sortOrder); }
private void OpenPageIfNeeded() { if (!App.MainSession.Initialized) { /* Device.BeginInvokeOnMainThread(() => * { * var page = new IntroPage(App.MainSession.GetAllWashingDays(), App.BL, mAlarmController); * page.PageClosed += IntroPage_Closed; * Navigation.PushAsync(page, true); * }); * return;*/ } if (!String.IsNullOrEmpty(App.washdayToShow)) { var day = App.MainSession.GetWashingDayById(App.washdayToShow); var contr = new WashingDayEditorController(day, App.MainSession.GetAllDefinitions(), mAlarmController); var wdInstance = contr.GetWashingDayInstance(ScheduleController.GetToday()); App.washdayToShow = String.Empty; Device.BeginInvokeOnMainThread(() => { Navigation.PushAsync(new WashDayInstance(day, wdInstance, mHairBl), true); }); ; } Device.BeginInvokeOnMainThread(() => { //var helpController = new Controller.HelpController(); //helpController.Add("Foo", "Des", "Tooltip", mAddCareDayButton); //var diaog = new HelpPage(helpController); // Open a PopupPage //Navigation.PushPopupAsync(diaog); }); }
private void WashDay_Edited(object sender, WashingDayDefinitionControl.WashingDayCellEventArgs e) { var contr = new WashingDayEditorController(e.Controller.GetModel(), App.MainSession.GetAllDefinitions(), this.mAlarmController); var editor = new WashDayEditor(mMainSessionController, contr, false, mHairbl); Navigation.PushAsync(editor); }
public void AddRoutine_CheckNullArgument() { WashingDayDefinition wd = new WashingDayDefinition(); AlarmController ac = new AlarmController(null, null, null); WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac); Assert.Throws <System.ArgumentNullException>(delegate { wdc.AddRoutine(null); }); }
public AddRoutineDialog(WashingDayEditorController controller, HairAppBl.Interfaces.IHairBl hairbl) : this() { this.mWashingDayEditorController = controller; mHairbl = hairbl; RefreshList(); AddButton.Clicked += AddButton_Clicked; openSettingsButton.Clicked += OpenSettingsButton_Clicked; }
public void AddWashDay() { var def = new WashingDayDefinition(); def.ID = Guid.NewGuid().ToString(); var contr = new WashingDayEditorController(def, App.MainSession.GetAllDefinitions(), this.mAlarmController); var editor = new WashDayEditor(mMainSessionController, contr, true, mHairbl); Navigation.PushAsync(editor); }
public void RoutineCanBeAdded() { WashingDayDefinition wd = new WashingDayDefinition(); AlarmController ac = new AlarmController(null, null, null); WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac); var r = allRoutines[0]; wdc.AddRoutine(r); Assert.True(wdc.GetRoutineDefinitions().Contains(r)); Assert.False(wdc.GetUnusedRoutineDefinitions().Contains(r)); }
public void MoveUp() { WashingDayDefinition wd = new WashingDayDefinition(); AlarmController ac = new AlarmController(null, null, null); WashingDayEditorController wdc = new WashingDayEditorController(wd, allRoutines, ac); var unused = wdc.GetUnusedRoutineDefinitions(); wdc.AddRoutine(unused[0]); wdc.AddRoutine(unused[1]); wdc.AddRoutine(unused[2]); wdc.MoveUp(unused[1]); Assert.AreEqual(wdc.GetRoutineDefinitions()[0], unused[1]); }
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 WashDayEditor(MainSessionController mainSession, WashingDayEditorController wdController, Boolean create, HairAppBl.Interfaces.IHairBl hairbl) { InitializeComponent(); mHairbl = hairbl; mCreate = create; mWashingDayEditorController = wdController; mMainSessionController = mainSession; RefreshList(); var saveClose = new NavigationControl(AppResources.Cancel, AppResources.Save, hairbl); SaveButtonContainer.Content = saveClose.View; //Events this.AddRoutine.Clicked += AddRoutine_Clicked; saveClose.RightButton.Clicked += OKButton_Clicked; saveClose.LeftButton.Clicked += CancelButton_Clicked; var colorButtonClicked = new TapGestureRecognizer(); colorButtonClicked.Tapped += ColorClicked_Tapped; colorButton.GestureRecognizers.Add(colorButtonClicked); InitFields(); //Resources mDefineYourCareDayLabel.Text = AppResources.DefineYourCareDay; AddRoutine.Text = AppResources.AddRoutine; mScheduleLabel.Text = AppResources.Schedule; mWeekSelectionEveryLabel.Text = AppResources.Every; mWeekSelectionEveryWeek.Text = AppResources.Weeks; mDaysSelectionEveryLabel.Text = AppResources.Every; mDaysSelectionDaysLabel.Text = AppResources.Days; mStartDateLabel.Text = AppResources.StartDate; mRoutinesLabel.Text = AppResources.Routines; AddDescription.Text = AppResources.AddDescription; mCheckBoxMonday.DefaultText = AppResources.Monday; mCheckBoxTuesday.DefaultText = AppResources.Tuesdays; mCheckBoxWednesday.DefaultText = AppResources.Wednesday; mCheckBoxThursday.DefaultText = AppResources.Thursday; mCheckBoxFriday.DefaultText = AppResources.Friday; mCheckBoxSaturday.DefaultText = AppResources.Saturday; mCheckBoxSunday.DefaultText = AppResources.Sunday; }
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 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))); }
public void RefreshList() { this.mWashDayList.Children.Clear(); var orderedList = mWashingDays.OrderBy(x => ((new ScheduleController(x.Scheduled)).Time2NextCareDay(ScheduleController.GetToday()))); foreach (var r in orderedList) { var wdController = new WashingDayEditorController(r, App.MainSession.GetAllDefinitions(), mAlarmController); var c = new WashingDayDefinitionHomeControl(wdController, App.BL); c.Removed += WashDay_Removed; c.Edited += WashDay_Edited; c.StartCareDay += WashDay_StartCareDay; this.mWashDayList.Children.Add(c.View); helpItem = c; } }
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]); }
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))); }
private void RefreshList(DateTime date) { PlanedWashDaysContainer.IsVisible = false; DoneWashDaysContainer.IsVisible = false; this.PlanedWashDays.Children.Clear(); var futureDays = mMainSessionController.GetFutureDays(); var instances = mMainSessionController.GetInstancesByDate(); if (futureDays.ContainsKey(date)) { if (date >= ScheduleController.GetToday()) { PlanedWashDaysContainer.IsVisible = true; foreach (var d in futureDays[date]) { var wdController = new WashingDayEditorController(d, App.MainSession.GetAllDefinitions(), mAlarmController); var c = new WashingDayDefinitionControl(wdController, App.BL); c.Edited += WashingDayEdited; c.Removed += C_Removed; this.PlanedWashDays.Children.Add(c.View); } } } this.DoneWashDays.Children.Clear(); if (instances.ContainsKey(date)) { PlanedWashDaysContainer.IsVisible = false; DoneWashDaysContainer.IsVisible = true; foreach (var d in instances[date]) { var def = mMainSessionController.GetWashingDayById(d.WashDayID); var c = new WashingDayInstanceCalendarCell(d, def, App.BL); c.Openclicked += C_Openclicked; c.ImageClicked += C_ImageClicked; this.DoneWashDays.Children.Add(c.View); } } }
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))); }
public void Instantiate() { var wdController = new WashingDayEditorController(new WashingDayDefinition(), allRoutines, new AlarmController(null, null, null)); WashDayEditor d = new WashDayEditor(msCOntroller, wdController, true, hairAppBl); }
public WashingDayCellEventArgs(WashingDayEditorController controller) { this.Controller = controller; }
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 } }); }