(五十五)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 ...
随机推荐
- Maven重新下载未下载完成的jar包
使用maven下载jar包,经常会遇到下载失败的情况,如果失败的jar包过多,或是不清楚到底有那些jar包在下载过程中出现了问题.可通过maven命令重新批量下载未成功的jar包. 1,打开cmd , ...
- 《HelloGitHub》第 40 期
<HelloGitHub>第 40 期 兴趣是最好的老师,HelloGitHub 就是帮你找到兴趣! 简介 分享 GitHub 上有趣.入门级的开源项目. 这是一个面向编程新手.热爱编程. ...
- 第二章 :初识MySQL
一.MySQL 1. MySQL的版本 社区版 企业帮 2.MySQL的优势 1.运行速度快 2.使用成本低 3.容易使用 4.可移植性高 5.适用更多用户 二.默认字符集设置 1.Standard ...
- solr配置分词器
一.solr4.10 + mmseg4j-2.2.0分词器 1.solr的安装部署:http://www.cnblogs.com/honger/p/5876289.html,注意不同的版本安装方式可能 ...
- Reporting报表开发知识合并[个人原创]
[个人原创] ,转发请声明原文链接 了解 a) SSRS全称 SQL Server Reporting Services,是依赖于数据库运行的,是微软开发的重量级别的BI产品 b) ...
- python post接口测试第一个用例日记
如下是我自己公司的一个请求,学习过程顺便记录下,都是白话语言,不那么专业,不喜勿喷! 首先看下图,post请求一般需要填写参数url, data(一般是表格类型的参数,如我们智联驾驶APP登录的参数) ...
- FB的新专利竟要监看使用者的脸
大家应该会很好奇Facebook又在搞什么新花招,这个专利的名称是"Techniques for emotion detection and content delivery",其 ...
- win10教育版激活错误:在运行 Microsoft Windows 非核心版本的计算机上,运行"slui.exe ...”
折腾了一天,最终轻松解决,先启用Software Protection服务,在激活(密钥或者工具都行). PS:但是这样还是无法解决Software Protection自动停止的问题,这个可以参考网 ...
- 运营商手机视频流量包业务日志ETL及统计分析
自己做过的项目在这里做一个记录,否则就感觉不是自己的了.一是因为过去时间已经很长了,二是因为当时做得有点粗糙,最后还不了了之了. 话不多说,先大致介绍一下项目背景.以前各大手机视频 App 一般都有运 ...
- Mysql无法启动情况下,如何恢复数据?
本文适用于,mysql无法启动,但数据文件未丢失的情况. Mysql因意外情况,导致无法启动,数据库未做备份的情况下,如何将数据迁移至其他数据库中. 原数据库地址:192.168.1.100(以下简称 ...