Exemplo n.º 1
0
 protected override void OnRefresh(HeaderModule.Section section)
 {
     using (Region rgn = new Region())
     {
         if ((section & HeaderModule.Section.Headers) != 0)
         {
             rgn.Union(new Rectangle(0, 0, _tabsbtn.X, HeaderHeight));
         }
         if ((section & HeaderModule.Section.Browser) != 0)
         {
             rgn.Union(_tabsbtn);
         }
         if ((section & HeaderModule.Section.CloseButton) != 0)
         {
             rgn.Union(_closebtn);
         }
         //update control
         this.Owner.Invalidate(rgn, false);
         this.Owner.Update();
     }
 }
Exemplo n.º 2
0
 protected override void OnReload(HeaderModule.Section section, ITabPage start)
 {
     if ((section & HeaderModule.Section.Headers) != 0)
     {
         #region remeasure headers
         bool remeasure = start == null;
         //manage paths array
         while (_paths.Count > this.Owner.Pages.Count)
         {
             GraphicsPath path = (GraphicsPath)_paths[0];
             _paths.RemoveAt(0);
             path.Dispose();
         }
         while (_paths.Count < this.Owner.Pages.Count)
         {
             _paths.Add(new GraphicsPath());
         }
         //remeasure tabs
         int x = 1, width;
         using (Graphics gr = this.Owner.CreateGraphics())
         {
             for (int i = 0; i < this.Owner.Pages.Count; i++)
             {
                 ITabPage     page = this.Owner.Pages[i];
                 GraphicsPath path = (GraphicsPath)_paths[i];
                 if (start == page)
                 {
                     remeasure = true;
                 }
                 if (!remeasure)
                 {
                     x = (int)(path.GetBounds().Right) - 10;
                     continue;
                 }
                 #region measure header
                 if (page.Caption == null || page.Caption == "")
                 {
                     width = 24;
                 }
                 else
                 {
                     width = Math.Min(this.MaxHeaderWidth,
                                      24 + (int)gr.MeasureString(page.Caption, _fontactive).Width);
                 }
                 path.Reset();
                 path.AddCurve(                        //create tab shape
                     new Point[] { new Point(x, 19),
                                   new Point(x + 12, 7),
                                   new Point(x + 19, 3) }, 0.7f);
                 path.AddLine(x + 19, 3, x + width - 2, 3);
                 path.AddLine(x + width, 5, x + width, 19);
                 #endregion
                 x += width - 10;
             }
         }
         #endregion
     }
     if ((section & HeaderModule.Section.Browser) != 0)
     {
         #region tabs button
         //manage contextmenu
         while (_mnu.MenuItems.Count > this.Owner.Pages.Count)
         {
             MenuItem item = _mnu.MenuItems[0];
             _mnu.MenuItems.RemoveAt(0);
             item.Dispose();
         }
         while (_mnu.MenuItems.Count < this.Owner.Pages.Count)
         {
             _mnu.MenuItems.Add(new MenuItem("item",
                                             new EventHandler(MenuItem_Click)));
         }
         //reset defaultitems
         foreach (MenuItem item in _mnu.MenuItems)
         {
             item.DefaultItem = false;
         }
         //update captions
         for (int i = 0; i < this.Owner.Pages.Count; i++)
         {
             ITabPage page = this.Owner.Pages[i];
             _mnu.MenuItems[i].Text = page.Caption;
             if (page == this.Owner.SelectedPage)
             {
                 _mnu.MenuItems[i].DefaultItem = true;
             }
         }
         _tabsstate = _mnu.MenuItems.Count > 0 ?
                      ButtonState.Normal : ButtonState.Inactive;
         #endregion
     }
     if ((section & HeaderModule.Section.CloseButton) != 0)
     {
         #region close button
         ButtonState state = (
             this.Owner.SelectedPage != null &&
             this.Owner.SelectedPage.CanClose) ?
                             ButtonState.Normal :
                             ButtonState.Inactive;
         if (_closestate != state)
         {
             _closestate = state;
             Refresh(Section.CloseButton);
         }
         #endregion
     }
 }