public SearchListXaml() { InitializeComponent(); favoritesRepository = XmlFavoritesRepository.OpenFile("XamarinFavorites.xml").Result; search = new Search("test"); viewModel = new SearchViewModel(App.Service, search); viewModel.SearchCompleted += (sender, e) => { if (viewModel.Groups == null) { // clear it out listView.ItemsSource = new string [1]; } else { listView.ItemsSource = viewModel.Groups; } }; viewModel.Error += (sender, e) => { // e.Exception }; BindingContext = viewModel; }
public SearchListXaml() { InitializeComponent(); var task = Task.Run(async() => { favoritesRepository = await XmlFavoritesRepository.OpenFile("XamarinFavorites.xml"); }); task.Wait(); search = new Search("test"); viewModel = new SearchViewModel(App.Service, search); viewModel.SearchCompleted += (sender, e) => { if (viewModel.Groups == null) { listView.ItemsSource = new string [1]; } else { listView.ItemsSource = viewModel.Groups; } }; viewModel.Error += (sender, e) => { DisplayAlert("Error", e.Exception.Message, "OK", null); }; BindingContext = viewModel; }
public override bool FinishedLaunching(UIApplication app, NSDictionary options) { Theme.Apply(); // // Create the service // // Local CSV file service = MemoryDirectoryService.FromCsv("Data/XamarinDirectory.csv"); // LDAP service - uncomment to try it out. //service = new LdapDirectoryService { // Host = "ldap.mit.edu", // SearchBase = "dc=mit,dc=edu", //}; // // Load the favorites // var favoritesRepository = XmlFavoritesRepository.OpenIsolatedStorage("Favorites.xml"); if (favoritesRepository.GetAll().Count() == 0) { favoritesRepository = XmlFavoritesRepository.OpenFile("Data/XamarinFavorites.xml"); favoritesRepository.IsolatedStorageName = "Favorites.xml"; } // // Load the last search // Search search = null; try { search = Search.Open("Search.xml"); } catch (Exception) { search = new Search("Search.xml"); } // // Build the UI // favoritesViewController = new FavoritesViewController(favoritesRepository, service, search); window = new UIWindow(UIScreen.MainScreen.Bounds); window.RootViewController = new UINavigationController(favoritesViewController); window.MakeKeyAndVisible(); // // Show the login screen at startup // var login = new LoginViewController(service); favoritesViewController.PresentViewController(login, false, null); return(true); }
public override void OnCreate() { base.OnCreate(); using (var reader = new System.IO.StreamReader(Assets.Open("XamarinDirectory.csv"))) Service = new MemoryDirectoryService(new CsvReader <Person> (reader).ReadAll()); var filePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "XamarinFavorites.xml"); using (var stream = Assets.Open("XamarinFavorites.xml")) using (var filestream = File.Open(filePath, FileMode.Create)) stream.CopyTo(filestream); repo = XmlFavoritesRepository.OpenFile(filePath); }
private void InitializeViewModel() { var task = Task.Run(async() => { favoritesRepository = await XmlFavoritesRepository.OpenFile("XamarinFavorites.xml"); }); task.Wait(); search = new Search(string.Empty); viewModel = new SearchViewModel(App.Service, search); viewModel.SearchCompleted += OnSearchCompleted; viewModel.Error += (sender, e) => { DisplayAlert("Help", e.Exception.Message, "OK", null); }; BindingContext = viewModel; }
protected async override void OnAppearing() { base.OnAppearing(); if (LoginViewModel.ShouldShowLogin(App.LastUseTime)) { await Navigation.PushModalAsync(new LoginView()); } favoritesRepository = await XmlFavoritesRepository.OpenIsolatedStorage("XamarinFavorites.xml"); if (favoritesRepository.GetAll().Count() == 0) { favoritesRepository = await XmlFavoritesRepository.OpenFile("XamarinFavorites.xml"); } viewModel = new FavoritesViewModel(favoritesRepository, true); listView.ItemsSource = viewModel.Groups; }
// Code to execute when the application is launching (eg, from Start) // This code will not execute when the application is reactivated private void Application_Launching(object sender, LaunchingEventArgs e) { // Load the directory var dataUri = new Uri("EmployeeDirectory.WinPhone;component/Data/XamarinDirectory.csv", UriKind.Relative); var dataInfo = GetResourceStream(dataUri); using (var reader = new System.IO.StreamReader(dataInfo.Stream)) { DirectoryService = new MemoryDirectoryService(new CsvReader <Person> (reader).ReadAll()); } // Load the favorites FavoritesRepository = XmlFavoritesRepository.OpenFile("EmployeeDirectory.WinPhone;component/Data/XamarinFavorites.xml"); // Load the search try { SavedSearch = Search.Open("SavedSearch.xml"); } catch (Exception) { SavedSearch = new Search("SavedSearch.xml"); } }
public SearchListXaml(SearchProperty filter, string title) { InitializeComponent(); On <iOS>().SetUseSafeArea(true); Title = title; var task = Task.Run(async() => { favoritesRepository = await XmlFavoritesRepository.OpenFile("XamarinFavorites.xml"); }); task.Wait(); search = new Search("test", filter); /*if( filter != SearchProperty.Personen && filter != SearchProperty.Alle) * { * listView.GroupShortNameBinding = null; * }*/ viewModel = new SearchViewModel(App.Service, search); viewModel.SearchCompleted += (sender, e) => { if (viewModel.Groups == null) { listView.ItemsSource = new string [1]; } else { listView.ItemsSource = viewModel.Groups; } }; viewModel.Error += (sender, e) => { DisplayAlert("Error", e.Exception.Message, "OK", null); }; BindingContext = viewModel; }