A page in a VerticalTabControl.
Inheritance: System.Windows.Forms.Panel, IStatusProviderAware
        /// <summary>
        /// Handles the <see cref="TabPageCollection.TabPageRemoved"/> event of this
        /// control's collection of <see cref="VerticalTabPage"/>s.
        /// </summary>
        /// <remarks>
        /// This unwires the tab page from the control, and removes it to the <see cref="UI.Controls"/>
        /// collection.
        /// </remarks>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">A <see cref="VerticalTabControl.TabPageEventArgs"/> describing the event arguments.</param>
        private void RemoveTabPage(object sender, VerticalTabControl.TabPageEventArgs e)
        {
            VerticalTabPage ctlPage = e.TabPage;

            ctlPage.TabButton.Selected -= TabSelected;
            for (Int32 i = 0; i < m_tpcPages.Count; i++)
            {
                if (m_tpcPages[i].PageIndex > ctlPage.PageIndex)
                {
                    m_tpcPages[i].PageIndex--;
                }
            }
            m_ptsTabContainer.removeToolStripItem(ctlPage.TabButton);
            if (SelectedTabPage == ctlPage)
            {
                if (m_tpcPages.Count == 0)
                {
                    SelectedTabPage = null;
                }
                else if (SelectedIndex == m_tpcPages.Count)
                {
                    SelectedIndex--;
                }
                else
                {
                    SelectedIndex++;
                }
            }
            Controls.Remove(e.TabPage);
        }
Example #2
0
 /// <summary>
 /// A simple constructor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_tpgPage">The <see cref="VerticalTabPage"/> associated with this tab.</param>
 internal VerticalTabButton(VerticalTabPage p_tpgPage)
     : base(new StatusButton(), "Click", -1, ToolStripItemDisplayStyle.Text)
 {
     m_tpgPage = p_tpgPage;
     StatusButton.Button.FlatStyle = FlatStyle.Flat;
     StatusButton.Button.FlatAppearance.BorderSize = 0;
     m_tpgPage.BackColorChanged += new EventHandler(m_tpgPage_BackColorChanged);
 }
		/// <summary>
		/// A simple constructor that initializes the object with the given values.
		/// </summary>
		/// <param name="p_tpgPage">The <see cref="VerticalTabPage"/> associated with this tab.</param>
		internal VerticalTabButton(VerticalTabPage p_tpgPage)
			: base(new StatusButton(), "Click", -1, ToolStripItemDisplayStyle.Text)
		{
			m_tpgPage = p_tpgPage;
			StatusButton.Button.FlatStyle = FlatStyle.Flat;
			StatusButton.Button.FlatAppearance.BorderSize = 0;
			m_tpgPage.BackColorChanged += new EventHandler(m_tpgPage_BackColorChanged);
		}
 /// <summary>
 /// Raises the <see cref="Control.ControlAdded"/> event.
 /// </summary>
 /// <remarks>
 /// This ensures that any <see cref="VerticalTabPage"/>s removed from this control are removed
 /// from the <see cref="TabPages"/> collection.
 /// </remarks>
 /// <param name="e">A <see cref="ControlEventArgs"/> describing the event arguments.</param>
 protected override void OnControlRemoved(ControlEventArgs e)
 {
     base.OnControlRemoved(e);
     if (e.Control is VerticalTabPage)
     {
         VerticalTabPage ctlPage = (VerticalTabPage)e.Control;
         m_tpcPages.Remove(ctlPage);
     }
 }
        /// <summary>
        /// Creates an instance of an item for use in the collection being edited.
        /// </summary>
        /// <remarks>
        /// This sets the text of the created <see cref="VerticalTabPage"/> to its
        /// name.
        /// </remarks>
        /// <param name="p_tpeItemType">The type of the item to be created.</param>
        /// <returns>A new object of the given type.</returns>
        protected override object CreateInstance(Type p_tpeItemType)
        {
            object          objNew  = base.CreateInstance(p_tpeItemType);
            VerticalTabPage vtpPage = objNew as VerticalTabPage;

            if (vtpPage != null)
            {
                vtpPage.Text = vtpPage.Name;
            }
            return(objNew);
        }
 /// <summary>
 /// Raises the <see cref="Control.ControlAdded"/> event.
 /// </summary>
 /// <remarks>
 /// This ensures that any <see cref="VerticalTabPage"/>s added to this control are added
 /// from the <see cref="TabPages"/> collection.
 /// </remarks>
 /// <param name="e">A <see cref="ControlEventArgs"/> describing the event arguments.</param>
 protected override void OnControlAdded(ControlEventArgs e)
 {
     base.OnControlAdded(e);
     if (e.Control is VerticalTabPage)
     {
         VerticalTabPage ctlPage = (VerticalTabPage)e.Control;
         if (!m_tpcPages.Contains(ctlPage))
         {
             m_tpcPages.Add(ctlPage);
         }
     }
 }
