GPSTrackers.xaml.cs 2.1 KB

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