GPSTrackers.xaml.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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 =>
  29. {
  30. options.RecordCount = true;
  31. options.FilterRows = true;
  32. options.MultiSelect = true;
  33. options.SelectColumns = true;
  34. });
  35. AddChild(Trackers);
  36. }
  37. public bool IsReady { get; set; }
  38. public event DataModelUpdateEvent? OnUpdateDataModel;
  39. public Dictionary<string, object[]> Selected()
  40. {
  41. return new Dictionary<string, object[]> { { typeof(GPSTracker).EntityName(), Trackers.SelectedRows } };
  42. }
  43. public void Setup()
  44. {
  45. }
  46. public void Shutdown(CancelEventArgs? cancel)
  47. {
  48. }
  49. public void CreateToolbarButtons(IPanelHost host)
  50. {
  51. EquipmentSetupActions.TrackerTypes(host);
  52. }
  53. public void Refresh()
  54. {
  55. Trackers.Refresh(true, true);
  56. }
  57. public string SectionName => "GPS Trackers";
  58. public DataModel DataModel(Selection selection)
  59. {
  60. var ids = Trackers.ExtractValues(x => x.ID, selection).ToArray();
  61. return new BaseDataModel<GPSTracker>(Filter<GPSTracker>.Where(x => x.ID).InList(ids));
  62. }
  63. public void Heartbeat(TimeSpan time)
  64. {
  65. }
  66. public Type DataType()
  67. {
  68. return typeof(GPSTracker);
  69. }
  70. }
  71. }