public void OnAddNewItemButtonClicked()
        {
            this.itemAddedCount++;
            string name = "ADDED ITEM (" + this.itemAddedCount + ")";

            ListViewItem listViewItem = new ListViewItem(new string[] { name, "Item added", "ATK +1" });
            this.ListView.Items.Add(listViewItem);

            // Select the new item and scroll to it.
            this.ListView.SelectedIndices.Add(this.ListView.Items.Count - 1);
            this.ListView.SetVerticalScrollBarValue(1);
        }
 public ListViewSubItem(ListViewItem owner, string text)
 {
     this.owner = owner;
     this.text = text;
 }
        public object Clone()
        {
            ListViewItem clone = new ListViewItem();

            clone.owner = this.owner;
            clone.selected = this.selected;

            foreach (ListViewSubItem subItem in this.subItems)
            {
                ListViewSubItem newItem = new ListViewSubItem();
                newItem.ListViewItem = subItem.ListViewItem;
                newItem.Name = subItem.Name;
                newItem.Tag = subItem.Tag;
                newItem.Text = subItem.Text;
                clone.subItems.Add(newItem);
            }

            return clone;
        }
        private void SetAllSubItemsTextColor(ListViewItem item, Color color)
        {
            item.ForeColor = color;

            foreach (ListViewItem.ListViewSubItem subItem in item.SubItems)
            {
                subItem.ForeColor = color;
            }
        }
        private void SetAllSubItemsBackgroundColor(ListViewItem item, Color color)
        {
            item.BackColor = color;

            foreach (ListViewItem.ListViewSubItem subItem in item.SubItems)
            {
                subItem.BackColor = color;
            }
        }
        public void OnInsertItemAtCurrentPositionButtonClicked()
        {
            this.itemInsertedCount++;
            string name = "INSERTED ITEM (" + this.itemInsertedCount + ")";

            ListViewItem listViewItem = new ListViewItem(new string[] { name, "Item inserted", "ATK +1" });
            int selectedIndex = this.ListView.SelectedIndices[0];
            this.ListView.Items.Insert(selectedIndex, listViewItem);
        }
 public void Remove(ListViewItem.ListViewSubItem item)
 {
     this.RemoveInternal(item);
 }
 public int IndexOf(ListViewItem.ListViewSubItem subItem)
 {
     return this.subItems.IndexOf(subItem);
 }
        private void OnItemBecameVisible(ListViewItem item)
        {
            // Create a slider custom control and add it to the third subitem.
            var subItem = item.SubItems[2];
            GameObject slider = GameObject.Instantiate(this.SliderPrefab) as GameObject;
            subItem.CustomControl = slider.transform as RectTransform;

            ItemData itemData = item.Tag as ItemData;
            slider.GetComponentInChildren<Scrollbar>().value = itemData.SliderValue;
        }
        private void OnItemBecameInvisible(ListViewItem item)
        {
            var subItem = item.SubItems[2];
            GameObject slider = subItem.CustomControl.gameObject;

            // Save the value of the slider so that it can be restored
            // when the item becomes visible again.
            ItemData itemData = item.Tag as ItemData;
            itemData.SliderValue = slider.GetComponentInChildren<Scrollbar>().value;

            // Destroy the slider custom control.
            GameObject.Destroy(subItem.CustomControl.gameObject);
        }
        private ListViewItem CreateListViewItem(string imageKey, string shipSpecies, string shipName)
        {
            string[] subItemTexts = new string[]
            {
            shipSpecies,
            shipName,
            "slider"
            };

            ListViewItem item = new ListViewItem(subItemTexts);

            // Add an image to the first subitem.
            item.ImageKey = imageKey;
            ItemData itemData = new ItemData();
            itemData.ImageKey = imageKey;
            itemData.SliderValue = 0;
            item.Tag = itemData;

            // NOTE: Any custom controls to be added to the list view item
            // should be created in OnItemBecameVisible, and destroyed in
            // OnItemBecameInvisible. This is because the list view only
            // creates GameObjects to display the items that are visible,
            // rather than for every item in ListView.Items.

            return item;
        }
 private static float GetItemSliderValue(ListViewItem item)
 {
     RectTransform customControl = item.SubItems[2].CustomControl;
     if (customControl != null)
     {
         return customControl.gameObject.GetComponentInChildren<Scrollbar>().value;
     }
     else
     {
         return (item.Tag as ItemData).SliderValue;
     }
 }
 public void OnSubItemClicked(PointerEventData pointerEventData, ListViewItem.ListViewSubItem subItem)
 {
     //Debug.Log(pointerEventData.button);
 }
        private ListViewItem GetListViewItemFromStrings(string sender, string emailAddress, string subject)
        {
            int minsAgo = this.previousMinsAgo;

            this.previousMinsAgo += Random.Range(15, 30);

            string timeAgo = "";
            if (minsAgo < 1)
            {
                timeAgo = "< 1 min ago";
            }
            else if (minsAgo < 60)
            {
                timeAgo = string.Format("{0} min{1} ago", minsAgo, minsAgo == 1 ? "" : "s");
            }
            else
            {
                int hoursAgo = minsAgo / 60;
                timeAgo = string.Format("{0} hour{1} ago", hoursAgo, hoursAgo == 1 ? "" : "s");
            }

            int size = Random.Range(0f, 1f) < 0.75f ? Random.Range(2500, 100000) : Random.Range(1000000, 3000000);

            string[] subItemTexts = new string[]
            {
                string.Format("\"{0}\" <{1}>", sender, emailAddress),
                subject,
                timeAgo,
                GetPrettyFileSizeTextFromInteger(size)
            };

            ListViewItem item = new ListViewItem(subItemTexts);

            // Randomly make it unread.
            if (Random.Range(0f, 1f) < 0.20f)
            {
                item.FontStyle = FontStyle.Bold;
            }

            return item;
        }
 public ListViewSubItemCollection(ListViewItem owner)
 {
     this.owner = owner;
     this.subItems = new List<ListViewSubItem>();
 }
 public bool Contains(ListViewItem.ListViewSubItem subItem)
 {
     return this.subItems.Contains(subItem);
 }
 private int CompareSubItemsByText(ListViewItem.ListViewSubItem a, ListViewItem.ListViewSubItem b)
 {
     return string.Compare(a.Text, b.Text);
 }
            public void Insert(int index, ListViewItem.ListViewSubItem item)
            {
                if (index < this.subItems.Count)
                {
                    this.subItems.Insert(index, item);
                    item.ListViewItem = this.owner;

                    ListView owner = this.owner.owner;
                    if (owner != null)
                    {
                        owner.RebuildHierarchy();
                    }
                }
            }
 public void OnItemChanged(ListViewItem listViewItem)
 {
     //Debug.Log("Item text changed to: " + listViewItem.Text);
 }
 public ListViewItemMouseHoverEventArgs(ListViewItem item)
 {
     this.item = item;
 }
        private ListViewItem CreateListViewItemFromPlayerName(string playerName)
        {
            int level = Random.Range(30, 40);
            int score = this.previousScore;
            int timePlayedInMins = Random.Range(400, 800);
            int games = Random.Range(85, 120);
            int averageScore = score / games;
            int rank = this.previousRank;

            this.previousScore -= Random.Range(1, 1000);
            this.previousRank++;

            int timePlayedInHours = timePlayedInMins / 60;
            int timePlayedInMinsMod = timePlayedInMins % 60;

            string timePlayedString = string.Format("{0:00}h {1:00}m", timePlayedInHours, timePlayedInMinsMod);

            string[] subItemTexts = new string[]
            {
            rank.ToString(),
            level.ToString(),
            playerName,
            score.ToString(),
            timePlayedString,
            games.ToString(),
            averageScore.ToString()
            };

            ListViewItem item = new ListViewItem(subItemTexts);
            return item;
        }