123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- using System;
- using System.Collections.Generic;
- using System.Linq.Expressions;
- using System.Windows.Controls;
- using System.Windows.Input;
- using Comal.Classes;
- using Comal.Stores;
- using InABox.Core;
- using InABox.Wpf;
- using Syncfusion.UI.Xaml.Maps;
- using System.ComponentModel;
- using System.Linq;
- using System.Windows;
- using System.Windows.Media;
- using System.Windows.Media.Imaging;
- using Geocoding;
- using InABox.DynamicGrid;
- using InABox.WPF;
- using Microsoft.Xaml.Behaviors.Core;
- using net.sf.mpxj;
- using Brush = System.Drawing.Brush;
- using Location = InABox.Core.Location;
- namespace PRSDesktop
- {
- public class MarkerAlignmentConverter : AbstractConverter<Border?, Thickness>
- {
- public override Thickness Convert(Border? value)
- {
- return new Thickness(
- (value?.Width / 2.0) ?? 0.0,
- (value?.Height / 2.0) ?? 0.0,
- 0.0,
- 0.0);
- }
- }
-
- public class EquipmentThumbnailConverter : AbstractConverter<Guid, BitmapImage?>
- {
-
- public static Dictionary<Guid, BitmapImage?> Cache { get; set; } = new ();
-
- public override BitmapImage? Convert(Guid value)
- {
- if (Cache?.TryGetValue(value, out var result) == true)
- return result;
- return null;
- }
- }
-
- public class EquipmentColorConverter : AbstractConverter<Equipment?, System.Windows.Media.Color>
- {
-
- public static GPSTrackerLocation[] Pings { get; set; }
-
- public override System.Windows.Media.Color Convert(Equipment? value)
- {
- if (value != null)
- {
- if (Pings?.Any(x=>x.Tracker.ID == value.TrackerLink.ID) == true)
- return Colors.LightYellow;
- }
- return Colors.LightGray;
- }
- }
-
- public class MarkerTemplateSelector : DataTemplateSelector
- {
- public DataTemplate? AssetMarkerTemplate { get; set; }
- public DataTemplate? SiteMarkerTemplate { get; set; }
- public override DataTemplate? SelectTemplate(object? item, DependencyObject container)
- {
- if (item is CustomDataSymbol customDataSymbol && customDataSymbol.Data != null)
- {
- return customDataSymbol.Data is SiteMapMarker
- ? SiteMarkerTemplate
- : AssetMarkerTemplate;
- }
- return base.SelectTemplate(item, container);
- }
- }
- /// <summary>
- /// Interaction logic for MapsPanel.xaml
- /// </summary>
- public partial class LiveMapsPanel : UserControl, IPanel<GPSTracker>
- {
-
-
- public LiveMapsPanel()
- {
- InitializeComponent();
- }
- public bool IsReady { get; set; }
- public void CreateToolbarButtons(IPanelHost host)
- {
- }
- public string SectionName => "Maps";
- public DataModel DataModel(Selection selection)
- {
- return new MapsDataModel();
- }
- public void Heartbeat(TimeSpan time)
- {
- }
- public void Refresh()
- {
- ViewModel.Refresh();
- }
- public Dictionary<string, object[]> Selected()
- {
- return new Dictionary<string, object[]>();
- }
- public void Setup()
- {
-
- }
- public void Shutdown(CancelEventArgs? cancel)
- {
- }
- public event DataModelUpdateEvent? OnUpdateDataModel;
-
- private void Map_OnPanned(object sender, PanEventArgs args)
- {
- ViewModel.SelectedSite = null;
- }
- private void Map_OnZoomed(object sender, ZoomEventArgs args)
- {
- ViewModel.SelectedSite = null;
- }
- }
- }
|