public SchedulePage() { InitializeComponent(); _vm = new SchedulePageViewModel(); this.DataContext = _vm; gridSchedule.ItemsSource = _vm.ScheduleDetails; gridSchedule.MouseDoubleClick += GridSchedule_MouseDoubleClick; gridSchedule.PreviewKeyDown += GridSchedule_PreviewKeyDown; // dch rkl 11/01/2016 Enter to select ticket // dch rkl 11/22/2016 select full text on focus filterStartDate.GotFocus += textbox_GotFocus; filterEndDate.GotFocus += textbox_GotFocus; filterStartDate.Focusable = true; Keyboard.Focus(filterStartDate); //bk 01/24/2017 if previous filter set - application only if (App.Current.Properties["filterStartDate"] != null) { _vm.DefaultStartDate = (DateTime)App.Current.Properties["filterStartDate"]; filterStartDate.SelectedDate = (DateTime)App.Current.Properties["filterStartDate"]; } if (App.Current.Properties["filterEndDate"] != null) { _vm.DefaultEndDate = (DateTime)App.Current.Properties["filterEndDate"]; filterEndDate.SelectedDate = (DateTime)App.Current.Properties["filterEndDate"]; } if (App.Current.Properties["filterStartDate"] != null && App.Current.Properties["filterEndDate"] != null) { _vm.filterScheduledAppointments((DateTime)filterStartDate.SelectedDate, (DateTime)filterEndDate.SelectedDate); } }
public void PrevFromFirstItemNotAllowed() { Schedule schedule = BaseSchedule.Build(); SchedulePageViewModel model = CreateViewModel(schedule); Assert.False(model.PreviousCommand.CanExecute(null)); }
public SchedulePage(Schedule schedule) { this.schedule = schedule; Debug.WriteLine($"SchedulePage: schedule ID = '{this.schedule.ScheduleId}', has {this.schedule.Items.Count} items"); var app = Application.Current as App; this.viewModel = new SchedulePageViewModel(this.schedule, app.RecMan, app.AnalyticsEventTracker, app.Resources, app.AppRepository, app.Config); this.viewModel.ScheduleFinished += ScheduleFinished; this.viewModel.MaxRecordingTimeReached += OnMaxRecordingTimeReached; this.viewModel.PropertyChanged += OnViewModelPropertyChanged; BindingContext = this.viewModel; Debug.WriteLine("View model for schedule page created and set as the binding context"); InitializeComponent(); var recordButtonSize = Device.GetNamedSize(NamedSize.Default, RecordButton) * 6.5; RecordButton.WidthRequest = recordButtonSize; RecordButton.HeightRequest = recordButtonSize; // On iOS page OnDisappearing is not called when app backgrounds, so we need to hook into // app sleep event directly. // On Android page OnDisappearing is called, so this is not needed but it doesnt cause problem app.AppSleep += OnAppSleep; }
public void FirstScheduleItemSelected() { Schedule schedule = BaseSchedule.Build(); SchedulePageViewModel model = CreateViewModel(schedule); Assert.NotNull(model.ItemViewModel); }
public void CounterIndexAndTotal() { var nonRecordingVideo = VideoItem.WithRecordingEnabled(false).Build(); var recordingVideo = VideoItem.Build(); var recordingVideo2 = VideoItem.Build(); var nonRecordingImage = ImageItem.WithRecordingEnabled(false).Build(); var recordingImage = ImageItem.Build(); Schedule schedule = new ScheduleBuilder() .WithItems( recordingVideo, nonRecordingImage, recordingImage, recordingVideo2, nonRecordingVideo ) .Build(); SchedulePageViewModel model = CreateViewModel(schedule); Assert.Equal(1, model.ItemViewModel.CounterIndex); Assert.Equal(3, model.ItemViewModel.CounterTotal); // move to third model.NextCommand.Execute(null); model.NextCommand.Execute(null); Assert.Equal(2, model.ItemViewModel.CounterIndex); Assert.Equal(3, model.ItemViewModel.CounterTotal); }
public SchedulePageViewModelTests() { this.appointmentServiceMock = new Mock <IAppointmentService>(); this.dialogServiceMock = new Mock <IPageDialogService>(); var navigationServiceMock = new Mock <INavigationService>(); this.viewModel = new SchedulePageViewModel( this.appointmentServiceMock.Object, this.dialogServiceMock.Object, navigationServiceMock.Object); }
public void PrevNextFromMiddleItemAllowed() { Schedule schedule = new ScheduleBuilder() .WithItems(ImageItem.Build(), VideoItem.Build(), ImageItem.Build()) .Build(); SchedulePageViewModel model = CreateViewModel(schedule); // move to middle model.NextCommand.Execute(null); Assert.True(model.PreviousCommand.CanExecute(null)); Assert.True(model.NextCommand.CanExecute(null)); }
public void NextFromLastItemFinishes() { Schedule schedule = BaseSchedule.Build(); SchedulePageViewModel model = CreateViewModel(schedule); model.NextCommand.Execute(null); Assert.Raises <EventArgs>( attach: handler => model.ScheduleFinished += handler, detach: handler => model.ScheduleFinished -= handler, testCode: () => model.NextCommand.Execute(null) ); }
public void RetryRecording() { Schedule schedule = BaseSchedule.Build(); SchedulePageViewModel model = CreateViewModel(schedule); model.RecordCommand.Execute(null); // start Assert.Equal(ScheduleItemStateType.Recording, model.DisplayState); model.RecordCommand.Execute(null); // stop Assert.Equal(ScheduleItemStateType.Finish, model.DisplayState); model.RetryCommand.Execute(null); Assert.Equal(ScheduleItemStateType.Start, model.DisplayState); Assert.True(model.ShowRecordButton, "Record button should show"); }
public SchedulerViewModelTests() { _entrySourceMock = new Mock <IGetScheduleEntriesQuery>(); _entrySourceMock.Setup(p => p.Execute()).Callback(() => { _entries = new List <EntryDto> { new EntryDto { From = DateTime.Now, To = DateTime.Now.AddMinutes(30), Id = 1, Metadata = null, Source = "Test", Title = "Test One", SourceId = "1" }, new EntryDto { From = DateTime.Now, To = DateTime.Now.AddMinutes(30), Id = 2, Metadata = null, Source = "Test", Title = "Test Two", SourceId = "2" }, new EntryDto { From = DateTime.Now, To = DateTime.Now.AddMinutes(30), Id = 3, Metadata = null, Source = "Test", Title = "Test Three", SourceId = "3" } }; }); _viewModel = new SchedulePageViewModel(_entrySourceMock.Object); }
public async Task <SchedulePageViewModel> GetSchedule() { var project = await Project.GetProjectWithFieldsAsync(CurrentProject.ProjectId); var characters = await Project.GetCharacters(CurrentProject.ProjectId); var scheduleBuilder = new ScheduleBuilder(project, characters); var result = scheduleBuilder.Build(); var viewModel = new SchedulePageViewModel() { NotScheduledProgramItems = result.NotScheduled.ToViewModel(), Columns = result.Rooms.ToViewModel(), Rows = result.TimeSlots.ToViewModel(), ConflictedProgramItems = result.Conflicted.ToViewModel(), Slots = result.Slots.Select2DList(x => x.ToViewModel()) }; MergeSlots(viewModel); return(viewModel); }
private void MergeSlots(SchedulePageViewModel viewModel) { for (var rowIndex = 0; rowIndex < viewModel.Slots.Count; rowIndex++) { var slotRow = viewModel.Slots[rowIndex]; for (var colIndex = 0; colIndex < slotRow.Count; colIndex++) { var slot = slotRow[colIndex]; if (slot.IsEmpty || slot.RowSpan == 0 || slot.ColSpan == 0) { continue; } int CountSameSlots(IEnumerable <ProgramItemViewModel> sameSlots) { return(sameSlots.TakeWhile(s => s.Id == slot.Id).Count()); } slot.ColSpan = CountSameSlots(slotRow.Skip(colIndex)); slot.RowSpan = CountSameSlots(viewModel.Slots.Skip(rowIndex).Select(row => row[colIndex])); for (var i = 0; i < slot.RowSpan; i++) { for (var j = 0; j < slot.ColSpan; j++) { if (i == 0 && j == 0) { continue; } var slotToRemove = viewModel.Slots[rowIndex + i][colIndex + j]; slotToRemove.ColSpan = 0; slotToRemove.RowSpan = 0; } } } } }
public void AnswerSavedOnNext() { string modifiedItemId = "1234"; string answerText = "test answer"; Schedule schedule = new ScheduleBuilder() .WithItems( TextPromptItem.WithId(modifiedItemId).Build(), TextPromptItem.Build()) .Build(); SchedulePageViewModel model = new SchedulePageViewModel(schedule, mockRecordingManager.Object, new DummyEventTracker(), new DummyDictionary(), mockRepo.Object, mockConfiguration.Object); // simulate text answer entered model.ItemViewModel.Answer = answerText; model.ItemViewModel.AnswerModified = true; model.NextCommand.Execute(null); mockRecordingManager.Verify(f => f.FinalizeAnswer(modifiedItemId, answerText)); }
public ViewModelLocator() { try { var config = new ConfigurationBuilder(); config.AddJsonFile(Directory.GetParent(Environment.CurrentDirectory).Parent.FullName + "\\Resources\\autofac.json"); var module = new ConfigurationModule(config.Build()); var builder = new ContainerBuilder(); builder.RegisterModule(module); Container = builder.Build(); navigationService = Container.Resolve <INavigationService>(); appViewModel = Container.Resolve <AppViewModel>(); // LogInViewModel = Container.Resolve <LogInPageViewModel>(); MainDesktopPageViewModel = Container.Resolve <MainDesktopPageViewModel>(); CalendarPageViewModel = Container.Resolve <CalendarPageViewModel>(); AddEditEventPageViewModel = Container.Resolve <AddEditEventPageViewModel>(); GMailPageViewModel = Container.Resolve <GMailPageViewModel>(); ReadMailPageViewModel = Container.Resolve <ReadMailPageViewModel>(); SchedulePageViewModel = Container.Resolve <SchedulePageViewModel>(); DocumentsPageViewModel = Container.Resolve <DocumentsPageViewModel>(); NewsPageViewModel = Container.Resolve <NewsPageViewModel>(); SettingsPageViewModel = Container.Resolve <SettingsPageViewModel>(); ContactsPageViewModel = Container.Resolve <ContactsPageViewModel>(); ComposeNewMailPageViewModel = Container.Resolve <ComposeNewMailPageViewModel>(); AdminPanelPageViewModel = Container.Resolve <AdminPanelPageViewModel>(); AddNewUserPageViewModel = Container.Resolve <AddNewUserPageViewModel>(); NormativeInfoPageViewModel = Container.Resolve <NormativeInfoPageViewModel>(); AddNewsPageViewModel = Container.Resolve <AddNewsPageViewModel>(); NewsListPageViewModel = Container.Resolve <NewsListPageViewModel>(); ConstantsPageViewModel = Container.Resolve <ConstantsPageViewModel>(); ChangeMyPassPageViewModel = Container.Resolve <ChangeMyPassPageViewModel>(); CreateNewContactPageViewModel = Container.Resolve <CreateNewContactPageViewModel>(); DocPageViewModel = Container.Resolve <DocPageViewModel>(); ShowHistoryPageViewModel = Container.Resolve <ShowHistoryPageViewModel>(); navigationService.Register <LogInPageView>(LogInViewModel); navigationService.Register <MainDesktopPageView>(MainDesktopPageViewModel); navigationService.Register <CalendarPageView>(CalendarPageViewModel); navigationService.Register <AddEditEventPageView>(AddEditEventPageViewModel); navigationService.Register <GMailPageView>(GMailPageViewModel); navigationService.Register <ReadMailPageView>(ReadMailPageViewModel); navigationService.Register <SchedulePageView>(SchedulePageViewModel); navigationService.Register <DocumentsPageView>(DocumentsPageViewModel); navigationService.Register <NewsPageView>(NewsPageViewModel); navigationService.Register <SettingsPageView>(SettingsPageViewModel); navigationService.Register <ContactsPageView>(ContactsPageViewModel); navigationService.Register <ComposeNewMailPageView>(ComposeNewMailPageViewModel); navigationService.Register <AdminPanelPageView>(AdminPanelPageViewModel); navigationService.Register <AddNewUserPageView>(AddNewUserPageViewModel); navigationService.Register <NormativeInfoPageView>(NormativeInfoPageViewModel); navigationService.Register <AddNewsPageView>(AddNewsPageViewModel); navigationService.Register <NewsListPageView>(NewsListPageViewModel); navigationService.Register <ConstantsPageView>(ConstantsPageViewModel); navigationService.Register <ChangeMyPassPageView>(ChangeMyPassPageViewModel); navigationService.Register <CreateNewContactPageView>(CreateNewContactPageViewModel); navigationService.Register <DocPageView>(DocPageViewModel); navigationService.Register <ShowHistoryPageView>(ShowHistoryPageViewModel); navigationService.Navigate <LogInPageView>(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void BuildAppointments(SchedulePageViewModel viewModel) { var result = new List <AppointmentViewModel>(64); for (var i = 0; i < viewModel.Rows.Count; i++) { var row = viewModel.Slots[i]; for (var j = 0; j < row.Count; j++) { var slot = row[j]; if (slot.IsEmpty || slot.ColSpan == 0 || slot.RowSpan == 0) { continue; } var rowIndex = i; var colIndex = j; var appointment = new AppointmentViewModel(() => new Rect { Left = colIndex * viewModel.ColumnWidth, Top = rowIndex * viewModel.RowHeight, Width = slot.ColSpan * viewModel.ColumnWidth, Height = slot.RowSpan * viewModel.RowHeight }) { ErrorType = viewModel.ConflictedProgramItems.FirstOrDefault(pi => pi.Id == slot.Id) != null ? AppointmentErrorType.Intersection : (AppointmentErrorType?)null, AllRooms = slot.ColSpan == viewModel.Columns.Count, RoomIndex = colIndex, RoomCount = slot.ColSpan, TimeSlotIndex = rowIndex, TimeSlotsCount = slot.RowSpan, DisplayName = slot.Name, Description = slot.Description.ToHtmlString(), ProjectId = slot.ProjectId, CharacterId = slot.Id, Users = slot.Users, }; appointment.Rooms = viewModel.Columns .SkipWhile((v, index) => index < colIndex) .Take(slot.ColSpan) .ToArray(); appointment.Slots = viewModel.Rows .SkipWhile((v, index) => index < rowIndex) .Take(slot.RowSpan) .ToArray(); result.Add(appointment); } } viewModel.Appointments = result; viewModel.Intersections = viewModel.ConflictedProgramItems .Select( source => new AppointmentViewModel( () => new Rect { Left = 0, Top = 0, Width = viewModel.ColumnWidth, Height = viewModel.RowHeight }) { ErrorMode = true, ErrorType = AppointmentErrorType.Intersection, DisplayName = source.Name, Description = source.Description.ToHtmlString(), ProjectId = source.ProjectId, CharacterId = source.Id, Users = source.Users }) .ToList(); viewModel.NotAllocated = viewModel.NotScheduledProgramItems .Select( source => new AppointmentViewModel( () => new Rect { Left = 0, Top = 0, Width = viewModel.ColumnWidth, Height = viewModel.RowHeight }) { ErrorMode = true, ErrorType = AppointmentErrorType.NotLocated, AllRooms = source.ColSpan == viewModel.Columns.Count, DisplayName = source.Name, Description = source.Description.ToHtmlString(), ProjectId = source.ProjectId, CharacterId = source.Id, Users = source.Users }) .ToList(); }
public SchedulePage() { // Create the view model for this page _vm = new SchedulePageViewModel(); this.BindingContext = _vm.ScheduleDetails; BackgroundColor = Color.White; // Create our screen objects // Create a label for the technician list _labelTitle = new Xamarin.Forms.Label(); _labelTitle.Text = "SCHEDULE"; _labelTitle.FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null); _labelTitle.FontSize = 22; _labelTitle.TextColor = Color.White; _labelTitle.HorizontalTextAlignment = TextAlignment.Center; _labelTitle.VerticalTextAlignment = TextAlignment.Center; Grid titleLayout = new Grid() { BackgroundColor = Color.FromHex("#2980b9"), HorizontalOptions = LayoutOptions.FillAndExpand, HeightRequest = 80 }; titleLayout.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) }); titleLayout.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); titleLayout.Children.Add(_labelTitle, 0, 0); StackLayout stackDateFilter = new StackLayout(); stackDateFilter.Padding = 30; stackDateFilter.Spacing = 10; filterStartDate = new DatePicker(); filterEndDate = new DatePicker(); Button buttonFilter = new Button() { FontFamily = Device.OnPlatform("OpenSans-Bold", "sans-serif-black", null), TextColor = Color.White, Text = "FILTER TICKETS BY DATE", BackgroundColor = Color.FromHex("#2ECC71") }; buttonFilter.Clicked += ButtonFilter_Clicked; App_Settings appSettings = App.Database.GetApplicationSettings(); filterStartDate.Date = (DateTime.Now.AddDays(Convert.ToDouble(appSettings.ScheduleDaysBefore) * (-1))).Date; filterEndDate.Date = (DateTime.Now.AddDays(Convert.ToDouble(appSettings.ScheduleDaysAfter))).Date; stackDateFilter.Children.Add(filterStartDate); stackDateFilter.Children.Add(filterEndDate); stackDateFilter.Children.Add(buttonFilter); // Create a template to display each technician in the list var dataTemplateItem = new DataTemplate(typeof(ScheduledAppointmentDataCell)); // Create the actual list _listViewScheduledAppointments = new ListView() { HasUnevenRows = true, BindingContext = _vm.ScheduleDetails, ItemsSource = _vm.ScheduleDetails, ItemTemplate = dataTemplateItem, SeparatorVisibility = SeparatorVisibility.None }; _listViewScheduledAppointments.ItemTapped += ListViewScheduledAppointments_ItemTapped; Content = new StackLayout { BackgroundColor = Color.FromHex("#2980b9"), Orientation = StackOrientation.Vertical, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { titleLayout, stackDateFilter, _listViewScheduledAppointments } }; }