DynamicFormWindow.cs 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using InABox.Core;
  2. using System.Collections.Generic;
  3. namespace InABox.DynamicGrid;
  4. public interface IDynamicFormWindow
  5. {
  6. DynamicFormDesignGrid Grid { get; }
  7. }
  8. public static class DynamicFormWindowExtensions
  9. {
  10. public static void LoadLayout(this IDynamicFormWindow window, DigitalFormLayout layout, IList<DigitalFormVariable> variables)
  11. {
  12. window.Grid.Variables = variables;
  13. var f = new DFLayout();
  14. if (!string.IsNullOrWhiteSpace(layout.Layout))
  15. {
  16. f.LoadLayout(layout.Layout);
  17. }
  18. else
  19. {
  20. f = new DFLayout();
  21. f.RowHeights.Add("Auto");
  22. f.ColumnWidths.AddRange(new[] { "*", "Auto" });
  23. }
  24. f.LoadVariables(variables);
  25. window.Grid.Form = f;
  26. }
  27. /// <summary>
  28. /// Renders the form; after this is called, any changes to properties triggers a refresh.
  29. /// </summary>
  30. public static void Initialize(this IDynamicFormWindow window)
  31. {
  32. window.Grid.Initialize();
  33. }
  34. }