修改项目结构

This commit is contained in:
gongxh
2021-12-26 21:30:02 +08:00
parent b06189cb49
commit d39ac43a08
106 changed files with 3392 additions and 3083 deletions

View File

@@ -0,0 +1,148 @@
// LEase.AnimateBase
using System;
using LEase;
public class AnimateBase
{
public static double Back(double x, LEaseMode easeMode)
{
switch (easeMode)
{
case LEaseMode.EaseIn:
return 2.70158 * x * x * x - 1.70158 * x * x;
case LEaseMode.EaseOut:
return 1.0 + 2.70158 * Math.Pow(x - 1.0, 3.0) + 1.70158 * Math.Pow(x - 1.0, 2.0);
case LEaseMode.EaseInOut:
return (x < 0.5) ? (Math.Pow(2.0 * x, 2.0) * (7.189819 * x - 2.5949095) / 2.0) : ((Math.Pow(2.0 * x - 2.0, 2.0) * (7.189819 * x - 4.5949095) + 2.0) / 2.0);
default:
return 0.0;
}
}
private static double BounceOut(double x)
{
if (x < 0.36363636363636365)
{
return 7.5625 * x * x;
}
if (x < 0.72727272727272729)
{
return 7.5625 * (x -= 0.54545454545454541) * x + 0.75;
}
if (x < 0.90909090909090906)
{
return 7.5625 * (x -= 0.81818181818181823) * x + 0.9375;
}
return 7.5625 * (x -= 21.0 / 22.0) * x + 63.0 / 64.0;
}
public static double Bounce(double x, LEaseMode easeMode)
{
switch (easeMode)
{
case LEaseMode.EaseIn:
return 1.0 - BounceOut(1.0 - x);
case LEaseMode.EaseOut:
return BounceOut(x);
case LEaseMode.EaseInOut:
return (x < 0.5) ? ((1.0 - BounceOut(1.0 - 2.0 * x)) / 2.0) : ((1.0 + BounceOut(2.0 * x - 1.0)) / 2.0);
default:
return 0.0;
}
}
public static double Circle(double x, LEaseMode easeMode)
{
switch (easeMode)
{
case LEaseMode.EaseIn:
return 1.0 - Math.Sqrt(1.0 - Math.Pow(x, 2.0));
case LEaseMode.EaseOut:
return Math.Sqrt(1.0 - Math.Pow(x - 1.0, 2.0));
case LEaseMode.EaseInOut:
return (x < 0.5) ? ((1.0 - Math.Sqrt(1.0 - Math.Pow(2.0 * x, 2.0))) / 2.0) : ((Math.Sqrt(1.0 - Math.Pow(-2.0 * x + 2.0, 2.0)) + 1.0) / 2.0);
default:
return 0.0;
}
}
public static double Power(double x, LEaseMode easeMode, int power)
{
switch (easeMode)
{
case LEaseMode.EaseIn:
return Math.Pow(x, power);
case LEaseMode.EaseOut:
return 1.0 - Math.Pow(1.0 - x, power);
case LEaseMode.EaseInOut:
return (x < 0.5) ? (Math.Pow(2.0, power - 1) * Math.Pow(x, power)) : (1.0 - Math.Pow(-2.0 * x + 2.0, power) / 2.0);
default:
return 0.0;
}
}
public static double Quadratic(double x, LEaseMode easeMode)
{
return Power(x, easeMode, 2);
}
public static double Cubic(double x, LEaseMode easeMode)
{
return Power(x, easeMode, 3);
}
public static double Quartic(double x, LEaseMode easeMode)
{
return Power(x, easeMode, 4);
}
public static double Quintic(double x, LEaseMode easeMode)
{
return Power(x, easeMode, 5);
}
public static double Elastic(double x, LEaseMode easeMode)
{
switch (easeMode)
{
case LEaseMode.EaseIn:
return (x == 0.0) ? 0.0 : ((x == 1.0) ? 1.0 : ((0.0 - Math.Pow(2.0, 10.0 * x - 10.0)) * Math.Sin((x * 10.0 - 10.75) * 2.0 * Math.PI / 3.0)));
case LEaseMode.EaseOut:
return (x == 0.0) ? 0.0 : ((x == 1.0) ? 1.0 : (Math.Pow(2.0, -10.0 * x) * Math.Sin((x * 10.0 - 0.75) * 2.0 * Math.PI / 3.0) + 1.0));
case LEaseMode.EaseInOut:
return (x == 0.0) ? 0.0 : ((x == 1.0) ? 1.0 : ((x < 0.5) ? ((0.0 - Math.Pow(2.0, 20.0 * x - 10.0) * Math.Sin((x * 20.0 - 11.125) * 2.0 * Math.PI / 4.5)) / 2.0) : (Math.Pow(2.0, -20.0 * x + 10.0) * Math.Sin((x * 20.0 - 11.125) * 2.0 * Math.PI / 4.5) / 2.0 + 1.0)));
default:
return 0.0;
}
}
public static double Exponential(double x, LEaseMode easeMode)
{
switch (easeMode)
{
case LEaseMode.EaseIn:
return (x == 0.0) ? 0.0 : Math.Pow(2.0, 10.0 * x - 10.0);
case LEaseMode.EaseOut:
return (x == 1.0) ? 1.0 : (1.0 - Math.Pow(2.0, -10.0 * x));
case LEaseMode.EaseInOut:
return (x == 0.0) ? 0.0 : ((x == 1.0) ? 1.0 : ((x < 0.5) ? (Math.Pow(2.0, 20.0 * x - 10.0) / 2.0) : ((2.0 - Math.Pow(2.0, -20.0 * x + 10.0)) / 2.0)));
default:
return 0.0;
}
}
public static double Sine(double x, LEaseMode easeMode)
{
switch (easeMode)
{
case LEaseMode.EaseIn:
return 1.0 - Math.Cos(x * Math.PI / 2.0);
case LEaseMode.EaseOut:
return Math.Sin(x * Math.PI / 2.0);
case LEaseMode.EaseInOut:
return (0.0 - (Math.Cos(Math.PI * x) - 1.0)) / 2.0;
default:
return 0.0;
}
}
}

