using System; using System.Collections.ObjectModel; using System.Linq; using System.Windows; using Comal.Classes; using InABox.Clients; using InABox.Core; using InABox.Wpf; using Syncfusion.XlsIO.Implementation.PivotTables; using Point = System.Windows.Point; namespace PRSDesktop.Forms { /// /// Interaction logic for MapForm.xaml /// public partial class MapForm : ThemableWindow { private double _zoom = 18.0; public MapForm(double latitude, double longitude, DateTime? timestamp = null) { InitializeComponent(); var geopoint = new GeoPoint(latitude, longitude); var fences = Client.Query().ToArray(); foreach (var fence in fences) { var def = Serialization.Deserialize(fence.Geofence) ?? new GeoFenceDefinition(); if (def.Contains(geopoint)) { Polygon.Points = new ObservableCollection(def.Coordinates.Select(p => new Point(p.Latitude, p.Longitude))); break; } } if (timestamp.HasValue) TimeStamp.Content = $"Last Updated {timestamp:dd MMM yyy hh:mm:ss tt}"; else TimeStamp.Visibility = Visibility.Collapsed; ImageryLayer.Center = new Point(latitude,longitude); } private void ZoomIn_OnClick(object sender, RoutedEventArgs e) { Map.MaxZoom = Math.Min(20, Map.ZoomLevel + 1); Map.ZoomLevel = Math.Min(20, Map.ZoomLevel + 1); } private void ZoomOut_OnClick(object sender, RoutedEventArgs e) { Map.MinZoom= Math.Max(5, Map.ZoomLevel - 1); Map.ZoomLevel = Math.Max(5, Map.ZoomLevel - 1); } } }