Пример #1
0
 /// <summary>
 /// Switch this combobox's state.
 /// </summary>
 private void SwitchState()
 {
     //Switch state.
     if (_State == ComboboxState.Open)
     {
         //Close the list.
         _State = ComboboxState.Closed;
         _List.IsActive = false;
     }
     else
     {
         //Open the list.
         _State = ComboboxState.Open;
         _List.IsActive = true;
     }
 }
Пример #2
0
        /// <summary>
        /// Initialize the combobox.
        /// </summary>
        /// <param name="gui">The GUI that this combobox will be a part of.</param>
        /// <param name="position">The position of this combobox.</param>
        /// <param name="height">The height of this combobox.</param>
        /// <param name="width">The width of this combobox.</param>
        protected override void Initialize(GraphicalUserInterface gui, Vector2 position, float width, float height)
        {
            //The inherited method.
            base.Initialize(gui, position, width, height);

            //Intialize some variables.
            _Ratio = .1f;
            _Label = new Label(GUI, Position, (Width * (1 - _Ratio)), Height);
            _Button = new Button(GUI, new Vector2((Position.X + (Width * (1 - _Ratio))), Position.Y), (Width * _Ratio), Height);
            _List = new List(GUI, new Vector2(Position.X, (Position.Y + (_Label.Height + 2))), Width, 118);
            _List.IsActive = false;
            _SelectedItem = null;
            _State = ComboboxState.Closed;
            _Label.Text = "";

            //Add the items.
            Add(_Label);
            Add(_Button);
            Add(_List);

            //Hook up some events.
            _List.ItemSelect += OnItemSelect;
            _Button.MouseClick += OnButtonClick;
        }