QAFormLayoutGrid.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Windows.Media.Imaging;
  5. using Comal.Classes;
  6. using InABox.Core;
  7. using InABox.DynamicGrid;
  8. using InABox.WPF;
  9. namespace PRSDesktop.Configuration
  10. {
  11. public abstract class QAFormLayoutGrid<T> : DynamicOneToManyGrid<DigitalForm, DigitalFormLayout> where T : Entity, IRemotable, IPersistent, new()
  12. {
  13. private readonly BitmapImage design = PRSDesktop.Resources.design.AsBitmapImage();
  14. public QAFormLayoutGrid()
  15. {
  16. Options.AddRange(DynamicGridOption.RecordCount);
  17. ActionColumns.Add(new DynamicActionColumn(DesignImage, DesignClick));
  18. //AddButton("Design", PRSDesktop.Resources.design.AsBitmapImage(), DesignClick);
  19. HiddenColumns.Add(x => x.Layout);
  20. }
  21. private BitmapImage DesignImage(CoreRow row)
  22. {
  23. return row != null ? design : null;
  24. }
  25. private bool DesignClick(CoreRow row)
  26. {
  27. if (row == null)
  28. return false;
  29. var layout = LoadItem(row);
  30. var vPage =
  31. EditorGrid.Pages.FirstOrDefault(x => x is DynamicOneToManyGrid<DigitalForm, DigitalFormVariable>) as
  32. DynamicOneToManyGrid<DigitalForm, DigitalFormVariable>;
  33. var variables = vPage != null ? vPage.Items.ToArray() : Array.Empty<DigitalFormVariable>();
  34. var vprops = new Dictionary<string, string>();
  35. var form = new DynamicFormDesignWindow
  36. {
  37. Type = layout.Type
  38. };
  39. form.LoadLayout(layout, variables);
  40. form.Initialize();
  41. if (form.ShowDialog() == true)
  42. {
  43. layout.Layout = form.SaveLayout();
  44. SaveItem(layout);
  45. }
  46. return false;
  47. }
  48. //protected override void SaveItem(DigitalFormLayout item)
  49. //{
  50. // bool bActive = item.Active;
  51. // foreach (var other in Items.Where(x=>(x != item) && (x.Type == item.Type)))
  52. // {
  53. // if (item.Active)
  54. // {
  55. // if (other.Active)
  56. // other.Active = false;
  57. // }
  58. // else
  59. // bActive = bActive || other.Active;
  60. // }
  61. // if (!bActive)
  62. // item.Active = true;
  63. // base.SaveItem(item);
  64. //}
  65. protected override void DoDoubleClick(object sender)
  66. {
  67. DesignClick(SelectedRows.FirstOrDefault());
  68. }
  69. }
  70. public class QAFormLayoutGrid : QAFormLayoutGrid<DigitalForm>
  71. {
  72. }
  73. public class KanbanQALayoutGrid : QAFormLayoutGrid<Kanban>
  74. {
  75. }
  76. public class ITPQALayoutGrid : QAFormLayoutGrid<JobITP>
  77. {
  78. }
  79. public class AssignmentQALayoutGrid : QAFormLayoutGrid<Assignment>
  80. {
  81. }
  82. public class ManufacturingSectionQALayoutGrid : QAFormLayoutGrid<ManufacturingSection>
  83. {
  84. }
  85. public class ManufacturingPacketStageQALayoutGrid : QAFormLayoutGrid<ManufacturingPacketStage>
  86. {
  87. }
  88. }