/// <summary> /// Set ListView DataSource. /// </summary> public void SetList() { ListView.DataSource = Utilites.CreateList(100, x => new ListViewSliderItem() { Value = Random.Range(0, 100) }); }
/// <summary> /// Set new list to ListViewIcons with specified items count. /// </summary> /// <param name="n">Items count.</param> public void TestiN(int n) { ListViewIcons.DataSource = Utilites.CreateList(n, x => new ListViewIconsItemDescription() { Name = x.ToString("00000"), }); }
/// <summary> /// Generate items list. /// </summary> /// <param name="count">Items count.</param> /// <returns>List.</returns> protected ObservableList <T> GenerateList(int count) { if (!CanGenerateItems) { return(new ObservableList <T>()); } return(Utilites.CreateList <T>(count, GenerateItem)); }
/// <summary> /// Generate and set TileViewIcons DataSource. /// </summary> protected virtual void Start() { var n = Icons.Count - 1; var tiles = GetComponent <TileViewIcons>(); tiles.Init(); tiles.DataSource = Utilites.CreateList(140, x => new ListViewIconsItemDescription() { Name = "Tile " + x, Icon = Icons.Count > 0 ? Icons[Random.Range(0, n)] : null, }); }
/// <summary> /// Generate nodes. /// </summary> /// <param name="items">Depth list.</param> /// <param name="nameStartsWith">Start part of name.</param> /// <param name="isExpanded">Is nodes expanded?</param> /// <param name="icon">Icon</param> /// <param name="start">Start index in the depth list.</param> /// <returns>Nodes.</returns> public static ObservableList <TreeNode <TreeViewItem> > GenerateTreeNodes(List <int> items, string nameStartsWith = "Node ", bool isExpanded = true, Sprite icon = null, int start = 0) { return(Utilites.CreateList(items[start], x => { var item_name = nameStartsWith + x; var item = new TreeViewItem(item_name, icon); var nodes = items.Count > (start + 1) ? GenerateTreeNodes(items, item_name + " - ", isExpanded, icon, start + 1) : null; return new TreeNode <TreeViewItem>(item, nodes, isExpanded); })); }
/// <summary> /// Show picker. /// </summary> public void ShowPicker() { currentPopup = PopupTemplate.Clone(); currentPopup.Show(); currentListView = currentPopup.GetComponentInChildren <ListViewInt>(); // fill list with values currentListView.DataSource = Utilites.CreateList(100, x => x); // deselect currentListView.SelectedIndex = -1; currentListView.OnSelectObject.AddListener(Callback); }
/// <summary> /// Run test. /// </summary> public void TestShow() { // create picker from template var picker = PickerTemplate.Clone(); // set values from template // picker.ListView.DataSource = PickerTemplate.ListView.DataSource.ToObservableList(); // or set new values picker.ListView.DataSource = Utilites.CreateList(100, x => x); // show picker picker.Show(currentValue, ShowValueSelected, ShowCanceled); }
/// <summary> /// Generate DataSource with specified items count. /// </summary> /// <param name="count">Items count.</param> public void GenerateItems(int count) { var tiles = GetComponent <TileViewSample>(); tiles.DataSource = Utilites.CreateList(count, x => { return(new TileViewItemSample() { Name = "Tile " + x, Capital = string.Empty, Area = Random.Range(10, 10 * 6), Population = Random.Range(100, 100 * 6), }); }); }
/// <summary> /// Generate nodes. /// </summary> /// <param name="config">List of nodex count per level.</param> /// <param name="namePrefix">Name prefix.</param> /// <param name="start">Start index in the config.</param> /// <returns>Nodex.</returns> protected ObservableList <TreeNode <T> > GenerateNodes(List <int> config, string namePrefix = "Node ", int start = 0) { if (!CanGenerateItems) { return(new ObservableList <TreeNode <T> >()); } return(Utilites.CreateList <TreeNode <T> >(config[start], i => { var item_name = namePrefix + i; var item = GenerateItem(name, i); var nodes = config.Count > (start + 1) ? GenerateNodes(config, item_name + " - ", start + 1) : null; return new TreeNode <T>(item, nodes, true); })); }
/// <summary> /// Start this instance. /// </summary> protected virtual void Start() { OriginalItems = Utilites.CreateList(40, x => { return(new TileViewItemSample() { Name = "Tile " + x, Capital = string.Empty, Area = Random.Range(10, 10 * 6), Population = Random.Range(100, 100 * 6), }); }); OriginalItems.OnChange += ReorderItems; SizeChanged(); var listener = Utilites.GetOrAddComponent <ResizeListener>(Tiles.ScrollRect); listener.OnResize.AddListener(SizeChanged); }
/// <summary> /// Set new list to ListView with specified items count. /// </summary> /// <param name="n">Items count.</param> public void TestN(int n) { ListView.DataSource = Utilites.CreateList(n, x => x.ToString("00000")); }