CustomPropertyGrid.cs 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637
  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(DynamicGridOptions options)
  15. {
  16. base.DoReconfigure(options);
  17. options.AddRows = true;
  18. options.EditRows = true;
  19. options.DeleteRows = true;
  20. options.RecordCount = true;
  21. options.SelectColumns = true;
  22. }
  23. protected override void DoValidate(CustomProperty[] items, List<string> errors)
  24. {
  25. base.DoValidate(items, errors);
  26. if (items.Any(x => string.IsNullOrWhiteSpace(x.Class)))
  27. errors.Add("[Class] must not be blank!");
  28. if (items.Any(x => string.IsNullOrWhiteSpace(x.Name)))
  29. errors.Add("[Name] must not be blank!");
  30. if (items.Any(x => string.IsNullOrWhiteSpace(x.Type)))
  31. errors.Add("[Type] must not be blank!");
  32. }
  33. }
  34. }