Commit e5d7c299 HZH

修改为anycpu

1 个父辈 7a37f04e
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.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
...@@ -9,9 +24,21 @@ using System.ComponentModel; ...@@ -9,9 +24,21 @@ using System.ComponentModel;
namespace HZH_Controls.Controls 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 public class UCSampling : UserControl
{ {
/// <summary>
/// The sampling imag
/// </summary>
private Bitmap samplingImag = null; private Bitmap samplingImag = null;
/// <summary>
/// Gets or sets the sampling imag.
/// </summary>
/// <value>The sampling imag.</value>
[Browsable(true), Category("自定义属性"), Description("采样图片"), Localizable(true)] [Browsable(true), Category("自定义属性"), Description("采样图片"), Localizable(true)]
public Bitmap SamplingImag public Bitmap SamplingImag
{ {
...@@ -24,8 +51,15 @@ namespace HZH_Controls.Controls ...@@ -24,8 +51,15 @@ namespace HZH_Controls.Controls
} }
} }
/// <summary>
/// The transparent
/// </summary>
private Color? transparent = null; private Color? transparent = null;
/// <summary>
/// Gets or sets the transparent.
/// </summary>
/// <value>The transparent.</value>
[Browsable(true), Category("自定义属性"), Description("透明色,如果为空,则使用0,0坐标处的颜色"), Localizable(true)] [Browsable(true), Category("自定义属性"), Description("透明色,如果为空,则使用0,0坐标处的颜色"), Localizable(true)]
public Color? Transparent public Color? Transparent
{ {
...@@ -38,8 +72,15 @@ namespace HZH_Controls.Controls ...@@ -38,8 +72,15 @@ namespace HZH_Controls.Controls
} }
} }
/// <summary>
/// The alpha
/// </summary>
private int alpha = 50; private int alpha = 50;
/// <summary>
/// Gets or sets the alpha.
/// </summary>
/// <value>The alpha.</value>
[Browsable(true), Category("自定义属性"), Description("当作透明色的透明度,小于此透明度的颜色将被认定为透明,0-255"), Localizable(true)] [Browsable(true), Category("自定义属性"), Description("当作透明色的透明度,小于此透明度的颜色将被认定为透明,0-255"), Localizable(true)]
public int Alpha public int Alpha
{ {
...@@ -54,8 +95,15 @@ namespace HZH_Controls.Controls ...@@ -54,8 +95,15 @@ namespace HZH_Controls.Controls
} }
} }
/// <summary>
/// The color threshold
/// </summary>
private int colorThreshold = 10; private int colorThreshold = 10;
/// <summary>
/// Gets or sets the color threshold.
/// </summary>
/// <value>The color threshold.</value>
[Browsable(true), Category("自定义属性"), Description("透明色颜色阀值"), Localizable(true)] [Browsable(true), Category("自定义属性"), Description("透明色颜色阀值"), Localizable(true)]
public int ColorThreshold public int ColorThreshold
{ {
...@@ -68,7 +116,13 @@ namespace HZH_Controls.Controls ...@@ -68,7 +116,13 @@ namespace HZH_Controls.Controls
} }
} }
/// <summary>
/// The bit cache
/// </summary>
private Bitmap _bitCache; private Bitmap _bitCache;
/// <summary>
/// Initializes a new instance of the <see cref="UCSampling"/> class.
/// </summary>
public UCSampling() public UCSampling()
{ {
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true); this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
...@@ -80,13 +134,24 @@ namespace HZH_Controls.Controls ...@@ -80,13 +134,24 @@ namespace HZH_Controls.Controls
this.SizeChanged += UCSampling_SizeChanged; this.SizeChanged += UCSampling_SizeChanged;
this.Size = new Size(35, 35); this.Size = new Size(35, 35);
} }
/// <summary>
/// The m border path
/// </summary>
GraphicsPath m_borderPath = new GraphicsPath(); 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) void UCSampling_SizeChanged(object sender, EventArgs e)
{ {
ResetBorderPath(); ResetBorderPath();
} }
/// <summary>
/// Resets the border path.
/// </summary>
private void ResetBorderPath() private void ResetBorderPath()
{ {
if (samplingImag == null) if (samplingImag == null)
...@@ -108,6 +173,12 @@ namespace HZH_Controls.Controls ...@@ -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&lt;PointF&gt;.</returns>
private List<PointF> GetBorderPoints(Bitmap bit, Color transparent) private List<PointF> GetBorderPoints(Bitmap bit, Color transparent)
{ {
float diameter = (float)Math.Sqrt(bit.Width * bit.Width + bit.Height * bit.Height); float diameter = (float)Math.Sqrt(bit.Width * bit.Width + bit.Height * bit.Height);
...@@ -137,6 +208,12 @@ namespace HZH_Controls.Controls ...@@ -137,6 +208,12 @@ namespace HZH_Controls.Controls
return lstPoint; 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) 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)); 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 ...@@ -165,6 +242,10 @@ namespace HZH_Controls.Controls
} }
#endregion #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) protected override void OnPaint(PaintEventArgs e)
{ {
base.OnPaint(e); base.OnPaint(e);
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType> <DebugType>pdbonly</DebugType>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols> <DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType> <DebugType>full</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!