| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System;
- using System.Collections.ObjectModel;
- using System.Linq;
- using System.Windows;
- using System.Windows.Media;
- using Comal.Classes;
- using InABox.Clients;
- using InABox.Core;
- using InABox.Wpf;
- using Syncfusion.UI.Xaml.Maps;
- using Syncfusion.Windows.PdfViewer;
- 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, GeoFenceDefinition? geofence = null, DateTime? timestamp = null)
- {
- InitializeComponent();
-
- var geopoint = new GeoPoint(latitude, longitude);
- if (geofence?.Coordinates.Any() == true)
- Polygon.Points = new ObservableCollection<Point>(geofence.Coordinates.Select(p => new Point(p.Latitude, p.Longitude)));
- else
- {
- var circle = new MapCircle();
- circle.Center = new Point(latitude, longitude);
- circle.Radius = 25;
- circle.Fill = new SolidColorBrush(Colors.Red) { Opacity = 0.5 };
- subLayer.MapElements.Add(circle);
- }
- // 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);
- }
- }
- }
|