public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            NavigationItem.SetLeftBarButtonItem(
                new UIBarButtonItem(UIImage.FromBundle("menu.png"), UIBarButtonItemStyle.Plain, (s, e) => NavigationController.PopViewController(true)),
                true);

            locations = new AvailableLocations();

            state = locations.States.ElementAt(0);
            currentSelected = locations.PotentialLocations.Where(loc => loc.State == state).ElementAt(0);

            stateTableSource = new StateTableSource(locations);
            cityTableSource = new CityTableSource(locations, locations.States.ElementAt(0));
            StateTableView.Source = stateTableSource;
            CityTableView.Source = cityTableSource;

            StateTableView.SelectRow(NSIndexPath.FromRowSection(0, 0), false, UITableViewScrollPosition.None);

            stateTableSource.ValueChanged += StateTable_Changed;
            cityTableSource.ValueChange += CityTable_Changed;

            RecentCitiesButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                var storyboard = UIStoryboard.FromName("Main", null);
                var recentCitiesViewController = (RecentCitiesTableViewController)storyboard.InstantiateViewController("RecentCitiesTableViewController");
                recentCitiesViewController.FromMenu = false;
                this.ShowViewController(recentCitiesViewController, this);
            };
        }
        public SearchOptionsView(Context context, Location location, KeyValuePair<string, string> category)
            : base(context)
        {
            this.context = context;
            this.location = location;
            this.category = category;

            SearchItems = new Dictionary<string, string>();
            Conditions = new Dictionary<object, KeyValuePair<object, object>>();

            rowHeight = PixelConverter.DpToPixels(context.Resources.GetInteger(Resource.Integer.textLabelRowHeight));

            Initialize();
        }
        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();
                };
        }
 void cityPickerChanged(object sender, EventArgs e)
 {
     currentSelected = cityModel.SelectedCity;
     CurrentCityLabel.Text = currentSelected.SiteName;
     //            ShowStateAndCityPicker();
 }
 void CityTable_Changed(object sender, EventArgs e)
 {
     currentSelected = cityTableSource.SelectedCity;
     Console.WriteLine(currentSelected.SiteName);
     ProceedToSearch(sender, e);
 }