Example #1
0
        public void UpdateControlViews(IEnumerable <IControlView> controlViews)
        {
            listView.BeginUpdate();
            listView.Items.Clear();
            listView.Groups.Clear();
            foreach (IControlView controlView in controlViews)
            {
                ListViewItem item = ControlViewMapper.ToListViewItem(controlView);

                if (item.Group != null)
                {
                    ListViewGroup existingGroup = null;
                    foreach (ListViewGroup group in listView.Groups)
                    {
                        if (group.Header == item.Group.Header)
                        {
                            existingGroup = group;
                        }
                    }

                    if (existingGroup != null)
                    {
                        item.Group = existingGroup;
                    }
                    else
                    {
                        listView.Groups.Add(item.Group);
                    }
                }
                listView.Items.Add(item);
            }
            listView.EndUpdate();

            ListViewSelectedIndexChanged();
        }
Example #2
0
        private void ListViewSelectedIndexChanged()
        {
            UpdateUI();

            var controlViews = new List <IControlView>(listView.SelectedItems.Count);

            foreach (ListViewItem item in listView.SelectedItems)
            {
                controlViews.Add(ControlViewMapper.FromListViewItem(item));
            }
            UpdateSelectedControlViews(controlViews);
        }