Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
Ftt_Common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
Ftt_Common
Commits
44e479b4
Commit
44e479b4
authored
Nov 01, 2021
by
tr
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1、定制Tab控件优化:肩线只绘制一次
parent
957c0103
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
16 deletions
+12
-16
TabControlEx.cs
Tools/MyControls/TabControlEx.cs
+12
-16
No files found.
Tools/MyControls/TabControlEx.cs
View file @
44e479b4
...
...
@@ -76,9 +76,19 @@ namespace Tools.MyControls
/// <param name="e"></param>
protected
override
void
OnPaintBackground
(
PaintEventArgs
e
)
{
var
g
=
e
.
Graphics
;
//绘制控件背景
var
brush
=
new
SolidBrush
(
this
.
BackgroundColor
);
e
.
Graphics
.
FillRectangle
(
brush
,
e
.
ClipRectangle
);
g
.
FillRectangle
(
brush
,
e
.
ClipRectangle
);
//扩展:绘制肩线(仅绘制一次:用以突出选中效果)
Rectangle
client
=
this
.
ClientRectangle
;
var
x
=
client
.
X
;
var
y
=
client
.
Y
+
this
.
ItemSize
.
Height
+
2
;
var
location
=
new
Point
(
x
+
2
,
y
);
//左右各留2像素
var
size
=
new
Size
(
client
.
Width
-
3
,
2
);
var
shoulder
=
new
Rectangle
(
location
,
size
);
var
shoulderBrush
=
new
SolidBrush
(
this
.
TabActivedBackColor
);
//肩线为激活颜色
g
.
FillRectangle
(
shoulderBrush
,
shoulder
);
}
/// <summary>
/// 重写:绘制方法
...
...
@@ -98,7 +108,6 @@ namespace Tools.MyControls
var
BackColor
=
IsSelected
?
TabActivedBackColor
:
isHover
?
TabDeactivedBackColorHover
:
TabDeactivedBackColor
;
var
FontColor
=
IsSelected
?
TabActivedFontColor
:
isHover
?
TabDeactivedFontColorHover
:
TabDeactivedFontColor
;
//画笔、画刷准备
var
backPen
=
new
Pen
(
BackColor
);
var
backBrush
=
new
SolidBrush
(
BackColor
);
var
fontBrush
=
new
SolidBrush
(
FontColor
);
//绘制并填充矩形框:背景
...
...
@@ -106,21 +115,8 @@ namespace Tools.MyControls
//绘制标题
var
title
=
this
.
TabPages
[
index
].
Text
;
g
.
DrawString
(
title
,
this
.
Font
,
fontBrush
,
tabRect
,
this
.
fmt
);
//扩展:绘制肩线(每轮绘制一次)
if
(
index
==
0
)
{
Rectangle
client
=
this
.
ClientRectangle
;
var
x
=
client
.
X
;
var
y
=
client
.
Y
+
tabRect
.
Height
+
2
;
var
location
=
new
Point
(
x
+
2
,
y
);
//左右各留2像素
var
size
=
new
Size
(
client
.
Width
-
3
,
2
);
var
shoulder
=
new
Rectangle
(
location
,
size
);
var
shoulderBrush
=
new
SolidBrush
(
this
.
TabActivedBackColor
);
//肩线为激活颜色
g
.
FillRectangle
(
shoulderBrush
,
shoulder
);
}
}
//扩展:绘制标签项边框线
//扩展:绘制标签项边框线
(每轮绘制一次:用以突出选中效果)
this
.
DrawTabsBorder
(
g
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment