QuoteDesigns.xaml.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Linq;
  5. using System.Windows.Controls;
  6. using Comal.Classes;
  7. using InABox.Core;
  8. using InABox.DynamicGrid;
  9. using InABox.Wpf;
  10. namespace PRSDesktop
  11. {
  12. /// <summary>
  13. /// Interaction logic for QuoteTakeoffs.xaml
  14. /// </summary>
  15. public partial class QuoteDesigns : UserControl, IMasterDetailControl<Quote>, IPanel<Quote>
  16. {
  17. public Quote? Master
  18. {
  19. get => Designs.Master;
  20. set => Designs.Master = value;
  21. }
  22. public QuoteDesigns()
  23. {
  24. InitializeComponent();
  25. }
  26. public bool IsReady { get; set; }
  27. public event DataModelUpdateEvent? OnUpdateDataModel;
  28. public void CreateToolbarButtons(IPanelHost host)
  29. {
  30. }
  31. public string SectionName => "Quote Designs";
  32. public DataModel DataModel(Selection selected)
  33. {
  34. var designs = Designs.ExtractValues(x => x.ID, selected).ToArray();
  35. return new BaseDataModel<QuoteDesign>(new Filter<QuoteDesign>(x => x.ID).InList(designs));
  36. }
  37. public void Heartbeat(TimeSpan time)
  38. {
  39. }
  40. public void Refresh()
  41. {
  42. Designs.Refresh(false, true);
  43. Items.Refresh(false, true);
  44. }
  45. public Dictionary<string, object[]> Selected()
  46. {
  47. return new Dictionary<string, object[]>();
  48. }
  49. public void Setup()
  50. {
  51. Designs.Refresh(true, false);
  52. Items.Refresh(true, false);
  53. }
  54. public void Shutdown(CancelEventArgs? cancel)
  55. {
  56. }
  57. public Dictionary<Type, CoreTable> DataEnvironment()
  58. {
  59. return new Dictionary<Type, CoreTable>();
  60. }
  61. private void Designs_OnSelectItem(object sender, DynamicGridSelectionEventArgs e)
  62. {
  63. Items.Master = e.Rows?.FirstOrDefault()?.ToObject<QuoteDesign>();
  64. Items.Refresh(false, true);
  65. }
  66. }
  67. }