Example #1
0
        /// <summary>
        ///     Adds a text to the list.
        /// </summary>
        /// <param name="text"></param>
        public void addItem(string text)
        {
            listItemGroup newItem = new listItemGroup();

            newItem.columns.Add(new listItem(text));
            addItem(newItem);
        }
Example #2
0
        /// <summary>
        ///     Adds a item to the list.
        /// </summary>
        /// <param name="item"></param>
        public void addItem(listItem item)
        {
            listItemGroup newItem = new listItemGroup();

            newItem.columns.Add(item);
            addItem(newItem);
        }
Example #3
0
 /// <summary>
 ///     Adds a item to the list. At least one column is necessary.
 /// </summary>
 /// <param name="item">The item with one or more columns</param>
 public void addItem(listItemGroup item, bool refresh = true)
 {
     list.Add(item);
     if (refresh)
     {
         recalcScroll();
     }
 }
Example #4
0
 /// <summary>
 ///     Changes the Item at the given Index.
 /// </summary>
 /// <param name="index">Index number of the item</param>
 /// <param name="newText">New item</param>
 public void changeItem(int index, listItemGroup newItem)
 {
     if (index >= list.Count || index < 0)
     {
         return;
     }
     list.RemoveAt(index);
     list.Insert(index, newItem);
     Refresh();
 }
Example #5
0
        /// <summary>
        ///     Changes the Text of a Item at the given Index.
        /// </summary>
        /// <param name="index">Index number of the item</param>
        /// <param name="newText">New text</param>
        public void changeItem(int index, string newText)
        {
            if (index >= list.Count || index < 0)
            {
                return;
            }
            listItemGroup item = list[index];

            list.RemoveAt(index);
            item.columns[0].text = newText;
            list.Insert(index, item);
            Refresh();
        }
Example #6
0
 /// <summary>
 ///     Changes the Item at the given Index.
 /// </summary>
 /// <param name="index">Index number of the item</param>
 /// <param name="newText">New item</param>
 public void changeItem(int index, listItemGroup newItem)
 {
     if (index >= list.Count || index < 0) return;
     list.RemoveAt(index);
     list.Insert(index, newItem);
     Refresh();
 }
Example #7
0
 /// <summary>
 ///     Adds a text to the list.
 /// </summary>
 /// <param name="text"></param>
 public void addItem(string text)
 {
     listItemGroup newItem = new listItemGroup();
     newItem.columns.Add(new listItem(text));
     addItem(newItem);
 }
Example #8
0
 /// <summary>
 ///     Adds a item to the list.
 /// </summary>
 /// <param name="item"></param>
 public void addItem(listItem item)
 {
     listItemGroup newItem = new listItemGroup();
     newItem.columns.Add(item);
     addItem(newItem);
 }
Example #9
0
 /// <summary>
 ///     Adds a item to the list. At least one column is necessary.
 /// </summary>
 /// <param name="item">The item with one or more columns</param>
 public void addItem(listItemGroup item)
 {
     list.Add(item);
     recalcScroll();
 }
