/// <summary>
 /// Set ListView DataSource.
 /// </summary>
 public void SetList()
 {
     ListView.DataSource = Utilites.CreateList(100, x => new ListViewSliderItem()
     {
         Value = Random.Range(0, 100)
     });
 }
Esempio n. 2
0
 /// <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"),
     });
 }
Esempio n. 3
0
        /// <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,
            });
        }
Esempio n. 5
0
        /// <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);
            }));
        }
Esempio n. 6
0
        /// <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);
        }
Esempio n. 7
0
        /// <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),
                });
            });
        }
Esempio n. 9
0
        /// <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);
            }));
        }
Esempio n. 10
0
        /// <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);
        }
Esempio n. 11
0
 /// <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"));
 }