// this method is used when loading a saved search public void SetDuplexFilter(object enabled) { DuplexFilter.FilterActive = Convert.ToBoolean(enabled); PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); }
// this method is used when loading a saved search public void SetTelevisionFilter(object enabled) { TelevisionIncluded.FilterActive = Convert.ToBoolean(enabled); PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); }
// this method is used when loading a saved search public void SetBathValue(object value) { BathText.Text = value.ToString(); PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); UpdateListings(); }
// this method is to update the addressprox text box with a new value (loading a saved search) public void SetAddressProx(object value) { AddressProx.Text = value.ToString(); PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); UpdateListings(); }
// this method is to update the address text box with a new value (loading a saved search) public void SetAddress(object value) { AddressTextBox.Text = value.ToString(); currentBasePin = PinCollection.pins.Where(x => x.address != null && (x.address.Equals(AddressTextBox.Text) || (PinCollection.searchLocations[x.address] != null && PinCollection.searchLocations[x.address].Equals(AddressTextBox.Text)))).FirstOrDefault(); PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); UpdateListings(); }
// this method handles updating the filter from the UI private void Buy_ValueChanged(object sender, EventArgs e) { TextBox box = sender as TextBox; int BuyMax; int.TryParse(box.Text, out BuyMax); Filters.FilterDict["BuyMax"] = BuyMax; PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); UpdateListings(); }
// this method is to handle when the buy button is clicked private void Buy_Button_Click(object sender, RoutedEventArgs e) { FilterButton btn = sender as FilterButton; bool enabled = btn.FilterActive; BuySlider.IsEnabled = enabled; BuyText.IsEnabled = enabled; PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); UpdateListings(); }
// this method is to handle when we want to refresh the buy filter from the backend (loading a saved search) public void SetBuyEnabled(object enabled) { bool state = Convert.ToBoolean(enabled); BuySlider.IsEnabled = state; BuyText.IsEnabled = state; BuyButton.FilterActive = state; PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); UpdateListings(); }
// this method is to handle updating the filters when a new address is entered private void UpdateAddressText(object sender, EventArgs e) { if (!addressValid) { Filters.FilterDict["Address"] = AddressTextBox.Text; currentBasePin = PinCollection.pins.Where(x => x.address != null && (x.address.Equals(AddressTextBox.Text) || (PinCollection.searchLocations[x.address] != null && PinCollection.searchLocations[x.address].Equals(AddressTextBox.Text)))).FirstOrDefault(); PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); UpdateListings(); } }
// this method is to handle when the rent button is clicked private void Rent_Button_Click(object sender, RoutedEventArgs e) { FilterButton btn = sender as FilterButton; bool enabled = btn.FilterActive; RentText.IsEnabled = enabled; RentSlider.IsEnabled = enabled; PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); UpdateListings(); TopBarGrid.ColumnDefinitions.ElementAt(5).Width = enabled ? new GridLength(1, GridUnitType.Auto) : new GridLength(0); }
// this method is to handle when we want to refresh the rent filter from the backend (loading a saved search) public void SetRentEnabled(object enabled) { bool state = Convert.ToBoolean(enabled); RentSlider.IsEnabled = state; RentText.IsEnabled = state; RentButton.FilterActive = state; PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); UpdateListings(); TopBarGrid.ColumnDefinitions.ElementAt(5).Width = state ? new GridLength(1, GridUnitType.Auto) : new GridLength(0); }
// this method handles updating the filter from the UI private void Bath_ValueChanged(object sender, EventArgs e) { TextBox box = sender as TextBox; double baths; Double.TryParse(box.Text, out baths); Filters.FilterDict["BathsMin"] = baths; double beds = Convert.ToInt32(Filters.FilterDict["BedsMin"]); ChangeHouseImage(beds, baths); PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); UpdateListings(); }
private void ViewSavedListingsClick(object sender, RoutedEventArgs e) { if (((FilterButton)sender).FilterActive) { // Unselect all the pins PinCollection.pins.Where(x => x.GetType() == typeof(ListingPin)).ToList().ForEach(x => ((ListingPin)x).UnselectPin()); PinCollection.RefreshPins(true); topbarblocker.Visibility = Visibility.Visible; } else { PinCollection.RefreshPins(false); topbarblocker.Visibility = Visibility.Hidden; } UpdateSearchAreaCircle(); UpdateListings(); }
// this method is to handle updating the filters when a new addressprox is entered private void UpdateAddressProx(object sender, EventArgs e) { TextBox box = sender as TextBox; int newVal = -1; int.TryParse(box.Text, out newVal); if (newVal != -1) { Filters.FilterDict["AddressProx"] = newVal; PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); UpdateListings(); } }
public MainPage() { InitializeComponent(); SetRentEnabled(Filters.FilterDict["Rent"]); Filters.ObserverDict.Add("Rent", new Action <object>(SetRentEnabled)); SetBuyEnabled(Filters.FilterDict["Buy"]); Filters.ObserverDict.Add("Buy", new Action <object>(SetBuyEnabled)); AddressTextBox.LostFocus += UpdateAddressText; SetAddress(Filters.FilterDict["Address"]); Filters.ObserverDict.Add("Address", new Action <object>(SetAddress)); SetAddressProx(Filters.FilterDict["AddressProx"]); Filters.ObserverDict.Add("AddressProx", new Action <object>(SetAddressProx)); Filters.ObserverDict.Add("House", new Action <object>(SetHouseFilter)); Filters.ObserverDict.Add("Townhouse", new Action <object>(SetTownhouseFilter)); Filters.ObserverDict.Add("Apartment", new Action <object>(SetApartmentFilter)); Filters.ObserverDict.Add("Condo", new Action <object>(SetCondoFilter)); Filters.ObserverDict.Add("Loft", new Action <object>(SetLoftFilter)); Filters.ObserverDict.Add("Duplex", new Action <object>(SetDuplexFilter)); Filters.ObserverDict.Add("Water", new Action <object>(SetWaterFilter)); Filters.ObserverDict.Add("Electricity", new Action <object>(SetElectricityFilter)); Filters.ObserverDict.Add("Heat", new Action <object>(SetHeatFilter)); Filters.ObserverDict.Add("Internet", new Action <object>(SetInternetFilter)); Filters.ObserverDict.Add("Parking", new Action <object>(SetParkingFilter)); Filters.ObserverDict.Add("Television", new Action <object>(SetTelevisionFilter)); Filters.ObserverDict.Add("RentMax", new Action <object>(SetRentValue)); Filters.ObserverDict.Add("BuyMax", new Action <object>(SetBuyValue)); Filters.ObserverDict.Add("BedsMin", new Action <object>(SetBedValue)); Filters.ObserverDict.Add("BathsMin", new Action <object>(SetBathValue)); ListingsView.PreviewMouseWheel += PreviewMouseWheel; string[] files = Directory.GetFiles("SavedFilters"); foreach (string file in files) { SavableFilters s = new SavableFilters(); s.ReadFilters(file.Remove(file.Length - 4).Substring(13)); saved_searches.Add(file.Remove(file.Length - 4).Substring(13), s); } // Once everything is loaded, calculate where the pins should be placed based on actual size of components Loaded += delegate { foreach (Pin p in PinCollection.pins) { MainGrid.Children.Add(p); Grid.SetColumn(p, 0); Grid.SetRow(p, 1); Grid.SetZIndex(p, 2); // Set initial position p.Margin = GetMapLocationAsMargin(p, p.Width, p.Height * 2); currentBasePin = PinCollection.pins.Where(x => x.address != null && (x.address.Equals(AddressTextBox.Text) || (PinCollection.searchLocations[x.address] != null && PinCollection.searchLocations[x.address].Equals(AddressTextBox.Text)))).FirstOrDefault(); PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); } }; // Update pin locations when the map is zoomed or translated, or when the window is resized MapBorder.OnUpdateTransform += OnUpdateMapTransform; SizeChanged += OnSizeChanged; MouseWheel += OnMouseWheel; locations = new List <string>(); locations.AddRange(PinCollection.searchLocations.Keys); locations.AddRange(PinCollection.searchLocations.Values); AddressTextBox.ItemsSource = locations; sideBarListings = new Dictionary <Pin, SideBarItem>(); foreach (Pin i in PinCollection.pins) { if (i.GetType() == typeof(ListingPin)) { i.Click += OnPinClick; SideBarItem item = new SideBarItem(((ListingPin)i).listing); item.Click += Sidebar_Button_Click; sideBarListings.Add(i, item); } ; } emptySidebarButton = new Button { Height = 50, Background = Brushes.Transparent, BorderBrush = Brushes.Transparent, }; UpdateListings(); MainGrid.MouseDown += MainGrid_MouseDown; }
// this is a click method used to add extra behaviour to a bunch of filters public void PinsRefresh(object sender, RoutedEventArgs e) { PinCollection.RefreshPins(false); UpdateSearchAreaCircle(); UpdateListings(); }