private void LoadSaveClick(object sender, EventArgs e) { SavableFilters saved_filters = new SavableFilters(); saved_filters.ReadFilters(searchname); Filters.InitializeFilters(saved_filters); p.Cancel_Click(sender, e); }
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; }