internal void ShowTab(TabPage tab, bool show)
        {
            var(index, bt) = FindBackingTab(tab, indexVisibleOnly: true);
            if (index < 0 || bt == null)
            {
                return;
            }

            if (show)
            {
                bt.Visible = true;
                if (!TabPages.Contains(bt.Tab))
                {
                    TabPages.Insert(Math.Min(index, TabCount), bt.Tab);
                }
            }
            else
            {
                bt.Visible = false;
                if (TabPages.Contains(bt.Tab))
                {
                    TabPages.Remove(bt.Tab);
                }
            }
        }
Exemple #2
0
        private void InsertTabPage(System.Windows.Forms.TabPage[] originalOrder, System.Windows.Forms.TabPage page)
        {
            if (TabPages.Contains(page))
            {
                return;
            }
            if (originalOrder == null)
            {
                TabPages.Add(page);
            }
            System.Collections.Generic.Dictionary <System.Windows.Forms.TabPage, int> dictionary = new System.Collections.Generic.Dictionary <System.Windows.Forms.TabPage, int>();
            for (int i1 = 0; i1 < originalOrder.Length; i1++)
            {
                dictionary.Add(originalOrder[i1], i1);
            }
            if (!dictionary.ContainsKey(page))
            {
                TabPages.Add(page);
            }
            int i2 = dictionary[page];// (page);

            for (int i3 = 0; i3 < TabPages.Count; i3++)
            {
                System.Windows.Forms.TabPage tabPage = TabPages[i3];
                if (dictionary.ContainsKey(tabPage) && (dictionary[tabPage] > i2))
                {
                    TabPages.Insert(i3, page);
                    return;
                }
            }
            TabPages.Add(page);
        }
 /// <summary>
 /// Closes/removes the smart part.
 /// </summary>
 protected virtual void OnClose(Control smartPart)
 {
     PopulatePages();
     if (smartPart != null)
     {
         smartPart.Disposed -= ControlDisposed;
         if (pages.ContainsKey(smartPart))
         {
             if (TabPages.Contains(pages[smartPart]) == true)
             {
                 TabPages.Remove(pages[smartPart]);
             }
             if (pages[smartPart].Controls != null)
             {
                 pages[smartPart].Controls.Remove(smartPart);
             }
             pages.Remove(smartPart);
         }
         if (!smartPart.IsDisposed)
         {
             smartPart.Dispose();
         }
     }
     //smartPart.Dispose();
 }
 public bool GetTabVisible(TabPage page)
 {
     if (initializing && hidingTabCache != null)
     {
         return(!hidingTabCache.Contains(page));
     }
     return(TabPages.Contains(page));
 }
Exemple #5
0
 public void HideTab(TabPage page)
 {
     if (page != null && TabPages.Contains(page))
     {
         BackupTabPages();
         TabPages.Remove(page);
     }
 }
        /// <summary>
        /// Checks if displayer is contained
        /// </summary>
        /// <param name="displayer">Displayer to be checked</param>
        /// <returns></returns>
        public bool Contains(IDisplayer displayer)
        {
            MultitabPage displayerPage = displayer as MultitabPage;

            if (displayerPage != null)
            {
                return(TabPages.Contains(displayerPage));
            }
            return(false);
        }
 public void HidePage(TabPage tabPage)
 {
     if (TabPages.Contains(tabPage))
     {
         int v = TabPages.IndexOf(tabPage);
         HiddenPages.Add(tabPage);
         lastIndex.Add(v);
         TabPages.RemoveAt(v);
     }
 }
Exemple #8
0
        /*
         * OnTabPageAdded
         */

        /// <summary>
        /// Will bubble the <see cref="E:Genetibase.Controls.NuGenTabbedMdi.TabPageAdded"/> event.
        /// </summary>
        /// <param name="e"></param>
        protected override void OnTabPageAdded(NuGenCollectionEventArgs <NuGenTabPage> e)
        {
            base.OnTabPageAdded(e);

            if (TabPages.Count > 1 && TabPages.Contains(BlankPage))
            {
                TabPages.Remove(BlankPage);
            }

            OnStateChanged(new MdiStateEventArgs(IsEmpty));
        }
