void ReleaseDesignerOutlets ()
		{
			if (CityPickerView != null) {
				CityPickerView.Dispose ();
				CityPickerView = null;
			}
			if (CurrentCityLabel != null) {
				CurrentCityLabel.Dispose ();
				CurrentCityLabel = null;
			}
			if (CurrentStateLabel != null) {
				CurrentStateLabel.Dispose ();
				CurrentStateLabel = null;
			}
			if (ProceedButton != null) {
				ProceedButton.Dispose ();
				ProceedButton = null;
			}
			if (RecentCitiesButton != null) {
				RecentCitiesButton.Dispose ();
				RecentCitiesButton = null;
			}
			if (StatePickerView != null) {
				StatePickerView.Dispose ();
				StatePickerView = null;
			}
		}
Пример #2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            locations       = new AvailableLocations();
            state           = locations.States.ElementAt((int)StatePickerView.SelectedRowInComponent(0));
            currentSelected = locations.PotentialLocations.Where(loc => loc.State == state).ElementAt(0);

            cityModel            = new LocationPickerModel(locations, state);
            CityPickerView.Model = cityModel;

            stateModel            = new StatePickerModel(locations);
            StatePickerView.Model = stateModel;

            cityModel.ValueChange += cityPickerChanged;

            CurrentStateLabel.AllTouchEvents += (sender, e) => {
                ShowStatePickerOnly();
            };

            CurrentCityLabel.AllTouchEvents += (sender, e) => {
                ShowCityPickerOnly();
            };

            CurrentStateLabel.ShouldReturn += delegate {
                return(false);
            };

            ProceedButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                var storyboard           = UIStoryboard.FromName("Main", null);
                var searchViewController = (SearchViewController)storyboard.InstantiateViewController("SearchViewController");

                Console.WriteLine(currentSelected.SiteName);
                searchViewController.Url  = currentSelected.Url;
                searchViewController.City = currentSelected.SiteName;

                System.Threading.Tasks.Task.Run(async() => {
                    await AppDelegate.databaseConnection.AddNewRecentCityAsync(currentSelected.SiteName, currentSelected.Url);

                    if (AppDelegate.databaseConnection.GetAllRecentCitiesAsync().Result.Count > 5)
                    {
                        await AppDelegate.databaseConnection.DeleteOldestCityAsync();
                    }
                });

//                    this.ShowViewController(searchViewController, this);
            };

            RecentCitiesButton.TouchUpInside += (object sender, EventArgs e) => {
                var storyboard = UIStoryboard.FromName("Main", null);
                var recentCitiesViewController = (RecentCitiesTableViewController)storyboard.InstantiateViewController("RecentCitiesTableViewController");
//                this.ShowViewController(recentCitiesViewController, this);
            };

            stateModel.ValueChanged += (object sender, EventArgs e) =>
            {
                state = stateModel.SelectedItem;
                CityPickerView.Select(0, 0, false);

                currentSelected      = locations.PotentialLocations.Where(loc => loc.State == state).ElementAt(0);
                cityModel            = new LocationPickerModel(locations, stateModel.SelectedItem);
                CityPickerView.Model = cityModel;

                cityModel.ValueChange += cityPickerChanged;
                CurrentStateLabel.Text = state;
//                    ShowCityPickerOnly();
            };
        }