public override void ViewDidLoad() { base.ViewDidLoad(); UIImageView background = new UIImageView(); //assign our image file to the UIImageView background.Image = UIImage.FromBundle("new_home_bg1"); //assign the UIImageView as the background view of the table this.TableView.BackgroundView = background; //set the textbox background to light gray this.TableView.BackgroundColor = UIColor.LightGray; //set the background of each table cell to clear foreach (var cell in this.TableView.VisibleCells) { cell.BackgroundColor = UIColor.Clear; cell.SelectionStyle = UITableViewCellSelectionStyle.None; } var statusBarHeight = UIApplication.SharedApplication.StatusBarFrame.Height; MultiStepProcessHorizontalViewController parentViewController = this.ParentViewController as MultiStepProcessHorizontalViewController; var navigationController = parentViewController.ContainerViewController.NavigationController; var navBarHeight = navigationController.NavigationBar.Bounds.Height; TableView.ContentInset = new UIEdgeInsets(statusBarHeight + navBarHeight, 0, 50, 0); MapCCodeList = new List <Location>(); LocationList = new List <Location>(); provinceList = new List <Location>(); stateList = new List <Location>(); FilteredLocationList = new List <Location>(); SelectedMapCCode = new Location(); SelectedLocation = new Location(); LocationsPickerViewProperty.Alpha = 0f; //LocationPickerWidthConstraintProperty.Constant = 0f; //if (UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone) //{ // MapCCodePickerWidthConstraint.Constant = 80f; //} //else { // MapCCodePickerWidthConstraint.Constant = 150f; //} //Load values if already registered if (Settings.IsRegistered) { EmailTextField.Text = Settings.Email; PasswordTextField.Text = Settings.Password; FirstNameTextField.Text = Settings.FirstName; LastNameTextField.Text = Settings.LastName; PhoneTextField.Text = Settings.Phone; CompanyTextField.Text = Settings.Company; HomeAirportTextField.Text = Settings.HomeAirport; } //hide keyboard when touch anywhere HideKeyboardGesture = new UITapGestureRecognizer(() => { View.EndEditing(true); }); Task.Run(async() => { LocationResponse location = new LocationResponse(); if (Reachability.IsHostReachable(Settings._baseDomain)) { location = await LocationResponse.GetLocations(); if (location.Status != "Success") { InvokeOnMainThread(() => { var alert = UIAlertController.Create("There was a problem loading registration data", "Please try again.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, (obj) => { RegistrationViewController registrationVC = (RegistrationViewController)((MultiStepProcessHorizontalViewController)this.ParentViewController).ContainerViewController; //var firstStep = registrationVC.Steps.FirstOrDefault(); //registrationVC._pageViewController.SetViewControllers(new[] { firstStep as UIViewController }, UIPageViewControllerNavigationDirection.Reverse, true, (finished) => //{ // if (finished) // { // //finalStep.StepActivated(this, new MultiStepProcessStepEventArgs()); // } //}); registrationVC.DismissViewController(true, null); })); PresentViewController(alert, animated: true, completionHandler: () => { }); }); } else { //Save to settings file to use object during the rest of the registration process Settings.LocationResponse = location; var distinctMapCodes = location.Locations.Select(row => row.MapCCode).Distinct().ToList(); List <Location> filteredLocationListByFirstMapCode = new List <Location>(); foreach (var mapCode in distinctMapCodes) { Location loc = location.Locations.FirstOrDefault(row => row.MapCCode == mapCode); if (loc != null) { if (loc.MapCCode == "WO") { Location placeholderLocation = new Location(); placeholderLocation.LocationId = loc.LocationId; placeholderLocation.LocName = "World"; placeholderLocation.Abbreviation = loc.Abbreviation; placeholderLocation.MapCCode = loc.MapCCode; placeholderLocation.DisplayOrder = loc.DisplayOrder; filteredLocationListByFirstMapCode.Add(placeholderLocation); } else { filteredLocationListByFirstMapCode.Add(loc); } } } MapCCodeList = filteredLocationListByFirstMapCode.OrderByDescending(row => row.DisplayOrder).ToList(); Location sleLocation = new Location(); sleLocation.LocationId = 0; sleLocation.LocName = "Select"; sleLocation.Abbreviation = "Select"; sleLocation.MapCCode = "SE"; sleLocation.DisplayOrder = 0; MapCCodeList.Insert(0, sleLocation); LocationList = location.Locations.OrderBy(row => row.DisplayOrder).ToList(); provinceList = location.ProvinceLst.OrderBy(row => row.DisplayOrder).ToList(); stateList = location.StatesLst.OrderBy(row => row.DisplayOrder).ToList(); FilteredLocationList = LocationList; if (MapCCodeList.Count > 1 && Settings.LocationPickerSelectedId == 0) { //Assign value to registration objec Settings.LocationPickerSelectedId = MapCCodeList[0].LocationId; } InvokeOnMainThread(() => { MapCCodePicker.Model = new MapCCodeMod(this); LocationPicker.Model = new LocationsMod(this); if (Settings.IsRegistered) { var previouslSelectedLocation = MapCCodeList.FirstOrDefault(row => row.LocationId == Settings.LocationPickerSelectedId); if (previouslSelectedLocation != null) { int currentIndex = MapCCodeList.IndexOf(MapCCodeList.FirstOrDefault(row => row.LocationId == Settings.LocationPickerSelectedId));; MapCCodePicker.Select(currentIndex, 0, true); } else { if (Settings.LocationPickerSelectedId != 0) { int locationId = Settings.LocationPickerSelectedId; int mapCIndex = MapCCodeList.IndexOf(MapCCodeList.FirstOrDefault(row => row.LocationId == 0)); MapCCodePicker.Select(mapCIndex, 0, true); MapCCodePicker.Model.Selected(MapCCodePicker, mapCIndex, 0); int locationCInddex = FilteredLocationList.IndexOf(FilteredLocationList.FirstOrDefault(row => row.LocationId == locationId)); LocationPicker.Select(locationCInddex, 0, true); LocationPicker.Model.Selected(LocationPicker, locationCInddex, 0); //LocationPicker.Alpha = 1f; } } } else { //MapCCodePicker.Model.Selected(MapCCodePicker, 0, 0); MapCCodePicker.Select(0, 0, true); } }); } } else { InvokeOnMainThread(() => { var alert = UIAlertController.Create("Please connect to the internet", "Internet access is required.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, (obj) => { RegistrationViewController registrationVC = (RegistrationViewController)((MultiStepProcessHorizontalViewController)this.ParentViewController).ContainerViewController; //var firstStep = registrationVC.Steps.FirstOrDefault(); //registrationVC._pageViewController.SetViewControllers(new[] { firstStep as UIViewController }, UIPageViewControllerNavigationDirection.Reverse, true, (finished) => //{ // if (finished) // { // //finalStep.StepActivated(this, new MultiStepProcessStepEventArgs()); // } //}); registrationVC.DismissViewController(true, null); })); PresentViewController(alert, animated: true, completionHandler: () => { }); }); } }); }
public override void ViewDidLoad() { base.ViewDidLoad(); PageHeaderLabel.BackgroundColor = UIColor.Gray; SizeF size = new SizeF(320, UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Pad ? 600 : 800); ProfileScrollView.ContentSize = size; MapCCodeList = new List <Location>(); LocationList = new List <Location>(); provinceList = new List <Location>(); stateList = new List <Location>(); FilteredLocationList = new List <Location>(); SelectedMapCCode = new Location(); SelectedLocation = new Location(); FirstNameTextField.AttributedPlaceholder = new NSAttributedString( "FIRST NAME", font: FirstNameTextField.Font, foregroundColor: UIColor.White ); LastNameTextField.AttributedPlaceholder = new NSAttributedString( "LAST NAME", font: LastNameTextField.Font, foregroundColor: UIColor.White ); MobilePhoneTextField.AttributedPlaceholder = new NSAttributedString( "MOBILE PHONE", font: MobilePhoneTextField.Font, foregroundColor: UIColor.White ); CompanyTextField.AttributedPlaceholder = new NSAttributedString( "COMPANY", font: CompanyTextField.Font, foregroundColor: UIColor.White ); FirstNameTextField.Text = Settings.FirstName; MobilePhoneTextField.Text = Settings.Phone; LastNameTextField.Text = Settings.LastName; //Task.Run(async () => { // try // { // AuthResponse response1 = await AuthResponse.GetAuthResponseAsync(Settings.AppID, Settings.Username, Settings.Password); // APIManager manager = new APIManager(); // var reponseProfile = await manager.getUserProfile(Settings.AppID, Settings.Username, response1.AuthToken, Settings.Password); // InvokeOnMainThread(() => // { // //CompanyTextField.Text = reponseProfile.Company; // }); // } // catch (Exception e) { // } //}); //ContainerViewWidthConstraint.Constant = View.Bounds.Width - 40; ContainerView.BackgroundColor = UIColor.Clear; ContainerView.Alpha = .8f; //CGSize contentSize = new CGSize(View.Bounds.Width - 40, ContainerView.Bounds.Height); //ProfileScrollView.ContentSize = contentSize; //LocationResponseList = new List<LocationResponse>(); MapCCodePickerView.Model = new MapCCodeModel(this); Task.Run(async() => { try { LocationResponse location = new LocationResponse(); if (Reachability.IsHostReachable(Settings._baseDomain)) { location = await LocationResponse.GetLocations(); if (location.Equals(null)) { return; } if (location.Status != "Success") { InvokeOnMainThread(() => { var alert = UIAlertController.Create("There was a problem loading location data", "Please try again.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, (obj) => { this.DismissViewController(true, null); })); PresentViewController(alert, animated: true, completionHandler: () => { }); }); } else { //Save to settings file to use object during the rest of the registration process Settings.LocationResponse = location; var distinctMapCodes = location.Locations.Select(row => row.MapCCode).Distinct().ToList(); List <Location> filteredLocationListByFirstMapCode = new List <Location>(); foreach (var mapCode in distinctMapCodes) { Location loc = location.Locations.FirstOrDefault(row => row.MapCCode == mapCode); if (loc != null) { if (loc.MapCCode == "WO") { Location placeholderLocation = new Location(); placeholderLocation.LocationId = loc.LocationId; placeholderLocation.LocName = "World"; placeholderLocation.Abbreviation = loc.Abbreviation; placeholderLocation.MapCCode = loc.MapCCode; placeholderLocation.DisplayOrder = loc.DisplayOrder + 1; filteredLocationListByFirstMapCode.Add(placeholderLocation); } else { filteredLocationListByFirstMapCode.Add(loc); } } } MapCCodeList = filteredLocationListByFirstMapCode.OrderByDescending(row => row.DisplayOrder).ToList(); Location sleLocation = new Location(); sleLocation.LocationId = 0; sleLocation.LocName = "Select"; sleLocation.Abbreviation = "Select"; sleLocation.MapCCode = "SE"; sleLocation.DisplayOrder = 0; MapCCodeList.Insert(0, sleLocation); LocationList = location.Locations.OrderBy(row => row.DisplayOrder).ToList(); FilteredLocationList = LocationList; provinceList = location.ProvinceLst.OrderBy(row => row.DisplayOrder).ToList(); stateList = location.StatesLst.OrderBy(row => row.DisplayOrder).ToList(); if (MapCCodeList.Count > 1 && Settings.LocationPickerSelectedId == 0) { //Assign value to registration objec Settings.LocationPickerSelectedId = MapCCodeList[0].LocationId; } InvokeOnMainThread(() => { MapCCodePickerView.Model = new MapCCodeModel(this); LocationsPicker.Model = new LocationsModel(this); if (Settings.IsRegistered) { var previouslSelectedLocation = MapCCodeList.FirstOrDefault(row => row.LocationId == Settings.LocationPickerSelectedId); if (previouslSelectedLocation != null) { int currentIndex = MapCCodeList.IndexOf(MapCCodeList.FirstOrDefault(row => row.LocationId == Settings.LocationPickerSelectedId));; MapCCodePickerView.Select(currentIndex, 0, true); } else { if (Settings.LocationPickerSelectedId != 0) { int locationId = Settings.LocationPickerSelectedId; int mapCIndex = MapCCodeList.IndexOf(MapCCodeList.FirstOrDefault(row => row.LocationId == 0)); MapCCodePickerView.Select(mapCIndex, 0, true); MapCCodePickerView.Model.Selected(MapCCodePickerView, mapCIndex, 0); int locationCInddex = FilteredLocationList.IndexOf(FilteredLocationList.FirstOrDefault(row => row.LocationId == locationId)); LocationsPicker.Select(locationCInddex, 0, true); LocationsPicker.Model.Selected(LocationsPicker, locationCInddex, 0); //LocationPicker.Alpha = 1f; } } } else { //MapCCodePicker.Model.Selected(MapCCodePicker, 0, 0); MapCCodePickerView.Select(0, 0, true); } }); } } else { InvokeOnMainThread(() => { var alert = UIAlertController.Create("Please connect to the internet", "Internet access is required.", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Cancel, (obj) => { RegistrationViewController registrationVC = (RegistrationViewController)((MultiStepProcessHorizontalViewController)this.ParentViewController).ContainerViewController; //var firstStep = registrationVC.Steps.FirstOrDefault(); //registrationVC._pageViewController.SetViewControllers(new[] { firstStep as UIViewController }, UIPageViewControllerNavigationDirection.Reverse, true, (finished) => //{ // if (finished) // { // //finalStep.StepActivated(this, new MultiStepProcessStepEventArgs()); // } //}); registrationVC.DismissViewController(true, null); })); PresentViewController(alert, animated: true, completionHandler: () => { }); }); } } catch (Exception exe) { } } ); }