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: () => { }); }); } }); }
void ReleaseDesignerOutlets() { if (CompanyTextField != null) { CompanyTextField.Dispose(); CompanyTextField = null; } if (EmailTextField != null) { EmailTextField.Dispose(); EmailTextField = null; } if (FirstNameTextField != null) { FirstNameTextField.Dispose(); FirstNameTextField = null; } if (HomeAirportTextField != null) { HomeAirportTextField.Dispose(); HomeAirportTextField = null; } if (LastNameTextField != null) { LastNameTextField.Dispose(); LastNameTextField = null; } if (LocationLabel != null) { LocationLabel.Dispose(); LocationLabel = null; } if (LocationPicker != null) { LocationPicker.Dispose(); LocationPicker = null; } if (MapCCodePicker != null) { MapCCodePicker.Dispose(); MapCCodePicker = null; } if (NextButton != null) { NextButton.Dispose(); NextButton = null; } if (PasswordTextField != null) { PasswordTextField.Dispose(); PasswordTextField = null; } if (PhoneTextField != null) { PhoneTextField.Dispose(); PhoneTextField = null; } if (ReEmailTextField != null) { ReEmailTextField.Dispose(); ReEmailTextField = null; } if (RePasswordTextField != null) { RePasswordTextField.Dispose(); RePasswordTextField = null; } }