PageRenderTime 70ms CodeModel.GetById 20ms app.highlight 41ms RepoModel.GetById 1ms app.codeStats 0ms

/WabbitStudio/Branches/Wabbitcode/WinFormsUI/Docking/VS2005DockPaneStrip.cs

#
C# | 1526 lines | 1265 code | 213 blank | 48 comment | 193 complexity | dd38ce480155b2f95ad1358b0dfa2ca2 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

   1using System;
   2using System.Drawing;
   3using System.Drawing.Drawing2D;
   4using System.Windows.Forms;
   5using System.ComponentModel;
   6
   7namespace WeifenLuo.WinFormsUI.Docking
   8{
   9    internal class VS2005DockPaneStrip : DockPaneStripBase
  10    {
  11        private class TabVS2005 : Tab
  12        {
  13            public TabVS2005(IDockContent content)
  14                : base(content)
  15            {
  16            }
  17
  18            private int m_tabX;
  19            public int TabX
  20            {
  21                get { return m_tabX; }
  22                set { m_tabX = value; }
  23            }
  24
  25            private int m_tabWidth;
  26            public int TabWidth
  27            {
  28                get { return m_tabWidth; }
  29                set { m_tabWidth = value; }
  30            }
  31
  32            private int m_maxWidth;
  33            public int MaxWidth
  34            {
  35                get { return m_maxWidth; }
  36                set { m_maxWidth = value; }
  37            }
  38
  39            private bool m_flag;
  40            protected internal bool Flag
  41            {
  42                get { return m_flag; }
  43                set { m_flag = value; }
  44            }
  45        }
  46
  47        protected internal override DockPaneStripBase.Tab CreateTab(IDockContent content)
  48        {
  49            return new TabVS2005(content);
  50        }
  51
  52        private sealed class InertButton : InertButtonBase
  53        {
  54            private Bitmap m_image0, m_image1;
  55
  56            public InertButton(Bitmap image0, Bitmap image1)
  57                : base()
  58            {
  59                m_image0 = image0;
  60                m_image1 = image1;
  61            }
  62
  63            private int m_imageCategory = 0;
  64            public int ImageCategory
  65            {
  66                get { return m_imageCategory; }
  67                set
  68                {
  69                    if (m_imageCategory == value)
  70                        return;
  71
  72                    m_imageCategory = value;
  73                    Invalidate();
  74                }
  75            }
  76
  77            public override Bitmap Image
  78            {
  79                get { return ImageCategory == 0 ? m_image0 : m_image1; }
  80            }
  81        }
  82
  83        #region Constants
  84
  85        private const int _ToolWindowStripGapTop = 0;
  86        private const int _ToolWindowStripGapBottom = 1;
  87        private const int _ToolWindowStripGapLeft = 0;
  88        private const int _ToolWindowStripGapRight = 0;
  89        private const int _ToolWindowImageHeight = 16;
  90        private const int _ToolWindowImageWidth = 16;
  91        private const int _ToolWindowImageGapTop = 3;
  92        private const int _ToolWindowImageGapBottom = 1;
  93        private const int _ToolWindowImageGapLeft = 2;
  94        private const int _ToolWindowImageGapRight = 0;
  95        private const int _ToolWindowTextGapRight = 3;
  96        private const int _ToolWindowTabSeperatorGapTop = 3;
  97        private const int _ToolWindowTabSeperatorGapBottom = 3;
  98
  99        private const int _DocumentStripGapTop = 0;
 100        private const int _DocumentStripGapBottom = 1;
 101        private const int _DocumentTabMaxWidth = 200;
 102        private const int _DocumentButtonGapTop = 4;
 103        private const int _DocumentButtonGapBottom = 4;
 104        private const int _DocumentButtonGapBetween = 0;
 105        private const int _DocumentButtonGapRight = 3;
 106        private const int _DocumentTabGapTop = 3;
 107        private const int _DocumentTabGapLeft = 3;
 108        private const int _DocumentTabGapRight = 3;
 109        private const int _DocumentIconGapBottom = 2;
 110        private const int _DocumentIconGapLeft = 8;
 111        private const int _DocumentIconGapRight = 0;
 112        private const int _DocumentIconHeight = 16;
 113        private const int _DocumentIconWidth = 16;
 114        private const int _DocumentTextGapRight = 3;
 115
 116        #endregion
 117
 118        #region Members
 119
 120        private ContextMenuStrip m_selectMenu;
 121        private static Bitmap m_imageButtonClose;
 122        private InertButton m_buttonClose;
 123        private static Bitmap m_imageButtonWindowList;
 124        private static Bitmap m_imageButtonWindowListOverflow;
 125        private InertButton m_buttonWindowList;
 126        private IContainer m_components;
 127        private ToolTip m_toolTip;
 128        private Font m_font;
 129        private Font m_boldFont;
 130        private int m_startDisplayingTab = 0;
 131        private int m_endDisplayingTab = 0;
 132        private int m_firstDisplayingTab = 0;
 133        private bool m_documentTabsOverflow = false;
 134        private static string m_toolTipSelect;
 135        private static string m_toolTipClose;
 136        private bool m_closeButtonVisible = false;
 137        private int _selectMenuMargin = 5;
 138
 139        #endregion
 140
 141        #region Properties
 142
 143        private Rectangle TabStripRectangle
 144        {
 145            get
 146            {
 147                if (Appearance == DockPane.AppearanceStyle.Document)
 148                    return TabStripRectangle_Document;
 149                else
 150                    return TabStripRectangle_ToolWindow;
 151            }
 152        }
 153
 154        private Rectangle TabStripRectangle_ToolWindow
 155        {
 156            get
 157            {
 158                Rectangle rect = ClientRectangle;
 159                return new Rectangle(rect.X, rect.Top + ToolWindowStripGapTop, rect.Width, rect.Height - ToolWindowStripGapTop - ToolWindowStripGapBottom);
 160            }
 161        }
 162
 163        private Rectangle TabStripRectangle_Document
 164        {
 165            get
 166            {
 167                Rectangle rect = ClientRectangle;
 168                return new Rectangle(rect.X, rect.Top + DocumentStripGapTop, rect.Width, rect.Height - DocumentStripGapTop - ToolWindowStripGapBottom);
 169            }
 170        }
 171
 172        private Rectangle TabsRectangle
 173        {
 174            get
 175            {
 176                if (Appearance == DockPane.AppearanceStyle.ToolWindow)
 177                    return TabStripRectangle;
 178
 179                Rectangle rectWindow = TabStripRectangle;
 180                int x = rectWindow.X;
 181                int y = rectWindow.Y;
 182                int width = rectWindow.Width;
 183                int height = rectWindow.Height;
 184
 185                x += DocumentTabGapLeft;
 186                width -= DocumentTabGapLeft +
 187                    DocumentTabGapRight +
 188                    DocumentButtonGapRight +
 189                    ButtonClose.Width +
 190                    ButtonWindowList.Width +
 191                    2 * DocumentButtonGapBetween;
 192
 193                return new Rectangle(x, y, width, height);
 194            }
 195        }
 196
 197        private ContextMenuStrip SelectMenu
 198        {
 199            get { return m_selectMenu; }
 200        }
 201
 202        public int SelectMenuMargin
 203        {
 204            get { return _selectMenuMargin; }
 205            set { _selectMenuMargin = value; }
 206        }
 207
 208        private static Bitmap ImageButtonClose
 209        {
 210            get
 211            {
 212                if (m_imageButtonClose == null)
 213                    m_imageButtonClose = Resources.DockPane_Close;
 214
 215                return m_imageButtonClose;
 216            }
 217        }
 218
 219        private InertButton ButtonClose
 220        {
 221            get
 222            {
 223                if (m_buttonClose == null)
 224                {
 225                    m_buttonClose = new InertButton(ImageButtonClose, ImageButtonClose);
 226                    m_toolTip.SetToolTip(m_buttonClose, ToolTipClose);
 227                    m_buttonClose.Click += new EventHandler(Close_Click);
 228                    Controls.Add(m_buttonClose);
 229                }
 230
 231                return m_buttonClose;
 232            }
 233        }
 234
 235        private static Bitmap ImageButtonWindowList
 236        {
 237            get
 238            {
 239                if (m_imageButtonWindowList == null)
 240                    m_imageButtonWindowList = Resources.DockPane_Option;
 241
 242                return m_imageButtonWindowList;
 243            }
 244        }
 245
 246        private static Bitmap ImageButtonWindowListOverflow
 247        {
 248            get
 249            {
 250                if (m_imageButtonWindowListOverflow == null)
 251                    m_imageButtonWindowListOverflow = Resources.DockPane_OptionOverflow;
 252
 253                return m_imageButtonWindowListOverflow;
 254            }
 255        }
 256
 257        private InertButton ButtonWindowList
 258        {
 259            get
 260            {
 261                if (m_buttonWindowList == null)
 262                {
 263                    m_buttonWindowList = new InertButton(ImageButtonWindowList, ImageButtonWindowListOverflow);
 264                    m_toolTip.SetToolTip(m_buttonWindowList, ToolTipSelect);
 265                    m_buttonWindowList.Click += new EventHandler(WindowList_Click);
 266                    Controls.Add(m_buttonWindowList);
 267                }
 268
 269                return m_buttonWindowList;
 270            }
 271        }
 272
 273        private static GraphicsPath GraphicsPath
 274        {
 275            get { return VS2005AutoHideStrip.GraphicsPath; }
 276        }
 277
 278        private IContainer Components
 279        {
 280            get { return m_components; }
 281        }
 282
 283        public Font TextFont
 284        {
 285            get { return DockPane.DockPanel.Skin.DockPaneStripSkin.TextFont; }
 286        }
 287
 288        private Font BoldFont
 289        {
 290            get
 291            {
 292                if (IsDisposed)
 293                    return null;
 294
 295                if (m_boldFont == null)
 296                {
 297                    m_font = TextFont;
 298                    m_boldFont = new Font(TextFont, FontStyle.Bold);
 299                }
 300                else if (m_font != TextFont)
 301                {
 302                    m_boldFont.Dispose();
 303                    m_font = TextFont;
 304                    m_boldFont = new Font(TextFont, FontStyle.Bold);
 305                }
 306
 307                return m_boldFont;
 308            }
 309        }
 310
 311        private int StartDisplayingTab
 312        {
 313            get { return m_startDisplayingTab; }
 314            set
 315            {
 316                m_startDisplayingTab = value;
 317                Invalidate();
 318            }
 319        }
 320
 321        private int EndDisplayingTab
 322        {
 323            get { return m_endDisplayingTab; }
 324            set { m_endDisplayingTab = value; }
 325        }
 326
 327        private int FirstDisplayingTab
 328        {
 329            get { return m_firstDisplayingTab; }
 330            set { m_firstDisplayingTab = value; }
 331        }
 332
 333        private bool DocumentTabsOverflow
 334        {
 335            set
 336            {
 337                if (m_documentTabsOverflow == value)
 338                    return;
 339
 340                m_documentTabsOverflow = value;
 341                if (value)
 342                    ButtonWindowList.ImageCategory = 1;
 343                else
 344                    ButtonWindowList.ImageCategory = 0;
 345            }
 346        }
 347
 348        #region Customizable Properties
 349
 350        private static int ToolWindowStripGapTop
 351        {
 352            get { return _ToolWindowStripGapTop; }
 353        }
 354
 355        private static int ToolWindowStripGapBottom
 356        {
 357            get { return _ToolWindowStripGapBottom; }
 358        }
 359
 360        private static int ToolWindowStripGapLeft
 361        {
 362            get { return _ToolWindowStripGapLeft; }
 363        }
 364
 365        private static int ToolWindowStripGapRight
 366        {
 367            get { return _ToolWindowStripGapRight; }
 368        }
 369
 370        private static int ToolWindowImageHeight
 371        {
 372            get { return _ToolWindowImageHeight; }
 373        }
 374
 375        private static int ToolWindowImageWidth
 376        {
 377            get { return _ToolWindowImageWidth; }
 378        }
 379
 380        private static int ToolWindowImageGapTop
 381        {
 382            get { return _ToolWindowImageGapTop; }
 383        }
 384
 385        private static int ToolWindowImageGapBottom
 386        {
 387            get { return _ToolWindowImageGapBottom; }
 388        }
 389
 390        private static int ToolWindowImageGapLeft
 391        {
 392            get { return _ToolWindowImageGapLeft; }
 393        }
 394
 395        private static int ToolWindowImageGapRight
 396        {
 397            get { return _ToolWindowImageGapRight; }
 398        }
 399
 400        private static int ToolWindowTextGapRight
 401        {
 402            get { return _ToolWindowTextGapRight; }
 403        }
 404
 405        private static int ToolWindowTabSeperatorGapTop
 406        {
 407            get { return _ToolWindowTabSeperatorGapTop; }
 408        }
 409
 410        private static int ToolWindowTabSeperatorGapBottom
 411        {
 412            get { return _ToolWindowTabSeperatorGapBottom; }
 413        }
 414
 415        private static string ToolTipClose
 416        {
 417            get
 418            {
 419                if (m_toolTipClose == null)
 420                    m_toolTipClose = Strings.DockPaneStrip_ToolTipClose;
 421                return m_toolTipClose;
 422            }
 423        }
 424
 425        private static string ToolTipSelect
 426        {
 427            get
 428            {
 429                if (m_toolTipSelect == null)
 430                    m_toolTipSelect = Strings.DockPaneStrip_ToolTipWindowList;
 431                return m_toolTipSelect;
 432            }
 433        }
 434
 435        private TextFormatFlags ToolWindowTextFormat
 436        {
 437            get
 438            {
 439                TextFormatFlags textFormat = TextFormatFlags.EndEllipsis |
 440                    TextFormatFlags.HorizontalCenter |
 441                    TextFormatFlags.SingleLine |
 442                    TextFormatFlags.VerticalCenter;
 443                if (RightToLeft == RightToLeft.Yes)
 444                    return textFormat | TextFormatFlags.RightToLeft | TextFormatFlags.Right;
 445                else
 446                    return textFormat;
 447            }
 448        }
 449
 450        private static int DocumentStripGapTop
 451        {
 452            get { return _DocumentStripGapTop; }
 453        }
 454
 455        private static int DocumentStripGapBottom
 456        {
 457            get { return _DocumentStripGapBottom; }
 458        }
 459
 460        private TextFormatFlags DocumentTextFormat
 461        {
 462            get
 463            {
 464                TextFormatFlags textFormat = TextFormatFlags.EndEllipsis |
 465                    TextFormatFlags.SingleLine |
 466                    TextFormatFlags.VerticalCenter |
 467                    TextFormatFlags.HorizontalCenter;
 468                if (RightToLeft == RightToLeft.Yes)
 469                    return textFormat | TextFormatFlags.RightToLeft;
 470                else
 471                    return textFormat;
 472            }
 473        }
 474
 475        private static int DocumentTabMaxWidth
 476        {
 477            get { return _DocumentTabMaxWidth; }
 478        }
 479
 480        private static int DocumentButtonGapTop
 481        {
 482            get { return _DocumentButtonGapTop; }
 483        }
 484
 485        private static int DocumentButtonGapBottom
 486        {
 487            get { return _DocumentButtonGapBottom; }
 488        }
 489
 490        private static int DocumentButtonGapBetween
 491        {
 492            get { return _DocumentButtonGapBetween; }
 493        }
 494
 495        private static int DocumentButtonGapRight
 496        {
 497            get { return _DocumentButtonGapRight; }
 498        }
 499
 500        private static int DocumentTabGapTop
 501        {
 502            get { return _DocumentTabGapTop; }
 503        }
 504
 505        private static int DocumentTabGapLeft
 506        {
 507            get { return _DocumentTabGapLeft; }
 508        }
 509
 510        private static int DocumentTabGapRight
 511        {
 512            get { return _DocumentTabGapRight; }
 513        }
 514
 515        private static int DocumentIconGapBottom
 516        {
 517            get { return _DocumentIconGapBottom; }
 518        }
 519
 520        private static int DocumentIconGapLeft
 521        {
 522            get { return _DocumentIconGapLeft; }
 523        }
 524
 525        private static int DocumentIconGapRight
 526        {
 527            get { return _DocumentIconGapRight; }
 528        }
 529
 530        private static int DocumentIconWidth
 531        {
 532            get { return _DocumentIconWidth; }
 533        }
 534
 535        private static int DocumentIconHeight
 536        {
 537            get { return _DocumentIconHeight; }
 538        }
 539
 540        private static int DocumentTextGapRight
 541        {
 542            get { return _DocumentTextGapRight; }
 543        }
 544
 545        private static Pen PenToolWindowTabBorder
 546        {
 547            get { return SystemPens.GrayText; }
 548        }
 549
 550        private static Pen PenDocumentTabActiveBorder
 551        {
 552            get { return SystemPens.ControlDarkDark; }
 553        }
 554
 555        private static Pen PenDocumentTabInactiveBorder
 556        {
 557            get { return SystemPens.GrayText; }
 558        }
 559
 560        #endregion
 561
 562        #endregion
 563
 564        public VS2005DockPaneStrip(DockPane pane)
 565            : base(pane)
 566        {
 567            SetStyle(ControlStyles.ResizeRedraw |
 568                ControlStyles.UserPaint |
 569                ControlStyles.AllPaintingInWmPaint |
 570                ControlStyles.OptimizedDoubleBuffer, true);
 571
 572            SuspendLayout();
 573
 574            m_components = new Container();
 575            m_toolTip = new ToolTip(Components);
 576            m_selectMenu = new ContextMenuStrip(Components);
 577
 578            ResumeLayout();
 579        }
 580
 581        protected override void Dispose(bool disposing)
 582        {
 583            if (disposing)
 584            {
 585                Components.Dispose();
 586                if (m_boldFont != null)
 587                {
 588                    m_boldFont.Dispose();
 589                    m_boldFont = null;
 590                }
 591            }
 592            base.Dispose(disposing);
 593        }
 594
 595        protected internal override int MeasureHeight()
 596        {
 597            if (Appearance == DockPane.AppearanceStyle.ToolWindow)
 598                return MeasureHeight_ToolWindow();
 599            else
 600                return MeasureHeight_Document();
 601        }
 602
 603        private int MeasureHeight_ToolWindow()
 604        {
 605            if (DockPane.IsAutoHide || Tabs.Count <= 1)
 606                return 0;
 607
 608            int height = Math.Max(TextFont.Height, ToolWindowImageHeight + ToolWindowImageGapTop + ToolWindowImageGapBottom)
 609                + ToolWindowStripGapTop + ToolWindowStripGapBottom;
 610
 611            return height;
 612        }
 613
 614        private int MeasureHeight_Document()
 615        {
 616            int height = Math.Max(TextFont.Height + DocumentTabGapTop,
 617                ButtonClose.Height + DocumentButtonGapTop + DocumentButtonGapBottom)
 618                + DocumentStripGapBottom + DocumentStripGapTop;
 619
 620            return height;
 621        }
 622
 623        protected override void OnPaint(PaintEventArgs e)
 624        {
 625            Rectangle rect = TabsRectangle;
 626
 627            if (Appearance == DockPane.AppearanceStyle.Document)
 628            {
 629                rect.X -= DocumentTabGapLeft;
 630
 631                // Add these values back in so that the DockStrip color is drawn
 632                // beneath the close button and window list button.
 633                rect.Width += DocumentTabGapLeft +
 634                    DocumentTabGapRight +
 635                    DocumentButtonGapRight +
 636                    ButtonClose.Width +
 637                    ButtonWindowList.Width;
 638
 639                // It is possible depending on the DockPanel DocumentStyle to have
 640                // a Document without a DockStrip.
 641                if (rect.Width > 0 && rect.Height > 0)
 642                {
 643                    Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.StartColor;
 644                    Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.EndColor;
 645                    LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.DocumentGradient.DockStripGradient.LinearGradientMode;
 646                    using (LinearGradientBrush brush = new LinearGradientBrush(rect, startColor, endColor, gradientMode))
 647                    {
 648                        e.Graphics.FillRectangle(brush, rect);
 649                    }
 650                }
 651            }
 652            else
 653            {
 654                Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.StartColor;
 655                Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.EndColor;
 656                LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.DockStripGradient.LinearGradientMode;
 657                using (LinearGradientBrush brush = new LinearGradientBrush(rect, startColor, endColor, gradientMode))
 658                {
 659                    e.Graphics.FillRectangle(brush, rect);
 660                }
 661            }
 662            base.OnPaint(e);
 663            CalculateTabs();
 664            if (Appearance == DockPane.AppearanceStyle.Document && DockPane.ActiveContent != null)
 665            {
 666                if (EnsureDocumentTabVisible(DockPane.ActiveContent, false))
 667                    CalculateTabs();
 668            }
 669
 670            DrawTabStrip(e.Graphics);
 671        }
 672
 673        protected override void OnRefreshChanges()
 674        {
 675            SetInertButtons();
 676            Invalidate();
 677        }
 678
 679        protected internal override GraphicsPath GetOutline(int index)
 680        {
 681
 682            if (Appearance == DockPane.AppearanceStyle.Document)
 683                return GetOutline_Document(index);
 684            else
 685                return GetOutline_ToolWindow(index);
 686
 687        }
 688
 689        private GraphicsPath GetOutline_Document(int index)
 690        {
 691            Rectangle rectTab = GetTabRectangle(index);
 692            rectTab.X -= rectTab.Height / 2;
 693            rectTab.Intersect(TabsRectangle);
 694            rectTab = RectangleToScreen(DrawHelper.RtlTransform(this, rectTab));
 695            Rectangle rectPaneClient = DockPane.RectangleToScreen(DockPane.ClientRectangle);
 696
 697            GraphicsPath path = new GraphicsPath();
 698            GraphicsPath pathTab = GetTabOutline_Document(Tabs[index], true, true, true);
 699            path.AddPath(pathTab, true);
 700
 701            if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom)
 702            {
 703                path.AddLine(rectTab.Right, rectTab.Top, rectPaneClient.Right, rectTab.Top);
 704                path.AddLine(rectPaneClient.Right, rectTab.Top, rectPaneClient.Right, rectPaneClient.Top);
 705                path.AddLine(rectPaneClient.Right, rectPaneClient.Top, rectPaneClient.Left, rectPaneClient.Top);
 706                path.AddLine(rectPaneClient.Left, rectPaneClient.Top, rectPaneClient.Left, rectTab.Top);
 707                path.AddLine(rectPaneClient.Left, rectTab.Top, rectTab.Right, rectTab.Top);
 708            }
 709            else
 710            {
 711                path.AddLine(rectTab.Right, rectTab.Bottom, rectPaneClient.Right, rectTab.Bottom);
 712                path.AddLine(rectPaneClient.Right, rectTab.Bottom, rectPaneClient.Right, rectPaneClient.Bottom);
 713                path.AddLine(rectPaneClient.Right, rectPaneClient.Bottom, rectPaneClient.Left, rectPaneClient.Bottom);
 714                path.AddLine(rectPaneClient.Left, rectPaneClient.Bottom, rectPaneClient.Left, rectTab.Bottom);
 715                path.AddLine(rectPaneClient.Left, rectTab.Bottom, rectTab.Right, rectTab.Bottom);
 716            }
 717            return path;
 718        }
 719
 720        private GraphicsPath GetOutline_ToolWindow(int index)
 721        {
 722            Rectangle rectTab = GetTabRectangle(index);
 723            rectTab.Intersect(TabsRectangle);
 724            rectTab = RectangleToScreen(DrawHelper.RtlTransform(this, rectTab));
 725            Rectangle rectPaneClient = DockPane.RectangleToScreen(DockPane.ClientRectangle);
 726
 727            GraphicsPath path = new GraphicsPath();
 728            GraphicsPath pathTab = GetTabOutline(Tabs[index], true, true);
 729            path.AddPath(pathTab, true);
 730            path.AddLine(rectTab.Left, rectTab.Top, rectPaneClient.Left, rectTab.Top);
 731            path.AddLine(rectPaneClient.Left, rectTab.Top, rectPaneClient.Left, rectPaneClient.Top);
 732            path.AddLine(rectPaneClient.Left, rectPaneClient.Top, rectPaneClient.Right, rectPaneClient.Top);
 733            path.AddLine(rectPaneClient.Right, rectPaneClient.Top, rectPaneClient.Right, rectTab.Top);
 734            path.AddLine(rectPaneClient.Right, rectTab.Top, rectTab.Right, rectTab.Top);
 735            return path;
 736        }
 737
 738        private void CalculateTabs()
 739        {
 740            if (Appearance == DockPane.AppearanceStyle.ToolWindow)
 741                CalculateTabs_ToolWindow();
 742            else
 743                CalculateTabs_Document();
 744        }
 745
 746        private void CalculateTabs_ToolWindow()
 747        {
 748            if (Tabs.Count <= 1 || DockPane.IsAutoHide)
 749                return;
 750
 751            Rectangle rectTabStrip = TabStripRectangle;
 752
 753            // Calculate tab widths
 754            int countTabs = Tabs.Count;
 755            foreach (TabVS2005 tab in Tabs)
 756            {
 757                tab.MaxWidth = GetMaxTabWidth(Tabs.IndexOf(tab));
 758                tab.Flag = false;
 759            }
 760
 761            // Set tab whose max width less than average width
 762            bool anyWidthWithinAverage = true;
 763            int totalWidth = rectTabStrip.Width - ToolWindowStripGapLeft - ToolWindowStripGapRight;
 764            int totalAllocatedWidth = 0;
 765            int averageWidth = totalWidth / countTabs;
 766            int remainedTabs = countTabs;
 767            for (anyWidthWithinAverage = true; anyWidthWithinAverage && remainedTabs > 0; )
 768            {
 769                anyWidthWithinAverage = false;
 770                foreach (TabVS2005 tab in Tabs)
 771                {
 772                    if (tab.Flag)
 773                        continue;
 774
 775                    if (tab.MaxWidth <= averageWidth)
 776                    {
 777                        tab.Flag = true;
 778                        tab.TabWidth = tab.MaxWidth;
 779                        totalAllocatedWidth += tab.TabWidth;
 780                        anyWidthWithinAverage = true;
 781                        remainedTabs--;
 782                    }
 783                }
 784                if (remainedTabs != 0)
 785                    averageWidth = (totalWidth - totalAllocatedWidth) / remainedTabs;
 786            }
 787
 788            // If any tab width not set yet, set it to the average width
 789            if (remainedTabs > 0)
 790            {
 791                int roundUpWidth = (totalWidth - totalAllocatedWidth) - (averageWidth * remainedTabs);
 792                foreach (TabVS2005 tab in Tabs)
 793                {
 794                    if (tab.Flag)
 795                        continue;
 796
 797                    tab.Flag = true;
 798                    if (roundUpWidth > 0)
 799                    {
 800                        tab.TabWidth = averageWidth + 1;
 801                        roundUpWidth--;
 802                    }
 803                    else
 804                        tab.TabWidth = averageWidth;
 805                }
 806            }
 807
 808            // Set the X position of the tabs
 809            int x = rectTabStrip.X + ToolWindowStripGapLeft;
 810            foreach (TabVS2005 tab in Tabs)
 811            {
 812                tab.TabX = x;
 813                x += tab.TabWidth;
 814            }
 815        }
 816
 817        private bool CalculateDocumentTab(Rectangle rectTabStrip, ref int x, int index)
 818        {
 819            bool overflow = false;
 820
 821            TabVS2005 tab = Tabs[index] as TabVS2005;
 822            tab.MaxWidth = GetMaxTabWidth(index);
 823            int width = Math.Min(tab.MaxWidth, DocumentTabMaxWidth);
 824            if (x + width < rectTabStrip.Right || index == StartDisplayingTab)
 825            {
 826                tab.TabX = x;
 827                tab.TabWidth = width;
 828                EndDisplayingTab = index;
 829            }
 830            else
 831            {
 832                tab.TabX = 0;
 833                tab.TabWidth = 0;
 834                overflow = true;
 835            }
 836            x += width;
 837
 838            return overflow;
 839        }
 840
 841        /// <summary>
 842        /// Calculate which tabs are displayed and in what order.
 843        /// </summary>
 844        private void CalculateTabs_Document()
 845        {
 846            if (m_startDisplayingTab >= Tabs.Count)
 847                m_startDisplayingTab = 0;
 848
 849            Rectangle rectTabStrip = TabsRectangle;
 850
 851            int x = rectTabStrip.X + rectTabStrip.Height / 2;
 852            bool overflow = false;
 853
 854            // Originally all new documents that were considered overflow
 855            // (not enough pane strip space to show all tabs) were added to
 856            // the far left (assuming not right to left) and the tabs on the
 857            // right were dropped from view. If StartDisplayingTab is not 0
 858            // then we are dealing with making sure a specific tab is kept in focus.
 859            if (m_startDisplayingTab > 0)
 860            {
 861                int tempX = x;
 862                TabVS2005 tab = Tabs[m_startDisplayingTab] as TabVS2005;
 863                tab.MaxWidth = GetMaxTabWidth(m_startDisplayingTab);
 864
 865                // Add the active tab and tabs to the left
 866                for (int i = StartDisplayingTab; i >= 0; i--)
 867                    CalculateDocumentTab(rectTabStrip, ref tempX, i);
 868
 869                // Store which tab is the first one displayed so that it
 870                // will be drawn correctly (without part of the tab cut off)
 871                FirstDisplayingTab = EndDisplayingTab;
 872
 873                tempX = x; // Reset X location because we are starting over
 874
 875                // Start with the first tab displayed - name is a little misleading.
 876                // Loop through each tab and set its location. If there is not enough
 877                // room for all of them overflow will be returned.
 878                for (int i = EndDisplayingTab; i < Tabs.Count; i++)
 879                    overflow = CalculateDocumentTab(rectTabStrip, ref tempX, i);
 880
 881                // If not all tabs are shown then we have an overflow.
 882                if (FirstDisplayingTab != 0)
 883                    overflow = true;
 884            }
 885            else
 886            {
 887                for (int i = StartDisplayingTab; i < Tabs.Count; i++)
 888                    overflow = CalculateDocumentTab(rectTabStrip, ref x, i);
 889                for (int i = 0; i < StartDisplayingTab; i++)
 890                    overflow = CalculateDocumentTab(rectTabStrip, ref x, i);
 891
 892                FirstDisplayingTab = StartDisplayingTab;
 893            }
 894
 895            if (!overflow)
 896            {
 897                m_startDisplayingTab = 0;
 898                FirstDisplayingTab = 0;
 899                x = rectTabStrip.X + rectTabStrip.Height / 2;
 900                foreach (TabVS2005 tab in Tabs)
 901                {
 902                    tab.TabX = x;
 903                    x += tab.TabWidth;
 904                }
 905            }
 906            DocumentTabsOverflow = overflow;
 907        }
 908
 909        protected internal override void EnsureTabVisible(IDockContent content)
 910        {
 911            if (Appearance != DockPane.AppearanceStyle.Document || !Tabs.Contains(content))
 912                return;
 913
 914            CalculateTabs();
 915            EnsureDocumentTabVisible(content, true);
 916        }
 917
 918        private bool EnsureDocumentTabVisible(IDockContent content, bool repaint)
 919        {
 920            int index = Tabs.IndexOf(content);
 921            TabVS2005 tab = Tabs[index] as TabVS2005;
 922            if (tab.TabWidth != 0)
 923                return false;
 924
 925            StartDisplayingTab = index;
 926            if (repaint)
 927                Invalidate();
 928
 929            return true;
 930        }
 931
 932        private int GetMaxTabWidth(int index)
 933        {
 934            if (Appearance == DockPane.AppearanceStyle.ToolWindow)
 935                return GetMaxTabWidth_ToolWindow(index);
 936            else
 937                return GetMaxTabWidth_Document(index);
 938        }
 939
 940        private int GetMaxTabWidth_ToolWindow(int index)
 941        {
 942            IDockContent content = Tabs[index].Content;
 943            Size sizeString = TextRenderer.MeasureText(content.DockHandler.TabText, TextFont);
 944            return ToolWindowImageWidth + sizeString.Width + ToolWindowImageGapLeft
 945                + ToolWindowImageGapRight + ToolWindowTextGapRight;
 946        }
 947
 948        private int GetMaxTabWidth_Document(int index)
 949        {
 950            IDockContent content = Tabs[index].Content;
 951
 952            int height = GetTabRectangle_Document(index).Height;
 953
 954            Size sizeText = TextRenderer.MeasureText(content.DockHandler.TabText, BoldFont, new Size(DocumentTabMaxWidth, height), DocumentTextFormat);
 955
 956            if (DockPane.DockPanel.ShowDocumentIcon)
 957                return sizeText.Width + DocumentIconWidth + DocumentIconGapLeft + DocumentIconGapRight + DocumentTextGapRight;
 958            else
 959                return sizeText.Width + DocumentIconGapLeft + DocumentTextGapRight;
 960        }
 961
 962        private void DrawTabStrip(Graphics g)
 963        {
 964            if (Appearance == DockPane.AppearanceStyle.Document)
 965                DrawTabStrip_Document(g);
 966            else
 967                DrawTabStrip_ToolWindow(g);
 968        }
 969
 970        private void DrawTabStrip_Document(Graphics g)
 971        {
 972            int count = Tabs.Count;
 973            if (count == 0)
 974                return;
 975
 976            Rectangle rectTabStrip = TabStripRectangle;
 977
 978            // Draw the tabs
 979            Rectangle rectTabOnly = TabsRectangle;
 980            Rectangle rectTab = Rectangle.Empty;
 981            TabVS2005 tabActive = null;
 982            g.SetClip(DrawHelper.RtlTransform(this, rectTabOnly));
 983            for (int i = 0; i < count; i++)
 984            {
 985                rectTab = GetTabRectangle(i);
 986                if (Tabs[i].Content == DockPane.ActiveContent)
 987                {
 988                    tabActive = Tabs[i] as TabVS2005;
 989                    continue;
 990                }
 991                if (rectTab.IntersectsWith(rectTabOnly))
 992                    DrawTab(g, Tabs[i] as TabVS2005, rectTab);
 993            }
 994
 995            g.SetClip(rectTabStrip);
 996
 997            if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom)
 998                g.DrawLine(PenDocumentTabActiveBorder, rectTabStrip.Left, rectTabStrip.Top + 1,
 999                    rectTabStrip.Right, rectTabStrip.Top + 1);
1000            else
1001                g.DrawLine(PenDocumentTabActiveBorder, rectTabStrip.Left, rectTabStrip.Bottom - 1,
1002                    rectTabStrip.Right, rectTabStrip.Bottom - 1);
1003
1004            g.SetClip(DrawHelper.RtlTransform(this, rectTabOnly));
1005            if (tabActive != null)
1006            {
1007                rectTab = GetTabRectangle(Tabs.IndexOf(tabActive));
1008                if (rectTab.IntersectsWith(rectTabOnly))
1009                {
1010                    rectTab.Intersect(rectTabOnly);
1011                    DrawTab(g, tabActive, rectTab);
1012                }
1013            }
1014        }
1015
1016        private void DrawTabStrip_ToolWindow(Graphics g)
1017        {
1018            Rectangle rectTabStrip = TabStripRectangle;
1019
1020            g.DrawLine(PenToolWindowTabBorder, rectTabStrip.Left, rectTabStrip.Top,
1021                rectTabStrip.Right, rectTabStrip.Top);
1022
1023            for (int i = 0; i < Tabs.Count; i++)
1024                DrawTab(g, Tabs[i] as TabVS2005, GetTabRectangle(i));
1025        }
1026
1027        private Rectangle GetTabRectangle(int index)
1028        {
1029            if (Appearance == DockPane.AppearanceStyle.ToolWindow)
1030                return GetTabRectangle_ToolWindow(index);
1031            else
1032                return GetTabRectangle_Document(index);
1033        }
1034
1035        private Rectangle GetTabRectangle_ToolWindow(int index)
1036        {
1037            Rectangle rectTabStrip = TabStripRectangle;
1038
1039            TabVS2005 tab = (TabVS2005)(Tabs[index]);
1040            return new Rectangle(tab.TabX, rectTabStrip.Y, tab.TabWidth, rectTabStrip.Height);
1041        }
1042
1043        private Rectangle GetTabRectangle_Document(int index)
1044        {
1045            Rectangle rectTabStrip = TabStripRectangle;
1046            TabVS2005 tab = (TabVS2005)Tabs[index];
1047
1048            Rectangle rect = new Rectangle();
1049            rect.X = tab.TabX;
1050            rect.Width = tab.TabWidth;
1051            rect.Height = rectTabStrip.Height - DocumentTabGapTop;
1052
1053            if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom)
1054                rect.Y = rectTabStrip.Y + DocumentStripGapBottom;
1055            else
1056                rect.Y = rectTabStrip.Y + DocumentTabGapTop;
1057
1058            return rect;
1059        }
1060
1061        private void DrawTab(Graphics g, TabVS2005 tab, Rectangle rect)
1062        {
1063            if (Appearance == DockPane.AppearanceStyle.ToolWindow)
1064                DrawTab_ToolWindow(g, tab, rect);
1065            else
1066                DrawTab_Document(g, tab, rect);
1067        }
1068
1069        private GraphicsPath GetTabOutline(Tab tab, bool rtlTransform, bool toScreen)
1070        {
1071            if (Appearance == DockPane.AppearanceStyle.ToolWindow)
1072                return GetTabOutline_ToolWindow(tab, rtlTransform, toScreen);
1073            else
1074                return GetTabOutline_Document(tab, rtlTransform, toScreen, false);
1075        }
1076
1077        private GraphicsPath GetTabOutline_ToolWindow(Tab tab, bool rtlTransform, bool toScreen)
1078        {
1079            Rectangle rect = GetTabRectangle(Tabs.IndexOf(tab));
1080            if (rtlTransform)
1081                rect = DrawHelper.RtlTransform(this, rect);
1082            if (toScreen)
1083                rect = RectangleToScreen(rect);
1084
1085            DrawHelper.GetRoundedCornerTab(GraphicsPath, rect, false);
1086            return GraphicsPath;
1087        }
1088
1089        private GraphicsPath GetTabOutline_Document(Tab tab, bool rtlTransform, bool toScreen, bool full)
1090        {
1091            int curveSize = 6;
1092
1093            GraphicsPath.Reset();
1094            Rectangle rect = GetTabRectangle(Tabs.IndexOf(tab));
1095            
1096            // Shorten TabOutline so it doesn't get overdrawn by icons next to it
1097            rect.Intersect(TabsRectangle);
1098            rect.Width--;
1099
1100            if (rtlTransform)
1101                rect = DrawHelper.RtlTransform(this, rect);
1102            if (toScreen)
1103                rect = RectangleToScreen(rect);
1104
1105            // Draws the full angle piece for active content (or first tab)
1106            if (tab.Content == DockPane.ActiveContent || full || Tabs.IndexOf(tab) == FirstDisplayingTab)
1107            {
1108                if (RightToLeft == RightToLeft.Yes)
1109                {
1110                    if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom)
1111                    {
1112                        // For some reason the next line draws a line that is not hidden like it is when drawing the tab strip on top.
1113                        // It is not needed so it has been commented out.
1114                        //GraphicsPath.AddLine(rect.Right, rect.Bottom, rect.Right + rect.Height / 2, rect.Bottom);
1115                        GraphicsPath.AddLine(rect.Right + rect.Height / 2, rect.Top, rect.Right - rect.Height / 2 + curveSize / 2, rect.Bottom - curveSize / 2);
1116                    }
1117                    else
1118                    {
1119                        GraphicsPath.AddLine(rect.Right, rect.Bottom, rect.Right + rect.Height / 2, rect.Bottom);
1120                        GraphicsPath.AddLine(rect.Right + rect.Height / 2, rect.Bottom, rect.Right - rect.Height / 2 + curveSize / 2, rect.Top + curveSize / 2);
1121                    }
1122                }
1123                else
1124                {
1125                    if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom)
1126                    {
1127                        // For some reason the next line draws a line that is not hidden like it is when drawing the tab strip on top.
1128                        // It is not needed so it has been commented out.
1129                        //GraphicsPath.AddLine(rect.Left, rect.Top, rect.Left - rect.Height / 2, rect.Top);
1130                        GraphicsPath.AddLine(rect.Left - rect.Height / 2, rect.Top, rect.Left + rect.Height / 2 - curveSize / 2, rect.Bottom - curveSize / 2);
1131                    }
1132                    else
1133                    {
1134                        GraphicsPath.AddLine(rect.Left, rect.Bottom, rect.Left - rect.Height / 2, rect.Bottom);
1135                        GraphicsPath.AddLine(rect.Left - rect.Height / 2, rect.Bottom, rect.Left + rect.Height / 2 - curveSize / 2, rect.Top + curveSize / 2);
1136                    }
1137                }
1138            }
1139            // Draws the partial angle for non-active content
1140            else
1141            {
1142                if (RightToLeft == RightToLeft.Yes)
1143                {
1144                    if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom)
1145                    {
1146                        GraphicsPath.AddLine(rect.Right, rect.Top, rect.Right, rect.Top + rect.Height / 2);
1147                        GraphicsPath.AddLine(rect.Right, rect.Top + rect.Height / 2, rect.Right - rect.Height / 2 + curveSize / 2, rect.Bottom - curveSize / 2);
1148                    }
1149                    else
1150                    {
1151                        GraphicsPath.AddLine(rect.Right, rect.Bottom, rect.Right, rect.Bottom - rect.Height / 2);
1152                        GraphicsPath.AddLine(rect.Right, rect.Bottom - rect.Height / 2, rect.Right - rect.Height / 2 + curveSize / 2, rect.Top + curveSize / 2);
1153                    }
1154                }
1155                else
1156                {
1157                    if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom)
1158                    {
1159                        GraphicsPath.AddLine(rect.Left, rect.Top, rect.Left, rect.Top + rect.Height / 2);
1160                        GraphicsPath.AddLine(rect.Left, rect.Top + rect.Height / 2, rect.Left + rect.Height / 2 - curveSize / 2, rect.Bottom - curveSize / 2);
1161                    }
1162                    else
1163                    {
1164                        GraphicsPath.AddLine(rect.Left, rect.Bottom, rect.Left, rect.Bottom - rect.Height / 2);
1165                        GraphicsPath.AddLine(rect.Left, rect.Bottom - rect.Height / 2, rect.Left + rect.Height / 2 - curveSize / 2, rect.Top + curveSize / 2);
1166                    }
1167                }
1168            }
1169
1170            if (RightToLeft == RightToLeft.Yes)
1171            {
1172                if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom)
1173                {
1174                    // Draws the bottom horizontal line (short side)
1175                    GraphicsPath.AddLine(rect.Right - rect.Height / 2 - curveSize / 2, rect.Bottom, rect.Left + curveSize / 2, rect.Bottom);
1176
1177                    // Drawing the rounded corner is not necessary. The path is automatically connected
1178                    //GraphicsPath.AddArc(new Rectangle(rect.Left, rect.Top, curveSize, curveSize), 180, 90);
1179                }
1180                else
1181                {
1182                    // Draws the bottom horizontal line (short side)
1183                    GraphicsPath.AddLine(rect.Right - rect.Height / 2 - curveSize / 2, rect.Top, rect.Left + curveSize / 2, rect.Top);
1184                    GraphicsPath.AddArc(new Rectangle(rect.Left, rect.Top, curveSize, curveSize), 180, 90);
1185                }
1186            }
1187            else
1188            {
1189                if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom)
1190                {
1191                    // Draws the bottom horizontal line (short side)
1192                    GraphicsPath.AddLine(rect.Left + rect.Height / 2 + curveSize / 2, rect.Bottom, rect.Right - curveSize / 2, rect.Bottom);
1193
1194                    // Drawing the rounded corner is not necessary. The path is automatically connected
1195                    //GraphicsPath.AddArc(new Rectangle(rect.Right - curveSize, rect.Bottom, curveSize, curveSize), 90, -90);
1196                }
1197                else
1198                {
1199                    // Draws the top horizontal line (short side)
1200                    GraphicsPath.AddLine(rect.Left + rect.Height / 2 + curveSize / 2, rect.Top, rect.Right - curveSize / 2, rect.Top);
1201
1202                    // Draws the rounded corner oppposite the angled side
1203                    GraphicsPath.AddArc(new Rectangle(rect.Right - curveSize, rect.Top, curveSize, curveSize), -90, 90);
1204                }
1205            }
1206
1207            if (Tabs.IndexOf(tab) != EndDisplayingTab &&
1208                (Tabs.IndexOf(tab) != Tabs.Count - 1 && Tabs[Tabs.IndexOf(tab) + 1].Content == DockPane.ActiveContent)
1209                && !full)
1210            {
1211                if (RightToLeft == RightToLeft.Yes)
1212                {
1213                    if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom)
1214                    {
1215                        GraphicsPath.AddLine(rect.Left, rect.Bottom - curveSize / 2, rect.Left, rect.Bottom - rect.Height / 2);
1216                        GraphicsPath.AddLine(rect.Left, rect.Bottom - rect.Height / 2, rect.Left + rect.Height / 2, rect.Top);
1217                    }
1218                    else
1219                    {
1220                        GraphicsPath.AddLine(rect.Left, rect.Top + curveSize / 2, rect.Left, rect.Top + rect.Height / 2);
1221                        GraphicsPath.AddLine(rect.Left, rect.Top + rect.Height / 2, rect.Left + rect.Height / 2, rect.Bottom);
1222                    }
1223                }
1224                else
1225                {
1226                    if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom)
1227                    {
1228                        GraphicsPath.AddLine(rect.Right, rect.Bottom - curveSize / 2, rect.Right, rect.Bottom - rect.Height / 2);
1229                        GraphicsPath.AddLine(rect.Right, rect.Bottom - rect.Height / 2, rect.Right - rect.Height / 2, rect.Top);
1230                    }
1231                    else
1232                    {
1233                        GraphicsPath.AddLine(rect.Right, rect.Top + curveSize / 2, rect.Right, rect.Top + rect.Height / 2);
1234                        GraphicsPath.AddLine(rect.Right, rect.Top + rect.Height / 2, rect.Right - rect.Height / 2, rect.Bottom);
1235                    }
1236                }
1237            }
1238            else
1239            {
1240                // Draw the vertical line opposite the angled side
1241                if (RightToLeft == RightToLeft.Yes)
1242                {
1243                    if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom)
1244                        GraphicsPath.AddLine(rect.Left, rect.Bottom - curveSize / 2, rect.Left, rect.Top);
1245                    else
1246                        GraphicsPath.AddLine(rect.Left, rect.Top + curveSize / 2, rect.Left, rect.Bottom);
1247                }
1248                else
1249                {
1250                    if (DockPane.DockPanel.DocumentTabStripLocation == DocumentTabStripLocation.Bottom)
1251                        GraphicsPath.AddLine(rect.Right, rect.Bottom - curveSize / 2, rect.Right, rect.Top);
1252                    else
1253                        GraphicsPath.AddLine(rect.Right, rect.Top + curveSize / 2, rect.Right, rect.Bottom);
1254                }
1255            }
1256
1257            return GraphicsPath;
1258        }
1259
1260        private void DrawTab_ToolWindow(Graphics g, TabVS2005 tab, Rectangle rect)
1261        {
1262            Rectangle rectIcon = new Rectangle(
1263                rect.X + ToolWindowImageGapLeft,
1264                rect.Y + rect.Height - 1 - ToolWindowImageGapBottom - ToolWindowImageHeight,
1265                ToolWindowImageWidth, ToolWindowImageHeight);
1266            Rectangle rectText = rectIcon;
1267            rectText.X += rectIcon.Width + ToolWindowImageGapRight;
1268            rectText.Width = rect.Width - rectIcon.Width - ToolWindowImageGapLeft -
1269                ToolWindowImageGapRight - ToolWindowTextGapRight;
1270
1271            Rectangle rectTab = DrawHelper.RtlTransform(this, rect);
1272            rectText = DrawHelper.RtlTransform(this, rectText);
1273            rectIcon = DrawHelper.RtlTransform(this, rectIcon);
1274            GraphicsPath path = GetTabOutline(tab, true, false);
1275            if (DockPane.ActiveContent == tab.Content)
1276            {
1277                Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.StartColor;
1278                Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.EndColor;
1279                LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.LinearGradientMode;
1280                g.FillPath(new LinearGradientBrush(rectTab, startColor, endColor, gradientMode), path);
1281                g.DrawPath(PenToolWindowTabBorder, path);
1282
1283                Color textColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.ActiveTabGradient.TextColor;
1284                TextRenderer.DrawText(g, tab.Content.DockHandler.TabText, TextFont, rectText, textColor, ToolWindowTextFormat);
1285            }
1286            else
1287            {
1288                Color startColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.StartColor;
1289                Color endColor = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.EndColor;
1290                LinearGradientMode gradientMode = DockPane.DockPanel.Skin.DockPaneStripSkin.ToolWindowGradient.InactiveTabGradient.LinearGradientMode;
1291                g.FillPath(new LinearGradientBrush(rectTab, startColor, endColor, gradientMode), path);
1292
1293                if (Tabs.IndexOf(DockPane.ActiveContent) != Tabs.IndexOf(tab) + 1)
1294                {
1295                    Point pt1 = new 

Large files files are truncated, but you can click here to view the full file