官网

http://www.hzhcontrols.com

前提

入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章。

GitHub:https://github.com/kwwwvagaa/NetWinformControl

码云:https://gitee.com/kwwwvagaa/net_winform_custom_control.git

如果觉得写的还行,请点个 star 支持一下吧

欢迎前来交流探讨: 企鹅群568015492 

麻烦博客下方点个【推荐】,谢谢

NuGet

Install-Package HZH_Controls

目录

https://www.cnblogs.com/bfyx/p/11364884.html

用处及效果

准备工作

使用GDI+画的,用到了三角函数,如果不了解可以先行百度

开始

添加一个类UCConduit,继承UserControl

添加几个属性

 /// <summary>
/// The conduit style
/// </summary>
private ConduitStyle conduitStyle = ConduitStyle.Horizontal_None_None; /// <summary>
/// Gets or sets the conduit style.
/// </summary>
/// <value>The conduit style.</value>
[Description("样式"), Category("自定义")]
public ConduitStyle ConduitStyle
{
get { return conduitStyle; }
set
{
string strOld = conduitStyle.ToString().Substring(, );
string strNew = value.ToString().Substring(, );
conduitStyle = value;
if (strOld != strNew)
{
this.Size = new Size(this.Size.Height, this.Size.Width);
}
Refresh();
}
} /// <summary>
/// The conduit color
/// </summary>
private Color conduitColor = Color.FromArgb(, , );
[Description("颜色"), Category("自定义")]
/// <summary>
/// Gets or sets the color of the conduit.
/// </summary>
/// <value>The color of the conduit.</value>
public Color ConduitColor
{
get { return conduitColor; }
set
{
conduitColor = value;
Refresh();
}
} /// <summary>
/// The liquid color
/// </summary>
private Color liquidColor = Color.FromArgb(, , ); /// <summary>
/// Gets or sets the color of the liquid.
/// </summary>
/// <value>The color of the liquid.</value>
[Description("液体颜色"), Category("自定义")]
public Color LiquidColor
{
get { return liquidColor; }
set
{
liquidColor = value;
if (liquidDirection != Conduit.LiquidDirection.None)
Refresh();
}
} /// <summary>
/// The liquid direction
/// </summary>
private LiquidDirection liquidDirection = LiquidDirection.Forward; /// <summary>
/// Gets or sets the liquid direction.
/// </summary>
/// <value>The liquid direction.</value>
[Description("液体流动方向"), Category("自定义")]
public LiquidDirection LiquidDirection
{
get { return liquidDirection; }
set
{
liquidDirection = value;
Refresh();
}
} /// <summary>
/// The liquid speed
/// </summary>
private int liquidSpeed = ; /// <summary>
/// 液体流速,越小,速度越快Gets or sets the liquid speed.
/// </summary>
/// <value>The liquid speed.</value>
[Description("液体流速,越小,速度越快"), Category("自定义")]
public int LiquidSpeed
{
get { return liquidSpeed; }
set
{
if (value <= )
return;
liquidSpeed = value;
m_timer.Interval = value;
}
} /// <summary>
/// The int pen width
/// </summary>
int intPenWidth = ; /// <summary>
/// The int line left
/// </summary>
int intLineLeft = ;
/// <summary>
/// The m timer
/// </summary>
Timer m_timer;

根据参数设置重绘

 /// <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);
