(五十五)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 ...
随机推荐
- spark streaming 接收kafka消息之五 -- spark streaming 和 kafka 的对接总结
Spark streaming 和kafka 处理确保消息不丢失的总结 接入kafka 我们前面的1到4 都在说 spark streaming 接入 kafka 消息的事情.讲了两种接入方式,以及s ...
- 12. 集合类Collection和Map
*:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: 0 !important; } /* ...
- 【iOS】图片缩放动画
iOS 开发中,可用 UIView 的下述方法实现图片的缩放动画效果: + transitionWithView:duration:options:animations:completion: 示例代 ...
- mysql5.7.18-winx64安装
win10下装mysql-5.7.18-winx64 步骤1 官网下载地址:https://dev.mysql.com/downloads/mysql/ 选择手动安装版: 解压到D盘mysql文件夹下 ...
- Python基础总结之异常、调试代码第十二天开始(新手可相互督促)
年薪20万的梦想,加油! 我们在写代码的时候,控制台经常会报错,因为某种错误,导致我们的程序停止,且不再运行下面的代码. 我们看一个错误的代码示例: def add_1(): #没有参数 print( ...
- python3学习--文件读写
这一篇我们来看文件读写操作. 打开和创建文件主要是open()函数: f = open('filename','r') # 读模式 f = open('filename','w') # 写模式 f = ...
- No!No!No! It's not fashion!
还记得搞怪的hold住姐Miss Lin么,对于人们常规的行为,Miss Lin会挑起夸张的眉毛说:"Oh my God, it's not fashion!".如果程序员圈子里有 ...
- 从Dictionary源码看哈希表
一.基本概念 哈希:哈希是一种查找算法,在关键字和元素的存储地址之间建立一个确定的对应关系,每个关键字对应唯一的存储地址,这些存储地址构成了有限.连续的存储地址. 哈希函数:在关键字和元素的存储地址之 ...
- css3实现loading效果--当页面加载过程中显示Loading的进度条,全部加载完成之后进度条消失
一个页面等图片资源全部加载完成,会需要很长时间,用户体验会很差,所以我们需要loading来掩盖这个漫长的过程! emmm,定时器?写个定时器还要清除,万一造成内存泄露?定时器之间还会互相影响,呼呼呼 ...
- JVM调优前戏之JDK命令行工具---jhat
在JDK的命令行中,一般开发人员最耳熟能详的肯定就是java,javac,javap等常用命令,不过在jdk/bin下还有许多其他的命令行工具,它们被用来监测JVM运行时的状态,下面我们来详细解读一下 ...