예제 #1
0
        public void AddNewListBoxItem(Texture2D texture, string text)
        {
            int index = ListBoxItems.Count();

            int       imageX      = base.Bounds.X + this.ItemPadding;
            int       imageY      = base.Bounds.Y + this.ItemPadding + (index * this.ItemHeight);
            int       imageWidth  = this.ItemHeight - this.ItemPadding;
            Rectangle imageBounds = new Rectangle(imageX, imageY, imageWidth, imageWidth);
            Image     image       = new Image(texture, imageBounds, Color.White);

            int       parentX      = imageX + this.ItemPadding;
            int       parentY      = imageY;
            int       labelWidth   = base.Bounds.Width - imageWidth - (this.ItemPadding * 3);
            int       labelHeight  = this.ItemHeight;
            Rectangle parentBounds = new Rectangle(parentX, parentY, labelWidth, labelHeight);
            Label     label        = new Label(parentBounds, Statics.Arial_8, text, Color.Black);

            int         itemX             = this.Bounds.X;
            int         itemY             = this.Bounds.Y + (this.ItemHeight * index);
            int         itemWidth         = this.Bounds.Width;
            int         itemHeight        = this.ItemHeight;
            Rectangle   listBoxItemBounds = new Rectangle(itemX, itemY, itemWidth, ItemHeight);
            ListBoxItem listBoxItem       = new ListBoxItem(image, label, listBoxItemBounds);

            listBoxItem.leftMouseButtonReleased += listBoxItem_clicked;

            this.ListBoxItems.Add(listBoxItem);
        }