CustomPropertyGrid.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Reflection;
  5. using Comal.Classes;
  6. using InABox.Clients;
  7. using InABox.Core;
  8. using InABox.DynamicGrid;
  9. namespace PRSDesktop.Configuration;
  10. internal class CustomPropertyGrid : DynamicDataGrid<CustomProperty>
  11. {
  12. protected override void Init()
  13. {
  14. base.Init();
  15. HiddenColumns.Add(x => x.Class);
  16. HiddenColumns.Add(x => x.Type);
  17. }
  18. protected override void DoReconfigure(DynamicGridOptions options)
  19. {
  20. base.DoReconfigure(options);
  21. options.RecordCount = true;
  22. options.SelectColumns = true;
  23. }
  24. protected override void DoValidate(CustomProperty[] items, List<string> errors)
  25. {
  26. base.DoValidate(items, errors);
  27. if (items.Any(x => string.IsNullOrWhiteSpace(x.Class)))
  28. errors.Add("[Class] must not be blank!");
  29. if (items.Any(x => string.IsNullOrWhiteSpace(x.Name)))
  30. errors.Add("[Name] must not be blank!");
  31. if (items.Any(x => string.IsNullOrWhiteSpace(x.Type)))
  32. errors.Add("[Type] must not be blank!");
  33. }
  34. }