(五十五)c#Winform自定义控件-管道
官网
前提
入行已经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自定义控件-管道的更多相关文章
- (五十)c#Winform自定义控件-滑块
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. GitHub:https://github.com/kwwwvagaa/NetWinformControl 码云:ht ...
- 第三百五十五天 how can I 坚持
快一年了,三百五十五天了,等写个程序算算时间,看看日期和天数能不能对的上,哈哈. 计划还是未制定,天气预报还是没有写完,立马行动,发完这个博客,立马行动. 计划:设计模式1个月,三大框架3个月,计算机 ...
- 第三百五十五节,Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy信号详解
第三百五十五节,Python分布式爬虫打造搜索引擎Scrapy精讲—scrapy信号详解 信号一般使用信号分发器dispatcher.connect(),来设置信号,和信号触发函数,当捕获到信号时执行 ...
- “全栈2019”Java第五十五章:方法的静态绑定与动态绑定
难度 初级 学习时间 10分钟 适合人群 零基础 开发语言 Java 开发环境 JDK v11 IntelliJ IDEA v2018.3 文章原文链接 "全栈2019"Java第 ...
- 孤荷凌寒自学python第五十五天初识MongoDb数据库
孤荷凌寒自学python第五十五天第一天初识MongoDb数据库 (完整学习过程屏幕记录视频地址在文末) 大家好,2019年新年快乐! 本来我想的是借新年第一天开始,正式尝试学习爬虫,结果今天偶然发现 ...
- (三十)c#Winform自定义控件-文本框(三)
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...
- OpenCV开发笔记(五十五):红胖子8分钟带你深入了解Haar、LBP特征以及级联分类器识别过程(图文并茂+浅显易懂+程序源码)
若该文为原创文章,未经允许不得转载原博主博客地址:https://blog.csdn.net/qq21497936原博主博客导航:https://blog.csdn.net/qq21497936/ar ...
- abp(net core)+easyui+efcore实现仓储管理系统——出库管理之六(五十五)
abp(net core)+easyui+efcore实现仓储管理系统目录 abp(net core)+easyui+efcore实现仓储管理系统--ABP总体介绍(一) abp(net core)+ ...
- (二十)c#Winform自定义控件-有后退的窗体
前提 入行已经7,8年了,一直想做一套漂亮点的自定义控件,于是就有了本系列文章. 开源地址:https://gitee.com/kwwwvagaa/net_winform_custom_control ...
随机推荐
- 一文搞懂List 、List<Object>、List<?>的区别以及<? extends T>与<? super T>的区别
前段时间看<Java编程思想>泛型时对 <? extends T>与<? super T>很懵逼,接着看到泛型与集合的更蒙蔽,随后又翻开<码出高效>时, ...
- 细说RESTFul API之版本管理
目录 接口实现版本管理的意义 如何实现接口的版本管理 项目实战 接口实现版本管理的意义 API版本管理的重要性不言而喻,对于API的设计者和使用者而言,版本管理都有着非常重要的意义. 首先,对于API ...
- 敏捷和DevOps:是敌是友?
DevOps是敏捷在软件开发团队的另一应用.那么相比之下,哪个更胜一筹? 一边,有业界认可的scrum master,它的朋友极限编程者,以及由其衍生的 LeSS.SAFe.DAD等,是敏捷. 另一边 ...
- GDB 基本用法
1.编译文件时需要加上 -g 选项,并非是将源码嵌入可执行文件,只是加入源代码的信息.eg:gcc -g main.c -o main 2.直接按回车键会重复上一条命令 3.基本指令 help,可以查 ...
- IOS应用无法下载、此时无法安装应用程序
无法安装应用 app开发者,进行程序测试,重试还不行,就重新打包, 个人,更改wifi的dns 在“设置” –> “WiFi” –> 进入当前的WiFi 进入之后点击旁边的叹号,然后进入之 ...
- http://regex.alf.nu/ 非标准答案
Plain strings (207) foo Anchors (206) ...
- docker挂载volume的用户权限问题,理解docker容器的uid
docker挂载volume的用户权限问题,理解docker容器的uid 在刚开始使用docker volume挂载数据卷的时候,经常出现没有权限的问题. 这里通过遇到的问题来理解docker容器用户 ...
- 【POJ - 2456】Aggressive cows(二分)
Aggressive cows 直接上中文了 Descriptions 农夫 John 建造了一座很长的畜栏,它包括N (2 <= N <= 100,000)个隔间,这些小隔间依次编号为x ...
- django+uwsgi+nginx 部署生产环境
一.Uwsgi安装 python3 -m pip install uwsgi cp /usr/local/python3/bin/uwsgi /usr/bin/ 测试 在django项目主目录下cre ...
- luogu1330_封锁阳光大学 图的遍历
传送门 解释:(转自洛谷题解) 首先,肯定要明确一点,那就是这个图是不一定联通的.于是,我们就可以将整张图切分成许多分开的连同子图来处理.然而最重要的事情是:如何处理一个连通图? 乍看下去,似乎无从下 ...