public List<Panel> loadLayout(Scaffold scaffold) { var panels = new List<Panel>(); foreach (var item in scaffold.elements) { if (item.name.IndexOf("panel-") == 0) { //create a new panel for the layout var id = item.name.Split('-')[1]; var p = new Panel(S, id, "panel " + id); p.cells = new List<Panel.structCell>(); p.arrangement = new Panel.structArrangement(); p.AddCell(); panels.Add(p); } } return panels; }
/// <summary> /// Initializes a component & sets up default properties if they don't already exist /// </summary> /// <param name="component"></param> /// <param name="panelId"></param> public Component loadComponent(Component component, Panel panel, Panel.structCell cell, bool isCreated = false) { if(component.id == "") { //component is new component.id = S.Util.Str.CreateID(); } component.panelId = panel.id; component.panelCellId = cell.id; //add component to panel cell var cellIndex = panel.cells.FindIndex(a => a.id == cell.id); if (cellIndex < 0) { cellIndex = 0; } var compIndex = panel.cells[cellIndex].components.Count; panel.cells[cellIndex].components.Add(component); panel.cells[cellIndex].componentIds.Add(component.id); panel.cells[cellIndex].components[compIndex].Initialize(S, this); if(isCreated == true) { panel.cells[cellIndex].components[compIndex].Create(); } panel.cells[cellIndex].components[compIndex].Load(); return panel.cells[cellIndex].components[compIndex]; }