123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- 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
- {
-
- /// <summary>
- /// Interaction logic for MapForm.xaml
- /// </summary>
- 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<GeoFence>().ToArray<GeoFence>();
- foreach (var fence in fences)
- {
- var def = Serialization.Deserialize<GeoFenceDefinition>(fence.Geofence) ?? new GeoFenceDefinition();
- if (def.Contains(geopoint))
- {
- Polygon.Points = new ObservableCollection<Point>(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);
- }
- }
- }
|