CustomPropertyGrid.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. using System.Collections.Generic;
  2. using System.Linq;
  3. using InABox.Core;
  4. using InABox.DynamicGrid;
  5. namespace PRSServer.Forms.CustomProperties
  6. {
  7. internal class CustomPropertyGrid : DynamicDataGrid<CustomProperty>
  8. {
  9. public CustomPropertyGrid()
  10. {
  11. HiddenColumns.Add(x => x.Class);
  12. HiddenColumns.Add(x => x.Type);
  13. }
  14. protected override void DoReconfigure(FluentList<DynamicGridOption> options)
  15. {
  16. base.DoReconfigure(options);
  17. options.AddRange(
  18. DynamicGridOption.AddRows,
  19. DynamicGridOption.EditRows,
  20. DynamicGridOption.DeleteRows,
  21. DynamicGridOption.RecordCount,
  22. DynamicGridOption.SelectColumns
  23. );
  24. }
  25. protected override void DoValidate(CustomProperty[] items, List<string> errors)
  26. {
  27. base.DoValidate(items, errors);
  28. if (items.Any(x => string.IsNullOrWhiteSpace(x.Class)))
  29. errors.Add("[Class] must not be blank!");
  30. if (items.Any(x => string.IsNullOrWhiteSpace(x.Name)))
  31. errors.Add("[Name] must not be blank!");
  32. if (items.Any(x => string.IsNullOrWhiteSpace(x.Type)))
  33. errors.Add("[Type] must not be blank!");
  34. }
  35. }
  36. }