CustomerPanel.xaml.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows;
  5. using System.Windows.Controls;
  6. using Comal.Classes;
  7. using InABox.Core;
  8. namespace PRSDesktop
  9. {
  10. public partial class CustomerPanel : UserControl, IPanel<Customer>
  11. {
  12. private readonly CustomerGrid Customers;
  13. public CustomerPanel()
  14. {
  15. InitializeComponent();
  16. Customers = new CustomerGrid
  17. {
  18. HorizontalAlignment = HorizontalAlignment.Stretch,
  19. VerticalAlignment = VerticalAlignment.Stretch,
  20. Margin = new Thickness(0)
  21. };
  22. AddChild(Customers);
  23. }
  24. public bool IsReady { get; set; }
  25. public event DataModelUpdateEvent OnUpdateDataModel;
  26. public Dictionary<string, object[]> Selected()
  27. {
  28. return new Dictionary<string, object[]> { { typeof(Customer).EntityName(), Customers.SelectedRows } };
  29. }
  30. public void Setup()
  31. {
  32. }
  33. public void Shutdown()
  34. {
  35. }
  36. public void CreateToolbarButtons(IPanelHost host)
  37. {
  38. //host.CreateToolbarButton(new PanelAction() { Caption = "Select Columns", OnExecute = DoSelectColumns, Image = PRSDesktop.Resources.shared });
  39. }
  40. public void Refresh()
  41. {
  42. Customers.Refresh(true, true);
  43. }
  44. public string SectionName => "Customers";
  45. public DataModel DataModel(Selection selection)
  46. {
  47. var ids = Customers.ExtractValues(x => x.ID, selection).ToArray();
  48. return new BaseDataModel<Customer>(new Filter<Customer>(x => x.ID).InList(ids));
  49. }
  50. public void Heartbeat(TimeSpan time)
  51. {
  52. }
  53. public Type DataType()
  54. {
  55. return typeof(Customer);
  56. }
  57. }
  58. }