Example #1
0
        /// <summary>
        /// Add an item to the combo box.
        /// </summary>
        /// <param name="value">ConfigText of the item.</param>
        /// <param name="imagePath">Optional image to load.</param>
        public void AddItem(string value, string imagePath)
        {
            var item = new ListBoxItem(value, value)
                           {
                               ImagePath = imagePath
                           };

            this.DropDownList.AddListItem(item);
        }
Example #2
0
        /// <summary>
        /// Removes the given list item from my list.
        /// </summary>
        /// <param name="item">The item.</param>
        public void RemoveListItem(ListBoxItem item)
        {
            var removedItem = false;
            foreach (var cmbItem in this.ListBoxItems)
            {
                if (cmbItem == item)
                {
                    this.Children.Remove(cmbItem);

                    // Ensure scrollbar uses relevant scroll area
                    this.totalListHeight -= (int)(cmbItem.State.Height + DefaultLineSpacing);
                    if (this.totalListHeight < (this.State.Height - DefaultLineSpacing))
                    {
                        this.scrollBarVertical.Config.Visible = false;
                    }

                    this.ScaleScrollBar();

                    removedItem = true;
                    break;
                }
            }

            if (removedItem)
            {
                this.ListBoxItems.Remove(item);
                this.RefreshAllListBoxSizes();
            }
        }
Example #3
0
        /// <summary>
        /// Refresh the X size based on whether the vertical scrollbar is visible
        /// </summary>
        /// <param name="item">The item to resize.</param>
        private void RefreshListBoxItemSize(ListBoxItem item)
        {
            DVector2 size;
            if (this.scrollBarVertical.Config.Visible)
            {
                size = new DVector2(
                                    this.Config.Width - (2f * this.Theme.ControlLargeSpacing) - this.scrollBarVertical.Config.Width, 
                                    item.Config.Height);
            }
            else
            {
                size = new DVector2(
                                    this.Config.Width - (2f * this.Theme.ControlLargeSpacing), 
                                    item.Config.Height);
            }

            item.State.Width = size.X;
            item.State.Height = size.Y;
        }
Example #4
0
        /// <summary>Adds a list-box-item to me,</summary>
        /// <param name="listBoxItem">The list box item.</param>
        /// <exception cref="System.ArgumentNullException">ListBoxItem is null.</exception>
        public void AddListItem(ListBoxItem listBoxItem)
        {
#if DEBUG
            if (listBoxItem == null)
            {
                throw new ArgumentNullException("listBoxItem");
            }
#endif
            // get where to place the next item
            var currentY = this.CalculateTotalListHeight();
            var newY = currentY + this.Theme.ControlLargeSpacing;
            var newWidth = this.Config.Width - (this.Theme.ControlLargeSpacing * 2);

            this.AddControl(listBoxItem);
            this.ListBoxItems.Add(listBoxItem);
            listBoxItem.Theme = this.Theme;
            listBoxItem.Config.Visible = false;
            listBoxItem.Config.PositionX = this.Theme.ControlLargeSpacing;
            listBoxItem.Config.PositionY = newY;
            listBoxItem.Config.Width = newWidth;
            listBoxItem.Config.Visible = true;

            // Ensure scrollbar uses relevant scroll area
            this.mustRedrawVerticalScrollBar = true;

            listBoxItem.ItemPressed += this.OnSelect;
        }