Exemplo n.º 1
0
        List <int> NewSelectedIndicies(IList <string> newItems)
        {
            var selected_indicies = new List <int>();

            if (newItems.Count == 0)
            {
                return(selected_indicies);
            }

            //duplicated items should not be selected more than at start
            var new_items_copy = new List <string>(newItems);

            var selected_items = SelectedIndicies.Select(x => strings[x]).ToList();

            selected_items = selected_items.Where(x => {
                var is_valid_item = newItems.Contains(x);
                if (is_valid_item)
                {
                    new_items_copy.Remove(x);
                }
                return(is_valid_item);
            }).ToList();

            newItems.ForEach((item, index) => {
                if (selected_items.Contains(item))
                {
                    selected_items.Remove(item);
                    selected_indicies.Add(index);
                }
            });

            return(selected_indicies);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the items.
        /// </summary>
        /// <param name="newItems">New items.</param>
        void UpdateItems(List <GameObject> newItems)
        {
            RemoveCallbacks();

            newItems = SortItems(newItems);

            var new_selected_indicies = SelectedIndicies
                                        .Select(x => objects.Count > x ? newItems.IndexOf(objects[x]) : -1)
                                        .Where(x => x != -1).ToList();

            SelectedIndicies.Except(new_selected_indicies).ForEach(Deselect);

            objects    = newItems;
            base.Items = newItems.Convert(x => x.GetComponent <ListViewItem>() ?? x.AddComponent <ListViewItem>());

            SelectedIndicies = new_selected_indicies;

            AddCallbacks();
        }