private void SetVerbs()
        {
            VisualTabControl _parentalControl = (VisualTabControl)Control;

            switch (_parentalControl.TabPages.Count)
            {
            case 0:
            {
                Verbs[1].Enabled = false;
                Verbs[2].Enabled = false;
                break;
            }

            case 1:
            {
                Verbs[1].Enabled = false;
                Verbs[2].Enabled = true;
                break;
            }

            default:
            {
                Verbs[1].Enabled = true;
                Verbs[2].Enabled = true;
                break;
            }
            }
        }
Example #2
0
        private void OnInsertPage(object sender, EventArgs e)
        {
            VisualTabControl _parentalControl = (VisualTabControl)Control;
            Control.ControlCollection _controlCollection = _parentalControl.Controls;
            int _index = _parentalControl.SelectedIndex;

            RaiseComponentChanging(TypeDescriptor.GetProperties(_parentalControl)["TabPages"]);

            VisualTabPage _tabPage = (VisualTabPage)DesignerHost.CreateComponent(typeof(VisualTabPage));
            _tabPage.Text = _tabPage.Name;

            var _tabPageCollection = new VisualTabPage[_parentalControl.TabCount];

            // Starting at our Insert Position, store and remove all the tab pages.
            for (int i = _index; i <= _tabPageCollection.Length - 1; i++)
            {
                _tabPageCollection[i] = (VisualTabPage)_parentalControl.TabPages[_index];
                _parentalControl.TabPages.Remove(_parentalControl.TabPages[_index]);
            }

            // add the tab page to be inserted.
            _parentalControl.TabPages.Add(_tabPage);

            // then re-add the original tab pages.
            for (int i = _index; i <= _tabPageCollection.Length - 1; i++)
            {
                _parentalControl.TabPages.Add(_tabPageCollection[i]);
            }

            RaiseComponentChanged(TypeDescriptor.GetProperties(_parentalControl)["TabPages"], _controlCollection, _parentalControl.TabPages);
            _parentalControl.SelectedTab = _tabPage;

            SetVerbs();
        }
Example #3
0
        private void OnAddPage(object sender, EventArgs e)
        {
            VisualTabControl _parentalControl = (VisualTabControl)Control;
            Control.ControlCollection _controlCollection = _parentalControl.Controls;

            RaiseComponentChanging(TypeDescriptor.GetProperties(_parentalControl)["TabPages"]);

            VisualTabPage _tabPage = (VisualTabPage)DesignerHost.CreateComponent(typeof(VisualTabPage));
            _tabPage.Text = _tabPage.Name;
            _parentalControl.TabPages.Add(_tabPage);

            RaiseComponentChanged(TypeDescriptor.GetProperties(_parentalControl)["TabPages"], _controlCollection, _parentalControl.TabPages);
            _parentalControl.SelectedTab = _tabPage;

            SetVerbs();
        }
Example #4
0
        private void OnRemovePage(object sender, EventArgs e)
        {
            VisualTabControl _parentalControl = (VisualTabControl)Control;
            Control.ControlCollection _controlCollection = _parentalControl.Controls;

            if (_parentalControl.SelectedIndex < 0)
            {
                return;
            }

            RaiseComponentChanging(TypeDescriptor.GetProperties(_parentalControl)["TabPages"]);

            DesignerHost.DestroyComponent(_parentalControl.TabPages[_parentalControl.SelectedIndex]);

            RaiseComponentChanged(TypeDescriptor.GetProperties(_parentalControl)["TabPages"], _controlCollection, _parentalControl.TabPages);

            SelectionService.SetSelectedComponents(new IComponent[] { _parentalControl }, SelectionTypes.Auto);

            SetVerbs();
        }