CustomPropertyGrid.cs 1.1 KB

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