GPSTrackers.xaml.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. }
  46. public void Refresh()
  47. {
  48. Trackers.Refresh(true, true);
  49. }
  50. public string SectionName => "GPS Trackers";
  51. public DataModel DataModel(Selection selection)
  52. {
  53. var ids = Trackers.ExtractValues(x => x.ID, selection).ToArray();
  54. return new BaseDataModel<GPSTracker>(new Filter<GPSTracker>(x => x.ID).InList(ids));
  55. }
  56. public void Heartbeat(TimeSpan time)
  57. {
  58. }
  59. public Type DataType()
  60. {
  61. return typeof(GPSTracker);
  62. }
  63. }
  64. }