Example #1
0
        private void ComptuteDisplayIndex()
        {
            Dictionary <TType, int> objTTypeIndexDictionary = new Dictionary <TType, int>();
            List <TType>            objTTypeList            = new List <TType>();

            for (int i = 0; i < _contentList.Count; i++)
            {
                ControlWithMetaData objLoopControl = _contentList[i];
                if (objLoopControl.Visible)
                {
                    objTTypeIndexDictionary.Add(objLoopControl.Item, i);
                    objTTypeList.Add(objLoopControl.Item);
                }
            }

            objTTypeList.Sort(_comparison);

            _displayIndex.Clear();
            foreach (TType objLoopTType in objTTypeList)
            {
                _displayIndex.Add(objTTypeIndexDictionary[objLoopTType]);
            }

            if (_rendered == null || _rendered.Length != _displayIndex.Count)
            {
                _rendered = new BitArray(_displayIndex.Count);
            }
            else
            {
                _rendered.SetAll(false);
            }
        }
Example #2
0
        private void LoadRange(int min, int max)
        {
            min = Math.Max(0, min);
            max = Math.Min(_displayIndex.Count, max);
            if (_rendered.FirstMatching(false, min) > max)
            {
                return;
            }

            pnlDisplay.SuspendLayout();

            for (int i = min; i < max; i++)
            {
                if (_rendered[i])
                {
                    continue;
                }

                ControlWithMetaData item = _contentList[_displayIndex[i]];

                item.Control.Location = new Point(0, i * _contentList[0].Control.Height);
                item.Control.Visible  = true;

                _rendered[i] = true;
            }

            pnlDisplay.ResumeLayout();
        }
Example #3
0
        public BindingListDisplay(BindingList <TType> contents, Func <TType, Control> funcCreateControl, bool blnLoadVisibleOnly = true)
        {
            InitializeComponent();
            Contents            = contents ?? throw new ArgumentNullException(nameof(contents));
            _funcCreateControl  = funcCreateControl;
            _blnLoadVisibleOnly = blnLoadVisibleOnly;
            DisplayPanel.SuspendLayout();
            try
            {
                int intMaxControlHeight = 0;
                foreach (TType objLoopTType in Contents)
                {
                    ControlWithMetaData objNewControl = new ControlWithMetaData(objLoopTType, this, false);
                    intMaxControlHeight = Math.Max(objNewControl.Control.PreferredSize.Height, intMaxControlHeight);
                    _lstContentList.Add(objNewControl);
                }

                if (intMaxControlHeight > 0)
                {
                    ListItemControlHeight = intMaxControlHeight;
                }

                DisplayPanel.Controls.AddRange(_lstContentList.Select(x => x.Control).ToArray());
                _indexComparer        = new IndexComparer(Contents);
                _comparison           = _comparison ?? _indexComparer;
                Contents.ListChanged += ContentsChanged;
                ComputeDisplayIndex();
                LoadScreenContent();
                BindingListDisplay_SizeChanged(null, null);
            }
            finally
            {
                _blnIsTopmostSuspendLayout = true;
                DisplayPanel.ResumeLayout();
            }
        }