Esempio n. 1
0
        /// <summary>
        /// Updates the items.
        /// </summary>
        /// <param name="newItems">New items.</param>
        void SetNewItems(ObservableList <string> newItems)
        {
            DataSource.OnChange -= UpdateItems;

            if (Sort && SortFunc != null)
            {
                newItems.BeginUpdate();

                var sorted = SortFunc(newItems).ToArray();

                newItems.Clear();
                newItems.AddRange(sorted);

                newItems.EndUpdate();
            }

            SilentDeselect(SelectedIndicies);
            var new_selected_indicies = SelectedItemsCache.Convert <string, int>(newItems.IndexOf);

            new_selected_indicies.RemoveAll(IndexNotFound);

            dataSource = newItems;

            SilentSelect(new_selected_indicies);
            SelectedItemsCache = SelectedIndicies.Convert <int, string>(GetDataItem);

            UpdateView();

            DataSource.OnChange += UpdateItems;
        }
Esempio n. 2
0
        /// <summary>
        /// Update data list.
        /// </summary>
        public void Update()
        {
            if (inUpdate)
            {
                isChanged = true;
                return;
            }

            if (Data == null)
            {
                return;
            }

            Data.BeginUpdate();

            Data.Clear();

            var groups = GroupsWithItems.Keys.ToList();

            if (GroupComparison != null)
            {
                groups.Sort(GroupComparison);
            }
            groups.ForEach(group => {
                Data.Add(group);
                Data.AddRange(GroupsWithItems[group]);
            });

            Data.EndUpdate();
        }
Esempio n. 3
0
        /// <summary>
        /// Insert groups with items to the Data list.
        /// </summary>
        protected virtual void InsertGroups()
        {
            var groups = new List <T>(GroupsWithItems.Keys);

            if (GroupComparison != null)
            {
                groups.Sort(GroupComparison);
            }

            groups.ForEach(group =>
            {
                Data.Add(group);

                for (var i = 1; i < ItemsPerBlock; i++)
                {
                    Data.Add(EmptyGroupItem);
                }

                var items = GroupsWithItems[group];
                Data.AddRange(items);

                if (ItemsPerBlock > 0)
                {
                    var n = items.Count % ItemsPerBlock;
                    if (n > 0)
                    {
                        for (var i = n; i < ItemsPerBlock; i++)
                        {
                            Data.Add(EmptyItem);
                        }
                    }
                }
            });
        }
Esempio n. 4
0
        /// <summary>
        /// Updates the items.
        /// </summary>
        /// <param name="newItems">New items.</param>
        protected virtual void SetNewItems(ObservableList <TItem> newItems)
        {
            //Start();

            DataSource.OnChange -= UpdateItems;

            if (Sort && SortFunc != null)
            {
                newItems.BeginUpdate();

                var sorted = SortFunc(newItems).ToArray();

                newItems.Clear();
                newItems.AddRange(sorted);

                newItems.EndUpdate();
            }

            SilentDeselect(SelectedIndicies);
            var new_selected_indicies = SelectedItemsCache.Convert <TItem, int>(newItems.IndexOf);

            new_selected_indicies.RemoveAll(IndexNotFound);

            dataSource = newItems;

            if (KeepSelection)
            {
                SilentSelect(new_selected_indicies);
            }
            SelectedItemsCache = SelectedItems;

            UpdateView();

            DataSource.OnChange += UpdateItems;
        }