/// <summary> /// Adds a new page to the container. /// </summary> /// <param name="page">The page </param> /// <param name="menuItem"></param> /// <param name="position">zero based position of the page</param> public void AddPage(MPPage page, MPMenuItem menuItem, int position) { htPages.Add(menuItem.pageID, page); if (page.Size.Width > largestPageSize.Width) { largestPageSize.Width = page.Size.Width; } if (page.Size.Height > largestPageSize.Height) { largestPageSize.Height = page.Size.Height; } TabPage tabPage = new TabPage(menuItem.menuText); tabPage.Name = page.PageID; tabPage.UseVisualStyleBackColor = true; tabPage.Size = page.Size; if (bPagesSizable) { page.Dock = DockStyle.Fill; } tabPage.Controls.Add(page); if (tabControl.ImageList != null) { tabPage.ImageIndex = tabControl.ImageList.Images.IndexOfKey(page.PageID); } page.ParentContainer = this; page.IPlugInContainer = container; page.position = position; // Menu positioning: // The assumption is that the caller will either care about // positioning and give each page a unique position or // that he will use POSITION_END or POSITION_BEGINING for all pages. if (page.position == MPMenu.POSITION_END || tabControl.TabPages.Count == 0) { tabControl.TabPages.Add(tabPage); } else { TabPage[] arrPages = new TabPage[tabControl.TabPages.Count + 1]; int i; int j = 0; for (i = 0; i < tabControl.TabPages.Count; i++) { MPPage curPage = GetPage(tabControl.TabPages[i].Name); if (i == j && page.position < curPage.position) { arrPages[j++] = tabPage; } arrPages[j++] = tabControl.TabPages[i]; } // insert at the end if (i == j) { arrPages[j++] = tabPage; } // the tabControl.TabPages.Insert( int index, TabPage page ) does not work for some reason tabControl.TabPages.Clear(); tabControl.TabPages.AddRange(arrPages); } // we need to remember the index of the tab page so we can get it // later by page ID htTabPages.Add(page.PageID, tabPage); }
/// <summary> /// Adds a new page to the container. /// </summary> /// <param name="page">The page </param> /// <param name="menuItem"></param> /// <param name="position">zero based position of the page</param> public void AddPage(MPPage page, MPMenuItem menuItem, int position) { htPages.Add(menuItem.pageID, page); if (page.Size.Width > largestPageSize.Width) largestPageSize.Width = page.Size.Width; if (page.Size.Height > largestPageSize.Height) largestPageSize.Height = page.Size.Height; TabPage tabPage = new TabPage(menuItem.menuText); tabPage.Name = page.PageID; tabPage.UseVisualStyleBackColor = true; tabPage.Size = page.Size; if (bPagesSizable) page.Dock = DockStyle.Fill; tabPage.Controls.Add(page); if (tabControl.ImageList != null) { tabPage.ImageIndex = tabControl.ImageList.Images.IndexOfKey(page.PageID); } page.ParentContainer = this; page.IPlugInContainer = container; page.position = position; // Menu positioning: // The assumption is that the caller will either care about // positioning and give each page a unique position or // that he will use POSITION_END or POSITION_BEGINING for all pages. if (page.position == MPMenu.POSITION_END || tabControl.TabPages.Count == 0) { tabControl.TabPages.Add(tabPage); } else { TabPage[] arrPages = new TabPage[tabControl.TabPages.Count + 1]; int i; int j = 0; for (i = 0; i < tabControl.TabPages.Count; i++) { MPPage curPage = GetPage(tabControl.TabPages[i].Name); if (i == j && page.position < curPage.position) arrPages[j++] = tabPage; arrPages[j++] = tabControl.TabPages[i]; } // insert at the end if (i == j) arrPages[j++] = tabPage; // the tabControl.TabPages.Insert( int index, TabPage page ) does not work for some reason tabControl.TabPages.Clear(); tabControl.TabPages.AddRange(arrPages); } // we need to remember the index of the tab page so we can get it // later by page ID htTabPages.Add(page.PageID, tabPage); }