From e9092c2e7956c18c429a1449e9bec4dc60eed3aa Mon Sep 17 00:00:00 2001 From: hirus <11228152+h1ru5@users.noreply.github.com> Date: Mon, 22 Jul 2019 14:44:24 +0000 Subject: [PATCH 1/2] added no closer on first N tabs --- TabControlExtra/TabControl/TabControlExtra.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/TabControlExtra/TabControl/TabControlExtra.cs b/TabControlExtra/TabControl/TabControlExtra.cs index a0b7f83..54462a5 100644 --- a/TabControlExtra/TabControl/TabControlExtra.cs +++ b/TabControlExtra/TabControl/TabControlExtra.cs @@ -1,4 +1,4 @@ -/* +/* * This code is provided under the Code Project Open Licence (CPOL) * See http://www.codeproject.com/info/cpol10.aspx for details */ @@ -377,7 +377,7 @@ public void SuspendDrawing() { protected override void OnMouseDown(MouseEventArgs e) { var mousePosition = new Point(e.X, e.Y); int index = this.GetActiveIndex(mousePosition); - if (!this.DesignMode && index > -1 && this._StyleProvider.ShowTabCloser && this.GetTabCloserButtonRect(index).Contains(mousePosition)) { + if (!this.DesignMode && index > (this._StyleProvider.CloserIgnoreFirstTabs - 1) && this._StyleProvider.ShowTabCloser && this.GetTabCloserButtonRect(index).Contains(mousePosition)) { // If we are clicking on a closer then remove the tab instead of raising the standard mouse down event // But raise the tab closing event first @@ -868,7 +868,7 @@ private void DrawTabPage(int index, Point mousePosition, Graphics graphics) { if (isTabVisible) { // Paint the tab - this.PaintTab(tabBorder, tabCloserButtonRect, state, graphics, mousePosition); + this.PaintTab(tabBorder, tabCloserButtonRect, state, graphics, mousePosition, index); // Draw any image if (tabImageRect != Rectangle.Empty) this.DrawTabImage(tabImage, tabImageRect, graphics, isTabEnabled); @@ -884,13 +884,14 @@ private void DrawTabPage(int index, Point mousePosition, Graphics graphics) { } } - private void PaintTab(GraphicsPath tabBorder, Rectangle tabCloserButtonRect, TabState state, Graphics graphics, Point mousePosition) { + private void PaintTab(GraphicsPath tabBorder, Rectangle tabCloserButtonRect, TabState state, Graphics graphics, Point mousePosition, int index) { this._StyleProvider.PaintTabBackground(tabBorder, state, graphics); // Paint a focus indication this._StyleProvider.DrawTabFocusIndicator(tabBorder, state, graphics); // Paint the closer - this._StyleProvider.DrawTabCloser(tabCloserButtonRect, graphics, state, mousePosition); + if (index > (this._StyleProvider.CloserIgnoreFirstTabs - 1)) + this._StyleProvider.DrawTabCloser(tabCloserButtonRect, graphics, state, mousePosition); } private void DrawTabPageBorder(GraphicsPath path, TabState state, Graphics graphics) { From 2b85559190fc9c5eea6093aa493214435f8d66da Mon Sep 17 00:00:00 2001 From: hirus <11228152+h1ru5@users.noreply.github.com> Date: Mon, 22 Jul 2019 14:46:21 +0000 Subject: [PATCH 2/2] added dont display closer on first N tabs --- TabControlExtra/TabControl/TabStyleProvider.cs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/TabControlExtra/TabControl/TabStyleProvider.cs b/TabControlExtra/TabControl/TabStyleProvider.cs index 23aa412..a22fb45 100644 --- a/TabControlExtra/TabControl/TabStyleProvider.cs +++ b/TabControlExtra/TabControl/TabStyleProvider.cs @@ -1,4 +1,4 @@ -/* +/* * This code is provided under the Code Project Open Licence (CPOL) * See http://www.codeproject.com/info/cpol10.aspx for details */ @@ -108,6 +108,7 @@ public static TabStyleProvider CreateProvider(TabControlExtra tabControl){ private bool _FocusTrack; private float _Opacity = 1; private bool _ShowTabCloser; + private int _CloserIgnoreFirstTabs; private bool _SelectedTabIsLarger; private BlendStyle _BlendStyle = BlendStyle.Normal; @@ -393,7 +394,7 @@ public bool SelectedTabIsLarger { } } - [Category("Appearance")] + [Category("Appearance")] public bool ShowTabCloser { get { return this._ShowTabCloser; } set { @@ -403,6 +404,12 @@ public bool ShowTabCloser { } } + [Category("Appearance")] + public int CloserIgnoreFirstTabs { + get { return this._CloserIgnoreFirstTabs; } + set { this._CloserIgnoreFirstTabs = value; } + } + [Category("Appearance")] public float Opacity { get { return this._Opacity; }