Example #10
0
        protected override void OnPaint(PaintEventArgs e)
        {
            int totalSize = (list.Count * tileSize) + (showHeader ? headerSize : 0);
            int startY    = 0;

            if (totalSize > Height)
            {
                startY = -ListScroll.Value;
            }
            int index = 0;

            //Renderiza a parte do Header
            int i = 0;

            if (showHeader)
            {
                int columnX = 0;

                foreach (columnHeader header in columns)
                {
                    int columnWidth;
                    if (i == columns.Count - 1)
                    {
                        columnWidth = Width - columnX;
                    }
                    else
                    {
                        columnWidth = header.width;
                    }
                    if (columnWidth < 2)
                    {
                        break;
                    }

                    Rectangle rect = new Rectangle(columnX, startY, columnWidth - 1, headerSize);
                    e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(0x1f, Color.White)), rect);

                    Font   font         = new Font(Font.FontFamily, Font.Size, FontStyle.Bold);
                    int    textHeight   = (int)e.Graphics.MeasureString(header.text, font).Height;
                    string text         = DrawingUtils.clampText(e.Graphics, header.text, font, columnWidth);
                    Point  textLocation = new Point(columnX, startY + ((headerSize / 2) - (textHeight / 2)));
                    e.Graphics.DrawString(text, font, new SolidBrush(ForeColor), textLocation);
                    font.Dispose();

                    columnX += columnWidth;
                    i++;
                }

                startY += headerSize;
            }

            //Renderiza os itens da lista
            for (int j = 0; j < list.Count; j++)
            {
                listItemGroup item = list[j];

                if (startY >= -tileSize)
                {
                    if (startY > Height)
                    {
                        break;
                    }

                    Rectangle itemRect = new Rectangle(0, startY, Width, tileSize);

                    //Selecionado
                    if (clicked)
                    {
                        if (itemRect.Contains(mousePosition))
                        {
                            e.Graphics.FillRectangle(new SolidBrush(selectedColor), itemRect);
                            selectedIndex = index;
                            if (selectedIndex != oldIndex && SelectedIndexChanged != null)
                            {
                                SelectedIndexChanged(this, EventArgs.Empty);
                            }
                            oldIndex = selectedIndex;
                            clicked  = false;
                        }
                    }
                    else
                    {
                        if (index == selectedIndex)
                        {
                            e.Graphics.FillRectangle(new SolidBrush(selectedColor), itemRect);
                        }
                    }

                    //Textos e afins
                    i = 0;
                    int x = 0;
                    foreach (listItem subItem in item.columns)
                    {
                        int columnWidth;
                        if (i == columns.Count - 1 || columns.Count == 0)
                        {
                            columnWidth = Width - x;
                        }
                        else
                        {
                            columnWidth = columns[i].width;
                        }

                        if (columnWidth < 1)
                        {
                            break;
                        }

                        if (subItem.thumbnail != null)
                        {
                            float     ar = (float)subItem.thumbnail.Width / subItem.thumbnail.Height;
                            int       w  = (int)(tileSize * ar);
                            int       h  = (int)(columnWidth / ar);
                            Rectangle dst;
                            if (w > columnWidth)
                            {
                                dst = new Rectangle(x, startY + ((tileSize / 2) - (h / 2)), columnWidth, h);
                            }
                            else
                            {
                                dst = new Rectangle(x + ((columnWidth / 2) - (w / 2)), startY, w, tileSize);
                            }

                            Rectangle src = new Rectangle(0, 0, subItem.thumbnail.Width, subItem.thumbnail.Height);
                            e.Graphics.DrawImage(subItem.thumbnail, dst, src, GraphicsUnit.Pixel);
                        }

                        int    textHeight   = (int)e.Graphics.MeasureString(subItem.text, Font).Height;
                        string text         = DrawingUtils.clampText(e.Graphics, subItem.text, Font, columnWidth);
                        Point  textLocation = new Point(x, startY + ((tileSize / 2) - (textHeight / 2)));
                        e.Graphics.DrawString(text, Font, new SolidBrush(ForeColor), textLocation);

                        x += columnWidth;
                        i++;
                    }
                }

                startY += tileSize;
                index++;
            }

            if (clicked)
            {
                selectedIndex = -1;
                if (selectedIndex != oldIndex && SelectedIndexChanged != null)
                {
                    SelectedIndexChanged(this, EventArgs.Empty);
                }
                oldIndex = selectedIndex;
            }
            clicked = false;

            base.OnPaint(e);
        }
Example #11
0
 /// <summary>
 ///     Adds a item to the list. At least one column is necessary.
 /// </summary>
 /// <param name="item">The item with one or more columns</param>
 public void addItem(listItemGroup item)
 {
     list.Add(item);
     recalcScroll();
 }