void Search_Clicked(object sender, System.EventArgs e)
        {
            CrimeSearchCriteria criteria = new CrimeSearchCriteria();

            // If there's a DCN we don't need to bother with rest
            if (DCN.Text != null && DCN.Text.Length > 3)
            {
                criteria.DCN = DCN.Text;
            }
            else
            {
                // Was a neighborhood selected?
                if (Neighborhood.SelectedIndex > -1)
                {
                    string selectedhood = Neighborhood.Items[Neighborhood.SelectedIndex];
                    var    hood         = Global.Neighborhoods.Where(p => p.Name == selectedhood).FirstOrDefault();
                    if (hood != null)
                    {
                        criteria.NeighborhoodID = hood.ID.ToString();
                    }

                    // Special case if user picked "Entire City"
                    if (Neighborhood.SelectedIndex == 0)
                    {
                        criteria.NeighborhoodID = "-1";
                    }
                }

                // What about a police district?
                if (PoliceDistrictID.SelectedIndex > -1)
                {
                    criteria.PoliceDistrict = PoliceDistrictID.Items[PoliceDistrictID.SelectedIndex];

                    // And what about a PSA?
                    if (PSA.SelectedIndex > 0)
                    {
                        criteria.PSA = PSA.Items[PSA.SelectedIndex];
                    }
                }

                criteria.StartDate   = DateStart.Date + TimeStart.Time;
                criteria.EndDate     = DateEnd.Date + TimeEnd.Time;
                criteria.Filter      = currentFilter;
                criteria.OnlyArrests = SwitchArrests.IsToggled;
            }

            // Do we have any selection criteria now?  If not then this query make no sense
            // and we need to train the user.
            if ((criteria.NeighborhoodID == null || criteria.NeighborhoodID == "") &&
                (criteria.PoliceDistrict == null || criteria.PoliceDistrict == "") &&
                (criteria.DCN == null || criteria.DCN == ""))
            {
                DisplayAlert("Incomplete Search", "Please provide a neighborhood or a police district to look for crimes in--or, a District Control Number to " +
                             "retrieve a specific crime", "OK");
                return;
            }

            Navigation.PushAsync(new BlotterPage(criteria));
        }
示例#2
0
        // For now we're overloading the blotter view to show
        // crime results.  That means (again, FOR NOW) we have to change the configuration of the
        // list view.   If we deviate too far then we'll have to build a new viewer for this.
        public BlotterPage(CrimeSearchCriteria criteria)
        {
            InitializeComponent();
            this.ToolbarItems.Add(new ToolbarItem("buttonJump", "Images/map.png", JumpToMap, ToolbarItemOrder.Primary));

            // No panels needed
            warningPanel.IsVisible = false;
            activity.IsVisible     = true;

            // Disable grouping and pull-to-refresh
            blotterListView.IsPullToRefreshEnabled = false;
            blotterListView.IsGroupingEnabled      = false;

            // Data used to execute search in the model.
            _searchResults       = true;
            _crimeSearchCriteria = criteria;
        }
示例#3
0
        async void NewCrimePush()
        {
            CrimeSearchCriteria criteria = new CrimeSearchCriteria();

            criteria.StartDate      = DateTime.Today.AddDays(-5);
            criteria.EndDate        = DateTime.Today;
            criteria.Longitude      = Settings.PrimaryLong;
            criteria.Latitutde      = Settings.PrimaryLat;
            criteria.Radius         = Settings.CrimeRadius;
            criteria.Filter         = Filter.Homicide | Filter.Robbery | Filter.Burglary | Filter.Assault | Filter.Rape;
            criteria.NeighborhoodID = "-1";             //Search whole city

            _data = await Data.SearchCrimes(criteria);

            Device.BeginInvokeOnMainThread(() =>
            {
                blotterListView.ItemsSource = _data;
                warningPanel.IsVisible      = false;
                blotterListView.IsVisible   = true;
                activity.IsRunning          = false;
                activity.IsVisible          = false;
            });
        }