GPSTrackers.xaml.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Windows;
  6. using System.Windows.Controls;
  7. using Comal.Classes;
  8. using InABox.Core;
  9. using InABox.DynamicGrid;
  10. using InABox.Wpf;
  11. namespace PRSDesktop
  12. {
  13. /// <summary>
  14. /// Interaction logic for GPSTrackers.xaml
  15. /// </summary>
  16. public partial class GPSTrackers : UserControl, IPanel<GPSTracker>
  17. {
  18. private readonly GPSTrackerGrid Trackers;
  19. public GPSTrackers()
  20. {
  21. InitializeComponent();
  22. Trackers = new GPSTrackerGrid
  23. {
  24. HorizontalAlignment = HorizontalAlignment.Stretch,
  25. VerticalAlignment = VerticalAlignment.Stretch,
  26. Margin = new Thickness(0)
  27. };
  28. Trackers.Reconfigure(options => options.AddRange(DynamicGridOption.RecordCount, DynamicGridOption.FilterRows, DynamicGridOption.MultiSelect,
  29. DynamicGridOption.SelectColumns));
  30. AddChild(Trackers);
  31. }
  32. public bool IsReady { get; set; }
  33. public event DataModelUpdateEvent? OnUpdateDataModel;
  34. public Dictionary<string, object[]> Selected()
  35. {
  36. return new Dictionary<string, object[]> { { typeof(GPSTracker).EntityName(), Trackers.SelectedRows } };
  37. }
  38. public void Setup()
  39. {
  40. }
  41. public void Shutdown(CancelEventArgs? cancel)
  42. {
  43. }
  44. public void CreateToolbarButtons(IPanelHost host)
  45. {
  46. EquipmentSetupActions.TrackerTypes(host);
  47. }
  48. public void Refresh()
  49. {
  50. Trackers.Refresh(true, true);
  51. }
  52. public string SectionName => "GPS Trackers";
  53. public DataModel DataModel(Selection selection)
  54. {
  55. var ids = Trackers.ExtractValues(x => x.ID, selection).ToArray();
  56. return new BaseDataModel<GPSTracker>(new Filter<GPSTracker>(x => x.ID).InList(ids));
  57. }
  58. public void Heartbeat(TimeSpan time)
  59. {
  60. }
  61. public Type DataType()
  62. {
  63. return typeof(GPSTracker);
  64. }
  65. }
  66. }