/// <summary>
        /// Add an item to the GUI.
        /// </summary>
        /// <param name="item">The item to add.</param>
        public void AddItem(Component item)
        {
            //Add the item, try to load its content and update its draw order.
            _Items.Add(item);
            if (_IsContentLoaded) { item.LoadContent(); }
            item.DrawOrder = _Items.CompleteCount;

            //Hook up some events.
            AddItemEvents(item);
        }
Пример #2
0
        /// <summary>
        /// Add a component.
        /// </summary>
        /// <param name="item">The component to add.</param>
        protected virtual Component Add(Component item)
        {
            //Add the component to the list of components.
            _Items.Add(item);
            item.Parent = this;
            item.DrawOrder = _Items.Count;

            //Load the item's content if necessary.
            if (_IsContentLoaded) { item.LoadContent(); }

            //Subscribe to some events.
            item.BoundsChange += OnItemBoundsChange;
            item.FocusChange += OnItemFocusChange;
            item.DrawOrderChange += OnDrawOrderChange;

            //Return the component.
            return item;
        }
Пример #3
0
 /// <summary>
 /// Insert an item.
 /// </summary>
 /// <param name="index">The index of where to insert the item.</param>
 /// <param name="item">The item to insert.</param>
 public void InsertItem(int index, Component item)
 {
     //Insert the item to the list.
     _Items.Insert(index, item);
     if (_GUI.ContentManager != null) { item.LoadContent(); }
     //Hook up some events.
     item.MouseClick += OnItemClick;
     //Call the event.
     ItemAddedInvoke(item);
 }