Exemple #9
0
 /// <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)
     {
         var ctlPage = (VerticalTabPage)e.Control;
         if (!TabPages.Contains(ctlPage))
         {
             TabPages.Add(ctlPage);
         }
     }
 }
        public void SwapTabPages(TabPage tp1, TabPage tp2)
        {
            if (!TabPages.Contains(tp1) || !TabPages.Contains(tp2))
            {
                throw new ArgumentException("TabPages must be in the TabCotrols TabPageCollection.");
            }
            int Index1 = TabPages.IndexOf(tp1);
            int Index2 = TabPages.IndexOf(tp2);

            TabPages[Index1] = tp2;
            TabPages[Index2] = tp1;
        }
Exemple #11
0
 public void ShowTabPage(bool show, System.Windows.Forms.TabPage page)
 {
     if (show)
     {
         InsertTabPage(_TabPageOrder, page);
         return;
     }
     if (TabPages.Contains(page))
     {
         TabPages.Remove(page);
     }
 }
        /// <summary>Swaps the tab pages.</summary>
        /// <param name="tabPage1">The tab page.</param>
        /// <param name="tabPage2">The other tab page.</param>
        public void SwapTabPages(TabPage tabPage1, TabPage tabPage2)
        {
            if (!TabPages.Contains(tabPage1) || !TabPages.Contains(tabPage2))
            {
                throw new ArgumentException(@"TabPages must be in the TabControls TabPageCollection.");
            }

            int _index1 = TabPages.IndexOf(tabPage1);
            int _index2 = TabPages.IndexOf(tabPage2);

            TabPages[_index1] = tabPage2;
            TabPages[_index2] = tabPage1;
        }
Exemple #13
0
        /// <summary>
        /// Removes a tab page, but keeps a reference to it to allow showing it again later.
        /// </summary>
        public void HidePage(TabPage page)
        {
            if (page == null)
            {
                throw new ArgumentNullException("page");
            }

            if (TabPages.Contains(page))
            {
                TabPages.Remove(page);
                m_hiddenPages.Add(page);
            }
        }
 /// <summary>
 /// Removes displayer from collection of Displayers
 /// </summary>
 /// <param name="displayer">Removed item</param>
 /// <returns>Result of operation</returns>
 /// <param name="performCloseChecking">Perform or not checking before closing</param>
 public bool Remove(IDisplayer displayer, bool performCloseChecking)
 {
     if (null == displayer)
     {
         throw new ArgumentNullException("displayer");
     }
     if (!(displayer is MultitabPage))
     {
         throw new ArgumentException("Displayer must be AvTabPage");
     }
     displayer.PerformCloseChecking = performCloseChecking;
     CloseTab(displayer as MultitabPage);
     return(!TabPages.Contains(displayer as MultitabPage));
 }
        private void SetTabProperties(XtraTabPage page, XtraTabSmartPartInfo smartPartInfo)
        {
            page.Text = String.IsNullOrEmpty(smartPartInfo.Title) ? page.Text : smartPartInfo.Title;

            try
            {
                XtraTabPage currentSelection = SelectedTabPage;
                callComposerActivateOnIndexChange = false;
                if (smartPartInfo.Position == TabPosition.Beginning)
                {
                    XtraTabPage[] tabPages = GetTabPages();
                    TabPages.Clear();

                    TabPages.Add(page);
                    TabPages.AddRange(tabPages);
                }
                else if (TabPages.Contains(page) == false)
                {
                    TabPages.Add(page);
                }

                page.BackColor       = smartPartInfo.BackColor;
                page.ForeColor       = smartPartInfo.ForeColor;
                page.Image           = smartPartInfo.Image;
                page.ImageIndex      = smartPartInfo.ImageIndex;
                page.PageEnabled     = smartPartInfo.PageEnabled;
                page.PageVisible     = smartPartInfo.PageVisible;
                page.ShowCloseButton = smartPartInfo.ShowCloseButton;

                if (smartPartInfo.Text != null || smartPartInfo.Text != null)   // don't apply if not set
                {
                    page.Text = smartPartInfo.Text ?? smartPartInfo.Title;
                }

                page.Tooltip = smartPartInfo.Tooltip;

                if (smartPartInfo.PageHeaderFont != null)
                {
                    page.Appearance.Header.Font            = smartPartInfo.PageHeaderFont;
                    page.Appearance.Header.Options.UseFont = true;
                }

                SelectedTabPage = currentSelection;             // preserve selection through the operation
            }
            finally
            {
                callComposerActivateOnIndexChange = true;
            }
        }
