Exemple #1
0
        public void Add(AccListItem item)
        {
            if (Size.Width != ITEM_WIDTH)
            {
                Size = new Size(ITEM_WIDTH, 0);
            }

            // Max visible size
            Size = new Size(Size.Width, MaximumHeight);

            // Full size
            this.AutoScrollMinSize = new Size(Size.Width, (Items.Count + 1) * ITEM_HEIGHT);
            Items.Add(item);
        }
Exemple #2
0
        /*
         *   Size = new System.Drawing.Size(280, 54);
         *  accFont = new Font("Segoe UI Semibold", 13f);
         *  rankFont = new Font("Segoe UI", 10f);
         *  regionFont = new Font("Segoe UI", 8f);
         */
        protected override void OnPaint(PaintEventArgs e)
        {
            // Clear
            e.Graphics.Clear(Color.FromArgb(249, 249, 249));

            e.Graphics.TranslateTransform(this.AutoScrollPosition.X,
                                          this.AutoScrollPosition.Y);

            for (int i = 0; i < Items.Count; i++)
            {
                AccListItem item = Items[i];

                if (hoveredItem == i)
                {
                    e.Graphics.FillRectangle(Brushes.LightGray, 0, i * ITEM_HEIGHT, ITEM_WIDTH, ITEM_HEIGHT);
                }

                // Border
                e.Graphics.DrawLine(Pens.LightGray, 0, (i + 1) * ITEM_HEIGHT - 1, Width, (i + 1) * ITEM_HEIGHT - 1);

                // Draw Icon (35,40)
                // 10, 5, 35, 40
                if (item.RankImage != null)
                {
                    e.Graphics.DrawImage(item.RankImage, 10, i * ITEM_HEIGHT + 8, 35, 40);
                }

                // Draw account name
                e.Graphics.DrawString(item.Nickname, accFont, Brushes.Black, 52, i * ITEM_HEIGHT + 6);

                // Draw rank
                e.Graphics.DrawString(item.RankText, rankFont, Brushes.DimGray, 53, i * ITEM_HEIGHT + 27);

                // Draw region
                SizeF size         = e.Graphics.MeasureString(item.Region, regionFont);
                int   scrollOffset = this.VerticalScroll.Visible ? 30 : 0;
                e.Graphics.DrawString(item.Region, regionFont, Brushes.DarkGray, ITEM_WIDTH - size.Width - 1 - scrollOffset, (i + 1) * ITEM_HEIGHT - 16);

                // e.Graphics.DrawString(x + " " + y, regionFont, Brushes.Red, 0,0);
            }

            base.OnPaint(e);
        }