LiveMapsPanel.xaml.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq.Expressions;
  4. using System.Windows.Controls;
  5. using System.Windows.Input;
  6. using Comal.Classes;
  7. using Comal.Stores;
  8. using InABox.Core;
  9. using InABox.Wpf;
  10. using Syncfusion.UI.Xaml.Maps;
  11. using System.ComponentModel;
  12. using System.Linq;
  13. using System.Windows.Media;
  14. using System.Windows.Media.Imaging;
  15. using Geocoding;
  16. using InABox.WPF;
  17. using Microsoft.Xaml.Behaviors.Core;
  18. using net.sf.mpxj;
  19. using Brush = System.Drawing.Brush;
  20. using Location = InABox.Core.Location;
  21. namespace PRSDesktop
  22. {
  23. public class EquipmentThumbnailConverter : AbstractConverter<Guid, BitmapImage?>
  24. {
  25. public static Dictionary<Guid, BitmapImage?> Cache { get; set; } = new ();
  26. public override BitmapImage? Convert(Guid value)
  27. {
  28. if (Cache?.TryGetValue(value, out var result) == true)
  29. return result;
  30. return null;
  31. }
  32. }
  33. public class EquipmentColorConverter : AbstractConverter<Equipment?, System.Windows.Media.Brush>
  34. {
  35. public static GPSTrackerLocation[] Pings { get; set; }
  36. public override System.Windows.Media.Brush Convert(Equipment? value)
  37. {
  38. if (value != null)
  39. {
  40. if (Pings?.Any(x=>x.Tracker.ID == value.TrackerLink.ID) == true)
  41. return new SolidColorBrush(Colors.LightYellow) { Opacity = 0.5};
  42. }
  43. return new SolidColorBrush(Colors.LightGray) { Opacity = 0.5};
  44. }
  45. }
  46. /// <summary>
  47. /// Interaction logic for MapsPanel.xaml
  48. /// </summary>
  49. public partial class LiveMapsPanel : UserControl, IPanel<GPSTracker>
  50. {
  51. public LiveMapsPanel()
  52. {
  53. InitializeComponent();
  54. }
  55. public bool IsReady { get; set; }
  56. public void CreateToolbarButtons(IPanelHost host)
  57. {
  58. }
  59. public string SectionName => "Maps";
  60. public DataModel DataModel(Selection selection)
  61. {
  62. return new MapsDataModel();
  63. }
  64. public void Heartbeat(TimeSpan time)
  65. {
  66. }
  67. public void Refresh()
  68. {
  69. ViewModel.Refresh();
  70. }
  71. public Dictionary<string, object[]> Selected()
  72. {
  73. return new Dictionary<string, object[]>();
  74. }
  75. public void Setup()
  76. {
  77. }
  78. public void Shutdown(CancelEventArgs? cancel)
  79. {
  80. }
  81. public event DataModelUpdateEvent? OnUpdateDataModel;
  82. }
  83. }