Exemple #16
0
        public void ShowTab(TabPage page)
        {
            if (page != null)
            {
                if (_TabPages != null)
                {
                    if (!TabPages.Contains(page) &&
                        _TabPages.Contains(page))
                    {
                        //	Get insert point from backup of pages
                        int pageIndex = _TabPages.IndexOf(page);
                        if (pageIndex > 0)
                        {
                            int start = pageIndex - 1;

                            //	Check for presence of earlier pages in the visible tabs
                            for (int index = start; index >= 0; index--)
                            {
                                if (TabPages.Contains(_TabPages[index]))
                                {
                                    //	Set insert point to the right of the last present tab
                                    pageIndex = TabPages.IndexOf(_TabPages[index]) + 1;
                                    break;
                                }
                            }
                        }

                        //	Insert the page, or add to the end
                        if ((pageIndex >= 0) && (pageIndex < TabPages.Count))
                        {
                            TabPages.Insert(pageIndex, page);
                        }
                        else
                        {
                            TabPages.Add(page);
                        }
                    }
                }
                else
                {
                    //	If the page is not found at all then just add it
                    if (!TabPages.Contains(page))
                    {
                        TabPages.Add(page);
                    }
                }
            }
        }
Exemple #17
0
        /// <summary>
        ///   Handles the <see cref="TabPageCollection.TabPageAdded" /> event of this
        ///   control's collection of <see cref="VerticalTabPages" />.
        /// </summary>
        /// <remarks>
        ///   This wires the added tab page into the control, and adds it to the <see cref="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, TabPageEventArgs e)
        {
            var ctlPage = e.TabPage;

            if (ctlPage.PageIndex == -1)
            {
                ctlPage.PageIndex = TabPages.Count - 1;
            }
            if (!TabPages.Contains(ctlPage))
            {
                TabPages.Add(ctlPage);
            }
            ctlPage.TabButton.Selected += TabSelected;
            m_ptsTabContainer.addToolStripItem(ctlPage.TabButton);
            ctlPage.Dock    = DockStyle.Fill;
            SelectedTabPage = ctlPage;
            Controls.Add(e.TabPage);
        }
Exemple #18
0
        /// <summary>
        ///   Handles the <see cref="TabPageCollection.TabPageAdded" /> event of this
        ///   control's collection of <see cref="DropDownTabPages" />.
        /// </summary>
        /// <remarks>
        ///   This wires the added tab page into the control, and adds it to the <see cref="Controls" />
        ///   collection.
        /// </remarks>
        /// <param name="sender">The object that raised the event.</param>
        /// <param name="e">A <see cref="DropDownTabControl.TabPageEventArgs" /> describing the event arguments.</param>
        private void AddTabPage(object sender, TabPageEventArgs e)
        {
            var ctlPage = e.TabPage;

            if (ctlPage.PageIndex == -1)
            {
                ctlPage.PageIndex = TabPages.Count - 1;
            }
            if (!TabPages.Contains(ctlPage))
            {
                TabPages.Add(ctlPage);
            }
            ctlPage.PageIndexChanged += PageIndexChanged;
            ctlPage.TextChanged      += PageTextChanged;
            InsertTabPageInSelector(ctlPage);
            ctlPage.Dock = DockStyle.Fill;
            Controls.Add(e.TabPage);
            SelectedTabPage = ctlPage;
        }
