예제 #1
0
        /// <summary>
        /// Updates the UI for a counter.
        /// </summary>
        /// <param name="counter"></param>
        private void UpdateCounter(IStatsCounter counter)
        {
            ListView view;

            // Figure out which list this counter goes into.
            if (counter is StatsCounterRate)
            {
                view = listViewRates;
            }
            else if (counter is StatsCounter || counter is StatsTimer)
            {
                view = listViewCounters;
            }
            else
            {
                return; // Counter type not supported yet.
            }
            // See if the counter is already in the list.
            ListViewItem item = view.Items[counter.name];

            if (item != null)
            {
                // Update an existing counter.
                Debug.Assert(item is StatsCounterListViewItem);
                StatsCounterListViewItem counter_item = item as StatsCounterListViewItem;
                counter_item.Update(counter, filter_pid_);
            }
            else
            {
                // Create a new counter
                StatsCounterListViewItem new_item = null;
                if (counter is StatsCounterRate)
                {
                    new_item = new RateListViewItem(counter, filter_pid_);
                }
                else if (counter is StatsCounter || counter is StatsTimer)
                {
                    new_item = new CounterListViewItem(counter, filter_pid_);
                }
                Debug.Assert(new_item != null);
                view.Items.Add(new_item);
            }
        }
예제 #2
0
        /// <summary>
        /// Updates the UI for a counter.
        /// </summary>
        /// <param name="counter"></param>
        private void UpdateCounter(IStatsCounter counter)
        {
            ListView view;

              // Figure out which list this counter goes into.
              if (counter is StatsCounterRate)
            view = listViewRates;
              else if (counter is StatsCounter || counter is StatsTimer)
            view = listViewCounters;
              else
            return; // Counter type not supported yet.

              // See if the counter is already in the list.
              ListViewItem item = view.Items[counter.name];
              if (item != null)
              {
            // Update an existing counter.
            Debug.Assert(item is StatsCounterListViewItem);
            StatsCounterListViewItem counter_item = item as StatsCounterListViewItem;
            counter_item.Update(counter, filter_pid_);
              }
              else
              {
            // Create a new counter
            StatsCounterListViewItem new_item = null;
            if (counter is StatsCounterRate)
              new_item = new RateListViewItem(counter, filter_pid_);
            else if (counter is StatsCounter || counter is StatsTimer)
              new_item = new CounterListViewItem(counter, filter_pid_);
            Debug.Assert(new_item != null);
            view.Items.Add(new_item);
              }
        }