/// <summary> /// Setup a control, it may create a new one. /// </summary> protected static object CreateControl(T parent, LitUiAttribute attr, PropertyInfo propInfo, object data) { var control = attr != null?Instance.CreateControl(attr.CtrlType) : null; if (control != null) { if (attr.HasGridSpecification && parent is TGrid grid) { var colCount = Instance.GetColumnsCount(grid); var rowCount = Instance.GetRowsCount(grid); var left = attr.Col; var right = attr.Col + attr.ColSpan < 0 ? colCount + attr.ColSpan : attr.ColSpan - 1; var top = attr.Row; var bottom = attr.Row + attr.RowSpan < 0 ? rowCount + attr.RowSpan : attr.RowSpan - 1; Instance.AddChild(grid, control, attr.Col, attr.Row); var colSpan = attr.ColSpan; if (colSpan < 0) { colSpan = 1 + colCount + attr.ColSpan - attr.Col; } if (colSpan != 1) { Instance.SetColumnSpan(control, colSpan); } var rowSpan = attr.RowSpan; if (rowSpan < 0) { rowSpan = 1 + rowCount + attr.RowSpan - attr.Row; } if (rowSpan != 1) { Instance.SetRowSpan(control, rowSpan); } } else { Instance.AddChild(parent, control); } UpdateControl(control, attr, propInfo, data, true); } /*else if (attr == null || attr.CtrlType == ControlType.None) * { * control = parent; * }*/ return(control); }
/// <summary> /// Update and optionally setup a control. /// </summary> protected static bool UpdateControl(TControl control, LitUiAttribute attr, PropertyInfo propInfo, object data, bool setup) { var controlType = attr?.CtrlType; if (controlType == ControlType.None) { controlType = Instance.GetControlType(control); } var controlProps = controlType != ControlType.None ? ReflectionPropertiesCache.Get(control.GetType()) : null; var dataProps = data != null ? ReflectionPropertiesCache <LitUiAttribute> .Get(data.GetType()) : null; return(Instance.UpdateControl(setup, controlType, control, controlProps, attr, propInfo, data, dataProps)); }
/// <summary> /// Updates (optionally also setup) a control. /// </summary> protected abstract bool UpdateControl(bool setup, ControlType?controlType, TControl control, IReflectionProperties controlProps, LitUiAttribute attr, PropertyInfo propInfo, object data, IReflectionProperties <LitUiAttribute> dataProps);