DynamicFormWindow.cs 1.2 KB

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