예제 #1
0
 /// <summary>
 /// An item in the list has been selected.
 /// </summary>
 /// <param name="obj">The object that fired the event.</param>
 /// <param name="e">The event's arguments.</param>
 private void OnItemSelect(object obj, ListItemSelectEventArgs e)
 {
     //Change the selected item.
     _SelectedItem = e.Item;
     //Invoke the event.
     ItemSelectInvoke(e.Item);
 }
예제 #2
0
        /// <summary>
        /// Initialize the menu item.
        /// </summary>
        /// <param name="gui">The GUI that this menu item will be a part of.</param>
        /// <param name="position">The position of this menu item.</param>
        /// <param name="height">The height of this menu item.</param>
        /// <param name="width">The width of this menu item.</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.
            _Label = new Label(GUI, Position, Width, 30);
            _List = new List(GUI, new Vector2(Position.X, (Position.Y + (_Label.Height + 2))), Width, 118);
            _List.IsActive = false;
            _SelectedItem = null;
            _State = MenuState.Closed;
            _Label.Text = "";

            //Add the controls.
            Add(_Label);
            Add(_List);

            //Hook up some events.
            _Label.MouseClick += OnLabelClick;
            _List.ItemSelect += OnItemSelect;
        }
예제 #3
0
 /// <summary>
 /// Tell the world that a child item has been pressed.
 /// </summary>
 /// <param name="item">The particular item.</param>
 protected virtual void ItemSelectInvoke(ListItem item)
 {
     //If someone has hooked up a delegate to the event, fire it.
     if (ItemSelect != null) { ItemSelect(this, new ListItemSelectEventArgs(item)); }
 }
예제 #4
0
 /// <summary>
 /// Create the event used when a bone has been created by an item.
 /// </summary>
 /// <param name="item">The created bone.</param>
 public ListItemAddedEventArgs(ListItem item)
 {
     //Pass along the data.
     _Item = item;
 }
예제 #5
0
 /// <summary>
 /// Create the event used when an list item has been selected.
 /// </summary>
 /// <param name="item">The selected item.</param>
 public ListItemSelectEventArgs(ListItem item)
 {
     //Pass along the data.
     _Item = item;
 }
예제 #6
0
 /// <summary>
 /// A menu item's list item has been selected.
 /// </summary>
 /// <param name="item">The selected list item.</param>
 private void MenuOptionSelectInvoke(ListItem item)
 {
     //If someone has hooked up a delegate to the event, fire it.
     if (MenuOptionSelect != null) { MenuOptionSelect(this, new ListItemSelectEventArgs(item)); }
 }
예제 #7
0
        /// <summary>
        /// An item in the list has been selected.
        /// </summary>
        /// <param name="obj">The object that fired the event.</param>
        /// <param name="e">The event's arguments.</param>
        private void OnItemSelect(object obj, ListItemSelectEventArgs e)
        {
            //Change the selected item.
            _SelectedItem = e.Item;
            //Change the displayed tag and text.
            _Label.Tag = (_SelectedItem as LabelListItem).Label.Tag;
            _Label.Text = (_SelectedItem as LabelListItem).Label.Text;

            //Fire the item select event.
            ItemSelectInvoke(e.Item);
        }
예제 #8
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;
        }
예제 #9
0
        /// <summary>
        /// An item has been selected.
        /// </summary>
        /// <param name="item">The selected item.</param>
        protected virtual void ItemSelectInvoke(Component item)
        {
            //Save the selected item.
            _SelectedItem = (ListItem)item;

            //If someone has hooked up a delegate to the event, fire it.
            if (ItemSelect != null) { ItemSelect(this, new ListItemSelectEventArgs((ListItem)item)); }
        }
예제 #10
0
        /// <summary>
        /// Move an item upwards in the list.
        /// </summary>
        /// <param name="item">The item to move.</param>
        /// <returns>Whether the operation was succesful or not. For instance if the node already is at the top, this method will return false.</returns>
        public bool MoveNodeUp(ListItem item)
        {
            //First see if the item actually exists in this list.
            if (_Items.Exists(n => (n.Equals(item))))
            {
                //Get the index position of the item.
                int index = _Items.FindIndex(i => (i.Equals(item)));

                //If the item can climb in the list.
                if (index != 0)
                {
                    //Remove the item from the list.
                    _Items.Remove(item);
                    //Insert the item at one step up from its past position in the list.
                    _Items.Insert((index - 1), item);

                    //Wrap it all up by returning true.
                    return true;
                }
                //Otherwise return false.
                else { return false; }
            }
            //Otherwise return false.
            else { return false; }
        }