private void btnMachinery_Click(object sender, RoutedEventArgs e) { LoadListBox(); scrollFilterView.Visibility = Visibility.Visible; gridHomePage.Visibility = Visibility.Collapsed; listBoxFarmerProfile.Items.Filter = delegate(object obj) { FarmerProfile f = (FarmerProfile)obj; if (cmbMachinery.SelectedIndex > 0) { if (!f.Machinery.Contains(cmbMachinery.SelectedItem.ToString())) { return(false); } } if (cmbLocation.SelectedIndex > 0) { if (f.Country != cmbLocation.SelectedItem.ToString()) { return(false); } } if (cmbGrain.SelectedIndex > 0) { if (!f.Grain.Contains(cmbGrain.SelectedItem.ToString())) { return(false); } } if (cmbFacility.SelectedIndex > 0) { if (!f.Facility.Contains(cmbFacility.SelectedItem.ToString())) { return(false); } } if (cmbAnimals.SelectedIndex > 0) { if (!f.Animals.Contains(cmbAnimals.SelectedItem.ToString())) { return(false); } } if (cmbProject.SelectedIndex > 0) { if (!f.Project.Contains(cmbProject.SelectedItem.ToString())) { return(false); } } try { foreach (var ele in visitorProfile.Element("Machinery").Elements()) { if (f.Machinery.Contains(ele.Value, StringComparer.InvariantCultureIgnoreCase)) { return(true); } } return(false); } catch { return(false); } return(true); }; }
private void btnSize_Click(object sender, RoutedEventArgs e) { LoadListBox(); scrollFilterView.Visibility = Visibility.Visible; gridHomePage.Visibility = Visibility.Collapsed; listBoxFarmerProfile.Items.Filter = delegate(object obj) { FarmerProfile f = (FarmerProfile)obj; if (cmbMachinery.SelectedIndex > 0) { if (!f.Machinery.Contains(cmbMachinery.SelectedItem.ToString())) { return(false); } } if (cmbLocation.SelectedIndex > 0) { if (f.Country != cmbLocation.SelectedItem.ToString()) { return(false); } } if (cmbGrain.SelectedIndex > 0) { if (!f.Grain.Contains(cmbGrain.SelectedItem.ToString())) { return(false); } } if (cmbFacility.SelectedIndex > 0) { if (!f.Facility.Contains(cmbFacility.SelectedItem.ToString())) { return(false); } } if (cmbAnimals.SelectedIndex > 0) { if (!f.Animals.Contains(cmbAnimals.SelectedItem.ToString())) { return(false); } } if (cmbProject.SelectedIndex > 0) { if (!f.Project.Contains(cmbProject.SelectedItem.ToString())) { return(false); } } int farmSizeVisitor = int.Parse(visitorProfile.Element("size_of_farm").Element("Total").Value); if (farmSizeVisitor == f.FarmSize || (f.FarmSize - 100 <= farmSizeVisitor && farmSizeVisitor <= f.FarmSize + 100)) { return(true); } else { return(false); } return(true); }; }
private void LoadListBox() { filterList.Clear(); if (visitorProfile == null) { visitorProfile = records[0]; } foreach (var rec in records) { FarmerProfile f = new FarmerProfile(); f.FirstName = rec.Element("Contact_information").Element("FirstName").Value; f.LastName = rec.Element("Contact_information").Element("LastName").Value; f.Phone = rec.Element("Contact_information").Element("ContactNo").Value; f.Email = rec.Element("Contact_information").Element("Email").Value; f.FarmSize = int.Parse(rec.Element("size_of_farm").Element("Total").Value); int farmSizeVisitor = int.Parse(visitorProfile.Element("size_of_farm").Element("Total").Value); if (farmSizeVisitor == f.FarmSize || (f.FarmSize - 100 <= farmSizeVisitor && farmSizeVisitor <= f.FarmSize + 100)) { f.SizeImage = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/" + "Images/size_N.png", UriKind.Absolute)); } string state = ""; try { state = rec.Element("Location").Element("State").Value; } catch { } string country = rec.Element("Location").Element("Country").Value; f.Country = country; f.State = state; string stateVisitor = visitorProfile.Element("Location").Element("State").Value; string countryVisitor = visitorProfile.Element("Location").Element("Country").Value; if (state == stateVisitor && country == countryVisitor) { f.LocationImage = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/" + "Images/Location_N.png", UriKind.Absolute)); } List <string> animals = new List <string>(); try { foreach (var ele in rec.Element("Animals").Elements()) { animals.Add(ele.Name.LocalName); } foreach (var ele in visitorProfile.Element("Animals").Elements()) { if (animals.Contains(ele.Name.LocalName, StringComparer.InvariantCultureIgnoreCase)) { f.AnimalsImage = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/" + "Images/Animals_N.png", UriKind.Absolute)); } List <string> machinery = new List <string>(); try { foreach (var ele in rec.Element("Machinery").Elements()) { machinery.Add(ele.Value); } foreach (var ele in visitorProfile.Element("Machinery").Elements()) { if (machinery.Contains(ele.Value, StringComparer.InvariantCultureIgnoreCase)) { f.MachineryImage = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/" + "Images/Machinery_N.png", UriKind.Absolute)); } List <string> facility = new List <string>(); try { foreach (var ele in rec.Element("Facility").Elements()) { facility.Add(ele.Name.LocalName); } foreach (var ele in visitorProfile.Element("Facility").Elements()) { if (facility.Contains(ele.Name.LocalName, StringComparer.InvariantCultureIgnoreCase)) { f.FacilityImage = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/" + "Images/Facility_N.png", UriKind.Absolute)); } List <string> project = new List <string>(); try { foreach (var ele in rec.Element("Project").Elements()) { project.Add(ele.Name.LocalName); } foreach (var ele in visitorProfile.Element("Project").Elements()) { if (project.Contains(ele.Name.LocalName, StringComparer.InvariantCultureIgnoreCase)) { f.ProjectImage = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/" + "Images/Project_N.png", UriKind.Absolute)); } List <string> grain = new List <string>(); try { foreach (var ele in rec.Element("size_of_farm").Elements().Where(d => d.Name.LocalName != "Total")) { grain.Add(ele.Name.LocalName); } foreach (var ele in visitorProfile.Element("size_of_farm").Elements().Where(d => d.Name.LocalName != "Total")) { if (grain.Contains(ele.Name.LocalName, StringComparer.InvariantCultureIgnoreCase)) { f.GrainImage = new BitmapImage(new Uri(@"pack://*****:*****@"pack://application:,,,/" + Assembly.GetExecutingAssembly().GetName().Name + ";component/" + "Images/Grain_N.png", UriKind.Absolute)); } filterList.Add(f); } }