Пример #1
0
    public void Test()
    {
        //Get last selected index
        Debug.Log(listViewIcons.SelectedIndex);

        //Get selected indicies
        var indicies = listViewIcons.SelectedIndicies;
        Debug.Log(string.Join(", ", indicies.ConvertAll(x => x.ToString()).ToArray()));

        //Get last selected string
        Debug.Log(listViewIcons.SelectedItem.Name);

        //Get selected strings
        var selected_items = listViewIcons.SelectedItems;
        Debug.Log(string.Join(", ", selected_items.ConvertAll(x => x.Name).ToArray()));

        //Deleting specified item
        var items = listViewIcons.Items;
        listViewIcons.Remove(items[0]);

        //Deleting item by index
        listViewIcons.Remove(0);

        //Clear List
        listViewIcons.Clear();

        //Add item
        var new_item = new ListViewIconsItemDescription() {
            Icon = sampleIcon,
            Name = "test item"
        };
        listViewIcons.Add(new_item);

        //Add items
        var new_items = new List<ListViewIconsItemDescription>() {
            new_item,
            new_item,
            new_item
        };
        new_items.AddRange(listViewIcons.Items);
        listViewIcons.Items = new_items;

        //Set selected index
        listViewIcons.SelectedIndex = 1;
        //or
        listViewIcons.Select(1);
    }
        /// <summary>
        /// Sets component data with specified item.
        /// </summary>
        /// <param name="item">Item.</param>
        public void SetData(ListViewIconsItemDescription item)
        {
            if (item==null)
            {
                Icon.sprite = null;
                Text.text = string.Empty;
            }
            else
            {
                Icon.sprite = item.Icon;
                Text.text = item.Name;
            }

            Icon.SetNativeSize();
            //set transparent color if no icon
            Icon.color = (Icon.sprite==null) ? new Color(0, 0, 0, 0) : Color.white;
        }
Пример #3
0
        /// <summary>
        /// Add items.
        /// </summary>
        public void AddItems()
        {
            var new_item = new ListViewIconsItemDescription()
            {
                Icon = SampleIcon,
                Name = "test item"
            };

            var new_items = new List <ListViewIconsItemDescription>()
            {
                new_item,
                new_item,
                new_item
            };

            ComboboxIcons.ListView.DataSource.AddRange(new_items);
        }
		/// <summary>
		/// Sets component data with specified item.
		/// </summary>
		/// <param name="item">Item.</param>
		public void SetData(ListViewIconsItemDescription item)
		{
			if (item==null)
			{
				Icon.sprite = null;
				Text.text = string.Empty;
			}
			else
			{
				Icon.sprite = item.Icon;
				Text.text = item.LocalizedName ?? item.Name;
			}

			if (SetNativeSize)
			{
				Icon.SetNativeSize();
			}

			//set transparent color if no icon
			Icon.color = (Icon.sprite==null) ? Color.clear : Color.white;
		}
 /// <summary>
 /// Set data.
 /// </summary>
 /// <param name="item">Item.</param>
 public override void SetData(ListViewIconsItemDescription item)
 {
     base.SetData(item);
     SetImageColor();
 }
Пример #6
0
 /// <summary>
 /// Set item.
 /// </summary>
 /// <param name="it">Item.</param>
 protected virtual void SetItem(ListViewIconsItemDescription it)
 {
     item = Autocomplete.TargetListView.DataSource[0];
     Autocomplete.TargetListView.DataSource.Clear();
 }
Пример #7
0
 /// <summary>
 /// Reset item.
 /// </summary>
 /// <param name="str">Input string.</param>
 protected virtual void ResetItem(string str)
 {
     item = null;
 }