Graphics g = e.Graphics; List<ArcEntity> lstArcs = new List<ArcEntity>(); GraphicsPath path = new GraphicsPath();
GraphicsPath linePath = new GraphicsPath();
switch (conduitStyle)
{
#region H English:H
case ConduitStyle.Horizontal_None_None:
path.AddLines(new PointF[]
{
new PointF(, ),
new PointF(this.ClientRectangle.Right, ),
new PointF(this.ClientRectangle.Right, this.Height),
new PointF(, this.Height)
});
path.CloseAllFigures();
linePath.AddLine(, this.Height / , this.Width, this.Height / );
break;
case ConduitStyle.Horizontal_Up_None:
path.AddLines(new PointF[]
{
new PointF(, ),
new PointF(this.ClientRectangle.Right, ),
new PointF(this.ClientRectangle.Right, this.Height),
new PointF(+intPenWidth, this.Height)
});
path.AddArc(new Rectangle(, intPenWidth * -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / + , - * intPenWidth / - , intPenWidth, intPenWidth), , -);
linePath.AddLine(intPenWidth, this.Height / , this.Width, this.Height / ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(, intPenWidth * -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Horizontal_Down_None:
path.AddLines(new PointF[]
{
new PointF(intPenWidth, ),
new PointF(this.ClientRectangle.Right, ),
new PointF(this.ClientRectangle.Right, this.Height),
new PointF(, this.Height)
});
path.AddArc(new Rectangle(, -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / + , this.Height / , intPenWidth, intPenWidth), , );
linePath.AddLine(intPenWidth + , this.Height / , this.Width, this.Height / ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(, -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Horizontal_None_Up:
path.AddLines(new PointF[]
{
new PointF(this.ClientRectangle.Right-intPenWidth, this.Height),
new PointF(, this.Height),
new PointF(, ),
new PointF(this.ClientRectangle.Right-intPenWidth, )
});
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * , intPenWidth * -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddLine(, this.Height / , this.Width - intPenWidth, this.Height / );
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / - , - * intPenWidth / - , intPenWidth, intPenWidth), , -); lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * , intPenWidth * -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Horizontal_None_Down:
path.AddLines(new PointF[]
{
new PointF(this.ClientRectangle.Right, this.Height),
new PointF(, this.Height),
new PointF(, ),
new PointF(this.ClientRectangle.Right-intPenWidth, )
});
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * , -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddLine(, this.Height / , this.Width - intPenWidth - , this.Height / );
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / - , intPenWidth / , intPenWidth, intPenWidth), , ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * , -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Horizontal_Down_Up:
path.AddLine(new Point(intPenWidth, ), new Point(this.Width, ));
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * , intPenWidth * -, intPenWidth * , intPenWidth * ), , );
path.AddLine(new Point(this.Width - intPenWidth, this.Height), new Point(, this.Height));
path.AddArc(new Rectangle(, -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / + , this.Height / , intPenWidth, intPenWidth), , );
//linePath.AddLine(intPenWidth, this.Height / 2, this.Width - intPenWidth, this.Height / 2);
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / - , - * intPenWidth / - , intPenWidth, intPenWidth), , -); lstArcs.Add(new ArcEntity() { rect = new Rectangle(, -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * , intPenWidth * -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Horizontal_Up_Down:
path.AddLine(new Point(, ), new Point(this.Width - intPenWidth, ));
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * , -, intPenWidth * , intPenWidth * ), , );
path.AddLine(new Point(this.Width, this.Height), new Point(intPenWidth, this.Height));
path.AddArc(new Rectangle(, intPenWidth * -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / + , - * intPenWidth / - , intPenWidth, intPenWidth), , -);
linePath.AddLine(intPenWidth, this.Height / , this.Width - intPenWidth - , this.Height / );
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / - , intPenWidth / , intPenWidth, intPenWidth), , ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(, intPenWidth * -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * , -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Horizontal_Up_Up:
path.AddLine(new Point(, ), new Point(this.Width, ));
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * , intPenWidth * -, intPenWidth * , intPenWidth * ), , );
path.AddLine(new Point(this.Width - intPenWidth, this.Height), new Point(intPenWidth, this.Height));
path.AddArc(new Rectangle(, intPenWidth * -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / + , - * intPenWidth / - , intPenWidth, intPenWidth), , -);
//linePath.AddLine(intPenWidth, this.Height / 2, this.Width - intPenWidth, this.Height / 2);
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / - , - * intPenWidth / - , intPenWidth, intPenWidth), , -); lstArcs.Add(new ArcEntity() { rect = new Rectangle(, intPenWidth * -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * , intPenWidth * -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Horizontal_Down_Down:
path.AddLine(new Point(intPenWidth, ), new Point(this.Width - intPenWidth, ));
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * , -, intPenWidth * , intPenWidth * ), , );
path.AddLine(new Point(this.Width, this.Height), new Point(, this.Height));
path.AddArc(new Rectangle(, -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / + , this.Height / , intPenWidth, intPenWidth), , );
linePath.AddLine(intPenWidth + , this.Height / , this.Width - intPenWidth - , this.Height / );
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / - , intPenWidth / , intPenWidth, intPenWidth), , ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(, -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * , -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
#endregion #region V English:V
case ConduitStyle.Vertical_None_None:
path.AddLines(new PointF[]
{
new PointF(, ),
new PointF(this.ClientRectangle.Right, ),
new PointF(this.ClientRectangle.Right, this.Height),
new PointF(, this.Height)
});
path.CloseAllFigures();
linePath.AddLine(this.Width / , , this.Width / , this.Height);
break;
case ConduitStyle.Vertical_Left_None:
path.AddLines(new PointF[]
{
new PointF(this.ClientRectangle.Right, intPenWidth),
new PointF(this.ClientRectangle.Right, this.Height),
new PointF(, this.Height),
new PointF(, )
});
path.AddArc(new Rectangle(- * intPenWidth, , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(- * intPenWidth / - , intPenWidth / + , intPenWidth, intPenWidth), , );
linePath.AddLine(intPenWidth / , intPenWidth, intPenWidth / , this.Height); lstArcs.Add(new ArcEntity() { rect = new Rectangle(- * intPenWidth, , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Vertical_Right_None:
path.AddLines(new PointF[]
{
new PointF(this.ClientRectangle.Right, ),
new PointF(this.ClientRectangle.Right, this.Height),
new PointF(, this.Height),
new PointF(, intPenWidth)
});
path.AddArc(new Rectangle(-, , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / , intPenWidth / + , intPenWidth, intPenWidth), , -);
linePath.AddLine(intPenWidth / , intPenWidth + , intPenWidth / , this.Height); lstArcs.Add(new ArcEntity() { rect = new Rectangle(-, , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Vertical_None_Left:
path.AddLines(new PointF[]
{
new PointF(, this.Height),
new PointF(, ),
new PointF(this.ClientRectangle.Right, ),
new PointF(this.ClientRectangle.Right, this.Height-intPenWidth),
});
path.AddArc(new Rectangle(- * intPenWidth, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddLine(this.Width / , , this.Width / , this.Height - intPenWidth);
linePath.AddArc(new Rectangle(- * intPenWidth / - , this.Height - intPenWidth - intPenWidth / - , intPenWidth, intPenWidth), -, ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(- * intPenWidth, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Vertical_None_Right:
path.AddLines(new PointF[]
{
new PointF(, this.Height-intPenWidth),
new PointF(, ),
new PointF(this.ClientRectangle.Right, ),
new PointF(this.ClientRectangle.Right, this.Height),
});
path.AddArc(new Rectangle(-, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddLine(this.Width / , , this.Width / , this.Height - intPenWidth - );
linePath.AddArc(new Rectangle(intPenWidth / , this.Height - intPenWidth - intPenWidth / - , intPenWidth, intPenWidth), , -); lstArcs.Add(new ArcEntity() { rect = new Rectangle(-, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Vertical_Left_Right:
path.AddLine(this.Width, intPenWidth, this.Width, this.Height);
path.AddArc(new Rectangle(-, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), , );
path.AddLine(, this.Height - intPenWidth, , );
path.AddArc(new Rectangle(- * intPenWidth, , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(- * intPenWidth / - , intPenWidth / + , intPenWidth, intPenWidth), , );
//linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
linePath.AddArc(new Rectangle(intPenWidth / , this.Height - intPenWidth - intPenWidth / - , intPenWidth, intPenWidth), , -); lstArcs.Add(new ArcEntity() { rect = new Rectangle(- * intPenWidth, , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Vertical_Right_Left:
path.AddLine(this.Width, , this.Width, this.Height - intPenWidth);
path.AddArc(new Rectangle(- * intPenWidth, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), , );
path.AddLine(, this.Height, , intPenWidth);
path.AddArc(new Rectangle(-, , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / , intPenWidth / + , intPenWidth, intPenWidth), , -);
//linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
linePath.AddArc(new Rectangle(- * intPenWidth / - , this.Height - intPenWidth - intPenWidth / - , intPenWidth, intPenWidth), -, ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(-, , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(- * intPenWidth, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Vertical_Left_Left:
path.AddLine(this.Width, intPenWidth, this.Width, this.Height - intPenWidth);
path.AddArc(new Rectangle(- * intPenWidth, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), , );
path.AddLine(, this.Height, , );
path.AddArc(new Rectangle(- * intPenWidth, , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(- * intPenWidth / - , intPenWidth / + , intPenWidth, intPenWidth), , );
//linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
linePath.AddArc(new Rectangle(- * intPenWidth / - , this.Height - intPenWidth - intPenWidth / - , intPenWidth, intPenWidth), -, ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(- * intPenWidth, , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(- * intPenWidth, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Vertical_Right_Right:
path.AddLine(this.Width, , this.Width, this.Height);
path.AddArc(new Rectangle(-, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), , );
path.AddLine(, this.Height - intPenWidth, , intPenWidth);
path.AddArc(new Rectangle(-, , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / , intPenWidth / + , intPenWidth, intPenWidth), , -);
//linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
linePath.AddArc(new Rectangle(intPenWidth / , this.Height - intPenWidth - intPenWidth / - , intPenWidth, intPenWidth), , -); lstArcs.Add(new ArcEntity() { rect = new Rectangle(-, , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
#endregion
}
g.FillPath(new SolidBrush(conduitColor), path); //渐变色
int intCount = intPenWidth / / ;
int intSplit = ( - ) / intCount;
for (int i = ; i < intCount; i++)
{
int _penWidth = intPenWidth / - * i;
if (_penWidth <= )
_penWidth = ;
g.DrawPath(new Pen(new SolidBrush(Color.FromArgb(, Color.White.R, Color.White.G, Color.White.B)), _penWidth), linePath);
if (_penWidth == )
break;
} g.SetGDIHigh();
//使用抗锯齿画圆角
foreach (var item in lstArcs)
{
g.DrawArc(new Pen(new SolidBrush(this.BackColor)), item.rect, item.startAngle, item.sweepAngle);
} //液体流动
if (LiquidDirection != Conduit.LiquidDirection.None)
{
Pen p = new Pen(new SolidBrush(liquidColor), );
p.DashPattern = new float[] { , };
p.DashOffset = intLineLeft * (LiquidDirection == Conduit.LiquidDirection.Forward ? - : );
g.DrawPath(p, linePath);
}
}

一个记录圆角的类

  /// <summary>
/// Class ArcEntity.
/// </summary>
class ArcEntity
{
/// <summary>
/// Gets or sets the rect.
/// </summary>
/// <value>The rect.</value>
public Rectangle rect { get; set; }
/// <summary>
/// Gets or sets the start angle.
/// </summary>
/// <value>The start angle.</value>
public float startAngle { get; set; }
/// <summary>
/// Gets or sets the sweep angle.
/// </summary>
/// <value>The sweep angle.</value>
public float sweepAngle { get; set; }
}

2个枚举

 /// <summary>
/// Enum LiquidDirection
/// </summary>
public enum LiquidDirection
{
/// <summary>
/// The none
/// </summary>
None,
/// <summary>
/// The forward
/// </summary>
Forward,
/// <summary>
/// The backward
/// </summary>
Backward
} /// <summary>
/// 管道样式Enum ConduitStyle
/// </summary>
public enum ConduitStyle
{
/// <summary>
/// 直线 The horizontal none none
/// </summary>
Horizontal_None_None,
/// <summary>
/// 左上The horizontal up none
/// </summary>
Horizontal_Up_None,
/// <summary>
/// 左下The horizontal down none
/// </summary>
Horizontal_Down_None,
/// <summary>
/// 右上The horizontal none up
/// </summary>
Horizontal_None_Up,
/// <summary>
/// 右下The horizontal none down
/// </summary>
Horizontal_None_Down,
/// <summary>
/// 左下右上The horizontal down up
/// </summary>
Horizontal_Down_Up,
/// <summary>
/// 左上右下The horizontal up down
/// </summary>
Horizontal_Up_Down,
/// <summary>
/// 左上,右上The horizontal up up
/// </summary>
Horizontal_Up_Up,
/// <summary>
/// 左下右下The horizontal down down
/// </summary>
Horizontal_Down_Down, /// <summary>
/// 竖线The vertical none none
/// </summary>
Vertical_None_None,
/// <summary>
/// 上左The vertical left none
/// </summary>
Vertical_Left_None,
/// <summary>
/// 上右The vertical right none
/// </summary>
Vertical_Right_None,
/// <summary>
/// 下左The vertical none left
/// </summary>
Vertical_None_Left,
/// <summary>
/// 下右The vertical none right
/// </summary>
Vertical_None_Right,
/// <summary>
/// 上左下右The vertical left right
/// </summary>
Vertical_Left_Right,
/// <summary>
/// 上右下左The vertical right left
/// </summary>
Vertical_Right_Left,
/// <summary>
/// 上左下左The vertical left left
/// </summary>
Vertical_Left_Left,
/// <summary>
/// 上右下右The vertical right left
/// </summary>
Vertical_Right_Right,
}

重点讲解来了,

重绘的时候,先填充底色,并且记录下中心线path,和圆角

填充底色后,画中间的渐变色

然后设置g为抗锯齿模式,把圆角重画一遍,就没有锯齿感了

然后根据中心线,画液体就可以了

完整代码

 // ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-04
//
// ***********************************************************************
// <copyright file="UCConduit.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;
using System.Windows.Forms;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.ComponentModel; namespace HZH_Controls.Controls.Conduit
{
/// <summary>
/// Class UCConduit.
/// Implements the <see cref="System.Windows.Forms.UserControl" />
/// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" />
public class UCConduit : UserControl
{
/// <summary>
/// The conduit style
/// </summary>
private ConduitStyle conduitStyle = ConduitStyle.Horizontal_None_None; /// <summary>
/// Gets or sets the conduit style.
/// </summary>
/// <value>The conduit style.</value>
[Description("样式"), Category("自定义")]
public ConduitStyle ConduitStyle
{
get { return conduitStyle; }
set
{
string strOld = conduitStyle.ToString().Substring(, );
string strNew = value.ToString().Substring(, );
conduitStyle = value;
if (strOld != strNew)
{
this.Size = new Size(this.Size.Height, this.Size.Width);
}
Refresh();
}
} /// <summary>
/// The conduit color
/// </summary>
private Color conduitColor = Color.FromArgb(, , );
[Description("颜色"), Category("自定义")]
/// <summary>
/// Gets or sets the color of the conduit.
/// </summary>
/// <value>The color of the conduit.</value>
public Color ConduitColor
{
get { return conduitColor; }
set
{
conduitColor = value;
Refresh();
}
} /// <summary>
/// The liquid color
/// </summary>
private Color liquidColor = Color.FromArgb(, , ); /// <summary>
/// Gets or sets the color of the liquid.
/// </summary>
/// <value>The color of the liquid.</value>
[Description("液体颜色"), Category("自定义")]
public Color LiquidColor
{
get { return liquidColor; }
set
{
liquidColor = value;
if (liquidDirection != Conduit.LiquidDirection.None)
Refresh();
}
} /// <summary>
/// The liquid direction
/// </summary>
private LiquidDirection liquidDirection = LiquidDirection.Forward; /// <summary>
/// Gets or sets the liquid direction.
/// </summary>
/// <value>The liquid direction.</value>
[Description("液体流动方向"), Category("自定义")]
public LiquidDirection LiquidDirection
{
get { return liquidDirection; }
set
{
liquidDirection = value;
Refresh();
}
} /// <summary>
/// The liquid speed
/// </summary>
private int liquidSpeed = ; /// <summary>
/// 液体流速,越小,速度越快Gets or sets the liquid speed.
/// </summary>
/// <value>The liquid speed.</value>
[Description("液体流速,越小,速度越快"), Category("自定义")]
public int LiquidSpeed
{
get { return liquidSpeed; }
set
{
if (value <= )
return;
liquidSpeed = value;
m_timer.Interval = value;
}
} /// <summary>
/// The int pen width
/// </summary>
int intPenWidth = ; /// <summary>
/// The int line left
/// </summary>
int intLineLeft = ;
/// <summary>
/// The m timer
/// </summary>
Timer m_timer;
/// <summary>
/// Initializes a new instance of the <see cref="UCConduit"/> class.
/// </summary>
public UCConduit()
{
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
this.SetStyle(ControlStyles.DoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.Selectable, true);
this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.SizeChanged += UCConduit_SizeChanged;
this.Size = new Size(, );
m_timer = new Timer();
m_timer.Interval = ;
m_timer.Tick += timer_Tick;
m_timer.Enabled = true;
} /// <summary>
/// Handles the Tick event of the timer 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 timer_Tick(object sender, EventArgs e)
{
intLineLeft += ;
if (intLineLeft > )
intLineLeft = ;
Refresh();
} /// <summary>
/// Handles the SizeChanged event of the UCConduit 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 UCConduit_SizeChanged(object sender, EventArgs e)
{
intPenWidth = conduitStyle.ToString().StartsWith("H") ? this.Height : this.Width;
} /// <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);
Graphics g = e.Graphics; List<ArcEntity> lstArcs = new List<ArcEntity>(); GraphicsPath path = new GraphicsPath();
GraphicsPath linePath = new GraphicsPath();
switch (conduitStyle)
{
#region H English:H
case ConduitStyle.Horizontal_None_None:
path.AddLines(new PointF[]
{
new PointF(, ),
new PointF(this.ClientRectangle.Right, ),
new PointF(this.ClientRectangle.Right, this.Height),
new PointF(, this.Height)
});
path.CloseAllFigures();
linePath.AddLine(, this.Height / , this.Width, this.Height / );
break;
case ConduitStyle.Horizontal_Up_None:
path.AddLines(new PointF[]
{
new PointF(, ),
new PointF(this.ClientRectangle.Right, ),
new PointF(this.ClientRectangle.Right, this.Height),
new PointF(+intPenWidth, this.Height)
});
path.AddArc(new Rectangle(, intPenWidth * -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / + , - * intPenWidth / - , intPenWidth, intPenWidth), , -);
linePath.AddLine(intPenWidth, this.Height / , this.Width, this.Height / ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(, intPenWidth * -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Horizontal_Down_None:
path.AddLines(new PointF[]
{
new PointF(intPenWidth, ),
new PointF(this.ClientRectangle.Right, ),
new PointF(this.ClientRectangle.Right, this.Height),
new PointF(, this.Height)
});
path.AddArc(new Rectangle(, -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / + , this.Height / , intPenWidth, intPenWidth), , );
linePath.AddLine(intPenWidth + , this.Height / , this.Width, this.Height / ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(, -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Horizontal_None_Up:
path.AddLines(new PointF[]
{
new PointF(this.ClientRectangle.Right-intPenWidth, this.Height),
new PointF(, this.Height),
new PointF(, ),
new PointF(this.ClientRectangle.Right-intPenWidth, )
});
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * , intPenWidth * -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddLine(, this.Height / , this.Width - intPenWidth, this.Height / );
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / - , - * intPenWidth / - , intPenWidth, intPenWidth), , -); lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * , intPenWidth * -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Horizontal_None_Down:
path.AddLines(new PointF[]
{
new PointF(this.ClientRectangle.Right, this.Height),
new PointF(, this.Height),
new PointF(, ),
new PointF(this.ClientRectangle.Right-intPenWidth, )
});
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * , -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddLine(, this.Height / , this.Width - intPenWidth - , this.Height / );
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / - , intPenWidth / , intPenWidth, intPenWidth), , ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * , -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Horizontal_Down_Up:
path.AddLine(new Point(intPenWidth, ), new Point(this.Width, ));
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * , intPenWidth * -, intPenWidth * , intPenWidth * ), , );
path.AddLine(new Point(this.Width - intPenWidth, this.Height), new Point(, this.Height));
path.AddArc(new Rectangle(, -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / + , this.Height / , intPenWidth, intPenWidth), , );
//linePath.AddLine(intPenWidth, this.Height / 2, this.Width - intPenWidth, this.Height / 2);
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / - , - * intPenWidth / - , intPenWidth, intPenWidth), , -); lstArcs.Add(new ArcEntity() { rect = new Rectangle(, -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * , intPenWidth * -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Horizontal_Up_Down:
path.AddLine(new Point(, ), new Point(this.Width - intPenWidth, ));
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * , -, intPenWidth * , intPenWidth * ), , );
path.AddLine(new Point(this.Width, this.Height), new Point(intPenWidth, this.Height));
path.AddArc(new Rectangle(, intPenWidth * -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / + , - * intPenWidth / - , intPenWidth, intPenWidth), , -);
linePath.AddLine(intPenWidth, this.Height / , this.Width - intPenWidth - , this.Height / );
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / - , intPenWidth / , intPenWidth, intPenWidth), , ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(, intPenWidth * -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * , -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Horizontal_Up_Up:
path.AddLine(new Point(, ), new Point(this.Width, ));
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * , intPenWidth * -, intPenWidth * , intPenWidth * ), , );
path.AddLine(new Point(this.Width - intPenWidth, this.Height), new Point(intPenWidth, this.Height));
path.AddArc(new Rectangle(, intPenWidth * -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / + , - * intPenWidth / - , intPenWidth, intPenWidth), , -);
//linePath.AddLine(intPenWidth, this.Height / 2, this.Width - intPenWidth, this.Height / 2);
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / - , - * intPenWidth / - , intPenWidth, intPenWidth), , -); lstArcs.Add(new ArcEntity() { rect = new Rectangle(, intPenWidth * -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * , intPenWidth * -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Horizontal_Down_Down:
path.AddLine(new Point(intPenWidth, ), new Point(this.Width - intPenWidth, ));
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * , -, intPenWidth * , intPenWidth * ), , );
path.AddLine(new Point(this.Width, this.Height), new Point(, this.Height));
path.AddArc(new Rectangle(, -, intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / + , this.Height / , intPenWidth, intPenWidth), , );
linePath.AddLine(intPenWidth + , this.Height / , this.Width - intPenWidth - , this.Height / );
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / - , intPenWidth / , intPenWidth, intPenWidth), , ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(, -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * , -, intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
#endregion #region V English:V
case ConduitStyle.Vertical_None_None:
path.AddLines(new PointF[]
{
new PointF(, ),
new PointF(this.ClientRectangle.Right, ),
new PointF(this.ClientRectangle.Right, this.Height),
new PointF(, this.Height)
});
path.CloseAllFigures();
linePath.AddLine(this.Width / , , this.Width / , this.Height);
break;
case ConduitStyle.Vertical_Left_None:
path.AddLines(new PointF[]
{
new PointF(this.ClientRectangle.Right, intPenWidth),
new PointF(this.ClientRectangle.Right, this.Height),
new PointF(, this.Height),
new PointF(, )
});
path.AddArc(new Rectangle(- * intPenWidth, , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(- * intPenWidth / - , intPenWidth / + , intPenWidth, intPenWidth), , );
linePath.AddLine(intPenWidth / , intPenWidth, intPenWidth / , this.Height); lstArcs.Add(new ArcEntity() { rect = new Rectangle(- * intPenWidth, , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Vertical_Right_None:
path.AddLines(new PointF[]
{
new PointF(this.ClientRectangle.Right, ),
new PointF(this.ClientRectangle.Right, this.Height),
new PointF(, this.Height),
new PointF(, intPenWidth)
});
path.AddArc(new Rectangle(-, , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / , intPenWidth / + , intPenWidth, intPenWidth), , -);
linePath.AddLine(intPenWidth / , intPenWidth + , intPenWidth / , this.Height); lstArcs.Add(new ArcEntity() { rect = new Rectangle(-, , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Vertical_None_Left:
path.AddLines(new PointF[]
{
new PointF(, this.Height),
new PointF(, ),
new PointF(this.ClientRectangle.Right, ),
new PointF(this.ClientRectangle.Right, this.Height-intPenWidth),
});
path.AddArc(new Rectangle(- * intPenWidth, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddLine(this.Width / , , this.Width / , this.Height - intPenWidth);
linePath.AddArc(new Rectangle(- * intPenWidth / - , this.Height - intPenWidth - intPenWidth / - , intPenWidth, intPenWidth), -, ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(- * intPenWidth, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Vertical_None_Right:
path.AddLines(new PointF[]
{
new PointF(, this.Height-intPenWidth),
new PointF(, ),
new PointF(this.ClientRectangle.Right, ),
new PointF(this.ClientRectangle.Right, this.Height),
});
path.AddArc(new Rectangle(-, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddLine(this.Width / , , this.Width / , this.Height - intPenWidth - );
linePath.AddArc(new Rectangle(intPenWidth / , this.Height - intPenWidth - intPenWidth / - , intPenWidth, intPenWidth), , -); lstArcs.Add(new ArcEntity() { rect = new Rectangle(-, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Vertical_Left_Right:
path.AddLine(this.Width, intPenWidth, this.Width, this.Height);
path.AddArc(new Rectangle(-, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), , );
path.AddLine(, this.Height - intPenWidth, , );
path.AddArc(new Rectangle(- * intPenWidth, , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(- * intPenWidth / - , intPenWidth / + , intPenWidth, intPenWidth), , );
//linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
linePath.AddArc(new Rectangle(intPenWidth / , this.Height - intPenWidth - intPenWidth / - , intPenWidth, intPenWidth), , -); lstArcs.Add(new ArcEntity() { rect = new Rectangle(- * intPenWidth, , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Vertical_Right_Left:
path.AddLine(this.Width, , this.Width, this.Height - intPenWidth);
path.AddArc(new Rectangle(- * intPenWidth, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), , );
path.AddLine(, this.Height, , intPenWidth);
path.AddArc(new Rectangle(-, , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / , intPenWidth / + , intPenWidth, intPenWidth), , -);
//linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
linePath.AddArc(new Rectangle(- * intPenWidth / - , this.Height - intPenWidth - intPenWidth / - , intPenWidth, intPenWidth), -, ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(-, , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(- * intPenWidth, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Vertical_Left_Left:
path.AddLine(this.Width, intPenWidth, this.Width, this.Height - intPenWidth);
path.AddArc(new Rectangle(- * intPenWidth, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), , );
path.AddLine(, this.Height, , );
path.AddArc(new Rectangle(- * intPenWidth, , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(- * intPenWidth / - , intPenWidth / + , intPenWidth, intPenWidth), , );
//linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
linePath.AddArc(new Rectangle(- * intPenWidth / - , this.Height - intPenWidth - intPenWidth / - , intPenWidth, intPenWidth), -, ); lstArcs.Add(new ArcEntity() { rect = new Rectangle(- * intPenWidth, , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(- * intPenWidth, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
case ConduitStyle.Vertical_Right_Right:
path.AddLine(this.Width, , this.Width, this.Height);
path.AddArc(new Rectangle(-, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), , );
path.AddLine(, this.Height - intPenWidth, , intPenWidth);
path.AddArc(new Rectangle(-, , intPenWidth * , intPenWidth * ), , );
path.CloseAllFigures(); linePath.AddArc(new Rectangle(intPenWidth / , intPenWidth / + , intPenWidth, intPenWidth), , -);
//linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
linePath.AddArc(new Rectangle(intPenWidth / , this.Height - intPenWidth - intPenWidth / - , intPenWidth, intPenWidth), , -); lstArcs.Add(new ArcEntity() { rect = new Rectangle(-, , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-, this.Height - intPenWidth * , intPenWidth * , intPenWidth * ), startAngle = , sweepAngle = });
break;
#endregion
}
g.FillPath(new SolidBrush(conduitColor), path); //渐变色
int intCount = intPenWidth / / ;
int intSplit = ( - ) / intCount;
for (int i = ; i < intCount; i++)
{
int _penWidth = intPenWidth / - * i;
if (_penWidth <= )
_penWidth = ;
g.DrawPath(new Pen(new SolidBrush(Color.FromArgb(, Color.White.R, Color.White.G, Color.White.B)), _penWidth), linePath);
if (_penWidth == )
break;
} g.SetGDIHigh();
//使用抗锯齿画圆角
foreach (var item in lstArcs)
{
g.DrawArc(new Pen(new SolidBrush(this.BackColor)), item.rect, item.startAngle, item.sweepAngle);
} //液体流动
if (LiquidDirection != Conduit.LiquidDirection.None)
{
Pen p = new Pen(new SolidBrush(liquidColor), );
p.DashPattern = new float[] { , };
p.DashOffset = intLineLeft * (LiquidDirection == Conduit.LiquidDirection.Forward ? - : );
g.DrawPath(p, linePath);
}
} /// <summary>
/// Class ArcEntity.
/// </summary>
class ArcEntity
{
/// <summary>
/// Gets or sets the rect.
/// </summary>
/// <value>The rect.</value>
public Rectangle rect { get; set; }
/// <summary>
/// Gets or sets the start angle.
/// </summary>
/// <value>The start angle.</value>
public float startAngle { get; set; }
/// <summary>
/// Gets or sets the sweep angle.
/// </summary>
/// <value>The sweep angle.</value>
public float sweepAngle { get; set; }
} } /// <summary>
/// Enum LiquidDirection
/// </summary>
public enum LiquidDirection
{
/// <summary>
/// The none
/// </summary>
None,
/// <summary>
/// The forward
/// </summary>
Forward,
/// <summary>
/// The backward
/// </summary>
Backward
} /// <summary>
/// 管道样式Enum ConduitStyle
/// </summary>
public enum ConduitStyle
{
/// <summary>
/// 直线 The horizontal none none
/// </summary>
Horizontal_None_None,
/// <summary>
/// 左上The horizontal up none
/// </summary>
Horizontal_Up_None,
/// <summary>
/// 左下The horizontal down none
/// </summary>
Horizontal_Down_None,
/// <summary>
/// 右上The horizontal none up
/// </summary>
Horizontal_None_Up,
/// <summary>
/// 右下The horizontal none down
/// </summary>
Horizontal_None_Down,
/// <summary>
/// 左下右上The horizontal down up
/// </summary>
Horizontal_Down_Up,
/// <summary>
/// 左上右下The horizontal up down
/// </summary>
Horizontal_Up_Down,
/// <summary>
/// 左上,右上The horizontal up up
/// </summary>
Horizontal_Up_Up,
/// <summary>
/// 左下右下The horizontal down down
/// </summary>
Horizontal_Down_Down, /// <summary>
/// 竖线The vertical none none
/// </summary>
Vertical_None_None,
/// <summary>
/// 上左The vertical left none
/// </summary>
Vertical_Left_None,
/// <summary>
/// 上右The vertical right none
/// </summary>
Vertical_Right_None,
/// <summary>
/// 下左The vertical none left
/// </summary>
Vertical_None_Left,
/// <summary>
/// 下右The vertical none right
/// </summary>
Vertical_None_Right,
/// <summary>
/// 上左下右The vertical left right
/// </summary>
Vertical_Left_Right,
/// <summary>
/// 上右下左The vertical right left
/// </summary>
Vertical_Right_Left,
/// <summary>
/// 上左下左The vertical left left
/// </summary>
Vertical_Left_Left,
/// <summary>
/// 上右下右The vertical right left
/// </summary>
Vertical_Right_Right,
}
}

最后的话

如果你喜欢的话,请到 https://gitee.com/kwwwvagaa/net_winform_custom_control 点个星星吧

(五十五)c#Winform自定义控件-管道的更多相关文章

  1. (五十)c#Winform自定义控件-滑块

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...

  2. 第三百五十五天 how can I 坚持

    快一年了,三百五十五天了,等写个程序算算时间,看看日期和天数能不能对的上,哈哈. 计划还是未制定,天气预报还是没有写完,立马行动,发完这个博客,立马行动. 计划:设计模式1个月,三大框架3个月,计算机 ...

  3. 第三百五十五节,Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy信号详解

    第三百五十五节,Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy信号详解 信号一般使用信号分发器dispatcher.connect(),来设置信号,和信号触发函数,当捕获到信号时执行 ...

  4. “全栈2019”Java第五十五章:方法的静态绑定与动态绑定

    难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java第 ...

  5. 孤荷凌寒自学python第五十五天初识MongoDb数据库

    孤荷凌寒自学python第五十五天第一天初识MongoDb数据库 (完整学习过程屏幕记录视频地址在文末) 大家好,2019年新年快乐! 本来我想的是借新年第一天开始,正式尝试学习爬虫,结果今天偶然发现 ...

  6. (三十)c#Winform自定义控件-文本框(三)

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

  7. OpenCV开发笔记(五十五):红胖子8分钟带你深入了解Haar、LBP特征以及级联分类器识别过程(图文并茂+浅显易懂+程序源码)

    若该文为原创文章,未经允许不得转载原博主博客地址:https://blog.csdn.net/qq21497936原博主博客导航:https://blog.csdn.net/qq21497936/ar ...

  8. abp(net core)+easyui+efcore实现仓储管理系统——出库管理之六(五十五)

    abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统--ABP总体介绍(一) abp(net core)+ ...

  9. (二十)c#Winform自定义控件-有后退的窗体

    前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...

随机推荐

  1. Unity3D热更新之LuaFramework篇[08]--热更新原理及热更服务器搭建

    前言 前面铺垫了这么久,终于要开始写热更新了. Unity游戏热更新包含两个方面,一个是资源的更新,一个是脚本的更新. 资源更新是Unity本来就支持的,在各大平台也都能用.而脚本的热更新在iOS平台 ...

  2. kubernetes 1.15.1 高可用部署 -- 从零开始

    这是一本书!!! 一本写我在容器生态圈的所学!!! 重点先知: 1. centos 7.6安装优化 2. k8s 1.15.1 高可用部署 3. 网络插件calico 4. dashboard 插件 ...

  3. OLE--SWT高级控件

    OLE和ActiveX控件的支持    OLE(Object Link Embeded)是指在程序之间链接和嵌入对象数据.通过OLE技术可以在一个应用程序中执行其他的应用程序.    而ActiveX ...

  4. 为什么你要用 Spring?

    ​ 前言 现在Spring几乎成为了Java在企业级复杂应用开发的代名词,得益于Spring简单的设计哲学和其完善的生态圈,确实为廉颇老矣,尚能饭否的 Java 带来了“春天”,有很多同学刚接触Jav ...

  5. 的Blog

    作者:Ovear链接:https://www.zhihu.com/question/20215561/answer/40316953来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请 ...

  6. HTML5 第二章 列表和表格和媒体元素

    列表: (1)什么是列表? 列表就是信息资源的一种展示形式. (2)无序列表: 语法: <ul> <li>第1项</li> <li>第2项</li ...

  7. 恐怖的Hibernate和JavaFX Table CallBack!

    目录 [隐藏] 1 Hibernate 2 JavaFX Table Hibernate 最近在做 JavaFX 应用,不管再怎么避免数据持久化,但面对几十万的数据量的时候也只能乖乖的去配置持久层框架 ...

  8. Docker最简单入门之(二)——简单使用Docker

    0.前言 本章主要写一些怎么使用Docker,拉取镜像和创建容器等之类的Docker的常用基本操作.在开始写之前,大家需要明白一下几个名词的含义 1.镜像:镜像是指一个类似于安装包的东西,尝试安装过电 ...

  9. Apache 80端口可以访问,8080却不可访问

    RT, 记录一下,后面看是否有解决方案.

  10. spring-boot-starter-quartz集群实践

    [**前情提要**]由于项目需要,需要一个定时任务集群,故此有了这个spring-boot-starter-quartz集群的实践.springboot的版本为:2.1.6.RELEASE:quart ...