public PlaceItemView(GeolocationPlace place) { Place = place; this.Icon = LazuriteUI.Icons.Icon.ChevronRight; this.Content = place.Name; this.Margin = new System.Windows.Thickness(0, 1, 0, 0); }
public void AddPlace(GeolocationPlace place) { this.Places = this.Places.Union(new[] { place }).ToArray(); this.SelectedPlace = place; PlacesManager.Current.Places.Add(place); PlacesManager.Save(); }
public void RemovePlace(GeolocationPlace place) { this.Places = this.Places.Where(x => x != place).ToArray(); this.SelectedPlace = this.Places.FirstOrDefault(); PlacesManager.Current.Places.Remove(place); PlacesManager.Save(); }
public PlacesLocationsView() { InitializeComponent(); bool ignorePlaceNavigation = false; placesView.SelectedPlaceChanged += (o, e) => { placeEditView.RefreshWith(e.Value); if (!ignorePlaceNavigation) { locationsView.NavigateTo(e.Value); } btRemovePlace.IsEnabled = e.Value != null; SelectedPlaceChanged?.Invoke(this, new EventsArgs <GeolocationPlace>(e.Value)); }; locationsView.PlaceNavigated += (o, e) => { ignorePlaceNavigation = true; var placeToSelect = placesView.Places.FirstOrDefault(x => x.Name == e.Value); placesView.SelectedPlace = placeToSelect; btRemovePlace.IsEnabled = placesView.SelectedPlace != null; ignorePlaceNavigation = false; }; btAddPlace.Click += (o, e) => { var geolocationPlace = new GeolocationPlace(); geolocationPlace.Name = "Новое место " + (PlacesManager.Current.Places.Count(x => x.Name.StartsWith("Новое место")) + 1); geolocationPlace.Location = locationsView.CurrentLocation; geolocationPlace.MetersRadious = 200; placesView.AddPlace(geolocationPlace); RefreshWith(_targets, null); placesView.SelectedPlace = geolocationPlace; }; btRemovePlace.Click += (o, e) => { if (placesView.SelectedPlace != null) { placesView.RemovePlace(placesView.SelectedPlace); RefreshWith(_targets, null); } }; placeEditView.SettingsApplied += (o, e) => { ignorePlaceNavigation = true; RefreshWith(_targets, null); placesView.SelectedPlace = e.Value; ignorePlaceNavigation = false; }; }
public void RefreshWith(GeolocationPlace place) { sliderRadious.Maximum = 3000; if (place != null) { _place = place; tbPlaceName.Text = _place.Name; tbRadious.Text = _place.MetersRadious.ToString(); btApply.IsEnabled = false; this.IsEnabled = true; } else { this.IsEnabled = false; } }
public void NavigateTo(GeolocationPlace place) { if (place != null && !this.CurrentLocation.Equals(place.Location)) { _gmapControl.SuspendLayout(); var fakeRoute = _gmapControl.Overlays .SelectMany(x => x.Routes) .Where(x => x.Tag is Place) .FirstOrDefault(x => ((Place)x.Tag).PlaceName.Equals(place.Name)); if (fakeRoute != null) { var rectToZoom = _gmapControl.GetRectOfRoute(fakeRoute); if (rectToZoom != null) { _gmapControl.SetZoomToFitRect(rectToZoom.Value); } } _gmapControl.Zoom -= 2; _gmapControl.ResumeLayout(); UpdateCurrentCoords(); } }