QuoteDesigns.xaml.cs 2.1 KB

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