Exemplo n.º 1
0
        /// <summary>
        /// 将某一项移动到最顶端
        /// </summary>
        /// <param name="index"></param>
        public void MoveItemToTop(int index)
        {
            if (index <= 0)
            {
                return;
            }

            if (ufiUserControls.Count <= index)
            {
                return;
            }

            if (ufiUserControls.Count <= 1)
            {
                return;
            }

            UserFriendItemUserControl ufiItem = ufiUserControls[index];

            ufiUserControls.RemoveAt(index);
            ufiUserControls.Insert(0, ufiItem);

            dataIsChange = true;

            this.RedrawItemsView();
        }
Exemplo n.º 2
0
        /// <summary>
        /// 添加内容项
        /// </summary>
        /// <param name="item"></param>
        /// <param name="isRedrawView">是否立即刷新界面</param>
        public void Add(UserFriendItemUserControl item, bool isRedrawView = true)
        {
            ufiUserControls.Add(item);
            dataIsChange = true;

            item.Click += item_Click;

            if (isRedrawView)
            {
                this.RedrawItemsView();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 重绘界面
        /// </summary>
        public void RedrawItemsView()
        {
            do
            {
                if (!dataIsChange)
                {
                    break;
                }

                lock (this)
                {
                    dataIsChange = false;

                    panel_box.Controls.Clear();

                    UserFriendItemUserControl[] items = ufiUserControls.ToArray();

                    Size _size = panel_box.Size;
                    _size.Height = items.Length * itemHeight;
                    bool isScroll = _size.Height > this.Height;
                    _size.Width = isScroll ? this.Width - 10 : this.Width;

                    if (isScroll)
                    {
                        vScrollBar_box.Show();
                    }
                    else
                    {
                        vScrollBar_box.Hide();
                    }
                    if (isScroll)
                    {
                        vScrollBar_box.Maximum = (_size.Height - this.Size.Height) / 5 + vScrollBar_box.LargeChange;
                    }

                    panel_box.Size = _size;

                    if (items.Length == 0)
                    {
                        break;
                    }

                    for (int i = 0; i < items.Length; i++)
                    {
                        UserFriendItemUserControl item = items[i];
                        item.Location = new Point(0, i * itemHeight);
                        item.Size     = new Size(panel_box.Width, itemHeight);
                        item.Index    = i;
                        panel_box.Controls.Add(item);
                    }
                }
            } while (false);
        }
Exemplo n.º 4
0
        private void RedrawViewByUserInfoModels(IEnumerable <UserInfoModel> items)
        {
            this.userFriendsListViewUserControl_friendList.RemoveAll(false);

            foreach (UserInfoModel item in items)
            {
                UserFriendItemUserControl ufiuc = new UserFriendItemUserControl();
                ufiuc.label_NickName.Text = item.NickName;
                this.userFriendsListViewUserControl_friendList.Add(ufiuc, false);
            }

            this.userFriendsListViewUserControl_friendList.RedrawItemsView();
        }