/// <summary> /// Resize items in ListView. /// </summary> public void Resize() { if (List == null) { return; } if (widths.Count < 2) { return; } List.Start(); List.ForEachComponent(ResizeComponent); }
public void RestoreOrder() { // restore order if ((List != null) && (CellsInfo != null) && (CellsInfo.Count > 1)) { //restore header cells order CellsInfo.ForEach((x, i) => { x.Position = i; x.Rect.SetSiblingIndex(i); }); // restore list components cells order List.Init(); List.ForEachComponent(component => { var resizable_item = component as IResizableItem; if (resizable_item == null) { return; } var objects = resizable_item.ObjectsToResize; objects.ForEach((x, i) => x.transform.SetSiblingIndex(i)); }); } }
/// <summary> /// Set the columns order. /// </summary> /// <param name="order">New columns order.</param> public void SetColumnsOrder(List <int> order) { // restore original order RestoreColumnsOrder(); // convert list of the new positions to list of the old positions var reverse_order = new List <int>(); for (int i = 0; i < order.Count; i++) { reverse_order.Add(order.IndexOf(i)); } var cells = new List <Transform>(); // restore list components cells order List.Init(); List.ForEachComponent(component => { cells.Clear(); foreach (Transform child in component.transform) { cells.Add(child); } for (int i = 0; i < reverse_order.Count; i++) { cells[i].SetAsLastSibling(); } }); for (int new_position = 0; new_position < reverse_order.Count; new_position++) { var old_position = reverse_order[new_position]; CellsInfo[old_position].Position = new_position; CellsInfo[old_position].Rect.SetAsLastSibling(); } }