Exemple #1
0
        public void AddRange(ShengListViewItemCollection value)
        {
            _owner.SuspendLayout();

            for (int i = 0; (i < value.Count); i = (i + 1))
            {
                this.Add(value[i]);
            }

            _owner.ResumeLayout(true);
        }
Exemple #2
0
        /// <summary>
        /// 根据矩形区域选择项
        /// </summary>
        /// <param name="rect"></param>
        private void SelectItemsByRectangle(Rectangle rect)
        {
            int viewOffset = _itemsAreaOffset;

            Point pt1 = new Point(SelectionRectangle.Left, SelectionRectangle.Top);
            Point pt2 = new Point(SelectionRectangle.Right, SelectionRectangle.Bottom);

            //- ItemsArea.Y 和 - ItemsArea.X
            //是因为,选择框的是以整个控件可视区域为坐标系的,而绘制的项是在Padding区内的
            //那么就需要修正或者说同步这个偏差,才能得到正确的行列
            int startRow = (int)Math.Floor((float)(Math.Min(pt1.Y, pt2.Y) + viewOffset - ItemsArea.Y) /
                                           (float)this._itemHeightWithMargin);
            int endRow = (int)Math.Floor((float)(Math.Max(pt1.Y, pt2.Y) + viewOffset - ItemsArea.Y) /
                                         (float)this._itemHeightWithMargin);
            //int startCol = (int)Math.Floor((float)(Math.Min(pt1.X, pt2.X) - ItemsArea.X) /
            //    (float)this._itemSizeWithMargin.Width);
            //int endCol = (int)Math.Floor((float)(Math.Max(pt1.X, pt2.X) - ItemsArea.X) /
            //    (float)this._itemSizeWithMargin.Width);

            //行不能这样判断,因为_rowCount表示的只是控件可视范围内的可视行数
            //在框选时,框会跨越可视区域的,这里的endRow要的是实际的项所在行数
            //列不存在这个问题,因为不支持水平滚动
            //if (endRow >= _rowCount)
            //    endRow = _rowCount -1;
            //if (endCol >= _columnCount)
            //    endCol = _columnCount - 1;
            //if (startCol < 0)
            //    startCol = 0;

            //创建一个应该被选定的项的index数组
            int        itemsCount       = _imageListView.Items.Count;
            List <int> selectItemsIndex = new List <int>();

            for (int i = startRow; i <= endRow; i++)
            {
                int index = i;
                if (index >= 0 && index < itemsCount)
                {
                    selectItemsIndex.Add(index);
                }

                //for (int j = startCol; j <= endCol; j++)
                //{
                //    int index = i * _columnCount + j;
                //    if (index >= 0 && index < itemsCount)
                //        selectItemsIndex.Add(index);
                //}
            }

            //如果当前没有按下Shift键,那么
            //判断当前选定的项中有没有不在框选区内的,如果有将其取消选定
            if (ShiftKey == false)
            {
                List <ShengListViewItem> currentSlectedItems = _imageListView.GetSelectedItems();
                foreach (var item in currentSlectedItems)
                {
                    if (selectItemsIndex.Contains(item.Index) == false)
                    {
                        item.Selected = false;
                    }
                }
            }

            ShengListViewItemCollection allItems = _imageListView.Items;

            //使框选区内的项都处于选中状态
            foreach (var index in selectItemsIndex)
            {
                if (allItems[index].Selected == false)
                {
                    allItems[index].Selected = true;
                }
            }

            //debug
            StartRow = startRow;
            EndRow   = endRow;
            //StartCol = startCol;
            //EndCol = endCol;
        }
Exemple #3
0
 public ImageListViewItemEnumerator(ShengListViewItemCollection mappings)
 {
     this.temp           = ((IEnumerable)(mappings));
     this.baseEnumerator = temp.GetEnumerator();
 }
Exemple #4
0
 public ShengListViewItemCollection(ShengListViewItemCollection value)
 {
     this.AddRange(value);
 }