Exemple #1
0
        void OnIncidentTypeFilterClicked(object sender, EventArgs e)
        {
            Button filterButton = (Button)sender;

            // Change button style
            if (!filterButton.ImageSource.ToString().Substring(6).Contains("2."))
            {
                filterAppliedNotificationText.Text = "Filter Applied";
                ShowFilterAppliedConfirmation();

                filterButton.ImageSource     = filterButton.ImageSource.ToString().Substring(6).Replace(".", "2.");
                filterButton.TextColor       = Color.White;
                IncidentTypeInfo.Type        = filterButton.Text;
                filterButton.BackgroundColor = IncidentTypeInfo.GetIncidentColor();
                SwitchOffOtherButtons(filterButton.Text);

                // each filter button sets the incidentFilter string differently, by incident type, and if no filter is selected string is left empty
                // Goes theough each incident type and checks is the filter button clicked corresponds to the incident type
                for (int i = 0; i < CrimeFilterer.incidentTypes.Length; i++)
                {
                    if (CrimeFilterer.incidentTypes[i].Contains(filterButton.Text))
                    {
                        Debug.WriteLine($"{CrimeFilterer.incidentTypes[i]}");
                        CrimeFilterer.IncidentTypeFilter = CrimeFilterer.incidentTypes[i];
                        break;
                    }
                    else
                    {
                        CrimeFilterer.IncidentTypeFilter = "Other";
                    }
                }

                if (filterButton.Text.Equals("Theft"))
                {
                    CrimeFilterer.IncidentTypeFilter = "Larceny/Theft Offenses | Robbery";
                }

                if (filterButton.Text.Equals("Disruption"))
                {
                    CrimeFilterer.IncidentTypeFilter = "Disorderly Conduct";
                }

                if (filterButton.Text.Equals("DUI"))
                {
                    CrimeFilterer.IncidentTypeFilter = "Driving Under the Influence";
                }
            }
            else
            {
                filterAppliedNotificationText.Text = "Filter Removed";
                ShowFilterAppliedConfirmation();

                filterButton.ImageSource         = filterButton.ImageSource.ToString().Substring(6).Replace("2.", ".");
                filterButton.TextColor           = Color.Black;
                filterButton.BackgroundColor     = Color.FromHex("#EBEAEA");
                IncidentTypeInfo.Type            = "All";
                CrimeFilterer.IncidentTypeFilter = "All";
            }
        }
Exemple #2
0
        protected override async void OnAppearing()
        {
            base.OnAppearing();

            activityIndicator.IsRunning = true;

            var incidents = (await CrimeFilterer.Filter()).ToArray();

            for (int i = 0; i < incidents.Length; i++)
            {
                Incident incident = incidents[i];

                // Set visual properties for incidents
                incident.Icon         = IncidentTypeInfo.GetIncidentIcon(incident.Type);
                incident.StandardTime = Convert.ToDateTime(incident.Time).ToString("dddd, dd MMMM yyyy");
            }

            listView.ItemsSource = incidents;

            activityIndicator.IsRunning = false;

            numOfIncidentsLabel.Text  = $"{incidents.Length} Incidents";
            InfoFrame.BackgroundColor = IncidentTypeInfo.GetIncidentColor();
        }
Exemple #3
0
        public CrimeLogPage()
        {
            InitializeComponent();

            InfoFrame.BackgroundColor = IncidentTypeInfo.GetIncidentColor();
        }