Exemple #19
0
        public void UpdateOnglets()
        {
            if (!LockEdition)
            {
                //valide les modifs car on va tout supprimer
                MAJ_Champs();
            }
            m_bIsInitializing = true;
            Hashtable tablePagesToHide = new Hashtable();

            foreach (Crownwood.Magic.Controls.TabPage page in TabPages)
            {
                m_tablePagesInit[page] = false;
                tablePagesToHide[page] = true;
            }

            if (m_elementEdite == null)
            {
                return;
            }

            /* YK : On obtient la session de l'objet en cours d'édition au lieur de la session par défaut */
            CSessionClient session = null;
            IObjetDonneeAIdNumeriqueAuto objetDonnee = m_elementEdite as IObjetDonneeAIdNumeriqueAuto;

            if (objetDonnee != null)
            {
                session = CSessionClient.GetSessionForIdSession(objetDonnee.ContexteDonnee.IdSession);
            }
            else
            {
                session = CSessionClient.GetSessionUnique();
            }

            ArrayList lstFormulaires = new ArrayList(m_elementEdite.GetFormulaires());

            lstFormulaires.Sort(new CSorterFormulaires());
            //Lit les champs liés et leurs valeurs
            StringBuilder bl = new StringBuilder();

            foreach (CFormulaire formulaire in lstFormulaires)
            {
                bl.Append(formulaire.Id);
                bl.Append(",");
            }
            if (bl.Length > 0)
            {
                bl.Remove(bl.Length - 1, 1);
                CListeObjetsDonnees lst = new CListeObjetsDonnees(((CFormulaire)lstFormulaires[0]).ContexteDonnee, typeof(CFormulaire));
                lst.Filtre = new CFiltreData(CFormulaire.c_champId + " in (" + bl.ToString() + ")");
                lst.AssureLectureFaite();
                lst.ReadDependances("RelationsChamps", "RelationsChamps.Champ", "RelationsChamps.Champ.ListeValeurs");
            }


            foreach (CFormulaire formulaire in lstFormulaires)
            {
                CRestrictionUtilisateurSurType restriction = new CRestrictionUtilisateurSurType(m_elementEdite.GetType());
                if (session.GetInfoUtilisateur() != null)
                {
                    int?nIdVersion = null;
                    IObjetAContexteDonnee objetAContexte = m_elementEdite as IObjetAContexteDonnee;
                    if (objetAContexte != null)
                    {
                        nIdVersion = objetAContexte.ContexteDonnee.IdVersionDeTravail;
                    }
                    restriction = session.GetInfoUtilisateur().GetRestrictionsSurObjet(m_elementEdite, nIdVersion);
                }

                ERestriction restrictionFormulaire = restriction.GetRestriction(formulaire.CleRestriction);

                if ((restrictionFormulaire & ERestriction.Hide) != ERestriction.Hide)
                {
                    Crownwood.Magic.Controls.TabPage page     = (Crownwood.Magic.Controls.TabPage)m_tableIdFormulaireToTabPage[formulaire.Id];
                    CCreateur2iFormulaire            createur = null;

                    if (page == null)
                    {
                        C2iWndFenetre wnd = formulaire.Formulaire;
                        if (wnd != null)
                        {
                            page = new Crownwood.Magic.Controls.TabPage(wnd.Text);
                            page.SuspendLayout();
                            if (wnd.Text == "")
                            {
                                page.Title = formulaire.Libelle;
                            }
                            TabPages.Add(page);
                            m_tableCreateurs[page]   = null;
                            m_tablePageTo2iWnd[page] = wnd;
                            m_tableIdFormulaireToTabPage[formulaire.Id] = page;
                        }
                    }
                    else
                    {
                        createur = (CCreateur2iFormulaire)m_tableCreateurs[page];
                    }

                    if (page != null)
                    {
                        m_tablePageToRestriction[page] = restrictionFormulaire;
                        if (!TabPages.Contains(page))
                        {
                            TabPages.Add(page);
                        }
                        tablePagesToHide.Remove(page);
                    }
                }
            }

            /*CChampCustom[] champs = ElementEdite.GetChampsHorsFormulaire();
             * if ( champs.Length != 0 )
             * {
             *      UpdatePageChamps( nRest );
             *      if ( m_pageGrid != null )
             *              tablePagesToHide.Remove(m_pageGrid);
             * }*/
            foreach (Crownwood.Magic.Controls.TabPage pageToDel in tablePagesToHide.Keys)
            {
                TabPages.Remove(pageToDel);
            }

            if (TabPages.Count == 1)
            {
                this.HideTabsMode = Crownwood.Magic.Controls.TabControl.HideTabsModes.HideAlways;
            }
            else
            {
                this.HideTabsMode = Crownwood.Magic.Controls.TabControl.HideTabsModes.ShowAlways;
            }
            if (SelectedTab != null)
            {
                InitPageWithObjetCourant(SelectedTab);
            }
            m_bIsInitializing = false;
        }
        public void UpdateOnglets()
        {
            this.SuspendDrawing();
            try
            {
                /*if (!LockEdition)
                 * {
                 *  //valide les modifs car on va tout supprimer
                 *  MAJ_Champs();
                 * }*/
                Crownwood.Magic.Controls.TabPage pageSelect = this.SelectedTab;
                m_bIsInitializing = true;
                Hashtable tablePagesToHide = new Hashtable();
                ArrayList pages            = new ArrayList(TabPages);
                foreach (Crownwood.Magic.Controls.TabPage page in pages)
                {
                    m_tablePagesInit[page] = false;
                    tablePagesToHide[page] = true;
                    TabPages.Remove(page);
                }

                if (m_elementEdite == null)
                {
                    return;
                }

                /* YK : On obtient la session de l'objet en cours d'édition au lieur de la session par défaut */
                CSessionClient           session     = null;
                IObjetDonneeAIdNumerique objetDonnee = m_elementEdite as IObjetDonneeAIdNumerique;
                if (objetDonnee != null)
                {
                    session = CSessionClient.GetSessionForIdSession(objetDonnee.ContexteDonnee.IdSession);
                }
                else
                {
                    session = CSessionClient.GetSessionUnique();
                }

                ArrayList lstFormulaires = new ArrayList(m_listeFormulaires);
                lstFormulaires.Sort(new CSorterFormulaires());
                //Lit les champs liés et leurs valeurs
                StringBuilder bl = new StringBuilder();
                foreach (CFormulaire formulaire in lstFormulaires)
                {
                    bl.Append(formulaire.Id);
                    bl.Append(",");
                }
                if (bl.Length > 0)
                {
                    bl.Remove(bl.Length - 1, 1);
                    CListeObjetsDonnees lst = new CListeObjetsDonnees(((CFormulaire)lstFormulaires[0]).ContexteDonnee, typeof(CFormulaire));
                    lst.Filtre = new CFiltreData(CFormulaire.c_champId + " in (" + bl.ToString() + ")");
                    lst.AssureLectureFaite();
                    lst.ReadDependances("RelationsChamps", "RelationsChamps.Champ", "RelationsChamps.Champ.ListeValeurs");
                }


                foreach (CFormulaire formulaire in lstFormulaires)
                {
                    Crownwood.Magic.Controls.TabPage page = null;
                    m_tableIdFormulaireToTabPage.TryGetValue(formulaire.Id, out page);
                    CCreateur2iFormulaireObjetDonnee createur = null;

                    if (page == null)
                    {
                        C2iWndFenetre wnd = formulaire.Formulaire;
                        if (wnd != null)
                        {
                            page      = new Crownwood.Magic.Controls.TabPage(wnd.Text);
                            page.Name = formulaire.IdUniversel;
                            if (wnd.Text == "")
                            {
                                page.Title = formulaire.Libelle;
                            }
                            TabPages.Add(page);
                            if (m_tableCreateurs.ContainsKey(page))
                            {
                                m_tableCreateurs.Remove(page);
                            }
                            m_tablePageTo2iWnd[page] = wnd;
                            m_tableIdFormulaireToTabPage[formulaire.Id] = page;
                            m_tablePageToIdFormulaire[page]             = formulaire.Id;
                        }
                    }
                    else
                    {
                        m_tableCreateurs.TryGetValue(page, out createur);
                    }

                    if (page != null)
                    {
                        if (!TabPages.Contains(page))
                        {
                            TabPages.Add(page);
                        }
                        tablePagesToHide.Remove(page);
                    }
                }


                /*CChampCustom[] champs = ElementEdite.GetChampsHorsFormulaire();
                 * if ( champs.Length != 0 )
                 * {
                 *  UpdatePageChamps( nRest );
                 *  if ( m_pageGrid != null )
                 *      tablePagesToHide.Remove(m_pageGrid);
                 * }*/
                foreach (Crownwood.Magic.Controls.TabPage pageToDel in tablePagesToHide.Keys)
                {
                    if (TabPages.Contains(pageToDel))
                    {
                        TabPages.Remove(pageToDel);
                    }
                }

                if (TabPages.Count == 1)
                {
                    this.HideTabsMode = Crownwood.Magic.Controls.TabControl.HideTabsModes.HideAlways;
                }
                else
                {
                    this.HideTabsMode = Crownwood.Magic.Controls.TabControl.HideTabsModes.ShowAlways;
                }
                if (TabPages.Contains(pageSelect))
                {
                    SelectedTab = pageSelect;
                }
                if (SelectedTab != null)
                {
                    InitPageWithObjetCourant(SelectedTab);
                }
            }
            finally
            {
                this.ResumeDrawing();
            }
            m_bIsInitializing = false;
        }