View File

@@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace CleanMachineHMI
{
[ToolboxItem(true)]
public class CircleButton : Button//继承按钮类 重新生成解决方案就能看见我啦
{
protected override void OnResize(EventArgs e)
{
base.OnResize(e);
System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath();
path.AddEllipse(2, 2, this.Width - 6, this.Height - 6);
Region = new Region(path);
}
protected override void OnPaint(PaintEventArgs e)//重新设置控件的形状
{
base.OnPaint(e);//递归 每次重新都发生此方法,保证其形状为自定义形状
Graphics g = e.Graphics;
g.DrawEllipse(new Pen(Color.White, 0), 2, 2, Width - 6, Height - 6);
}
}
}

View File

@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6891D010-F826-49C9-A087-2717A264BC16}</ProjectGuid>
<OutputType>Library</OutputType>
<RootNamespace>CleanMachine.Control</RootNamespace>
<AssemblyName>CleanMachine.Control</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AnimateBase.cs" />
<Compile Include="CircleButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="LEaseMode.cs" />
<Compile Include="LEaseType.cs" />
<Compile Include="LEnum.cs" />
<Compile Include="LEventArgs.cs" />
<Compile Include="LSwitchButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Service Include="{94E38DFF-614B-4cbd-B67C-F211BB35CE8B}" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@@ -0,0 +1,9 @@
namespace LEase
{
public enum LEaseMode
{
EaseIn,
EaseOut,
EaseInOut
}
}

View File

@@ -0,0 +1,16 @@
namespace LEase
{
public enum LEaseType
{
Back,
Bounce,
Circle,
Quadratic,
Cubic,
Quartic,
Quintic,
Elastic,
Exponential,
Sine
}
}

View File

@@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CleanMachineHMI
{
/// <summary>
/// 方向
/// </summary>
public enum Orientation
{
/// <summary>
/// 水平方向(从左到右)
/// </summary>
Horizontal_LR,
/// <summary>
/// 水平方向(从右到左)
/// </summary>
Horizontal_RL,
/// <summary>
/// 垂直方向(从上到上)
/// </summary>
Vertical_BT,
/// <summary>
/// 垂直方向(从上到下)
/// </summary>
Vertical_TB
}
/// <summary>
/// 鼠标状态
/// </summary>
public enum MouseStatus
{
/// <summary>
/// 鼠标进入
/// </summary>
Enter,
/// <summary>
/// 鼠标离开
/// </summary>
Leave,
/// <summary>
/// 鼠标按下
/// </summary>
Down,
/// <summary>
/// 鼠标按下释放
/// </summary>
Up
}
/// <summary>
/// 滚动条方向
/// </summary>
public enum OrientationScrollBar
{
/// <summary>
/// 水平方向
/// </summary>
Horizontal,
/// <summary>
/// 垂直方向
/// </summary>
Vertical
}
}

View File

@@ -0,0 +1,52 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace CleanMachineHMI
{
/// <summary>
/// 事件数据
/// </summary>
public class LEventArgs:EventArgs
{
/// <summary>
/// 事件数据
/// </summary>
/// <param name="value">值</param>
public LEventArgs(object value)
{
Value = value;
}
/// <summary>
/// 值
/// </summary>
public object Value { get; set; }
}
/// <summary>
/// 滚动条事件数据
/// </summary>
public class LScrollEventArgs : EventArgs
{
/// <summary>
/// 滚动条事件数据
/// </summary>
/// <param name="sliderPosition">滑块距顶部(垂直)/左侧(横向)位置</param>
/// <param name="showPosition">显示位置(正数)</param>
public LScrollEventArgs(float sliderPosition, float showPosition)
{
SliderPosition = sliderPosition;
ShowPosition = showPosition;
}
/// <summary>
/// 滑块距顶部(垂直)/左侧(横向)位置
/// </summary>
public float SliderPosition { get; set; }
/// <summary>
/// 显示位置(正数)
/// </summary>
public float ShowPosition { get; set; }
}
}

