Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
HZH_Controls
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 2ce7c3bc
由
HZH
编写于
2019-09-27 10:24:26 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
修改面包屑导航,支持改变颜色
1 个父辈
21728239
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
98 行增加
和
22 行删除
HZH_Controls/HZH_Controls/Controls/Navigation/CrumbNavigationClickEventArgs.cs
HZH_Controls/HZH_Controls/Controls/Navigation/CrumbNavigationItem.cs
HZH_Controls/HZH_Controls/Controls/Navigation/UCCrumbNavigation.cs
HZH_Controls/HZH_Controls/HZH_Controls.csproj
HZH_Controls/Test/UC/UCTestNavigation.Designer.cs
HZH_Controls/Test/UC/UCTestNavigation.cs
HZH_Controls/HZH_Controls/Controls/Navigation/CrumbNavigationClickEventArgs.cs
0 → 100644
查看文件 @
2ce7c3b
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
namespace
HZH_Controls.Controls
{
public
class
CrumbNavigationClickEventArgs
:
EventArgs
{
public
int
Index
{
get
;
set
;
}
public
CrumbNavigationItem
Item
{
get
;
set
;
}
}
}
HZH_Controls/HZH_Controls/Controls/Navigation/CrumbNavigationItem.cs
0 → 100644
查看文件 @
2ce7c3b
using
System
;
using
System.Collections.Generic
;
using
System.Drawing
;
using
System.Linq
;
using
System.Text
;
namespace
HZH_Controls.Controls
{
public
class
CrumbNavigationItem
{
public
string
Key
{
get
;
set
;
}
public
string
Text
{
get
;
set
;
}
public
Color
?
ItemColor
{
get
;
set
;
}
}
}
HZH_Controls/HZH_Controls/Controls/Navigation/UCCrumbNavigation.cs
查看文件 @
2ce7c3b
...
@@ -30,6 +30,7 @@ namespace HZH_Controls.Controls
...
@@ -30,6 +30,7 @@ namespace HZH_Controls.Controls
/// Implements the <see cref="System.Windows.Forms.UserControl" />
/// Implements the <see cref="System.Windows.Forms.UserControl" />
/// </summary>
/// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" />
/// <seealso cref="System.Windows.Forms.UserControl" />
[
DefaultEvent
(
"ClickItemed"
)]
public
partial
class
UCCrumbNavigation
:
UserControl
public
partial
class
UCCrumbNavigation
:
UserControl
{
{
/// <summary>
/// <summary>
...
@@ -54,24 +55,20 @@ namespace HZH_Controls.Controls
...
@@ -54,24 +55,20 @@ namespace HZH_Controls.Controls
}
}
/// <summary>
/// The m navigations
/// </summary>
private
string
[]
m_navigations
=
new
string
[]
{
"目录1"
,
"目录2"
,
"目录3"
};
/// <summary>
/// <summary>
/// The m paths
/// The m paths
/// </summary>
/// </summary>
GraphicsPath
[]
m_paths
;
GraphicsPath
[]
m_paths
;
/// <summary>
/// Gets or sets the navigations.
private
CrumbNavigationItem
[]
items
;
/// </summary>
/// <value>The navigations.</value>
public
CrumbNavigationItem
[]
Items
public
string
[]
Navigations
{
{
get
{
return
m_navigation
s
;
}
get
{
return
item
s
;
}
set
set
{
{
m_navigation
s
=
value
;
item
s
=
value
;
if
(
value
==
null
)
if
(
value
==
null
)
m_paths
=
new
GraphicsPath
[
0
];
m_paths
=
new
GraphicsPath
[
0
];
else
else
...
@@ -123,6 +120,9 @@ namespace HZH_Controls.Controls
...
@@ -123,6 +120,9 @@ namespace HZH_Controls.Controls
}
}
}
}
public
delegate
void
CrumbNavigationEventHander
(
object
sender
,
CrumbNavigationClickEventArgs
e
);
public
event
CrumbNavigationEventHander
ClickItemed
;
/// <summary>
/// <summary>
/// Initializes a new instance of the <see cref="UCCrumbNavigation" /> class.
/// Initializes a new instance of the <see cref="UCCrumbNavigation" /> class.
/// </summary>
/// </summary>
...
@@ -136,6 +136,15 @@ namespace HZH_Controls.Controls
...
@@ -136,6 +136,15 @@ namespace HZH_Controls.Controls
this
.
SetStyle
(
ControlStyles
.
SupportsTransparentBackColor
,
true
);
this
.
SetStyle
(
ControlStyles
.
SupportsTransparentBackColor
,
true
);
this
.
SetStyle
(
ControlStyles
.
UserPaint
,
true
);
this
.
SetStyle
(
ControlStyles
.
UserPaint
,
true
);
this
.
MouseDown
+=
UCCrumbNavigation_MouseDown
;
this
.
MouseDown
+=
UCCrumbNavigation_MouseDown
;
Items
=
new
CrumbNavigationItem
[
0
];
if
(
ControlHelper
.
IsDesignMode
())
{
Items
=
new
CrumbNavigationItem
[
3
];
for
(
int
i
=
0
;
i
<
3
;
i
++)
{
Items
[
i
]
=
new
CrumbNavigationItem
()
{
Text
=
"item"
+
(
i
+
1
),
Key
=
i
.
ToString
()
};
}
}
}
}
/// <summary>
/// <summary>
...
@@ -145,15 +154,18 @@ namespace HZH_Controls.Controls
...
@@ -145,15 +154,18 @@ namespace HZH_Controls.Controls
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
void
UCCrumbNavigation_MouseDown
(
object
sender
,
MouseEventArgs
e
)
void
UCCrumbNavigation_MouseDown
(
object
sender
,
MouseEventArgs
e
)
{
{
if
(
!
DesignMode
)
if
(
ClickItemed
!=
null
)
{
{
if
(
m_paths
!=
null
&&
m_paths
.
Length
>
0
)
if
(
!
DesignMode
)
{
{
for
(
int
i
=
0
;
i
<
m_paths
.
Length
;
i
++
)
if
(
m_paths
!=
null
&&
m_paths
.
Length
>
0
)
{
{
if
(
m_paths
[
i
].
IsVisible
(
e
.
Location
)
)
for
(
int
i
=
0
;
i
<
m_paths
.
Length
;
i
++
)
{
{
HZH_Controls
.
Forms
.
FrmTips
.
ShowTipsSuccess
(
this
.
FindForm
(),
m_navigations
[
i
]);
if
(
m_paths
[
i
].
IsVisible
(
e
.
Location
))
{
ClickItemed
(
this
,
new
CrumbNavigationClickEventArgs
()
{
Index
=
i
,
Item
=
items
[
i
]
});
}
}
}
}
}
}
}
...
@@ -168,16 +180,16 @@ namespace HZH_Controls.Controls
...
@@ -168,16 +180,16 @@ namespace HZH_Controls.Controls
{
{
base
.
OnPaint
(
e
);
base
.
OnPaint
(
e
);
if
(
m_navigations
!=
null
&&
m_navigation
s
.
Length
>
0
)
if
(
items
!=
null
&&
item
s
.
Length
>
0
)
{
{
var
g
=
e
.
Graphics
;
var
g
=
e
.
Graphics
;
g
.
SetGDIHigh
();
g
.
SetGDIHigh
();
int
intLastX
=
0
;
int
intLastX
=
0
;
int
intLength
=
m_navigation
s
.
Length
;
int
intLength
=
item
s
.
Length
;
for
(
int
i
=
0
;
i
<
m_navigation
s
.
Length
;
i
++)
for
(
int
i
=
0
;
i
<
item
s
.
Length
;
i
++)
{
{
GraphicsPath
path
=
new
GraphicsPath
();
GraphicsPath
path
=
new
GraphicsPath
();
string
strText
=
m_navigations
[
i
]
;
string
strText
=
items
[
i
].
Text
;
System
.
Drawing
.
SizeF
sizeF
=
g
.
MeasureString
(
strText
.
Replace
(
" "
,
"A"
),
Font
);
System
.
Drawing
.
SizeF
sizeF
=
g
.
MeasureString
(
strText
.
Replace
(
" "
,
"A"
),
Font
);
int
intTextWidth
=
(
int
)
sizeF
.
Width
+
1
;
int
intTextWidth
=
(
int
)
sizeF
.
Width
+
1
;
path
.
AddLine
(
new
Point
(
intLastX
+
1
,
1
),
new
Point
(
intLastX
+
1
+
(
i
==
0
?
0
:
10
)
+
intTextWidth
,
1
));
path
.
AddLine
(
new
Point
(
intLastX
+
1
,
1
),
new
Point
(
intLastX
+
1
+
(
i
==
0
?
0
:
10
)
+
intTextWidth
,
1
));
...
@@ -203,7 +215,7 @@ namespace HZH_Controls.Controls
...
@@ -203,7 +215,7 @@ namespace HZH_Controls.Controls
{
{
path
.
AddLine
(
new
Point
(
intLastX
+
1
,
this
.
Height
-
1
),
new
Point
(
intLastX
+
1
,
1
));
path
.
AddLine
(
new
Point
(
intLastX
+
1
,
this
.
Height
-
1
),
new
Point
(
intLastX
+
1
,
1
));
}
}
g
.
FillPath
(
new
SolidBrush
(
m_navColor
),
path
);
g
.
FillPath
(
new
SolidBrush
(
(
items
[
i
].
ItemColor
==
null
||
items
[
i
].
ItemColor
==
Color
.
Empty
||
items
[
i
].
ItemColor
==
Color
.
Transparent
)
?
m_navColor
:
items
[
i
].
ItemColor
.
Value
),
path
);
g
.
DrawString
(
strText
,
this
.
Font
,
new
SolidBrush
(
this
.
ForeColor
),
new
PointF
(
intLastX
+
2
+
(
i
==
0
?
0
:
10
),
(
this
.
Height
-
sizeF
.
Height
)
/
2
+
1
));
g
.
DrawString
(
strText
,
this
.
Font
,
new
SolidBrush
(
this
.
ForeColor
),
new
PointF
(
intLastX
+
2
+
(
i
==
0
?
0
:
10
),
(
this
.
Height
-
sizeF
.
Height
)
/
2
+
1
));
m_paths
[
i
]
=
path
;
m_paths
[
i
]
=
path
;
...
...
HZH_Controls/HZH_Controls/HZH_Controls.csproj
查看文件 @
2ce7c3b
...
@@ -70,6 +70,8 @@
...
@@ -70,6 +70,8 @@
<Compile Include="Controls\Charts\RadarChart\UCRadarChart.cs">
<Compile Include="Controls\Charts\RadarChart\UCRadarChart.cs">
<SubType>UserControl</SubType>
<SubType>UserControl</SubType>
</Compile>
</Compile>
<Compile Include="Controls\Navigation\CrumbNavigationClickEventArgs.cs" />
<Compile Include="Controls\Navigation\CrumbNavigationItem.cs" />
<Compile Include="Controls\ScrollBar\ScrollbarComponent.cs">
<Compile Include="Controls\ScrollBar\ScrollbarComponent.cs">
<SubType>Component</SubType>
<SubType>Component</SubType>
</Compile>
</Compile>
...
...
HZH_Controls/Test/UC/UCTestNavigation.Designer.cs
查看文件 @
2ce7c3b
此文件的差异被折叠,
点击展开。
HZH_Controls/Test/UC/UCTestNavigation.cs
查看文件 @
2ce7c3b
...
@@ -16,5 +16,39 @@ namespace Test.UC
...
@@ -16,5 +16,39 @@ namespace Test.UC
{
{
InitializeComponent
();
InitializeComponent
();
}
}
private
void
ucCrumbNavigation3_ClickItemed
(
object
sender
,
HZH_Controls
.
Controls
.
CrumbNavigationClickEventArgs
e
)
{
for
(
int
i
=
0
;
i
<
ucCrumbNavigation3
.
Items
.
Length
;
i
++)
{
if
(
i
>
e
.
Index
)
ucCrumbNavigation3
.
Items
[
i
].
ItemColor
=
Color
.
Gray
;
else
ucCrumbNavigation3
.
Items
[
i
].
ItemColor
=
null
;
}
ucCrumbNavigation3
.
Invalidate
();
}
private
void
ucCrumbNavigation4_ClickItemed
(
object
sender
,
HZH_Controls
.
Controls
.
CrumbNavigationClickEventArgs
e
)
{
for
(
int
i
=
0
;
i
<
ucCrumbNavigation4
.
Items
.
Length
;
i
++)
{
if
(
i
>
e
.
Index
)
ucCrumbNavigation4
.
Items
[
i
].
ItemColor
=
Color
.
Gray
;
else
ucCrumbNavigation4
.
Items
[
i
].
ItemColor
=
null
;
}
ucCrumbNavigation4
.
Invalidate
();
}
private
void
ucCrumbNavigation1_ClickItemed
(
object
sender
,
HZH_Controls
.
Controls
.
CrumbNavigationClickEventArgs
e
)
{
HZH_Controls
.
Forms
.
FrmTips
.
ShowTipsSuccess
(
this
.
FindForm
(),
e
.
Item
.
Text
);
}
private
void
ucCrumbNavigation2_ClickItemed
(
object
sender
,
HZH_Controls
.
Controls
.
CrumbNavigationClickEventArgs
e
)
{
HZH_Controls
.
Forms
.
FrmTips
.
ShowTipsSuccess
(
this
.
FindForm
(),
e
.
Item
.
Text
);
}
}
}
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论