Beispiel #1
0
        private void LazyLoadItems(List items)
        {
            _data = new IdleData();

            _data.Items     = items;
            _data.NumItems  = 0;
            _data.NumLoaded = 0;
            _data.ListStore = _store;
            _data.LoadState = Controls.State.Started;
            _data.LoadId    = Idle.Add(new IdleHandler(LoadItems));
        }
Beispiel #2
0
        private bool LoadItems()
        {
            IdleData id = _data;
            CellBase obj;
            TreeIter iter;

            // Make sure we're in the right state
            var isLoading = (id.LoadState == Controls.State.Started) ||
                            (id.LoadState == Controls.State.Loading);

            if (!isLoading)
            {
                id.LoadState = Controls.State.Completed;
                return(false);
            }

            // No items
            if (id.Items.Count == 0)
            {
                id.LoadState = Controls.State.Completed;
                return(false);
            }

            // First run
            if (id.NumItems == 0)
            {
                id.NumItems  = id.Items.Count;
                id.NumLoaded = 0;
                id.LoadState = Controls.State.Loading;
            }

            // Get the item in the list at pos n_loaded
            obj = id.Items[id.NumLoaded] as CellBase;

            // Append the row to the store
            iter = id.ListStore.AppendValues(obj);

            // Fill in the row at position n_loaded
            id.ListStore.SetValue(iter, 0, obj);

            id.NumLoaded += 1;

            // Update UI with every item
            UpdateItem(obj);

            // We loaded everything, so we can change state and remove the idle callback function
            if (id.NumLoaded == id.NumItems)
            {
                id.LoadState = Controls.State.Completed;
                id.NumLoaded = 0;
                id.NumItems  = 0;
                id.Items     = null;

                CleanupLoadItems();

                return(false);
            }
            else
            {
                return(true);
            }
        }