View File

@@ -0,0 +1,292 @@
/*
* 作者:Leslie Xin
* 邮箱:lesliexin@outlook.com
* 网站:www.lesliexin.com
*
* 版权所有,使用本代码需附上本段注释。
*
*/
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using LEase;
namespace CleanMachineHMI
{
[ToolboxItem(true)]
/// <summary>
/// 开关按钮
/// </summary>
[DefaultEvent("LSwitched")]
public class LSwitchButton:Control
{
/// <summary>
/// 开关按钮
/// </summary>
public LSwitchButton()
{
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
CreateControl();
tTimer = new System.Windows.Forms.Timer();
tTimer.Interval = 10;
tTimer.Tick += TTimer_Tick;
}
#region Event
/// <summary>
/// 委托
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public delegate void LSwitchedEventHandler(object sender, LEventArgs e);
/// <summary>
/// 开关状态发生改变时引发的事件
/// </summary>
public event LSwitchedEventHandler LSwitched;
#endregion
#region Property
private Color _CloseColor = Color.FromArgb(224, 224, 224);//浅灰
/// <summary>
/// “关”时背景色<para>默认:浅灰</para>
/// </summary>
[Category("DemoUI"), Description("“关”时背景色\r\n默认:浅灰")]
public Color L_CloseColor
{
get { return _CloseColor; }
set
{
_CloseColor = value;
Invalidate();
}
}
private Color _OpenColor = Color.FromArgb(128, 255, 128);//浅绿
/// <summary>
/// “开”时背景色<para>默认:浅绿</para>
/// </summary>
[Category("DemoUI"), Description("“开”时背景色\r\n默认:浅绿")]
public Color L_OpenColor
{
get { return _OpenColor; }
set
{
_OpenColor = value;
Invalidate();
}
}
private Color _DotColor = Color.White;
/// <summary>
/// 圆点颜色<para>默认:白色</para>
/// </summary>
[Category("DemoUI"), Description("圆点颜色\r\n默认:白色")]
public Color L_DotColor
{
get { return _DotColor; }
set
{
_DotColor = value;
Invalidate();
}
}
private int _DotHight = 20;
/// <summary>
/// 圆点高度(直径)<para>默认:20</para>
/// </summary>
[Category("DemoUI"), Description("圆点高度(直径)\r\n默认:20")]
public int L_DotHight
{
get { return _DotHight; }
set
{
_DotHight = value < 0 ? 0 : value;
Size =new Size(Width,Math.Max(_DotHight, _BarHight));
Invalidate();
}
}
private int _BarHight = 24;
/// <summary>
/// 背景条高度<para>默认:24</para>
/// </summary>
[Category("DemoUI"), Description("背景条高度\r\n默认:24")]
public int L_BarHight
{
get { return _BarHight; }
set
{
_BarHight = value < 0 ? 0 : value;
Size = new Size(Width, Math.Max(_DotHight, _BarHight));
Invalidate();
}
}
private bool _IsOpen = false;
/// <summary>
/// 开关状态是否是“开”<para>默认:false</para>
/// </summary>
[Category("DemoUI"), Description("开关状态是否是“开”\r\n默认:false")]
public bool L_IsOpen
{
get { return _IsOpen; }
set
{
_IsOpen = value;
Invalidate();
}
}
private int _Margin = 2;
/// <summary>
/// 圆点距左右两侧距离<para>默认:2</para>
/// </summary>
[Category("DemoUI"), Description("圆点距左右两侧距离\r\n默认:2")]
public int L_Margin
{
get { return _Margin; }
set
{
_Margin = value < 0 ? 0 : value; ;
Invalidate();
}
}
/// <summary>
/// 动画效果<para>默认:Quartic</para>
/// </summary>
[Category("DemoUI"), Description("动画效果\r\n默认:Quartic")]
public LEaseType L_AnimateType { get; set; } = LEaseType.Quartic;
#endregion
#region Private
Timer tTimer;
float fNowLocationBar, fNowLocationDot;
/// <summary>
/// 动画效果时长,毫秒
/// </summary>
int iDuration = 200;
int iNow;
bool bInAnimate = false;
float fRangeBar,fRangeDot;
#endregion
private void TTimer_Tick(object sender, EventArgs e)
{
bool b = (_IsOpen?(iNow>=0):(iNow<=iDuration));
if (b)
{
double d = 0;
switch (L_AnimateType)
{
case LEaseType.Back:
d = AnimateBase.Back(Convert.ToDouble(iNow) / iDuration, _IsOpen ? LEaseMode.EaseIn : LEaseMode.EaseOut);
break;
case LEaseType.Bounce:
d = AnimateBase.Bounce(Convert.ToDouble(iNow) / iDuration, _IsOpen ? LEaseMode.EaseIn : LEaseMode.EaseOut);
break;
case LEaseType.Circle:
d = AnimateBase.Circle(Convert.ToDouble(iNow) / iDuration, _IsOpen ? LEaseMode.EaseIn : LEaseMode.EaseOut);
break;
case LEaseType.Cubic:
d = AnimateBase.Cubic(Convert.ToDouble(iNow) / iDuration, _IsOpen ? LEaseMode.EaseIn : LEaseMode.EaseOut);
break;
case LEaseType.Elastic:
d = AnimateBase.Elastic(Convert.ToDouble(iNow) / iDuration, _IsOpen ? LEaseMode.EaseIn : LEaseMode.EaseOut);
break;
case LEaseType.Exponential:
d = AnimateBase.Exponential(Convert.ToDouble(iNow) / iDuration, _IsOpen ? LEaseMode.EaseIn : LEaseMode.EaseOut);
break;
case LEaseType.Quadratic:
d = AnimateBase.Quadratic(Convert.ToDouble(iNow) / iDuration, _IsOpen ? LEaseMode.EaseIn : LEaseMode.EaseOut);
break;
case LEaseType.Quartic:
d = AnimateBase.Quartic(Convert.ToDouble(iNow) / iDuration, _IsOpen ? LEaseMode.EaseIn : LEaseMode.EaseOut);
break;
case LEaseType.Quintic:
d = AnimateBase.Quintic(Convert.ToDouble(iNow) / iDuration, _IsOpen ? LEaseMode.EaseIn : LEaseMode.EaseOut);
break;
case LEaseType.Sine:
d = AnimateBase.Sine(Convert.ToDouble(iNow) / iDuration, _IsOpen ? LEaseMode.EaseIn : LEaseMode.EaseOut);
break;
}
fNowLocationBar = Convert.ToSingle(d * fRangeBar);
fNowLocationDot = Convert.ToSingle(d * fRangeDot)+_Margin;
iNow = _IsOpen ? (iNow-tTimer.Interval) : (iNow+tTimer.Interval);
Invalidate();
}
else
{
tTimer.Stop();
bInAnimate = false;
LSwitched?.Invoke(this, new LEventArgs(_IsOpen));
}
}
protected override void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified)
{
//为达到较好的视觉效果,宽度至少要是高度的两倍
int iHeight = Math.Max(_DotHight,_BarHight);
int iWidth = Math.Max(iHeight * 2, width);
iHeight++;
fRangeBar = iWidth - _BarHight;
fRangeDot = iWidth - _DotHight- _Margin * 2;
base.SetBoundsCore(x, y, iWidth, iHeight, specified);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.SmoothingMode = SmoothingMode.HighQuality;
Pen penBarBack = new Pen(_CloseColor, _BarHight);
Pen penBarFore = new Pen(_OpenColor, _BarHight);
penBarBack.StartCap = LineCap.Round;
penBarBack.EndCap = LineCap.Round;
penBarFore.StartCap = LineCap.Round;
penBarFore.EndCap = LineCap.Round;
float fCapHalfWidth = _BarHight / 2.0f;
float fLeftTop = Convert.ToSingle(Height - _DotHight) / 2.0f;
if (!bInAnimate)
{
fNowLocationBar = _IsOpen ? 0: fRangeBar;
fNowLocationDot = _IsOpen ? _Margin : (fRangeDot + _Margin);
}
//画背景
e.Graphics.DrawLine(penBarBack, fCapHalfWidth, Height / 2f, Width - fCapHalfWidth, Height / 2f);
//画前景
e.Graphics.DrawLine(penBarFore, fCapHalfWidth, Height / 2f, Width - fCapHalfWidth - fNowLocationBar, Height / 2f);
//画圆点
e.Graphics.FillEllipse(new SolidBrush(_DotColor),Width-_DotHight- fNowLocationDot, fLeftTop, _DotHight, _DotHight);
}
protected override void OnMouseDown(MouseEventArgs e)
{
base.OnMouseDown(e);
if (!bInAnimate)
{
bInAnimate = true;
_IsOpen = !_IsOpen;
iNow = _IsOpen ? iDuration : 0;
tTimer.Start();
}
}
}
}

View File

@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("CleanMachine.Control")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CleanMachine.Control")]
[assembly: AssemblyCopyright("Copyright © 2021")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("6891d010-f826-49c9-a087-2717a264bc16")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]