Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
HZH_Controls
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit e5d7c299
由
HZH
编写于
2019-09-28 15:44:51 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
修改为anycpu
1 个父辈
7a37f04e
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
84 行增加
和
3 行删除
HZH_Controls/HZH_Controls/Controls/Sampling/UCSampling.cs
HZH_Controls/HZH_Controls/HZH_Controls.csproj
HZH_Controls/Test/Test.csproj
HZH_Controls/HZH_Controls/Controls/Sampling/UCSampling.cs
查看文件 @
e5d7c29
using
System
;
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-28
//
// ***********************************************************************
// <copyright file="UCSampling.cs">
// Copyright by Huang Zhenghui(黄正辉) All, QQ group:568015492 QQ:623128629 Email:623128629@qq.com
// </copyright>
//
// Blog: https://www.cnblogs.com/bfyx
// GitHub:https://github.com/kwwwvagaa/NetWinformControl
// gitee:https://gitee.com/kwwwvagaa/net_winform_custom_control.git
//
// If you use this code, please keep this note.
// ***********************************************************************
using
System
;
using
System.Collections.Generic
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -9,9 +24,21 @@ using System.ComponentModel;
namespace
HZH_Controls.Controls
{
/// <summary>
/// Class UCSampling.
/// Implements the <see cref="System.Windows.Forms.UserControl" />
/// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" />
public
class
UCSampling
:
UserControl
{
/// <summary>
/// The sampling imag
/// </summary>
private
Bitmap
samplingImag
=
null
;
/// <summary>
/// Gets or sets the sampling imag.
/// </summary>
/// <value>The sampling imag.</value>
[
Browsable
(
true
),
Category
(
"自定义属性"
),
Description
(
"采样图片"
),
Localizable
(
true
)]
public
Bitmap
SamplingImag
{
...
...
@@ -24,8 +51,15 @@ namespace HZH_Controls.Controls
}
}
/// <summary>
/// The transparent
/// </summary>
private
Color
?
transparent
=
null
;
/// <summary>
/// Gets or sets the transparent.
/// </summary>
/// <value>The transparent.</value>
[
Browsable
(
true
),
Category
(
"自定义属性"
),
Description
(
"透明色,如果为空,则使用0,0坐标处的颜色"
),
Localizable
(
true
)]
public
Color
?
Transparent
{
...
...
@@ -38,8 +72,15 @@ namespace HZH_Controls.Controls
}
}
/// <summary>
/// The alpha
/// </summary>
private
int
alpha
=
50
;
/// <summary>
/// Gets or sets the alpha.
/// </summary>
/// <value>The alpha.</value>
[
Browsable
(
true
),
Category
(
"自定义属性"
),
Description
(
"当作透明色的透明度,小于此透明度的颜色将被认定为透明,0-255"
),
Localizable
(
true
)]
public
int
Alpha
{
...
...
@@ -54,8 +95,15 @@ namespace HZH_Controls.Controls
}
}
/// <summary>
/// The color threshold
/// </summary>
private
int
colorThreshold
=
10
;
/// <summary>
/// Gets or sets the color threshold.
/// </summary>
/// <value>The color threshold.</value>
[
Browsable
(
true
),
Category
(
"自定义属性"
),
Description
(
"透明色颜色阀值"
),
Localizable
(
true
)]
public
int
ColorThreshold
{
...
...
@@ -68,7 +116,13 @@ namespace HZH_Controls.Controls
}
}
/// <summary>
/// The bit cache
/// </summary>
private
Bitmap
_bitCache
;
/// <summary>
/// Initializes a new instance of the <see cref="UCSampling"/> class.
/// </summary>
public
UCSampling
()
{
this
.
SetStyle
(
ControlStyles
.
AllPaintingInWmPaint
,
true
);
...
...
@@ -80,13 +134,24 @@ namespace HZH_Controls.Controls
this
.
SizeChanged
+=
UCSampling_SizeChanged
;
this
.
Size
=
new
Size
(
35
,
35
);
}
/// <summary>
/// The m border path
/// </summary>
GraphicsPath
m_borderPath
=
new
GraphicsPath
();
/// <summary>
/// Handles the SizeChanged event of the UCSampling control.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
void
UCSampling_SizeChanged
(
object
sender
,
EventArgs
e
)
{
ResetBorderPath
();
}
/// <summary>
/// Resets the border path.
/// </summary>
private
void
ResetBorderPath
()
{
if
(
samplingImag
==
null
)
...
...
@@ -108,6 +173,12 @@ namespace HZH_Controls.Controls
}
}
/// <summary>
/// Gets the border points.
/// </summary>
/// <param name="bit">The bit.</param>
/// <param name="transparent">The transparent.</param>
/// <returns>List<PointF>.</returns>
private
List
<
PointF
>
GetBorderPoints
(
Bitmap
bit
,
Color
transparent
)
{
float
diameter
=
(
float
)
Math
.
Sqrt
(
bit
.
Width
*
bit
.
Width
+
bit
.
Height
*
bit
.
Height
);
...
...
@@ -137,6 +208,12 @@ namespace HZH_Controls.Controls
return
lstPoint
;
}
/// <summary>
/// Determines whether [is like color] [the specified color1].
/// </summary>
/// <param name="color1">The color1.</param>
/// <param name="color2">The color2.</param>
/// <returns><c>true</c> if [is like color] [the specified color1]; otherwise, <c>false</c>.</returns>
private
bool
IsLikeColor
(
Color
color1
,
Color
color2
)
{
var
cv
=
Math
.
Sqrt
(
Math
.
Pow
((
color1
.
R
-
color2
.
R
),
2
)
+
Math
.
Pow
((
color1
.
G
-
color2
.
G
),
2
)
+
Math
.
Pow
((
color1
.
B
-
color2
.
B
),
2
));
...
...
@@ -165,6 +242,10 @@ namespace HZH_Controls.Controls
}
#
endregion
/// <summary>
/// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。
/// </summary>
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.PaintEventArgs" />。</param>
protected
override
void
OnPaint
(
PaintEventArgs
e
)
{
base
.
OnPaint
(
e
);
...
...
HZH_Controls/HZH_Controls/HZH_Controls.csproj
查看文件 @
e5d7c29
...
...
@@ -20,7 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>
x86
</PlatformTarget>
<PlatformTarget>
AnyCPU
</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
...
...
HZH_Controls/Test/Test.csproj
查看文件 @
e5d7c29
...
...
@@ -13,7 +13,7 @@
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>
x86
</PlatformTarget>
<PlatformTarget>
AnyCPU
</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论