Example #7
0
        /// <summary>
        /// Adds default tag pages to a new <see cref="VerticalTabControl"/>.
        /// </summary>
        /// <param name="defaultValues">The values with which to instantiate the control.</param>
        public override void InitializeNewComponent(IDictionary defaultValues)
        {
            base.InitializeNewComponent(defaultValues);

            VerticalTabPage tpgPage = (VerticalTabPage)DesignerHost.CreateComponent(typeof(VerticalTabPage));

            tpgPage.Text      = tpgPage.Name;
            tpgPage.BackColor = Color.FromKnownColor(KnownColor.Control);
            DesignedTabControl.TabPages.Add(tpgPage);

            tpgPage           = (VerticalTabPage)DesignerHost.CreateComponent(typeof(VerticalTabPage));
            tpgPage.Text      = tpgPage.Name;
            tpgPage.BackColor = Color.FromKnownColor(KnownColor.Control);
            DesignedTabControl.TabPages.Add(tpgPage);

            DesignedTabControl.SelectedIndex = 0;
        }
Example #8
0
        /// <summary>
        /// The event handler for the "Add Tab Page" verb.
        /// </summary>
        /// <remarks>
        /// Adds a new tab page to the control.
        /// </remarks>
        /// <param name="sender">The object that triggered the event.</param>
        /// <param name="e">An <see cref="EventArgs"/> describing the event arguments.</param>
        private void AddTabPage(object sender, EventArgs e)
        {
            VerticalTabControl.TabPageCollection tpcOldPages = DesignedTabControl.TabPages;

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

            VerticalTabPage tpgPage = (VerticalTabPage)DesignerHost.CreateComponent(typeof(VerticalTabPage));

            tpgPage.Text      = tpgPage.Name;
            tpgPage.BackColor = Color.FromKnownColor(KnownColor.Control);
            DesignedTabControl.TabPages.Add(tpgPage);

            RaiseComponentChanged(TypeDescriptor.GetProperties(DesignedTabControl)["TabPages"], tpcOldPages, DesignedTabControl.TabPages);

            DesignedTabControl.SelectedTabPage = tpgPage;
            EnableVerbs();
        }
        /// <summary>
        /// Handles the <see cref="TabPageCollection.TabPageAdded"/> event of this
        /// control's collection of <see cref="VerticalTabPage"/>s.
        /// </summary>
        /// <remarks>
        /// This wires the added tab page into the control, and adds it to the <see cref="UI.Controls"/>
        /// collection.
        /// </remarks>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">A <see cref="VerticalTabControl.TabPageEventArgs"/> describing the event arguments.</param>
        private void AddTabPage(object sender, VerticalTabControl.TabPageEventArgs e)
        {
            VerticalTabPage ctlPage = e.TabPage;

            if (ctlPage.PageIndex == -1)
            {
                ctlPage.PageIndex = m_tpcPages.Count - 1;
            }
            if (!m_tpcPages.Contains(ctlPage))
            {
                m_tpcPages.Add(ctlPage);
            }
            ctlPage.TabButton.Selected += TabSelected;
            m_ptsTabContainer.addToolStripItem(ctlPage.TabButton);
            ctlPage.Dock    = DockStyle.Fill;
            SelectedTabPage = ctlPage;
            Controls.Add(e.TabPage);
        }
 /// <summary>
 /// A simple consturctor that initializes the object with the given values.
 /// </summary>
 /// <param name="p_tpgPage">The tab page that was affected by the event.</param>
 public TabPageEventArgs(VerticalTabPage p_tpgPage)
 {
     m_tpgPage = p_tpgPage;
 }