Beispiel #1
0
        private void ListBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (!handleSelectedIndexChanged)
            {
                return;
            }

            handleSelectedIndexChanged = false;

            XNAListBox lbSender = (XNAListBox)sender;

            foreach (XNAListBox lb in listBoxes)
            {
                lb.SelectedIndex = lbSender.SelectedIndex;
            }

            SelectedIndex = lbSender.SelectedIndex;

            if (SelectedIndexChanged != null)
            {
                SelectedIndexChanged(this, EventArgs.Empty);
            }

            handleSelectedIndexChanged = true;
        }
Beispiel #2
0
        /// <summary>
        /// Creates a column with the given header and list box.
        /// </summary>
        /// <param name="header">The header panel.</param>
        /// <param name="listBox">The list box.</param>
        public void AddColumn(XNAPanel header, XNAListBox listBox)
        {
            AdjustExistingListBoxes();

            int width = GetExistingWidth();

            header.ClientRectangle = new Rectangle(width, 0, header.Width, header.Height);

            headers.Add(header);

            listBox.Name            = Name + "_lb" + listBoxes.Count;
            listBox.ClientRectangle = new Rectangle(width, header.Bottom - 1,
                                                    header.Width, Height - header.Bottom + 1);
            listBox.DrawBorders             = DrawListBoxBorders;
            listBox.LineHeight              = LineHeight;
            listBox.TopIndexChanged        += ListBox_TopIndexChanged;
            listBox.SelectedIndexChanged   += ListBox_SelectedIndexChanged;
            listBox.AllowMultiLineItems     = false;
            listBox.AllowKeyboardInput      = this.AllowKeyboardInput;
            listBox.AllowRightClickUnselect = AllowRightClickUnselect;
            listBox.RightClick             += ListBox_RightClick;

            listBoxes.Add(listBox);
            AddChild(listBox);
            AddChild(header);
        }
Beispiel #3
0
        /// <summary>
        /// Creates a column with the given header and an automatically generated list box.
        /// The width of the header defines the width of the list box.
        /// </summary>
        /// <param name="header">The header panel.</param>
        public void AddColumn(XNAPanel header)
        {
            XNAListBox listBox = new XNAListBox(WindowManager);

            listBox.FontIndex          = FontIndex;
            listBox.TextBorderDistance = 5;

            AddColumn(header, listBox);
        }
Beispiel #4
0
        private void AdjustExistingListBoxes()
        {
            if (listBoxes.Count > 0)
            {
                XNAListBox lb = listBoxes[listBoxes.Count - 1];
                lb.EnableScrollbar = false;

                if (DrawListBoxBorders)
                {
                    lb.Width++;
                    headers[headers.Count - 1].Width++;
                }
                else
                {
                    lb.Width += 2;
                }
            }
        }
Beispiel #5
0
        /// <summary>
        /// Adjusts the positions and sizes of the columns
        /// when the size of the list box is changed.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void XNAMultiColumnListBox_ClientRectangleUpdated(object sender, EventArgs e)
        {
            if (listBoxes.Count == 0)
            {
                return;
            }

            // Adjust size of columns

            foreach (XNAListBox lb in listBoxes)
            {
                lb.Height = Height - lb.Y;
            }

            XNAListBox lastListBox = listBoxes[listBoxes.Count - 1];
            XNAPanel   lastHeader  = headers[headers.Count - 1];

            int lastColumnWidth = Width -
                                  listBoxes[listBoxes.Count - 1].X;

            lastListBox.Width = lastColumnWidth;
            lastHeader.Width  = lastColumnWidth;
        }