QuoteDesigns.xaml.cs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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. namespace PRSDesktop
  10. {
  11. /// <summary>
  12. /// Interaction logic for QuoteTakeoffs.xaml
  13. /// </summary>
  14. public partial class QuoteDesigns : UserControl, IQuotePage, IPanel<Quote>
  15. {
  16. public QuoteDesigns()
  17. {
  18. InitializeComponent();
  19. Designs.OnSelectItem += Designs_OnSelectItem;
  20. }
  21. public bool IsReady { get; set; }
  22. public event DataModelUpdateEvent OnUpdateDataModel;
  23. public void CreateToolbarButtons(IPanelHost host)
  24. {
  25. }
  26. public string SectionName => "Quote Designs";
  27. public DataModel DataModel(Selection selected)
  28. {
  29. var designs = Designs.ExtractValues(x => x.ID, selected).ToArray();
  30. return new BaseDataModel<QuoteDesign>(new Filter<QuoteDesign>(x => x.ID).InList(designs));
  31. }
  32. public void Heartbeat(TimeSpan time)
  33. {
  34. }
  35. public void Refresh()
  36. {
  37. Designs.Refresh(false, true);
  38. Items.Refresh(false, true);
  39. }
  40. public Dictionary<string, object[]> Selected()
  41. {
  42. return new Dictionary<string, object[]>();
  43. }
  44. public void Setup()
  45. {
  46. Designs.Refresh(true, false);
  47. Items.Refresh(true, false);
  48. }
  49. public void Shutdown(CancelEventArgs? cancel)
  50. {
  51. }
  52. public Quote Quote
  53. {
  54. get => Designs.Quote;
  55. set => Designs.Quote = value;
  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. var row = e.Rows?.FirstOrDefault();
  64. Items.Design = row?.ToObject<QuoteDesign>() ?? new QuoteDesign();
  65. Items.Refresh(false, true);
  66. }
  67. }
  68. }