コード例 #1
0
        /// <summary>
        /// Update the on screen representation to match
        /// up with the current state of it's text queue.
        /// </summary>
        public void DataBind()
        {
            //Find the difference
            int diff = activeLabels.Count - items.Count;

            //Sync up labels to items count
            while (diff != 0)
            {
                if (diff < 0)
                {
                    activeLabels.Add(labelPool.GetInstance());
                    diff++;
                }
                else if (diff > 0)
                {
                    int    lastIndex = activeLabels.Count - 1;
                    ILabel label     = activeLabels[lastIndex];
                    activeLabels.RemoveAt(lastIndex);

                    labelPool.ReturnInstance(label);
                    diff--;
                }
            }

            string[] itemArray = items.ToArray();
            //Set their values
            for (int i = 0; i < itemArray.Length; i++)
            {
                activeLabels[i].Text = itemArray[i];
            }

            ScrollToBottom();
        }