async void Handle_Refreshing(object sender, System.EventArgs e) { if (App.IsConnected()) { await App.SyncData(); } await(BindingContext as PatientListViewModel).BindData(); PatientListView.EndRefresh(); isExecuting = false; }
public static PatientDto MapToDto(PatientListView classMapFrom) { PatientDto retval = null; if (classMapFrom != null) { retval = new PatientDto { Id = classMapFrom.PatientId, LastName = classMapFrom.LastName, FirstName = classMapFrom.FirstName, LastVisitDate = classMapFrom.LastVisited }; } return(retval); }
void Handle_TextChanged(object sender, Xamarin.Forms.TextChangedEventArgs e) { if (!string.IsNullOrWhiteSpace(e.OldTextValue) && string.IsNullOrWhiteSpace(e.NewTextValue)) { Device.BeginInvokeOnMainThread(() => { searchBar.Unfocus(); PatientListView.Focus(); PatientListView.SetBinding(ListView.ItemsSourceProperty, "ItemsSource"); if (BindingContext != null) { (BindingContext as PatientListViewModel).ItemsSource = (BindingContext as PatientListViewModel).ItemsSource; } }); } }
private void Application_Startup(object sender, StartupEventArgs e) { try { // open the Users screen MainWindow mainWindow = new MainWindow(); MainViewModel mainviewModel = new MainViewModel(); PatientListView patientView = null; string themeName = "Green";//default theme if (System.IO.File.Exists(APP_SETTING_PATH)) { var applicationThemeSetting = File.ReadAllText("PatientCARE_TEST_THEME.txt"); applicationThemeSetting = applicationThemeSetting.Replace(System.Environment.NewLine, ""); var listTheme = new string[] { "White", "Green", "Red", "Blue" }; foreach (var item in listTheme) { if (applicationThemeSetting.ToUpper() == item.ToUpper()) { themeName = item; _settingTheme = themeName; break; } } } // Loading theme LoadTheme(themeName); mainviewModel.ThemeChangeEvent += (changeTheme) => { LoadTheme(changeTheme); }; mainviewModel.NewPateintEvent += (patientId) => { LoadPatient(patientId, mainWindow, mainviewModel); }; mainviewModel.ClosePateintEvent += () => { ClosePatient(mainWindow, mainviewModel); }; mainviewModel.ShowPateintListScreenAction += () => { try { // ensure only one view is loaded, and the same one remains open for multiple requests patientView = patientView ?? new PatientListView(); if (!patientView.IsLoaded) { var patientListViewModel = new PatientListViewModel(); patientView.Close(); patientView = new PatientListView(); patientListViewModel.ClosePateintListScreenAction += () => { patientView.Close(); }; patientListViewModel.PatientSelectedAction += () => { LoadPatient(patientListViewModel.SelectedPatient.PatientId, mainWindow, mainviewModel); patientView.Close(); }; patientView.DataContext = patientListViewModel; } patientView.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); Application.Current.Shutdown(); } }; var loginView = new LoginView(); var loginViewModel = new ViewModel.LoginViewModel(); loginViewModel.LoginEvent += () => { loginView.Close(); TabControl addTabControl = new TabControl(); addTabControl.Name = "tcMain"; addTabControl.BorderThickness = new Thickness(0); mainWindow.mainPanel.Children.Add(addTabControl); mainWindow.DataContext = mainviewModel; mainWindow.Show(); }; loginViewModel.CancelLoginEvent += () => { App.Current.Shutdown(); }; loginView.DataContext = loginViewModel; loginView.Closed += new EventHandler(loginView_Closed); loginView.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error"); Application.Current.Shutdown(); } }