Commit 970640e7 HZH

add 池子

1 个父辈 db2b4e71
// ***********************************************************************
// Assembly : HZH_Controls
// Created : 2019-09-06
//
// ***********************************************************************
// <copyright file="UCPond.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
{
/// <summary>
/// Class UCPond.
/// Implements the <see cref="System.Windows.Forms.UserControl" />
/// </summary>
/// <seealso cref="System.Windows.Forms.UserControl" />
public class UCPond : UserControl
{
/// <summary>
/// The maximum value
/// </summary>
private decimal maxValue = 100;
/// <summary>
/// Gets or sets the maximum value.
/// </summary>
/// <value>The maximum value.</value>
[Description("最大值"), Category("自定义")]
public decimal MaxValue
{
get { return maxValue; }
set
{
if (value < m_value)
return;
maxValue = value;
Refresh();
}
}
/// <summary>
/// The m value
/// </summary>
private decimal m_value = 0;
/// <summary>
/// Gets or sets the value.
/// </summary>
/// <value>The value.</value>
[Description("值"), Category("自定义")]
public decimal Value
{
get { return m_value; }
set
{
if (value < 0)
return;
if (value > maxValue)
m_value = maxValue;
else
m_value = value;
Refresh();
}
}
/// <summary>
/// The wall color
/// </summary>
private Color wallColor = Color.FromArgb(255, 77, 59);
/// <summary>
/// Gets or sets the color of the wall.
/// </summary>
/// <value>The color of the wall.</value>
[Description("池壁颜色"), Category("自定义")]
public Color WallColor
{
get { return wallColor; }
set
{
wallColor = value;
Refresh();
}
}
/// <summary>
/// The wall width
/// </summary>
private int wallWidth = 2;
/// <summary>
/// Gets or sets the width of the wall.
/// </summary>
/// <value>The width of the wall.</value>
[Description("池壁宽度"), Category("自定义")]
public int WallWidth
{
get { return wallWidth; }
set
{
if (value <= 0)
return;
wallWidth = value;
Refresh();
}
}
/// <summary>
/// The liquid color
/// </summary>
private Color liquidColor = Color.FromArgb(3, 169, 243);
/// <summary>
/// Initializes a new instance of the <see cref="UCPond"/> class.
/// </summary>
public UCPond()
{
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.Size = new Size(150, 50);
}
/// <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);
if (Height <= 0)
return;
var g = e.Graphics;
g.SetGDIHigh();
int intHeight = (int)(m_value / maxValue * this.Height);
if (intHeight != 0)
{
g.FillRectangle(new SolidBrush(liquidColor), new Rectangle(0, this.Height - intHeight, this.Width, intHeight));
}
//划边
g.FillRectangle(new SolidBrush(wallColor), 0, 0, wallWidth, this.Height);
g.FillRectangle(new SolidBrush(wallColor), 0, this.Height - wallWidth, this.Width, wallWidth);
g.FillRectangle(new SolidBrush(wallColor), this.Width - wallWidth-1, 0, wallWidth, this.Height);
}
}
}
......@@ -20,6 +20,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
......@@ -99,6 +100,9 @@
<Compile Include="Controls\FactoryControls\Conveyor\UCConveyor.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\FactoryControls\Pond\UCPond.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="Controls\FactoryControls\Valve\UCValve.cs">
<SubType>UserControl</SubType>
</Compile>
......
......@@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.ucValve4 = new HZH_Controls.Controls.UCValve();
this.ucValve1 = new HZH_Controls.Controls.UCValve();
this.ucValve2 = new HZH_Controls.Controls.UCValve();
this.ucValve3 = new HZH_Controls.Controls.UCValve();
......@@ -67,11 +68,28 @@
this.ucConduit10 = new HZH_Controls.Controls.Conduit.UCConduit();
this.ucConduit1 = new HZH_Controls.Controls.Conduit.UCConduit();
this.ucBottle1 = new HZH_Controls.Controls.UCBottle();
this.ucValve4 = new HZH_Controls.Controls.UCValve();
this.ucPond1 = new HZH_Controls.Controls.UCPond();
this.SuspendLayout();
//
// ucValve4
//
this.ucValve4.AsisBottomColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(243)))));
this.ucValve4.AxisColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(243)))));
this.ucValve4.LiquidColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(243)))));
this.ucValve4.LiquidDirection = HZH_Controls.Controls.Conduit.LiquidDirection.Backward;
this.ucValve4.LiquidSpeed = 100;
this.ucValve4.Location = new System.Drawing.Point(1079, 52);
this.ucValve4.Name = "ucValve4";
this.ucValve4.Opened = true;
this.ucValve4.Size = new System.Drawing.Size(169, 106);
this.ucValve4.SwitchColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(30)))), ((int)(((byte)(99)))));
this.ucValve4.TabIndex = 22;
this.ucValve4.ValveColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucValve4.ValveStyle = HZH_Controls.Controls.ValveStyle.Horizontal_Bottom;
//
// ucValve1
//
this.ucValve1.AsisBottomColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(243)))));
this.ucValve1.AxisColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(243)))));
this.ucValve1.LiquidColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(243)))));
this.ucValve1.LiquidDirection = HZH_Controls.Controls.Conduit.LiquidDirection.Backward;
......@@ -87,11 +105,12 @@
//
// ucValve2
//
this.ucValve2.AsisBottomColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(243)))));
this.ucValve2.AxisColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(243)))));
this.ucValve2.LiquidColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(243)))));
this.ucValve2.LiquidDirection = HZH_Controls.Controls.Conduit.LiquidDirection.Backward;
this.ucValve2.LiquidDirection = HZH_Controls.Controls.Conduit.LiquidDirection.Forward;
this.ucValve2.LiquidSpeed = 100;
this.ucValve2.Location = new System.Drawing.Point(1222, 307);
this.ucValve2.Location = new System.Drawing.Point(1222, 279);
this.ucValve2.Name = "ucValve2";
this.ucValve2.Opened = true;
this.ucValve2.Size = new System.Drawing.Size(97, 131);
......@@ -102,11 +121,12 @@
//
// ucValve3
//
this.ucValve3.AsisBottomColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(243)))));
this.ucValve3.AxisColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(243)))));
this.ucValve3.LiquidColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(243)))));
this.ucValve3.LiquidDirection = HZH_Controls.Controls.Conduit.LiquidDirection.Backward;
this.ucValve3.LiquidDirection = HZH_Controls.Controls.Conduit.LiquidDirection.Forward;
this.ucValve3.LiquidSpeed = 100;
this.ucValve3.Location = new System.Drawing.Point(1259, 176);
this.ucValve3.Location = new System.Drawing.Point(1259, 148);
this.ucValve3.Name = "ucValve3";
this.ucValve3.Opened = true;
this.ucValve3.Size = new System.Drawing.Size(97, 131);
......@@ -592,29 +612,34 @@
0,
0});
//
// ucValve4
// ucPond1
//
this.ucValve4.AxisColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(243)))));
this.ucValve4.LiquidColor = System.Drawing.Color.FromArgb(((int)(((byte)(3)))), ((int)(((byte)(169)))), ((int)(((byte)(243)))));
this.ucValve4.LiquidDirection = HZH_Controls.Controls.Conduit.LiquidDirection.Backward;
this.ucValve4.LiquidSpeed = 100;
this.ucValve4.Location = new System.Drawing.Point(1079, 52);
this.ucValve4.Name = "ucValve4";
this.ucValve4.Opened = true;
this.ucValve4.Size = new System.Drawing.Size(169, 106);
this.ucValve4.SwitchColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(30)))), ((int)(((byte)(99)))));
this.ucValve4.TabIndex = 22;
this.ucValve4.ValveColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucValve4.ValveStyle = HZH_Controls.Controls.ValveStyle.Horizontal_Bottom;
this.ucPond1.Location = new System.Drawing.Point(1206, 384);
this.ucPond1.MaxValue = new decimal(new int[] {
100,
0,
0,
0});
this.ucPond1.Name = "ucPond1";
this.ucPond1.Size = new System.Drawing.Size(150, 71);
this.ucPond1.TabIndex = 23;
this.ucPond1.Value = new decimal(new int[] {
50,
0,
0,
0});
this.ucPond1.WallColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
this.ucPond1.WallWidth = 2;
//
// Form4
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(1368, 680);
this.Controls.Add(this.ucValve2);
this.Controls.Add(this.ucPond1);
this.Controls.Add(this.ucValve4);
this.Controls.Add(this.ucValve1);
this.Controls.Add(this.ucValve2);
this.Controls.Add(this.ucValve3);
this.Controls.Add(this.ucConveyor2);
this.Controls.Add(this.ucConveyor6);
......@@ -700,5 +725,6 @@
private HZH_Controls.Controls.UCValve ucValve1;
private HZH_Controls.Controls.UCValve ucValve2;
private HZH_Controls.Controls.UCValve ucValve4;
private HZH_Controls.Controls.UCPond ucPond1;
}
}
\ No newline at end of file
......@@ -13,7 +13,7 @@
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<PlatformTarget>x86</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!