Exemple #21
0
        internal void TabPagesChanged()
        {
            //This is called whenever a tab has been added or removed from the TabPages collection.

            //Remove all of the tabs from the control
            foreach (Control mycontrol in Controls)
            {
                if (ReferenceEquals(mycontrol.GetType(), typeof(LcarsTabPage)))
                {
                    Controls.Remove(mycontrol);
                }
            }

            //Remove the tab's button from the buttonPanel.
            tabButtonPanel.Controls.Clear();

            //Add all of the tabs back to the control, so now the new ones are there, too
            //(or old ones are gone...)
            foreach (LcarsTabPage mytab in TabPages)
            {
                Controls.Add(mytab);

                //Set the size of the tab equal to the area we want the tab to cover.  Basically,
                //everwhere our heading, elbow, and buttonpanel are not.

                mytab.Width  = Width - tabButtonPanel.Width - spacing * 2;
                mytab.Height = Height - (horizantalBar.Height + spacing);

                switch (elbowStyle)
                {
                case LcarsElbowStyle.UpperRight:
                    mytab.Location = new Point(0, horizantalBar.Height + spacing);
                    break;

                case LcarsElbowStyle.UpperLeft:
                    mytab.Location = new Point(Width - mytab.Width, horizantalBar.Height + spacing);
                    break;

                case LcarsElbowStyle.LowerRight:
                    mytab.Location = new Point(0, 0);
                    break;

                case LcarsElbowStyle.LowerLeft:
                    mytab.Location = new Point(Width - mytab.Width, 0);
                    break;
                }

                //Set the anchor so the tab will resize with the tabcontrol
                mytab.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Right;

                //Now that we have the tab added to the tab control, we need to create a button
                //that will bring it to the front when the user clicks it.
                FlatButton mybutton = new FlatButton();
                mybutton.Width           = verticalBarWidth;
                mybutton.Height          = tabButtonHeight;
                mybutton.Left            = 0;
                mybutton.ForceCaps       = ForceCaps;
                mybutton.Text            = mytab.Text;
                mybutton.ButtonTextAlign = ContentAlignment.BottomRight;
                mybutton.ColorFunction   = mytab.ColorFunction;

                mybutton.DoesSound  = true;
                mybutton.SoundAsset = Assets.Access.LcarsSoundAsset.RandomProcessing;

                //position the button based on how many buttons are already there.
                switch (elbowStyle)
                {
                case LcarsElbowStyle.UpperRight:
                case LcarsElbowStyle.UpperLeft:
                    mybutton.Top    = tabButtonPanel.Controls.Count * (tabButtonHeight + spacing);
                    mybutton.Anchor = AnchorStyles.Top | AnchorStyles.Right;
                    break;

                case LcarsElbowStyle.LowerRight:
                case LcarsElbowStyle.LowerLeft:
                    mybutton.Top    = tabButtonPanel.Height - ((tabButtonPanel.Controls.Count + 1) * (tabButtonHeight + spacing)) + spacing;
                    mybutton.Anchor = AnchorStyles.Bottom | AnchorStyles.Right;
                    break;
                }

                //By setting the button's 'Tag' property to the Tab it is associated with,
                //we can easily tell what button goes with what tab.
                mybutton.Tag = mytab;

                //Make the button call "TabButton_Click" whenever someone clicks on it.
                mybutton.Click += TabButton_Click;
                tabButtonPanel.Controls.Add(mybutton);
            }

            //If there's any room left after all of tabs have been made, we need to fill the
            //empty space with another button that isn't clickable.
            if ((tabButtonPanel.Controls.Count * (tabButtonHeight + spacing)) < tabButtonPanel.Height)
            {
                FlatButton myButton = new FlatButton();

                myButton.Width = verticalBarWidth;

                switch (elbowStyle)
                {
                case LcarsElbowStyle.UpperRight:
                    myButton.Top             = tabButtonPanel.Controls.Count * (tabButtonHeight + spacing);
                    myButton.Height          = tabButtonPanel.Height - myButton.Top;
                    myButton.ButtonTextAlign = ContentAlignment.BottomRight;
                    myButton.Anchor          = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
                    break;

                case LcarsElbowStyle.UpperLeft:
                    myButton.Top             = tabButtonPanel.Controls.Count * (tabButtonHeight + spacing);
                    myButton.Height          = tabButtonPanel.Height - myButton.Top;
                    myButton.ButtonTextAlign = ContentAlignment.BottomLeft;
                    myButton.Anchor          = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
                    break;

                case LcarsElbowStyle.LowerRight:
                    myButton.Top             = 0;
                    myButton.Height          = tabButtonPanel.Height - (tabButtonPanel.Controls.Count * (tabButtonHeight + spacing));
                    myButton.ButtonTextAlign = ContentAlignment.TopRight;
                    myButton.Anchor          = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
                    break;

                case LcarsElbowStyle.LowerLeft:
                    myButton.Top             = 0;
                    myButton.Height          = tabButtonPanel.Height - (tabButtonPanel.Controls.Count * (tabButtonHeight + spacing));
                    myButton.ButtonTextAlign = ContentAlignment.TopLeft;
                    myButton.Anchor          = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Right;
                    break;
                }

                myButton.TextVisible   = false;
                myButton.ColorFunction = LcarsColorFunction.StaticTan;
                myButton.Clickable     = false;
                tabButtonPanel.Controls.Add(myButton);
            }

            //If the "SelectedTab" property isn't set, then select the first tab added to the control.
            if (SelectedTab == null | TabPages.Contains(SelectedTab) == false)
            {
                if (TabPages.Count > 0)
                {
                    SelectedTab = TabPages[0];
                }
                else
                {
                    SelectedTab = null;
                }
            }

            //There's a label placed on the form if no tabs have been added that explains how to
            //add tabs to the control.  This message is only shown if there are no tabs and the
            //control is in 'Design Time' (not executing, but rather in the designer).
            if (TabPages.Count > 0)
            {
                designerMessage.Visible = false;
            }
            else
            {
                designerMessage.Visible = true;
            }

            //Bring the tab that is currently set as selected to the front.
            ChangeTab(selectedTab);
        }
        /// ///////////////////////////////////////////////////
        public void AppliqueRestrictions(CListeRestrictionsUtilisateurSurType restrictions, IGestionnaireReadOnlySysteme gestionnaireReadOnly)
        {
            if (restrictions == null || gestionnaireReadOnly == null)
            {
                return;
            }
            m_listeRestrictions    = restrictions.Clone() as CListeRestrictionsUtilisateurSurType;
            m_gestionnaireReadOnly = gestionnaireReadOnly;

            //Gère la visibilité des formulaires
            if (m_elementEdite != null)
            {
                CRestrictionUtilisateurSurType rest = m_listeRestrictions.GetRestriction(m_elementEdite.GetType());
                rest.ApplyToObjet(m_elementEdite);
                if (rest.HasRestrictions)
                {
                    foreach (KeyValuePair <Crownwood.Magic.Controls.TabPage, int> kv in m_tablePageToIdFormulaire)
                    {
                        CFormulaire formulaire = new CFormulaire(m_elementEdite.ContexteDonnee);
                        if (formulaire.ReadIfExists(kv.Value))
                        {
                            ERestriction r = rest.GetRestriction(formulaire.CleRestriction);
                            if ((r & ERestriction.Hide) == ERestriction.Hide)
                            {
                                if (TabPages.Contains(kv.Key))
                                {
                                    TabPages.Remove(kv.Key);
                                    m_tablePagesInit[kv.Key] = false;
                                }
                            }
                        }
                    }
                }
            }


            //Update les pages initialisées
            foreach (KeyValuePair <Crownwood.Magic.Controls.TabPage, bool> kv in m_tablePagesInit)
            {
                if (kv.Value)
                {
                    CCreateur2iFormulaireObjetDonnee createur = null;
                    if (m_tableCreateurs.TryGetValue(kv.Key, out createur))
                    {
                        CRestrictionUtilisateurSurType oldRest = null;

                        if (m_elementEdite != null)
                        {
                            CRestrictionUtilisateurSurType restriction = m_listeRestrictions.GetRestriction(m_elementEdite.GetType());
                            oldRest = m_listeRestrictions.GetRestriction(m_elementEdite.GetType());
                            restriction.ApplyToObjet(m_elementEdite);
                            int nIdFormulaire;
                            if (m_tablePageToIdFormulaire.TryGetValue(kv.Key, out nIdFormulaire))
                            {
                                CFormulaire formulaire = new CFormulaire(m_elementEdite.ContexteDonnee);
                                if (formulaire.ReadIfExists(nIdFormulaire))
                                {
                                    ERestriction rest = restriction.GetRestriction(formulaire.CleRestriction);
                                    if ((rest & ERestriction.ReadOnly) == ERestriction.ReadOnly)
                                    {
                                        restriction.AddRestrictionsHorsPriorite(new CRestrictionUtilisateurSurType(restriction.TypeAssocie, ERestriction.ReadOnly));
                                        //force readonly sur tous les contrôles
                                        restriction.RestrictionUtilisateur = ERestriction.ReadOnly;
                                        m_listeRestrictions.SetRestriction(restriction);
                                    }
                                }
                            }
                        }
                        createur.AppliqueRestrictions(m_listeRestrictions, m_gestionnaireReadOnly);
                        if (oldRest != null)
                        {
                            m_listeRestrictions.SetRestriction(oldRest);
                        }
                    }
                }
            }
        }