Example #1
0
        /// <summary>
        /// Add a tab page to the tab control.
        /// </summary>
        /// <param name="item">The items to be displayed on the new tab page.</param>
        /// <param name="title">The title of the tab page.</param>
        public void AddTab(Component item, string title)
        {
            //Create the new tabpage.
            TabPage tab = new TabPage(_GUI, _Position + new Vector2(_Tabs.Count * 55, 0), 50, 25);

            //set the caption of the tab page.
            tab.Title = title;

            //Add the item to the tabpage.
            tab.AddItem(item);
            //Add the tabpage to this tab control.
            _Tabs.Add(tab);
            Add(tab);

            //Change the selected tab to this.
            TabSelectInvoke(tab);

            //Perform the additional event subscribing here.
            tab.MouseClick += OnTabClick;
        }
Example #2
0
        /// <summary>
        /// Change the selected tab.
        /// </summary>
        /// <param name="item">The selected tab component.</param>
        protected void TabSelectInvoke(TabPage item)
        {
            //See if the specified item really is a tab and if isn't already selected.
            if (!_Items.Contains(item) || (item == _SelectedTab)) { return; }

            //Select the tab.
            _SelectedTab = item;
            //Bring the tab to front.
            _SelectedTab.DrawOrder = 0;
            //Update the state of the tab control.
            UpdateState();

            //Ask for focus.
            _GUI.RequestFocus(item);

            //If someone has hooked up a delegate to the event, fire it.
            //if (TabSelect != null) { TabSelect(this, new ItemSelectEventArgs(item)); }
        }
Example #3
0
        /// <summary>
        /// Initialize the tab control.
        /// </summary>
        /// <param name="gui">The GUI that this tab control will be a part of.</param>
        /// <param name="position">The position of this tab control.</param>
        /// <param name="height">The height of this tab control.</param>
        /// <param name="width">The width of this tab control.</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.
            _Tabs = new List<TabPage>();
            _SelectedTab = null;
        }