mirror of
https://github.com/eggplantlwj/VisionEdit.git
synced 2026-03-24 08:46:35 +08:00
1、优化LOG显示与引用
2、添加PMA工具,工具内容待完善 3、修复流程树显示 4、添加开源项目,优化UI空间 5、其他BUG更改
This commit is contained in:
116
UsingControl/HZHControls/Controls/Btn/UCBtnExt.Designer.cs
generated
Normal file
116
UsingControl/HZHControls/Controls/Btn/UCBtnExt.Designer.cs
generated
Normal file
@@ -0,0 +1,116 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCBtnExt.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCBtnExt.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCControlBase" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCControlBase" />
|
||||
public partial class UCBtnExt
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lbl = new System.Windows.Forms.Label();
|
||||
this.lblTips = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lbl
|
||||
//
|
||||
this.lbl.BackColor = System.Drawing.Color.Transparent;
|
||||
this.lbl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.lbl.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.lbl.ForeColor = System.Drawing.Color.White;
|
||||
this.lbl.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.lbl.Location = new System.Drawing.Point(0, 0);
|
||||
this.lbl.Name = "lbl";
|
||||
this.lbl.Size = new System.Drawing.Size(184, 60);
|
||||
this.lbl.TabIndex = 0;
|
||||
this.lbl.Text = "自定义按钮";
|
||||
this.lbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.lbl.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lbl_MouseDown);
|
||||
//
|
||||
// lblTips
|
||||
//
|
||||
this.lblTips.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.lblTips.BackColor = System.Drawing.Color.Transparent;
|
||||
this.lblTips.Font = new System.Drawing.Font("Arial Unicode MS", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.lblTips.ForeColor = System.Drawing.Color.White;
|
||||
this.lblTips.ImageIndex = 0;
|
||||
this.lblTips.Location = new System.Drawing.Point(158, 0);
|
||||
this.lblTips.Name = "lblTips";
|
||||
this.lblTips.Size = new System.Drawing.Size(24, 24);
|
||||
this.lblTips.TabIndex = 1;
|
||||
this.lblTips.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.lblTips.Visible = false;
|
||||
//
|
||||
// UCBtnExt
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.ConerRadius = 5;
|
||||
this.Controls.Add(this.lblTips);
|
||||
this.Controls.Add(this.lbl);
|
||||
this.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.IsRadius = true;
|
||||
this.IsShowRect = true;
|
||||
this.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.Name = "UCBtnExt";
|
||||
this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(58)))));
|
||||
this.Size = new System.Drawing.Size(184, 60);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The label
|
||||
/// </summary>
|
||||
public System.Windows.Forms.Label lbl;
|
||||
/// <summary>
|
||||
/// The label tips
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Label lblTips;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
255
UsingControl/HZHControls/Controls/Btn/UCBtnExt.cs
Normal file
255
UsingControl/HZHControls/Controls/Btn/UCBtnExt.cs
Normal file
@@ -0,0 +1,255 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCBtnExt.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCBtnExt.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCControlBase" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCControlBase" />
|
||||
[DefaultEvent("BtnClick")]
|
||||
|
||||
public partial class UCBtnExt : UCControlBase
|
||||
{
|
||||
#region 字段属性
|
||||
private bool enabledMouseEffect = false;
|
||||
[Description("是否启用鼠标效果"), Category("自定义")]
|
||||
public bool EnabledMouseEffect
|
||||
{
|
||||
get { return enabledMouseEffect; }
|
||||
set { enabledMouseEffect = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否显示角标
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is show tips; otherwise, <c>false</c>.</value>
|
||||
[Description("是否显示角标"), Category("自定义")]
|
||||
public bool IsShowTips
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.lblTips.Visible;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.lblTips.Visible = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 角标文字
|
||||
/// </summary>
|
||||
/// <value>The tips text.</value>
|
||||
[Description("角标文字"), Category("自定义")]
|
||||
public string TipsText
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.lblTips.Text;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.lblTips.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The BTN back color
|
||||
/// </summary>
|
||||
private Color _btnBackColor = Color.White;
|
||||
/// <summary>
|
||||
/// 按钮背景色
|
||||
/// </summary>
|
||||
/// <value>The color of the BTN back.</value>
|
||||
[Description("按钮背景色"), Category("自定义")]
|
||||
public Color BtnBackColor
|
||||
{
|
||||
get { return _btnBackColor; }
|
||||
set
|
||||
{
|
||||
_btnBackColor = value;
|
||||
this.BackColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The BTN fore color
|
||||
/// </summary>
|
||||
private Color _btnForeColor = Color.White;
|
||||
/// <summary>
|
||||
/// 按钮字体颜色
|
||||
/// </summary>
|
||||
/// <value>The color of the BTN fore.</value>
|
||||
[Description("按钮字体颜色"), Category("自定义")]
|
||||
public virtual Color BtnForeColor
|
||||
{
|
||||
get { return _btnForeColor; }
|
||||
set
|
||||
{
|
||||
_btnForeColor = value;
|
||||
this.lbl.ForeColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The BTN font
|
||||
/// </summary>
|
||||
private Font _btnFont = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
/// <summary>
|
||||
/// 按钮字体
|
||||
/// </summary>
|
||||
/// <value>The BTN font.</value>
|
||||
[Description("按钮字体"), Category("自定义")]
|
||||
public Font BtnFont
|
||||
{
|
||||
get { return _btnFont; }
|
||||
set
|
||||
{
|
||||
_btnFont = value;
|
||||
this.lbl.Font = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按钮点击事件
|
||||
/// </summary>
|
||||
[Description("按钮点击事件"), Category("自定义")]
|
||||
public event EventHandler BtnClick;
|
||||
|
||||
/// <summary>
|
||||
/// The BTN text
|
||||
/// </summary>
|
||||
private string _btnText;
|
||||
/// <summary>
|
||||
/// 按钮文字
|
||||
/// </summary>
|
||||
/// <value>The BTN text.</value>
|
||||
[Description("按钮文字"), Category("自定义")]
|
||||
public virtual string BtnText
|
||||
{
|
||||
get { return _btnText; }
|
||||
set
|
||||
{
|
||||
_btnText = value;
|
||||
lbl.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m tips color
|
||||
/// </summary>
|
||||
private Color m_tipsColor = Color.FromArgb(232, 30, 99);
|
||||
/// <summary>
|
||||
/// 角标颜色
|
||||
/// </summary>
|
||||
/// <value>The color of the tips.</value>
|
||||
[Description("角标颜色"), Category("自定义")]
|
||||
public Color TipsColor
|
||||
{
|
||||
get { return m_tipsColor; }
|
||||
set { m_tipsColor = value; }
|
||||
}
|
||||
[Description("鼠标效果生效时发生,需要和MouseEffected同时使用,否则无效"), Category("自定义")]
|
||||
public event EventHandler MouseEffecting;
|
||||
[Description("鼠标效果结束时发生,需要和MouseEffecting同时使用,否则无效"), Category("自定义")]
|
||||
public event EventHandler MouseEffected;
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCBtnExt" /> class.
|
||||
/// </summary>
|
||||
public UCBtnExt()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.TabStop = false;
|
||||
lblTips.Paint += lblTips_Paint;
|
||||
this.lbl.MouseEnter += lbl_MouseEnter;
|
||||
this.lbl.MouseLeave += lbl_MouseLeave;
|
||||
}
|
||||
Color m_cacheColor = Color.Empty;
|
||||
void lbl_MouseLeave(object sender, EventArgs e)
|
||||
{
|
||||
if (enabledMouseEffect)
|
||||
{
|
||||
if (MouseEffecting != null && MouseEffected != null)
|
||||
{
|
||||
MouseEffected(this, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_cacheColor != Color.Empty)
|
||||
{
|
||||
this.FillColor = m_cacheColor;
|
||||
m_cacheColor = Color.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void lbl_MouseEnter(object sender, EventArgs e)
|
||||
{
|
||||
if (enabledMouseEffect)
|
||||
{
|
||||
if (MouseEffecting != null && MouseEffected != null)
|
||||
{
|
||||
MouseEffecting(this, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (FillColor != Color.Empty && FillColor != null)
|
||||
{
|
||||
m_cacheColor = this.FillColor;
|
||||
this.FillColor = Color.FromArgb(230, this.FillColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Paint event of the lblTips control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="PaintEventArgs" /> instance containing the event data.</param>
|
||||
void lblTips_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
e.Graphics.SetGDIHigh();
|
||||
e.Graphics.FillEllipse(new SolidBrush(m_tipsColor), new Rectangle(0, 0, lblTips.Width - 1, lblTips.Height - 1));
|
||||
System.Drawing.SizeF sizeEnd = e.Graphics.MeasureString(TipsText, lblTips.Font);
|
||||
|
||||
e.Graphics.DrawString(TipsText, lblTips.Font, new SolidBrush(lblTips.ForeColor), new PointF((lblTips.Width - sizeEnd.Width) / 2, (lblTips.Height - sizeEnd.Height) / 2 + 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the lbl control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void lbl_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (this.BtnClick != null)
|
||||
BtnClick(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/Btn/UCBtnExt.resx
Normal file
120
UsingControl/HZHControls/Controls/Btn/UCBtnExt.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
90
UsingControl/HZHControls/Controls/Btn/UCBtnFillet.Designer.cs
generated
Normal file
90
UsingControl/HZHControls/Controls/Btn/UCBtnFillet.Designer.cs
generated
Normal file
@@ -0,0 +1,90 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCBtnFillet.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCBtnFillet.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCControlBase" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCControlBase" />
|
||||
partial class UCBtnFillet
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.lbl = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lbl
|
||||
//
|
||||
this.lbl.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.lbl.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.lbl.Image = global::HZH_Controls.Properties.Resources.alarm;
|
||||
this.lbl.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.lbl.Location = new System.Drawing.Point(0, 0);
|
||||
this.lbl.Name = "lbl";
|
||||
this.lbl.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0);
|
||||
this.lbl.Size = new System.Drawing.Size(120, 76);
|
||||
this.lbl.TabIndex = 0;
|
||||
this.lbl.Text = "按钮1 ";
|
||||
this.lbl.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.lbl.MouseDown += new System.Windows.Forms.MouseEventHandler(this.lbl_MouseDown);
|
||||
//
|
||||
// UCBtnFillet
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.ConerRadius = 5;
|
||||
this.Controls.Add(this.lbl);
|
||||
this.IsShowRect = true;
|
||||
this.IsRadius = true;
|
||||
this.Name = "UCBtnFillet";
|
||||
this.Size = new System.Drawing.Size(120, 76);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The label
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Label lbl;
|
||||
}
|
||||
}
|
||||
88
UsingControl/HZHControls/Controls/Btn/UCBtnFillet.cs
Normal file
88
UsingControl/HZHControls/Controls/Btn/UCBtnFillet.cs
Normal file
@@ -0,0 +1,88 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCBtnFillet.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCBtnFillet.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCControlBase" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCControlBase" />
|
||||
[DefaultEvent("BtnClick")]
|
||||
public partial class UCBtnFillet : UCControlBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 按钮点击事件
|
||||
/// </summary>
|
||||
[Description("按钮点击事件"), Category("自定义")]
|
||||
public event EventHandler BtnClick;
|
||||
/// <summary>
|
||||
/// 按钮图片
|
||||
/// </summary>
|
||||
/// <value>The BTN image.</value>
|
||||
[Description("按钮图片"), Category("自定义")]
|
||||
public Image BtnImage
|
||||
{
|
||||
get
|
||||
{
|
||||
return lbl.Image;
|
||||
}
|
||||
set
|
||||
{
|
||||
lbl.Image = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 按钮文字
|
||||
/// </summary>
|
||||
/// <value>The BTN text.</value>
|
||||
[Description("按钮文字"), Category("自定义")]
|
||||
public string BtnText
|
||||
{
|
||||
get { return lbl.Text; }
|
||||
set
|
||||
{
|
||||
lbl.Text = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCBtnFillet" /> class.
|
||||
/// </summary>
|
||||
public UCBtnFillet()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the lbl control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void lbl_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (BtnClick != null)
|
||||
BtnClick(this, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/Btn/UCBtnFillet.resx
Normal file
120
UsingControl/HZHControls/Controls/Btn/UCBtnFillet.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
69
UsingControl/HZHControls/Controls/Btn/UCBtnImg.Designer.cs
generated
Normal file
69
UsingControl/HZHControls/Controls/Btn/UCBtnImg.Designer.cs
generated
Normal file
@@ -0,0 +1,69 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCBtnImg.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCBtnImg.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCBtnExt" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCBtnExt" />
|
||||
partial class UCBtnImg
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lbl
|
||||
//
|
||||
this.lbl.Image = global::HZH_Controls.Properties.Resources.back;
|
||||
//
|
||||
// UCBtnImg
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.IsShowTips = true;
|
||||
this.Name = "UCBtnImg";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
129
UsingControl/HZHControls/Controls/Btn/UCBtnImg.cs
Normal file
129
UsingControl/HZHControls/Controls/Btn/UCBtnImg.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCBtnImg.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCBtnImg.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCBtnExt" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCBtnExt" />
|
||||
public partial class UCBtnImg : UCBtnExt
|
||||
{
|
||||
/// <summary>
|
||||
/// The BTN text
|
||||
/// </summary>
|
||||
private string _btnText = "自定义按钮";
|
||||
/// <summary>
|
||||
/// 按钮文字
|
||||
/// </summary>
|
||||
/// <value>The BTN text.</value>
|
||||
[Description("按钮文字"), Category("自定义")]
|
||||
public override string BtnText
|
||||
{
|
||||
get { return _btnText; }
|
||||
set
|
||||
{
|
||||
_btnText = value;
|
||||
lbl.Text = value;
|
||||
lbl.Refresh();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 图片
|
||||
/// </summary>
|
||||
/// <value>The image.</value>
|
||||
[Description("图片"), Category("自定义")]
|
||||
public virtual Image Image
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.lbl.Image;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.lbl.Image = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The image font icons
|
||||
/// </summary>
|
||||
private object imageFontIcons;
|
||||
/// <summary>
|
||||
/// Gets or sets the image font icons.
|
||||
/// </summary>
|
||||
/// <value>The image font icons.</value>
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
[Editor(typeof(ImagePropertyEditor), typeof(System.Drawing.Design.UITypeEditor))]
|
||||
public object ImageFontIcons
|
||||
{
|
||||
get { return imageFontIcons; }
|
||||
set
|
||||
{
|
||||
if (value == null || value is Image)
|
||||
{
|
||||
imageFontIcons = value;
|
||||
if (value != null)
|
||||
{
|
||||
Image = (Image)value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 图片位置
|
||||
/// </summary>
|
||||
/// <value>The image align.</value>
|
||||
[Description("图片位置"), Category("自定义")]
|
||||
public virtual ContentAlignment ImageAlign
|
||||
{
|
||||
get { return this.lbl.ImageAlign; }
|
||||
set { lbl.ImageAlign = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 文字位置
|
||||
/// </summary>
|
||||
/// <value>The text align.</value>
|
||||
[Description("文字位置"), Category("自定义")]
|
||||
public virtual ContentAlignment TextAlign
|
||||
{
|
||||
get { return this.lbl.TextAlign; }
|
||||
set { lbl.TextAlign = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCBtnImg" /> class.
|
||||
/// </summary>
|
||||
public UCBtnImg()
|
||||
{
|
||||
InitializeComponent();
|
||||
IsShowTips = false;
|
||||
base.BtnForeColor = ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(102)))), ((int)(((byte)(102)))), ((int)(((byte)(102)))));
|
||||
base.BtnFont = new System.Drawing.Font("微软雅黑", 17F);
|
||||
base.BtnText = "自定义按钮";
|
||||
}
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/Btn/UCBtnImg.resx
Normal file
120
UsingControl/HZHControls/Controls/Btn/UCBtnImg.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
79
UsingControl/HZHControls/Controls/Btn/UCDropDownBtn.Designer.cs
generated
Normal file
79
UsingControl/HZHControls/Controls/Btn/UCDropDownBtn.Designer.cs
generated
Normal file
@@ -0,0 +1,79 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-27-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCDropDownBtn.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCDropDownBtn.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCBtnImg" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCBtnImg" />
|
||||
partial class UCDropDownBtn
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(UCDropDownBtn));
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// lbl
|
||||
//
|
||||
this.lbl.Font = new System.Drawing.Font("微软雅黑", 14F);
|
||||
this.lbl.ForeColor = System.Drawing.Color.White;
|
||||
this.lbl.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.lbl.ImageList = null;
|
||||
this.lbl.Text = "自定义按钮";
|
||||
this.lbl.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// UCDropDownBtn
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BtnFont = new System.Drawing.Font("微软雅黑", 14F);
|
||||
this.BtnForeColor = System.Drawing.Color.White;
|
||||
this.ForeColor = System.Drawing.Color.White;
|
||||
this.Image = ((System.Drawing.Image)(resources.GetObject("$this.Image")));
|
||||
this.ImageAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.Margin = new System.Windows.Forms.Padding(2);
|
||||
this.Name = "UCDropDownBtn";
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
211
UsingControl/HZHControls/Controls/Btn/UCDropDownBtn.cs
Normal file
211
UsingControl/HZHControls/Controls/Btn/UCDropDownBtn.cs
Normal file
@@ -0,0 +1,211 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-27-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCDropDownBtn.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCDropDownBtn.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCBtnImg" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCBtnImg" />
|
||||
[DefaultEvent("BtnClick")]
|
||||
public partial class UCDropDownBtn : UCBtnImg
|
||||
{
|
||||
/// <summary>
|
||||
/// The FRM anchor
|
||||
/// </summary>
|
||||
Forms.FrmAnchor _frmAnchor;
|
||||
/// <summary>
|
||||
/// The drop panel height
|
||||
/// </summary>
|
||||
private int _dropPanelHeight = -1;
|
||||
/// <summary>
|
||||
/// 按钮点击事件
|
||||
/// </summary>
|
||||
public new event EventHandler BtnClick;
|
||||
/// <summary>
|
||||
/// 下拉框高度
|
||||
/// </summary>
|
||||
/// <value>The height of the drop panel.</value>
|
||||
[Description("下拉框高度"), Category("自定义")]
|
||||
public int DropPanelHeight
|
||||
{
|
||||
get { return _dropPanelHeight; }
|
||||
set { _dropPanelHeight = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The BTNS
|
||||
/// </summary>
|
||||
private string[] btns;
|
||||
/// <summary>
|
||||
/// 需要显示的按钮文字
|
||||
/// </summary>
|
||||
/// <value>The BTNS.</value>
|
||||
[Description("需要显示的按钮文字"), Category("自定义")]
|
||||
public string[] Btns
|
||||
{
|
||||
get { return btns; }
|
||||
set { btns = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 图片
|
||||
/// </summary>
|
||||
/// <value>The image.</value>
|
||||
[Obsolete("不再可用的属性")]
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override Image Image
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 图片位置
|
||||
/// </summary>
|
||||
/// <value>The image align.</value>
|
||||
[Obsolete("不再可用的属性")]
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
public override ContentAlignment ImageAlign
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// 按钮字体颜色
|
||||
/// </summary>
|
||||
/// <value>The color of the BTN fore.</value>
|
||||
[Description("按钮字体颜色"), Category("自定义")]
|
||||
public override Color BtnForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.BtnForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.BtnForeColor = value;
|
||||
Bitmap bit = new Bitmap(12, 10);
|
||||
Graphics g = Graphics.FromImage(bit);
|
||||
g.SetGDIHigh();
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLines(new Point[]
|
||||
{
|
||||
new Point(1,1),
|
||||
new Point(11,1),
|
||||
new Point(6,10),
|
||||
new Point(1,1)
|
||||
});
|
||||
g.FillPath(new SolidBrush(value), path);
|
||||
g.Dispose();
|
||||
this.lbl.Image = bit;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCDropDownBtn" /> class.
|
||||
/// </summary>
|
||||
public UCDropDownBtn()
|
||||
{
|
||||
InitializeComponent();
|
||||
IsShowTips = false;
|
||||
this.lbl.ImageAlign = ContentAlignment.MiddleRight;
|
||||
base.BtnClick += UCDropDownBtn_BtnClick;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the BtnClick event of the UCDropDownBtn 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 UCDropDownBtn_BtnClick(object sender, EventArgs e)
|
||||
{
|
||||
if (_frmAnchor == null || _frmAnchor.IsDisposed || _frmAnchor.Visible == false)
|
||||
{
|
||||
|
||||
if (Btns != null && Btns.Length > 0)
|
||||
{
|
||||
int intRow = 0;
|
||||
int intCom = 1;
|
||||
var p = this.PointToScreen(this.Location);
|
||||
while (true)
|
||||
{
|
||||
int intScreenHeight = Screen.PrimaryScreen.Bounds.Height;
|
||||
if ((p.Y + this.Height + Btns.Length / intCom * 50 < intScreenHeight || p.Y - Btns.Length / intCom * 50 > 0)
|
||||
&& (_dropPanelHeight <= 0 ? true : (Btns.Length / intCom * 50 <= _dropPanelHeight)))
|
||||
{
|
||||
intRow = Btns.Length / intCom + (Btns.Length % intCom != 0 ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
intCom++;
|
||||
}
|
||||
UCTimePanel ucTime = new UCTimePanel();
|
||||
ucTime.IsShowBorder = true;
|
||||
int intWidth = this.Width / intCom;
|
||||
|
||||
Size size = new Size(intCom * intWidth, intRow * 50);
|
||||
ucTime.Size = size;
|
||||
ucTime.FirstEvent = true;
|
||||
ucTime.SelectSourceEvent += ucTime_SelectSourceEvent;
|
||||
ucTime.Row = intRow;
|
||||
ucTime.Column = intCom;
|
||||
|
||||
List<KeyValuePair<string, string>> lst = new List<KeyValuePair<string, string>>();
|
||||
foreach (var item in Btns)
|
||||
{
|
||||
lst.Add(new KeyValuePair<string, string>(item, item));
|
||||
}
|
||||
ucTime.Source = lst;
|
||||
|
||||
_frmAnchor = new Forms.FrmAnchor(this, ucTime);
|
||||
_frmAnchor.Load += (a, b) => { (a as Form).Size = size; };
|
||||
|
||||
_frmAnchor.Show(this.FindForm());
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_frmAnchor.Close();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Handles the SelectSourceEvent event of the ucTime 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 ucTime_SelectSourceEvent(object sender, EventArgs e)
|
||||
{
|
||||
if (_frmAnchor != null && !_frmAnchor.IsDisposed && _frmAnchor.Visible)
|
||||
{
|
||||
_frmAnchor.Close();
|
||||
|
||||
if (BtnClick != null)
|
||||
{
|
||||
BtnClick(sender.ToString(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
131
UsingControl/HZHControls/Controls/Btn/UCDropDownBtn.resx
Normal file
131
UsingControl/HZHControls/Controls/Btn/UCDropDownBtn.resx
Normal file
@@ -0,0 +1,131 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
<data name="$this.Image" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>
|
||||
iVBORw0KGgoAAAANSUhEUgAAAA4AAAAYCAYAAADKx8xXAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8
|
||||
YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAD0SURBVDhPjZLtDcIwDES9Ezt1py7AMCgrdIGKH3SC0OfE
|
||||
JZ/FJxmR+E55livP1ycua4iPJboKLxnZti0HPeFwemPc9z3KcRx68AbX04uEHw4eXB4A8wqmOcfmsvCE
|
||||
oLkoCOb/uAlT5zMxp+IOA6noQYY3x6TAnb/YYSIOXN7NaZhdkEuaoxBlmFUQcaG4g5DN14UQlzNcne+t
|
||||
uT6Ifmupq1tDK2YAqd5n+qirNbQCBdzyNea7xUQ0MZW4/O/W0Ipmu5bpGlrVc4b+a5kJk+G6ME2YbC2U
|
||||
CxNhMlzKlNtzZZ/i2hpQbt8LI6+6MU3qLpSvC4l8ASkgxV0fp9H6AAAAAElFTkSuQmCC
|
||||
</value>
|
||||
</data>
|
||||
</root>
|
||||
81
UsingControl/HZHControls/Controls/BtnsGroup/UCBtnsGroup.Designer.cs
generated
Normal file
81
UsingControl/HZHControls/Controls/BtnsGroup/UCBtnsGroup.Designer.cs
generated
Normal file
@@ -0,0 +1,81 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-15-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCBtnsGroup.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCBtnsGroup.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
partial class UCBtnsGroup
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// flowLayoutPanel1
|
||||
//
|
||||
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(420, 50);
|
||||
this.flowLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// UCBtnsGroup
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.Controls.Add(this.flowLayoutPanel1);
|
||||
this.MinimumSize = new System.Drawing.Size(0, 50);
|
||||
this.Name = "UCBtnsGroup";
|
||||
this.Size = new System.Drawing.Size(420, 50);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The flow layout panel1
|
||||
/// </summary>
|
||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
||||
}
|
||||
}
|
||||
229
UsingControl/HZHControls/Controls/BtnsGroup/UCBtnsGroup.cs
Normal file
229
UsingControl/HZHControls/Controls/BtnsGroup/UCBtnsGroup.cs
Normal file
@@ -0,0 +1,229 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-15-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCBtnsGroup.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCBtnsGroup.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public partial class UCBtnsGroup : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// 选中改变事件
|
||||
/// </summary>
|
||||
[Description("选中改变事件"), Category("自定义")]
|
||||
public event EventHandler SelectedItemChanged;
|
||||
/// <summary>
|
||||
/// The m data source
|
||||
/// </summary>
|
||||
private Dictionary<string, string> m_dataSource = new Dictionary<string, string>();
|
||||
/// <summary>
|
||||
/// 数据源
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
[Description("数据源"), Category("自定义")]
|
||||
public Dictionary<string, string> DataSource
|
||||
{
|
||||
get { return m_dataSource; }
|
||||
set
|
||||
{
|
||||
m_dataSource = value;
|
||||
Reload();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m select item
|
||||
/// </summary>
|
||||
private List<string> m_selectItem = new List<string>();
|
||||
/// <summary>
|
||||
/// 选中项
|
||||
/// </summary>
|
||||
/// <value>The select item.</value>
|
||||
[Description("选中项"), Category("自定义")]
|
||||
public List<string> SelectItem
|
||||
{
|
||||
get { return m_selectItem; }
|
||||
set
|
||||
{
|
||||
m_selectItem = value;
|
||||
if (m_selectItem == null)
|
||||
m_selectItem = new List<string>();
|
||||
SetSelected();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m is multiple
|
||||
/// </summary>
|
||||
private bool m_isMultiple = false;
|
||||
/// <summary>
|
||||
/// 是否多选
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is multiple; otherwise, <c>false</c>.</value>
|
||||
[Description("是否多选"), Category("自定义")]
|
||||
public bool IsMultiple
|
||||
{
|
||||
get { return m_isMultiple; }
|
||||
set { m_isMultiple = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCBtnsGroup" /> class.
|
||||
/// </summary>
|
||||
public UCBtnsGroup()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reloads this instance.
|
||||
/// </summary>
|
||||
private void Reload()
|
||||
{
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(flowLayoutPanel1, true);
|
||||
this.flowLayoutPanel1.Controls.Clear();
|
||||
if (DataSource != null)
|
||||
{
|
||||
foreach (var item in DataSource)
|
||||
{
|
||||
UCBtnExt btn = new UCBtnExt();
|
||||
btn.BackColor = System.Drawing.Color.Transparent;
|
||||
btn.BtnBackColor = System.Drawing.Color.White;
|
||||
btn.BtnFont = new System.Drawing.Font("微软雅黑", 10F);
|
||||
btn.BtnForeColor = System.Drawing.Color.Gray;
|
||||
btn.BtnText = item.Value;
|
||||
btn.ConerRadius = 5;
|
||||
btn.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
btn.FillColor = System.Drawing.Color.White;
|
||||
btn.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
btn.IsRadius = true;
|
||||
btn.IsShowRect = true;
|
||||
btn.IsShowTips = false;
|
||||
btn.Location = new System.Drawing.Point(5, 5);
|
||||
btn.Margin = new System.Windows.Forms.Padding(5);
|
||||
btn.Name = item.Key;
|
||||
btn.RectColor = System.Drawing.Color.FromArgb(224, 224, 224);
|
||||
btn.RectWidth = 1;
|
||||
btn.Size = new System.Drawing.Size(72, 38);
|
||||
btn.TabStop = false;
|
||||
btn.BtnClick += btn_BtnClick;
|
||||
this.flowLayoutPanel1.Controls.Add(btn);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(flowLayoutPanel1, false);
|
||||
}
|
||||
SetSelected();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the BtnClick event of the btn 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 btn_BtnClick(object sender, EventArgs e)
|
||||
{
|
||||
var btn = sender as UCBtnExt;
|
||||
if (m_selectItem.Contains(btn.Name))
|
||||
{
|
||||
btn.RectColor = System.Drawing.Color.FromArgb(224, 224, 224);
|
||||
m_selectItem.Remove(btn.Name);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_isMultiple)
|
||||
{
|
||||
foreach (var item in m_selectItem)
|
||||
{
|
||||
var lst = this.flowLayoutPanel1.Controls.Find(item, false);
|
||||
if (lst.Length == 1)
|
||||
{
|
||||
var _btn = lst[0] as UCBtnExt;
|
||||
_btn.RectColor = System.Drawing.Color.FromArgb(224, 224, 224);
|
||||
}
|
||||
}
|
||||
m_selectItem.Clear();
|
||||
}
|
||||
btn.RectColor = System.Drawing.Color.FromArgb(255, 77, 59);
|
||||
m_selectItem.Add(btn.Name);
|
||||
}
|
||||
if (SelectedItemChanged != null)
|
||||
SelectedItemChanged(this, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the selected.
|
||||
/// </summary>
|
||||
private void SetSelected()
|
||||
{
|
||||
if (m_selectItem != null && m_selectItem.Count > 0 && DataSource != null && DataSource.Count > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(flowLayoutPanel1, true);
|
||||
if (m_isMultiple)
|
||||
{
|
||||
foreach (var item in m_selectItem)
|
||||
{
|
||||
var lst = this.flowLayoutPanel1.Controls.Find(item, false);
|
||||
if (lst.Length == 1)
|
||||
{
|
||||
var btn = lst[0] as UCBtnExt;
|
||||
btn.RectColor = System.Drawing.Color.FromArgb(255, 77, 59);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
UCBtnExt btn = null;
|
||||
foreach (var item in m_selectItem)
|
||||
{
|
||||
var lst = this.flowLayoutPanel1.Controls.Find(item, false);
|
||||
if (lst.Length == 1)
|
||||
{
|
||||
btn = lst[0] as UCBtnExt;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (btn != null)
|
||||
{
|
||||
m_selectItem = new List<string>() { btn.Name };
|
||||
btn.RectColor = System.Drawing.Color.FromArgb(255, 77, 59);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(flowLayoutPanel1, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/BtnsGroup/UCBtnsGroup.resx
Normal file
120
UsingControl/HZHControls/Controls/BtnsGroup/UCBtnsGroup.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
38
UsingControl/HZHControls/Controls/Charts/AuxiliaryLable.cs
Normal file
38
UsingControl/HZHControls/Controls/Charts/AuxiliaryLable.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
public class AuxiliaryLable
|
||||
{
|
||||
public string Text
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Brush TextBrush
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Brush TextBack
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public float LocationX
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public AuxiliaryLable()
|
||||
{
|
||||
TextBrush = Brushes.Black;
|
||||
TextBack = Brushes.Transparent;
|
||||
LocationX = 0.5f;
|
||||
}
|
||||
}
|
||||
}
|
||||
122
UsingControl/HZHControls/Controls/Charts/AuxiliaryLine.cs
Normal file
122
UsingControl/HZHControls/Controls/Charts/AuxiliaryLine.cs
Normal file
@@ -0,0 +1,122 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-17
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="AuxiliaryLine.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.Drawing;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class AuxiliaryLine.
|
||||
/// Implements the <see cref="System.IDisposable" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.IDisposable" />
|
||||
internal class AuxiliaryLine : IDisposable
|
||||
{
|
||||
private bool disposedValue = false;
|
||||
|
||||
public float Value
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public float PaintValue
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public float PaintValueBackUp
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Color LineColor
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Pen PenDash
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Pen PenSolid
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public float LineThickness
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public Brush LineTextBrush
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
public bool IsLeftFrame
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
private bool isDashStyle = true;
|
||||
|
||||
public bool IsDashStyle
|
||||
{
|
||||
get { return isDashStyle; }
|
||||
set { isDashStyle = value; }
|
||||
}
|
||||
|
||||
|
||||
public Pen GetPen()
|
||||
{
|
||||
return IsDashStyle ? PenDash : PenSolid;
|
||||
}
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if(PenDash==null)
|
||||
PenDash.Dispose();
|
||||
if(PenSolid==null)
|
||||
PenSolid.Dispose();
|
||||
if(LineTextBrush==null)
|
||||
LineTextBrush.Dispose();
|
||||
}
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
public string Tip { get; set; }
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Dispose(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-26
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="FunelChartAlignment.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;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum FunelChartAlignment
|
||||
/// </summary>
|
||||
public enum FunelChartAlignment
|
||||
{
|
||||
/// <summary>
|
||||
/// The left
|
||||
/// </summary>
|
||||
Left,
|
||||
/// <summary>
|
||||
/// The center
|
||||
/// </summary>
|
||||
Center,
|
||||
/// <summary>
|
||||
/// The right
|
||||
/// </summary>
|
||||
Right
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-26
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="FunelChartDirection.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;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum FunelChartDirection
|
||||
/// </summary>
|
||||
public enum FunelChartDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// Up
|
||||
/// </summary>
|
||||
UP,
|
||||
/// <summary>
|
||||
/// Down
|
||||
/// </summary>
|
||||
Down
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-26
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="FunelChartItem.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;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class FunelChartItem.
|
||||
/// </summary>
|
||||
public class FunelChartItem
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the text.
|
||||
/// </summary>
|
||||
/// <value>The text.</value>
|
||||
public string Text { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the value.
|
||||
/// </summary>
|
||||
/// <value>The value.</value>
|
||||
public float Value { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the value.
|
||||
/// </summary>
|
||||
/// <value>The color of the value.</value>
|
||||
public System.Drawing.Color? ValueColor { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the text fore.
|
||||
/// </summary>
|
||||
/// <value>The color of the text fore.</value>
|
||||
public System.Drawing.Color? TextForeColor { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,506 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-26
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCFunnelChart.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 UCFunnelChart.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public class UCFunnelChart : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The title
|
||||
/// </summary>
|
||||
private string title;
|
||||
/// <summary>
|
||||
/// Gets or sets the title.
|
||||
/// </summary>
|
||||
/// <value>The title.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置标题")]
|
||||
public string Title
|
||||
{
|
||||
get { return title; }
|
||||
set
|
||||
{
|
||||
title = value;
|
||||
ResetTitleSize();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The title font
|
||||
/// </summary>
|
||||
private Font titleFont = new Font("微软雅黑", 12);
|
||||
/// <summary>
|
||||
/// Gets or sets the title font.
|
||||
/// </summary>
|
||||
/// <value>The title font.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置标题字体")]
|
||||
public Font TitleFont
|
||||
{
|
||||
get { return titleFont; }
|
||||
set
|
||||
{
|
||||
titleFont = value;
|
||||
ResetTitleSize();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The title fore color
|
||||
/// </summary>
|
||||
private Color titleForeColor = Color.Black;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the title fore.
|
||||
/// </summary>
|
||||
/// <value>The color of the title fore.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置标题文字颜色")]
|
||||
public Color TitleForeColor
|
||||
{
|
||||
get { return titleForeColor; }
|
||||
set
|
||||
{
|
||||
titleForeColor = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The items
|
||||
/// </summary>
|
||||
private FunelChartItem[] items;
|
||||
/// <summary>
|
||||
/// Gets or sets the items.
|
||||
/// </summary>
|
||||
/// <value>The items.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置项目")]
|
||||
public FunelChartItem[] Items
|
||||
{
|
||||
get { return items; }
|
||||
set
|
||||
{
|
||||
items = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The direction
|
||||
/// </summary>
|
||||
private FunelChartDirection direction = FunelChartDirection.UP;
|
||||
/// <summary>
|
||||
/// Gets or sets the direction.
|
||||
/// </summary>
|
||||
/// <value>The direction.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置方向")]
|
||||
public FunelChartDirection Direction
|
||||
{
|
||||
get { return direction; }
|
||||
set
|
||||
{
|
||||
direction = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The alignment
|
||||
/// </summary>
|
||||
private FunelChartAlignment alignment = FunelChartAlignment.Center;
|
||||
/// <summary>
|
||||
/// Gets or sets the alignment.
|
||||
/// </summary>
|
||||
/// <value>The alignment.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置对齐方式")]
|
||||
public FunelChartAlignment Alignment
|
||||
{
|
||||
get { return alignment; }
|
||||
set
|
||||
{
|
||||
alignment = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The item text align
|
||||
/// </summary>
|
||||
private FunelChartAlignment itemTextAlign = FunelChartAlignment.Center;
|
||||
/// <summary>
|
||||
/// Gets or sets the item text align.
|
||||
/// </summary>
|
||||
/// <value>The item text align.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置文字位置")]
|
||||
public FunelChartAlignment ItemTextAlign
|
||||
{
|
||||
get { return itemTextAlign; }
|
||||
set
|
||||
{
|
||||
itemTextAlign = value;
|
||||
ResetWorkingRect();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The show value
|
||||
/// </summary>
|
||||
private bool showValue = false;
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether [show value].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [show value]; otherwise, <c>false</c>.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置是否显示值")]
|
||||
public bool ShowValue
|
||||
{
|
||||
get { return showValue; }
|
||||
set
|
||||
{
|
||||
showValue = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The value format
|
||||
/// </summary>
|
||||
private string valueFormat = "0.##";
|
||||
/// <summary>
|
||||
/// Gets or sets the value format.
|
||||
/// </summary>
|
||||
/// <value>The value format.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置值格式化")]
|
||||
public string ValueFormat
|
||||
{
|
||||
get { return valueFormat; }
|
||||
set
|
||||
{
|
||||
valueFormat = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m rect working
|
||||
/// </summary>
|
||||
RectangleF m_rectWorking;
|
||||
/// <summary>
|
||||
/// The m title size
|
||||
/// </summary>
|
||||
SizeF m_titleSize = SizeF.Empty;
|
||||
/// <summary>
|
||||
/// The int split width
|
||||
/// </summary>
|
||||
int intSplitWidth = 1;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCFunnelChart"/> class.
|
||||
/// </summary>
|
||||
public UCFunnelChart()
|
||||
{
|
||||
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.FontChanged += UCFunnelChart_FontChanged;
|
||||
Font = new Font("微软雅黑", 8);
|
||||
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.SizeChanged += UCFunnelChart_SizeChanged;
|
||||
Size = new System.Drawing.Size(150, 150);
|
||||
items = new FunelChartItem[0];
|
||||
if (ControlHelper.IsDesignMode())
|
||||
{
|
||||
items = new FunelChartItem[5];
|
||||
for (int i = 0; i < 5; i++)
|
||||
{
|
||||
items[i] = new FunelChartItem()
|
||||
{
|
||||
Text = "item" + i,
|
||||
Value = 10 * (i + 1)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the FontChanged event of the UCFunnelChart 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 UCFunnelChart_FontChanged(object sender, EventArgs e)
|
||||
{
|
||||
ResetWorkingRect();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the UCFunnelChart 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 UCFunnelChart_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
ResetWorkingRect();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the working rect.
|
||||
/// </summary>
|
||||
private void ResetWorkingRect()
|
||||
{
|
||||
if (itemTextAlign == FunelChartAlignment.Center)
|
||||
{
|
||||
m_rectWorking = new RectangleF(0, m_titleSize.Height == 0 ? 0 : (m_titleSize.Height + 10), this.Width, this.Height - (m_titleSize.Height == 0 ? 0 : (m_titleSize.Height + 10)));
|
||||
}
|
||||
else if (itemTextAlign == FunelChartAlignment.Left)
|
||||
{
|
||||
float fltMax = 0;
|
||||
if (items != null && items.Length > 0)
|
||||
{
|
||||
using (Graphics g = this.CreateGraphics())
|
||||
{
|
||||
fltMax = items.Max(p => g.MeasureString(p.Text, Font).Width);
|
||||
}
|
||||
}
|
||||
m_rectWorking = new RectangleF(fltMax, m_titleSize.Height == 0 ? 0 : (m_titleSize.Height + 10), this.Width - fltMax, this.Height - (m_titleSize.Height == 0 ? 0 : (m_titleSize.Height + 10)));
|
||||
}
|
||||
else
|
||||
{
|
||||
float fltMax = 0;
|
||||
if (items != null && items.Length > 0)
|
||||
{
|
||||
using (Graphics g = this.CreateGraphics())
|
||||
{
|
||||
fltMax = items.Max(p => g.MeasureString(p.Text, Font).Width);
|
||||
}
|
||||
}
|
||||
m_rectWorking = new RectangleF(0, m_titleSize.Height == 0 ? 0 : (m_titleSize.Height + 10), this.Width - fltMax, this.Height - (m_titleSize.Height == 0 ? 0 : (m_titleSize.Height + 10)));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the size of the title.
|
||||
/// </summary>
|
||||
private void ResetTitleSize()
|
||||
{
|
||||
if (string.IsNullOrEmpty(title))
|
||||
{
|
||||
m_titleSize = SizeF.Empty;
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Graphics g = this.CreateGraphics())
|
||||
{
|
||||
m_titleSize = g.MeasureString(title, titleFont);
|
||||
m_titleSize.Height += 20;
|
||||
}
|
||||
}
|
||||
ResetWorkingRect();
|
||||
}
|
||||
|
||||
/// <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);
|
||||
var g = e.Graphics;
|
||||
g.SetGDIHigh();
|
||||
|
||||
if (!string.IsNullOrEmpty(title))
|
||||
{
|
||||
g.DrawString(title, titleFont, new SolidBrush(titleForeColor), new RectangleF(0, 0, this.Width, m_titleSize.Height), new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
|
||||
}
|
||||
|
||||
if (items == null || items.Length <= 0)
|
||||
{
|
||||
g.DrawString("没有数据", Font, new SolidBrush(Color.Black), this.m_rectWorking, new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
|
||||
return;
|
||||
}
|
||||
|
||||
List<FunelChartItem> lstItems;
|
||||
if (direction == FunelChartDirection.UP)
|
||||
{
|
||||
lstItems = items.OrderBy(p => p.Value).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
lstItems = items.OrderByDescending(p => p.Value).ToList();
|
||||
}
|
||||
|
||||
List<RectangleF> lstRects = new List<RectangleF>();
|
||||
List<GraphicsPath> lstPaths = new List<GraphicsPath>();
|
||||
float maxValue = lstItems.Max(p => p.Value);
|
||||
float dblSplitHeight = m_rectWorking.Height / lstItems.Count;
|
||||
for (int i = 0; i < lstItems.Count; i++)
|
||||
{
|
||||
FunelChartItem item = lstItems[i];
|
||||
if (item.ValueColor == null || item.ValueColor == Color.Empty || item.ValueColor == Color.Transparent)
|
||||
item.ValueColor = ControlHelper.Colors[i];
|
||||
|
||||
switch (alignment)
|
||||
{
|
||||
case FunelChartAlignment.Left:
|
||||
lstRects.Add(new RectangleF(m_rectWorking.Left, m_rectWorking.Top + dblSplitHeight * i, item.Value / maxValue * m_rectWorking.Width, dblSplitHeight));
|
||||
break;
|
||||
case FunelChartAlignment.Center:
|
||||
lstRects.Add(new RectangleF(m_rectWorking.Left + (m_rectWorking.Width - (item.Value / maxValue * m_rectWorking.Width)) / 2, m_rectWorking.Top + dblSplitHeight * i, item.Value / maxValue * m_rectWorking.Width, dblSplitHeight));
|
||||
break;
|
||||
case FunelChartAlignment.Right:
|
||||
lstRects.Add(new RectangleF(m_rectWorking.Right - (item.Value / maxValue * m_rectWorking.Width), m_rectWorking.Top + dblSplitHeight * i, item.Value / maxValue * m_rectWorking.Width, dblSplitHeight));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < lstRects.Count; i++)
|
||||
{
|
||||
var rect = lstRects[i];
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
List<PointF> lstPoints = new List<PointF>();
|
||||
if (direction == FunelChartDirection.UP)
|
||||
{
|
||||
switch (alignment)
|
||||
{
|
||||
case FunelChartAlignment.Left:
|
||||
lstPoints.Add(new PointF(rect.Left, rect.Top));
|
||||
if (i != 0)
|
||||
{
|
||||
lstPoints.Add(new PointF(lstRects[i - 1].Right, rect.Top));
|
||||
}
|
||||
break;
|
||||
case FunelChartAlignment.Center:
|
||||
if (i == 0)
|
||||
{
|
||||
lstPoints.Add(new PointF(rect.Left + rect.Width / 2, rect.Top));
|
||||
}
|
||||
else
|
||||
{
|
||||
lstPoints.Add(new PointF(lstRects[i - 1].Left, rect.Top));
|
||||
lstPoints.Add(new PointF(lstRects[i - 1].Right, rect.Top));
|
||||
}
|
||||
break;
|
||||
case FunelChartAlignment.Right:
|
||||
if (i == 0)
|
||||
{
|
||||
lstPoints.Add(new PointF(rect.Right, rect.Top));
|
||||
}
|
||||
else
|
||||
{
|
||||
lstPoints.Add(new PointF(rect.Right - lstRects[i - 1].Width, rect.Top));
|
||||
lstPoints.Add(new PointF(rect.Right, rect.Top));
|
||||
}
|
||||
break;
|
||||
}
|
||||
lstPoints.Add(new PointF(rect.Right, rect.Bottom - intSplitWidth));
|
||||
lstPoints.Add(new PointF(rect.Left, rect.Bottom - intSplitWidth));
|
||||
}
|
||||
else
|
||||
{
|
||||
lstPoints.Add(new PointF(rect.Left, rect.Top + intSplitWidth));
|
||||
lstPoints.Add(new PointF(rect.Right, rect.Top + intSplitWidth));
|
||||
switch (alignment)
|
||||
{
|
||||
case FunelChartAlignment.Left:
|
||||
if (i == lstRects.Count - 1)
|
||||
{
|
||||
lstPoints.Add(new PointF(rect.Left, rect.Bottom));
|
||||
}
|
||||
else
|
||||
{
|
||||
lstPoints.Add(new PointF(lstRects[i + 1].Right, rect.Bottom));
|
||||
lstPoints.Add(new PointF(rect.Left, rect.Bottom));
|
||||
}
|
||||
break;
|
||||
case FunelChartAlignment.Center:
|
||||
if (i == lstRects.Count - 1)
|
||||
{
|
||||
lstPoints.Add(new PointF(rect.Left + rect.Width / 2, rect.Bottom));
|
||||
}
|
||||
else
|
||||
{
|
||||
lstPoints.Add(new PointF(lstRects[i + 1].Right, rect.Bottom));
|
||||
lstPoints.Add(new PointF(lstRects[i + 1].Left, rect.Bottom));
|
||||
}
|
||||
break;
|
||||
case FunelChartAlignment.Right:
|
||||
if (i == lstRects.Count - 1)
|
||||
{
|
||||
lstPoints.Add(new PointF(rect.Right, rect.Bottom));
|
||||
}
|
||||
else
|
||||
{
|
||||
lstPoints.Add(new PointF(rect.Right, rect.Bottom));
|
||||
lstPoints.Add(new PointF(lstRects[i + 1].Left, rect.Bottom));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
path.AddLines(lstPoints.ToArray());
|
||||
path.CloseAllFigures();
|
||||
// g.DrawPath(new Pen(new SolidBrush(lstItems[i].ValueColor.Value)), path);
|
||||
g.FillPath(new SolidBrush(lstItems[i].ValueColor.Value), path);
|
||||
|
||||
//写字
|
||||
if (itemTextAlign == FunelChartAlignment.Center)
|
||||
{
|
||||
g.DrawString(lstItems[i].Text + (ShowValue ? lstItems[i].Value.ToString("\n" + valueFormat) : ""), Font, new SolidBrush((lstItems[i].TextForeColor == null || lstItems[i].TextForeColor == Color.Empty || lstItems[i].TextForeColor == Color.Transparent) ? Color.White : lstItems[i].TextForeColor.Value), rect, new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
|
||||
}
|
||||
else if (itemTextAlign == FunelChartAlignment.Left)
|
||||
{
|
||||
g.DrawString(lstItems[i].Text + (ShowValue ? lstItems[i].Value.ToString("\n" + valueFormat) : ""), Font, new SolidBrush((lstItems[i].TextForeColor == null || lstItems[i].TextForeColor == Color.Empty || lstItems[i].TextForeColor == Color.Transparent) ? lstItems[i].ValueColor.Value : lstItems[i].TextForeColor.Value), new RectangleF(0, rect.Top, rect.Left, rect.Height), new StringFormat() { Alignment = StringAlignment.Far, LineAlignment = StringAlignment.Center });
|
||||
g.DrawLine(new Pen(new SolidBrush((lstItems[i].TextForeColor == null || lstItems[i].TextForeColor == Color.Empty || lstItems[i].TextForeColor == Color.Transparent) ? lstItems[i].ValueColor.Value : lstItems[i].TextForeColor.Value)), rect.Left, rect.Top + rect.Height / 2, rect.Left + rect.Width / 2, rect.Top + rect.Height / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawString(lstItems[i].Text + (ShowValue ? lstItems[i].Value.ToString("\n" + valueFormat) : ""), Font, new SolidBrush((lstItems[i].TextForeColor == null || lstItems[i].TextForeColor == Color.Empty || lstItems[i].TextForeColor == Color.Transparent) ? lstItems[i].ValueColor.Value : lstItems[i].TextForeColor.Value), new RectangleF(rect.Right, rect.Top, this.Width - rect.Right, rect.Height), new StringFormat() { Alignment = StringAlignment.Near, LineAlignment = StringAlignment.Center });
|
||||
g.DrawLine(new Pen(new SolidBrush((lstItems[i].TextForeColor == null || lstItems[i].TextForeColor == Color.Empty || lstItems[i].TextForeColor == Color.Transparent) ? lstItems[i].ValueColor.Value : lstItems[i].TextForeColor.Value)), rect.Left + rect.Width / 2, rect.Top + rect.Height / 2, rect.Right, rect.Top + rect.Height / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
113
UsingControl/HZHControls/Controls/Charts/MarkText.cs
Normal file
113
UsingControl/HZHControls/Controls/Charts/MarkText.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-23
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="MarkText.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.Drawing;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class MarkText.
|
||||
/// </summary>
|
||||
public class MarkText
|
||||
{
|
||||
/// <summary>
|
||||
/// The mark text offect
|
||||
/// </summary>
|
||||
public static readonly int MarkTextOffect = 5;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the curve key.
|
||||
/// </summary>
|
||||
/// <value>The curve key.</value>
|
||||
public string CurveKey
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the index.
|
||||
/// </summary>
|
||||
/// <value>The index.</value>
|
||||
public int Index
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the mark text.
|
||||
/// </summary>
|
||||
/// <value>The mark text.</value>
|
||||
public string Text
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
private Color? textColor = null;
|
||||
|
||||
public Color? TextColor
|
||||
{
|
||||
get { return textColor; }
|
||||
set { textColor = value; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The position style
|
||||
/// </summary>
|
||||
private MarkTextPositionStyle positionStyle = MarkTextPositionStyle.Auto;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the position style.
|
||||
/// </summary>
|
||||
/// <value>The position style.</value>
|
||||
public MarkTextPositionStyle PositionStyle
|
||||
{
|
||||
get { return positionStyle; }
|
||||
set { positionStyle = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Calculates the index of the direction from data.
|
||||
/// </summary>
|
||||
/// <param name="data">The data.</param>
|
||||
/// <param name="Index">The index.</param>
|
||||
/// <returns>MarkTextPositionStyle.</returns>
|
||||
public static MarkTextPositionStyle CalculateDirectionFromDataIndex(float[] data, int Index)
|
||||
{
|
||||
float num = (Index == 0) ? data[Index] : data[Index - 1];
|
||||
float num2 = (Index == data.Length - 1) ? data[Index] : data[Index + 1];
|
||||
if (num < data[Index] && data[Index] < num2)
|
||||
{
|
||||
return MarkTextPositionStyle.Left;
|
||||
}
|
||||
if (num > data[Index] && data[Index] > num2)
|
||||
{
|
||||
return MarkTextPositionStyle.Right;
|
||||
}
|
||||
if (num <= data[Index] && data[Index] >= num2)
|
||||
{
|
||||
return MarkTextPositionStyle.Up;
|
||||
}
|
||||
if (num >= data[Index] && data[Index] <= num2)
|
||||
{
|
||||
return MarkTextPositionStyle.Down;
|
||||
}
|
||||
return MarkTextPositionStyle.Up;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
public enum MarkTextPositionStyle
|
||||
{
|
||||
Up = 1,
|
||||
Right = 2,
|
||||
Down = 4,
|
||||
Left = 8,
|
||||
Auto = 16
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-25
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="RadarLine.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.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class RadarLine.
|
||||
/// </summary>
|
||||
public class RadarLine
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name.
|
||||
/// </summary>
|
||||
/// <value>The name.</value>
|
||||
public string Name { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the values.
|
||||
/// </summary>
|
||||
/// <value>The values.</value>
|
||||
public double[] Values { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the line.
|
||||
/// </summary>
|
||||
/// <value>The color of the line.</value>
|
||||
public Color? LineColor { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether [show value text].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [show value text]; otherwise, <c>false</c>.</value>
|
||||
public bool ShowValueText { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the fill.
|
||||
/// </summary>
|
||||
/// <value>The color of the fill.</value>
|
||||
public Color? FillColor { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
public class RadarPosition
|
||||
{
|
||||
public string Text { get; set; }
|
||||
public double MaxValue { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,663 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-25
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCRadarChart.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 UCRadarChart.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public class UCRadarChart : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The split count
|
||||
/// </summary>
|
||||
private int splitCount = 5;
|
||||
/// <summary>
|
||||
/// Gets or sets the split count.
|
||||
/// </summary>
|
||||
/// <value>The split count.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置分隔份数")]
|
||||
public int SplitCount
|
||||
{
|
||||
get { return splitCount; }
|
||||
set
|
||||
{
|
||||
splitCount = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置是否使用圆代替连线进行分隔")]
|
||||
public bool UseRoundSplit { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The split odd color
|
||||
/// </summary>
|
||||
private Color splitOddColor = Color.White;
|
||||
/// <summary>
|
||||
/// 分隔奇数栏背景色
|
||||
/// </summary>
|
||||
/// <value>The color of the split odd.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置分隔奇数栏背景色")]
|
||||
public Color SplitOddColor
|
||||
{
|
||||
get { return splitOddColor; }
|
||||
set
|
||||
{
|
||||
splitOddColor = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The split even color
|
||||
/// </summary>
|
||||
private Color splitEvenColor = Color.FromArgb(232, 232, 232);
|
||||
/// <summary>
|
||||
/// 分隔偶数栏背景色
|
||||
/// </summary>
|
||||
/// <value>The color of the split even.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置分隔偶数栏背景色")]
|
||||
public Color SplitEvenColor
|
||||
{
|
||||
get { return splitEvenColor; }
|
||||
set
|
||||
{
|
||||
splitEvenColor = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The line color
|
||||
/// </summary>
|
||||
private Color lineColor = Color.FromArgb(153, 153, 153);
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the line.
|
||||
/// </summary>
|
||||
/// <value>The color of the line.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置线条色")]
|
||||
public Color LineColor
|
||||
{
|
||||
get { return lineColor; }
|
||||
set
|
||||
{
|
||||
lineColor = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The radar positions
|
||||
/// </summary>
|
||||
private RadarPosition[] radarPositions;
|
||||
/// <summary>
|
||||
/// 节点列表,至少需要3个
|
||||
/// </summary>
|
||||
/// <value>The radar positions.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置节点,至少需要3个")]
|
||||
public RadarPosition[] RadarPositions
|
||||
{
|
||||
get { return radarPositions; }
|
||||
set
|
||||
{
|
||||
radarPositions = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The title
|
||||
/// </summary>
|
||||
private string title;
|
||||
/// <summary>
|
||||
/// 标题
|
||||
/// </summary>
|
||||
/// <value>The title.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置标题")]
|
||||
public string Title
|
||||
{
|
||||
get { return title; }
|
||||
set
|
||||
{
|
||||
title = value;
|
||||
ResetTitleSize();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The title font
|
||||
/// </summary>
|
||||
private Font titleFont = new Font("微软雅黑", 12);
|
||||
/// <summary>
|
||||
/// Gets or sets the title font.
|
||||
/// </summary>
|
||||
/// <value>The title font.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置标题字体")]
|
||||
public Font TitleFont
|
||||
{
|
||||
get { return titleFont; }
|
||||
set
|
||||
{
|
||||
titleFont = value;
|
||||
ResetTitleSize();
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The title color
|
||||
/// </summary>
|
||||
private Color titleColor = Color.Black;
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the title.
|
||||
/// </summary>
|
||||
/// <value>The color of the title.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置标题文本颜色")]
|
||||
public Color TitleColor
|
||||
{
|
||||
get { return titleColor; }
|
||||
set
|
||||
{
|
||||
titleColor = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The lines
|
||||
/// </summary>
|
||||
private RadarLine[] lines;
|
||||
/// <summary>
|
||||
/// Gets or sets the lines.
|
||||
/// </summary>
|
||||
/// <value>The lines.</value>
|
||||
[Browsable(true)]
|
||||
[Category("自定义")]
|
||||
[Description("获取或设置值线条,Values长度必须与RadarPositions长度一致,否则无法显示")]
|
||||
public RadarLine[] Lines
|
||||
{
|
||||
get { return lines; }
|
||||
set
|
||||
{
|
||||
lines = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The title size
|
||||
/// </summary>
|
||||
SizeF titleSize = SizeF.Empty;
|
||||
/// <summary>
|
||||
/// The m rect working
|
||||
/// </summary>
|
||||
private RectangleF m_rectWorking = Rectangle.Empty;
|
||||
/// <summary>
|
||||
/// The line value type size
|
||||
/// </summary>
|
||||
SizeF lineValueTypeSize = SizeF.Empty;
|
||||
/// <summary>
|
||||
/// The int line value COM count
|
||||
/// </summary>
|
||||
int intLineValueComCount = 0;
|
||||
/// <summary>
|
||||
/// The int line value row count
|
||||
/// </summary>
|
||||
int intLineValueRowCount = 0;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCRadarChart"/> class.
|
||||
/// </summary>
|
||||
public UCRadarChart()
|
||||
{
|
||||
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 += UCRadarChart_SizeChanged;
|
||||
Size = new System.Drawing.Size(150, 150);
|
||||
radarPositions = new RadarPosition[0];
|
||||
if (ControlHelper.IsDesignMode())
|
||||
{
|
||||
radarPositions = new RadarPosition[6];
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
radarPositions[i] = new RadarPosition
|
||||
{
|
||||
Text = "Item" + (i + 1),
|
||||
MaxValue = 100
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
lines = new RadarLine[0];
|
||||
if (ControlHelper.IsDesignMode())
|
||||
{
|
||||
Random r = new Random();
|
||||
lines = new RadarLine[2];
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
lines[i] = new RadarLine()
|
||||
{
|
||||
Name = "line" + i
|
||||
};
|
||||
lines[i].Values = new double[radarPositions.Length];
|
||||
for (int j = 0; j < radarPositions.Length; j++)
|
||||
{
|
||||
lines[i].Values[j] = r.Next(20, (int)radarPositions[j].MaxValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the UCRadarChart 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 UCRadarChart_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
ResetWorkingRect();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the working rect.
|
||||
/// </summary>
|
||||
private void ResetWorkingRect()
|
||||
{
|
||||
if (lines != null && lines.Length > 0)
|
||||
{
|
||||
using (Graphics g = this.CreateGraphics())
|
||||
{
|
||||
foreach (var item in lines)
|
||||
{
|
||||
var s = g.MeasureString(item.Name, Font);
|
||||
if (s.Width > lineValueTypeSize.Width)
|
||||
lineValueTypeSize = s;
|
||||
}
|
||||
}
|
||||
}
|
||||
var lineTypePanelHeight = 0f;
|
||||
if (lineValueTypeSize != SizeF.Empty)
|
||||
{
|
||||
intLineValueComCount = (int)(this.Width / (lineValueTypeSize.Width + 25));
|
||||
|
||||
intLineValueRowCount = lines.Length / intLineValueComCount;
|
||||
if (lines.Length % intLineValueComCount != 0)
|
||||
{
|
||||
intLineValueRowCount++;
|
||||
}
|
||||
lineTypePanelHeight = (lineValueTypeSize.Height + 10) * intLineValueRowCount;
|
||||
}
|
||||
var min = Math.Min(this.Width, this.Height - titleSize.Height - lineTypePanelHeight);
|
||||
var rectWorking = new RectangleF((this.Width - min) / 2 + 10, titleSize.Height + lineTypePanelHeight + 10, min - 10, min - 10);
|
||||
//处理文字
|
||||
float fltSplitAngle = 360F / radarPositions.Length;
|
||||
float fltRadiusWidth = rectWorking.Width / 2;
|
||||
float minX = rectWorking.Left;
|
||||
float maxX = rectWorking.Right;
|
||||
float minY = rectWorking.Top;
|
||||
float maxY = rectWorking.Bottom;
|
||||
using (Graphics g = this.CreateGraphics())
|
||||
{
|
||||
PointF centrePoint = new PointF(rectWorking.Left + rectWorking.Width / 2, rectWorking.Top + rectWorking.Height / 2);
|
||||
for (int i = 0; i < radarPositions.Length; i++)
|
||||
{
|
||||
float fltAngle = 270 + fltSplitAngle * i;
|
||||
fltAngle = fltAngle % 360;
|
||||
PointF _point = GetPointByAngle(centrePoint, fltAngle, fltRadiusWidth);
|
||||
var _txtSize = g.MeasureString(radarPositions[i].Text, Font);
|
||||
if (_point.X < centrePoint.X)//左
|
||||
{
|
||||
if (_point.X - _txtSize.Width < minX)
|
||||
{
|
||||
minX = rectWorking.Left + _txtSize.Width;
|
||||
}
|
||||
}
|
||||
else//右
|
||||
{
|
||||
if (_point.X + _txtSize.Width > maxX)
|
||||
{
|
||||
maxX = rectWorking.Right - _txtSize.Width;
|
||||
}
|
||||
}
|
||||
if (_point.Y < centrePoint.Y)//上
|
||||
{
|
||||
if (_point.Y - _txtSize.Height < minY)
|
||||
{
|
||||
minY = rectWorking.Top + _txtSize.Height;
|
||||
}
|
||||
}
|
||||
else//下
|
||||
{
|
||||
if (_point.Y + _txtSize.Height > maxY)
|
||||
{
|
||||
maxY = rectWorking.Bottom - _txtSize.Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
min = Math.Min(maxX - minX, maxY - minY);
|
||||
m_rectWorking = new RectangleF(minX, minY, min, min);
|
||||
}
|
||||
|
||||
/// <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);
|
||||
var g = e.Graphics;
|
||||
g.SetGDIHigh();
|
||||
|
||||
if (!string.IsNullOrEmpty(title))
|
||||
{
|
||||
g.DrawString(title, titleFont, new SolidBrush(titleColor), new RectangleF(m_rectWorking.Left + (m_rectWorking.Width - titleSize.Width) / 2, m_rectWorking.Top - titleSize.Height - 10 - (intLineValueRowCount * (10 + lineValueTypeSize.Height)), titleSize.Width, titleSize.Height));
|
||||
}
|
||||
|
||||
if (radarPositions.Length <= 2)
|
||||
{
|
||||
g.DrawString("至少需要3个顶点", Font, new SolidBrush(Color.Black), m_rectWorking, new StringFormat() { Alignment = StringAlignment.Center, LineAlignment = StringAlignment.Center });
|
||||
return;
|
||||
}
|
||||
|
||||
var y = m_rectWorking.Top - 20 - (intLineValueRowCount * (10 + lineValueTypeSize.Height));
|
||||
|
||||
for (int i = 0; i < intLineValueRowCount; i++)
|
||||
{
|
||||
var x = 0f;
|
||||
int intCount = intLineValueComCount;
|
||||
if (i == intLineValueRowCount - 1)
|
||||
{
|
||||
intCount = lines.Length % intLineValueComCount;
|
||||
|
||||
}
|
||||
x = m_rectWorking.Left + (m_rectWorking.Width - intCount * (lineValueTypeSize.Width + 25)) / 2;
|
||||
|
||||
for (int j = 0; j < intCount; j++)
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(lines[i * intLineValueComCount + j].LineColor.Value), new RectangleF(x + (lineValueTypeSize.Width + 25) * j, y + lineValueTypeSize.Height * i, 15, lineValueTypeSize.Height));
|
||||
g.DrawString(lines[i * intLineValueComCount + j].Name, Font, new SolidBrush(lines[i * intLineValueComCount + j].LineColor.Value), new PointF(x + (lineValueTypeSize.Width + 25) * j + 20, y + lineValueTypeSize.Height * i));
|
||||
}
|
||||
}
|
||||
|
||||
float fltSplitAngle = 360F / radarPositions.Length;
|
||||
float fltRadiusWidth = m_rectWorking.Width / 2;
|
||||
float fltSplitRadiusWidth = fltRadiusWidth / splitCount;
|
||||
PointF centrePoint = new PointF(m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Top + m_rectWorking.Height / 2);
|
||||
|
||||
List<List<PointF>> lstRingPoints = new List<List<PointF>>(splitCount);
|
||||
//分割点
|
||||
for (int i = 0; i < radarPositions.Length; i++)
|
||||
{
|
||||
float fltAngle = 270 + fltSplitAngle * i;
|
||||
fltAngle = fltAngle % 360;
|
||||
for (int j = 0; j < splitCount; j++)
|
||||
{
|
||||
if (i == 0)
|
||||
{
|
||||
lstRingPoints.Add(new List<PointF>());
|
||||
}
|
||||
PointF _point = GetPointByAngle(centrePoint, fltAngle, fltSplitRadiusWidth * (splitCount - j));
|
||||
lstRingPoints[j].Add(_point);
|
||||
}
|
||||
}
|
||||
|
||||
if (UseRoundSplit)
|
||||
{
|
||||
for (int i = 0; i < splitCount; i++)
|
||||
{
|
||||
RectangleF rect = new RectangleF(centrePoint.X - fltSplitRadiusWidth * (splitCount - i), centrePoint.Y - fltSplitRadiusWidth * (splitCount - i), fltSplitRadiusWidth * (splitCount - i) * 2, fltSplitRadiusWidth * (splitCount - i) * 2);
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
g.FillEllipse(new SolidBrush(splitOddColor), rect);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.FillEllipse(new SolidBrush(splitEvenColor), rect);
|
||||
}
|
||||
|
||||
g.DrawEllipse(new Pen(new SolidBrush(lineColor)), rect);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//间隔颜色
|
||||
for (int i = 0; i < lstRingPoints.Count; i++)
|
||||
{
|
||||
var ring = lstRingPoints[i];
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLines(ring.ToArray());
|
||||
if ((lstRingPoints.Count - i) % 2 == 0)
|
||||
{
|
||||
g.FillPath(new SolidBrush(splitEvenColor), path);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.FillPath(new SolidBrush(splitOddColor), path);
|
||||
}
|
||||
}
|
||||
//画环
|
||||
foreach (var ring in lstRingPoints)
|
||||
{
|
||||
ring.Add(ring[0]);
|
||||
g.DrawLines(new Pen(new SolidBrush(lineColor)), ring.ToArray());
|
||||
}
|
||||
}
|
||||
//分割线
|
||||
foreach (var item in lstRingPoints[0])
|
||||
{
|
||||
g.DrawLine(new Pen(new SolidBrush(lineColor)), centrePoint, item);
|
||||
}
|
||||
|
||||
//值
|
||||
for (int i = 0; i < lines.Length; i++)
|
||||
{
|
||||
var line = lines[i];
|
||||
if (line.Values.Length != radarPositions.Length)//如果数据长度和节点长度不一致则不绘制
|
||||
continue;
|
||||
if (line.LineColor == null || line.LineColor == Color.Empty || line.LineColor == Color.Transparent)
|
||||
line.LineColor = ControlHelper.Colors[i + 13];
|
||||
List<PointF> ps = new List<PointF>();
|
||||
for (int j = 0; j < radarPositions.Length; j++)
|
||||
{
|
||||
float fltAngle = 270 + fltSplitAngle * j;
|
||||
fltAngle = fltAngle % 360;
|
||||
PointF _point = GetPointByAngle(centrePoint, fltAngle, fltRadiusWidth * (float)(line.Values[j] / radarPositions[i].MaxValue));
|
||||
ps.Add(_point);
|
||||
}
|
||||
ps.Add(ps[0]);
|
||||
if (line.FillColor != null && line.FillColor != Color.Empty && line.FillColor != Color.Transparent)
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLines(ps.ToArray());
|
||||
g.FillPath(new SolidBrush(line.FillColor.Value), path);
|
||||
}
|
||||
g.DrawLines(new Pen(new SolidBrush(line.LineColor.Value), 2), ps.ToArray());
|
||||
|
||||
for (int j = 0; j < radarPositions.Length; j++)
|
||||
{
|
||||
var item = ps[j];
|
||||
g.FillEllipse(new SolidBrush(Color.White), new RectangleF(item.X - 3, item.Y - 3, 6, 6));
|
||||
g.DrawEllipse(new Pen(new SolidBrush(line.LineColor.Value)), new RectangleF(item.X - 3, item.Y - 3, 6, 6));
|
||||
if (line.ShowValueText)
|
||||
{
|
||||
var valueSize = g.MeasureString(line.Values[j].ToString("0.##"), Font);
|
||||
g.DrawString(line.Values[j].ToString("0.##"), Font, new SolidBrush(line.LineColor.Value), new PointF(item.X - valueSize.Width / 2, item.Y - valueSize.Height - 5));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//文本
|
||||
|
||||
for (int i = 0; i < radarPositions.Length; i++)
|
||||
{
|
||||
PointF point = lstRingPoints[0][i];
|
||||
var txtSize = g.MeasureString(radarPositions[i].Text, Font);
|
||||
|
||||
if (point.X == centrePoint.X)
|
||||
{
|
||||
if (point.Y > centrePoint.Y)
|
||||
{
|
||||
g.DrawString(radarPositions[i].Text, Font, new SolidBrush(ForeColor), new PointF(point.X - txtSize.Width / 2, point.Y + 10));
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawString(radarPositions[i].Text, Font, new SolidBrush(ForeColor), new PointF(point.X - txtSize.Width / 2, point.Y - 10 - txtSize.Height));
|
||||
}
|
||||
}
|
||||
else if (point.Y == centrePoint.Y)
|
||||
{
|
||||
if (point.X < centrePoint.X)
|
||||
g.DrawString(radarPositions[i].Text, Font, new SolidBrush(ForeColor), new PointF(point.X - 10 - txtSize.Width, point.Y - txtSize.Height / 2));
|
||||
else
|
||||
g.DrawString(radarPositions[i].Text, Font, new SolidBrush(ForeColor), new PointF(point.X + 10, point.Y - txtSize.Height / 2));
|
||||
}
|
||||
else if (point.X < centrePoint.X)//左
|
||||
{
|
||||
if (point.Y < centrePoint.Y)//左上
|
||||
{
|
||||
g.DrawString(radarPositions[i].Text, Font, new SolidBrush(ForeColor), new PointF(point.X - 10 - txtSize.Width, point.Y - 10 + txtSize.Height / 2));
|
||||
}
|
||||
else//左下
|
||||
{
|
||||
g.DrawString(radarPositions[i].Text, Font, new SolidBrush(ForeColor), new PointF(point.X - 10 - txtSize.Width, point.Y + 10 - txtSize.Height / 2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (point.Y < centrePoint.Y)//右上
|
||||
{
|
||||
g.DrawString(radarPositions[i].Text, Font, new SolidBrush(ForeColor), new PointF(point.X + 10, point.Y - 10 + txtSize.Height / 2));
|
||||
}
|
||||
else//右下
|
||||
{
|
||||
g.DrawString(radarPositions[i].Text, Font, new SolidBrush(ForeColor), new PointF(point.X + 10, point.Y + 10 - txtSize.Height / 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#region 根据中心点、角度、半径计算圆边坐标点 English:Calculating the coordinate points of circular edge according to the center point, angle and radius
|
||||
/// <summary>
|
||||
/// 功能描述:根据中心点、角度、半径计算圆边坐标点 English:Calculating the coordinate points of circular edge according to the center point, angle and radius
|
||||
/// 作 者:HZH
|
||||
/// 创建日期:2019-09-25 09:46:32
|
||||
/// 任务编号:POS
|
||||
/// </summary>
|
||||
/// <param name="centrePoint">centrePoint</param>
|
||||
/// <param name="fltAngle">fltAngle</param>
|
||||
/// <param name="fltRadiusWidth">fltRadiusWidth</param>
|
||||
/// <returns>返回值</returns>
|
||||
private PointF GetPointByAngle(PointF centrePoint, float fltAngle, float fltRadiusWidth)
|
||||
{
|
||||
PointF p = centrePoint;
|
||||
if (fltAngle == 0)
|
||||
{
|
||||
p.X += fltRadiusWidth;
|
||||
}
|
||||
else if (fltAngle == 90)
|
||||
{
|
||||
p.Y += fltRadiusWidth;
|
||||
}
|
||||
else if (fltAngle == 180)
|
||||
{
|
||||
p.X -= fltRadiusWidth;
|
||||
}
|
||||
else if (fltAngle == 270)
|
||||
{
|
||||
p.Y -= fltRadiusWidth;
|
||||
}
|
||||
else if (fltAngle > 0 && fltAngle < 90)
|
||||
{
|
||||
p.Y += (float)Math.Sin(Math.PI * (fltAngle / 180.00F)) * fltRadiusWidth;
|
||||
p.X += (float)Math.Cos(Math.PI * (fltAngle / 180.00F)) * fltRadiusWidth;
|
||||
}
|
||||
else if (fltAngle > 90 && fltAngle < 180)
|
||||
{
|
||||
p.Y += (float)Math.Sin(Math.PI * ((180 - fltAngle) / 180.00F)) * fltRadiusWidth;
|
||||
p.X -= (float)Math.Cos(Math.PI * ((180 - fltAngle) / 180.00F)) * fltRadiusWidth;
|
||||
}
|
||||
else if (fltAngle > 180 && fltAngle < 270)
|
||||
{
|
||||
p.Y -= (float)Math.Sin(Math.PI * ((fltAngle - 180) / 180.00F)) * fltRadiusWidth;
|
||||
p.X -= (float)Math.Cos(Math.PI * ((fltAngle - 180) / 180.00F)) * fltRadiusWidth;
|
||||
}
|
||||
else if (fltAngle > 270 && fltAngle < 360)
|
||||
{
|
||||
p.Y -= (float)Math.Sin(Math.PI * ((360 - fltAngle) / 180.00F)) * fltRadiusWidth;
|
||||
p.X += (float)Math.Cos(Math.PI * ((360 - fltAngle) / 180.00F)) * fltRadiusWidth;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Resets the size of the title.
|
||||
/// </summary>
|
||||
private void ResetTitleSize()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(title))
|
||||
{
|
||||
using (Graphics g = this.CreateGraphics())
|
||||
{
|
||||
titleSize = g.MeasureString(title, titleFont);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
titleSize = SizeF.Empty;
|
||||
}
|
||||
titleSize.Height += 20;
|
||||
ResetWorkingRect();
|
||||
}
|
||||
}
|
||||
}
|
||||
36
UsingControl/HZHControls/Controls/Charts/ZoomType.cs
Normal file
36
UsingControl/HZHControls/Controls/Charts/ZoomType.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-17
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="ZoomType.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum ZoomType
|
||||
/// </summary>
|
||||
public enum ZoomType
|
||||
{
|
||||
/// <summary>
|
||||
/// The none
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// The enlarge
|
||||
/// </summary>
|
||||
Enlarge,
|
||||
/// <summary>
|
||||
/// The reduce
|
||||
/// </summary>
|
||||
Reduce
|
||||
}
|
||||
}
|
||||
105
UsingControl/HZHControls/Controls/Checkbox/UCCheckBox.Designer.cs
generated
Normal file
105
UsingControl/HZHControls/Controls/Checkbox/UCCheckBox.Designer.cs
generated
Normal file
@@ -0,0 +1,105 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCCheckBox.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCCheckBox.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
partial class UCCheckBox
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.BackgroundImage = global::HZH_Controls.Properties.Resources.checkbox0;
|
||||
this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Zoom;
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.panel1.Location = new System.Drawing.Point(1, 1);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(18, 28);
|
||||
this.panel1.TabIndex = 0;
|
||||
this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CheckBox_MouseDown);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.label1.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(62)))), ((int)(((byte)(62)))), ((int)(((byte)(62)))));
|
||||
this.label1.Location = new System.Drawing.Point(19, 1);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Padding = new System.Windows.Forms.Padding(5, 0, 0, 0);
|
||||
this.label1.Size = new System.Drawing.Size(213, 28);
|
||||
this.label1.TabIndex = 1;
|
||||
this.label1.Text = "复选框";
|
||||
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.label1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CheckBox_MouseDown);
|
||||
//
|
||||
// UCCheckBox
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Name = "UCCheckBox";
|
||||
this.Padding = new System.Windows.Forms.Padding(1);
|
||||
this.Size = new System.Drawing.Size(233, 30);
|
||||
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.CheckBox_MouseDown);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The panel1
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
/// <summary>
|
||||
/// The label1
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Label label1;
|
||||
}
|
||||
}
|
||||
216
UsingControl/HZHControls/Controls/Checkbox/UCCheckBox.cs
Normal file
216
UsingControl/HZHControls/Controls/Checkbox/UCCheckBox.cs
Normal file
@@ -0,0 +1,216 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCCheckBox.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCCheckBox.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
[DefaultEvent("CheckedChangeEvent")]
|
||||
public partial class UCCheckBox : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// 选中改变事件
|
||||
/// </summary>
|
||||
[Description("选中改变事件"), Category("自定义")]
|
||||
public event EventHandler CheckedChangeEvent;
|
||||
/// <summary>
|
||||
/// 字体
|
||||
/// </summary>
|
||||
/// <value>The font.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
||||
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Description("字体"), Category("自定义")]
|
||||
public override Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Font = value;
|
||||
label1.Font = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The fore color
|
||||
/// </summary>
|
||||
private Color _ForeColor = Color.FromArgb(62, 62, 62);
|
||||
/// <summary>
|
||||
/// 字体颜色
|
||||
/// </summary>
|
||||
/// <value>The color of the fore.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Description("字体颜色"), Category("自定义")]
|
||||
public new Color ForeColor
|
||||
{
|
||||
get { return _ForeColor; }
|
||||
set
|
||||
{
|
||||
base.ForeColor = value;
|
||||
label1.ForeColor = value;
|
||||
_ForeColor = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The text
|
||||
/// </summary>
|
||||
private string _Text = "复选框";
|
||||
/// <summary>
|
||||
/// 文本
|
||||
/// </summary>
|
||||
/// <value>The text value.</value>
|
||||
[Description("文本"), Category("自定义")]
|
||||
public string TextValue
|
||||
{
|
||||
get { return _Text; }
|
||||
set
|
||||
{
|
||||
label1.Text = value;
|
||||
_Text = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The checked
|
||||
/// </summary>
|
||||
private bool _checked = false;
|
||||
/// <summary>
|
||||
/// 是否选中
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if checked; otherwise, <c>false</c>.</value>
|
||||
[Description("是否选中"), Category("自定义")]
|
||||
public bool Checked
|
||||
{
|
||||
get
|
||||
{
|
||||
return _checked;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_checked != value)
|
||||
{
|
||||
_checked = value;
|
||||
if (base.Enabled)
|
||||
{
|
||||
if (_checked)
|
||||
{
|
||||
panel1.BackgroundImage = Properties.Resources.checkbox1;
|
||||
}
|
||||
else
|
||||
{
|
||||
panel1.BackgroundImage = Properties.Resources.checkbox0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_checked)
|
||||
{
|
||||
panel1.BackgroundImage = Properties.Resources.checkbox10;
|
||||
}
|
||||
else
|
||||
{
|
||||
panel1.BackgroundImage = Properties.Resources.checkbox00;
|
||||
}
|
||||
}
|
||||
|
||||
if (CheckedChangeEvent != null)
|
||||
{
|
||||
CheckedChangeEvent(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置一个值,该值指示控件是否可以对用户交互作出响应。
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if enabled; otherwise, <c>false</c>.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
||||
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
public new bool Enabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Enabled;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Enabled = value;
|
||||
if (value)
|
||||
{
|
||||
if (_checked)
|
||||
{
|
||||
panel1.BackgroundImage = Properties.Resources.checkbox1;
|
||||
}
|
||||
else
|
||||
{
|
||||
panel1.BackgroundImage = Properties.Resources.checkbox0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_checked)
|
||||
{
|
||||
panel1.BackgroundImage = Properties.Resources.checkbox10;
|
||||
}
|
||||
else
|
||||
{
|
||||
panel1.BackgroundImage = Properties.Resources.checkbox00;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCCheckBox" /> class.
|
||||
/// </summary>
|
||||
public UCCheckBox()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the CheckBox control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void CheckBox_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
Checked = !Checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/Checkbox/UCCheckBox.resx
Normal file
120
UsingControl/HZHControls/Controls/Checkbox/UCCheckBox.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
147
UsingControl/HZHControls/Controls/ComboBox/UCCombox.Designer.cs
generated
Normal file
147
UsingControl/HZHControls/Controls/ComboBox/UCCombox.Designer.cs
generated
Normal file
@@ -0,0 +1,147 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCCombox.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCCombox.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCControlBase" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCControlBase" />
|
||||
partial class UCCombox
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.txtInput = new HZH_Controls.Controls.TextBoxEx();
|
||||
this.lblInput = new System.Windows.Forms.Label();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.BackColor = System.Drawing.Color.Transparent;
|
||||
this.panel1.BackgroundImage = global::HZH_Controls.Properties.Resources.ComboBox;
|
||||
this.panel1.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.panel1.Location = new System.Drawing.Point(136, 0);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(37, 32);
|
||||
this.panel1.TabIndex = 0;
|
||||
this.panel1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.click_MouseDown);
|
||||
//
|
||||
// txtInput
|
||||
//
|
||||
this.txtInput.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.txtInput.BackColor = System.Drawing.Color.White;
|
||||
this.txtInput.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.txtInput.DecLength = 2;
|
||||
this.txtInput.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtInput.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.txtInput.InputType = HZH_Controls.TextInputType.NotControl;
|
||||
this.txtInput.Location = new System.Drawing.Point(3, 4);
|
||||
this.txtInput.Margin = new System.Windows.Forms.Padding(3, 3, 10, 3);
|
||||
this.txtInput.MaxValue = new decimal(new int[] {
|
||||
1000000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtInput.MinValue = new decimal(new int[] {
|
||||
1000000,
|
||||
0,
|
||||
0,
|
||||
-2147483648});
|
||||
this.txtInput.MyRectangle = new System.Drawing.Rectangle(0, 0, 0, 0);
|
||||
this.txtInput.Name = "txtInput";
|
||||
this.txtInput.OldText = null;
|
||||
this.txtInput.PromptColor = System.Drawing.Color.Silver;
|
||||
this.txtInput.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtInput.PromptText = "";
|
||||
this.txtInput.RegexPattern = "";
|
||||
this.txtInput.Size = new System.Drawing.Size(133, 24);
|
||||
this.txtInput.TabIndex = 1;
|
||||
this.txtInput.TextChanged += new System.EventHandler(this.txtInput_TextChanged);
|
||||
//
|
||||
// lblInput
|
||||
//
|
||||
this.lblInput.AutoSize = true;
|
||||
this.lblInput.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(64)))), ((int)(((byte)(64)))), ((int)(((byte)(64)))));
|
||||
this.lblInput.Location = new System.Drawing.Point(3, 6);
|
||||
this.lblInput.Name = "lblInput";
|
||||
this.lblInput.Size = new System.Drawing.Size(0, 20);
|
||||
this.lblInput.TabIndex = 2;
|
||||
this.lblInput.Visible = false;
|
||||
this.lblInput.MouseDown += new System.Windows.Forms.MouseEventHandler(this.click_MouseDown);
|
||||
//
|
||||
// UCCombox
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.ConerRadius = 5;
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Controls.Add(this.txtInput);
|
||||
this.Controls.Add(this.lblInput);
|
||||
this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
|
||||
this.IsRadius = true;
|
||||
this.IsShowRect = true;
|
||||
this.Name = "UCCombox";
|
||||
this.Size = new System.Drawing.Size(173, 32);
|
||||
this.Load += new System.EventHandler(this.UCComboBox_Load);
|
||||
this.SizeChanged += new System.EventHandler(this.UCComboBox_SizeChanged);
|
||||
this.MouseDown += new System.Windows.Forms.MouseEventHandler(this.click_MouseDown);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The panel1
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
/// <summary>
|
||||
/// The text input
|
||||
/// </summary>
|
||||
public TextBoxEx txtInput;
|
||||
/// <summary>
|
||||
/// The label input
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Label lblInput;
|
||||
}
|
||||
}
|
||||
586
UsingControl/HZHControls/Controls/ComboBox/UCCombox.cs
Normal file
586
UsingControl/HZHControls/Controls/ComboBox/UCCombox.cs
Normal file
@@ -0,0 +1,586 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCCombox.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Drawing.Drawing2D;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCCombox.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCControlBase" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCControlBase" />
|
||||
[DefaultEvent("SelectedChangedEvent")]
|
||||
public partial class UCCombox : UCControlBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The fore color
|
||||
/// </summary>
|
||||
Color _ForeColor = Color.FromArgb(64, 64, 64);
|
||||
/// <summary>
|
||||
/// 文字颜色
|
||||
/// </summary>
|
||||
/// <value>The color of the fore.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Description("文字颜色"), Category("自定义")]
|
||||
public override Color ForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return _ForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
_ForeColor = value;
|
||||
lblInput.ForeColor = value;
|
||||
txtInput.ForeColor = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 选中事件
|
||||
/// </summary>
|
||||
[Description("选中事件"), Category("自定义")]
|
||||
public event EventHandler SelectedChangedEvent;
|
||||
/// <summary>
|
||||
/// 文本改变事件
|
||||
/// </summary>
|
||||
[Description("文本改变事件"), Category("自定义")]
|
||||
public event EventHandler TextChangedEvent;
|
||||
|
||||
/// <summary>
|
||||
/// The box style
|
||||
/// </summary>
|
||||
private ComboBoxStyle _BoxStyle = ComboBoxStyle.DropDown;
|
||||
/// <summary>
|
||||
/// 控件样式
|
||||
/// </summary>
|
||||
/// <value>The box style.</value>
|
||||
[Description("控件样式"), Category("自定义")]
|
||||
public ComboBoxStyle BoxStyle
|
||||
{
|
||||
get { return _BoxStyle; }
|
||||
set
|
||||
{
|
||||
_BoxStyle = value;
|
||||
if (value == ComboBoxStyle.DropDownList)
|
||||
{
|
||||
lblInput.Visible = true;
|
||||
txtInput.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
lblInput.Visible = false;
|
||||
txtInput.Visible = true;
|
||||
}
|
||||
|
||||
if (this._BoxStyle == ComboBoxStyle.DropDownList)
|
||||
{
|
||||
txtInput.BackColor = _BackColor;
|
||||
base.FillColor = _BackColor;
|
||||
base.RectColor = _BackColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
txtInput.BackColor = Color.White;
|
||||
base.FillColor = Color.White;
|
||||
base.RectColor = Color.FromArgb(220, 220, 220);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The font
|
||||
/// </summary>
|
||||
private Font _Font = new Font("微软雅黑", 12);
|
||||
/// <summary>
|
||||
/// 字体
|
||||
/// </summary>
|
||||
/// <value>The font.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
||||
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Description("字体"), Category("自定义")]
|
||||
public new Font Font
|
||||
{
|
||||
get { return _Font; }
|
||||
set
|
||||
{
|
||||
_Font = value;
|
||||
lblInput.Font = value;
|
||||
txtInput.Font = value;
|
||||
txtInput.PromptFont = value;
|
||||
this.txtInput.Location = new Point(this.txtInput.Location.X, (this.Height - txtInput.Height) / 2);
|
||||
this.lblInput.Location = new Point(this.lblInput.Location.X, (this.Height - lblInput.Height) / 2);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当使用边框时填充颜色,当值为背景色或透明色或空值则不填充
|
||||
/// </summary>
|
||||
/// <value>The color of the fill.</value>
|
||||
[Obsolete("不再可用的属性")]
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private new Color FillColor
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 边框颜色
|
||||
/// </summary>
|
||||
/// <value>The color of the rect.</value>
|
||||
[Obsolete("不再可用的属性")]
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private new Color RectColor
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The text value
|
||||
/// </summary>
|
||||
private string _TextValue;
|
||||
/// <summary>
|
||||
/// 文字
|
||||
/// </summary>
|
||||
/// <value>The text value.</value>
|
||||
[Description("文字"), Category("自定义")]
|
||||
public string TextValue
|
||||
{
|
||||
get { return _TextValue; }
|
||||
set
|
||||
{
|
||||
_TextValue = value;
|
||||
if (lblInput.Text != value)
|
||||
lblInput.Text = value;
|
||||
if (txtInput.Text != value)
|
||||
txtInput.Text = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The source
|
||||
/// </summary>
|
||||
private List<KeyValuePair<string, string>> _source = null;
|
||||
/// <summary>
|
||||
/// 数据源
|
||||
/// </summary>
|
||||
/// <value>The source.</value>
|
||||
[Description("数据源"), Category("自定义")]
|
||||
public List<KeyValuePair<string, string>> Source
|
||||
{
|
||||
get { return _source; }
|
||||
set
|
||||
{
|
||||
_source = value;
|
||||
_selectedIndex = -1;
|
||||
_selectedValue = "";
|
||||
_selectedItem = new KeyValuePair<string, string>();
|
||||
_selectedText = "";
|
||||
lblInput.Text = "";
|
||||
txtInput.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The selected item
|
||||
/// </summary>
|
||||
private KeyValuePair<string, string> _selectedItem = new KeyValuePair<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// The selected index
|
||||
/// </summary>
|
||||
private int _selectedIndex = -1;
|
||||
/// <summary>
|
||||
/// 选中的数据下标
|
||||
/// </summary>
|
||||
/// <value>The index of the selected.</value>
|
||||
[Description("选中的数据下标"), Category("自定义")]
|
||||
public int SelectedIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selectedIndex;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value < 0 || _source == null || _source.Count <= 0 || value >= _source.Count)
|
||||
{
|
||||
_selectedIndex = -1;
|
||||
_selectedValue = "";
|
||||
_selectedItem = new KeyValuePair<string, string>();
|
||||
SelectedText = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
_selectedIndex = value;
|
||||
_selectedItem = _source[value];
|
||||
_selectedValue = _source[value].Key;
|
||||
SelectedText = _source[value].Value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The selected value
|
||||
/// </summary>
|
||||
private string _selectedValue = "";
|
||||
/// <summary>
|
||||
/// 选中的值
|
||||
/// </summary>
|
||||
/// <value>The selected value.</value>
|
||||
[Description("选中的值"), Category("自定义")]
|
||||
public string SelectedValue
|
||||
{
|
||||
get
|
||||
{
|
||||
return _selectedValue;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_source == null || _source.Count <= 0)
|
||||
{
|
||||
SelectedText = "";
|
||||
_selectedValue = "";
|
||||
_selectedIndex = -1;
|
||||
_selectedItem = new KeyValuePair<string, string>();
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < _source.Count; i++)
|
||||
{
|
||||
if (_source[i].Key == value)
|
||||
{
|
||||
_selectedValue = value;
|
||||
_selectedIndex = i;
|
||||
_selectedItem = _source[i];
|
||||
SelectedText = _source[i].Value;
|
||||
return;
|
||||
}
|
||||
}
|
||||
_selectedValue = "";
|
||||
_selectedIndex = -1;
|
||||
_selectedItem = new KeyValuePair<string, string>();
|
||||
SelectedText = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The selected text
|
||||
/// </summary>
|
||||
private string _selectedText = "";
|
||||
/// <summary>
|
||||
/// 选中的文本
|
||||
/// </summary>
|
||||
/// <value>The selected text.</value>
|
||||
[Description("选中的文本"), Category("自定义")]
|
||||
public string SelectedText
|
||||
{
|
||||
get { return _selectedText; }
|
||||
private set
|
||||
{
|
||||
_selectedText = value;
|
||||
lblInput.Text = _selectedText;
|
||||
txtInput.Text = _selectedText;
|
||||
if (SelectedChangedEvent != null)
|
||||
{
|
||||
SelectedChangedEvent(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The item width
|
||||
/// </summary>
|
||||
private int _ItemWidth = 70;
|
||||
/// <summary>
|
||||
/// 项宽度
|
||||
/// </summary>
|
||||
/// <value>The width of the item.</value>
|
||||
[Description("项宽度"), Category("自定义")]
|
||||
public int ItemWidth
|
||||
{
|
||||
get { return _ItemWidth; }
|
||||
set { _ItemWidth = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The drop panel height
|
||||
/// </summary>
|
||||
private int _dropPanelHeight = -1;
|
||||
/// <summary>
|
||||
/// 下拉面板高度
|
||||
/// </summary>
|
||||
/// <value>The height of the drop panel.</value>
|
||||
[Description("下拉面板高度"), Category("自定义")]
|
||||
public int DropPanelHeight
|
||||
{
|
||||
get { return _dropPanelHeight; }
|
||||
set { _dropPanelHeight = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取或设置控件的背景色。
|
||||
/// </summary>
|
||||
/// <value>The color of the back.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Obsolete("不再可用的属性,如需要改变背景色,请使用BackColorExt")]
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private new Color BackColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.BackColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.BackColor = Color.Transparent;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The back color
|
||||
/// </summary>
|
||||
private Color _BackColor = Color.FromArgb(240, 240, 240);
|
||||
/// <summary>
|
||||
/// 背景色
|
||||
/// </summary>
|
||||
/// <value>The back color ext.</value>
|
||||
[Description("背景色"), Category("自定义")]
|
||||
public Color BackColorExt
|
||||
{
|
||||
get
|
||||
{
|
||||
return _BackColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == Color.Transparent)
|
||||
return;
|
||||
_BackColor = value;
|
||||
lblInput.BackColor = value;
|
||||
|
||||
if (this._BoxStyle == ComboBoxStyle.DropDownList)
|
||||
{
|
||||
txtInput.BackColor = value;
|
||||
base.FillColor = value;
|
||||
base.RectColor = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
txtInput.BackColor = Color.White;
|
||||
base.FillColor = Color.White;
|
||||
base.RectColor = Color.FromArgb(220, 220, 220);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The triangle color
|
||||
/// </summary>
|
||||
private Color triangleColor = Color.FromArgb(255, 77, 59);
|
||||
/// <summary>
|
||||
/// 三角颜色
|
||||
/// </summary>
|
||||
/// <value>The color of the triangle.</value>
|
||||
[Description("三角颜色"), Category("自定义")]
|
||||
public Color TriangleColor
|
||||
{
|
||||
get { return triangleColor; }
|
||||
set
|
||||
{
|
||||
triangleColor = value;
|
||||
Bitmap bit = new Bitmap(12, 10);
|
||||
Graphics g = Graphics.FromImage(bit);
|
||||
g.SetGDIHigh();
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLines(new Point[]
|
||||
{
|
||||
new Point(1,1),
|
||||
new Point(11,1),
|
||||
new Point(6,10),
|
||||
new Point(1,1)
|
||||
});
|
||||
g.FillPath(new SolidBrush(value), path);
|
||||
g.Dispose();
|
||||
panel1.BackgroundImage = bit;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCCombox" /> class.
|
||||
/// </summary>
|
||||
public UCCombox()
|
||||
{
|
||||
InitializeComponent();
|
||||
lblInput.BackColor = _BackColor;
|
||||
if (this._BoxStyle == ComboBoxStyle.DropDownList)
|
||||
{
|
||||
txtInput.BackColor = _BackColor;
|
||||
base.FillColor = _BackColor;
|
||||
base.RectColor = _BackColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
txtInput.BackColor = Color.White;
|
||||
base.FillColor = Color.White;
|
||||
base.RectColor = Color.FromArgb(220, 220, 220);
|
||||
}
|
||||
base.BackColor = Color.Transparent;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the UCComboBox control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void UCComboBox_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
this.txtInput.Location = new Point(this.txtInput.Location.X, (this.Height - txtInput.Height) / 2);
|
||||
this.lblInput.Location = new Point(this.lblInput.Location.X, (this.Height - lblInput.Height) / 2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the TextChanged event of the txtInput control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void txtInput_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
TextValue = txtInput.Text;
|
||||
if (TextChangedEvent != null)
|
||||
{
|
||||
TextChangedEvent(this, null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the click control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
protected virtual void click_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (_frmAnchor == null || _frmAnchor.IsDisposed || _frmAnchor.Visible == false)
|
||||
{
|
||||
|
||||
if (this.Source != null && this.Source.Count > 0)
|
||||
{
|
||||
int intRow = 0;
|
||||
int intCom = 1;
|
||||
var p = this.PointToScreen(this.Location);
|
||||
while (true)
|
||||
{
|
||||
int intScreenHeight = Screen.PrimaryScreen.Bounds.Height;
|
||||
if ((p.Y + this.Height + this.Source.Count / intCom * 50 < intScreenHeight || p.Y - this.Source.Count / intCom * 50 > 0)
|
||||
&& (_dropPanelHeight <= 0 ? true : (this.Source.Count / intCom * 50 <= _dropPanelHeight)))
|
||||
{
|
||||
intRow = this.Source.Count / intCom + (this.Source.Count % intCom != 0 ? 1 : 0);
|
||||
break;
|
||||
}
|
||||
intCom++;
|
||||
}
|
||||
UCTimePanel ucTime = new UCTimePanel();
|
||||
ucTime.IsShowBorder = true;
|
||||
int intWidth = this.Width / intCom;
|
||||
if (intWidth < _ItemWidth)
|
||||
intWidth = _ItemWidth;
|
||||
Size size = new Size(intCom * intWidth, intRow * 50);
|
||||
ucTime.Size = size;
|
||||
ucTime.FirstEvent = true;
|
||||
ucTime.SelectSourceEvent += ucTime_SelectSourceEvent;
|
||||
ucTime.Row = intRow;
|
||||
ucTime.Column = intCom;
|
||||
List<KeyValuePair<string, string>> lst = new List<KeyValuePair<string, string>>();
|
||||
foreach (var item in this.Source)
|
||||
{
|
||||
lst.Add(new KeyValuePair<string, string>(item.Key, item.Value));
|
||||
}
|
||||
ucTime.Source = lst;
|
||||
|
||||
ucTime.SetSelect(_selectedValue);
|
||||
|
||||
_frmAnchor = new Forms.FrmAnchor(this, ucTime);
|
||||
_frmAnchor.Load += (a, b) => { (a as Form).Size = size; };
|
||||
|
||||
_frmAnchor.Show(this.FindForm());
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_frmAnchor.Close();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The FRM anchor
|
||||
/// </summary>
|
||||
Forms.FrmAnchor _frmAnchor;
|
||||
/// <summary>
|
||||
/// Handles the SelectSourceEvent event of the ucTime 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 ucTime_SelectSourceEvent(object sender, EventArgs e)
|
||||
{
|
||||
if (_frmAnchor != null && !_frmAnchor.IsDisposed && _frmAnchor.Visible)
|
||||
{
|
||||
SelectedValue = sender.ToString();
|
||||
_frmAnchor.Close();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Load event of the UCComboBox control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void UCComboBox_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (this._BoxStyle == ComboBoxStyle.DropDownList)
|
||||
{
|
||||
txtInput.BackColor = _BackColor;
|
||||
base.FillColor = _BackColor;
|
||||
base.RectColor = _BackColor;
|
||||
}
|
||||
else
|
||||
{
|
||||
txtInput.BackColor = Color.White;
|
||||
base.FillColor = Color.White;
|
||||
base.RectColor = Color.FromArgb(220, 220, 220);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/ComboBox/UCCombox.resx
Normal file
120
UsingControl/HZHControls/Controls/ComboBox/UCCombox.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
73
UsingControl/HZHControls/Controls/ComboBox/UCComboxGrid.Designer.cs
generated
Normal file
73
UsingControl/HZHControls/Controls/ComboBox/UCComboxGrid.Designer.cs
generated
Normal file
@@ -0,0 +1,73 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-28-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCComboxGrid.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCComboxGrid.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCCombox" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCCombox" />
|
||||
partial class UCComboxGrid
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// txtInput
|
||||
//
|
||||
this.txtInput.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
|
||||
//
|
||||
// UCComboxGrid
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.Transparent;
|
||||
this.BoxStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
|
||||
this.Name = "UCComboxGrid";
|
||||
this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(240)))), ((int)(((byte)(240)))), ((int)(((byte)(240)))));
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
229
UsingControl/HZHControls/Controls/ComboBox/UCComboxGrid.cs
Normal file
229
UsingControl/HZHControls/Controls/ComboBox/UCComboxGrid.cs
Normal file
@@ -0,0 +1,229 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-28-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCComboxGrid.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using HZH_Controls.Controls;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCComboxGrid.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCCombox" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCCombox" />
|
||||
public partial class UCComboxGrid : UCCombox
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The m row type
|
||||
/// </summary>
|
||||
private Type m_rowType = typeof(UCDataGridViewRow);
|
||||
/// <summary>
|
||||
/// 表格行类型
|
||||
/// </summary>
|
||||
/// <value>The type of the grid row.</value>
|
||||
[Description("表格行类型"), Category("自定义")]
|
||||
public Type GridRowType
|
||||
{
|
||||
get { return m_rowType; }
|
||||
set
|
||||
{
|
||||
m_rowType = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The int width
|
||||
/// </summary>
|
||||
int intWidth = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The m columns
|
||||
/// </summary>
|
||||
private List<DataGridViewColumnEntity> m_columns = null;
|
||||
/// <summary>
|
||||
/// 表格列
|
||||
/// </summary>
|
||||
/// <value>The grid columns.</value>
|
||||
[Description("表格列"), Category("自定义")]
|
||||
public List<DataGridViewColumnEntity> GridColumns
|
||||
{
|
||||
get { return m_columns; }
|
||||
set
|
||||
{
|
||||
m_columns = value;
|
||||
if (value != null)
|
||||
intWidth = value.Sum(p => p.WidthType == SizeType.Absolute ? p.Width : (p.Width < 80 ? 80 : p.Width));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The m data source
|
||||
/// </summary>
|
||||
private List<object> m_dataSource = null;
|
||||
/// <summary>
|
||||
/// 表格数据源
|
||||
/// </summary>
|
||||
/// <value>The grid data source.</value>
|
||||
[Description("表格数据源"), Category("自定义")]
|
||||
public List<object> GridDataSource
|
||||
{
|
||||
get { return m_dataSource; }
|
||||
set { m_dataSource = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m text field
|
||||
/// </summary>
|
||||
private string m_textField;
|
||||
/// <summary>
|
||||
/// 显示值字段名称
|
||||
/// </summary>
|
||||
/// <value>The text field.</value>
|
||||
[Description("显示值字段名称"), Category("自定义")]
|
||||
public string TextField
|
||||
{
|
||||
get { return m_textField; }
|
||||
set
|
||||
{
|
||||
m_textField = value;
|
||||
SetText();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 控件样式
|
||||
/// </summary>
|
||||
/// <value>The box style.</value>
|
||||
[Obsolete("不再可用的属性")]
|
||||
[Browsable(false), EditorBrowsable(EditorBrowsableState.Never)]
|
||||
private new ComboBoxStyle BoxStyle
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// The select source
|
||||
/// </summary>
|
||||
private object selectSource = null;
|
||||
/// <summary>
|
||||
/// 选中的数据源
|
||||
/// </summary>
|
||||
/// <value>The select source.</value>
|
||||
[Description("选中的数据源"), Category("自定义")]
|
||||
public object SelectSource
|
||||
{
|
||||
get { return selectSource; }
|
||||
set
|
||||
{
|
||||
selectSource = value;
|
||||
SetText();
|
||||
if (SelectedChangedEvent != null)
|
||||
{
|
||||
SelectedChangedEvent(value, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 选中数据源改变事件
|
||||
/// </summary>
|
||||
[Description("选中数据源改变事件"), Category("自定义")]
|
||||
public new event EventHandler SelectedChangedEvent;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCComboxGrid" /> class.
|
||||
/// </summary>
|
||||
public UCComboxGrid()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
/// <summary>
|
||||
/// The m uc panel
|
||||
/// </summary>
|
||||
UCComboxGridPanel m_ucPanel = null;
|
||||
/// <summary>
|
||||
/// The FRM anchor
|
||||
/// </summary>
|
||||
Forms.FrmAnchor _frmAnchor;
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the click control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
protected override void click_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (m_columns == null || m_columns.Count <= 0)
|
||||
return;
|
||||
if (m_ucPanel == null)
|
||||
{
|
||||
var p = this.Parent.PointToScreen(this.Location);
|
||||
int intScreenHeight = Screen.PrimaryScreen.Bounds.Height;
|
||||
int intHeight = Math.Max(p.Y, intScreenHeight - p.Y - this.Height);
|
||||
intHeight -= 100;
|
||||
m_ucPanel = new UCComboxGridPanel();
|
||||
m_ucPanel.ItemClick += m_ucPanel_ItemClick;
|
||||
m_ucPanel.Height = intHeight;
|
||||
m_ucPanel.Width = intWidth;
|
||||
m_ucPanel.Columns = m_columns;
|
||||
m_ucPanel.RowType = m_rowType;
|
||||
if (m_dataSource != null && m_dataSource.Count > 0)
|
||||
{
|
||||
int _intHeight = Math.Min(110 + m_dataSource.Count * 36, m_ucPanel.Height);
|
||||
if (_intHeight <= 0)
|
||||
_intHeight = 100;
|
||||
m_ucPanel.Height = _intHeight;
|
||||
}
|
||||
}
|
||||
m_ucPanel.DataSource = m_dataSource;
|
||||
if (_frmAnchor == null || _frmAnchor.IsDisposed || _frmAnchor.Visible == false)
|
||||
{
|
||||
_frmAnchor = new Forms.FrmAnchor(this, m_ucPanel, isNotFocus: false);
|
||||
_frmAnchor.Show(this.FindForm());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the ItemClick event of the m_ucPanel control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="DataGridViewEventArgs" /> instance containing the event data.</param>
|
||||
void m_ucPanel_ItemClick(object sender, DataGridViewEventArgs e)
|
||||
{
|
||||
_frmAnchor.Hide();
|
||||
SelectSource = sender;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the text.
|
||||
/// </summary>
|
||||
private void SetText()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(m_textField) && selectSource != null)
|
||||
{
|
||||
var pro = selectSource.GetType().GetProperty(m_textField);
|
||||
if (pro != null)
|
||||
{
|
||||
TextValue = pro.GetValue(selectSource, null).ToStringExt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/ComboBox/UCComboxGrid.resx
Normal file
120
UsingControl/HZHControls/Controls/ComboBox/UCComboxGrid.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
290
UsingControl/HZHControls/Controls/ComboBox/UCComboxGridPanel.Designer.cs
generated
Normal file
290
UsingControl/HZHControls/Controls/ComboBox/UCComboxGridPanel.Designer.cs
generated
Normal file
@@ -0,0 +1,290 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-28-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCComboxGridPanel.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCComboxGridPanel.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
partial class UCComboxGridPanel
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.ucControlBase1 = new HZH_Controls.Controls.UCControlBase();
|
||||
this.ucDataGridView1 = new HZH_Controls.Controls.UCDataGridView();
|
||||
this.m_page = new HZH_Controls.Controls.UCPagerControl();
|
||||
this.panel2 = new System.Windows.Forms.Panel();
|
||||
this.txtSearch = new HZH_Controls.Controls.UCTextBoxEx();
|
||||
this.timer1 = new System.Windows.Forms.Timer(this.components);
|
||||
this.ucSplitLine_V2 = new HZH_Controls.Controls.UCSplitLine_V();
|
||||
this.ucSplitLine_V1 = new HZH_Controls.Controls.UCSplitLine_V();
|
||||
this.ucSplitLine_H2 = new HZH_Controls.Controls.UCSplitLine_H();
|
||||
this.ucSplitLine_H1 = new HZH_Controls.Controls.UCSplitLine_H();
|
||||
this.panel1.SuspendLayout();
|
||||
this.ucControlBase1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.ucControlBase1);
|
||||
this.panel1.Controls.Add(this.panel2);
|
||||
this.panel1.Controls.Add(this.txtSearch);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel1.Location = new System.Drawing.Point(1, 1);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.panel1.Size = new System.Drawing.Size(447, 333);
|
||||
this.panel1.TabIndex = 4;
|
||||
//
|
||||
// ucControlBase1
|
||||
//
|
||||
this.ucControlBase1.ConerRadius = 5;
|
||||
this.ucControlBase1.Controls.Add(this.ucDataGridView1);
|
||||
this.ucControlBase1.Controls.Add(this.m_page);
|
||||
this.ucControlBase1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.ucControlBase1.FillColor = System.Drawing.Color.Transparent;
|
||||
this.ucControlBase1.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.ucControlBase1.IsRadius = false;
|
||||
this.ucControlBase1.IsShowRect = true;
|
||||
this.ucControlBase1.Location = new System.Drawing.Point(5, 62);
|
||||
this.ucControlBase1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.ucControlBase1.Name = "ucControlBase1";
|
||||
this.ucControlBase1.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.ucControlBase1.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
|
||||
this.ucControlBase1.RectWidth = 1;
|
||||
this.ucControlBase1.Size = new System.Drawing.Size(437, 266);
|
||||
this.ucControlBase1.TabIndex = 2;
|
||||
this.ucControlBase1.TabStop = false;
|
||||
//
|
||||
// ucDataGridView1
|
||||
//
|
||||
this.ucDataGridView1.AutoScroll = true;
|
||||
this.ucDataGridView1.BackColor = System.Drawing.Color.White;
|
||||
this.ucDataGridView1.Columns = null;
|
||||
this.ucDataGridView1.DataSource = null;
|
||||
this.ucDataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.ucDataGridView1.HeadFont = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.ucDataGridView1.HeadHeight = 40;
|
||||
this.ucDataGridView1.HeadPadingLeft = 0;
|
||||
this.ucDataGridView1.HeadTextColor = System.Drawing.Color.Black;
|
||||
this.ucDataGridView1.IsShowCheckBox = false;
|
||||
this.ucDataGridView1.IsShowHead = true;
|
||||
this.ucDataGridView1.Location = new System.Drawing.Point(5, 5);
|
||||
this.ucDataGridView1.Name = "ucDataGridView1";
|
||||
this.ucDataGridView1.RowHeight = 30;
|
||||
this.ucDataGridView1.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
|
||||
this.ucDataGridView1.Size = new System.Drawing.Size(427, 223);
|
||||
this.ucDataGridView1.TabIndex = 0;
|
||||
this.ucDataGridView1.TabStop = false;
|
||||
//
|
||||
// m_page
|
||||
//
|
||||
this.m_page.DataSource = null;
|
||||
this.m_page.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.m_page.Location = new System.Drawing.Point(5, 228);
|
||||
this.m_page.Name = "m_page";
|
||||
this.m_page.PageCount = 0;
|
||||
this.m_page.PageIndex = 1;
|
||||
this.m_page.PageSize = 10;
|
||||
this.m_page.Size = new System.Drawing.Size(427, 33);
|
||||
this.m_page.StartIndex = 0;
|
||||
this.m_page.TabIndex = 1;
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
this.panel2.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel2.Location = new System.Drawing.Point(5, 47);
|
||||
this.panel2.Name = "panel2";
|
||||
this.panel2.Size = new System.Drawing.Size(437, 15);
|
||||
this.panel2.TabIndex = 1;
|
||||
//
|
||||
// txtSearch
|
||||
//
|
||||
this.txtSearch.BackColor = System.Drawing.Color.Transparent;
|
||||
this.txtSearch.ConerRadius = 5;
|
||||
this.txtSearch.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||
this.txtSearch.DecLength = 2;
|
||||
this.txtSearch.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.txtSearch.FillColor = System.Drawing.Color.Empty;
|
||||
this.txtSearch.FocusBorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.txtSearch.Font = new System.Drawing.Font("微软雅黑", 18F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtSearch.InputText = "";
|
||||
this.txtSearch.InputType = HZH_Controls.TextInputType.NotControl;
|
||||
this.txtSearch.IsFocusColor = true;
|
||||
this.txtSearch.IsRadius = true;
|
||||
this.txtSearch.IsShowClearBtn = true;
|
||||
this.txtSearch.IsShowKeyboard = false;
|
||||
this.txtSearch.IsShowRect = true;
|
||||
this.txtSearch.IsShowSearchBtn = false;
|
||||
this.txtSearch.KeyBoardType = HZH_Controls.Controls.KeyBoardType.UCKeyBorderAll_EN;
|
||||
this.txtSearch.Location = new System.Drawing.Point(5, 5);
|
||||
this.txtSearch.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||
this.txtSearch.MaxValue = new decimal(new int[] {
|
||||
1000000,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtSearch.MinValue = new decimal(new int[] {
|
||||
1000000,
|
||||
0,
|
||||
0,
|
||||
-2147483648});
|
||||
this.txtSearch.Name = "txtSearch";
|
||||
this.txtSearch.Padding = new System.Windows.Forms.Padding(5);
|
||||
this.txtSearch.PromptColor = System.Drawing.Color.Gray;
|
||||
this.txtSearch.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtSearch.PromptText = "输入内容模糊搜索";
|
||||
this.txtSearch.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(220)))), ((int)(((byte)(220)))));
|
||||
this.txtSearch.RectWidth = 1;
|
||||
this.txtSearch.RegexPattern = "";
|
||||
this.txtSearch.Size = new System.Drawing.Size(437, 42);
|
||||
this.txtSearch.TabIndex = 0;
|
||||
//
|
||||
// timer1
|
||||
//
|
||||
this.timer1.Interval = 1000;
|
||||
this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
|
||||
//
|
||||
// ucSplitLine_V2
|
||||
//
|
||||
this.ucSplitLine_V2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
|
||||
this.ucSplitLine_V2.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.ucSplitLine_V2.Location = new System.Drawing.Point(448, 1);
|
||||
this.ucSplitLine_V2.Name = "ucSplitLine_V2";
|
||||
this.ucSplitLine_V2.Size = new System.Drawing.Size(1, 333);
|
||||
this.ucSplitLine_V2.TabIndex = 3;
|
||||
this.ucSplitLine_V2.TabStop = false;
|
||||
//
|
||||
// ucSplitLine_V1
|
||||
//
|
||||
this.ucSplitLine_V1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
|
||||
this.ucSplitLine_V1.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.ucSplitLine_V1.Location = new System.Drawing.Point(0, 1);
|
||||
this.ucSplitLine_V1.Name = "ucSplitLine_V1";
|
||||
this.ucSplitLine_V1.Size = new System.Drawing.Size(1, 333);
|
||||
this.ucSplitLine_V1.TabIndex = 2;
|
||||
this.ucSplitLine_V1.TabStop = false;
|
||||
//
|
||||
// ucSplitLine_H2
|
||||
//
|
||||
this.ucSplitLine_H2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
|
||||
this.ucSplitLine_H2.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.ucSplitLine_H2.Location = new System.Drawing.Point(0, 334);
|
||||
this.ucSplitLine_H2.Name = "ucSplitLine_H2";
|
||||
this.ucSplitLine_H2.Size = new System.Drawing.Size(449, 1);
|
||||
this.ucSplitLine_H2.TabIndex = 1;
|
||||
this.ucSplitLine_H2.TabStop = false;
|
||||
//
|
||||
// ucSplitLine_H1
|
||||
//
|
||||
this.ucSplitLine_H1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
|
||||
this.ucSplitLine_H1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.ucSplitLine_H1.Location = new System.Drawing.Point(0, 0);
|
||||
this.ucSplitLine_H1.Name = "ucSplitLine_H1";
|
||||
this.ucSplitLine_H1.Size = new System.Drawing.Size(449, 1);
|
||||
this.ucSplitLine_H1.TabIndex = 0;
|
||||
this.ucSplitLine_H1.TabStop = false;
|
||||
//
|
||||
// UCComboxGridPanel
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Controls.Add(this.ucSplitLine_V2);
|
||||
this.Controls.Add(this.ucSplitLine_V1);
|
||||
this.Controls.Add(this.ucSplitLine_H2);
|
||||
this.Controls.Add(this.ucSplitLine_H1);
|
||||
this.Name = "UCComboxGridPanel";
|
||||
this.Size = new System.Drawing.Size(449, 335);
|
||||
this.Load += new System.EventHandler(this.UCComboxGridPanel_Load);
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.ucControlBase1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The uc split line h1
|
||||
/// </summary>
|
||||
private UCSplitLine_H ucSplitLine_H1;
|
||||
/// <summary>
|
||||
/// The uc split line h2
|
||||
/// </summary>
|
||||
private UCSplitLine_H ucSplitLine_H2;
|
||||
/// <summary>
|
||||
/// The uc split line v1
|
||||
/// </summary>
|
||||
private UCSplitLine_V ucSplitLine_V1;
|
||||
/// <summary>
|
||||
/// The uc split line v2
|
||||
/// </summary>
|
||||
private UCSplitLine_V ucSplitLine_V2;
|
||||
/// <summary>
|
||||
/// The panel1
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
/// <summary>
|
||||
/// The uc control base1
|
||||
/// </summary>
|
||||
private UCControlBase ucControlBase1;
|
||||
/// <summary>
|
||||
/// The uc data grid view1
|
||||
/// </summary>
|
||||
private UCDataGridView ucDataGridView1;
|
||||
/// <summary>
|
||||
/// The panel2
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panel2;
|
||||
/// <summary>
|
||||
/// The timer1
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Timer timer1;
|
||||
/// <summary>
|
||||
/// The text search
|
||||
/// </summary>
|
||||
private UCTextBoxEx txtSearch;
|
||||
private UCPagerControl m_page;
|
||||
}
|
||||
}
|
||||
188
UsingControl/HZHControls/Controls/ComboBox/UCComboxGridPanel.cs
Normal file
188
UsingControl/HZHControls/Controls/ComboBox/UCComboxGridPanel.cs
Normal file
@@ -0,0 +1,188 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-28-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCComboxGridPanel.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCComboxGridPanel.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
[ToolboxItem(false)]
|
||||
public partial class UCComboxGridPanel : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// 项点击事件
|
||||
/// </summary>
|
||||
[Description("项点击事件"), Category("自定义")]
|
||||
public event DataGridViewEventHandler ItemClick;
|
||||
/// <summary>
|
||||
/// The m row type
|
||||
/// </summary>
|
||||
private Type m_rowType = typeof(UCDataGridViewRow);
|
||||
/// <summary>
|
||||
/// 行类型
|
||||
/// </summary>
|
||||
/// <value>The type of the row.</value>
|
||||
[Description("行类型"), Category("自定义")]
|
||||
public Type RowType
|
||||
{
|
||||
get { return m_rowType; }
|
||||
set
|
||||
{
|
||||
m_rowType = value;
|
||||
this.ucDataGridView1.RowType = m_rowType;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m columns
|
||||
/// </summary>
|
||||
private List<DataGridViewColumnEntity> m_columns = null;
|
||||
/// <summary>
|
||||
/// 列
|
||||
/// </summary>
|
||||
/// <value>The columns.</value>
|
||||
[Description("列"), Category("自定义")]
|
||||
public List<DataGridViewColumnEntity> Columns
|
||||
{
|
||||
get { return m_columns; }
|
||||
set
|
||||
{
|
||||
m_columns = value;
|
||||
this.ucDataGridView1.Columns = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The m data source
|
||||
/// </summary>
|
||||
private List<object> m_dataSource = null;
|
||||
/// <summary>
|
||||
/// 数据源
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
[Description("数据源"), Category("自定义")]
|
||||
public List<object> DataSource
|
||||
{
|
||||
get { return m_dataSource; }
|
||||
set { m_dataSource = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The string last search text
|
||||
/// </summary>
|
||||
private string strLastSearchText = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCComboxGridPanel" /> class.
|
||||
/// </summary>
|
||||
public UCComboxGridPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.txtSearch.txtInput.TextChanged += txtInput_TextChanged;
|
||||
this.ucDataGridView1.ItemClick += ucDataGridView1_ItemClick;
|
||||
m_page.ShowSourceChanged += m_page_ShowSourceChanged;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles the ItemClick event of the ucDataGridView1 control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="DataGridViewEventArgs" /> instance containing the event data.</param>
|
||||
void ucDataGridView1_ItemClick(object sender, DataGridViewEventArgs e)
|
||||
{
|
||||
if (ItemClick != null)
|
||||
{
|
||||
ItemClick((sender as IDataGridViewRow).DataSource, null);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the TextChanged event of the txtInput 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 txtInput_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
timer1.Enabled = false;
|
||||
timer1.Enabled = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Load event of the UCComboxGridPanel control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void UCComboxGridPanel_Load(object sender, EventArgs e)
|
||||
{
|
||||
m_page.DataSource = m_dataSource;
|
||||
this.ucDataGridView1.DataSource = m_page.GetCurrentSource();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Tick event of the timer1 control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void timer1_Tick(object sender, EventArgs e)
|
||||
{
|
||||
if (strLastSearchText == txtSearch.InputText)
|
||||
{
|
||||
timer1.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
strLastSearchText = txtSearch.InputText;
|
||||
Search(txtSearch.InputText);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Searches the specified string text.
|
||||
/// </summary>
|
||||
/// <param name="strText">The string text.</param>
|
||||
private void Search(string strText)
|
||||
{
|
||||
m_page.StartIndex = 0;
|
||||
if (!string.IsNullOrEmpty(strText))
|
||||
{
|
||||
strText = strText.ToLower().Trim();
|
||||
List<object> lst = m_dataSource.FindAll(p => m_columns.Any(c => (c.Format == null ? (p.GetType().GetProperty(c.DataField).GetValue(p, null).ToStringExt()) : c.Format(p.GetType().GetProperty(c.DataField).GetValue(p, null))).ToLower().Contains(strText)));
|
||||
m_page.DataSource = lst;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_page.DataSource = m_dataSource;
|
||||
}
|
||||
m_page.Reload();
|
||||
}
|
||||
|
||||
void m_page_ShowSourceChanged(object currentSource)
|
||||
{
|
||||
this.ucDataGridView1.DataSource = currentSource;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>17, 17</value>
|
||||
</metadata>
|
||||
</root>
|
||||
@@ -0,0 +1,45 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-09-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="DataGridViewCellEntity.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;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class DataGridViewCellEntity.
|
||||
/// </summary>
|
||||
public class DataGridViewCellEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the title.
|
||||
/// </summary>
|
||||
/// <value>The title.</value>
|
||||
public string Title { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the width.
|
||||
/// </summary>
|
||||
/// <value>The width.</value>
|
||||
public int Width { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the width.
|
||||
/// </summary>
|
||||
/// <value>The type of the width.</value>
|
||||
public System.Windows.Forms.SizeType WidthType { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-09-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="DataGridViewCellEventArgs.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;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class DataGridViewEventArgs.
|
||||
/// Implements the <see cref="System.EventArgs" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.EventArgs" />
|
||||
public class DataGridViewEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the cell control.
|
||||
/// </summary>
|
||||
/// <value>The cell control.</value>
|
||||
public Control CellControl { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the index of the cell.
|
||||
/// </summary>
|
||||
/// <value>The index of the cell.</value>
|
||||
public int CellIndex { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the index of the row.
|
||||
/// </summary>
|
||||
/// <value>The index of the row.</value>
|
||||
public int RowIndex { get; set; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-09-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="DataGridViewCellEventHandler.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.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Delegate DataGridViewEventHandler
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The <see cref="DataGridViewEventArgs" /> instance containing the event data.</param>
|
||||
[Serializable]
|
||||
[ComVisible(true)]
|
||||
public delegate void DataGridViewEventHandler(object sender, DataGridViewEventArgs e);
|
||||
|
||||
/// <summary>
|
||||
/// Delegate DataGridViewRowCustomEventHandler
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The <see cref="DataGridViewRowCustomEventArgs" /> instance containing the event data.</param>
|
||||
[Serializable]
|
||||
[ComVisible(true)]
|
||||
public delegate void DataGridViewRowCustomEventHandler(object sender, DataGridViewRowCustomEventArgs e);
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-09-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="DataGridViewColumnEntity.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.Drawing;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class DataGridViewColumnEntity.
|
||||
/// </summary>
|
||||
public class DataGridViewColumnEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the head text.
|
||||
/// </summary>
|
||||
/// <value>The head text.</value>
|
||||
public string HeadText { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the width.
|
||||
/// </summary>
|
||||
/// <value>The width.</value>
|
||||
public int Width { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the width.
|
||||
/// </summary>
|
||||
/// <value>The type of the width.</value>
|
||||
public System.Windows.Forms.SizeType WidthType { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the data field.
|
||||
/// </summary>
|
||||
/// <value>The data field.</value>
|
||||
public string DataField { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the format.
|
||||
/// </summary>
|
||||
/// <value>The format.</value>
|
||||
public Func<object, string> Format { get; set; }
|
||||
/// <summary>
|
||||
/// The text align
|
||||
/// </summary>
|
||||
private ContentAlignment _TextAlign = ContentAlignment.MiddleCenter;
|
||||
/// <summary>
|
||||
/// Gets or sets the text align.
|
||||
/// </summary>
|
||||
/// <value>The text align.</value>
|
||||
public ContentAlignment TextAlign { get { return _TextAlign; } set { _TextAlign = value; } }
|
||||
/// <summary>
|
||||
/// 自定义的单元格控件,一个实现IDataGridViewCustomCell的Control
|
||||
/// </summary>
|
||||
/// <value>The custom cell.</value>
|
||||
private Type customCellType = null;
|
||||
public Type CustomCellType
|
||||
{
|
||||
get
|
||||
{
|
||||
return customCellType;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (!typeof(IDataGridViewCustomCell).IsAssignableFrom(value) || !value.IsSubclassOf(typeof(System.Windows.Forms.Control)))
|
||||
throw new Exception("行控件没有实现IDataGridViewCustomCell接口");
|
||||
customCellType = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-27-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="DataGridViewRowCustomEventArgs.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;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class DataGridViewRowCustomEventArgs.
|
||||
/// Implements the <see cref="System.EventArgs" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.EventArgs" />
|
||||
public class DataGridViewRowCustomEventArgs : EventArgs
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the name of the event.
|
||||
/// </summary>
|
||||
/// <value>The name of the event.</value>
|
||||
public string EventName { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
public interface IDataGridViewCustomCell
|
||||
{
|
||||
/// <summary>
|
||||
/// 绑定行关联的数据
|
||||
/// </summary>
|
||||
/// <param name="obj">The object.</param>
|
||||
void SetBindSource(object obj);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-09-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="IDataGridViewRow.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;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Interface IDataGridViewRow
|
||||
/// </summary>
|
||||
public interface IDataGridViewRow
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when [row custom event].
|
||||
/// </summary>
|
||||
event DataGridViewRowCustomEventHandler RowCustomEvent;
|
||||
/// <summary>
|
||||
/// CheckBox选中事件
|
||||
/// </summary>
|
||||
event DataGridViewEventHandler CheckBoxChangeEvent;
|
||||
/// <summary>
|
||||
/// 点击单元格事件
|
||||
/// </summary>
|
||||
event DataGridViewEventHandler CellClick;
|
||||
/// <summary>
|
||||
/// 数据源改变事件
|
||||
/// </summary>
|
||||
event DataGridViewEventHandler SourceChanged;
|
||||
/// <summary>
|
||||
/// 列参数,用于创建列数和宽度
|
||||
/// </summary>
|
||||
/// <value>The columns.</value>
|
||||
List<DataGridViewColumnEntity> Columns { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is show CheckBox.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is show CheckBox; otherwise, <c>false</c>.</value>
|
||||
bool IsShowCheckBox { get; set; }
|
||||
/// <summary>
|
||||
/// 是否选中
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is checked; otherwise, <c>false</c>.</value>
|
||||
bool IsChecked { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 数据源
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
object DataSource { get; set; }
|
||||
/// <summary>
|
||||
/// 添加单元格元素,仅做添加控件操作,不做数据绑定,数据绑定使用BindingCells
|
||||
/// </summary>
|
||||
void ReloadCells();
|
||||
/// <summary>
|
||||
/// 绑定数据到Cell
|
||||
/// </summary>
|
||||
/// <returns>返回true则表示已处理过,否则将进行默认绑定(通常只针对有Text值的控件)</returns>
|
||||
void BindingCellData();
|
||||
/// <summary>
|
||||
/// 设置选中状态,通常为设置颜色即可
|
||||
/// </summary>
|
||||
/// <param name="blnSelected">是否选中</param>
|
||||
void SetSelect(bool blnSelected);
|
||||
/// <summary>
|
||||
/// 行高
|
||||
/// </summary>
|
||||
/// <value>The height of the row.</value>
|
||||
int RowHeight { get; set; }
|
||||
/// <summary>
|
||||
/// 行号
|
||||
/// </summary>
|
||||
/// <value>The Index of the row.</value>
|
||||
int RowIndex { get; set; }
|
||||
}
|
||||
}
|
||||
148
UsingControl/HZHControls/Controls/DataGridView/UCDataGridView.Designer.cs
generated
Normal file
148
UsingControl/HZHControls/Controls/DataGridView/UCDataGridView.Designer.cs
generated
Normal file
@@ -0,0 +1,148 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-09-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCDataGridView.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCDataGridView.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
partial class UCDataGridView
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panHead = new System.Windows.Forms.Panel();
|
||||
this.panColumns = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.panHeadLeft = new System.Windows.Forms.Panel();
|
||||
this.ucSplitLine_H1 = new HZH_Controls.Controls.UCSplitLine_H();
|
||||
this.panRow = new System.Windows.Forms.Panel();
|
||||
this.panHead.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panHead
|
||||
//
|
||||
this.panHead.Controls.Add(this.panColumns);
|
||||
this.panHead.Controls.Add(this.panHeadLeft);
|
||||
this.panHead.Controls.Add(this.ucSplitLine_H1);
|
||||
this.panHead.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panHead.Location = new System.Drawing.Point(0, 0);
|
||||
this.panHead.Name = "panHead";
|
||||
this.panHead.Size = new System.Drawing.Size(1061, 40);
|
||||
this.panHead.TabIndex = 0;
|
||||
//
|
||||
// panColumns
|
||||
//
|
||||
this.panColumns.ColumnCount = 1;
|
||||
this.panColumns.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.panColumns.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panColumns.Location = new System.Drawing.Point(0, 0);
|
||||
this.panColumns.Name = "panColumns";
|
||||
this.panColumns.RowCount = 1;
|
||||
this.panColumns.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.panColumns.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.panColumns.Size = new System.Drawing.Size(1061, 39);
|
||||
this.panColumns.TabIndex = 1;
|
||||
//
|
||||
// panHeadLeft
|
||||
//
|
||||
this.panHeadLeft.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.panHeadLeft.Location = new System.Drawing.Point(0, 0);
|
||||
this.panHeadLeft.Name = "panHeadLeft";
|
||||
this.panHeadLeft.Size = new System.Drawing.Size(0, 39);
|
||||
this.panHeadLeft.TabIndex = 2;
|
||||
//
|
||||
// ucSplitLine_H1
|
||||
//
|
||||
this.ucSplitLine_H1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
|
||||
this.ucSplitLine_H1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.ucSplitLine_H1.Location = new System.Drawing.Point(0, 39);
|
||||
this.ucSplitLine_H1.Name = "ucSplitLine_H1";
|
||||
this.ucSplitLine_H1.Size = new System.Drawing.Size(1061, 1);
|
||||
this.ucSplitLine_H1.TabIndex = 0;
|
||||
this.ucSplitLine_H1.TabStop = false;
|
||||
//
|
||||
// panRow
|
||||
//
|
||||
this.panRow.AutoScroll = true;
|
||||
this.panRow.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panRow.Location = new System.Drawing.Point(0, 40);
|
||||
this.panRow.Name = "panRow";
|
||||
this.panRow.Size = new System.Drawing.Size(1061, 525);
|
||||
this.panRow.TabIndex = 1;
|
||||
//
|
||||
// UCDataGridView
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.AutoScroll = true;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.Controls.Add(this.panRow);
|
||||
this.Controls.Add(this.panHead);
|
||||
this.Name = "UCDataGridView";
|
||||
this.Size = new System.Drawing.Size(1061, 565);
|
||||
this.panHead.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The pan head
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panHead;
|
||||
/// <summary>
|
||||
/// The pan columns
|
||||
/// </summary>
|
||||
private System.Windows.Forms.TableLayoutPanel panColumns;
|
||||
/// <summary>
|
||||
/// The uc split line h1
|
||||
/// </summary>
|
||||
private UCSplitLine_H ucSplitLine_H1;
|
||||
/// <summary>
|
||||
/// The pan row
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panRow;
|
||||
/// <summary>
|
||||
/// The pan head left
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panHeadLeft;
|
||||
|
||||
}
|
||||
}
|
||||
714
UsingControl/HZHControls/Controls/DataGridView/UCDataGridView.cs
Normal file
714
UsingControl/HZHControls/Controls/DataGridView/UCDataGridView.cs
Normal file
@@ -0,0 +1,714 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-09-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCDataGridView.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCDataGridView.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public partial class UCDataGridView : UserControl
|
||||
{
|
||||
#region 属性
|
||||
/// <summary>
|
||||
/// The m head pading left
|
||||
/// </summary>
|
||||
private int m_headPadingLeft = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the head pading left.
|
||||
/// </summary>
|
||||
/// <value>The head pading left.</value>
|
||||
[Description("标题左侧间距"), Category("自定义")]
|
||||
public int HeadPadingLeft
|
||||
{
|
||||
get { return m_headPadingLeft; }
|
||||
set
|
||||
{
|
||||
m_headPadingLeft = value;
|
||||
this.panHeadLeft.Width = m_headPadingLeft;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m head font
|
||||
/// </summary>
|
||||
private Font m_headFont = new Font("微软雅黑", 12F);
|
||||
/// <summary>
|
||||
/// 标题字体
|
||||
/// </summary>
|
||||
/// <value>The head font.</value>
|
||||
[Description("标题字体"), Category("自定义")]
|
||||
public Font HeadFont
|
||||
{
|
||||
get { return m_headFont; }
|
||||
set { m_headFont = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The m head text color
|
||||
/// </summary>
|
||||
private Color m_headTextColor = Color.Black;
|
||||
/// <summary>
|
||||
/// 标题字体颜色
|
||||
/// </summary>
|
||||
/// <value>The color of the head text.</value>
|
||||
[Description("标题文字颜色"), Category("自定义")]
|
||||
public Color HeadTextColor
|
||||
{
|
||||
get { return m_headTextColor; }
|
||||
set { m_headTextColor = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m is show head
|
||||
/// </summary>
|
||||
private bool m_isShowHead = true;
|
||||
/// <summary>
|
||||
/// 是否显示标题
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is show head; otherwise, <c>false</c>.</value>
|
||||
[Description("是否显示标题"), Category("自定义")]
|
||||
public bool IsShowHead
|
||||
{
|
||||
get { return m_isShowHead; }
|
||||
set
|
||||
{
|
||||
m_isShowHead = value;
|
||||
panHead.Visible = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The m head height
|
||||
/// </summary>
|
||||
private int m_headHeight = 40;
|
||||
/// <summary>
|
||||
/// 标题高度
|
||||
/// </summary>
|
||||
/// <value>The height of the head.</value>
|
||||
[Description("标题高度"), Category("自定义")]
|
||||
public int HeadHeight
|
||||
{
|
||||
get { return m_headHeight; }
|
||||
set
|
||||
{
|
||||
m_headHeight = value;
|
||||
panHead.Height = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m is show CheckBox
|
||||
/// </summary>
|
||||
private bool m_isShowCheckBox = false;
|
||||
/// <summary>
|
||||
/// 是否显示复选框
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is show CheckBox; otherwise, <c>false</c>.</value>
|
||||
[Description("是否显示选择框"), Category("自定义")]
|
||||
public bool IsShowCheckBox
|
||||
{
|
||||
get { return m_isShowCheckBox; }
|
||||
set
|
||||
{
|
||||
if (value != m_isShowCheckBox)
|
||||
{
|
||||
m_isShowCheckBox = value;
|
||||
LoadColumns();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m row height
|
||||
/// </summary>
|
||||
private int m_rowHeight = 40;
|
||||
/// <summary>
|
||||
/// 行高
|
||||
/// </summary>
|
||||
/// <value>The height of the row.</value>
|
||||
[Description("数据行高"), Category("自定义")]
|
||||
public int RowHeight
|
||||
{
|
||||
get { return m_rowHeight; }
|
||||
set { m_rowHeight = value; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the show count.
|
||||
/// </summary>
|
||||
/// <value>The show count.</value>
|
||||
[Description("当前高度可显示行个数"), Category("自定义")]
|
||||
public int ShowCount
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.panRow.Height / (m_rowHeight);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m columns
|
||||
/// </summary>
|
||||
private List<DataGridViewColumnEntity> m_columns = null;
|
||||
/// <summary>
|
||||
/// 列
|
||||
/// </summary>
|
||||
/// <value>The columns.</value>
|
||||
[Description("列"), Category("自定义")]
|
||||
public List<DataGridViewColumnEntity> Columns
|
||||
{
|
||||
get { return m_columns; }
|
||||
set
|
||||
{
|
||||
m_columns = value;
|
||||
LoadColumns();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m data source
|
||||
/// </summary>
|
||||
private object m_dataSource = null;
|
||||
/// <summary>
|
||||
/// 数据源,支持列表或table,如果使用翻页控件,请使用翻页控件的DataSource
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
/// <exception cref="Exception">数据源不是有效的数据类型,请使用Datatable或列表</exception>
|
||||
/// <exception cref="System.Exception">数据源不是有效的数据类型,请使用Datatable或列表</exception>
|
||||
[Description("数据源,支持列表或table,如果使用翻页控件,请使用翻页控件的DataSource"), Category("自定义")]
|
||||
public object DataSource
|
||||
{
|
||||
get { return m_dataSource; }
|
||||
set
|
||||
{
|
||||
if (value != null)
|
||||
{
|
||||
if (!(value is DataTable) && (!typeof(IList).IsAssignableFrom(value.GetType())))
|
||||
{
|
||||
throw new Exception("数据源不是有效的数据类型,请使用Datatable或列表");
|
||||
}
|
||||
}
|
||||
m_dataSource = value;
|
||||
if (m_columns != null && m_columns.Count > 0)
|
||||
{
|
||||
ReloadSource();
|
||||
}
|
||||
if (BindingSourceEvent != null)
|
||||
{
|
||||
BindingSourceEvent(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the rows.
|
||||
/// </summary>
|
||||
/// <value>The rows.</value>
|
||||
public List<IDataGridViewRow> Rows { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The m row type
|
||||
/// </summary>
|
||||
private Type m_rowType = typeof(UCDataGridViewRow);
|
||||
/// <summary>
|
||||
/// 行元素类型,默认UCDataGridViewItem
|
||||
/// </summary>
|
||||
/// <value>The type of the row.</value>
|
||||
/// <exception cref="Exception">行控件没有实现IDataGridViewRow接口</exception>
|
||||
/// <exception cref="System.Exception">行控件没有实现IDataGridViewRow接口</exception>
|
||||
[Description("行控件类型,默认UCDataGridViewRow,如果不满足请自定义行控件实现接口IDataGridViewRow"), Category("自定义")]
|
||||
public Type RowType
|
||||
{
|
||||
get { return m_rowType; }
|
||||
set
|
||||
{
|
||||
if (value == null)
|
||||
return;
|
||||
if (!typeof(IDataGridViewRow).IsAssignableFrom(value) || !value.IsSubclassOf(typeof(Control)))
|
||||
throw new Exception("行控件没有实现IDataGridViewRow接口");
|
||||
m_rowType = value;
|
||||
if (m_columns != null && m_columns.Count > 0)
|
||||
ReloadSource();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m select row
|
||||
/// </summary>
|
||||
IDataGridViewRow m_selectRow = null;
|
||||
/// <summary>
|
||||
/// 选中的节点
|
||||
/// </summary>
|
||||
/// <value>The select row.</value>
|
||||
[Description("选中行"), Category("自定义")]
|
||||
public IDataGridViewRow SelectRow
|
||||
{
|
||||
get { return m_selectRow; }
|
||||
private set { m_selectRow = value; }
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 选中的行,如果显示CheckBox,则以CheckBox选中为准
|
||||
/// </summary>
|
||||
/// <value>The select rows.</value>
|
||||
[Description("选中的行,如果显示CheckBox,则以CheckBox选中为准"), Category("自定义")]
|
||||
public List<IDataGridViewRow> SelectRows
|
||||
{
|
||||
get
|
||||
{
|
||||
return GetSelectRows();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the select rows.
|
||||
/// </summary>
|
||||
/// <returns>List<IDataGridViewRow>.</returns>
|
||||
private List<IDataGridViewRow> GetSelectRows()
|
||||
{
|
||||
List<IDataGridViewRow> lst = new List<IDataGridViewRow>();
|
||||
if (m_isShowCheckBox)
|
||||
{
|
||||
if (Rows != null && Rows.Count > 0)
|
||||
lst.AddRange(Rows.FindAll(p => p.IsChecked));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m_selectRow != null)
|
||||
lst.AddRange(new List<IDataGridViewRow>() { m_selectRow });
|
||||
}
|
||||
if (Rows != null && Rows.Count > 0)
|
||||
{
|
||||
foreach (var row in Rows)
|
||||
{
|
||||
Control c = row as Control;
|
||||
UCDataGridView grid = FindChildGrid(c);
|
||||
if (grid != null)
|
||||
lst.AddRange(grid.SelectRows);
|
||||
}
|
||||
}
|
||||
return lst;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Finds the child grid.
|
||||
/// </summary>
|
||||
/// <param name="c">The c.</param>
|
||||
/// <returns>UCDataGridView.</returns>
|
||||
private UCDataGridView FindChildGrid(Control c)
|
||||
{
|
||||
foreach (Control item in c.Controls)
|
||||
{
|
||||
if (item is UCDataGridView)
|
||||
return item as UCDataGridView;
|
||||
else if (item.Controls.Count > 0)
|
||||
{
|
||||
var grid = FindChildGrid(item);
|
||||
if (grid != null)
|
||||
return grid;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
#region 事件
|
||||
/// <summary>
|
||||
/// The head CheckBox change event
|
||||
/// </summary>
|
||||
[Description("选中标题选择框事件"), Category("自定义")]
|
||||
public EventHandler HeadCheckBoxChangeEvent;
|
||||
/// <summary>
|
||||
/// The head column click event
|
||||
/// </summary>
|
||||
[Description("标题点击事件"), Category("自定义")]
|
||||
public EventHandler HeadColumnClickEvent;
|
||||
/// <summary>
|
||||
/// Occurs when [item click].
|
||||
/// </summary>
|
||||
[Description("项点击事件"), Category("自定义")]
|
||||
public event DataGridViewEventHandler ItemClick;
|
||||
/// <summary>
|
||||
/// Occurs when [source changed].
|
||||
/// </summary>
|
||||
[Description("行数据源改变事件"), Category("自定义")]
|
||||
public event DataGridViewEventHandler RowSourceChangedEvent;
|
||||
/// <summary>
|
||||
/// Occurs when [row custom event].
|
||||
/// </summary>
|
||||
[Description("预留的自定义的事件,比如你需要在行上放置删改等按钮时,可以通过此事件传递出来"), Category("自定义")]
|
||||
public event DataGridViewRowCustomEventHandler RowCustomEvent;
|
||||
[Description("绑定数据源后事件"), Category("自定义")]
|
||||
public event EventHandler BindingSourceEvent;
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCDataGridView" /> class.
|
||||
/// </summary>
|
||||
public UCDataGridView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region 私有方法
|
||||
#region 加载column
|
||||
/// <summary>
|
||||
/// 功能描述:加载column
|
||||
/// 作 者:HZH
|
||||
/// 创建日期:2019-08-08 17:51:50
|
||||
/// 任务编号:POS
|
||||
/// </summary>
|
||||
private void LoadColumns()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (DesignMode)
|
||||
{ return; }
|
||||
|
||||
ControlHelper.FreezeControl(this.panHead, true);
|
||||
this.panRow.Controls.Clear();
|
||||
this.panColumns.Controls.Clear();
|
||||
this.panColumns.ColumnStyles.Clear();
|
||||
|
||||
if (m_columns != null && m_columns.Count() > 0)
|
||||
{
|
||||
int intColumnsCount = m_columns.Count();
|
||||
if (m_isShowCheckBox)
|
||||
{
|
||||
intColumnsCount++;
|
||||
}
|
||||
this.panColumns.ColumnCount = intColumnsCount;
|
||||
for (int i = 0; i < intColumnsCount; i++)
|
||||
{
|
||||
Control c = null;
|
||||
if (i == 0 && m_isShowCheckBox)
|
||||
{
|
||||
this.panColumns.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(SizeType.Absolute, 30F));
|
||||
|
||||
UCCheckBox box = new UCCheckBox();
|
||||
box.TextValue = "";
|
||||
box.Size = new Size(30, 30);
|
||||
box.CheckedChangeEvent += (a, b) =>
|
||||
{
|
||||
Rows.ForEach(p => p.IsChecked = box.Checked);
|
||||
if (HeadCheckBoxChangeEvent != null)
|
||||
{
|
||||
HeadCheckBoxChangeEvent(a, b);
|
||||
}
|
||||
};
|
||||
c = box;
|
||||
}
|
||||
else
|
||||
{
|
||||
var item = m_columns[i - (m_isShowCheckBox ? 1 : 0)];
|
||||
this.panColumns.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(item.WidthType, item.Width));
|
||||
Label lbl = new Label();
|
||||
lbl.Name = "dgvColumns_" + i;
|
||||
lbl.Text = item.HeadText;
|
||||
lbl.Font = m_headFont;
|
||||
lbl.ForeColor = m_headTextColor;
|
||||
lbl.TextAlign = ContentAlignment.MiddleCenter;
|
||||
lbl.AutoSize = false;
|
||||
lbl.Dock = DockStyle.Fill;
|
||||
lbl.MouseDown += (a, b) =>
|
||||
{
|
||||
if (HeadColumnClickEvent != null)
|
||||
{
|
||||
HeadColumnClickEvent(a, b);
|
||||
}
|
||||
};
|
||||
c = lbl;
|
||||
}
|
||||
this.panColumns.Controls.Add(c, i, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(this.panHead, false);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region 公共函数
|
||||
/// <summary>
|
||||
/// 刷新数据
|
||||
/// </summary>
|
||||
public void ReloadSource()
|
||||
{
|
||||
if (DesignMode)
|
||||
{ return; }
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(this, true);
|
||||
Rows = new List<IDataGridViewRow>();
|
||||
if (m_columns == null || m_columns.Count <= 0)
|
||||
return;
|
||||
if (m_dataSource != null)
|
||||
{
|
||||
int intIndex = 0;
|
||||
|
||||
int intSourceCount = 0;
|
||||
if (m_dataSource is DataTable)
|
||||
{
|
||||
intSourceCount = (m_dataSource as DataTable).Rows.Count;
|
||||
}
|
||||
else if (typeof(IList).IsAssignableFrom(m_dataSource.GetType()))
|
||||
{
|
||||
intSourceCount = (m_dataSource as IList).Count;
|
||||
}
|
||||
|
||||
foreach (Control item in this.panRow.Controls)
|
||||
{
|
||||
if (intIndex >= intSourceCount)
|
||||
{
|
||||
item.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
var row = (item as IDataGridViewRow);
|
||||
row.IsShowCheckBox = m_isShowCheckBox;
|
||||
if (m_dataSource is DataTable)
|
||||
{
|
||||
row.DataSource = (m_dataSource as DataTable).Rows[intIndex];
|
||||
}
|
||||
else
|
||||
{
|
||||
row.DataSource = (m_dataSource as IList)[intIndex];
|
||||
}
|
||||
row.BindingCellData();
|
||||
if (row.RowHeight != m_rowHeight)
|
||||
row.RowHeight = m_rowHeight;
|
||||
item.Visible = true;
|
||||
item.BringToFront();
|
||||
|
||||
Rows.Add(row);
|
||||
row.RowIndex = Rows.IndexOf(row);
|
||||
}
|
||||
intIndex++;
|
||||
}
|
||||
|
||||
if (intIndex < intSourceCount)
|
||||
{
|
||||
for (int i = intIndex; i < intSourceCount; i++)
|
||||
{
|
||||
IDataGridViewRow row = (IDataGridViewRow)Activator.CreateInstance(m_rowType);
|
||||
if (m_dataSource is DataTable)
|
||||
{
|
||||
row.DataSource = (m_dataSource as DataTable).Rows[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
row.DataSource = (m_dataSource as IList)[i];
|
||||
}
|
||||
row.Columns = m_columns;
|
||||
List<Control> lstCells = new List<Control>();
|
||||
row.IsShowCheckBox = m_isShowCheckBox;
|
||||
row.ReloadCells();
|
||||
row.BindingCellData();
|
||||
|
||||
Control rowControl = (row as Control);
|
||||
row.RowHeight = m_rowHeight;
|
||||
rowControl.Dock = DockStyle.Top;
|
||||
row.CellClick += (a, b) => { SetSelectRow(rowControl, b); };
|
||||
row.CheckBoxChangeEvent += (a, b) => { SetSelectRow(rowControl, b); };
|
||||
row.RowCustomEvent += (a, b) => { if (RowCustomEvent != null) { RowCustomEvent(a, b); } };
|
||||
row.SourceChanged += RowSourceChanged;
|
||||
Rows.Add(row);
|
||||
row.RowIndex = Rows.IndexOf(row);
|
||||
this.panRow.Controls.Add(rowControl);
|
||||
rowControl.BringToFront();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (Control item in this.panRow.Controls)
|
||||
{
|
||||
item.Visible = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 快捷键
|
||||
/// </summary>
|
||||
/// <param name="msg">通过引用传递的 <see cref="T:System.Windows.Forms.Message" />,它表示要处理的窗口消息。</param>
|
||||
/// <param name="keyData"><see cref="T:System.Windows.Forms.Keys" /> 值之一,它表示要处理的键。</param>
|
||||
/// <returns>如果字符已由控件处理,则为 true;否则为 false。</returns>
|
||||
protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
|
||||
{
|
||||
if (keyData == Keys.Up)
|
||||
{
|
||||
Previous();
|
||||
}
|
||||
else if (keyData == Keys.Down)
|
||||
{
|
||||
Next();
|
||||
}
|
||||
else if (keyData == Keys.Home)
|
||||
{
|
||||
First();
|
||||
}
|
||||
else if (keyData == Keys.End)
|
||||
{
|
||||
End();
|
||||
}
|
||||
return base.ProcessCmdKey(ref msg, keyData);
|
||||
}
|
||||
/// <summary>
|
||||
/// 选中第一个
|
||||
/// </summary>
|
||||
public void First()
|
||||
{
|
||||
if (Rows == null || Rows.Count <= 0)
|
||||
return;
|
||||
Control c = null;
|
||||
c = (Rows[0] as Control);
|
||||
SetSelectRow(c, new DataGridViewEventArgs() { RowIndex = 0 });
|
||||
}
|
||||
/// <summary>
|
||||
/// 选中上一个
|
||||
/// </summary>
|
||||
public void Previous()
|
||||
{
|
||||
if (Rows == null || Rows.Count <= 0)
|
||||
return;
|
||||
Control c = null;
|
||||
|
||||
int index = Rows.IndexOf(m_selectRow);
|
||||
if (index - 1 >= 0)
|
||||
{
|
||||
c = (Rows[index - 1] as Control);
|
||||
SetSelectRow(c, new DataGridViewEventArgs() { RowIndex = index - 1 });
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 选中下一个
|
||||
/// </summary>
|
||||
public void Next()
|
||||
{
|
||||
if (Rows == null || Rows.Count <= 0)
|
||||
return;
|
||||
Control c = null;
|
||||
|
||||
int index = Rows.IndexOf(m_selectRow);
|
||||
if (index + 1 < Rows.Count)
|
||||
{
|
||||
c = (Rows[index + 1] as Control);
|
||||
SetSelectRow(c, new DataGridViewEventArgs() { RowIndex = index + 1 });
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 选中最后一个
|
||||
/// </summary>
|
||||
public void End()
|
||||
{
|
||||
if (Rows == null || Rows.Count <= 0)
|
||||
return;
|
||||
Control c = null;
|
||||
c = (Rows[Rows.Count - 1] as Control);
|
||||
SetSelectRow(c, new DataGridViewEventArgs() { RowIndex = Rows.Count - 1 });
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 事件
|
||||
/// <summary>
|
||||
/// Rows the source changed.
|
||||
/// </summary>
|
||||
/// <param name="sender">The sender.</param>
|
||||
/// <param name="e">The <see cref="DataGridViewEventArgs" /> instance containing the event data.</param>
|
||||
void RowSourceChanged(object sender, DataGridViewEventArgs e)
|
||||
{
|
||||
if (RowSourceChangedEvent != null)
|
||||
RowSourceChangedEvent(sender, e);
|
||||
}
|
||||
/// <summary>
|
||||
/// Sets the select row.
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="e">The <see cref="DataGridViewEventArgs" /> instance containing the event data.</param>
|
||||
private void SetSelectRow(Control item, DataGridViewEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(this, true);
|
||||
if (item == null)
|
||||
return;
|
||||
if (item.Visible == false)
|
||||
return;
|
||||
this.FindForm().ActiveControl = this;
|
||||
this.FindForm().ActiveControl = item;
|
||||
if (m_selectRow != item)
|
||||
{
|
||||
if (m_selectRow != null)
|
||||
{
|
||||
m_selectRow.SetSelect(false);
|
||||
}
|
||||
m_selectRow = item as IDataGridViewRow;
|
||||
m_selectRow.SetSelect(true);
|
||||
|
||||
if (this.panRow.Controls.Count > 0)
|
||||
{
|
||||
if (item.Location.Y < 0)
|
||||
{
|
||||
this.panRow.AutoScrollPosition = new Point(0, Math.Abs(this.panRow.Controls[this.panRow.Controls.Count - 1].Location.Y) + item.Location.Y);
|
||||
}
|
||||
else if (item.Location.Y + m_rowHeight > this.panRow.Height)
|
||||
{
|
||||
this.panRow.AutoScrollPosition = new Point(0, Math.Abs(this.panRow.AutoScrollPosition.Y) + item.Location.Y - this.panRow.Height + m_rowHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ItemClick != null)
|
||||
{
|
||||
ItemClick(item, e);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
102
UsingControl/HZHControls/Controls/DataGridView/UCDataGridViewRow.Designer.cs
generated
Normal file
102
UsingControl/HZHControls/Controls/DataGridView/UCDataGridViewRow.Designer.cs
generated
Normal file
@@ -0,0 +1,102 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-09-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCDataGridViewRow.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCDataGridViewRow.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
partial class UCDataGridViewRow
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.ucSplitLine_H1 = new HZH_Controls.Controls.UCSplitLine_H();
|
||||
this.panCells = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ucSplitLine_H1
|
||||
//
|
||||
this.ucSplitLine_H1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
|
||||
this.ucSplitLine_H1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.ucSplitLine_H1.Location = new System.Drawing.Point(0, 55);
|
||||
this.ucSplitLine_H1.Name = "ucSplitLine_H1";
|
||||
this.ucSplitLine_H1.Size = new System.Drawing.Size(661, 1);
|
||||
this.ucSplitLine_H1.TabIndex = 0;
|
||||
this.ucSplitLine_H1.TabStop = false;
|
||||
//
|
||||
// panCells
|
||||
//
|
||||
this.panCells.ColumnCount = 1;
|
||||
this.panCells.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.panCells.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.panCells.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panCells.Location = new System.Drawing.Point(0, 0);
|
||||
this.panCells.Name = "panCells";
|
||||
this.panCells.RowCount = 1;
|
||||
this.panCells.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.panCells.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.panCells.Size = new System.Drawing.Size(661, 55);
|
||||
this.panCells.TabIndex = 1;
|
||||
//
|
||||
// UCDataGridViewItem
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.Controls.Add(this.panCells);
|
||||
this.Controls.Add(this.ucSplitLine_H1);
|
||||
this.Name = "UCDataGridViewItem";
|
||||
this.Size = new System.Drawing.Size(661, 56);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The uc split line h1
|
||||
/// </summary>
|
||||
private UCSplitLine_H ucSplitLine_H1;
|
||||
/// <summary>
|
||||
/// The pan cells
|
||||
/// </summary>
|
||||
private System.Windows.Forms.TableLayoutPanel panCells;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,323 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-09-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCDataGridViewRow.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCDataGridViewRow.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// Implements the <see cref="HZH_Controls.Controls.IDataGridViewRow" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
/// <seealso cref="HZH_Controls.Controls.IDataGridViewRow" />
|
||||
[ToolboxItem(false)]
|
||||
public partial class UCDataGridViewRow : UserControl, IDataGridViewRow
|
||||
{
|
||||
|
||||
#region 属性
|
||||
/// <summary>
|
||||
/// CheckBox选中事件
|
||||
/// </summary>
|
||||
public event DataGridViewEventHandler CheckBoxChangeEvent;
|
||||
/// <summary>
|
||||
/// Occurs when [row custom event].
|
||||
/// </summary>
|
||||
public event DataGridViewRowCustomEventHandler RowCustomEvent;
|
||||
/// <summary>
|
||||
/// 点击单元格事件
|
||||
/// </summary>
|
||||
public event DataGridViewEventHandler CellClick;
|
||||
|
||||
/// <summary>
|
||||
/// 数据源改变事件
|
||||
/// </summary>
|
||||
public event DataGridViewEventHandler SourceChanged;
|
||||
|
||||
/// <summary>
|
||||
/// 列参数,用于创建列数和宽度
|
||||
/// </summary>
|
||||
/// <value>The columns.</value>
|
||||
public List<DataGridViewColumnEntity> Columns
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据源
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
public object DataSource
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 行号
|
||||
/// </summary>
|
||||
/// <value>The Index of the row.</value>
|
||||
public int RowIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is show CheckBox.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is show CheckBox; otherwise, <c>false</c>.</value>
|
||||
public bool IsShowCheckBox
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// The m is checked
|
||||
/// </summary>
|
||||
private bool m_isChecked;
|
||||
/// <summary>
|
||||
/// 是否选中
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is checked; otherwise, <c>false</c>.</value>
|
||||
public bool IsChecked
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_isChecked;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (m_isChecked != value)
|
||||
{
|
||||
m_isChecked = value;
|
||||
(this.panCells.Controls.Find("check", false)[0] as UCCheckBox).Checked = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The m row height
|
||||
/// </summary>
|
||||
int m_rowHeight = 40;
|
||||
/// <summary>
|
||||
/// 行高
|
||||
/// </summary>
|
||||
/// <value>The height of the row.</value>
|
||||
public int RowHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_rowHeight;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_rowHeight = value;
|
||||
this.Height = value;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCDataGridViewRow" /> class.
|
||||
/// </summary>
|
||||
public UCDataGridViewRow()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 绑定数据到Cell
|
||||
/// </summary>
|
||||
/// <returns>返回true则表示已处理过,否则将进行默认绑定(通常只针对有Text值的控件)</returns>
|
||||
public void BindingCellData()
|
||||
{
|
||||
if (DataSource != null)
|
||||
{
|
||||
for (int i = 0; i < Columns.Count; i++)
|
||||
{
|
||||
DataGridViewColumnEntity com = Columns[i];
|
||||
var cs = this.panCells.Controls.Find("lbl_" + com.DataField, false);
|
||||
if (cs != null && cs.Length > 0)
|
||||
{
|
||||
if (DataSource is DataRow)
|
||||
{
|
||||
DataRow row=DataSource as DataRow;
|
||||
if (com.Format != null)
|
||||
{
|
||||
cs[0].Text = com.Format(row[com.DataField]);
|
||||
}
|
||||
else
|
||||
{
|
||||
cs[0].Text = row[com.DataField].ToStringExt();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var pro = DataSource.GetType().GetProperty(com.DataField);
|
||||
|
||||
if (pro != null)
|
||||
{
|
||||
var value = pro.GetValue(DataSource, null);
|
||||
if (com.Format != null)
|
||||
{
|
||||
cs[0].Text = com.Format(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
cs[0].Text = value.ToStringExt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (Control item in this.panCells.Controls)
|
||||
{
|
||||
if (item is IDataGridViewCustomCell)
|
||||
{
|
||||
IDataGridViewCustomCell cell = item as IDataGridViewCustomCell;
|
||||
cell.SetBindSource(DataSource);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the Item control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
void Item_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (CellClick != null)
|
||||
{
|
||||
CellClick(this, new DataGridViewEventArgs()
|
||||
{
|
||||
CellControl = this,
|
||||
CellIndex = (sender as Control).Tag.ToInt(),
|
||||
RowIndex = this.RowIndex
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置选中状态,通常为设置颜色即可
|
||||
/// </summary>
|
||||
/// <param name="blnSelected">是否选中</param>
|
||||
public void SetSelect(bool blnSelected)
|
||||
{
|
||||
if (blnSelected)
|
||||
{
|
||||
this.BackColor = Color.FromArgb(255, 247, 245);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.BackColor = Color.Transparent;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reloads the cells.
|
||||
/// </summary>
|
||||
public void ReloadCells()
|
||||
{
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(this, true);
|
||||
this.panCells.Controls.Clear();
|
||||
this.panCells.ColumnStyles.Clear();
|
||||
|
||||
int intColumnsCount = Columns.Count();
|
||||
if (Columns != null && intColumnsCount > 0)
|
||||
{
|
||||
if (IsShowCheckBox)
|
||||
{
|
||||
intColumnsCount++;
|
||||
}
|
||||
this.panCells.ColumnCount = intColumnsCount;
|
||||
for (int i = 0; i < intColumnsCount; i++)
|
||||
{
|
||||
Control c = null;
|
||||
if (i == 0 && IsShowCheckBox)
|
||||
{
|
||||
this.panCells.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(SizeType.Absolute, 30F));
|
||||
|
||||
UCCheckBox box = new UCCheckBox();
|
||||
box.Name = "check";
|
||||
box.TextValue = "";
|
||||
box.Size = new Size(30, 30);
|
||||
box.Dock = DockStyle.Fill;
|
||||
box.CheckedChangeEvent += (a, b) =>
|
||||
{
|
||||
IsChecked = box.Checked;
|
||||
if (CheckBoxChangeEvent != null)
|
||||
{
|
||||
CheckBoxChangeEvent(a, new DataGridViewEventArgs()
|
||||
{
|
||||
RowIndex = this.RowIndex,
|
||||
CellControl = box,
|
||||
CellIndex = 0
|
||||
});
|
||||
}
|
||||
};
|
||||
c = box;
|
||||
}
|
||||
else
|
||||
{
|
||||
var item = Columns[i - (IsShowCheckBox ? 1 : 0)];
|
||||
this.panCells.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(item.WidthType, item.Width));
|
||||
|
||||
if (item.CustomCellType == null)
|
||||
{
|
||||
Label lbl = new Label();
|
||||
lbl.Tag = i - (IsShowCheckBox ? 1 : 0);
|
||||
lbl.Name = "lbl_" + item.DataField;
|
||||
lbl.Font = new Font("微软雅黑", 12);
|
||||
lbl.ForeColor = Color.Black;
|
||||
lbl.AutoSize = false;
|
||||
lbl.Dock = DockStyle.Fill;
|
||||
lbl.TextAlign = item.TextAlign;
|
||||
lbl.MouseDown += (a, b) =>
|
||||
{
|
||||
Item_MouseDown(a, b);
|
||||
};
|
||||
c = lbl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Control cc = (Control)Activator.CreateInstance(item.CustomCellType);
|
||||
cc.Dock = DockStyle.Fill;
|
||||
c = cc;
|
||||
}
|
||||
}
|
||||
this.panCells.Controls.Add(c, i, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
211
UsingControl/HZHControls/Controls/DataGridView/UCDataGridViewTreeRow.Designer.cs
generated
Normal file
211
UsingControl/HZHControls/Controls/DataGridView/UCDataGridViewTreeRow.Designer.cs
generated
Normal file
@@ -0,0 +1,211 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-23-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCDataGridViewTreeRow.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCDataGridViewTreeRow.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
partial class UCDataGridViewTreeRow
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panCells = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.panLeft = new System.Windows.Forms.Panel();
|
||||
this.panChildGrid = new System.Windows.Forms.Panel();
|
||||
this.ucDGVChild = new HZH_Controls.Controls.UCDataGridView();
|
||||
this.ucSplitLine_V1 = new HZH_Controls.Controls.UCSplitLine_V();
|
||||
this.panChildLeft = new System.Windows.Forms.Panel();
|
||||
this.panMain = new System.Windows.Forms.Panel();
|
||||
this.ucSplitLine_H1 = new HZH_Controls.Controls.UCSplitLine_H();
|
||||
this.panChildGrid.SuspendLayout();
|
||||
this.panMain.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panCells
|
||||
//
|
||||
this.panCells.ColumnCount = 1;
|
||||
this.panCells.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.panCells.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.panCells.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panCells.Location = new System.Drawing.Point(24, 0);
|
||||
this.panCells.Name = "panCells";
|
||||
this.panCells.RowCount = 1;
|
||||
this.panCells.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.panCells.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 55F));
|
||||
this.panCells.Size = new System.Drawing.Size(637, 64);
|
||||
this.panCells.TabIndex = 2;
|
||||
//
|
||||
// panLeft
|
||||
//
|
||||
this.panLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.panLeft.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.panLeft.Location = new System.Drawing.Point(0, 0);
|
||||
this.panLeft.Name = "panLeft";
|
||||
this.panLeft.Size = new System.Drawing.Size(24, 64);
|
||||
this.panLeft.TabIndex = 0;
|
||||
this.panLeft.Tag = "0";
|
||||
this.panLeft.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panLeft_MouseDown);
|
||||
//
|
||||
// panChildGrid
|
||||
//
|
||||
this.panChildGrid.Controls.Add(this.ucDGVChild);
|
||||
this.panChildGrid.Controls.Add(this.ucSplitLine_V1);
|
||||
this.panChildGrid.Controls.Add(this.panChildLeft);
|
||||
this.panChildGrid.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.panChildGrid.Location = new System.Drawing.Point(0, 65);
|
||||
this.panChildGrid.Name = "panChildGrid";
|
||||
this.panChildGrid.Size = new System.Drawing.Size(661, 0);
|
||||
this.panChildGrid.TabIndex = 0;
|
||||
this.panChildGrid.SizeChanged += new System.EventHandler(this.panChildGrid_SizeChanged);
|
||||
//
|
||||
// ucDGVChild
|
||||
//
|
||||
this.ucDGVChild.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.ucDGVChild.BackColor = System.Drawing.Color.White;
|
||||
this.ucDGVChild.Columns = null;
|
||||
this.ucDGVChild.DataSource = null;
|
||||
this.ucDGVChild.HeadFont = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.ucDGVChild.HeadHeight = 40;
|
||||
this.ucDGVChild.HeadPadingLeft = 0;
|
||||
this.ucDGVChild.HeadTextColor = System.Drawing.Color.Black;
|
||||
this.ucDGVChild.IsShowCheckBox = false;
|
||||
this.ucDGVChild.IsShowHead = false;
|
||||
this.ucDGVChild.Location = new System.Drawing.Point(25, 0);
|
||||
this.ucDGVChild.Name = "ucDGVChild";
|
||||
this.ucDGVChild.RowHeight = 40;
|
||||
this.ucDGVChild.RowType = typeof(HZH_Controls.Controls.UCDataGridViewRow);
|
||||
this.ucDGVChild.Size = new System.Drawing.Size(636, 100);
|
||||
this.ucDGVChild.TabIndex = 0;
|
||||
this.ucDGVChild.SizeChanged += new System.EventHandler(this.ucDGVChild_SizeChanged);
|
||||
//
|
||||
// ucSplitLine_V1
|
||||
//
|
||||
this.ucSplitLine_V1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
|
||||
this.ucSplitLine_V1.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.ucSplitLine_V1.Location = new System.Drawing.Point(24, 0);
|
||||
this.ucSplitLine_V1.Name = "ucSplitLine_V1";
|
||||
this.ucSplitLine_V1.Size = new System.Drawing.Size(1, 0);
|
||||
this.ucSplitLine_V1.TabIndex = 0;
|
||||
this.ucSplitLine_V1.TabStop = false;
|
||||
//
|
||||
// panChildLeft
|
||||
//
|
||||
this.panChildLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.panChildLeft.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.panChildLeft.Location = new System.Drawing.Point(0, 0);
|
||||
this.panChildLeft.Name = "panChildLeft";
|
||||
this.panChildLeft.Size = new System.Drawing.Size(24, 0);
|
||||
this.panChildLeft.TabIndex = 1;
|
||||
this.panChildLeft.Tag = "0";
|
||||
//
|
||||
// panMain
|
||||
//
|
||||
this.panMain.Controls.Add(this.panCells);
|
||||
this.panMain.Controls.Add(this.panLeft);
|
||||
this.panMain.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panMain.Location = new System.Drawing.Point(0, 0);
|
||||
this.panMain.Name = "panMain";
|
||||
this.panMain.Size = new System.Drawing.Size(661, 64);
|
||||
this.panMain.TabIndex = 0;
|
||||
//
|
||||
// ucSplitLine_H1
|
||||
//
|
||||
this.ucSplitLine_H1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(232)))), ((int)(((byte)(232)))), ((int)(((byte)(232)))));
|
||||
this.ucSplitLine_H1.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.ucSplitLine_H1.Location = new System.Drawing.Point(0, 64);
|
||||
this.ucSplitLine_H1.Name = "ucSplitLine_H1";
|
||||
this.ucSplitLine_H1.Size = new System.Drawing.Size(661, 1);
|
||||
this.ucSplitLine_H1.TabIndex = 1;
|
||||
this.ucSplitLine_H1.TabStop = false;
|
||||
//
|
||||
// UCDataGridViewTreeRow
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.Controls.Add(this.panMain);
|
||||
this.Controls.Add(this.ucSplitLine_H1);
|
||||
this.Controls.Add(this.panChildGrid);
|
||||
this.Name = "UCDataGridViewTreeRow";
|
||||
this.Size = new System.Drawing.Size(661, 65);
|
||||
this.panChildGrid.ResumeLayout(false);
|
||||
this.panMain.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The pan cells
|
||||
/// </summary>
|
||||
private System.Windows.Forms.TableLayoutPanel panCells;
|
||||
/// <summary>
|
||||
/// The uc split line h1
|
||||
/// </summary>
|
||||
private UCSplitLine_H ucSplitLine_H1;
|
||||
/// <summary>
|
||||
/// The pan left
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panLeft;
|
||||
/// <summary>
|
||||
/// The pan child grid
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panChildGrid;
|
||||
/// <summary>
|
||||
/// The uc DGV child
|
||||
/// </summary>
|
||||
private UCDataGridView ucDGVChild;
|
||||
/// <summary>
|
||||
/// The pan child left
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panChildLeft;
|
||||
/// <summary>
|
||||
/// The pan main
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panMain;
|
||||
/// <summary>
|
||||
/// The uc split line v1
|
||||
/// </summary>
|
||||
private UCSplitLine_V ucSplitLine_V1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,474 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-23-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCDataGridViewTreeRow.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using System.Collections;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCDataGridViewTreeRow.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// Implements the <see cref="HZH_Controls.Controls.IDataGridViewRow" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
/// <seealso cref="HZH_Controls.Controls.IDataGridViewRow" />
|
||||
[ToolboxItem(false)]
|
||||
public partial class UCDataGridViewTreeRow : UserControl, IDataGridViewRow
|
||||
{
|
||||
#region 属性
|
||||
/// <summary>
|
||||
/// CheckBox选中事件
|
||||
/// </summary>
|
||||
public event DataGridViewEventHandler CheckBoxChangeEvent;
|
||||
|
||||
/// <summary>
|
||||
/// 点击单元格事件
|
||||
/// </summary>
|
||||
public event DataGridViewEventHandler CellClick;
|
||||
|
||||
/// <summary>
|
||||
/// 数据源改变事件
|
||||
/// </summary>
|
||||
public event DataGridViewEventHandler SourceChanged;
|
||||
/// <summary>
|
||||
/// Occurs when [row custom event].
|
||||
/// </summary>
|
||||
public event DataGridViewRowCustomEventHandler RowCustomEvent;
|
||||
/// <summary>
|
||||
/// 列参数,用于创建列数和宽度
|
||||
/// </summary>
|
||||
/// <value>The columns.</value>
|
||||
public List<DataGridViewColumnEntity> Columns
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 数据源
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
public object DataSource
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 行号,树状图目前没有给予行号
|
||||
/// </summary>
|
||||
/// <value>The Index of the row.</value>
|
||||
public int RowIndex { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is show CheckBox.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is show CheckBox; otherwise, <c>false</c>.</value>
|
||||
public bool IsShowCheckBox
|
||||
{
|
||||
get;
|
||||
set;
|
||||
}
|
||||
/// <summary>
|
||||
/// The m is checked
|
||||
/// </summary>
|
||||
private bool m_isChecked;
|
||||
/// <summary>
|
||||
/// 是否选中
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is checked; otherwise, <c>false</c>.</value>
|
||||
public bool IsChecked
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_isChecked;
|
||||
}
|
||||
|
||||
set
|
||||
{
|
||||
if (m_isChecked != value)
|
||||
{
|
||||
m_isChecked = value;
|
||||
(this.panCells.Controls.Find("check", false)[0] as UCCheckBox).Checked = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m row height
|
||||
/// </summary>
|
||||
int m_rowHeight = 40;
|
||||
/// <summary>
|
||||
/// 行高
|
||||
/// </summary>
|
||||
/// <value>The height of the row.</value>
|
||||
public int RowHeight
|
||||
{
|
||||
get
|
||||
{
|
||||
return m_rowHeight;
|
||||
}
|
||||
set
|
||||
{
|
||||
m_rowHeight = value;
|
||||
this.Height = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCDataGridViewTreeRow" /> class.
|
||||
/// </summary>
|
||||
public UCDataGridViewTreeRow()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.ucDGVChild.RowType = this.GetType();
|
||||
this.SizeChanged += UCDataGridViewTreeRow_SizeChanged;
|
||||
this.ucDGVChild.ItemClick += (a, b) =>
|
||||
{
|
||||
if (CellClick != null)
|
||||
{
|
||||
CellClick(a, new DataGridViewEventArgs()
|
||||
{
|
||||
CellControl = (a as Control),
|
||||
CellIndex = (a as Control).Tag.ToInt()
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the UCDataGridViewTreeRow 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 UCDataGridViewTreeRow_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (this.Parent != null)
|
||||
{
|
||||
if (this.Parent.Parent.Parent != null && this.Parent.Parent.Parent.Name == "panChildGrid" && this.panLeft.Tag.ToInt() == 1)
|
||||
{
|
||||
int intHeight = this.Parent.Parent.Controls[0].Controls.ToArray().Sum(p => p.Height);
|
||||
if (this.Parent.Parent.Parent.Height != intHeight)
|
||||
this.Parent.Parent.Parent.Height = intHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 绑定数据到Cell
|
||||
/// </summary>
|
||||
/// <returns>返回true则表示已处理过,否则将进行默认绑定(通常只针对有Text值的控件)</returns>
|
||||
public void BindingCellData()
|
||||
{
|
||||
for (int i = 0; i < Columns.Count; i++)
|
||||
{
|
||||
DataGridViewColumnEntity com = Columns[i];
|
||||
var cs = this.panCells.Controls.Find("lbl_" + com.DataField, false);
|
||||
if (cs != null && cs.Length > 0)
|
||||
{
|
||||
var pro = DataSource.GetType().GetProperty(com.DataField);
|
||||
if (pro != null)
|
||||
{
|
||||
var value = pro.GetValue(DataSource, null);
|
||||
if (com.Format != null)
|
||||
{
|
||||
cs[0].Text = com.Format(value);
|
||||
}
|
||||
else
|
||||
{
|
||||
cs[0].Text = value.ToStringExt();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (Control item in this.panCells.Controls)
|
||||
{
|
||||
if (item is IDataGridViewCustomCell)
|
||||
{
|
||||
IDataGridViewCustomCell cell = item as IDataGridViewCustomCell;
|
||||
cell.SetBindSource(DataSource);
|
||||
}
|
||||
}
|
||||
panLeft.Tag = 0;
|
||||
var proChildrens = DataSource.GetType().GetProperty("Childrens");
|
||||
if (proChildrens != null)
|
||||
{
|
||||
var value = proChildrens.GetValue(DataSource, null);
|
||||
if (value != null)
|
||||
{
|
||||
int intSourceCount = 0;
|
||||
if (value is DataTable)
|
||||
{
|
||||
intSourceCount = (value as DataTable).Rows.Count;
|
||||
}
|
||||
else if (typeof(IList).IsAssignableFrom(value.GetType()))
|
||||
{
|
||||
intSourceCount = (value as IList).Count;
|
||||
}
|
||||
if (intSourceCount > 0)
|
||||
{
|
||||
panLeft.BackgroundImage = Properties.Resources.caret_right;
|
||||
panLeft.Enabled = true;
|
||||
panChildGrid.Tag = value;
|
||||
}
|
||||
else
|
||||
{
|
||||
panLeft.BackgroundImage = null;
|
||||
panLeft.Enabled = false;
|
||||
panChildGrid.Tag = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
panLeft.BackgroundImage = null;
|
||||
panLeft.Enabled = false;
|
||||
panChildGrid.Tag = null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
panLeft.BackgroundImage = null;
|
||||
panLeft.Enabled = false;
|
||||
panChildGrid.Tag = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the Item control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
void Item_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (CellClick != null)
|
||||
{
|
||||
CellClick(this, new DataGridViewEventArgs()
|
||||
{
|
||||
CellControl = this,
|
||||
CellIndex = (sender as Control).Tag.ToInt()
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置选中状态,通常为设置颜色即可
|
||||
/// </summary>
|
||||
/// <param name="blnSelected">是否选中</param>
|
||||
public void SetSelect(bool blnSelected)
|
||||
{
|
||||
if (blnSelected)
|
||||
{
|
||||
this.panMain.BackColor = Color.FromArgb(255, 247, 245);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.panMain.BackColor = Color.Transparent;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加单元格元素,仅做添加控件操作,不做数据绑定,数据绑定使用BindingCells
|
||||
/// </summary>
|
||||
public void ReloadCells()
|
||||
{
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(this, true);
|
||||
this.panCells.Controls.Clear();
|
||||
this.panCells.ColumnStyles.Clear();
|
||||
|
||||
int intColumnsCount = Columns.Count();
|
||||
if (Columns != null && intColumnsCount > 0)
|
||||
{
|
||||
if (IsShowCheckBox)
|
||||
{
|
||||
intColumnsCount++;
|
||||
}
|
||||
this.panCells.ColumnCount = intColumnsCount;
|
||||
for (int i = 0; i < intColumnsCount; i++)
|
||||
{
|
||||
Control c = null;
|
||||
if (i == 0 && IsShowCheckBox)
|
||||
{
|
||||
this.panCells.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(SizeType.Absolute, 30F));
|
||||
|
||||
UCCheckBox box = new UCCheckBox();
|
||||
box.Name = "check";
|
||||
box.TextValue = "";
|
||||
box.Size = new Size(30, 30);
|
||||
box.Dock = DockStyle.Fill;
|
||||
box.CheckedChangeEvent += (a, b) =>
|
||||
{
|
||||
IsChecked = box.Checked;
|
||||
if (this.ucDGVChild.Rows != null)
|
||||
{
|
||||
this.ucDGVChild.Rows.ForEach(p => p.IsChecked = box.Checked);
|
||||
if (CheckBoxChangeEvent != null)
|
||||
{
|
||||
CheckBoxChangeEvent(a, new DataGridViewEventArgs()
|
||||
{
|
||||
CellControl = box,
|
||||
CellIndex = 0
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
c = box;
|
||||
}
|
||||
else
|
||||
{
|
||||
var item = Columns[i - (IsShowCheckBox ? 1 : 0)];
|
||||
this.panCells.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(item.WidthType, item.Width));
|
||||
|
||||
if (item.CustomCellType == null)
|
||||
{
|
||||
Label lbl = new Label();
|
||||
lbl.Tag = i - (IsShowCheckBox ? 1 : 0);
|
||||
lbl.Name = "lbl_" + item.DataField;
|
||||
lbl.Font = new Font("微软雅黑", 12);
|
||||
lbl.ForeColor = Color.Black;
|
||||
lbl.AutoSize = false;
|
||||
lbl.Dock = DockStyle.Fill;
|
||||
lbl.TextAlign = item.TextAlign;
|
||||
lbl.MouseDown += (a, b) =>
|
||||
{
|
||||
Item_MouseDown(a, b);
|
||||
};
|
||||
c = lbl;
|
||||
}
|
||||
else
|
||||
{
|
||||
Control cc = (Control)Activator.CreateInstance(item.CustomCellType);
|
||||
cc.Dock = DockStyle.Fill;
|
||||
c = cc;
|
||||
}
|
||||
}
|
||||
this.panCells.Controls.Add(c, i, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the panChildGrid control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void panChildGrid_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
int intHeight = RowHeight + panChildGrid.Height;
|
||||
if (panChildGrid.Height != 0)
|
||||
this.ucDGVChild.Height = panChildGrid.Height;
|
||||
if (this.Height != intHeight)
|
||||
{
|
||||
this.Height = intHeight;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the panLeft control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void panLeft_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(this.FindForm(), true);
|
||||
if (panLeft.Tag.ToInt() == 0)
|
||||
{
|
||||
var value = panChildGrid.Tag;
|
||||
if (value != null)
|
||||
{
|
||||
panLeft.BackgroundImage = Properties.Resources.caret_down;
|
||||
panLeft.Tag = 1;
|
||||
int intSourceCount = 0;
|
||||
if (value is DataTable)
|
||||
{
|
||||
intSourceCount = (value as DataTable).Rows.Count;
|
||||
}
|
||||
else if (typeof(IList).IsAssignableFrom(value.GetType()))
|
||||
{
|
||||
intSourceCount = (value as IList).Count;
|
||||
}
|
||||
this.panChildGrid.Height = RowHeight * intSourceCount;
|
||||
if (panChildGrid.Height > 0)
|
||||
{
|
||||
if (value != this.ucDGVChild.DataSource)
|
||||
{
|
||||
this.ucDGVChild.Columns = Columns;
|
||||
this.ucDGVChild.RowHeight = RowHeight;
|
||||
this.ucDGVChild.HeadPadingLeft = this.panLeft.Width;
|
||||
this.ucDGVChild.IsShowCheckBox = IsShowCheckBox;
|
||||
this.ucDGVChild.DataSource = value;
|
||||
this.ucDGVChild.Rows.ForEach(p => p.IsChecked = this.IsChecked);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Control[] cs = panChildGrid.Controls.Find("panLeft", true);
|
||||
foreach (var item in cs)
|
||||
{
|
||||
item.Tag = 0;
|
||||
item.BackgroundImage = Properties.Resources.caret_right;
|
||||
}
|
||||
|
||||
Control[] cs1 = panChildGrid.Controls.Find("panChildGrid", true);
|
||||
foreach (var item in cs1)
|
||||
{
|
||||
item.Height = 0;
|
||||
}
|
||||
panChildGrid.Height = 0;
|
||||
panLeft.BackgroundImage = Properties.Resources.caret_right;
|
||||
this.Height = m_rowHeight;
|
||||
panLeft.Tag = 0;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(this.FindForm(), false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the ucDGVChild control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void ucDGVChild_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,41 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="DateTimePickerType.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;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Enum DateTimePickerType
|
||||
/// </summary>
|
||||
public enum DateTimePickerType
|
||||
{
|
||||
/// <summary>
|
||||
/// The date time
|
||||
/// </summary>
|
||||
DateTime = 1,
|
||||
/// <summary>
|
||||
/// The date
|
||||
/// </summary>
|
||||
Date = 2,
|
||||
/// <summary>
|
||||
/// The time
|
||||
/// </summary>
|
||||
Time = 4
|
||||
}
|
||||
}
|
||||
384
UsingControl/HZHControls/Controls/DateTime/UCDatePickerExt.Designer.cs
generated
Normal file
384
UsingControl/HZHControls/Controls/DateTime/UCDatePickerExt.Designer.cs
generated
Normal file
@@ -0,0 +1,384 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCDatePickerExt.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCDatePickerExt.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCControlBase" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCControlBase" />
|
||||
partial class UCDatePickerExt
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.label5 = new System.Windows.Forms.Label();
|
||||
this.txtMinute = new HZH_Controls.Controls.TextBoxEx();
|
||||
this.label4 = new System.Windows.Forms.Label();
|
||||
this.txtHour = new HZH_Controls.Controls.TextBoxEx();
|
||||
this.label3 = new System.Windows.Forms.Label();
|
||||
this.txtDay = new HZH_Controls.Controls.TextBoxEx();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.txtMonth = new HZH_Controls.Controls.TextBoxEx();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.txtYear = new HZH_Controls.Controls.TextBoxEx();
|
||||
this.panel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.panel1.Controls.Add(this.label5);
|
||||
this.panel1.Controls.Add(this.txtMinute);
|
||||
this.panel1.Controls.Add(this.label4);
|
||||
this.panel1.Controls.Add(this.txtHour);
|
||||
this.panel1.Controls.Add(this.label3);
|
||||
this.panel1.Controls.Add(this.txtDay);
|
||||
this.panel1.Controls.Add(this.label2);
|
||||
this.panel1.Controls.Add(this.txtMonth);
|
||||
this.panel1.Controls.Add(this.label1);
|
||||
this.panel1.Controls.Add(this.txtYear);
|
||||
this.panel1.Location = new System.Drawing.Point(3, 6);
|
||||
this.panel1.MaximumSize = new System.Drawing.Size(0, 27);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(330, 27);
|
||||
this.panel1.TabIndex = 9;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
this.label5.AutoSize = true;
|
||||
this.label5.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.label5.Font = new System.Drawing.Font("微软雅黑", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.label5.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
|
||||
this.label5.Location = new System.Drawing.Point(301, 0);
|
||||
this.label5.Name = "label5";
|
||||
this.label5.Size = new System.Drawing.Size(32, 27);
|
||||
this.label5.TabIndex = 17;
|
||||
this.label5.Text = "分";
|
||||
this.label5.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// txtMinute
|
||||
//
|
||||
this.txtMinute.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.txtMinute.DecLength = 2;
|
||||
this.txtMinute.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.txtMinute.Font = new System.Drawing.Font("Arial Unicode MS", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtMinute.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
|
||||
this.txtMinute.InputType = HZH_Controls.TextInputType.Integer;
|
||||
this.txtMinute.Location = new System.Drawing.Point(272, 0);
|
||||
this.txtMinute.MaxValue = new decimal(new int[] {
|
||||
59,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtMinute.MinValue = new decimal(new int[] {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtMinute.MyRectangle = new System.Drawing.Rectangle(0, 0, 0, 0);
|
||||
this.txtMinute.Name = "txtMinute";
|
||||
this.txtMinute.OldText = null;
|
||||
this.txtMinute.PromptColor = System.Drawing.Color.Gray;
|
||||
this.txtMinute.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtMinute.PromptText = "";
|
||||
this.txtMinute.RegexPattern = "";
|
||||
this.txtMinute.Size = new System.Drawing.Size(29, 27);
|
||||
this.txtMinute.TabIndex = 5;
|
||||
this.txtMinute.Text = "59";
|
||||
this.txtMinute.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.txtMinute.SizeChanged += new System.EventHandler(this.txt_SizeChanged);
|
||||
this.txtMinute.Leave += new System.EventHandler(this.txtMinute_Leave);
|
||||
//
|
||||
// label4
|
||||
//
|
||||
this.label4.AutoSize = true;
|
||||
this.label4.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.label4.Font = new System.Drawing.Font("微软雅黑", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.label4.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
|
||||
this.label4.Location = new System.Drawing.Point(240, 0);
|
||||
this.label4.Name = "label4";
|
||||
this.label4.Size = new System.Drawing.Size(32, 27);
|
||||
this.label4.TabIndex = 16;
|
||||
this.label4.Text = "时";
|
||||
this.label4.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// txtHour
|
||||
//
|
||||
this.txtHour.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.txtHour.DecLength = 2;
|
||||
this.txtHour.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.txtHour.Font = new System.Drawing.Font("Arial Unicode MS", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtHour.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
|
||||
this.txtHour.InputType = HZH_Controls.TextInputType.Integer;
|
||||
this.txtHour.Location = new System.Drawing.Point(211, 0);
|
||||
this.txtHour.MaxValue = new decimal(new int[] {
|
||||
23,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtHour.MinValue = new decimal(new int[] {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtHour.MyRectangle = new System.Drawing.Rectangle(0, 0, 0, 0);
|
||||
this.txtHour.Name = "txtHour";
|
||||
this.txtHour.OldText = null;
|
||||
this.txtHour.PromptColor = System.Drawing.Color.Gray;
|
||||
this.txtHour.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtHour.PromptText = "";
|
||||
this.txtHour.RegexPattern = "";
|
||||
this.txtHour.Size = new System.Drawing.Size(29, 27);
|
||||
this.txtHour.TabIndex = 4;
|
||||
this.txtHour.Text = "23";
|
||||
this.txtHour.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.txtHour.SizeChanged += new System.EventHandler(this.txt_SizeChanged);
|
||||
this.txtHour.TextChanged += new System.EventHandler(this.txtHour_TextChanged);
|
||||
this.txtHour.Leave += new System.EventHandler(this.txtHour_Leave);
|
||||
//
|
||||
// label3
|
||||
//
|
||||
this.label3.AutoSize = true;
|
||||
this.label3.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.label3.Font = new System.Drawing.Font("微软雅黑", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.label3.Location = new System.Drawing.Point(173, 0);
|
||||
this.label3.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.label3.Name = "label3";
|
||||
this.label3.Size = new System.Drawing.Size(38, 27);
|
||||
this.label3.TabIndex = 14;
|
||||
this.label3.Text = " 日";
|
||||
this.label3.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// txtDay
|
||||
//
|
||||
this.txtDay.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.txtDay.DecLength = 2;
|
||||
this.txtDay.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.txtDay.Font = new System.Drawing.Font("Arial Unicode MS", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtDay.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
|
||||
this.txtDay.InputType = HZH_Controls.TextInputType.Integer;
|
||||
this.txtDay.Location = new System.Drawing.Point(144, 0);
|
||||
this.txtDay.MaxValue = new decimal(new int[] {
|
||||
31,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtDay.MinValue = new decimal(new int[] {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtDay.MyRectangle = new System.Drawing.Rectangle(0, 0, 0, 0);
|
||||
this.txtDay.Name = "txtDay";
|
||||
this.txtDay.OldText = null;
|
||||
this.txtDay.PromptColor = System.Drawing.Color.Gray;
|
||||
this.txtDay.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtDay.PromptText = "";
|
||||
this.txtDay.RegexPattern = "";
|
||||
this.txtDay.Size = new System.Drawing.Size(29, 27);
|
||||
this.txtDay.TabIndex = 3;
|
||||
this.txtDay.Text = "12";
|
||||
this.txtDay.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.txtDay.SizeChanged += new System.EventHandler(this.txt_SizeChanged);
|
||||
this.txtDay.TextChanged += new System.EventHandler(this.txtDay_TextChanged);
|
||||
this.txtDay.Leave += new System.EventHandler(this.txtDay_Leave);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.label2.Font = new System.Drawing.Font("微软雅黑", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.label2.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
|
||||
this.label2.Location = new System.Drawing.Point(112, 0);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(32, 27);
|
||||
this.label2.TabIndex = 12;
|
||||
this.label2.Text = "月";
|
||||
this.label2.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// txtMonth
|
||||
//
|
||||
this.txtMonth.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.txtMonth.DecLength = 2;
|
||||
this.txtMonth.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.txtMonth.Font = new System.Drawing.Font("Arial Unicode MS", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtMonth.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
|
||||
this.txtMonth.InputType = HZH_Controls.TextInputType.Integer;
|
||||
this.txtMonth.Location = new System.Drawing.Point(83, 0);
|
||||
this.txtMonth.MaxValue = new decimal(new int[] {
|
||||
12,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtMonth.MinValue = new decimal(new int[] {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtMonth.MyRectangle = new System.Drawing.Rectangle(0, 0, 0, 0);
|
||||
this.txtMonth.Name = "txtMonth";
|
||||
this.txtMonth.OldText = null;
|
||||
this.txtMonth.PromptColor = System.Drawing.Color.Gray;
|
||||
this.txtMonth.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtMonth.PromptText = "";
|
||||
this.txtMonth.RegexPattern = "";
|
||||
this.txtMonth.Size = new System.Drawing.Size(29, 27);
|
||||
this.txtMonth.TabIndex = 2;
|
||||
this.txtMonth.Text = "12";
|
||||
this.txtMonth.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.txtMonth.SizeChanged += new System.EventHandler(this.txt_SizeChanged);
|
||||
this.txtMonth.TextChanged += new System.EventHandler(this.txtMonth_TextChanged);
|
||||
this.txtMonth.Leave += new System.EventHandler(this.txtMonth_Leave);
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.label1.Font = new System.Drawing.Font("微软雅黑", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.label1.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
|
||||
this.label1.Location = new System.Drawing.Point(51, 0);
|
||||
this.label1.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(32, 27);
|
||||
this.label1.TabIndex = 10;
|
||||
this.label1.Text = "年";
|
||||
this.label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
//
|
||||
// txtYear
|
||||
//
|
||||
this.txtYear.BorderStyle = System.Windows.Forms.BorderStyle.None;
|
||||
this.txtYear.DecLength = 2;
|
||||
this.txtYear.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.txtYear.Font = new System.Drawing.Font("Arial Unicode MS", 20F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtYear.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(60)))), ((int)(((byte)(60)))), ((int)(((byte)(60)))));
|
||||
this.txtYear.InputType = HZH_Controls.TextInputType.Integer;
|
||||
this.txtYear.Location = new System.Drawing.Point(0, 0);
|
||||
this.txtYear.MaxValue = new decimal(new int[] {
|
||||
2099,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtYear.MinValue = new decimal(new int[] {
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.txtYear.MyRectangle = new System.Drawing.Rectangle(0, 0, 0, 0);
|
||||
this.txtYear.Name = "txtYear";
|
||||
this.txtYear.OldText = null;
|
||||
this.txtYear.PromptColor = System.Drawing.Color.Gray;
|
||||
this.txtYear.PromptFont = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.txtYear.PromptText = "";
|
||||
this.txtYear.RegexPattern = "";
|
||||
this.txtYear.Size = new System.Drawing.Size(51, 27);
|
||||
this.txtYear.TabIndex = 1;
|
||||
this.txtYear.Text = "2019";
|
||||
this.txtYear.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||
this.txtYear.SizeChanged += new System.EventHandler(this.txt_SizeChanged);
|
||||
this.txtYear.TextChanged += new System.EventHandler(this.txtYear_TextChanged);
|
||||
this.txtYear.Leave += new System.EventHandler(this.txtYear_Leave);
|
||||
//
|
||||
// UCDatePickerExt
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.ConerRadius = 5;
|
||||
this.Controls.Add(this.panel1);
|
||||
this.IsRadius = true;
|
||||
this.IsShowRect = true;
|
||||
this.Name = "UCDatePickerExt";
|
||||
this.Padding = new System.Windows.Forms.Padding(0, 10, 0, 0);
|
||||
this.Size = new System.Drawing.Size(336, 39);
|
||||
this.Load += new System.EventHandler(this.UCDatePickerExt_Load);
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel1.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The panel1
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
/// <summary>
|
||||
/// The label4
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Label label4;
|
||||
/// <summary>
|
||||
/// The label3
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Label label3;
|
||||
/// <summary>
|
||||
/// The label2
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Label label2;
|
||||
/// <summary>
|
||||
/// The label1
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Label label1;
|
||||
/// <summary>
|
||||
/// The text minute
|
||||
/// </summary>
|
||||
private TextBoxEx txtMinute;
|
||||
/// <summary>
|
||||
/// The text hour
|
||||
/// </summary>
|
||||
private TextBoxEx txtHour;
|
||||
/// <summary>
|
||||
/// The text day
|
||||
/// </summary>
|
||||
private TextBoxEx txtDay;
|
||||
/// <summary>
|
||||
/// The text month
|
||||
/// </summary>
|
||||
private TextBoxEx txtMonth;
|
||||
/// <summary>
|
||||
/// The text year
|
||||
/// </summary>
|
||||
private TextBoxEx txtYear;
|
||||
/// <summary>
|
||||
/// The label5
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Label label5;
|
||||
}
|
||||
}
|
||||
369
UsingControl/HZHControls/Controls/DateTime/UCDatePickerExt.cs
Normal file
369
UsingControl/HZHControls/Controls/DateTime/UCDatePickerExt.cs
Normal file
@@ -0,0 +1,369 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCDatePickerExt.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCDatePickerExt.
|
||||
/// Implements the <see cref="HZH_Controls.Controls.UCControlBase" />
|
||||
/// </summary>
|
||||
/// <seealso cref="HZH_Controls.Controls.UCControlBase" />
|
||||
public partial class UCDatePickerExt : UCControlBase
|
||||
{
|
||||
/// <summary>
|
||||
/// The m FRM anchor
|
||||
/// </summary>
|
||||
Forms.FrmAnchor m_frmAnchor;
|
||||
/// <summary>
|
||||
/// The m select pan
|
||||
/// </summary>
|
||||
UCDateTimeSelectPan m_selectPan = null;
|
||||
/// <summary>
|
||||
/// The m type
|
||||
/// </summary>
|
||||
DateTimePickerType m_type = DateTimePickerType.DateTime;
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the time.
|
||||
/// </summary>
|
||||
/// <value>The type of the time.</value>
|
||||
[Description("时间类型"), Category("自定义")]
|
||||
public DateTimePickerType TimeType
|
||||
{
|
||||
get { return m_type; }
|
||||
set
|
||||
{
|
||||
m_type = value;
|
||||
if (value == DateTimePickerType.DateTime)
|
||||
{
|
||||
txtYear.Visible = true;
|
||||
label1.Visible = true;
|
||||
txtMonth.Visible = true;
|
||||
label2.Visible = true;
|
||||
txtDay.Visible = true;
|
||||
label3.Visible = true;
|
||||
txtHour.Visible = true;
|
||||
label4.Visible = true;
|
||||
txtMinute.Visible = true;
|
||||
label5.Visible = true;
|
||||
}
|
||||
else if (value == DateTimePickerType.Date)
|
||||
{
|
||||
txtYear.Visible = true;
|
||||
label1.Visible = true;
|
||||
txtMonth.Visible = true;
|
||||
label2.Visible = true;
|
||||
txtDay.Visible = true;
|
||||
label3.Visible = true;
|
||||
txtHour.Visible = false;
|
||||
label4.Visible = false;
|
||||
txtMinute.Visible = false;
|
||||
label5.Visible = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
txtYear.Visible = false;
|
||||
label1.Visible = false;
|
||||
txtMonth.Visible = false;
|
||||
label2.Visible = false;
|
||||
txtDay.Visible = false;
|
||||
label3.Visible = false;
|
||||
txtHour.Visible = true;
|
||||
label4.Visible = true;
|
||||
txtMinute.Visible = true;
|
||||
label5.Visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The current time
|
||||
/// </summary>
|
||||
private DateTime currentTime = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// The time font size
|
||||
/// </summary>
|
||||
private int timeFontSize = 20;
|
||||
/// <summary>
|
||||
/// Gets or sets the size of the time font.
|
||||
/// </summary>
|
||||
/// <value>The size of the time font.</value>
|
||||
[Description("时间字体大小"), Category("自定义")]
|
||||
public int TimeFontSize
|
||||
{
|
||||
get { return timeFontSize; }
|
||||
set
|
||||
{
|
||||
if (timeFontSize != value)
|
||||
{
|
||||
timeFontSize = value;
|
||||
foreach (Control c in panel1.Controls)
|
||||
{
|
||||
c.Font = new Font(c.Font.Name, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current time.
|
||||
/// </summary>
|
||||
/// <value>The current time.</value>
|
||||
[Description("时间"), Category("自定义")]
|
||||
public DateTime CurrentTime
|
||||
{
|
||||
get { return currentTime; }
|
||||
set
|
||||
{
|
||||
currentTime = value;
|
||||
SetTimeToControl();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the time to control.
|
||||
/// </summary>
|
||||
private void SetTimeToControl()
|
||||
{
|
||||
this.txtYear.Text = currentTime.Year.ToString();
|
||||
this.txtMonth.Text = currentTime.Month.ToString().PadLeft(2, '0');
|
||||
this.txtDay.Text = currentTime.Day.ToString().PadLeft(2, '0');
|
||||
this.txtHour.Text = currentTime.Hour.ToString().PadLeft(2, '0');
|
||||
this.txtMinute.Text = currentTime.Minute.ToString().PadLeft(2, '0');
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCDatePickerExt" /> class.
|
||||
/// </summary>
|
||||
public UCDatePickerExt()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Load event of the UCDatePickerExt control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void UCDatePickerExt_Load(object sender, EventArgs e)
|
||||
{
|
||||
SetTimeToControl();
|
||||
panel1.Height = this.txtDay.Height;
|
||||
panel1.Height = this.txtHour.Height;
|
||||
SetEvent(this);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the event.
|
||||
/// </summary>
|
||||
/// <param name="c">The c.</param>
|
||||
private void SetEvent(Control c)
|
||||
{
|
||||
if (c != null)
|
||||
{
|
||||
c.MouseDown += c_MouseDown;
|
||||
foreach (Control item in c.Controls)
|
||||
{
|
||||
SetEvent(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the c control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
void c_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (m_selectPan == null)
|
||||
{
|
||||
m_selectPan = new UCDateTimeSelectPan();
|
||||
m_selectPan.SelectedTimeEvent += uc_SelectedTimeEvent;
|
||||
m_selectPan.CancelTimeEvent += m_selectPan_CancelTimeEvent;
|
||||
}
|
||||
m_selectPan.CurrentTime = currentTime;
|
||||
m_selectPan.TimeType = m_type;
|
||||
m_frmAnchor = new Forms.FrmAnchor(this, m_selectPan);
|
||||
m_frmAnchor.Show(this.FindForm());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the CancelTimeEvent event of the m_selectPan 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 m_selectPan_CancelTimeEvent(object sender, EventArgs e)
|
||||
{
|
||||
m_frmAnchor.Hide();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SelectedTimeEvent event of the uc 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 uc_SelectedTimeEvent(object sender, EventArgs e)
|
||||
{
|
||||
CurrentTime = m_selectPan.CurrentTime;
|
||||
m_frmAnchor.Hide();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the TextChanged event of the txtYear control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void txtYear_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (txtYear.Text.Length == 4)
|
||||
this.ActiveControl = txtMonth;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the TextChanged event of the txtMonth control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void txtMonth_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (txtMonth.Text.Length == 2 || txtMonth.Text.ToInt() >= 3)
|
||||
{
|
||||
this.ActiveControl = txtDay;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the TextChanged event of the txtDay control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void txtDay_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (m_type == DateTimePickerType.Date)
|
||||
return;
|
||||
if (txtDay.Text.Length == 2 || txtDay.Text.ToInt() >= 4)
|
||||
{
|
||||
this.ActiveControl = txtHour;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the TextChanged event of the txtHour control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void txtHour_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (txtHour.Text.Length == 2 || txtHour.Text.ToInt() >= 3)
|
||||
{
|
||||
this.ActiveControl = txtMinute;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Leave event of the txtYear control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void txtYear_Leave(object sender, EventArgs e)
|
||||
{
|
||||
if (txtYear.Text.ToInt() < 1990)
|
||||
{
|
||||
txtYear.Text = currentTime.Year.ToString();
|
||||
}
|
||||
currentTime = (txtYear.Text + currentTime.ToString("-MM-dd HH:mm:ss")).ToDate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Leave event of the txtMonth control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void txtMonth_Leave(object sender, EventArgs e)
|
||||
{
|
||||
if (txtMonth.Text.ToInt() < 1)
|
||||
{
|
||||
txtMonth.Text = currentTime.Month.ToString().PadLeft(2, '0');
|
||||
}
|
||||
txtMonth.Text = txtMonth.Text.PadLeft(2, '0');
|
||||
currentTime = (currentTime.ToString("yyyy-" + txtMonth.Text + "-dd HH:mm:ss")).ToDate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Leave event of the txtDay control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void txtDay_Leave(object sender, EventArgs e)
|
||||
{
|
||||
if (txtDay.Text.ToInt() < 1 || txtDay.Text.ToInt() > DateTime.DaysInMonth(currentTime.Year, currentTime.Month))
|
||||
{
|
||||
txtDay.Text = currentTime.Day.ToString().PadLeft(2, '0');
|
||||
}
|
||||
txtDay.Text = txtDay.Text.PadLeft(2, '0');
|
||||
currentTime = (currentTime.ToString("yyyy-MM-" + txtDay.Text + " HH:mm:ss")).ToDate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Leave event of the txtHour control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void txtHour_Leave(object sender, EventArgs e)
|
||||
{
|
||||
if (txtHour.Text.ToInt() < 1)
|
||||
{
|
||||
txtHour.Text = currentTime.Hour.ToString().PadLeft(2, '0');
|
||||
}
|
||||
txtHour.Text = txtHour.Text.PadLeft(2, '0');
|
||||
currentTime = (currentTime.ToString("yyyy-MM-dd " + txtHour.Text + ":mm:ss")).ToDate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Leave event of the txtMinute control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void txtMinute_Leave(object sender, EventArgs e)
|
||||
{
|
||||
if (txtMinute.Text.ToInt() < 1)
|
||||
{
|
||||
txtMinute.Text = currentTime.Minute.ToString().PadLeft(2, '0');
|
||||
}
|
||||
txtMinute.Text = txtMinute.Text.PadLeft(2, '0');
|
||||
currentTime = (currentTime.ToString("yyyy-MM-dd HH:" + txtMinute.Text + ":ss")).ToDate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the txt control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void txt_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
panel1.Height = (sender as TextBoxEx).Height;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/DateTime/UCDatePickerExt.resx
Normal file
120
UsingControl/HZHControls/Controls/DateTime/UCDatePickerExt.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
504
UsingControl/HZHControls/Controls/DateTime/UCDateTimeSelectPan.Designer.cs
generated
Normal file
504
UsingControl/HZHControls/Controls/DateTime/UCDateTimeSelectPan.Designer.cs
generated
Normal file
@@ -0,0 +1,504 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCDateTimeSelectPan.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCDateTimeSelectPan.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public partial class UCDateTimeSelectPan
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.btnMinute = new HZH_Controls.Controls.UCBtnExt();
|
||||
this.sp4 = new System.Windows.Forms.Panel();
|
||||
this.btnHour = new HZH_Controls.Controls.UCBtnExt();
|
||||
this.sp3 = new System.Windows.Forms.Panel();
|
||||
this.btnDay = new HZH_Controls.Controls.UCBtnExt();
|
||||
this.sp2 = new System.Windows.Forms.Panel();
|
||||
this.btnMonth = new HZH_Controls.Controls.UCBtnExt();
|
||||
this.sp1 = new System.Windows.Forms.Panel();
|
||||
this.btnYear = new HZH_Controls.Controls.UCBtnExt();
|
||||
this.panel2 = new System.Windows.Forms.Panel();
|
||||
this.btnCancel = new HZH_Controls.Controls.UCBtnExt();
|
||||
this.btnOk = new HZH_Controls.Controls.UCBtnExt();
|
||||
this.panMian = new System.Windows.Forms.Panel();
|
||||
this.panTime = new HZH_Controls.Controls.UCTimePanel();
|
||||
this.panRight = new System.Windows.Forms.Panel();
|
||||
this.panLeft = new System.Windows.Forms.Panel();
|
||||
this.ucSplitLine_H2 = new HZH_Controls.Controls.UCSplitLine_H();
|
||||
this.ucSplitLine_H1 = new HZH_Controls.Controls.UCSplitLine_H();
|
||||
this.panel3 = new System.Windows.Forms.Panel();
|
||||
this.panel1.SuspendLayout();
|
||||
this.panel2.SuspendLayout();
|
||||
this.panMian.SuspendLayout();
|
||||
this.panel3.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.btnMinute);
|
||||
this.panel1.Controls.Add(this.sp4);
|
||||
this.panel1.Controls.Add(this.btnHour);
|
||||
this.panel1.Controls.Add(this.sp3);
|
||||
this.panel1.Controls.Add(this.btnDay);
|
||||
this.panel1.Controls.Add(this.sp2);
|
||||
this.panel1.Controls.Add(this.btnMonth);
|
||||
this.panel1.Controls.Add(this.sp1);
|
||||
this.panel1.Controls.Add(this.btnYear);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.panel1.Location = new System.Drawing.Point(9, 9);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Padding = new System.Windows.Forms.Padding(10, 7, 10, 7);
|
||||
this.panel1.Size = new System.Drawing.Size(497, 45);
|
||||
this.panel1.TabIndex = 0;
|
||||
//
|
||||
// btnMinute
|
||||
//
|
||||
this.btnMinute.BackColor = System.Drawing.Color.Transparent;
|
||||
this.btnMinute.BtnBackColor = System.Drawing.Color.Transparent;
|
||||
this.btnMinute.BtnFont = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.btnMinute.BtnForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.btnMinute.BtnText = "30分";
|
||||
this.btnMinute.ConerRadius = 5;
|
||||
this.btnMinute.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnMinute.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.btnMinute.FillColor = System.Drawing.Color.White;
|
||||
this.btnMinute.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.btnMinute.IsRadius = true;
|
||||
this.btnMinute.IsShowRect = true;
|
||||
this.btnMinute.IsShowTips = false;
|
||||
this.btnMinute.Location = new System.Drawing.Point(406, 7);
|
||||
this.btnMinute.Margin = new System.Windows.Forms.Padding(3, 6, 3, 6);
|
||||
this.btnMinute.Name = "btnMinute";
|
||||
this.btnMinute.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.btnMinute.RectWidth = 1;
|
||||
this.btnMinute.Size = new System.Drawing.Size(80, 31);
|
||||
this.btnMinute.TabIndex = 1;
|
||||
this.btnMinute.TabStop = false;
|
||||
this.btnMinute.TipsText = "";
|
||||
this.btnMinute.BtnClick += new System.EventHandler(this.btnTime_BtnClick);
|
||||
//
|
||||
// sp4
|
||||
//
|
||||
this.sp4.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.sp4.Location = new System.Drawing.Point(387, 7);
|
||||
this.sp4.Name = "sp4";
|
||||
this.sp4.Size = new System.Drawing.Size(19, 31);
|
||||
this.sp4.TabIndex = 5;
|
||||
//
|
||||
// btnHour
|
||||
//
|
||||
this.btnHour.BackColor = System.Drawing.Color.Transparent;
|
||||
this.btnHour.BtnBackColor = System.Drawing.Color.Transparent;
|
||||
this.btnHour.BtnFont = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.btnHour.BtnForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.btnHour.BtnText = "12时";
|
||||
this.btnHour.ConerRadius = 5;
|
||||
this.btnHour.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnHour.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.btnHour.FillColor = System.Drawing.Color.White;
|
||||
this.btnHour.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.btnHour.IsRadius = true;
|
||||
this.btnHour.IsShowRect = true;
|
||||
this.btnHour.IsShowTips = false;
|
||||
this.btnHour.Location = new System.Drawing.Point(307, 7);
|
||||
this.btnHour.Margin = new System.Windows.Forms.Padding(3, 6, 3, 6);
|
||||
this.btnHour.Name = "btnHour";
|
||||
this.btnHour.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.btnHour.RectWidth = 1;
|
||||
this.btnHour.Size = new System.Drawing.Size(80, 31);
|
||||
this.btnHour.TabIndex = 1;
|
||||
this.btnHour.TabStop = false;
|
||||
this.btnHour.TipsText = "";
|
||||
this.btnHour.BtnClick += new System.EventHandler(this.btnTime_BtnClick);
|
||||
//
|
||||
// sp3
|
||||
//
|
||||
this.sp3.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.sp3.Location = new System.Drawing.Point(288, 7);
|
||||
this.sp3.Name = "sp3";
|
||||
this.sp3.Size = new System.Drawing.Size(19, 31);
|
||||
this.sp3.TabIndex = 4;
|
||||
//
|
||||
// btnDay
|
||||
//
|
||||
this.btnDay.BackColor = System.Drawing.Color.Transparent;
|
||||
this.btnDay.BtnBackColor = System.Drawing.Color.Transparent;
|
||||
this.btnDay.BtnFont = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.btnDay.BtnForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.btnDay.BtnText = "30日";
|
||||
this.btnDay.ConerRadius = 5;
|
||||
this.btnDay.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnDay.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.btnDay.FillColor = System.Drawing.Color.White;
|
||||
this.btnDay.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.btnDay.IsRadius = true;
|
||||
this.btnDay.IsShowRect = true;
|
||||
this.btnDay.IsShowTips = false;
|
||||
this.btnDay.Location = new System.Drawing.Point(208, 7);
|
||||
this.btnDay.Margin = new System.Windows.Forms.Padding(3, 6, 3, 6);
|
||||
this.btnDay.Name = "btnDay";
|
||||
this.btnDay.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.btnDay.RectWidth = 1;
|
||||
this.btnDay.Size = new System.Drawing.Size(80, 31);
|
||||
this.btnDay.TabIndex = 1;
|
||||
this.btnDay.TabStop = false;
|
||||
this.btnDay.TipsText = "";
|
||||
this.btnDay.BtnClick += new System.EventHandler(this.btnTime_BtnClick);
|
||||
//
|
||||
// sp2
|
||||
//
|
||||
this.sp2.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.sp2.Location = new System.Drawing.Point(189, 7);
|
||||
this.sp2.Name = "sp2";
|
||||
this.sp2.Size = new System.Drawing.Size(19, 31);
|
||||
this.sp2.TabIndex = 3;
|
||||
//
|
||||
// btnMonth
|
||||
//
|
||||
this.btnMonth.BackColor = System.Drawing.Color.Transparent;
|
||||
this.btnMonth.BtnBackColor = System.Drawing.Color.Transparent;
|
||||
this.btnMonth.BtnFont = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.btnMonth.BtnForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.btnMonth.BtnText = "12月";
|
||||
this.btnMonth.ConerRadius = 5;
|
||||
this.btnMonth.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnMonth.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.btnMonth.FillColor = System.Drawing.Color.White;
|
||||
this.btnMonth.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.btnMonth.IsRadius = true;
|
||||
this.btnMonth.IsShowRect = true;
|
||||
this.btnMonth.IsShowTips = false;
|
||||
this.btnMonth.Location = new System.Drawing.Point(109, 7);
|
||||
this.btnMonth.Margin = new System.Windows.Forms.Padding(3, 6, 3, 6);
|
||||
this.btnMonth.Name = "btnMonth";
|
||||
this.btnMonth.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.btnMonth.RectWidth = 1;
|
||||
this.btnMonth.Size = new System.Drawing.Size(80, 31);
|
||||
this.btnMonth.TabIndex = 1;
|
||||
this.btnMonth.TabStop = false;
|
||||
this.btnMonth.TipsText = "";
|
||||
this.btnMonth.BtnClick += new System.EventHandler(this.btnTime_BtnClick);
|
||||
//
|
||||
// sp1
|
||||
//
|
||||
this.sp1.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.sp1.Location = new System.Drawing.Point(90, 7);
|
||||
this.sp1.Name = "sp1";
|
||||
this.sp1.Size = new System.Drawing.Size(19, 31);
|
||||
this.sp1.TabIndex = 2;
|
||||
//
|
||||
// btnYear
|
||||
//
|
||||
this.btnYear.BackColor = System.Drawing.Color.Transparent;
|
||||
this.btnYear.BtnBackColor = System.Drawing.Color.Transparent;
|
||||
this.btnYear.BtnFont = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.btnYear.BtnForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.btnYear.BtnText = "2019年";
|
||||
this.btnYear.ConerRadius = 5;
|
||||
this.btnYear.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnYear.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.btnYear.FillColor = System.Drawing.Color.White;
|
||||
this.btnYear.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.btnYear.IsRadius = true;
|
||||
this.btnYear.IsShowRect = true;
|
||||
this.btnYear.IsShowTips = false;
|
||||
this.btnYear.Location = new System.Drawing.Point(10, 7);
|
||||
this.btnYear.Margin = new System.Windows.Forms.Padding(3, 6, 3, 6);
|
||||
this.btnYear.Name = "btnYear";
|
||||
this.btnYear.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.btnYear.RectWidth = 1;
|
||||
this.btnYear.Size = new System.Drawing.Size(80, 31);
|
||||
this.btnYear.TabIndex = 1;
|
||||
this.btnYear.TabStop = false;
|
||||
this.btnYear.TipsText = "";
|
||||
this.btnYear.BtnClick += new System.EventHandler(this.btnTime_BtnClick);
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
this.panel2.Controls.Add(this.btnCancel);
|
||||
this.panel2.Controls.Add(this.btnOk);
|
||||
this.panel2.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.panel2.Location = new System.Drawing.Point(9, 300);
|
||||
this.panel2.Name = "panel2";
|
||||
this.panel2.Size = new System.Drawing.Size(497, 54);
|
||||
this.panel2.TabIndex = 2;
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.btnCancel.BackColor = System.Drawing.Color.Transparent;
|
||||
this.btnCancel.BtnBackColor = System.Drawing.Color.Transparent;
|
||||
this.btnCancel.BtnFont = new System.Drawing.Font("微软雅黑", 13F);
|
||||
this.btnCancel.BtnForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.btnCancel.BtnText = "取 消";
|
||||
this.btnCancel.ConerRadius = 5;
|
||||
this.btnCancel.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnCancel.FillColor = System.Drawing.Color.White;
|
||||
this.btnCancel.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.btnCancel.IsRadius = true;
|
||||
this.btnCancel.IsShowRect = true;
|
||||
this.btnCancel.IsShowTips = false;
|
||||
this.btnCancel.Location = new System.Drawing.Point(89, 9);
|
||||
this.btnCancel.Margin = new System.Windows.Forms.Padding(3, 6, 3, 6);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.btnCancel.RectWidth = 1;
|
||||
this.btnCancel.Size = new System.Drawing.Size(129, 36);
|
||||
this.btnCancel.TabIndex = 2;
|
||||
this.btnCancel.TabStop = false;
|
||||
this.btnCancel.TipsText = "";
|
||||
this.btnCancel.BtnClick += new System.EventHandler(this.btnCancel_BtnClick);
|
||||
//
|
||||
// btnOk
|
||||
//
|
||||
this.btnOk.Anchor = System.Windows.Forms.AnchorStyles.None;
|
||||
this.btnOk.BackColor = System.Drawing.Color.Transparent;
|
||||
this.btnOk.BtnBackColor = System.Drawing.Color.Transparent;
|
||||
this.btnOk.BtnFont = new System.Drawing.Font("微软雅黑", 13F);
|
||||
this.btnOk.BtnForeColor = System.Drawing.Color.White;
|
||||
this.btnOk.BtnText = "确 定";
|
||||
this.btnOk.ConerRadius = 5;
|
||||
this.btnOk.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnOk.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.btnOk.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
this.btnOk.IsRadius = true;
|
||||
this.btnOk.IsShowRect = true;
|
||||
this.btnOk.IsShowTips = false;
|
||||
this.btnOk.Location = new System.Drawing.Point(307, 9);
|
||||
this.btnOk.Margin = new System.Windows.Forms.Padding(3, 6, 3, 6);
|
||||
this.btnOk.Name = "btnOk";
|
||||
this.btnOk.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(255)))), ((int)(((byte)(77)))), ((int)(((byte)(59)))));
|
||||
this.btnOk.RectWidth = 1;
|
||||
this.btnOk.Size = new System.Drawing.Size(129, 36);
|
||||
this.btnOk.TabIndex = 1;
|
||||
this.btnOk.TabStop = false;
|
||||
this.btnOk.TipsText = "";
|
||||
this.btnOk.BtnClick += new System.EventHandler(this.btnOk_BtnClick);
|
||||
//
|
||||
// panMian
|
||||
//
|
||||
this.panMian.Controls.Add(this.panTime);
|
||||
this.panMian.Controls.Add(this.panRight);
|
||||
this.panMian.Controls.Add(this.panLeft);
|
||||
this.panMian.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panMian.Location = new System.Drawing.Point(9, 55);
|
||||
this.panMian.Name = "panMian";
|
||||
this.panMian.Size = new System.Drawing.Size(497, 244);
|
||||
this.panMian.TabIndex = 4;
|
||||
//
|
||||
// panTime
|
||||
//
|
||||
this.panTime.BackColor = System.Drawing.Color.White;
|
||||
this.panTime.Column = 0;
|
||||
this.panTime.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panTime.FirstEvent = false;
|
||||
this.panTime.Location = new System.Drawing.Point(48, 0);
|
||||
this.panTime.Name = "panTime";
|
||||
this.panTime.Row = 0;
|
||||
this.panTime.SelectBtn = null;
|
||||
this.panTime.Size = new System.Drawing.Size(401, 244);
|
||||
this.panTime.Source = null;
|
||||
this.panTime.TabIndex = 0;
|
||||
//
|
||||
// panRight
|
||||
//
|
||||
this.panRight.BackgroundImage = global::HZH_Controls.Properties.Resources.dateRight;
|
||||
this.panRight.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.panRight.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.panRight.Location = new System.Drawing.Point(449, 0);
|
||||
this.panRight.Name = "panRight";
|
||||
this.panRight.Size = new System.Drawing.Size(48, 244);
|
||||
this.panRight.TabIndex = 2;
|
||||
this.panRight.Visible = false;
|
||||
this.panRight.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panRight_MouseDown);
|
||||
//
|
||||
// panLeft
|
||||
//
|
||||
this.panLeft.BackgroundImage = global::HZH_Controls.Properties.Resources.datetLeft;
|
||||
this.panLeft.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Center;
|
||||
this.panLeft.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.panLeft.Location = new System.Drawing.Point(0, 0);
|
||||
this.panLeft.Name = "panLeft";
|
||||
this.panLeft.Size = new System.Drawing.Size(48, 244);
|
||||
this.panLeft.TabIndex = 1;
|
||||
this.panLeft.Visible = false;
|
||||
this.panLeft.MouseDown += new System.Windows.Forms.MouseEventHandler(this.panLeft_MouseDown);
|
||||
//
|
||||
// ucSplitLine_H2
|
||||
//
|
||||
this.ucSplitLine_H2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(238)))), ((int)(((byte)(238)))));
|
||||
this.ucSplitLine_H2.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.ucSplitLine_H2.Location = new System.Drawing.Point(9, 299);
|
||||
this.ucSplitLine_H2.Name = "ucSplitLine_H2";
|
||||
this.ucSplitLine_H2.Size = new System.Drawing.Size(497, 1);
|
||||
this.ucSplitLine_H2.TabIndex = 3;
|
||||
this.ucSplitLine_H2.TabStop = false;
|
||||
//
|
||||
// ucSplitLine_H1
|
||||
//
|
||||
this.ucSplitLine_H1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(238)))), ((int)(((byte)(238)))));
|
||||
this.ucSplitLine_H1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.ucSplitLine_H1.Location = new System.Drawing.Point(9, 54);
|
||||
this.ucSplitLine_H1.Name = "ucSplitLine_H1";
|
||||
this.ucSplitLine_H1.Size = new System.Drawing.Size(497, 1);
|
||||
this.ucSplitLine_H1.TabIndex = 1;
|
||||
this.ucSplitLine_H1.TabStop = false;
|
||||
//
|
||||
// panel3
|
||||
//
|
||||
this.panel3.BackColor = System.Drawing.Color.White;
|
||||
this.panel3.Controls.Add(this.panMian);
|
||||
this.panel3.Controls.Add(this.ucSplitLine_H2);
|
||||
this.panel3.Controls.Add(this.panel2);
|
||||
this.panel3.Controls.Add(this.ucSplitLine_H1);
|
||||
this.panel3.Controls.Add(this.panel1);
|
||||
this.panel3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel3.Location = new System.Drawing.Point(1, 1);
|
||||
this.panel3.Name = "panel3";
|
||||
this.panel3.Padding = new System.Windows.Forms.Padding(9);
|
||||
this.panel3.Size = new System.Drawing.Size(515, 363);
|
||||
this.panel3.TabIndex = 5;
|
||||
//
|
||||
// UCDateTimeSelectPan
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(247)))), ((int)(((byte)(247)))), ((int)(((byte)(247)))));
|
||||
this.Controls.Add(this.panel3);
|
||||
this.Name = "UCDateTimeSelectPan";
|
||||
this.Padding = new System.Windows.Forms.Padding(1);
|
||||
this.Size = new System.Drawing.Size(517, 365);
|
||||
this.Load += new System.EventHandler(this.UCDateTimePickerExt_Load);
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel2.ResumeLayout(false);
|
||||
this.panMian.ResumeLayout(false);
|
||||
this.panel3.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The panel1
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
/// <summary>
|
||||
/// The uc split line h1
|
||||
/// </summary>
|
||||
private UCSplitLine_H ucSplitLine_H1;
|
||||
/// <summary>
|
||||
/// The panel2
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panel2;
|
||||
/// <summary>
|
||||
/// The uc split line h2
|
||||
/// </summary>
|
||||
private UCSplitLine_H ucSplitLine_H2;
|
||||
/// <summary>
|
||||
/// The pan mian
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panMian;
|
||||
/// <summary>
|
||||
/// The BTN minute
|
||||
/// </summary>
|
||||
private UCBtnExt btnMinute;
|
||||
/// <summary>
|
||||
/// The BTN day
|
||||
/// </summary>
|
||||
private UCBtnExt btnDay;
|
||||
/// <summary>
|
||||
/// The BTN hour
|
||||
/// </summary>
|
||||
private UCBtnExt btnHour;
|
||||
/// <summary>
|
||||
/// The BTN month
|
||||
/// </summary>
|
||||
private UCBtnExt btnMonth;
|
||||
/// <summary>
|
||||
/// The BTN year
|
||||
/// </summary>
|
||||
private UCBtnExt btnYear;
|
||||
/// <summary>
|
||||
/// The pan time
|
||||
/// </summary>
|
||||
private UCTimePanel panTime;
|
||||
/// <summary>
|
||||
/// The BTN cancel
|
||||
/// </summary>
|
||||
private UCBtnExt btnCancel;
|
||||
/// <summary>
|
||||
/// The BTN ok
|
||||
/// </summary>
|
||||
private UCBtnExt btnOk;
|
||||
/// <summary>
|
||||
/// The pan right
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panRight;
|
||||
/// <summary>
|
||||
/// The pan left
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panLeft;
|
||||
/// <summary>
|
||||
/// The SP4
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel sp4;
|
||||
/// <summary>
|
||||
/// The SP3
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel sp3;
|
||||
/// <summary>
|
||||
/// The SP2
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel sp2;
|
||||
/// <summary>
|
||||
/// The SP1
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel sp1;
|
||||
/// <summary>
|
||||
/// The panel3
|
||||
/// </summary>
|
||||
private System.Windows.Forms.Panel panel3;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,398 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCDateTimeSelectPan.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCDateTimeSelectPan.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
[ToolboxItem(false)]
|
||||
public partial class UCDateTimeSelectPan : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when [selected time event].
|
||||
/// </summary>
|
||||
[Description("确定事件"), Category("自定义")]
|
||||
public event EventHandler SelectedTimeEvent;
|
||||
/// <summary>
|
||||
/// Occurs when [cancel time event].
|
||||
/// </summary>
|
||||
[Description("取消事件"), Category("自定义")]
|
||||
public event EventHandler CancelTimeEvent;
|
||||
/// <summary>
|
||||
/// The automatic select next
|
||||
/// </summary>
|
||||
private bool autoSelectNext = true;
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether [automatic select next].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [automatic select next]; otherwise, <c>false</c>.</value>
|
||||
[Description("自动选中下一级"), Category("自定义")]
|
||||
public bool AutoSelectNext
|
||||
{
|
||||
get { return autoSelectNext; }
|
||||
set { autoSelectNext = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m dt
|
||||
/// </summary>
|
||||
DateTime m_dt = DateTime.Now;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the current time.
|
||||
/// </summary>
|
||||
/// <value>The current time.</value>
|
||||
public DateTime CurrentTime
|
||||
{
|
||||
get { return m_dt; }
|
||||
set
|
||||
{
|
||||
m_dt = value;
|
||||
SetTimeToControl();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The m this BTN
|
||||
/// </summary>
|
||||
UCBtnExt m_thisBtn = null;
|
||||
|
||||
/// <summary>
|
||||
/// The m type
|
||||
/// </summary>
|
||||
DateTimePickerType m_type = DateTimePickerType.DateTime;
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the time.
|
||||
/// </summary>
|
||||
/// <value>The type of the time.</value>
|
||||
[Description("时间类型"), Category("自定义")]
|
||||
public DateTimePickerType TimeType
|
||||
{
|
||||
get { return m_type; }
|
||||
set { m_type = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCDateTimeSelectPan" /> class.
|
||||
/// </summary>
|
||||
public UCDateTimeSelectPan()
|
||||
{
|
||||
InitializeComponent();
|
||||
panTime.SelectSourceEvent += panTime_SelectSourceEvent;
|
||||
this.TabStop = false;
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCDateTimeSelectPan" /> class.
|
||||
/// </summary>
|
||||
/// <param name="dt">The dt.</param>
|
||||
public UCDateTimeSelectPan(DateTime dt)
|
||||
{
|
||||
m_dt = dt;
|
||||
InitializeComponent();
|
||||
panTime.SelectSourceEvent += panTime_SelectSourceEvent;
|
||||
this.TabStop = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SelectSourceEvent event of the panTime 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 panTime_SelectSourceEvent(object sender, EventArgs e)
|
||||
{
|
||||
string strKey = sender.ToString();
|
||||
if (m_thisBtn == btnYear)
|
||||
{
|
||||
m_dt = (strKey + "-" + m_dt.Month + "-" + m_dt.Day + " " + m_dt.Hour + ":" + m_dt.Minute).ToDate();
|
||||
}
|
||||
else if (m_thisBtn == btnMonth)
|
||||
{
|
||||
m_dt = (m_dt.Year + "-" + strKey + "-" + m_dt.Day + " " + m_dt.Hour + ":" + m_dt.Minute).ToDate();
|
||||
}
|
||||
else if (m_thisBtn == btnDay)
|
||||
{
|
||||
m_dt = (m_dt.Year + "-" + m_dt.Month + "-" + strKey + " " + m_dt.Hour + ":" + m_dt.Minute).ToDate();
|
||||
}
|
||||
else if (m_thisBtn == btnHour)
|
||||
{
|
||||
m_dt = (m_dt.Year + "-" + m_dt.Month + "-" + m_dt.Day + " " + strKey + ":" + m_dt.Minute).ToDate();
|
||||
}
|
||||
else if (m_thisBtn == btnMinute)
|
||||
{
|
||||
m_dt = (m_dt.Year + "-" + m_dt.Month + "-" + m_dt.Day + " " + m_dt.Hour + ":" + strKey).ToDate();
|
||||
}
|
||||
SetTimeToControl();
|
||||
if (this.Visible)
|
||||
{
|
||||
if (autoSelectNext)
|
||||
{
|
||||
if (m_thisBtn == btnYear)
|
||||
{
|
||||
SetSelectType(btnMonth);
|
||||
}
|
||||
else if (m_thisBtn == btnMonth)
|
||||
{
|
||||
SetSelectType(btnDay);
|
||||
}
|
||||
else if (m_thisBtn == btnDay)
|
||||
{
|
||||
if (m_type == DateTimePickerType.DateTime || m_type == DateTimePickerType.Time)
|
||||
SetSelectType(btnHour);
|
||||
}
|
||||
else if (m_thisBtn == btnHour)
|
||||
{
|
||||
SetSelectType(btnMinute);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Load event of the UCDateTimePickerExt control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void UCDateTimePickerExt_Load(object sender, EventArgs e)
|
||||
{
|
||||
SetTimeToControl();
|
||||
|
||||
if (m_type == DateTimePickerType.Date)
|
||||
{
|
||||
btnHour.Visible = false;
|
||||
btnMinute.Visible = false;
|
||||
}
|
||||
else if (m_type == DateTimePickerType.Time)
|
||||
{
|
||||
btnYear.Visible = false;
|
||||
btnMonth.Visible = false;
|
||||
btnDay.Visible = false;
|
||||
sp1.Visible = false;
|
||||
sp2.Visible = false;
|
||||
sp3.Visible = false;
|
||||
}
|
||||
if ((int)m_type <= 2)
|
||||
{
|
||||
SetSelectType(btnYear);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetSelectType(btnHour);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the time to control.
|
||||
/// </summary>
|
||||
private void SetTimeToControl()
|
||||
{
|
||||
btnYear.Tag = m_dt.Year;
|
||||
btnYear.BtnText = m_dt.Year + "年";
|
||||
btnMonth.Tag = m_dt.Month;
|
||||
btnMonth.BtnText = m_dt.Month.ToString().PadLeft(2, '0') + "月";
|
||||
btnDay.Tag = m_dt.Day;
|
||||
btnDay.BtnText = m_dt.Day.ToString().PadLeft(2, '0') + "日";
|
||||
btnHour.Tag = m_dt.Hour;
|
||||
btnHour.BtnText = m_dt.Hour.ToString().PadLeft(2, '0') + "时";
|
||||
btnMinute.Tag = m_dt.Minute;
|
||||
btnMinute.BtnText = m_dt.Minute.ToString().PadLeft(2, '0') + "分";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the type of the select.
|
||||
/// </summary>
|
||||
/// <param name="btn">The BTN.</param>
|
||||
private void SetSelectType(UCBtnExt btn)
|
||||
{
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(this, true);
|
||||
if (m_thisBtn != null)
|
||||
{
|
||||
m_thisBtn.FillColor = Color.White;
|
||||
m_thisBtn.BtnForeColor = Color.FromArgb(255, 77, 59);
|
||||
}
|
||||
m_thisBtn = btn;
|
||||
if (m_thisBtn != null)
|
||||
{
|
||||
m_thisBtn.FillColor = Color.FromArgb(255, 77, 59);
|
||||
m_thisBtn.BtnForeColor = Color.White;
|
||||
|
||||
List<KeyValuePair<string, string>> lstSource = new List<KeyValuePair<string, string>>();
|
||||
panTime.SuspendLayout();
|
||||
|
||||
if (btn == btnYear)
|
||||
{
|
||||
panLeft.Visible = true;
|
||||
panRight.Visible = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
panLeft.Visible = false;
|
||||
panRight.Visible = false;
|
||||
}
|
||||
|
||||
if (btn == btnYear)
|
||||
{
|
||||
panTime.Row = 5;
|
||||
panTime.Column = 6;
|
||||
int intYear = m_dt.Year - m_dt.Year % 30;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
lstSource.Add(new KeyValuePair<string, string>((intYear + i).ToString(), (intYear + i).ToString()));
|
||||
}
|
||||
}
|
||||
else if (btn == btnMonth)
|
||||
{
|
||||
panTime.Row = 3;
|
||||
panTime.Column = 4;
|
||||
for (int i = 1; i <= 12; i++)
|
||||
{
|
||||
lstSource.Add(new KeyValuePair<string, string>(i.ToString(), i.ToString().PadLeft(2, '0') + "月\r\n" + (("2019-" + i + "-01").ToDate().ToString("MMM", System.Globalization.CultureInfo.CreateSpecificCulture("en-GB")))));
|
||||
}
|
||||
}
|
||||
else if (btn == btnDay)
|
||||
{
|
||||
panTime.Column = 7;
|
||||
int intDayCount = DateTime.DaysInMonth(m_dt.Year, m_dt.Month);
|
||||
int intIndex = (int)(m_dt.DayOfWeek);
|
||||
panTime.Row = (intDayCount + intIndex) / 7 + ((intDayCount + intIndex) % 7 != 0 ? 1 : 0);
|
||||
for (int i = 0; i < intIndex; i++)
|
||||
{
|
||||
lstSource.Add(new KeyValuePair<string, string>("", ""));
|
||||
}
|
||||
for (int i = 1; i <= intDayCount; i++)
|
||||
{
|
||||
lstSource.Add(new KeyValuePair<string, string>(i.ToString(), i.ToString().PadLeft(2, '0')));
|
||||
}
|
||||
}
|
||||
else if (btn == btnHour)
|
||||
{
|
||||
panTime.Row = 4;
|
||||
panTime.Column = 6;
|
||||
for (int i = 0; i <= 24; i++)
|
||||
{
|
||||
lstSource.Add(new KeyValuePair<string, string>(i.ToString(), i.ToString() + "时"));
|
||||
}
|
||||
}
|
||||
else if (btn == btnMinute)
|
||||
{
|
||||
panTime.Row = 5;
|
||||
panTime.Column = 12;
|
||||
for (int i = 0; i <= 60; i++)
|
||||
{
|
||||
lstSource.Add(new KeyValuePair<string, string>(i.ToString(), i.ToString().PadLeft(2, '0')));
|
||||
}
|
||||
}
|
||||
panTime.Source = lstSource;
|
||||
panTime.SetSelect(btn.Tag.ToStringExt());
|
||||
panTime.ResumeLayout(true);
|
||||
|
||||
// panTime.Enabled = true;
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(this, false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the BtnClick event of the btnTime control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void btnTime_BtnClick(object sender, EventArgs e)
|
||||
{
|
||||
SetSelectType((UCBtnExt)sender);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the panLeft control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void panLeft_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
List<KeyValuePair<string, string>> lstSource = new List<KeyValuePair<string, string>>();
|
||||
int intYear = this.panTime.Source[0].Key.ToInt() - this.panTime.Source[0].Key.ToInt() % 30 - 30;
|
||||
panTime.SuspendLayout();
|
||||
panTime.Row = 5;
|
||||
panTime.Column = 6;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
lstSource.Add(new KeyValuePair<string, string>((intYear + i).ToString(), (intYear + i).ToString()));
|
||||
}
|
||||
panTime.Source = lstSource;
|
||||
panTime.SetSelect(btnYear.Tag.ToStringExt());
|
||||
panTime.ResumeLayout(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the panRight control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void panRight_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
List<KeyValuePair<string, string>> lstSource = new List<KeyValuePair<string, string>>();
|
||||
int intYear = this.panTime.Source[0].Key.ToInt() - this.panTime.Source[0].Key.ToInt() % 30 + 30;
|
||||
panTime.SuspendLayout();
|
||||
panTime.Row = 5;
|
||||
panTime.Column = 6;
|
||||
for (int i = 0; i < 30; i++)
|
||||
{
|
||||
lstSource.Add(new KeyValuePair<string, string>((intYear + i).ToString(), (intYear + i).ToString()));
|
||||
}
|
||||
panTime.Source = lstSource;
|
||||
panTime.SetSelect(btnYear.Tag.ToStringExt());
|
||||
panTime.ResumeLayout(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the BtnClick event of the btnOk control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void btnOk_BtnClick(object sender, EventArgs e)
|
||||
{
|
||||
if (SelectedTimeEvent != null)
|
||||
SelectedTimeEvent(m_dt, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the BtnClick event of the btnCancel control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void btnCancel_BtnClick(object sender, EventArgs e)
|
||||
{
|
||||
if (CancelTimeEvent != null)
|
||||
{
|
||||
CancelTimeEvent(null, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
154
UsingControl/HZHControls/Controls/DateTime/UCTimePanel.Designer.cs
generated
Normal file
154
UsingControl/HZHControls/Controls/DateTime/UCTimePanel.Designer.cs
generated
Normal file
@@ -0,0 +1,154 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCTimePanel.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCTimePanel.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
partial class UCTimePanel
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.panMain = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.ucSplitLine_V1 = new HZH_Controls.Controls.UCSplitLine_V();
|
||||
this.ucSplitLine_V2 = new HZH_Controls.Controls.UCSplitLine_V();
|
||||
this.ucSplitLine_H1 = new HZH_Controls.Controls.UCSplitLine_H();
|
||||
this.ucSplitLine_H2 = new HZH_Controls.Controls.UCSplitLine_H();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panMain
|
||||
//
|
||||
this.panMain.ColumnCount = 1;
|
||||
this.panMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.panMain.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panMain.Location = new System.Drawing.Point(1, 1);
|
||||
this.panMain.Name = "panMain";
|
||||
this.panMain.RowCount = 1;
|
||||
this.panMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.panMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.panMain.Size = new System.Drawing.Size(99, 228);
|
||||
this.panMain.TabIndex = 0;
|
||||
//
|
||||
// ucSplitLine_V1
|
||||
//
|
||||
this.ucSplitLine_V1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(238)))), ((int)(((byte)(238)))));
|
||||
this.ucSplitLine_V1.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.ucSplitLine_V1.Location = new System.Drawing.Point(0, 0);
|
||||
this.ucSplitLine_V1.Name = "ucSplitLine_V1";
|
||||
this.ucSplitLine_V1.Size = new System.Drawing.Size(1, 230);
|
||||
this.ucSplitLine_V1.TabIndex = 0;
|
||||
this.ucSplitLine_V1.TabStop = false;
|
||||
this.ucSplitLine_V1.Visible = false;
|
||||
//
|
||||
// ucSplitLine_V2
|
||||
//
|
||||
this.ucSplitLine_V2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(238)))), ((int)(((byte)(238)))));
|
||||
this.ucSplitLine_V2.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.ucSplitLine_V2.Location = new System.Drawing.Point(100, 0);
|
||||
this.ucSplitLine_V2.Name = "ucSplitLine_V2";
|
||||
this.ucSplitLine_V2.Size = new System.Drawing.Size(1, 230);
|
||||
this.ucSplitLine_V2.TabIndex = 1;
|
||||
this.ucSplitLine_V2.TabStop = false;
|
||||
this.ucSplitLine_V2.Visible = false;
|
||||
//
|
||||
// ucSplitLine_H1
|
||||
//
|
||||
this.ucSplitLine_H1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(238)))), ((int)(((byte)(238)))));
|
||||
this.ucSplitLine_H1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.ucSplitLine_H1.Location = new System.Drawing.Point(1, 0);
|
||||
this.ucSplitLine_H1.Name = "ucSplitLine_H1";
|
||||
this.ucSplitLine_H1.Size = new System.Drawing.Size(99, 1);
|
||||
this.ucSplitLine_H1.TabIndex = 0;
|
||||
this.ucSplitLine_H1.TabStop = false;
|
||||
this.ucSplitLine_H1.Visible = false;
|
||||
//
|
||||
// ucSplitLine_H2
|
||||
//
|
||||
this.ucSplitLine_H2.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(238)))), ((int)(((byte)(238)))), ((int)(((byte)(238)))));
|
||||
this.ucSplitLine_H2.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.ucSplitLine_H2.Location = new System.Drawing.Point(1, 229);
|
||||
this.ucSplitLine_H2.Name = "ucSplitLine_H2";
|
||||
this.ucSplitLine_H2.Size = new System.Drawing.Size(99, 1);
|
||||
this.ucSplitLine_H2.TabIndex = 2;
|
||||
this.ucSplitLine_H2.TabStop = false;
|
||||
this.ucSplitLine_H2.Visible = false;
|
||||
//
|
||||
// UCTimePanel
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.Controls.Add(this.panMain);
|
||||
this.Controls.Add(this.ucSplitLine_H2);
|
||||
this.Controls.Add(this.ucSplitLine_H1);
|
||||
this.Controls.Add(this.ucSplitLine_V2);
|
||||
this.Controls.Add(this.ucSplitLine_V1);
|
||||
this.Name = "UCTimePanel";
|
||||
this.Size = new System.Drawing.Size(101, 230);
|
||||
this.Load += new System.EventHandler(this.UCTimePanel_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The pan main
|
||||
/// </summary>
|
||||
private System.Windows.Forms.TableLayoutPanel panMain;
|
||||
/// <summary>
|
||||
/// The uc split line v1
|
||||
/// </summary>
|
||||
private UCSplitLine_V ucSplitLine_V1;
|
||||
/// <summary>
|
||||
/// The uc split line v2
|
||||
/// </summary>
|
||||
private UCSplitLine_V ucSplitLine_V2;
|
||||
/// <summary>
|
||||
/// The uc split line h1
|
||||
/// </summary>
|
||||
private UCSplitLine_H ucSplitLine_H1;
|
||||
/// <summary>
|
||||
/// The uc split line h2
|
||||
/// </summary>
|
||||
private UCSplitLine_H ucSplitLine_H2;
|
||||
}
|
||||
}
|
||||
317
UsingControl/HZHControls/Controls/DateTime/UCTimePanel.cs
Normal file
317
UsingControl/HZHControls/Controls/DateTime/UCTimePanel.cs
Normal file
@@ -0,0 +1,317 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCTimePanel.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCTimePanel.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
[ToolboxItem(false)]
|
||||
public partial class UCTimePanel : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when [select source event].
|
||||
/// </summary>
|
||||
public event EventHandler SelectSourceEvent;
|
||||
/// <summary>
|
||||
/// The source
|
||||
/// </summary>
|
||||
private List<KeyValuePair<string, string>> source = null;
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether [first event].
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [first event]; otherwise, <c>false</c>.</value>
|
||||
public bool FirstEvent { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the source.
|
||||
/// </summary>
|
||||
/// <value>The source.</value>
|
||||
public List<KeyValuePair<string, string>> Source
|
||||
{
|
||||
get { return source; }
|
||||
set
|
||||
{
|
||||
source = value;
|
||||
SetSource(value);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The is show border
|
||||
/// </summary>
|
||||
private bool _IsShowBorder = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is show border.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is show border; otherwise, <c>false</c>.</value>
|
||||
public bool IsShowBorder
|
||||
{
|
||||
get { return _IsShowBorder; }
|
||||
set
|
||||
{
|
||||
_IsShowBorder = value;
|
||||
ucSplitLine_H1.Visible = value;
|
||||
ucSplitLine_H2.Visible = value;
|
||||
ucSplitLine_V1.Visible = value;
|
||||
ucSplitLine_V2.Visible = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The select BTN
|
||||
/// </summary>
|
||||
UCBtnExt selectBtn;
|
||||
/// <summary>
|
||||
/// 选中按钮
|
||||
/// </summary>
|
||||
/// <value>The select BTN.</value>
|
||||
public UCBtnExt SelectBtn
|
||||
{
|
||||
get { return selectBtn; }
|
||||
set
|
||||
{
|
||||
if (selectBtn != null && !selectBtn.IsDisposed)
|
||||
{
|
||||
selectBtn.FillColor = System.Drawing.Color.White;
|
||||
selectBtn.RectColor = System.Drawing.Color.White;
|
||||
selectBtn.BtnForeColor = System.Drawing.Color.FromArgb(66, 66, 66);
|
||||
}
|
||||
bool blnEvent = FirstEvent ? true : (selectBtn != null);
|
||||
selectBtn = value;
|
||||
if (value != null)
|
||||
{
|
||||
selectBtn.FillColor = System.Drawing.Color.FromArgb(255, 77, 59);
|
||||
selectBtn.RectColor = System.Drawing.Color.FromArgb(255, 77, 59);
|
||||
selectBtn.BtnForeColor = System.Drawing.Color.White;
|
||||
if (blnEvent && SelectSourceEvent != null)
|
||||
SelectSourceEvent(selectBtn.Tag.ToStringExt(), null);
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCTimePanel" /> class.
|
||||
/// </summary>
|
||||
public UCTimePanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
this.SizeChanged += UCTimePanel_SizeChanged;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the UCTimePanel 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 UCTimePanel_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The row
|
||||
/// </summary>
|
||||
private int row = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the row.
|
||||
/// </summary>
|
||||
/// <value>The row.</value>
|
||||
public int Row
|
||||
{
|
||||
get { return row; }
|
||||
set
|
||||
{
|
||||
row = value;
|
||||
ReloadPanel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The column
|
||||
/// </summary>
|
||||
private int column = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the column.
|
||||
/// </summary>
|
||||
/// <value>The column.</value>
|
||||
public int Column
|
||||
{
|
||||
get { return column; }
|
||||
set
|
||||
{
|
||||
column = value;
|
||||
ReloadPanel();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Load event of the UCTimePanel control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
private void UCTimePanel_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#region 设置面板数据源
|
||||
/// <summary>
|
||||
/// 功能描述:设置面板数据源
|
||||
/// 作 者:HZH
|
||||
/// 创建日期:2019-06-25 15:02:15
|
||||
/// 任务编号:POS
|
||||
/// </summary>
|
||||
/// <param name="lstSource">lstSource</param>
|
||||
public void SetSource(List<KeyValuePair<string, string>> lstSource)
|
||||
{
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(this, true);
|
||||
if (row <= 0 || column <= 0)
|
||||
return;
|
||||
if (Source != lstSource)
|
||||
Source = lstSource;
|
||||
int index = 0;
|
||||
SelectBtn = null;
|
||||
foreach (UCBtnExt btn in this.panMain.Controls)
|
||||
{
|
||||
if (lstSource != null && index < lstSource.Count)
|
||||
{
|
||||
btn.BtnText = lstSource[index].Value;
|
||||
btn.Tag = lstSource[index].Key;
|
||||
index++;
|
||||
}
|
||||
else
|
||||
{
|
||||
btn.BtnText = "";
|
||||
btn.Tag = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(this, false);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
/// <summary>
|
||||
/// 设置选中项
|
||||
/// </summary>
|
||||
/// <param name="strKey">The string key.</param>
|
||||
public void SetSelect(string strKey)
|
||||
{
|
||||
foreach (UCBtnExt item in this.panMain.Controls)
|
||||
{
|
||||
if (item.Tag != null && item.Tag.ToStringExt() == strKey)
|
||||
{
|
||||
SelectBtn = item;
|
||||
return;
|
||||
}
|
||||
}
|
||||
SelectBtn = new UCBtnExt();
|
||||
}
|
||||
|
||||
#region 重置面板
|
||||
/// <summary>
|
||||
/// 功能描述:重置面板
|
||||
/// 作 者:HZH
|
||||
/// 创建日期:2019-06-25 15:02:05
|
||||
/// 任务编号:POS
|
||||
/// </summary>
|
||||
public void ReloadPanel()
|
||||
{
|
||||
if (row <= 0 || column <= 0)
|
||||
return;
|
||||
SelectBtn = null;
|
||||
this.panMain.Controls.Clear();
|
||||
this.panMain.ColumnCount = column;
|
||||
this.panMain.ColumnStyles.Clear();
|
||||
for (int i = 0; i < column; i++)
|
||||
{
|
||||
this.panMain.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
}
|
||||
|
||||
this.panMain.RowCount = row;
|
||||
this.panMain.RowStyles.Clear();
|
||||
for (int i = 0; i < row; i++)
|
||||
{
|
||||
this.panMain.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
}
|
||||
|
||||
for (int i = 0; i < row; i++)
|
||||
{
|
||||
for (int j = 0; j < column; j++)
|
||||
{
|
||||
UCBtnExt btn = new UCBtnExt();
|
||||
btn.BackColor = System.Drawing.Color.Transparent;
|
||||
btn.BtnBackColor = System.Drawing.Color.Transparent;
|
||||
btn.BtnFont = new System.Drawing.Font("微软雅黑", 13F);
|
||||
btn.BtnForeColor = System.Drawing.Color.FromArgb(66, 66, 66);
|
||||
btn.ConerRadius = 5;
|
||||
btn.Dock = DockStyle.Fill;
|
||||
btn.FillColor = System.Drawing.Color.White;
|
||||
btn.Font = new System.Drawing.Font("微软雅黑", 15F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel);
|
||||
btn.Cursor = Cursor.Current;
|
||||
btn.IsShowRect = true;
|
||||
btn.IsRadius = true;
|
||||
btn.IsShowTips = false;
|
||||
btn.Name = "btn_" + i + "_" + j;
|
||||
btn.RectColor = System.Drawing.Color.White;
|
||||
btn.RectWidth = 1;
|
||||
btn.Width = this.Width;
|
||||
btn.TabIndex = 0;
|
||||
btn.TipsText = "";
|
||||
btn.BtnClick += btn_BtnClick;
|
||||
this.panMain.Controls.Add(btn, j, i);
|
||||
}
|
||||
}
|
||||
|
||||
if (Source != null)
|
||||
{
|
||||
SetSource(Source);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Handles the BtnClick event of the btn 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 btn_BtnClick(object sender, EventArgs e)
|
||||
{
|
||||
var btn = (UCBtnExt)sender;
|
||||
if (btn.Tag == null)
|
||||
return;
|
||||
SelectBtn = btn;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/DateTime/UCTimePanel.resx
Normal file
120
UsingControl/HZHControls/Controls/DateTime/UCTimePanel.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -0,0 +1,343 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-10
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCArrow.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 UCArrow.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public class UCArrow : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The arrow color
|
||||
/// </summary>
|
||||
private Color arrowColor = Color.FromArgb(255, 77, 59);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the arrow.
|
||||
/// </summary>
|
||||
/// <value>The color of the arrow.</value>
|
||||
[Description("箭头颜色"), Category("自定义")]
|
||||
public Color ArrowColor
|
||||
{
|
||||
get { return arrowColor; }
|
||||
set
|
||||
{
|
||||
arrowColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The border color
|
||||
/// </summary>
|
||||
private Color? borderColor = null;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the border.
|
||||
/// </summary>
|
||||
/// <value>The color of the border.</value>
|
||||
[Description("箭头边框颜色,为空则无边框"), Category("自定义")]
|
||||
public Color? BorderColor
|
||||
{
|
||||
get { return borderColor; }
|
||||
set
|
||||
{
|
||||
borderColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The direction
|
||||
/// </summary>
|
||||
private ArrowDirection direction = ArrowDirection.Right;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the direction.
|
||||
/// </summary>
|
||||
/// <value>The direction.</value>
|
||||
[Description("箭头方向"), Category("自定义")]
|
||||
public ArrowDirection Direction
|
||||
{
|
||||
get { return direction; }
|
||||
set
|
||||
{
|
||||
direction = value;
|
||||
ResetPath();
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取或设置控件显示的文字的字体。
|
||||
/// </summary>
|
||||
/// <value>The font.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
||||
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
public override Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Font = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取或设置控件的前景色。
|
||||
/// </summary>
|
||||
/// <value>The color of the fore.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
public override Color ForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ForeColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The text
|
||||
/// </summary>
|
||||
private string text;
|
||||
/// <summary>
|
||||
/// Gets or sets the text.
|
||||
/// </summary>
|
||||
/// <value>The text.</value>
|
||||
[Bindable(true)]
|
||||
[Browsable(true)]
|
||||
[DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)]
|
||||
[EditorBrowsable(EditorBrowsableState.Always)]
|
||||
[Localizable(true)]
|
||||
[Description("箭头文字"), Category("自定义")]
|
||||
public override string Text
|
||||
{
|
||||
get
|
||||
{
|
||||
return text;
|
||||
}
|
||||
set
|
||||
{
|
||||
text = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The m path
|
||||
/// </summary>
|
||||
GraphicsPath m_path;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCArrow" /> class.
|
||||
/// </summary>
|
||||
public UCArrow()
|
||||
{
|
||||
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.ForeColor = Color.White;
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.SizeChanged += UCArrow_SizeChanged;
|
||||
this.Size = new Size(100, 50);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the UCArrow 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 UCArrow_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
ResetPath();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the path.
|
||||
/// </summary>
|
||||
private void ResetPath()
|
||||
{
|
||||
Point[] ps = null;
|
||||
switch (direction)
|
||||
{
|
||||
case ArrowDirection.Left:
|
||||
ps = new Point[]
|
||||
{
|
||||
new Point(0,this.Height/2),
|
||||
new Point(40,0),
|
||||
new Point(40,this.Height/4),
|
||||
new Point(this.Width-1,this.Height/4),
|
||||
new Point(this.Width-1,this.Height-this.Height/4),
|
||||
new Point(40,this.Height-this.Height/4),
|
||||
new Point(40,this.Height),
|
||||
new Point(0,this.Height/2)
|
||||
};
|
||||
break;
|
||||
case ArrowDirection.Right:
|
||||
ps = new Point[]
|
||||
{
|
||||
new Point(0,this.Height/4),
|
||||
new Point(this.Width-40,this.Height/4),
|
||||
new Point(this.Width-40,0),
|
||||
new Point(this.Width-1,this.Height/2),
|
||||
new Point(this.Width-40,this.Height),
|
||||
new Point(this.Width-40,this.Height-this.Height/4),
|
||||
new Point(0,this.Height-this.Height/4),
|
||||
new Point(0,this.Height/4)
|
||||
};
|
||||
break;
|
||||
case ArrowDirection.Top:
|
||||
ps = new Point[]
|
||||
{
|
||||
new Point(this.Width/2,0),
|
||||
new Point(this.Width,40),
|
||||
new Point(this.Width-this.Width/4,40),
|
||||
new Point(this.Width-this.Width/4,this.Height-1),
|
||||
new Point(this.Width/4,this.Height-1),
|
||||
new Point(this.Width/4,40),
|
||||
new Point(0,40),
|
||||
new Point(this.Width/2,0),
|
||||
};
|
||||
break;
|
||||
case ArrowDirection.Bottom:
|
||||
ps = new Point[]
|
||||
{
|
||||
new Point(this.Width-this.Width/4,0),
|
||||
new Point(this.Width-this.Width/4,this.Height-40),
|
||||
new Point(this.Width,this.Height-40),
|
||||
new Point(this.Width/2,this.Height-1),
|
||||
new Point(0,this.Height-40),
|
||||
new Point(this.Width/4,this.Height-40),
|
||||
new Point(this.Width/4,0),
|
||||
new Point(this.Width-this.Width/4,0),
|
||||
};
|
||||
break;
|
||||
case ArrowDirection.Left_Right:
|
||||
ps = new Point[]
|
||||
{
|
||||
new Point(0,this.Height/2),
|
||||
new Point(40,0),
|
||||
new Point(40,this.Height/4),
|
||||
new Point(this.Width-40,this.Height/4),
|
||||
new Point(this.Width-40,0),
|
||||
new Point(this.Width-1,this.Height/2),
|
||||
new Point(this.Width-40,this.Height),
|
||||
new Point(this.Width-40,this.Height-this.Height/4),
|
||||
new Point(40,this.Height-this.Height/4),
|
||||
new Point(40,this.Height),
|
||||
new Point(0,this.Height/2),
|
||||
};
|
||||
break;
|
||||
case ArrowDirection.Top_Bottom:
|
||||
ps = new Point[]
|
||||
{
|
||||
new Point(this.Width/2,0),
|
||||
new Point(this.Width,40),
|
||||
new Point(this.Width-this.Width/4,40),
|
||||
new Point(this.Width-this.Width/4,this.Height-40),
|
||||
new Point(this.Width,this.Height-40),
|
||||
new Point(this.Width/2,this.Height-1),
|
||||
new Point(0,this.Height-40),
|
||||
new Point(this.Width/4,this.Height-40),
|
||||
new Point(this.Width/4,40),
|
||||
new Point(0,40),
|
||||
new Point(this.Width/2,0),
|
||||
};
|
||||
break;
|
||||
}
|
||||
m_path = new GraphicsPath();
|
||||
m_path.AddLines(ps);
|
||||
m_path.CloseAllFigures();
|
||||
}
|
||||
|
||||
/// <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);
|
||||
var g = e.Graphics;
|
||||
g.SetGDIHigh();
|
||||
base.Region = new Region(m_path);
|
||||
|
||||
g.FillPath(new SolidBrush(arrowColor), m_path);
|
||||
|
||||
if (borderColor != null && borderColor != Color.Empty)
|
||||
g.DrawPath(new Pen(new SolidBrush(borderColor.Value)), m_path);
|
||||
if (!string.IsNullOrEmpty(text))
|
||||
{
|
||||
var size = g.MeasureString(Text, Font);
|
||||
g.DrawString(Text, Font, new SolidBrush(ForeColor), new PointF((this.Width - size.Width) / 2, (this.Height - size.Height) / 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enum ArrowDirection
|
||||
/// </summary>
|
||||
public enum ArrowDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// The left
|
||||
/// </summary>
|
||||
Left,
|
||||
/// <summary>
|
||||
/// The right
|
||||
/// </summary>
|
||||
Right,
|
||||
/// <summary>
|
||||
/// The top
|
||||
/// </summary>
|
||||
Top,
|
||||
/// <summary>
|
||||
/// The bottom
|
||||
/// </summary>
|
||||
Bottom,
|
||||
/// <summary>
|
||||
/// The left right
|
||||
/// </summary>
|
||||
Left_Right,
|
||||
/// <summary>
|
||||
/// The top bottom
|
||||
/// </summary>
|
||||
Top_Bottom
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,298 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-09
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCBlower.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 UCBlower.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public class UCBlower : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The entrance direction
|
||||
/// </summary>
|
||||
private BlowerEntranceDirection entranceDirection = BlowerEntranceDirection.None;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the entrance direction.
|
||||
/// </summary>
|
||||
/// <value>The entrance direction.</value>
|
||||
[Description("入口方向"), Category("自定义")]
|
||||
public BlowerEntranceDirection EntranceDirection
|
||||
{
|
||||
get { return entranceDirection; }
|
||||
set
|
||||
{
|
||||
entranceDirection = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The exit direction
|
||||
/// </summary>
|
||||
private BlowerExitDirection exitDirection = BlowerExitDirection.Right;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the exit direction.
|
||||
/// </summary>
|
||||
/// <value>The exit direction.</value>
|
||||
[Description("出口方向"), Category("自定义")]
|
||||
public BlowerExitDirection ExitDirection
|
||||
{
|
||||
get { return exitDirection; }
|
||||
set
|
||||
{
|
||||
exitDirection = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The blower color
|
||||
/// </summary>
|
||||
private Color blowerColor = Color.FromArgb(255, 77, 59);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the blower.
|
||||
/// </summary>
|
||||
/// <value>The color of the blower.</value>
|
||||
[Description("风机颜色"), Category("自定义")]
|
||||
public Color BlowerColor
|
||||
{
|
||||
get { return blowerColor; }
|
||||
set
|
||||
{
|
||||
blowerColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The fan color
|
||||
/// </summary>
|
||||
private Color fanColor = Color.FromArgb(3, 169, 243);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the fan.
|
||||
/// </summary>
|
||||
/// <value>The color of the fan.</value>
|
||||
[Description("风叶颜色"), Category("自定义")]
|
||||
public Color FanColor
|
||||
{
|
||||
get { return fanColor; }
|
||||
set
|
||||
{
|
||||
fanColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m rect working
|
||||
/// </summary>
|
||||
Rectangle m_rectWorking;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCBlower" /> class.
|
||||
/// </summary>
|
||||
public UCBlower()
|
||||
{
|
||||
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 += UCBlower_SizeChanged;
|
||||
this.Size = new Size(120, 120);
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the UCBlower 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 UCBlower_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
int intMin = Math.Min(this.Width, this.Height);
|
||||
m_rectWorking = new Rectangle((this.Width - (intMin / 3 * 2)) / 2, (this.Height - (intMin / 3 * 2)) / 2, (intMin / 3 * 2), (intMin / 3 * 2));
|
||||
}
|
||||
|
||||
/// <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);
|
||||
var g = e.Graphics;
|
||||
g.SetGDIHigh();
|
||||
GraphicsPath pathLineIn = new GraphicsPath();
|
||||
GraphicsPath pathLineOut = new GraphicsPath();
|
||||
int intLinePenWidth = 0;
|
||||
|
||||
switch (exitDirection)
|
||||
{
|
||||
case BlowerExitDirection.Left:
|
||||
g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(0, m_rectWorking.Top, this.Width / 2, m_rectWorking.Height / 2 - 5));
|
||||
intLinePenWidth = m_rectWorking.Height / 2 - 5;
|
||||
pathLineOut.AddLine(new Point(-10, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) / 2), new Point(m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) / 2));
|
||||
g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(1, m_rectWorking.Top - 2), new Point(1, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) + 2));
|
||||
break;
|
||||
case BlowerExitDirection.Right:
|
||||
g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(this.Width / 2, m_rectWorking.Top, this.Width / 2, m_rectWorking.Height / 2 - 5));
|
||||
intLinePenWidth = m_rectWorking.Height / 2 - 5;
|
||||
pathLineOut.AddLine(new Point(this.Width + 10, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) / 2), new Point(m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) / 2));
|
||||
g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(this.Width - 2, m_rectWorking.Top - 2), new Point(this.Width - 2, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) + 2));
|
||||
break;
|
||||
case BlowerExitDirection.Up:
|
||||
g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(m_rectWorking.Right - (m_rectWorking.Width / 2 - 5), 0, m_rectWorking.Width / 2 - 5, this.Height / 2));
|
||||
intLinePenWidth = m_rectWorking.Width / 2 - 5;
|
||||
pathLineOut.AddLine(new Point(m_rectWorking.Right - (m_rectWorking.Width / 2 - 5) / 2, -10), new Point(m_rectWorking.Right - (m_rectWorking.Width / 2 - 5) / 2, m_rectWorking.Top + m_rectWorking.Height / 2));
|
||||
g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(m_rectWorking.Right + 2, 1), new Point(m_rectWorking.Right - (m_rectWorking.Width / 2 - 5) - 2, 1));
|
||||
break;
|
||||
}
|
||||
|
||||
switch (entranceDirection)
|
||||
{
|
||||
case BlowerEntranceDirection.Left:
|
||||
g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(0, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5, this.Width / 2, m_rectWorking.Height / 2 - 5));
|
||||
pathLineIn.AddLine(new Point(-10, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) / 2), new Point(m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) / 2));
|
||||
g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(1, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 - 2), new Point(1, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) + 2));
|
||||
break;
|
||||
case BlowerEntranceDirection.Right:
|
||||
g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(this.Width / 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5, this.Width / 2, m_rectWorking.Height / 2 - 5));
|
||||
pathLineIn.AddLine(new Point(this.Width + 10, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) / 2), new Point(m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) / 2));
|
||||
g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(this.Width - 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 - 2), new Point(this.Width - 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) + 2));
|
||||
break;
|
||||
case BlowerEntranceDirection.Up:
|
||||
g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(m_rectWorking.Left, 0, m_rectWorking.Width / 2 - 5, this.Height / 2));
|
||||
pathLineIn.AddLine(new Point(m_rectWorking.Left + (m_rectWorking.Width / 2 - 5) / 2, -10), new Point(m_rectWorking.Left + (m_rectWorking.Width / 2 - 5) / 2, m_rectWorking.Top + m_rectWorking.Height / 2));
|
||||
g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(m_rectWorking.Left - 2, 1), new Point(m_rectWorking.Left + (m_rectWorking.Width / 2 - 5) + 2, 1));
|
||||
break;
|
||||
}
|
||||
|
||||
//渐变色
|
||||
int _intPenWidth = intLinePenWidth;
|
||||
int intCount = _intPenWidth / 2 / 4;
|
||||
for (int i = 0; i < intCount; i++)
|
||||
{
|
||||
int _penWidth = _intPenWidth / 2 - 4 * i;
|
||||
if (_penWidth <= 0)
|
||||
_penWidth = 1;
|
||||
if (entranceDirection != BlowerEntranceDirection.None)
|
||||
g.DrawPath(new Pen(new SolidBrush(Color.FromArgb(40, Color.White.R, Color.White.G, Color.White.B)), _penWidth), pathLineIn);
|
||||
g.DrawPath(new Pen(new SolidBrush(Color.FromArgb(40, Color.White.R, Color.White.G, Color.White.B)), _penWidth), pathLineOut);
|
||||
if (_penWidth == 1)
|
||||
break;
|
||||
}
|
||||
|
||||
//底座
|
||||
GraphicsPath gpDZ = new GraphicsPath();
|
||||
gpDZ.AddLines(new Point[]
|
||||
{
|
||||
new Point( m_rectWorking.Left+m_rectWorking.Width/2,m_rectWorking.Top+m_rectWorking.Height/2),
|
||||
new Point(m_rectWorking.Left+2,this.Height),
|
||||
new Point(m_rectWorking.Right-2,this.Height)
|
||||
});
|
||||
gpDZ.CloseAllFigures();
|
||||
g.FillPath(new SolidBrush(blowerColor), gpDZ);
|
||||
g.FillPath(new SolidBrush(Color.FromArgb(50, Color.White)), gpDZ);
|
||||
g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(m_rectWorking.Left, this.Height - 2), new Point(m_rectWorking.Right, this.Height - 2));
|
||||
|
||||
//中心
|
||||
g.FillEllipse(new SolidBrush(blowerColor), m_rectWorking);
|
||||
g.FillEllipse(new SolidBrush(Color.FromArgb(20, Color.White)), m_rectWorking);
|
||||
|
||||
|
||||
//扇叶
|
||||
Rectangle _rect = new Rectangle(m_rectWorking.Left + (m_rectWorking.Width - (m_rectWorking.Width / 3 * 2)) / 2, m_rectWorking.Top + (m_rectWorking.Height - (m_rectWorking.Width / 3 * 2)) / 2, (m_rectWorking.Width / 3 * 2), (m_rectWorking.Width / 3 * 2));
|
||||
|
||||
int _splitCount = 8;
|
||||
float fltSplitValue = 360F / (float)_splitCount;
|
||||
for (int i = 0; i <= _splitCount; i++)
|
||||
{
|
||||
float fltAngle = (fltSplitValue * i - 180) % 360;
|
||||
float fltY1 = (float)(_rect.Top + _rect.Width / 2 - ((_rect.Width / 2) * Math.Sin(Math.PI * (fltAngle / 180.00F))));
|
||||
float fltX1 = (float)(_rect.Left + (_rect.Width / 2 - ((_rect.Width / 2) * Math.Cos(Math.PI * (fltAngle / 180.00F)))));
|
||||
float fltY2 = 0;
|
||||
float fltX2 = 0;
|
||||
|
||||
fltY2 = (float)(_rect.Top + _rect.Width / 2 - ((_rect.Width / 4) * Math.Sin(Math.PI * (fltAngle / 180.00F))));
|
||||
fltX2 = (float)(_rect.Left + (_rect.Width / 2 - ((_rect.Width / 4) * Math.Cos(Math.PI * (fltAngle / 180.00F)))));
|
||||
|
||||
g.DrawLine(new Pen(new SolidBrush(fanColor), 2), new PointF(fltX1, fltY1), new PointF(fltX2, fltY2));
|
||||
}
|
||||
|
||||
g.FillEllipse(new SolidBrush(fanColor), new Rectangle(_rect.Left + _rect.Width / 2 - _rect.Width / 4 + 2, _rect.Top + _rect.Width / 2 - _rect.Width / 4 + 2, _rect.Width / 2 - 4, _rect.Width / 2 - 4));
|
||||
g.FillEllipse(new SolidBrush(Color.FromArgb(50, Color.White)), new Rectangle(_rect.Left - 5, _rect.Top - 5, _rect.Width + 10, _rect.Height + 10));
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Enum BlowerEntranceDirection
|
||||
/// </summary>
|
||||
public enum BlowerEntranceDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// The none
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// The left
|
||||
/// </summary>
|
||||
Left,
|
||||
/// <summary>
|
||||
/// The right
|
||||
/// </summary>
|
||||
Right,
|
||||
/// <summary>
|
||||
/// Up
|
||||
/// </summary>
|
||||
Up
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enum BlowerExitDirection
|
||||
/// </summary>
|
||||
public enum BlowerExitDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// The left
|
||||
/// </summary>
|
||||
Left,
|
||||
/// <summary>
|
||||
/// The right
|
||||
/// </summary>
|
||||
Right,
|
||||
/// <summary>
|
||||
/// Up
|
||||
/// </summary>
|
||||
Up
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,368 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-05
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCBottle.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 UCBottle.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public class UCBottle : UserControl
|
||||
{
|
||||
//瓶身区域
|
||||
/// <summary>
|
||||
/// The m working rect
|
||||
/// </summary>
|
||||
Rectangle m_workingRect;
|
||||
|
||||
/// <summary>
|
||||
/// The title
|
||||
/// </summary>
|
||||
string title = "瓶子1";
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the title.
|
||||
/// </summary>
|
||||
/// <value>The title.</value>
|
||||
[Description("标题"), Category("自定义")]
|
||||
public string Title
|
||||
{
|
||||
get { return title; }
|
||||
set
|
||||
{
|
||||
title = value;
|
||||
ResetWorkingRect();
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The bottle color
|
||||
/// </summary>
|
||||
private Color bottleColor = Color.FromArgb(255, 77, 59);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the bottle.
|
||||
/// </summary>
|
||||
/// <value>The color of the bottle.</value>
|
||||
[Description("瓶子颜色"), Category("自定义")]
|
||||
public Color BottleColor
|
||||
{
|
||||
get { return bottleColor; }
|
||||
set
|
||||
{
|
||||
bottleColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The bottle mouth color
|
||||
/// </summary>
|
||||
private Color bottleMouthColor = Color.FromArgb(105, 105, 105);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the bottle mouth.
|
||||
/// </summary>
|
||||
/// <value>The color of the bottle mouth.</value>
|
||||
[Description("瓶口颜色"), Category("自定义")]
|
||||
public Color BottleMouthColor
|
||||
{
|
||||
get { return bottleMouthColor; }
|
||||
set { bottleMouthColor = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The liquid color
|
||||
/// </summary>
|
||||
private Color liquidColor = Color.FromArgb(3, 169, 243);
|
||||
|
||||
/// <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;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置控件显示的文字的字体。
|
||||
/// </summary>
|
||||
/// <value>The font.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
||||
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Description("文字字体"), Category("自定义")]
|
||||
public override Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Font = value;
|
||||
ResetWorkingRect();
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置控件的前景色。
|
||||
/// </summary>
|
||||
/// <value>The color of the fore.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Description("文字颜色"), Category("自定义")]
|
||||
public override System.Drawing.Color ForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ForeColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <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 = 50;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value.
|
||||
/// </summary>
|
||||
/// <value>The value.</value>
|
||||
[Description("值"), Category("自定义")]
|
||||
public decimal Value
|
||||
{
|
||||
get { return m_value; }
|
||||
set
|
||||
{
|
||||
if (value <= 0 || value > maxValue)
|
||||
return;
|
||||
m_value = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m no
|
||||
/// </summary>
|
||||
private string m_NO;
|
||||
/// <summary>
|
||||
/// Gets or sets the NO.
|
||||
/// </summary>
|
||||
/// <value>The no.</value>
|
||||
[Description("编号"), Category("自定义")]
|
||||
public string NO
|
||||
{
|
||||
get { return m_NO; }
|
||||
set
|
||||
{
|
||||
m_NO = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCBottle" /> class.
|
||||
/// </summary>
|
||||
public UCBottle()
|
||||
{
|
||||
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 += UCBottle_SizeChanged;
|
||||
this.Size = new Size(100, 150);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the UCBottle 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 UCBottle_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
ResetWorkingRect();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the working rect.
|
||||
/// </summary>
|
||||
private void ResetWorkingRect()
|
||||
{
|
||||
var g = this.CreateGraphics();
|
||||
var size = g.MeasureString(title, Font);
|
||||
m_workingRect = new Rectangle(0, (int)size.Height + 10, this.Width, this.Height - ((int)size.Height + 10) - 15);
|
||||
}
|
||||
|
||||
/// <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);
|
||||
var g = e.Graphics;
|
||||
g.SetGDIHigh();
|
||||
//写文字
|
||||
var size = g.MeasureString(title, Font);
|
||||
g.DrawString(title, Font, new SolidBrush(ForeColor), new PointF((this.Width - size.Width) / 2, 2));
|
||||
|
||||
//画空瓶子
|
||||
GraphicsPath pathPS = new GraphicsPath();
|
||||
Point[] psPS = new Point[]
|
||||
{
|
||||
new Point(m_workingRect.Left, m_workingRect.Top),
|
||||
new Point(m_workingRect.Right - 1, m_workingRect.Top),
|
||||
new Point(m_workingRect.Right - 1, m_workingRect.Bottom - 15),
|
||||
new Point(m_workingRect.Right - 1 - m_workingRect.Width / 4, m_workingRect.Bottom),
|
||||
new Point(m_workingRect.Left + m_workingRect.Width / 4, m_workingRect.Bottom),
|
||||
new Point(m_workingRect.Left, m_workingRect.Bottom - 15),
|
||||
};
|
||||
pathPS.AddLines(psPS);
|
||||
pathPS.CloseAllFigures();
|
||||
g.FillPath(new SolidBrush(bottleColor), pathPS);
|
||||
//画液体
|
||||
decimal decYTHeight = (m_value / maxValue) * m_workingRect.Height;
|
||||
GraphicsPath pathYT = new GraphicsPath();
|
||||
Rectangle rectYT = Rectangle.Empty;
|
||||
if (decYTHeight < 15)
|
||||
{
|
||||
PointF[] psYT = new PointF[]
|
||||
{
|
||||
new PointF((float)(m_workingRect.Left+(15-decYTHeight))+3,(float)(m_workingRect.Bottom-decYTHeight)),
|
||||
new PointF((float)(m_workingRect.Right-(15-decYTHeight))-3,(float)(m_workingRect.Bottom-decYTHeight)),
|
||||
new PointF(m_workingRect.Right-1-m_workingRect.Width/4, m_workingRect.Bottom),
|
||||
new PointF(m_workingRect.Left+m_workingRect.Width/4, m_workingRect.Bottom),
|
||||
};
|
||||
pathYT.AddLines(psYT);
|
||||
pathYT.CloseAllFigures();
|
||||
rectYT = new Rectangle((m_workingRect.Left + (15 - (int)decYTHeight)) + 3, m_workingRect.Bottom - (int)decYTHeight - 5, m_workingRect.Width - (int)(15 - decYTHeight) * 2 - 8, 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
PointF[] psYT = new PointF[]
|
||||
{
|
||||
new PointF(m_workingRect.Left,(float)(m_workingRect.Bottom-decYTHeight)),
|
||||
new PointF(m_workingRect.Right-1,(float)(m_workingRect.Bottom-decYTHeight)),
|
||||
new PointF(m_workingRect.Right-1,m_workingRect.Bottom-15),
|
||||
new PointF(m_workingRect.Right-1-m_workingRect.Width/4, m_workingRect.Bottom),
|
||||
new PointF(m_workingRect.Left+m_workingRect.Width/4, m_workingRect.Bottom),
|
||||
new PointF(m_workingRect.Left,m_workingRect.Bottom-15),
|
||||
};
|
||||
pathYT.AddLines(psYT);
|
||||
pathYT.CloseAllFigures();
|
||||
rectYT = new Rectangle(m_workingRect.Left, m_workingRect.Bottom - (int)decYTHeight - 5, m_workingRect.Width, 10);
|
||||
}
|
||||
|
||||
g.FillPath(new SolidBrush(liquidColor), pathYT);
|
||||
g.FillPath(new SolidBrush(Color.FromArgb(50, bottleMouthColor)), pathYT);
|
||||
//画液体面
|
||||
g.FillEllipse(new SolidBrush(liquidColor), rectYT);
|
||||
g.FillEllipse(new SolidBrush(Color.FromArgb(50, Color.White)), rectYT);
|
||||
|
||||
//画高亮
|
||||
int intCount = m_workingRect.Width / 2 / 4;
|
||||
int intSplit = (255 - 100) / intCount;
|
||||
for (int i = 0; i < intCount; i++)
|
||||
{
|
||||
int _penWidth = m_workingRect.Width / 2 - 4 * i;
|
||||
if (_penWidth <= 0)
|
||||
_penWidth = 1;
|
||||
g.DrawLine(new Pen(new SolidBrush(Color.FromArgb(10, Color.White)), _penWidth), new Point(m_workingRect.Width / 2, m_workingRect.Top), new Point(m_workingRect.Width / 2, m_workingRect.Bottom - 15));
|
||||
if (_penWidth == 1)
|
||||
break;
|
||||
}
|
||||
|
||||
//画瓶底
|
||||
g.FillEllipse(new SolidBrush(bottleColor), new RectangleF(m_workingRect.Left, m_workingRect.Top - 5, m_workingRect.Width - 2, 10));
|
||||
g.FillEllipse(new SolidBrush(Color.FromArgb(50, Color.White)), new RectangleF(m_workingRect.Left, m_workingRect.Top - 5, m_workingRect.Width - 2, 10));
|
||||
//画瓶口
|
||||
g.FillRectangle(new SolidBrush(bottleMouthColor), new Rectangle(m_workingRect.Left + m_workingRect.Width / 4, m_workingRect.Bottom, m_workingRect.Width / 2, 15));
|
||||
//画瓶颈阴影
|
||||
GraphicsPath pathPJ = new GraphicsPath();
|
||||
Point[] psPJ = new Point[]
|
||||
{
|
||||
new Point(m_workingRect.Left, m_workingRect.Bottom-15),
|
||||
new Point(m_workingRect.Right-1, m_workingRect.Bottom-15),
|
||||
new Point(m_workingRect.Right-1-m_workingRect.Width/4, m_workingRect.Bottom),
|
||||
new Point(m_workingRect.Left+m_workingRect.Width/4, m_workingRect.Bottom)
|
||||
};
|
||||
pathPJ.AddLines(psPJ);
|
||||
pathPJ.CloseAllFigures();
|
||||
g.FillPath(new SolidBrush(Color.FromArgb(50, bottleMouthColor)), pathPJ);
|
||||
|
||||
//写编号
|
||||
if (!string.IsNullOrEmpty(m_NO))
|
||||
{
|
||||
var nosize = g.MeasureString(m_NO, Font);
|
||||
g.DrawString(m_NO, Font, new SolidBrush(ForeColor), new PointF((this.Width - nosize.Width) / 2, m_workingRect.Top + 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,803 @@
|
||||
// ***********************************************************************
|
||||
// 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
|
||||
{
|
||||
/// <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(0, 1);
|
||||
string strNew = value.ToString().Substring(0, 1);
|
||||
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(255, 77, 59);
|
||||
[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(3, 169, 243);
|
||||
|
||||
/// <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 != 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;
|
||||
if (value == LiquidDirection.None)
|
||||
m_timer.Enabled = false;
|
||||
else
|
||||
m_timer.Enabled = true;
|
||||
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The liquid speed
|
||||
/// </summary>
|
||||
private int liquidSpeed = 100;
|
||||
|
||||
/// <summary>
|
||||
/// 液体流速,越小,速度越快Gets or sets the liquid speed.
|
||||
/// </summary>
|
||||
/// <value>The liquid speed.</value>
|
||||
[Description("液体流速,越小,速度越快"), Category("自定义")]
|
||||
public int LiquidSpeed
|
||||
{
|
||||
get { return liquidSpeed; }
|
||||
set
|
||||
{
|
||||
if (value <= 0)
|
||||
return;
|
||||
liquidSpeed = value;
|
||||
m_timer.Interval = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The conduit width
|
||||
/// </summary>
|
||||
int conduitWidth = 50;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the width of the conduit.
|
||||
/// </summary>
|
||||
/// <value>The width of the conduit.</value>
|
||||
[Description("管道宽度,当ConduitStyle的值是Horizontal_Tilt_Up,Horizontal_Tilt_Down,Vertical_Tilt_Left,Vertical_Tilt_Right时有效,其他时候将根据管道大小使用自动宽度"), Category("自定义")]
|
||||
public int ConduitWidth
|
||||
{
|
||||
get { return conduitWidth; }
|
||||
set
|
||||
{
|
||||
conduitWidth = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The int pen width
|
||||
/// </summary>
|
||||
int intPenWidth = 0;
|
||||
|
||||
/// <summary>
|
||||
/// The int line left
|
||||
/// </summary>
|
||||
int intLineLeft = 0;
|
||||
/// <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(200, 50);
|
||||
m_timer = new Timer();
|
||||
m_timer.Interval = 100;
|
||||
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 += 2;
|
||||
if (intLineLeft > 12)
|
||||
intLineLeft = 0;
|
||||
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();
|
||||
List<Point[]> tileLine = new List<Point[]>();
|
||||
switch (conduitStyle)
|
||||
{
|
||||
#region H English:H
|
||||
case ConduitStyle.Horizontal_None_None:
|
||||
path.AddLines(new PointF[]
|
||||
{
|
||||
new PointF(0, 0),
|
||||
new PointF(this.ClientRectangle.Right, 0),
|
||||
new PointF(this.ClientRectangle.Right, this.Height),
|
||||
new PointF(0, this.Height)
|
||||
});
|
||||
path.CloseAllFigures();
|
||||
linePath.AddLine(0, this.Height / 2, this.Width, this.Height / 2);
|
||||
break;
|
||||
case ConduitStyle.Horizontal_Up_None:
|
||||
path.AddLines(new PointF[]
|
||||
{
|
||||
new PointF(0, 0),
|
||||
new PointF(this.ClientRectangle.Right, 0),
|
||||
new PointF(this.ClientRectangle.Right, this.Height),
|
||||
new PointF(0+intPenWidth, this.Height)
|
||||
});
|
||||
path.AddArc(new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 90, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);
|
||||
linePath.AddLine(intPenWidth, this.Height / 2, this.Width, this.Height / 2);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Horizontal_Down_None:
|
||||
path.AddLines(new PointF[]
|
||||
{
|
||||
new PointF(intPenWidth, 0),
|
||||
new PointF(this.ClientRectangle.Right, 0),
|
||||
new PointF(this.ClientRectangle.Right, this.Height),
|
||||
new PointF(0, this.Height)
|
||||
});
|
||||
path.AddArc(new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), 180, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, this.Height / 2, intPenWidth, intPenWidth), 179, 91);
|
||||
linePath.AddLine(intPenWidth + 1, this.Height / 2, this.Width, this.Height / 2);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Horizontal_None_Up:
|
||||
path.AddLines(new PointF[]
|
||||
{
|
||||
new PointF(this.ClientRectangle.Right-intPenWidth, this.Height),
|
||||
new PointF(0, this.Height),
|
||||
new PointF(0, 0),
|
||||
new PointF(this.ClientRectangle.Right-intPenWidth, 0)
|
||||
});
|
||||
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 0, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddLine(0, this.Height / 2, this.Width - intPenWidth, this.Height / 2);
|
||||
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 91, -91);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Horizontal_None_Down:
|
||||
path.AddLines(new PointF[]
|
||||
{
|
||||
new PointF(this.ClientRectangle.Right, this.Height),
|
||||
new PointF(0, this.Height),
|
||||
new PointF(0, 0),
|
||||
new PointF(this.ClientRectangle.Right-intPenWidth, 0)
|
||||
});
|
||||
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), 270, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddLine(0, this.Height / 2, this.Width - intPenWidth - 1, this.Height / 2);
|
||||
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, intPenWidth / 2, intPenWidth, intPenWidth), 269, 91);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Horizontal_Down_Up:
|
||||
path.AddLine(new Point(intPenWidth, 0), new Point(this.Width, 0));
|
||||
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 0, 90);
|
||||
path.AddLine(new Point(this.Width - intPenWidth, this.Height), new Point(0, this.Height));
|
||||
path.AddArc(new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), 180, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, this.Height / 2, intPenWidth, intPenWidth), 179, 91);
|
||||
//linePath.AddLine(intPenWidth, this.Height / 2, this.Width - intPenWidth, this.Height / 2);
|
||||
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 91, -91);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90 });
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Horizontal_Up_Down:
|
||||
path.AddLine(new Point(0, 0), new Point(this.Width - intPenWidth, 0));
|
||||
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), 270, 90);
|
||||
path.AddLine(new Point(this.Width, this.Height), new Point(intPenWidth, this.Height));
|
||||
path.AddArc(new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 90, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);
|
||||
linePath.AddLine(intPenWidth, this.Height / 2, this.Width - intPenWidth - 1, this.Height / 2);
|
||||
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, intPenWidth / 2, intPenWidth, intPenWidth), 269, 91);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90 });
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Horizontal_Up_Up:
|
||||
path.AddLine(new Point(0, 0), new Point(this.Width, 0));
|
||||
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 0, 90);
|
||||
path.AddLine(new Point(this.Width - intPenWidth, this.Height), new Point(intPenWidth, this.Height));
|
||||
path.AddArc(new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), 90, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);
|
||||
//linePath.AddLine(intPenWidth, this.Height / 2, this.Width - intPenWidth, this.Height / 2);
|
||||
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, -1 * intPenWidth / 2 - 1, intPenWidth, intPenWidth), 91, -91);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(0, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90 });
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, intPenWidth * -1, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Horizontal_Down_Down:
|
||||
path.AddLine(new Point(intPenWidth, 0), new Point(this.Width - intPenWidth, 0));
|
||||
path.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), 270, 90);
|
||||
path.AddLine(new Point(this.Width, this.Height), new Point(0, this.Height));
|
||||
path.AddArc(new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), 180, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddArc(new Rectangle(intPenWidth / 2 + 1, this.Height / 2, intPenWidth, intPenWidth), 179, 91);
|
||||
linePath.AddLine(intPenWidth + 1, this.Height / 2, this.Width - intPenWidth - 1, this.Height / 2);
|
||||
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - intPenWidth - intPenWidth / 2 - 1, intPenWidth / 2, intPenWidth, intPenWidth), 269, 91);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(0, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90 });
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - intPenWidth * 2, -1, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90 });
|
||||
break;
|
||||
|
||||
case ConduitStyle.Horizontal_Tilt_Up:
|
||||
|
||||
double angleUp = Math.Atan((this.ClientRectangle.Height - conduitWidth) / (double)this.ClientRectangle.Width);
|
||||
angleUp = angleUp / Math.PI * 180f;
|
||||
path.AddArc(new Rectangle(this.ClientRectangle.Left - conduitWidth, this.ClientRectangle.Bottom - conduitWidth * 2, conduitWidth * 2, conduitWidth * 2), 90, -1 * (float)angleUp);
|
||||
path.AddLine(new Point(this.ClientRectangle.Right, this.ClientRectangle.Top + conduitWidth), new Point(this.ClientRectangle.Right, this.ClientRectangle.Top));
|
||||
path.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth, this.ClientRectangle.Top, conduitWidth * 2, conduitWidth * 2), 270, -1 * (float)angleUp);
|
||||
path.AddLine(new Point(this.ClientRectangle.Left, this.ClientRectangle.Bottom - conduitWidth), new Point(this.ClientRectangle.Left, this.ClientRectangle.Bottom));
|
||||
path.CloseAllFigures();
|
||||
|
||||
|
||||
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth / 2, this.ClientRectangle.Top + conduitWidth / 2, conduitWidth, conduitWidth), 270, -1 * (float)angleUp);
|
||||
linePath.AddArc(new Rectangle(this.ClientRectangle.Left - conduitWidth / 2, this.ClientRectangle.Bottom - 1 - conduitWidth - conduitWidth / 2, conduitWidth, conduitWidth), 95 - (float)angleUp, (float)angleUp + 5);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Left - conduitWidth, this.ClientRectangle.Bottom - conduitWidth * 2, conduitWidth * 2, conduitWidth * 2), startAngle = 90, sweepAngle = -1 * (float)angleUp });
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - conduitWidth, this.ClientRectangle.Top, conduitWidth * 2, conduitWidth * 2), startAngle = 270, sweepAngle = -1 * (float)angleUp });
|
||||
|
||||
tileLine.Add(new Point[]
|
||||
{
|
||||
new Point((int)(this.ClientRectangle.Right+1 - Math.Sin(Math.PI * (angleUp / 180.00F)) * conduitWidth),(int)( this.ClientRectangle.Top + conduitWidth - Math.Cos(Math.PI * (angleUp / 180.00F)) * conduitWidth)),
|
||||
new Point(this.ClientRectangle.Left,this.ClientRectangle.Bottom-conduitWidth-1)
|
||||
});
|
||||
tileLine.Add(new Point[]
|
||||
{
|
||||
new Point((int)(this.ClientRectangle.Left+1 + Math.Sin(Math.PI * (angleUp / 180.00F)) * conduitWidth),(int)( this.ClientRectangle.Bottom - conduitWidth + Math.Cos(Math.PI * (angleUp / 180.00F)) * conduitWidth)),
|
||||
new Point(this.ClientRectangle.Right,this.ClientRectangle.Top+conduitWidth)
|
||||
});
|
||||
|
||||
break;
|
||||
case ConduitStyle.Horizontal_Tilt_Down:
|
||||
double angleDown = Math.Atan((this.ClientRectangle.Height - conduitWidth) / (double)this.ClientRectangle.Width);
|
||||
angleDown = angleDown / Math.PI * 180f;
|
||||
path.AddArc(new Rectangle(this.ClientRectangle.Left - conduitWidth, this.ClientRectangle.Top, conduitWidth * 2, conduitWidth * 2), 270, (float)angleDown);
|
||||
path.AddLine(new Point(this.ClientRectangle.Right, this.ClientRectangle.Bottom - conduitWidth), new Point(this.ClientRectangle.Right, this.ClientRectangle.Bottom));
|
||||
path.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth, this.ClientRectangle.Bottom - conduitWidth * 2, conduitWidth * 2, conduitWidth * 2), 90, (float)angleDown);
|
||||
path.AddLine(new Point(this.ClientRectangle.Left, this.ClientRectangle.Top + conduitWidth), new Point(this.ClientRectangle.Left, this.ClientRectangle.Top));
|
||||
path.CloseAllFigures();
|
||||
|
||||
|
||||
linePath.AddArc(new Rectangle(this.ClientRectangle.Left - conduitWidth / 2, this.ClientRectangle.Top + conduitWidth / 2, conduitWidth, conduitWidth), 265, (float)angleDown + 5);
|
||||
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth / 2, this.ClientRectangle.Bottom - conduitWidth - conduitWidth / 2 - 1, conduitWidth, conduitWidth), 90 + (float)angleDown, -1 * (float)angleDown - 5);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Left - conduitWidth, this.ClientRectangle.Top, conduitWidth * 2, conduitWidth * 2), startAngle = 270, sweepAngle = (float)angleDown });
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - conduitWidth, this.ClientRectangle.Bottom - conduitWidth * 2, conduitWidth * 2, conduitWidth * 2), startAngle = 90, sweepAngle = (float)angleDown });
|
||||
|
||||
tileLine.Add(new Point[]
|
||||
{
|
||||
new Point((int)(this.ClientRectangle.Left + Math.Sin(Math.PI * (angleDown / 180.00F)) * conduitWidth),(int)( this.ClientRectangle.Top + conduitWidth - Math.Cos(Math.PI * (angleDown / 180.00F)) * conduitWidth)),
|
||||
new Point(this.ClientRectangle.Right-1,this.ClientRectangle.Bottom-conduitWidth-1)
|
||||
});
|
||||
tileLine.Add(new Point[]
|
||||
{
|
||||
new Point((int)(this.ClientRectangle.Right - Math.Sin(Math.PI * (angleDown / 180.00F)) * conduitWidth),(int)( this.ClientRectangle.Bottom - conduitWidth + Math.Cos(Math.PI * (angleDown / 180.00F)) * conduitWidth)),
|
||||
new Point(this.ClientRectangle.Left,this.ClientRectangle.Top+conduitWidth)
|
||||
});
|
||||
break;
|
||||
#endregion
|
||||
|
||||
#region V English:V
|
||||
case ConduitStyle.Vertical_None_None:
|
||||
path.AddLines(new PointF[]
|
||||
{
|
||||
new PointF(0, 0),
|
||||
new PointF(this.ClientRectangle.Right, 0),
|
||||
new PointF(this.ClientRectangle.Right, this.Height),
|
||||
new PointF(0, this.Height)
|
||||
});
|
||||
path.CloseAllFigures();
|
||||
linePath.AddLine(this.Width / 2, 0, this.Width / 2, 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(0, this.Height),
|
||||
new PointF(0, 0)
|
||||
});
|
||||
path.AddArc(new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), 270, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 269, 91);
|
||||
linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Vertical_Right_None:
|
||||
path.AddLines(new PointF[]
|
||||
{
|
||||
new PointF(this.ClientRectangle.Right, 0),
|
||||
new PointF(this.ClientRectangle.Right, this.Height),
|
||||
new PointF(0, this.Height),
|
||||
new PointF(0, intPenWidth)
|
||||
});
|
||||
path.AddArc(new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), 180, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddArc(new Rectangle(intPenWidth / 2, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 271, -91);
|
||||
linePath.AddLine(intPenWidth / 2, intPenWidth + 1, intPenWidth / 2, this.Height);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Vertical_None_Left:
|
||||
path.AddLines(new PointF[]
|
||||
{
|
||||
new PointF(0, this.Height),
|
||||
new PointF(0, 0),
|
||||
new PointF(this.ClientRectangle.Right, 0),
|
||||
new PointF(this.ClientRectangle.Right, this.Height-intPenWidth),
|
||||
});
|
||||
path.AddArc(new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 0, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddLine(this.Width / 2, 0, this.Width / 2, this.Height - intPenWidth);
|
||||
linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), -1, 91);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Vertical_None_Right:
|
||||
path.AddLines(new PointF[]
|
||||
{
|
||||
new PointF(0, this.Height-intPenWidth),
|
||||
new PointF(0, 0),
|
||||
new PointF(this.ClientRectangle.Right, 0),
|
||||
new PointF(this.ClientRectangle.Right, this.Height),
|
||||
});
|
||||
path.AddArc(new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 90, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddLine(this.Width / 2, 0, this.Width / 2, this.Height - intPenWidth - 1);
|
||||
linePath.AddArc(new Rectangle(intPenWidth / 2, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Vertical_Left_Right:
|
||||
path.AddLine(this.Width, intPenWidth, this.Width, this.Height);
|
||||
path.AddArc(new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 90, 90);
|
||||
path.AddLine(0, this.Height - intPenWidth, 0, 0);
|
||||
path.AddArc(new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), 270, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 269, 91);
|
||||
//linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
|
||||
linePath.AddArc(new Rectangle(intPenWidth / 2, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), 181, -91);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90 });
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Vertical_Right_Left:
|
||||
path.AddLine(this.Width, 0, this.Width, this.Height - intPenWidth);
|
||||
path.AddArc(new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 0, 90);
|
||||
path.AddLine(0, this.Height, 0, intPenWidth);
|
||||
path.AddArc(new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), 180, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddArc(new Rectangle(intPenWidth / 2, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 271, -91);
|
||||
//linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
|
||||
linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), -1, 91);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90 });
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Vertical_Left_Left:
|
||||
path.AddLine(this.Width, intPenWidth, this.Width, this.Height - intPenWidth);
|
||||
path.AddArc(new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 0, 90);
|
||||
path.AddLine(0, this.Height, 0, 0);
|
||||
path.AddArc(new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), 270, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 269, 91);
|
||||
//linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
|
||||
linePath.AddArc(new Rectangle(-1 * intPenWidth / 2 - 1, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), -1, 91);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-1 * intPenWidth, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 270, sweepAngle = 90 });
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-1 * intPenWidth, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 0, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Vertical_Right_Right:
|
||||
path.AddLine(this.Width, 0, this.Width, this.Height);
|
||||
path.AddArc(new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), 90, 90);
|
||||
path.AddLine(0, this.Height - intPenWidth, 0, intPenWidth);
|
||||
path.AddArc(new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), 180, 90);
|
||||
path.CloseAllFigures();
|
||||
|
||||
linePath.AddArc(new Rectangle(intPenWidth / 2, intPenWidth / 2 + 1, intPenWidth, intPenWidth), 271, -91);
|
||||
//linePath.AddLine(intPenWidth / 2, intPenWidth, intPenWidth / 2, this.Height - intPenWidth);
|
||||
linePath.AddArc(new Rectangle(intPenWidth / 2, this.Height - intPenWidth - intPenWidth / 2 - 1, intPenWidth, intPenWidth), 180, -91);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-1, 0, intPenWidth * 2, intPenWidth * 2), startAngle = 180, sweepAngle = 90 });
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(-1, this.Height - intPenWidth * 2, intPenWidth * 2, intPenWidth * 2), startAngle = 90, sweepAngle = 90 });
|
||||
break;
|
||||
case ConduitStyle.Vertical_Tilt_Left:
|
||||
double angleLeft = Math.Atan((this.ClientRectangle.Width - conduitWidth) / (double)this.ClientRectangle.Height);
|
||||
angleLeft = angleLeft / Math.PI * 180f;
|
||||
path.AddArc(new Rectangle(this.ClientRectangle.Left - 1, ClientRectangle.Top - conduitWidth, conduitWidth * 2, conduitWidth * 2), 180, -1 * (float)angleLeft);
|
||||
path.AddLine(new Point(this.ClientRectangle.Right - conduitWidth, this.ClientRectangle.Bottom), new Point(this.ClientRectangle.Right, this.ClientRectangle.Bottom));
|
||||
path.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth * 2, this.ClientRectangle.Bottom - conduitWidth, conduitWidth * 2, conduitWidth * 2), 0, -1 * (float)angleLeft);
|
||||
path.AddLine(new Point(this.ClientRectangle.Left + conduitWidth, this.ClientRectangle.Top), new Point(this.ClientRectangle.Left, this.ClientRectangle.Top));
|
||||
path.CloseAllFigures();
|
||||
|
||||
|
||||
linePath.AddArc(new Rectangle(this.ClientRectangle.Left + conduitWidth / 2, this.ClientRectangle.Top - conduitWidth / 2, conduitWidth, conduitWidth), 185, -1 * (float)angleLeft - 5);
|
||||
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth - conduitWidth / 2, this.ClientRectangle.Bottom - conduitWidth / 2, conduitWidth, conduitWidth), -1 * (float)angleLeft, (float)angleLeft);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Left - 1, ClientRectangle.Top - conduitWidth, conduitWidth * 2, conduitWidth * 2), startAngle = 180, sweepAngle = -1 * (float)angleLeft });
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - conduitWidth * 2, this.ClientRectangle.Bottom - conduitWidth, conduitWidth * 2, conduitWidth * 2), startAngle = 0, sweepAngle = -1 * (float)angleLeft });
|
||||
|
||||
tileLine.Add(new Point[]
|
||||
{
|
||||
new Point((int)(this.ClientRectangle.Left + conduitWidth),this.ClientRectangle.Top),
|
||||
new Point((int)(this.ClientRectangle.Right-conduitWidth+Math.Cos(Math.PI * (angleLeft / 180.00F)) * conduitWidth),(int)(this.ClientRectangle.Bottom-Math.Sin(Math.PI * (angleLeft / 180.00F)) * conduitWidth))
|
||||
});
|
||||
tileLine.Add(new Point[]
|
||||
{
|
||||
new Point((int)(this.ClientRectangle.Left-1+conduitWidth-Math.Cos(Math.PI * (angleLeft / 180.00F)) * conduitWidth),(int)(this.ClientRectangle.Top+Math.Sin(Math.PI * (angleLeft / 180.00F)) * conduitWidth)),
|
||||
new Point(this.ClientRectangle.Right-conduitWidth,this.ClientRectangle.Bottom)
|
||||
});
|
||||
break;
|
||||
case ConduitStyle.Vertical_Tilt_Right:
|
||||
double angleRight = Math.Atan((this.ClientRectangle.Width - conduitWidth) / (double)this.ClientRectangle.Height);
|
||||
angleRight = angleRight / Math.PI * 180f;
|
||||
path.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth * 2, ClientRectangle.Top - conduitWidth, conduitWidth * 2, conduitWidth * 2), 0, (float)angleRight);
|
||||
path.AddLine(new Point(this.ClientRectangle.Left + conduitWidth, this.ClientRectangle.Bottom), new Point(this.ClientRectangle.Left, this.ClientRectangle.Bottom));
|
||||
path.AddArc(new Rectangle(this.ClientRectangle.Left - 1, this.ClientRectangle.Bottom - conduitWidth, conduitWidth * 2, conduitWidth * 2), 180, (float)angleRight);
|
||||
path.AddLine(new Point(this.ClientRectangle.Right - conduitWidth, this.ClientRectangle.Top), new Point(this.ClientRectangle.Right, this.ClientRectangle.Top));
|
||||
path.CloseAllFigures();
|
||||
|
||||
|
||||
linePath.AddArc(new Rectangle(this.ClientRectangle.Right - conduitWidth - conduitWidth / 2, this.ClientRectangle.Top - conduitWidth / 2, conduitWidth, conduitWidth), -5, (float)angleRight + 5);
|
||||
linePath.AddArc(new Rectangle(this.ClientRectangle.Left + conduitWidth / 2, this.ClientRectangle.Bottom - conduitWidth / 2, conduitWidth, conduitWidth), 180 + (float)angleRight, -1 * (float)angleRight);
|
||||
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Right - conduitWidth * 2, ClientRectangle.Top - conduitWidth, conduitWidth * 2, conduitWidth * 2), startAngle = 0, sweepAngle = (float)angleRight });
|
||||
lstArcs.Add(new ArcEntity() { rect = new Rectangle(this.ClientRectangle.Left - 1, this.ClientRectangle.Bottom - conduitWidth, conduitWidth * 2, conduitWidth * 2), startAngle = 180, sweepAngle = (float)angleRight });
|
||||
|
||||
tileLine.Add(new Point[]
|
||||
{
|
||||
new Point((int)(this.ClientRectangle.Right - conduitWidth),this.ClientRectangle.Top),
|
||||
new Point((int)(this.ClientRectangle.Left + conduitWidth - Math.Cos(Math.PI * (angleRight / 180.00F)) * conduitWidth),(int)(this.ClientRectangle.Bottom-Math.Sin(Math.PI * (angleRight / 180.00F)) * conduitWidth))
|
||||
});
|
||||
tileLine.Add(new Point[]
|
||||
{
|
||||
new Point((int)(this.ClientRectangle.Right - conduitWidth+Math.Cos(Math.PI * (angleRight / 180.00F)) * conduitWidth),(int)(this.ClientRectangle.Top+Math.Sin(Math.PI * (angleRight / 180.00F)) * conduitWidth)),
|
||||
new Point(this.ClientRectangle.Left + conduitWidth,this.ClientRectangle.Bottom)
|
||||
});
|
||||
break;
|
||||
#endregion
|
||||
}
|
||||
base.Region = new Region(path);
|
||||
g.FillPath(new SolidBrush(conduitColor), path);
|
||||
|
||||
//渐变色
|
||||
int _intPenWidth = intPenWidth;
|
||||
if (conduitStyle.ToString().Contains("Tilt"))
|
||||
{
|
||||
_intPenWidth = conduitWidth;
|
||||
}
|
||||
int intCount = _intPenWidth / 2 / 4;
|
||||
for (int i = 0; i < intCount; i++)
|
||||
{
|
||||
int _penWidth = _intPenWidth / 2 - 4 * i;
|
||||
if (_penWidth <= 0)
|
||||
_penWidth = 1;
|
||||
g.DrawPath(new Pen(new SolidBrush(Color.FromArgb(40, Color.White.R, Color.White.G, Color.White.B)), _penWidth), linePath);
|
||||
if (_penWidth == 1)
|
||||
break;
|
||||
}
|
||||
|
||||
g.SetGDIHigh();
|
||||
//使用抗锯齿画圆角
|
||||
foreach (var item in lstArcs)
|
||||
{
|
||||
g.DrawArc(new Pen(new SolidBrush(this.BackColor)), item.rect, item.startAngle, item.sweepAngle);
|
||||
}
|
||||
|
||||
if (tileLine.Count > 0)
|
||||
{
|
||||
foreach (var item in tileLine)
|
||||
{
|
||||
g.DrawLine(new Pen(new SolidBrush(this.BackColor)), item[0], item[1]);
|
||||
}
|
||||
}
|
||||
|
||||
//液体流动
|
||||
if (LiquidDirection != LiquidDirection.None)
|
||||
{
|
||||
Pen p = new Pen(new SolidBrush(liquidColor), 4);
|
||||
p.DashPattern = new float[] { 6, 6 };
|
||||
p.DashOffset = intLineLeft * (LiquidDirection == LiquidDirection.Forward ? -1 : 1);
|
||||
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 horizontal tilt up
|
||||
/// </summary>
|
||||
Horizontal_Tilt_Up,
|
||||
/// <summary>
|
||||
/// 向下倾斜The horizontal tilt down
|
||||
/// </summary>
|
||||
Horizontal_Tilt_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,
|
||||
/// <summary>
|
||||
/// 向左倾斜The vertical tilt
|
||||
/// </summary>
|
||||
Vertical_Tilt_Left,
|
||||
/// <summary>
|
||||
/// 向右倾斜The vertical tilt right
|
||||
/// </summary>
|
||||
Vertical_Tilt_Right
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,295 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-05
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCConveyor.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 UCConveyor.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public class UCConveyor : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The conveyor color
|
||||
/// </summary>
|
||||
private Color conveyorColor = Color.FromArgb(255, 77, 59);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the conveyor.
|
||||
/// </summary>
|
||||
/// <value>The color of the conveyor.</value>
|
||||
[Description("传送带颜色"), Category("自定义")]
|
||||
public Color ConveyorColor
|
||||
{
|
||||
get { return conveyorColor; }
|
||||
set
|
||||
{
|
||||
conveyorColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The inclination
|
||||
/// </summary>
|
||||
private double inclination = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the inclination.
|
||||
/// </summary>
|
||||
/// <value>The inclination.</value>
|
||||
[Description("传送带角度(-90<=value<=90)"), Category("自定义")]
|
||||
public double Inclination
|
||||
{
|
||||
get { return inclination; }
|
||||
set
|
||||
{
|
||||
if (value > 90 || value < -90)
|
||||
return;
|
||||
inclination = value;
|
||||
ResetWorkingRect();
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The conveyor height
|
||||
/// </summary>
|
||||
private int conveyorHeight = 50;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the height of the conveyor.
|
||||
/// </summary>
|
||||
/// <value>The height of the conveyor.</value>
|
||||
[Description("传送带高度"), Category("自定义")]
|
||||
public int ConveyorHeight
|
||||
{
|
||||
get { return conveyorHeight; }
|
||||
set
|
||||
{
|
||||
conveyorHeight = value;
|
||||
ResetWorkingRect();
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The conveyor direction
|
||||
/// </summary>
|
||||
private ConveyorDirection conveyorDirection = ConveyorDirection.Forward;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the conveyor direction.
|
||||
/// </summary>
|
||||
/// <value>The conveyor direction.</value>
|
||||
[Description("传送带运行方向"), Category("自定义")]
|
||||
public ConveyorDirection ConveyorDirection
|
||||
{
|
||||
get { return conveyorDirection; }
|
||||
set
|
||||
{
|
||||
conveyorDirection = value;
|
||||
if (value == HZH_Controls.Controls.ConveyorDirection.None)
|
||||
{
|
||||
m_timer.Enabled = false;
|
||||
Refresh();
|
||||
}
|
||||
else
|
||||
{
|
||||
m_timer.Enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The liquid speed
|
||||
/// </summary>
|
||||
private int conveyorSpeed = 100;
|
||||
|
||||
/// <summary>
|
||||
/// 传送带运行速度,越小,速度越快Gets or sets the ConveyorSpeed.
|
||||
/// </summary>
|
||||
/// <value>The liquid speed.</value>
|
||||
[Description("传送带运行速度,越小,速度越快"), Category("自定义")]
|
||||
public int ConveyorSpeed
|
||||
{
|
||||
get { return conveyorSpeed; }
|
||||
set
|
||||
{
|
||||
if (value <= 0)
|
||||
return;
|
||||
conveyorSpeed = value;
|
||||
m_timer.Interval = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m working rect
|
||||
/// </summary>
|
||||
Rectangle m_workingRect;
|
||||
/// <summary>
|
||||
/// The int line left
|
||||
/// </summary>
|
||||
int intLineLeft = 0;
|
||||
/// <summary>
|
||||
/// The m timer
|
||||
/// </summary>
|
||||
Timer m_timer;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCConveyor" /> class.
|
||||
/// </summary>
|
||||
public UCConveyor()
|
||||
{
|
||||
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.SizeChanged += UCConveyor_SizeChanged;
|
||||
this.Size = new Size(300, 50);
|
||||
m_timer = new Timer();
|
||||
m_timer.Interval = 100;
|
||||
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 += 2;
|
||||
if (intLineLeft > 12)
|
||||
intLineLeft = 0;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the UCConveyor 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 UCConveyor_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
ResetWorkingRect();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets the working rect.
|
||||
/// </summary>
|
||||
private void ResetWorkingRect()
|
||||
{
|
||||
if (inclination == 90 || inclination == -90)
|
||||
{
|
||||
m_workingRect = new Rectangle((this.Width - conveyorHeight) / 2, 1, conveyorHeight, this.Height - 2);
|
||||
}
|
||||
else if (inclination == 0)
|
||||
{
|
||||
m_workingRect = new Rectangle(1, (this.Height - conveyorHeight) / 2 + 1, this.Width - 2, conveyorHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
//根据角度计算需要的高度
|
||||
int intHeight = (int)(Math.Tan(Math.PI * (Math.Abs(inclination) / 180.00000)) * (this.Width));
|
||||
if (intHeight >= this.Height)
|
||||
intHeight = this.Height;
|
||||
|
||||
int intWidth = (int)(intHeight / (Math.Tan(Math.PI * (Math.Abs(inclination) / 180.00000))));
|
||||
intHeight += conveyorHeight;
|
||||
if (intHeight >= this.Height)
|
||||
intHeight = this.Height;
|
||||
m_workingRect = new Rectangle((this.Width - intWidth) / 2 + 1, (this.Height - intHeight) / 2 + 1, intWidth - 2, intHeight - 2);
|
||||
}
|
||||
}
|
||||
|
||||
/// <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);
|
||||
var g = e.Graphics;
|
||||
g.SetGDIHigh();
|
||||
//g.FillRectangle(new SolidBrush(Color.FromArgb(100, conveyorColor)), m_workingRect);
|
||||
|
||||
//轴
|
||||
//左端
|
||||
var rectLeft = new Rectangle(m_workingRect.Left + 5, (inclination >= 0 ? (m_workingRect.Bottom - conveyorHeight) : m_workingRect.Top) + 5, conveyorHeight - 10, conveyorHeight - 10);
|
||||
g.FillEllipse(new SolidBrush(conveyorColor), rectLeft);
|
||||
g.FillEllipse(new SolidBrush(Color.White), new Rectangle(rectLeft.Left + (rectLeft.Width - 6) / 2, rectLeft.Top + (rectLeft.Height - 6) / 2, 6, 6));
|
||||
//右端
|
||||
var rectRight = new Rectangle(m_workingRect.Right - conveyorHeight + 5, (inclination >= 0 ? (m_workingRect.Top) : (m_workingRect.Bottom - conveyorHeight)) + 5, conveyorHeight - 10, conveyorHeight - 10);
|
||||
g.FillEllipse(new SolidBrush(conveyorColor), rectRight);
|
||||
g.FillEllipse(new SolidBrush(Color.White), new Rectangle(rectRight.Left + (rectRight.Width - 6) / 2, rectRight.Top + (rectRight.Height - 6) / 2, 6, 6));
|
||||
|
||||
//传送带
|
||||
//左端
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
GraphicsPath pathRegion = new GraphicsPath();
|
||||
path.AddArc(new Rectangle(m_workingRect.Left + 3, (inclination >= 0 ? (m_workingRect.Bottom - conveyorHeight) : m_workingRect.Top) + 3, conveyorHeight - 6, conveyorHeight - 6), 90F - (float)inclination, 180F);
|
||||
pathRegion.AddArc(new Rectangle(m_workingRect.Left, (inclination >= 0 ? (m_workingRect.Bottom - conveyorHeight) : m_workingRect.Top), conveyorHeight, conveyorHeight), 90F - (float)inclination, 180F);
|
||||
//右端
|
||||
path.AddArc(new Rectangle(m_workingRect.Right - conveyorHeight + 3, (inclination >= 0 ? (m_workingRect.Top) : (m_workingRect.Bottom - conveyorHeight)) + 3, conveyorHeight - 6, conveyorHeight - 6), 270 - (float)inclination, 180F);
|
||||
pathRegion.AddArc(new Rectangle(m_workingRect.Right - conveyorHeight, (inclination >= 0 ? (m_workingRect.Top) : (m_workingRect.Bottom - conveyorHeight)), conveyorHeight, conveyorHeight), 270 - (float)inclination, 180F);
|
||||
path.CloseAllFigures();
|
||||
|
||||
base.Region = new System.Drawing.Region(pathRegion);
|
||||
|
||||
g.DrawPath(new Pen(new SolidBrush(conveyorColor), 3), path);
|
||||
|
||||
//液体流动
|
||||
if (ConveyorDirection != ConveyorDirection.None)
|
||||
{
|
||||
Pen p = new Pen(new SolidBrush(Color.FromArgb(150, this.BackColor)), 4);
|
||||
p.DashPattern = new float[] { 6, 6 };
|
||||
p.DashOffset = intLineLeft * (ConveyorDirection == ConveyorDirection.Forward ? -1 : 1);
|
||||
g.DrawPath(p, path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enum ConveyorDirection
|
||||
/// </summary>
|
||||
public enum ConveyorDirection
|
||||
{
|
||||
/// <summary>
|
||||
/// The none
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// The forward
|
||||
/// </summary>
|
||||
Forward,
|
||||
/// <summary>
|
||||
/// The backward
|
||||
/// </summary>
|
||||
Backward
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-10
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCAlarmLamp.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 UCAlarmLamp.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public class UCAlarmLamp : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The lamp color
|
||||
/// </summary>
|
||||
private Color[] lampColor = new Color[] { Color.FromArgb(255, 77, 59) };
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the lamp.
|
||||
/// </summary>
|
||||
/// <value>The color of the lamp.</value>
|
||||
[Description("灯颜色,当需要闪烁时,至少需要2个及以上颜色,不需要闪烁则至少需要1个颜色"), Category("自定义")]
|
||||
public Color[] LampColor
|
||||
{
|
||||
get { return lampColor; }
|
||||
set
|
||||
{
|
||||
if (value == null || value.Length <= 0)
|
||||
return;
|
||||
lampColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The lampstand
|
||||
/// </summary>
|
||||
private Color lampstand = Color.FromArgb(105, 105, 105);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the lampstand.
|
||||
/// </summary>
|
||||
/// <value>The lampstand.</value>
|
||||
[Description("灯座颜色"), Category("自定义")]
|
||||
public Color Lampstand
|
||||
{
|
||||
get { return lampstand; }
|
||||
set { lampstand = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The twinkle speed
|
||||
/// </summary>
|
||||
private int twinkleSpeed = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the twinkle speed.
|
||||
/// </summary>
|
||||
/// <value>The twinkle speed.</value>
|
||||
[Description("闪烁间隔时间(毫秒),当为0时不闪烁"), Category("自定义")]
|
||||
public int TwinkleSpeed
|
||||
{
|
||||
get { return twinkleSpeed; }
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
return;
|
||||
twinkleSpeed = value;
|
||||
if (value == 0 || lampColor.Length <= 1)
|
||||
{
|
||||
timer.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
intColorIndex = 0;
|
||||
timer.Interval = value;
|
||||
timer.Enabled = true;
|
||||
}
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The timer
|
||||
/// </summary>
|
||||
Timer timer;
|
||||
/// <summary>
|
||||
/// The int color index
|
||||
/// </summary>
|
||||
int intColorIndex = 0;
|
||||
/// <summary>
|
||||
/// The m rect working
|
||||
/// </summary>
|
||||
Rectangle m_rectWorking;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCAlarmLamp" /> class.
|
||||
/// </summary>
|
||||
public UCAlarmLamp()
|
||||
{
|
||||
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 += UCAlarmLamp_SizeChanged;
|
||||
this.Size = new Size(50, 50);
|
||||
timer = new Timer();
|
||||
timer.Interval = 200;
|
||||
timer.Tick += timer_Tick;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the UCAlarmLamp 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 UCAlarmLamp_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
m_rectWorking = new Rectangle(10, 0, this.Width - 20, this.Height);
|
||||
}
|
||||
/// <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)
|
||||
{
|
||||
intColorIndex++;
|
||||
if (intColorIndex >= lampColor.Length)
|
||||
intColorIndex = 0;
|
||||
Refresh();
|
||||
}
|
||||
/// <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);
|
||||
var g = e.Graphics;
|
||||
g.SetGDIHigh();
|
||||
|
||||
Color c1 = lampColor[intColorIndex];
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLine(new Point(m_rectWorking.Left, m_rectWorking.Bottom), new Point(m_rectWorking.Left, m_rectWorking.Top + m_rectWorking.Width));
|
||||
path.AddArc(new Rectangle(m_rectWorking.Left, m_rectWorking.Top, m_rectWorking.Width, m_rectWorking.Width), 180f, 180f);
|
||||
path.AddLine(new Point(m_rectWorking.Right, m_rectWorking.Top + m_rectWorking.Width), new Point(m_rectWorking.Right, m_rectWorking.Bottom));
|
||||
path.CloseAllFigures();
|
||||
g.FillPath(new SolidBrush(c1), path);
|
||||
|
||||
g.FillRectangle(new SolidBrush(lampstand), new Rectangle(5, m_rectWorking.Bottom - 19, this.Width - 10, 10));
|
||||
g.FillRectangle(new SolidBrush(lampstand), new Rectangle(0, m_rectWorking.Bottom - 10, this.Width, 10));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-09
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCSignalLamp.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 UCSignalLamp.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public class UCSignalLamp : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The is show border
|
||||
/// </summary>
|
||||
private bool isShowBorder = false;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is show border.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is show border; otherwise, <c>false</c>.</value>
|
||||
[Description("是否显示边框"), Category("自定义")]
|
||||
public bool IsShowBorder
|
||||
{
|
||||
get { return isShowBorder; }
|
||||
set
|
||||
{
|
||||
isShowBorder = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The lamp color
|
||||
/// </summary>
|
||||
private Color[] lampColor = new Color[] { Color.FromArgb(255, 77, 59) };
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the lamp.
|
||||
/// </summary>
|
||||
/// <value>The color of the lamp.</value>
|
||||
[Description("灯颜色,当需要闪烁时,至少需要2个及以上颜色,不需要闪烁则至少需要1个颜色"), Category("自定义")]
|
||||
public Color[] LampColor
|
||||
{
|
||||
get { return lampColor; }
|
||||
set
|
||||
{
|
||||
if (value == null || value.Length <= 0)
|
||||
return;
|
||||
lampColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The is highlight
|
||||
/// </summary>
|
||||
private bool isHighlight = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this instance is highlight.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is highlight; otherwise, <c>false</c>.</value>
|
||||
[Description("是否高亮显示"), Category("自定义")]
|
||||
public bool IsHighlight
|
||||
{
|
||||
get { return isHighlight; }
|
||||
set
|
||||
{
|
||||
isHighlight = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The twinkle speed
|
||||
/// </summary>
|
||||
private int twinkleSpeed = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the twinkle speed.
|
||||
/// </summary>
|
||||
/// <value>The twinkle speed.</value>
|
||||
[Description("闪烁间隔时间(毫秒),当为0时不闪烁"), Category("自定义")]
|
||||
public int TwinkleSpeed
|
||||
{
|
||||
get { return twinkleSpeed; }
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
return;
|
||||
twinkleSpeed = value;
|
||||
if (value == 0 || lampColor.Length <= 1)
|
||||
{
|
||||
timer.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
intColorIndex = 0;
|
||||
timer.Interval = value;
|
||||
timer.Enabled = true;
|
||||
}
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The timer
|
||||
/// </summary>
|
||||
Timer timer;
|
||||
/// <summary>
|
||||
/// The int color index
|
||||
/// </summary>
|
||||
int intColorIndex = 0;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCSignalLamp" /> class.
|
||||
/// </summary>
|
||||
public UCSignalLamp()
|
||||
{
|
||||
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(50, 50);
|
||||
this.SizeChanged += UCSignalLamp_SizeChanged;
|
||||
timer = new Timer();
|
||||
timer.Interval = 200;
|
||||
timer.Tick += timer_Tick;
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
intColorIndex++;
|
||||
if (intColorIndex >= lampColor.Length)
|
||||
intColorIndex = 0;
|
||||
Refresh();
|
||||
}
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the UCSignalLamp 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 UCSignalLamp_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
var maxSize = Math.Min(this.Width, this.Height);
|
||||
if (this.Width != maxSize)
|
||||
this.Width = maxSize;
|
||||
if (this.Height != maxSize)
|
||||
this.Height = maxSize;
|
||||
}
|
||||
|
||||
/// <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);
|
||||
var g = e.Graphics;
|
||||
g.SetGDIHigh();
|
||||
|
||||
Color c1 = lampColor[intColorIndex];
|
||||
g.FillEllipse(new SolidBrush(c1), new Rectangle(this.ClientRectangle.Location, this.ClientRectangle.Size - new Size(1, 1)));
|
||||
|
||||
if (isHighlight)
|
||||
{
|
||||
GraphicsPath gp = new GraphicsPath();
|
||||
|
||||
Rectangle rec = new Rectangle(5, 5, this.Width - 10 - 1, this.Height - 10 - 1);
|
||||
gp.AddEllipse(rec);
|
||||
|
||||
Color[] surroundColor = new Color[] { c1 };
|
||||
PathGradientBrush pb = new PathGradientBrush(gp);
|
||||
pb.CenterColor = Color.White;
|
||||
pb.SurroundColors = surroundColor;
|
||||
g.FillPath(pb, gp);
|
||||
}
|
||||
|
||||
if (isShowBorder)
|
||||
{
|
||||
g.DrawEllipse(new Pen(new SolidBrush(this.BackColor), 2), new Rectangle(4, 4, this.Width - 1 - 8, this.Height - 1 - 8));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,434 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-03
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCMeter.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 UCMeter.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public class UCMeter : UserControl
|
||||
{
|
||||
private int splitCount = 10;
|
||||
/// <summary>
|
||||
/// Gets or sets the split count.
|
||||
/// </summary>
|
||||
/// <value>The split count.</value>
|
||||
[Description("分隔刻度数量,>1"), Category("自定义")]
|
||||
public int SplitCount
|
||||
{
|
||||
get { return splitCount; }
|
||||
set
|
||||
{
|
||||
if (value < 1)
|
||||
return;
|
||||
splitCount = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private int meterDegrees = 150;
|
||||
/// <summary>
|
||||
/// Gets or sets the meter degrees.
|
||||
/// </summary>
|
||||
/// <value>The meter degrees.</value>
|
||||
[Description("表盘跨度角度,0-360"), Category("自定义")]
|
||||
public int MeterDegrees
|
||||
{
|
||||
get { return meterDegrees; }
|
||||
set
|
||||
{
|
||||
if (value > 360 || value <= 0)
|
||||
return;
|
||||
meterDegrees = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private decimal minValue = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the minimum value.
|
||||
/// </summary>
|
||||
/// <value>The minimum value.</value>
|
||||
[Description("最小值,<MaxValue"), Category("自定义")]
|
||||
public decimal MinValue
|
||||
{
|
||||
get { return minValue; }
|
||||
set
|
||||
{
|
||||
if (value >= maxValue)
|
||||
return;
|
||||
minValue = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private decimal maxValue = 100;
|
||||
/// <summary>
|
||||
/// Gets or sets the maximum value.
|
||||
/// </summary>
|
||||
/// <value>The maximum value.</value>
|
||||
[Description("最大值,>MinValue"), Category("自定义")]
|
||||
public decimal MaxValue
|
||||
{
|
||||
get { return maxValue; }
|
||||
set
|
||||
{
|
||||
if (value <= minValue)
|
||||
return;
|
||||
maxValue = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 获取或设置控件显示的文字的字体。
|
||||
/// </summary>
|
||||
/// <value>The font.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
||||
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Description("刻度字体"), Category("自定义")]
|
||||
public override Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Font = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private decimal m_value = 0;
|
||||
/// <summary>
|
||||
/// Gets or sets the value.
|
||||
/// </summary>
|
||||
/// <value>The value.</value>
|
||||
[Description("值,>=MinValue并且<=MaxValue"), Category("自定义")]
|
||||
public decimal Value
|
||||
{
|
||||
get { return m_value; }
|
||||
set
|
||||
{
|
||||
if (value < minValue || value > maxValue)
|
||||
return;
|
||||
m_value = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private MeterTextLocation textLocation = MeterTextLocation.None;
|
||||
/// <summary>
|
||||
/// Gets or sets the text location.
|
||||
/// </summary>
|
||||
/// <value>The text location.</value>
|
||||
[Description("值和固定文字显示位置"), Category("自定义")]
|
||||
public MeterTextLocation TextLocation
|
||||
{
|
||||
get { return textLocation; }
|
||||
set
|
||||
{
|
||||
textLocation = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private string fixedText;
|
||||
/// <summary>
|
||||
/// Gets or sets the fixed text.
|
||||
/// </summary>
|
||||
/// <value>The fixed text.</value>
|
||||
[Description("固定文字"), Category("自定义")]
|
||||
public string FixedText
|
||||
{
|
||||
get { return fixedText; }
|
||||
set
|
||||
{
|
||||
fixedText = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private Font textFont = DefaultFont;
|
||||
/// <summary>
|
||||
/// Gets or sets the text font.
|
||||
/// </summary>
|
||||
/// <value>The text font.</value>
|
||||
[Description("值和固定文字字体"), Category("自定义")]
|
||||
public Font TextFont
|
||||
{
|
||||
get { return textFont; }
|
||||
set
|
||||
{
|
||||
textFont = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private Color externalRoundColor = Color.FromArgb(255, 77, 59);
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the external round.
|
||||
/// </summary>
|
||||
/// <value>The color of the external round.</value>
|
||||
[Description("外圆颜色"), Category("自定义")]
|
||||
public Color ExternalRoundColor
|
||||
{
|
||||
get { return externalRoundColor; }
|
||||
set
|
||||
{
|
||||
externalRoundColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private Color insideRoundColor = Color.FromArgb(255, 77, 59);
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the inside round.
|
||||
/// </summary>
|
||||
/// <value>The color of the inside round.</value>
|
||||
[Description("内圆颜色"), Category("自定义")]
|
||||
public Color InsideRoundColor
|
||||
{
|
||||
get { return insideRoundColor; }
|
||||
set
|
||||
{
|
||||
insideRoundColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private Color boundaryLineColor = Color.FromArgb(255, 77, 59);
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the boundary line.
|
||||
/// </summary>
|
||||
/// <value>The color of the boundary line.</value>
|
||||
[Description("边界线颜色"), Category("自定义")]
|
||||
public Color BoundaryLineColor
|
||||
{
|
||||
get { return boundaryLineColor; }
|
||||
set
|
||||
{
|
||||
boundaryLineColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private Color scaleColor = Color.FromArgb(255, 77, 59);
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the scale.
|
||||
/// </summary>
|
||||
/// <value>The color of the scale.</value>
|
||||
[Description("刻度颜色"), Category("自定义")]
|
||||
public Color ScaleColor
|
||||
{
|
||||
get { return scaleColor; }
|
||||
set
|
||||
{
|
||||
scaleColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private Color scaleValueColor = Color.FromArgb(255, 77, 59);
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the scale value.
|
||||
/// </summary>
|
||||
/// <value>The color of the scale value.</value>
|
||||
[Description("刻度值文字颜色"), Category("自定义")]
|
||||
public Color ScaleValueColor
|
||||
{
|
||||
get { return scaleValueColor; }
|
||||
set
|
||||
{
|
||||
scaleValueColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private Color pointerColor = Color.FromArgb(255, 77, 59);
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the pointer.
|
||||
/// </summary>
|
||||
/// <value>The color of the pointer.</value>
|
||||
[Description("指针颜色"), Category("自定义")]
|
||||
public Color PointerColor
|
||||
{
|
||||
get { return pointerColor; }
|
||||
set
|
||||
{
|
||||
pointerColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
private Color textColor = Color.FromArgb(255, 77, 59);
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the text.
|
||||
/// </summary>
|
||||
/// <value>The color of the text.</value>
|
||||
[Description("值和固定文字颜色"), Category("自定义")]
|
||||
public Color TextColor
|
||||
{
|
||||
get { return textColor; }
|
||||
set
|
||||
{
|
||||
textColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
Rectangle m_rectWorking;
|
||||
public UCMeter()
|
||||
{
|
||||
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.SizeChanged += UCMeter1_SizeChanged;
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.Size = new Size(350, 200);
|
||||
}
|
||||
|
||||
void UCMeter1_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
m_rectWorking = new Rectangle(10, 10, this.Width - 20, this.Height - 20);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
base.OnPaint(e);
|
||||
var g = e.Graphics;
|
||||
g.SetGDIHigh();
|
||||
|
||||
//外圆
|
||||
float fltStartAngle = -90 - (meterDegrees) / 2 + 360;
|
||||
var r1 = new Rectangle(m_rectWorking.Location, new Size(m_rectWorking.Width, m_rectWorking.Width));
|
||||
g.DrawArc(new Pen(new SolidBrush(externalRoundColor), 1), r1, fltStartAngle, meterDegrees);
|
||||
//内圆
|
||||
var r2 = new Rectangle(m_rectWorking.Left + (m_rectWorking.Width - m_rectWorking.Width / 4) / 2, m_rectWorking.Top + (m_rectWorking.Width - m_rectWorking.Width / 4) / 2, m_rectWorking.Width / 4, m_rectWorking.Width / 4);
|
||||
g.DrawArc(new Pen(new SolidBrush(insideRoundColor), 1), r2, fltStartAngle, meterDegrees);
|
||||
|
||||
//边界线
|
||||
if (meterDegrees != 360)
|
||||
{
|
||||
float fltAngle = fltStartAngle - 180;
|
||||
|
||||
float intY = (float)(m_rectWorking.Top + m_rectWorking.Width / 2 - ((m_rectWorking.Width / 2 - m_rectWorking.Width / 8) * Math.Sin(Math.PI * (fltAngle / 180.00F))));
|
||||
float intX = (float)(m_rectWorking.Left + (m_rectWorking.Width / 2 - ((m_rectWorking.Width / 2 - m_rectWorking.Width / 8) * Math.Cos(Math.PI * (fltAngle / 180.00F)))));
|
||||
|
||||
float fltY1 = (float)(m_rectWorking.Top + m_rectWorking.Width / 2 - (m_rectWorking.Width / 8 * Math.Sin(Math.PI * (fltAngle / 180.00F))));
|
||||
float fltX1 = (float)(m_rectWorking.Left + (m_rectWorking.Width / 2 - (m_rectWorking.Width / 8 * Math.Cos(Math.PI * (fltAngle / 180.00F)))));
|
||||
|
||||
g.DrawLine(new Pen(new SolidBrush(boundaryLineColor), 1), new PointF(intX, intY), new PointF(fltX1, fltY1));
|
||||
g.DrawLine(new Pen(new SolidBrush(boundaryLineColor), 1), new PointF(m_rectWorking.Right - (fltX1 - m_rectWorking.Left), fltY1), new PointF(m_rectWorking.Right - (intX - m_rectWorking.Left), intY));
|
||||
}
|
||||
|
||||
//分割线
|
||||
int _splitCount = splitCount * 2;
|
||||
float fltSplitValue = (float)meterDegrees / (float)_splitCount;
|
||||
for (int i = 0; i <= _splitCount; i++)
|
||||
{
|
||||
float fltAngle = (fltStartAngle + fltSplitValue * i - 180) % 360;
|
||||
float fltY1 = (float)(m_rectWorking.Top + m_rectWorking.Width / 2 - ((m_rectWorking.Width / 2) * Math.Sin(Math.PI * (fltAngle / 180.00F))));
|
||||
float fltX1 = (float)(m_rectWorking.Left + (m_rectWorking.Width / 2 - ((m_rectWorking.Width / 2) * Math.Cos(Math.PI * (fltAngle / 180.00F)))));
|
||||
float fltY2 = 0;
|
||||
float fltX2 = 0;
|
||||
if (i % 2 == 0)
|
||||
{
|
||||
fltY2 = (float)(m_rectWorking.Top + m_rectWorking.Width / 2 - ((m_rectWorking.Width / 2 - 10) * Math.Sin(Math.PI * (fltAngle / 180.00F))));
|
||||
fltX2 = (float)(m_rectWorking.Left + (m_rectWorking.Width / 2 - ((m_rectWorking.Width / 2 - 10) * Math.Cos(Math.PI * (fltAngle / 180.00F)))));
|
||||
if (!(meterDegrees == 360 && i == _splitCount))
|
||||
{
|
||||
decimal decValue = minValue + (maxValue - minValue) / _splitCount * i;
|
||||
var txtSize = g.MeasureString(decValue.ToString("0.##"), this.Font);
|
||||
float fltFY1 = (float)(m_rectWorking.Top - txtSize.Height / 2 + m_rectWorking.Width / 2 - ((m_rectWorking.Width / 2 - 20) * Math.Sin(Math.PI * (fltAngle / 180.00F))));
|
||||
float fltFX1 = (float)(m_rectWorking.Left - txtSize.Width / 2 + (m_rectWorking.Width / 2 - ((m_rectWorking.Width / 2 - 20) * Math.Cos(Math.PI * (fltAngle / 180.00F)))));
|
||||
g.DrawString(decValue.ToString("0.##"), Font, new SolidBrush(scaleValueColor), fltFX1, fltFY1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
fltY2 = (float)(m_rectWorking.Top + m_rectWorking.Width / 2 - ((m_rectWorking.Width / 2 - 5) * Math.Sin(Math.PI * (fltAngle / 180.00F))));
|
||||
fltX2 = (float)(m_rectWorking.Left + (m_rectWorking.Width / 2 - ((m_rectWorking.Width / 2 - 5) * Math.Cos(Math.PI * (fltAngle / 180.00F)))));
|
||||
}
|
||||
g.DrawLine(new Pen(new SolidBrush(scaleColor), i % 2 == 0 ? 2 : 1), new PointF(fltX1, fltY1), new PointF(fltX2, fltY2));
|
||||
}
|
||||
|
||||
//值文字和固定文字
|
||||
if (textLocation != MeterTextLocation.None)
|
||||
{
|
||||
string str = m_value.ToString("0.##");
|
||||
var txtSize = g.MeasureString(str, textFont);
|
||||
float fltY = m_rectWorking.Top + m_rectWorking.Width / 4 - txtSize.Height / 2;
|
||||
float fltX = m_rectWorking.Left + m_rectWorking.Width / 2 - txtSize.Width / 2;
|
||||
g.DrawString(str, textFont, new SolidBrush(textColor), new PointF(fltX, fltY));
|
||||
|
||||
if (!string.IsNullOrEmpty(fixedText))
|
||||
{
|
||||
str = fixedText;
|
||||
txtSize = g.MeasureString(str, textFont);
|
||||
fltY = m_rectWorking.Top + m_rectWorking.Width / 4 + txtSize.Height / 2;
|
||||
fltX = m_rectWorking.Left + m_rectWorking.Width / 2 - txtSize.Width / 2;
|
||||
g.DrawString(str, textFont, new SolidBrush(textColor), new PointF(fltX, fltY));
|
||||
}
|
||||
}
|
||||
|
||||
//画指针
|
||||
g.FillEllipse(new SolidBrush(Color.FromArgb(100, pointerColor.R, pointerColor.G, pointerColor.B)), new Rectangle(m_rectWorking.Left + m_rectWorking.Width / 2 - 10, m_rectWorking.Top + m_rectWorking.Width / 2 - 10, 20, 20));
|
||||
g.FillEllipse(new SolidBrush(pointerColor), new Rectangle(m_rectWorking.Left + m_rectWorking.Width / 2 - 5, m_rectWorking.Top + m_rectWorking.Width / 2 - 5, 10, 10));
|
||||
float fltValueAngle = (fltStartAngle + ((float)(m_value - minValue) / (float)(maxValue - minValue)) * (float)meterDegrees - 180) % 360;
|
||||
float intValueY1 = (float)(m_rectWorking.Top + m_rectWorking.Width / 2 - ((m_rectWorking.Width / 2 - 30) * Math.Sin(Math.PI * (fltValueAngle / 180.00F))));
|
||||
float intValueX1 = (float)(m_rectWorking.Left + (m_rectWorking.Width / 2 - ((m_rectWorking.Width / 2 - 30) * Math.Cos(Math.PI * (fltValueAngle / 180.00F)))));
|
||||
g.DrawLine(new Pen(new SolidBrush(pointerColor), 3), intValueX1, intValueY1, m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Top + m_rectWorking.Width / 2);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enum MeterTextLocation
|
||||
/// </summary>
|
||||
public enum MeterTextLocation
|
||||
{
|
||||
/// <summary>
|
||||
/// The none
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// The top
|
||||
/// </summary>
|
||||
Top,
|
||||
/// <summary>
|
||||
/// The bottom
|
||||
/// </summary>
|
||||
Bottom
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,237 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-11
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="MindMappingItemEntity.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.Drawing;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class MindMappingItemEntity.
|
||||
/// </summary>
|
||||
public class MindMappingItemEntity
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the identifier.
|
||||
/// </summary>
|
||||
/// <value>The identifier.</value>
|
||||
public string ID { get; set; }
|
||||
/// <summary>
|
||||
/// The text
|
||||
/// </summary>
|
||||
private string _text;
|
||||
/// <summary>
|
||||
/// Gets or sets the text.
|
||||
/// </summary>
|
||||
/// <value>The text.</value>
|
||||
public string Text
|
||||
{
|
||||
get { return _text; }
|
||||
set
|
||||
{
|
||||
_text = value;
|
||||
ResetSize();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the data source.
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
public object DataSource { get; set; }
|
||||
/// <summary>
|
||||
/// The childrens
|
||||
/// </summary>
|
||||
private MindMappingItemEntity[] _Childrens;
|
||||
/// <summary>
|
||||
/// Gets or sets the childrens.
|
||||
/// </summary>
|
||||
/// <value>The childrens.</value>
|
||||
public MindMappingItemEntity[] Childrens
|
||||
{
|
||||
get { return _Childrens; }
|
||||
set
|
||||
{
|
||||
_Childrens = value;
|
||||
if (value != null && value.Length > 0)
|
||||
{
|
||||
value.ToList().ForEach(p => { if (p != null) { p.ParentItem = this; } });
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The back color
|
||||
/// </summary>
|
||||
private Color? backColor;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the back.
|
||||
/// </summary>
|
||||
/// <value>The color of the back.</value>
|
||||
public Color? BackColor
|
||||
{
|
||||
get { return backColor; }
|
||||
set { backColor = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The font
|
||||
/// </summary>
|
||||
private Font font = new Font("微软雅黑", 10);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the font.
|
||||
/// </summary>
|
||||
/// <value>The font.</value>
|
||||
public Font Font
|
||||
{
|
||||
get { return font; }
|
||||
set
|
||||
{
|
||||
font = value;
|
||||
ResetSize();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The fore color
|
||||
/// </summary>
|
||||
private Color foreColor = Color.Black;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the fore.
|
||||
/// </summary>
|
||||
/// <value>The color of the fore.</value>
|
||||
public Color ForeColor
|
||||
{
|
||||
get { return foreColor; }
|
||||
set { foreColor = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The is expansion
|
||||
/// </summary>
|
||||
private bool _IsExpansion = false;
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether the instance is expanded.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if this instance is expansion; otherwise, <c>false</c>.</value>
|
||||
public bool IsExpansion
|
||||
{
|
||||
get
|
||||
{
|
||||
return _IsExpansion;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == _IsExpansion)
|
||||
return;
|
||||
_IsExpansion = value;
|
||||
if (!value && _Childrens != null && _Childrens.Length > 0)
|
||||
{
|
||||
_Childrens.ToList().ForEach(p => { if (p != null) { p.IsExpansion = false; } });
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the parent item.
|
||||
/// </summary>
|
||||
/// <value>The parent item.</value>
|
||||
public MindMappingItemEntity ParentItem { get; private set; }
|
||||
/// <summary>
|
||||
/// Gets all childrens maximum show count.
|
||||
/// </summary>
|
||||
/// <value>All childrens maximum show count.</value>
|
||||
public int AllChildrensMaxShowHeight { get { return GetAllChildrensMaxShowHeight(); } }
|
||||
/// <summary>
|
||||
/// Gets the maximum level.
|
||||
/// </summary>
|
||||
/// <value>The maximum level.</value>
|
||||
public int AllChildrensMaxShowWidth { get { return GetAllChildrensMaxShowWidth(); } }
|
||||
|
||||
/// <summary>
|
||||
/// Gets all childrens maximum show count.
|
||||
/// </summary>
|
||||
/// <returns>System.Int32.</returns>
|
||||
private int GetAllChildrensMaxShowHeight()
|
||||
{
|
||||
if (!_IsExpansion || _Childrens == null || _Childrens.Length <= 0)
|
||||
return ItemHeight + 10;
|
||||
else
|
||||
{
|
||||
return _Childrens.Sum(p => p == null ? 0 : p.AllChildrensMaxShowHeight);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets the maximum level.
|
||||
/// </summary>
|
||||
/// <returns>System.Int32.</returns>
|
||||
private int GetAllChildrensMaxShowWidth()
|
||||
{
|
||||
if (!_IsExpansion || _Childrens == null || _Childrens.Length <= 0)
|
||||
return ItemWidth + 50;
|
||||
else
|
||||
{
|
||||
return ItemWidth + 50 + _Childrens.Max(p => p == null ? 0 : p.AllChildrensMaxShowWidth);
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the working rectangle.
|
||||
/// </summary>
|
||||
/// <value>The working rectangle.</value>
|
||||
internal RectangleF WorkingRectangle { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the draw rectangle.
|
||||
/// </summary>
|
||||
/// <value>The draw rectangle.</value>
|
||||
internal RectangleF DrawRectangle { get; set; }
|
||||
/// <summary>
|
||||
/// Gets or sets the expansion rectangle.
|
||||
/// </summary>
|
||||
/// <value>The expansion rectangle.</value>
|
||||
internal RectangleF ExpansionRectangle { get; set; }
|
||||
/// <summary>
|
||||
/// Gets the height of the item.
|
||||
/// </summary>
|
||||
/// <value>The height of the item.</value>
|
||||
int ItemHeight { get; set; }
|
||||
/// <summary>
|
||||
/// Gets the width of the item.
|
||||
/// </summary>
|
||||
/// <value>The width of the item.</value>
|
||||
int ItemWidth { get; set; }
|
||||
/// <summary>
|
||||
/// Resets the size.
|
||||
/// </summary>
|
||||
private void ResetSize()
|
||||
{
|
||||
string _t = _text;
|
||||
if (string.IsNullOrEmpty(_t))
|
||||
{
|
||||
_t = "aaaa";
|
||||
}
|
||||
Bitmap bit = new Bitmap(1, 1);
|
||||
var g = Graphics.FromImage(bit);
|
||||
var size = g.MeasureString(_t, font);
|
||||
g.Dispose();
|
||||
bit.Dispose();
|
||||
ItemHeight = (int)size.Height;
|
||||
ItemWidth = (int)size.Width;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,423 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-11
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCMindMapping.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 UCMindMapping.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
internal class UCMindMapping : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The item context menu strip
|
||||
/// </summary>
|
||||
private ContextMenuStrip itemContextMenuStrip;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the item context menu strip.
|
||||
/// </summary>
|
||||
/// <value>The item context menu strip.</value>
|
||||
[Description("节点关联的右键菜单"), Category("自定义")]
|
||||
public ContextMenuStrip ItemContextMenuStrip
|
||||
{
|
||||
get { return itemContextMenuStrip; }
|
||||
set { itemContextMenuStrip = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// The item backcolor
|
||||
/// </summary>
|
||||
private Color itemBackcolor = Color.FromArgb(255, 77, 59);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the item backcolor.
|
||||
/// </summary>
|
||||
/// <value>The item backcolor.</value>
|
||||
[Description("节点背景色,优先级小于数据源中设置的背景色"), Category("自定义")]
|
||||
public Color ItemBackcolor
|
||||
{
|
||||
get { return itemBackcolor; }
|
||||
set
|
||||
{
|
||||
itemBackcolor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The line color
|
||||
/// </summary>
|
||||
private Color lineColor = Color.Black;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the line.
|
||||
/// </summary>
|
||||
/// <value>The color of the line.</value>
|
||||
[Description("线条颜色"), Category("自定义")]
|
||||
public Color LineColor
|
||||
{
|
||||
get { return lineColor; }
|
||||
set
|
||||
{
|
||||
lineColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The split width
|
||||
/// </summary>
|
||||
private int splitWidth = 50;
|
||||
// private int itemHeight = 20;
|
||||
/// <summary>
|
||||
/// The padding
|
||||
/// </summary>
|
||||
private int padding = 20;
|
||||
|
||||
/// <summary>
|
||||
/// The m rect working
|
||||
/// </summary>
|
||||
Rectangle m_rectWorking = Rectangle.Empty;
|
||||
/// <summary>
|
||||
/// Occurs when [item clicked].
|
||||
/// </summary>
|
||||
public event EventHandler ItemClicked;
|
||||
/// <summary>
|
||||
/// The data source
|
||||
/// </summary>
|
||||
private MindMappingItemEntity dataSource;
|
||||
|
||||
/// <summary>
|
||||
/// The select entity
|
||||
/// </summary>
|
||||
private MindMappingItemEntity selectEntity;
|
||||
/// <summary>
|
||||
/// Gets the select entity.
|
||||
/// </summary>
|
||||
/// <value>The select entity.</value>
|
||||
[Description("选中的数据源"), Category("自定义")]
|
||||
public MindMappingItemEntity SelectEntity
|
||||
{
|
||||
get { return selectEntity; }
|
||||
private set { selectEntity = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the data source.
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
[Description("数据源"), Category("自定义")]
|
||||
public MindMappingItemEntity DataSource
|
||||
{
|
||||
get { return dataSource; }
|
||||
set
|
||||
{
|
||||
dataSource = value;
|
||||
|
||||
ResetSize();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCMindMapping" /> class.
|
||||
/// </summary>
|
||||
public UCMindMapping()
|
||||
{
|
||||
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.Click += UCMindMapping_Click;
|
||||
this.DoubleClick += UCMindMapping_DoubleClick;
|
||||
this.Load += UCMindMapping_Load;
|
||||
this.MouseClick += UCMindMapping_MouseClick;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Handles the Load event of the UCMindMapping 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 UCMindMapping_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (this.Parent != null)
|
||||
{
|
||||
//父控件大小改变时重置大小和位置
|
||||
this.Parent.SizeChanged += (a, b) =>
|
||||
{
|
||||
ResetSize();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 双击处理,主要用于检测节点双击展开折叠
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
void UCMindMapping_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
var mouseLocation = this.PointToClient(Control.MousePosition);
|
||||
|
||||
bool bln = CheckDrawRectClick(dataSource, mouseLocation);
|
||||
if (bln)
|
||||
{
|
||||
ResetSize();
|
||||
this.Parent.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单击处理,主要用于单击节点事件和,展开关闭圆圈处理
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||
void UCMindMapping_Click(object sender, EventArgs e)
|
||||
{
|
||||
var mouseLocation = this.PointToClient(Control.MousePosition);
|
||||
|
||||
bool bln = CheckExpansionClick(dataSource, mouseLocation);
|
||||
if (bln)
|
||||
{
|
||||
ResetSize();
|
||||
this.Parent.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseClick event of the UCMindMapping control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs"/> instance containing the event data.</param>
|
||||
void UCMindMapping_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (itemContextMenuStrip != null && e.Button == System.Windows.Forms.MouseButtons.Right)
|
||||
{
|
||||
bool bln = CheckDrawRectClick(dataSource, e.Location, false);
|
||||
if (bln)
|
||||
{
|
||||
itemContextMenuStrip.Show(this.PointToScreen(e.Location));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 双击检查
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="mouseLocation">The mouse location.</param>
|
||||
/// <param name="blnDoExpansion">if set to <c>true</c> [BLN do expansion].</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
private bool CheckDrawRectClick(MindMappingItemEntity item, Point mouseLocation, bool blnDoExpansion = true)
|
||||
{
|
||||
if (item == null)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
if (item.DrawRectangle.Contains(mouseLocation))
|
||||
{
|
||||
if (blnDoExpansion)
|
||||
item.IsExpansion = !item.IsExpansion;
|
||||
return true;
|
||||
}
|
||||
if (item.Childrens != null && item.Childrens.Length > 0)
|
||||
{
|
||||
foreach (var child in item.Childrens)
|
||||
{
|
||||
var bln = CheckDrawRectClick(child, mouseLocation, blnDoExpansion);
|
||||
if (bln)
|
||||
return bln;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 单击检查
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="mouseLocation">The mouse location.</param>
|
||||
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||
private bool CheckExpansionClick(MindMappingItemEntity item, Point mouseLocation)
|
||||
{
|
||||
if (item == null)
|
||||
return false;
|
||||
else
|
||||
{
|
||||
if (item.DrawRectangle.Contains(mouseLocation))
|
||||
{
|
||||
selectEntity = item;
|
||||
if (ItemClicked != null )
|
||||
{
|
||||
ItemClicked(item, null);
|
||||
}
|
||||
}
|
||||
|
||||
if (item.ExpansionRectangle.Contains(mouseLocation))
|
||||
{
|
||||
item.IsExpansion = !item.IsExpansion;
|
||||
return true;
|
||||
}
|
||||
if (item.Childrens != null && item.Childrens.Length > 0)
|
||||
{
|
||||
foreach (var child in item.Childrens)
|
||||
{
|
||||
var bln = CheckExpansionClick(child, mouseLocation);
|
||||
if (bln)
|
||||
return bln;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
try
|
||||
{
|
||||
base.OnPaint(e);
|
||||
if (m_rectWorking == Rectangle.Empty || m_rectWorking == null)
|
||||
return;
|
||||
var g = e.Graphics;
|
||||
g.SetGDIHigh();
|
||||
|
||||
int intHeight = dataSource.AllChildrensMaxShowHeight;
|
||||
dataSource.WorkingRectangle = new RectangleF(m_rectWorking.Left, m_rectWorking.Top + (m_rectWorking.Height - intHeight) / 2, m_rectWorking.Width, intHeight);
|
||||
|
||||
DrawItem(dataSource, g);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
MessageBox.Show(exc.ToString(), "错误");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 画节点
|
||||
/// </summary>
|
||||
/// <param name="item">The item.</param>
|
||||
/// <param name="g">The g.</param>
|
||||
private void DrawItem(MindMappingItemEntity item, Graphics g)
|
||||
{
|
||||
//节点
|
||||
var size = g.MeasureString(item.Text, item.Font);
|
||||
item.DrawRectangle = new RectangleF(item.WorkingRectangle.Left + 2, item.WorkingRectangle.Top + (item.WorkingRectangle.Height - size.Height) / 2 + 2, size.Width + 4, size.Height + 4);
|
||||
GraphicsPath drawPath = item.DrawRectangle.CreateRoundedRectanglePath(5);
|
||||
if (item.BackColor.HasValue)
|
||||
g.FillPath(new SolidBrush(item.BackColor.Value), drawPath);
|
||||
else
|
||||
g.FillPath(new SolidBrush(itemBackcolor), drawPath);
|
||||
|
||||
g.DrawString(item.Text, item.Font, new SolidBrush(item.ForeColor), item.DrawRectangle.Location.X + 2, item.DrawRectangle.Location.Y + 2);
|
||||
//子节点
|
||||
if (item.Childrens != null && item.IsExpansion)
|
||||
{
|
||||
for (int i = 0; i < item.Childrens.Length; i++)
|
||||
{
|
||||
var child = item.Childrens[i];
|
||||
if (i == 0)
|
||||
{
|
||||
child.WorkingRectangle = new RectangleF(item.DrawRectangle.Right + splitWidth, item.WorkingRectangle.Top, item.WorkingRectangle.Width - (item.DrawRectangle.Width + splitWidth), child.AllChildrensMaxShowHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
child.WorkingRectangle = new RectangleF(item.DrawRectangle.Right + splitWidth, item.Childrens[i - 1].WorkingRectangle.Bottom, item.WorkingRectangle.Width - (item.DrawRectangle.Width + splitWidth), child.AllChildrensMaxShowHeight);
|
||||
}
|
||||
DrawItem(child, g);
|
||||
}
|
||||
}
|
||||
//连线
|
||||
if (item.ParentItem != null)
|
||||
{
|
||||
g.DrawLines(new Pen(new SolidBrush(lineColor), 1), new PointF[]
|
||||
{
|
||||
new PointF(item.ParentItem.DrawRectangle.Right,item.ParentItem.DrawRectangle.Top+item.ParentItem.DrawRectangle.Height/2),
|
||||
new PointF(item.ParentItem.DrawRectangle.Right+12,item.ParentItem.DrawRectangle.Top+item.ParentItem.DrawRectangle.Height/2),
|
||||
//new PointF(item.ParentItem.DrawRectangle.Right+12,item.DrawRectangle.Top+item.DrawRectangle.Height/2),
|
||||
new PointF(item.DrawRectangle.Left-12,item.DrawRectangle.Top+item.DrawRectangle.Height/2),
|
||||
new PointF(item.DrawRectangle.Left,item.DrawRectangle.Top+item.DrawRectangle.Height/2),
|
||||
});
|
||||
}
|
||||
//展开折叠按钮
|
||||
if (item.Childrens != null && item.Childrens.Length > 0)
|
||||
{
|
||||
RectangleF _rect = new RectangleF(item.DrawRectangle.Right + 1, item.DrawRectangle.Top + (item.DrawRectangle.Height - 10) / 2, 10, 10);
|
||||
item.ExpansionRectangle = _rect;
|
||||
g.FillEllipse(new SolidBrush(this.BackColor), _rect);
|
||||
g.DrawEllipse(new Pen(new SolidBrush(Color.Black)), _rect);
|
||||
g.DrawLine(new Pen(new SolidBrush(lineColor)), _rect.Left + 2, _rect.Y + _rect.Height / 2, _rect.Right - 2, _rect.Y + _rect.Height / 2);
|
||||
if (!item.IsExpansion)
|
||||
{
|
||||
g.DrawLine(new Pen(new SolidBrush(lineColor)), _rect.Left + _rect.Width / 2, _rect.Top + 2, _rect.Left + _rect.Width / 2, _rect.Bottom - 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 重置大小
|
||||
/// </summary>
|
||||
private void ResetSize()
|
||||
{
|
||||
if (this.Parent == null)
|
||||
return;
|
||||
try
|
||||
{
|
||||
ControlHelper.FreezeControl(this, true);
|
||||
if (dataSource == null)
|
||||
{
|
||||
m_rectWorking = Rectangle.Empty;
|
||||
this.Size = this.Parent.Size;
|
||||
}
|
||||
else
|
||||
{
|
||||
int intWidth = dataSource.AllChildrensMaxShowWidth;
|
||||
int intHeight = dataSource.AllChildrensMaxShowHeight;
|
||||
this.Width = intWidth + padding * 2;
|
||||
this.Height = intHeight + padding * 2;
|
||||
if (this.Width < this.Parent.Width)
|
||||
this.Width = this.Parent.Width;
|
||||
m_rectWorking = new Rectangle(padding, padding, intWidth, intHeight);
|
||||
if (this.Height > this.Parent.Height)
|
||||
{
|
||||
//this.Location = new Point(0, 0);
|
||||
}
|
||||
else
|
||||
this.Location = new Point(0, (this.Parent.Height - this.Height) / 2);
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
ControlHelper.FreezeControl(this, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
80
UsingControl/HZHControls/Controls/FactoryControls/MindMapping/UCMindMappingPanel.Designer.cs
generated
Normal file
80
UsingControl/HZHControls/Controls/FactoryControls/MindMapping/UCMindMappingPanel.Designer.cs
generated
Normal file
@@ -0,0 +1,80 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-11
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCMindMappingPanel.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCMindMappingPanel.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
partial class UCMindMappingPanel
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.ucMindMapping1 = new HZH_Controls.Controls.UCMindMapping();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ucMindMapping1
|
||||
//
|
||||
this.ucMindMapping1.Location = new System.Drawing.Point(0, 0);
|
||||
this.ucMindMapping1.Name = "ucMindMapping1";
|
||||
this.ucMindMapping1.Size = new System.Drawing.Size(200, 200);
|
||||
this.ucMindMapping1.TabIndex = 0;
|
||||
//
|
||||
// UCMindMappingPanel
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.AutoScroll = true;
|
||||
this.BackColor = System.Drawing.Color.White;
|
||||
this.Controls.Add(this.ucMindMapping1);
|
||||
this.Name = "UCMindMappingPanel";
|
||||
this.Size = new System.Drawing.Size(200, 200);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The uc mind mapping1
|
||||
/// </summary>
|
||||
private UCMindMapping ucMindMapping1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-11
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCMindMappingPanel.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCMindMappingPanel.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
[DefaultEvent("ItemClicked")]
|
||||
public partial class UCMindMappingPanel : UserControl
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// The item context menu strip
|
||||
/// </summary>
|
||||
private ContextMenuStrip itemContextMenuStrip;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the item context menu strip.
|
||||
/// </summary>
|
||||
/// <value>The item context menu strip.</value>
|
||||
[Description("节点关联的右键菜单"), Category("自定义")]
|
||||
public ContextMenuStrip ItemContextMenuStrip
|
||||
{
|
||||
get { return itemContextMenuStrip; }
|
||||
set
|
||||
{
|
||||
itemContextMenuStrip = value;
|
||||
this.ucMindMapping1.ItemContextMenuStrip = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The item backcolor
|
||||
/// </summary>
|
||||
private Color itemBackcolor = Color.FromArgb(255, 77, 59);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the item backcolor.
|
||||
/// </summary>
|
||||
/// <value>The item backcolor.</value>
|
||||
[Description("节点背景色,优先级小于数据源中设置的背景色"), Category("自定义")]
|
||||
public Color ItemBackcolor
|
||||
{
|
||||
get { return itemBackcolor; }
|
||||
set
|
||||
{
|
||||
itemBackcolor = value;
|
||||
this.ucMindMapping1.ItemBackcolor = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The data source
|
||||
/// </summary>
|
||||
private MindMappingItemEntity dataSource;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the data source.
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
[Description("数据源"), Category("自定义")]
|
||||
public MindMappingItemEntity DataSource
|
||||
{
|
||||
get { return dataSource; }
|
||||
set
|
||||
{
|
||||
dataSource = value;
|
||||
this.ucMindMapping1.DataSource = value;
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Gets or sets the data source.
|
||||
/// </summary>
|
||||
/// <value>The data source.</value>
|
||||
[Description("数据源"), Category("自定义")]
|
||||
public event EventHandler ItemClicked;
|
||||
|
||||
/// <summary>
|
||||
/// The line color
|
||||
/// </summary>
|
||||
private Color lineColor = Color.Black;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the line.
|
||||
/// </summary>
|
||||
/// <value>The color of the line.</value>
|
||||
[Description("线条颜色"), Category("自定义")]
|
||||
public Color LineColor
|
||||
{
|
||||
get { return lineColor; }
|
||||
set
|
||||
{
|
||||
lineColor = value;
|
||||
this.ucMindMapping1.LineColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Gets the select entity.
|
||||
/// </summary>
|
||||
/// <value>The select entity.</value>
|
||||
[Description("选中的数据源"), Category("自定义")]
|
||||
public MindMappingItemEntity SelectEntity
|
||||
{
|
||||
get { return ucMindMapping1.SelectEntity; }
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCMindMappingPanel" /> class.
|
||||
/// </summary>
|
||||
public UCMindMappingPanel()
|
||||
{
|
||||
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);
|
||||
InitializeComponent();
|
||||
ucMindMapping1.ItemClicked += ucMindMapping1_ItemClicked;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the ItemClicked event of the ucMindMapping1 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 ucMindMapping1_ItemClicked(object sender, EventArgs e)
|
||||
{
|
||||
if (ItemClicked != null)
|
||||
{
|
||||
ItemClicked(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
174
UsingControl/HZHControls/Controls/FactoryControls/Pond/UCPond.cs
Normal file
174
UsingControl/HZHControls/Controls/FactoryControls/Pond/UCPond.cs
Normal file
@@ -0,0 +1,174 @@
|
||||
// ***********************************************************************
|
||||
// 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>
|
||||
/// 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; }
|
||||
}
|
||||
/// <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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,475 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-10
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCThermometer.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 UCThermometer.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public class UCThermometer : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The glass tube color
|
||||
/// </summary>
|
||||
private Color glassTubeColor = Color.FromArgb(211, 211, 211);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the glass tube.
|
||||
/// </summary>
|
||||
/// <value>The color of the glass tube.</value>
|
||||
[Description("玻璃管颜色"), Category("自定义")]
|
||||
public Color GlassTubeColor
|
||||
{
|
||||
get { return glassTubeColor; }
|
||||
set
|
||||
{
|
||||
glassTubeColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The mercury color
|
||||
/// </summary>
|
||||
private Color mercuryColor = Color.FromArgb(255, 77, 59);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the mercury.
|
||||
/// </summary>
|
||||
/// <value>The color of the mercury.</value>
|
||||
[Description("水印颜色"), Category("自定义")]
|
||||
public Color MercuryColor
|
||||
{
|
||||
get { return mercuryColor; }
|
||||
set
|
||||
{
|
||||
mercuryColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The minimum value
|
||||
/// </summary>
|
||||
private decimal minValue = 0;
|
||||
/// <summary>
|
||||
/// 左侧刻度最小值
|
||||
/// </summary>
|
||||
/// <value>The minimum value.</value>
|
||||
[Description("左侧刻度最小值"), Category("自定义")]
|
||||
public decimal MinValue
|
||||
{
|
||||
get { return minValue; }
|
||||
set
|
||||
{
|
||||
minValue = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The maximum value
|
||||
/// </summary>
|
||||
private decimal maxValue = 100;
|
||||
/// <summary>
|
||||
/// 左侧刻度最大值
|
||||
/// </summary>
|
||||
/// <value>The maximum value.</value>
|
||||
[Description("左侧刻度最大值"), Category("自定义")]
|
||||
public decimal MaxValue
|
||||
{
|
||||
get { return maxValue; }
|
||||
set
|
||||
{
|
||||
maxValue = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m value
|
||||
/// </summary>
|
||||
private decimal m_value = 10;
|
||||
/// <summary>
|
||||
/// 左侧刻度值
|
||||
/// </summary>
|
||||
/// <value>The value.</value>
|
||||
[Description("左侧刻度值"), Category("自定义")]
|
||||
public decimal Value
|
||||
{
|
||||
get { return m_value; }
|
||||
set
|
||||
{
|
||||
m_value = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The split count
|
||||
/// </summary>
|
||||
private int splitCount = 0;
|
||||
/// <summary>
|
||||
/// 刻度分隔份数
|
||||
/// </summary>
|
||||
/// <value>The split count.</value>
|
||||
[Description("刻度分隔份数"), Category("自定义")]
|
||||
public int SplitCount
|
||||
{
|
||||
get { return splitCount; }
|
||||
set
|
||||
{
|
||||
if (value <= 0)
|
||||
return;
|
||||
splitCount = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置控件显示的文字的字体。
|
||||
/// </summary>
|
||||
/// <value>The font.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.EnvironmentPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// <IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Flags="UnmanagedCode, ControlEvidence" />
|
||||
/// <IPermission class="System.Diagnostics.PerformanceCounterPermission, System, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Description("获取或设置控件显示的文字的字体"), Category("自定义")]
|
||||
public override Font Font
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.Font;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.Font = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置控件的前景色。
|
||||
/// </summary>
|
||||
/// <value>The color of the fore.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Description("获取或设置控件的文字及刻度颜色"), Category("自定义")]
|
||||
public override System.Drawing.Color ForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ForeColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The left temperature unit
|
||||
/// </summary>
|
||||
private TemperatureUnit leftTemperatureUnit = TemperatureUnit.C;
|
||||
/// <summary>
|
||||
/// 左侧刻度单位,不可为none
|
||||
/// </summary>
|
||||
/// <value>The left temperature unit.</value>
|
||||
[Description("左侧刻度单位,不可为none"), Category("自定义")]
|
||||
public TemperatureUnit LeftTemperatureUnit
|
||||
{
|
||||
get { return leftTemperatureUnit; }
|
||||
set
|
||||
{
|
||||
if (value == TemperatureUnit.None)
|
||||
return;
|
||||
leftTemperatureUnit = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The right temperature unit
|
||||
/// </summary>
|
||||
private TemperatureUnit rightTemperatureUnit = TemperatureUnit.C;
|
||||
/// <summary>
|
||||
/// 右侧刻度单位,当为none时,不显示
|
||||
/// </summary>
|
||||
/// <value>The right temperature unit.</value>
|
||||
[Description("右侧刻度单位,当为none时,不显示"), Category("自定义")]
|
||||
public TemperatureUnit RightTemperatureUnit
|
||||
{
|
||||
get { return rightTemperatureUnit; }
|
||||
set
|
||||
{
|
||||
rightTemperatureUnit = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m rect working
|
||||
/// </summary>
|
||||
Rectangle m_rectWorking;
|
||||
/// <summary>
|
||||
/// The m rect left
|
||||
/// </summary>
|
||||
Rectangle m_rectLeft;
|
||||
/// <summary>
|
||||
/// The m rect right
|
||||
/// </summary>
|
||||
Rectangle m_rectRight;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCThermometer" /> class.
|
||||
/// </summary>
|
||||
public UCThermometer()
|
||||
{
|
||||
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 += UCThermometer_SizeChanged;
|
||||
this.Size = new Size(70, 200);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the UCThermometer 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 UCThermometer_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
m_rectWorking = new Rectangle(this.Width / 2 - this.Width / 8, this.Width / 4, this.Width / 4, this.Height - this.Width / 2);
|
||||
m_rectLeft = new Rectangle(0, m_rectWorking.Top + m_rectWorking.Width / 2, (this.Width - this.Width / 4) / 2 - 2, m_rectWorking.Height - m_rectWorking.Width * 2);
|
||||
m_rectRight = new Rectangle(this.Width - (this.Width - this.Width / 4) / 2 + 2, m_rectWorking.Top + m_rectWorking.Width / 2, (this.Width - this.Width / 4) / 2 - 2, m_rectWorking.Height - m_rectWorking.Width * 2);
|
||||
}
|
||||
|
||||
/// <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);
|
||||
var g = e.Graphics;
|
||||
g.SetGDIHigh();
|
||||
|
||||
//玻璃管管
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLine(m_rectWorking.Left, m_rectWorking.Bottom, m_rectWorking.Left, m_rectWorking.Top + m_rectWorking.Width / 2);
|
||||
path.AddArc(new Rectangle(m_rectWorking.Left, m_rectWorking.Top, m_rectWorking.Width, m_rectWorking.Width), 180, 180);
|
||||
path.AddLine(m_rectWorking.Right, m_rectWorking.Top + m_rectWorking.Width / 2, m_rectWorking.Right, m_rectWorking.Bottom);
|
||||
path.CloseAllFigures();
|
||||
g.FillPath(new SolidBrush(glassTubeColor), path);
|
||||
|
||||
//底部
|
||||
var rectDi = new Rectangle(this.Width / 2 - m_rectWorking.Width, m_rectWorking.Bottom - m_rectWorking.Width - 2, m_rectWorking.Width * 2, m_rectWorking.Width * 2);
|
||||
g.FillEllipse(new SolidBrush(glassTubeColor), rectDi);
|
||||
g.FillEllipse(new SolidBrush(mercuryColor), new Rectangle(rectDi.Left + 4, rectDi.Top + 4, rectDi.Width - 8, rectDi.Height - 8));
|
||||
|
||||
//刻度
|
||||
decimal decSplit = (maxValue - minValue) / splitCount;
|
||||
decimal decSplitHeight = m_rectLeft.Height / splitCount;
|
||||
for (int i = 0; i <= splitCount; i++)
|
||||
{
|
||||
g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectLeft.Left + 2, (float)(m_rectLeft.Bottom - decSplitHeight * i)), new PointF(m_rectLeft.Right, (float)(m_rectLeft.Bottom - decSplitHeight * i)));
|
||||
|
||||
var valueLeft = (minValue + decSplit * i).ToString("0.##");
|
||||
var sizeLeft = g.MeasureString(valueLeft, Font);
|
||||
g.DrawString(valueLeft, Font, new SolidBrush(ForeColor), new PointF(m_rectLeft.Left, m_rectLeft.Bottom - (float)decSplitHeight * i - sizeLeft.Height - 1));
|
||||
|
||||
if (rightTemperatureUnit != TemperatureUnit.None)
|
||||
{
|
||||
g.DrawLine(new Pen(new SolidBrush(Color.Black), 1), new PointF(m_rectRight.Left + 2, (float)(m_rectRight.Bottom - decSplitHeight * i)), new PointF(m_rectRight.Right, (float)(m_rectRight.Bottom - decSplitHeight * i)));
|
||||
var valueRight = GetRightValue(minValue + decSplit * i).ToString("0.##");
|
||||
var sizeRight = g.MeasureString(valueRight, Font);
|
||||
g.DrawString(valueRight, Font, new SolidBrush(ForeColor), new PointF(m_rectRight.Right - sizeRight.Width - 1, m_rectRight.Bottom - (float)decSplitHeight * i - sizeRight.Height - 1));
|
||||
}
|
||||
if (i != splitCount)
|
||||
{
|
||||
if (decSplitHeight > 40)
|
||||
{
|
||||
var decSp1 = decSplitHeight / 10;
|
||||
for (int j = 1; j < 10; j++)
|
||||
{
|
||||
if (j == 5)
|
||||
{
|
||||
g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectLeft.Right - 10, (m_rectLeft.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))), new PointF(m_rectLeft.Right, (m_rectLeft.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))));
|
||||
if (rightTemperatureUnit != TemperatureUnit.None)
|
||||
{
|
||||
g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectRight.Left + 10, (m_rectRight.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))), new PointF(m_rectRight.Left, (m_rectRight.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectLeft.Right - 5, (m_rectLeft.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))), new PointF(m_rectLeft.Right, (m_rectLeft.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))));
|
||||
if (rightTemperatureUnit != TemperatureUnit.None)
|
||||
{
|
||||
g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectRight.Left + 5, (m_rectRight.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))), new PointF(m_rectRight.Left, (m_rectRight.Bottom - (float)decSplitHeight * i - ((float)decSp1 * j))));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (decSplitHeight > 10)
|
||||
{
|
||||
g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectLeft.Right - 5, (m_rectLeft.Bottom - (float)decSplitHeight * i - (float)decSplitHeight / 2)), new PointF(m_rectLeft.Right, (m_rectLeft.Bottom - (float)decSplitHeight * i - (float)decSplitHeight / 2)));
|
||||
if (rightTemperatureUnit != TemperatureUnit.None)
|
||||
{
|
||||
g.DrawLine(new Pen(new SolidBrush(ForeColor), 1), new PointF(m_rectRight.Left + 5, (m_rectRight.Bottom - (float)decSplitHeight * i - (float)decSplitHeight / 2)), new PointF(m_rectRight.Left, (m_rectRight.Bottom - (float)decSplitHeight * i - (float)decSplitHeight / 2)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//单位
|
||||
string strLeftUnit = GetUnitChar(leftTemperatureUnit);
|
||||
g.DrawString(strLeftUnit, Font, new SolidBrush(ForeColor), new PointF(m_rectLeft.Left + 2, 2));
|
||||
if (rightTemperatureUnit != TemperatureUnit.None)
|
||||
{
|
||||
string strRightUnit = GetUnitChar(rightTemperatureUnit);
|
||||
var rightSize = g.MeasureString(strRightUnit, Font);
|
||||
g.DrawString(strRightUnit, Font, new SolidBrush(ForeColor), new PointF(m_rectRight.Right - 2 - rightSize.Width, 2));
|
||||
}
|
||||
//值
|
||||
float fltHeightValue = (float)(Value / (maxValue - minValue) * m_rectLeft.Height);
|
||||
RectangleF rectValue = new RectangleF(m_rectWorking.Left + 4, m_rectLeft.Top + (m_rectLeft.Height - fltHeightValue), m_rectWorking.Width - 8, fltHeightValue + (m_rectWorking.Height - m_rectWorking.Width / 2 - m_rectLeft.Height));
|
||||
g.FillRectangle(new SolidBrush(mercuryColor), rectValue);
|
||||
|
||||
|
||||
var sizeValue = g.MeasureString(m_value.ToString("0.##"), Font);
|
||||
g.DrawString(m_value.ToString("0.##"), Font, new SolidBrush(Color.White), new PointF(rectDi.Left + (rectDi.Width - sizeValue.Width) / 2, rectDi.Top + (rectDi.Height - sizeValue.Height) / 2 + 1));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the unit character.
|
||||
/// </summary>
|
||||
/// <param name="unit">The unit.</param>
|
||||
/// <returns>System.String.</returns>
|
||||
private string GetUnitChar(TemperatureUnit unit)
|
||||
{
|
||||
string strUnit = "℃";
|
||||
switch (unit)
|
||||
{
|
||||
case TemperatureUnit.C:
|
||||
strUnit = "℃";
|
||||
break;
|
||||
case TemperatureUnit.F:
|
||||
strUnit = "℉";
|
||||
break;
|
||||
case TemperatureUnit.K:
|
||||
strUnit = "K";
|
||||
break;
|
||||
case TemperatureUnit.R:
|
||||
strUnit = "°R";
|
||||
break;
|
||||
case TemperatureUnit.Re:
|
||||
strUnit = "°Re";
|
||||
break;
|
||||
}
|
||||
return strUnit;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the right value.
|
||||
/// </summary>
|
||||
/// <param name="decValue">The decimal value.</param>
|
||||
/// <returns>System.Decimal.</returns>
|
||||
private decimal GetRightValue(decimal decValue)
|
||||
{
|
||||
//先将左侧的换算为摄氏度
|
||||
var dec = decValue;
|
||||
switch (leftTemperatureUnit)
|
||||
{
|
||||
case TemperatureUnit.F:
|
||||
dec = (decValue - 32) / (9M / 5M);
|
||||
break;
|
||||
case TemperatureUnit.K:
|
||||
dec = decValue - 273;
|
||||
break;
|
||||
case TemperatureUnit.R:
|
||||
dec = decValue / (5M / 9M) - 273.15M;
|
||||
break;
|
||||
case TemperatureUnit.Re:
|
||||
dec = decValue / 1.25M;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
switch (rightTemperatureUnit)
|
||||
{
|
||||
case TemperatureUnit.C:
|
||||
return dec;
|
||||
case TemperatureUnit.F:
|
||||
return 9M / 5M * dec + 32;
|
||||
case TemperatureUnit.K:
|
||||
return dec + 273;
|
||||
case TemperatureUnit.R:
|
||||
return (dec + 273.15M) * (5M / 9M);
|
||||
case TemperatureUnit.Re:
|
||||
return dec * 1.25M;
|
||||
}
|
||||
return decValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enum TemperatureUnit
|
||||
/// </summary>
|
||||
public enum TemperatureUnit
|
||||
{
|
||||
/// <summary>
|
||||
/// 不显示
|
||||
/// </summary>
|
||||
None,
|
||||
/// <summary>
|
||||
/// 摄氏度
|
||||
/// </summary>
|
||||
C,
|
||||
/// <summary>
|
||||
/// 华氏度
|
||||
/// </summary>
|
||||
F,
|
||||
/// <summary>
|
||||
/// 开氏度
|
||||
/// </summary>
|
||||
K,
|
||||
/// <summary>
|
||||
/// 兰氏度
|
||||
/// </summary>
|
||||
R,
|
||||
/// <summary>
|
||||
/// 列氏度
|
||||
/// </summary>
|
||||
Re
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,449 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 2019-09-06
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCValve.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 HZH_Controls.Controls;
|
||||
using System.ComponentModel;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCValve.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public class UCValve : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when [open checked].
|
||||
/// </summary>
|
||||
[Description("打开状态改变事件"), Category("自定义")]
|
||||
public event EventHandler OpenChecked;
|
||||
/// <summary>
|
||||
/// The valve style
|
||||
/// </summary>
|
||||
private ValveStyle valveStyle = ValveStyle.Horizontal_Top;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the valve style.
|
||||
/// </summary>
|
||||
/// <value>The valve style.</value>
|
||||
[Description("阀门样式"), Category("自定义")]
|
||||
public ValveStyle ValveStyle
|
||||
{
|
||||
get { return valveStyle; }
|
||||
set
|
||||
{
|
||||
valveStyle = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The valve color
|
||||
/// </summary>
|
||||
private Color valveColor = Color.FromArgb(255, 77, 59);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the valve.
|
||||
/// </summary>
|
||||
/// <value>The color of the valve.</value>
|
||||
[Description("阀门颜色"), Category("自定义")]
|
||||
public Color ValveColor
|
||||
{
|
||||
get { return valveColor; }
|
||||
set
|
||||
{
|
||||
valveColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The switch color
|
||||
/// </summary>
|
||||
private Color switchColor = Color.FromArgb(232, 30, 99);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the switch.
|
||||
/// </summary>
|
||||
/// <value>The color of the switch.</value>
|
||||
[Description("开关把手颜色"), Category("自定义")]
|
||||
public Color SwitchColor
|
||||
{
|
||||
get { return switchColor; }
|
||||
set
|
||||
{
|
||||
switchColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The axis color
|
||||
/// </summary>
|
||||
private Color axisColor = Color.FromArgb(3, 169, 243);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the axis.
|
||||
/// </summary>
|
||||
/// <value>The color of the axis.</value>
|
||||
[Description("轴颜色"), Category("自定义")]
|
||||
public Color AxisColor
|
||||
{
|
||||
get { return axisColor; }
|
||||
set
|
||||
{
|
||||
axisColor = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The asis bottom color
|
||||
/// </summary>
|
||||
private Color asisBottomColor = Color.FromArgb(3, 169, 243);
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the color of the asis bottom.
|
||||
/// </summary>
|
||||
/// <value>The color of the asis bottom.</value>
|
||||
[Description("轴底座颜色"), Category("自定义")]
|
||||
public Color AsisBottomColor
|
||||
{
|
||||
get { return asisBottomColor; }
|
||||
set { asisBottomColor = value; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The opened
|
||||
/// </summary>
|
||||
private bool opened = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets a value indicating whether this <see cref="UCValve" /> is opened.
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if opened; otherwise, <c>false</c>.</value>
|
||||
[Description("是否打开"), Category("自定义")]
|
||||
public bool Opened
|
||||
{
|
||||
get { return opened; }
|
||||
set
|
||||
{
|
||||
opened = value;
|
||||
Refresh();
|
||||
if (OpenChecked != null)
|
||||
{
|
||||
OpenChecked(this, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <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;
|
||||
if (value == LiquidDirection.None)
|
||||
m_timer.Enabled = false;
|
||||
else
|
||||
m_timer.Enabled = true;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The liquid speed
|
||||
/// </summary>
|
||||
private int liquidSpeed = 100;
|
||||
|
||||
/// <summary>
|
||||
/// 液体流速,越小,速度越快Gets or sets the liquid speed.
|
||||
/// </summary>
|
||||
/// <value>The liquid speed.</value>
|
||||
[Description("液体流速,越小,速度越快"), Category("自定义")]
|
||||
public int LiquidSpeed
|
||||
{
|
||||
get { return liquidSpeed; }
|
||||
set
|
||||
{
|
||||
if (value <= 0)
|
||||
return;
|
||||
liquidSpeed = value;
|
||||
m_timer.Interval = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The liquid color
|
||||
/// </summary>
|
||||
private Color liquidColor = Color.FromArgb(3, 169, 243);
|
||||
|
||||
/// <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 != LiquidDirection.None)
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// The m timer
|
||||
/// </summary>
|
||||
Timer m_timer;
|
||||
/// <summary>
|
||||
/// The int line left
|
||||
/// </summary>
|
||||
int intLineLeft = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCValve" /> class.
|
||||
/// </summary>
|
||||
public UCValve()
|
||||
{
|
||||
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(120, 100);
|
||||
m_timer = new Timer();
|
||||
m_timer.Interval = 100;
|
||||
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 += 2;
|
||||
if (intLineLeft > 12)
|
||||
intLineLeft = 0;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
|
||||
/// <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);
|
||||
var g = e.Graphics;
|
||||
Rectangle rectGuan = Rectangle.Empty;//管道
|
||||
Rectangle rectJK1 = Rectangle.Empty;//接口1
|
||||
Rectangle rectJK2 = Rectangle.Empty;//接口2
|
||||
Rectangle rectZ = Rectangle.Empty;//轴
|
||||
GraphicsPath linePath = new GraphicsPath();//管道中心线
|
||||
GraphicsPath dzPath = new GraphicsPath();//轴底座
|
||||
GraphicsPath bsPath = new GraphicsPath();//开关把手
|
||||
switch (valveStyle)
|
||||
{
|
||||
case ValveStyle.Horizontal_Top:
|
||||
rectGuan = new Rectangle(0, this.Height / 2, this.Width, this.Height / 2 - this.Height / 8);
|
||||
rectJK1 = new Rectangle(this.Height / 8, rectGuan.Top - this.Height / 8, rectGuan.Height / 2, rectGuan.Height + this.Height / 4);
|
||||
rectJK2 = new Rectangle(rectGuan.Right - this.Height / 8 - rectGuan.Height / 2, rectGuan.Top - this.Height / 8, rectGuan.Height / 2, rectGuan.Height + this.Height / 4);
|
||||
linePath.AddLine(new Point(rectGuan.Left - 10, rectGuan.Top + rectGuan.Height / 2), new Point(rectGuan.Right + 10, rectGuan.Top + rectGuan.Height / 2));
|
||||
rectZ = new Rectangle(rectGuan.Left + (rectGuan.Width - rectGuan.Height / 4) / 2, 10, rectGuan.Height / 4, rectGuan.Top - 10);
|
||||
Point[] psTop = new Point[]
|
||||
{
|
||||
new Point(rectGuan.Left+(rectGuan.Width-rectGuan.Height/2)/2,rectGuan.Top- this.Height / 8- 5 ),
|
||||
new Point(rectGuan.Right-(rectGuan.Width-rectGuan.Height/2)/2,rectGuan.Top- this.Height / 8- 5 ),
|
||||
new Point(rectGuan.Right-(rectGuan.Width-rectGuan.Height)/2,rectGuan.Top+2 ),
|
||||
new Point(rectGuan.Left+(rectGuan.Width-rectGuan.Height)/2,rectGuan.Top +2),
|
||||
};
|
||||
dzPath.AddLines(psTop);
|
||||
dzPath.CloseAllFigures();
|
||||
if (opened)
|
||||
{
|
||||
bsPath.AddLine(rectGuan.Left + (rectGuan.Width - rectGuan.Height - 10) / 2, 10 + (rectGuan.Height / 3) / 2, rectGuan.Left + (rectGuan.Width - rectGuan.Height - 10) / 2 + rectGuan.Height + 10, 10 + (rectGuan.Height / 3) / 2);
|
||||
}
|
||||
else
|
||||
{
|
||||
bsPath.AddLine(new Point(rectGuan.Left + rectGuan.Width / 2 - 3, 1), new Point(rectGuan.Left + rectGuan.Width / 2 + 4, rectGuan.Height + 10));
|
||||
}
|
||||
break;
|
||||
case ValveStyle.Horizontal_Bottom:
|
||||
rectGuan = new Rectangle(0, this.Height / 8, this.Width, this.Height / 2 - this.Height / 8);
|
||||
rectJK1 = new Rectangle(this.Height / 8, rectGuan.Top - this.Height / 8, rectGuan.Height / 2, rectGuan.Height + this.Height / 4);
|
||||
rectJK2 = new Rectangle(rectGuan.Right - this.Height / 8 - rectGuan.Height / 2, rectGuan.Top - this.Height / 8, rectGuan.Height / 2, rectGuan.Height + this.Height / 4);
|
||||
linePath.AddLine(new Point(rectGuan.Left - 10, rectGuan.Top + rectGuan.Height / 2), new Point(rectGuan.Right + 10, rectGuan.Top + rectGuan.Height / 2));
|
||||
rectZ = new Rectangle(rectGuan.Left + (rectGuan.Width - rectGuan.Height / 4) / 2, rectGuan.Bottom + 10, rectGuan.Height / 4, this.Height - 10 - (rectGuan.Bottom + 10));
|
||||
Point[] psBottom = new Point[]
|
||||
{
|
||||
new Point(rectGuan.Left+(rectGuan.Width-rectGuan.Height/2)/2,rectGuan.Bottom+ this.Height / 8+ 5 ),
|
||||
new Point(rectGuan.Right-(rectGuan.Width-rectGuan.Height/2)/2,rectGuan.Bottom+ this.Height / 8+ 5 ),
|
||||
new Point(rectGuan.Right-(rectGuan.Width-rectGuan.Height)/2,rectGuan.Bottom-2 ),
|
||||
new Point(rectGuan.Left+(rectGuan.Width-rectGuan.Height)/2,rectGuan.Bottom-2),
|
||||
};
|
||||
dzPath.AddLines(psBottom);
|
||||
dzPath.CloseAllFigures();
|
||||
if (opened)
|
||||
{
|
||||
bsPath.AddLine(rectGuan.Left + (rectGuan.Width - rectGuan.Height - 10) / 2, this.Height - (10 + (rectGuan.Height / 3) / 2), rectGuan.Left + (rectGuan.Width - rectGuan.Height - 10) / 2 + rectGuan.Height + 10, this.Height - (10 + (rectGuan.Height / 3) / 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
bsPath.AddLine(new Point(rectGuan.Left + rectGuan.Width / 2 - 3, this.Height - 1), new Point(rectGuan.Left + rectGuan.Width / 2 + 4, this.Height - (rectGuan.Height + 10)));
|
||||
}
|
||||
break;
|
||||
case ValveStyle.Vertical_Left:
|
||||
rectGuan = new Rectangle(this.Width / 8, 0, this.Width / 2 - this.Width / 8, this.Height);
|
||||
rectJK1 = new Rectangle(0, this.Width / 8, rectGuan.Width + this.Width / 4, rectGuan.Width / 2);
|
||||
rectJK2 = new Rectangle(0, this.Height - this.Width / 8 - rectGuan.Width / 2, rectGuan.Width + this.Width / 4, rectGuan.Width / 2);
|
||||
linePath.AddLine(new Point(rectGuan.Left + rectGuan.Width / 2, rectGuan.Top - 10), new Point(rectGuan.Left + rectGuan.Width / 2, rectGuan.Bottom + 10));
|
||||
rectZ = new Rectangle(rectGuan.Right, rectGuan.Top + (rectGuan.Height - rectGuan.Width / 4) / 2, rectGuan.Right - 10, rectGuan.Width / 4);
|
||||
Point[] psLeft = new Point[]
|
||||
{
|
||||
new Point(rectGuan.Right+ this.Width / 8+ 5 ,rectGuan.Top + (rectGuan.Height - rectGuan.Width / 2) / 2),
|
||||
new Point(rectGuan.Right+ this.Width / 8+ 5 ,rectGuan.Top + (rectGuan.Height - rectGuan.Width / 2) / 2+rectGuan.Width / 2),
|
||||
new Point(rectGuan.Right-2, rectGuan.Top +(rectGuan.Height-rectGuan.Width)/2+rectGuan.Width),
|
||||
new Point(rectGuan.Right-2, rectGuan.Top +(rectGuan.Height-rectGuan.Width)/2),
|
||||
};
|
||||
dzPath.AddLines(psLeft);
|
||||
dzPath.CloseAllFigures();
|
||||
if (opened)
|
||||
{
|
||||
bsPath.AddLine(this.Width - (10 + (rectGuan.Width / 3) / 2), rectGuan.Top + (rectGuan.Height - rectGuan.Width - 10) / 2, this.Width - (10 + (rectGuan.Width / 3) / 2), rectGuan.Top + (rectGuan.Height - rectGuan.Width - 10) / 2 + rectGuan.Width + 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
bsPath.AddLine(new Point(this.Width - 1, rectGuan.Top + rectGuan.Height / 2 - 3), new Point(this.Width - (rectGuan.Width + 10), rectGuan.Top + rectGuan.Height / 2 + 4));
|
||||
}
|
||||
break;
|
||||
case ValveStyle.Vertical_Right:
|
||||
rectGuan = new Rectangle(this.Width - this.Width / 8 - (this.Width / 2 - this.Width / 8), 0, this.Width / 2 - this.Width / 8, this.Height);
|
||||
rectJK1 = new Rectangle(this.Width - (rectGuan.Width + this.Width / 4), this.Width / 8, rectGuan.Width + this.Width / 4, rectGuan.Width / 2);
|
||||
rectJK2 = new Rectangle(this.Width - (rectGuan.Width + this.Width / 4), this.Height - this.Width / 8 - rectGuan.Width / 2, rectGuan.Width + this.Width / 4, rectGuan.Width / 2);
|
||||
linePath.AddLine(new Point(rectGuan.Left + rectGuan.Width / 2, rectGuan.Top - 10), new Point(rectGuan.Left + rectGuan.Width / 2, rectGuan.Bottom + 10));
|
||||
rectZ = new Rectangle(10, rectGuan.Top + (rectGuan.Height - rectGuan.Width / 4) / 2, rectGuan.Left - 10, rectGuan.Width / 4);
|
||||
Point[] psRight = new Point[]
|
||||
{
|
||||
new Point(rectGuan.Left- (this.Width / 8+ 5) ,rectGuan.Top + (rectGuan.Height - rectGuan.Width / 2) / 2),
|
||||
new Point(rectGuan.Left-( this.Width / 8+ 5) ,rectGuan.Top + (rectGuan.Height - rectGuan.Width / 2) / 2+rectGuan.Width / 2),
|
||||
new Point(rectGuan.Left+2, rectGuan.Top +(rectGuan.Height-rectGuan.Width)/2+rectGuan.Width),
|
||||
new Point(rectGuan.Left+2, rectGuan.Top +(rectGuan.Height-rectGuan.Width)/2),
|
||||
};
|
||||
dzPath.AddLines(psRight);
|
||||
dzPath.CloseAllFigures();
|
||||
|
||||
if (opened)
|
||||
{
|
||||
bsPath.AddLine((10 + (rectGuan.Width / 3) / 2), rectGuan.Top + (rectGuan.Height - rectGuan.Width - 10) / 2, (10 + (rectGuan.Width / 3) / 2), rectGuan.Top + (rectGuan.Height - rectGuan.Width - 10) / 2 + rectGuan.Width + 10);
|
||||
}
|
||||
else
|
||||
{
|
||||
bsPath.AddLine(new Point(1, rectGuan.Top + rectGuan.Height / 2 - 3), new Point((rectGuan.Width + 10), rectGuan.Top + rectGuan.Height / 2 + 4));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
//管道
|
||||
g.FillRectangle(new SolidBrush(valveColor), rectGuan);
|
||||
//接口
|
||||
g.FillRectangle(new SolidBrush(valveColor), rectJK1);
|
||||
g.FillRectangle(new SolidBrush(Color.FromArgb(40, Color.White)), rectJK1);
|
||||
g.FillRectangle(new SolidBrush(valveColor), rectJK2);
|
||||
g.FillRectangle(new SolidBrush(Color.FromArgb(40, Color.White)), rectJK2);
|
||||
|
||||
|
||||
//高亮
|
||||
int intCount = (valveStyle.ToString().StartsWith("H") ? rectGuan.Height : rectGuan.Width) / 2 / 4;
|
||||
for (int i = 0; i < intCount; i++)
|
||||
{
|
||||
int _penWidth = (valveStyle.ToString().StartsWith("H") ? rectGuan.Height : rectGuan.Width) / 2 - 4 * i;
|
||||
if (_penWidth <= 0)
|
||||
_penWidth = 1;
|
||||
g.DrawPath(new Pen(new SolidBrush(Color.FromArgb(40, Color.White.R, Color.White.G, Color.White.B)), _penWidth), linePath);
|
||||
if (_penWidth == 1)
|
||||
break;
|
||||
}
|
||||
|
||||
g.SetGDIHigh();
|
||||
//轴
|
||||
g.FillRectangle(new SolidBrush(axisColor), rectZ);
|
||||
|
||||
//阀门底座
|
||||
g.FillPath(new SolidBrush(asisBottomColor), dzPath);
|
||||
g.FillPath(new SolidBrush(Color.FromArgb(50, Color.White)), dzPath);
|
||||
|
||||
//把手
|
||||
g.DrawPath(new Pen(new SolidBrush(switchColor), (valveStyle.ToString().StartsWith("H") ? rectGuan.Height : rectGuan.Width) / 3), bsPath);
|
||||
|
||||
//液体流动
|
||||
if (opened)
|
||||
{
|
||||
Pen p = new Pen(new SolidBrush(liquidColor), 4);
|
||||
p.DashPattern = new float[] { 6, 6 };
|
||||
p.DashOffset = intLineLeft * (LiquidDirection == LiquidDirection.Forward ? -1 : 1);
|
||||
g.DrawPath(p, linePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enum ValveStyle
|
||||
/// </summary>
|
||||
public enum ValveStyle
|
||||
{
|
||||
/// <summary>
|
||||
/// 横向,开关在上方
|
||||
/// </summary>
|
||||
Horizontal_Top,
|
||||
/// <summary>
|
||||
/// 横向,开关在下方
|
||||
/// </summary>
|
||||
Horizontal_Bottom,
|
||||
/// <summary>
|
||||
/// 纵向,开关在左侧
|
||||
/// </summary>
|
||||
Vertical_Left,
|
||||
/// <summary>
|
||||
/// 纵向,开关在右侧
|
||||
/// </summary>
|
||||
Vertical_Right,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,142 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
[DefaultEvent("Paint")]
|
||||
public partial class GraphicalOverlayComponent : Component
|
||||
{
|
||||
public event EventHandler<PaintEventArgs> Paint;
|
||||
|
||||
public GraphicalOverlayComponent()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public GraphicalOverlayComponent(IContainer container)
|
||||
{
|
||||
container.Add(this);
|
||||
|
||||
InitializeComponent();
|
||||
}
|
||||
private Control owner;
|
||||
[Browsable(true), Category("自定义属性"), Description("父控件"), Localizable(true)]
|
||||
public Control Owner
|
||||
{
|
||||
get { return owner; }
|
||||
set
|
||||
{
|
||||
// The owner form cannot be set to null.
|
||||
if (value == null)
|
||||
return;
|
||||
|
||||
// The owner form can only be set once.
|
||||
if (owner != null)
|
||||
return;
|
||||
|
||||
// Save the form for future reference.
|
||||
owner = value;
|
||||
|
||||
// Handle the form's Resize event.
|
||||
owner.Resize += new EventHandler(Form_Resize);
|
||||
|
||||
// Handle the Paint event for each of the controls in the form's hierarchy.
|
||||
ConnectPaintEventHandlers(owner);
|
||||
}
|
||||
}
|
||||
|
||||
private void Form_Resize(object sender, EventArgs e)
|
||||
{
|
||||
owner.Invalidate(true);
|
||||
}
|
||||
|
||||
private void ConnectPaintEventHandlers(Control control)
|
||||
{
|
||||
|
||||
Type type = control.GetType();
|
||||
System.Reflection.PropertyInfo pi = type.GetProperty("DoubleBuffered", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
|
||||
pi.SetValue(control, true, null);
|
||||
|
||||
|
||||
control.Paint -= new PaintEventHandler(Control_Paint);
|
||||
control.Paint += new PaintEventHandler(Control_Paint);
|
||||
|
||||
control.ControlAdded -= new ControlEventHandler(Control_ControlAdded);
|
||||
control.ControlAdded += new ControlEventHandler(Control_ControlAdded);
|
||||
|
||||
// Recurse the hierarchy.
|
||||
foreach (Control child in control.Controls)
|
||||
ConnectPaintEventHandlers(child);
|
||||
}
|
||||
|
||||
private void Control_ControlAdded(object sender, ControlEventArgs e)
|
||||
{
|
||||
// Connect the paint event handler for the new control.
|
||||
ConnectPaintEventHandlers(e.Control);
|
||||
}
|
||||
|
||||
private void Control_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
if (e == null) return;
|
||||
|
||||
// As each control on the form is repainted, this handler is called.
|
||||
|
||||
Control control = sender as Control;
|
||||
Point location;
|
||||
|
||||
// Determine the location of the control's client area relative to the form's client area.
|
||||
if (control == owner)
|
||||
// The form's client area is already form-relative.
|
||||
location = control.Location;
|
||||
else
|
||||
{
|
||||
// The control may be in a hierarchy, so convert to screen coordinates and then back to form coordinates.
|
||||
location = owner.PointToClient(control.Parent.PointToScreen(control.Location));
|
||||
|
||||
// If the control has a border shift the location of the control's client area.
|
||||
location += new Size((control.Width - control.ClientSize.Width) / 2, (control.Height - control.ClientSize.Height) / 2);
|
||||
}
|
||||
|
||||
// Translate the location so that we can use form-relative coordinates to draw on the control.
|
||||
if (control != owner)
|
||||
e.Graphics.TranslateTransform(-location.X, -location.Y);
|
||||
|
||||
// Fire a paint event.
|
||||
OnPaint(sender, e);
|
||||
}
|
||||
|
||||
private void OnPaint(object sender, PaintEventArgs e)
|
||||
{
|
||||
// Fire a paint event.
|
||||
// The paint event will be handled in Form1.graphicalOverlay1_Paint().
|
||||
|
||||
if (Paint != null)
|
||||
Paint(sender, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
namespace System.Windows.Forms
|
||||
{
|
||||
using System.Drawing;
|
||||
|
||||
public static class Extensions
|
||||
{
|
||||
public static Rectangle Coordinates(this Control control)
|
||||
{
|
||||
// Extend System.Windows.Forms.Control to have a Coordinates property.
|
||||
// The Coordinates property contains the control's form-relative location.
|
||||
Rectangle coordinates;
|
||||
Form form = (Form)control.TopLevelControl;
|
||||
|
||||
if (control == form)
|
||||
coordinates = form.ClientRectangle;
|
||||
else
|
||||
coordinates = form.RectangleToClient(control.Parent.RectangleToScreen(control.Bounds));
|
||||
|
||||
return coordinates;
|
||||
}
|
||||
}
|
||||
}
|
||||
36
UsingControl/HZHControls/Controls/GraphicalOverlay/GraphicalOverlayComponent.designer.cs
generated
Normal file
36
UsingControl/HZHControls/Controls/GraphicalOverlay/GraphicalOverlayComponent.designer.cs
generated
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
partial class GraphicalOverlayComponent
|
||||
{
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
components = new System.ComponentModel.Container();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
2467
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderAll.Designer.cs
generated
Normal file
2467
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderAll.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
219
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderAll.cs
Normal file
219
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderAll.cs
Normal file
@@ -0,0 +1,219 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCKeyBorderAll.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCKeyBorderAll.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
[DefaultEvent("KeyDown")]
|
||||
public partial class UCKeyBorderAll : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The character type
|
||||
/// </summary>
|
||||
private KeyBorderCharType _charType = KeyBorderCharType.CHAR;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the type of the character.
|
||||
/// </summary>
|
||||
/// <value>The type of the character.</value>
|
||||
[Description("默认显示样式"), Category("自定义")]
|
||||
public KeyBorderCharType CharType
|
||||
{
|
||||
get { return _charType; }
|
||||
set
|
||||
{
|
||||
_charType = value;
|
||||
if (value == KeyBorderCharType.CHAR)
|
||||
{
|
||||
if (label37.Text.ToLower() == "abc.")
|
||||
{
|
||||
CharOrNum();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (label37.Text.ToLower() == "?123")
|
||||
{
|
||||
CharOrNum();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Occurs when [key click].
|
||||
/// </summary>
|
||||
[Description("按键点击事件"), Category("自定义")]
|
||||
public event EventHandler KeyClick;
|
||||
/// <summary>
|
||||
/// Occurs when [enter click].
|
||||
/// </summary>
|
||||
[Description("回车点击事件"), Category("自定义")]
|
||||
public event EventHandler EnterClick;
|
||||
/// <summary>
|
||||
/// Occurs when [backspace clike].
|
||||
/// </summary>
|
||||
[Description("删除点击事件"), Category("自定义")]
|
||||
public event EventHandler BackspaceClike;
|
||||
/// <summary>
|
||||
/// Occurs when [retract clike].
|
||||
/// </summary>
|
||||
[Description("收起点击事件"), Category("自定义")]
|
||||
public event EventHandler RetractClike;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCKeyBorderAll" /> class.
|
||||
/// </summary>
|
||||
public UCKeyBorderAll()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the KeyDown control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void KeyDown_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
Label lbl = sender as Label;
|
||||
if (string.IsNullOrEmpty(lbl.Text))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (lbl.Text == "大写")
|
||||
{
|
||||
ToUper(true);
|
||||
lbl.Text = "小写";
|
||||
}
|
||||
else if (lbl.Text == "小写")
|
||||
{
|
||||
ToUper(false);
|
||||
lbl.Text = "大写";
|
||||
}
|
||||
else if (lbl.Text == "?123" || lbl.Text == "abc.")
|
||||
{
|
||||
CharOrNum();
|
||||
}
|
||||
else if (lbl.Text == "空格")
|
||||
{
|
||||
SendKeys.Send(" ");
|
||||
}
|
||||
else if (lbl.Text == "删除")
|
||||
{
|
||||
SendKeys.Send("{BACKSPACE}");
|
||||
if (BackspaceClike != null)
|
||||
BackspaceClike(sender, e);
|
||||
}
|
||||
else if (lbl.Text == "回车")
|
||||
{
|
||||
SendKeys.Send("{ENTER}");
|
||||
if (EnterClick != null)
|
||||
EnterClick(sender, e);
|
||||
}
|
||||
else if (lbl.Text == "收起")
|
||||
{
|
||||
if (RetractClike != null)
|
||||
RetractClike(sender, e);
|
||||
}
|
||||
else
|
||||
{
|
||||
string Str = "{"+ lbl.Text + "}";
|
||||
SendKeys.Send(lbl.Text);
|
||||
}
|
||||
if (KeyClick != null)
|
||||
KeyClick(sender, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts to uper.
|
||||
/// </summary>
|
||||
/// <param name="bln">if set to <c>true</c> [BLN].</param>
|
||||
private void ToUper(bool bln)
|
||||
{
|
||||
foreach (Control item in this.tableLayoutPanel2.Controls)
|
||||
{
|
||||
if (item is Panel)
|
||||
{
|
||||
foreach (Control pc in item.Controls)
|
||||
{
|
||||
if (pc is Label)
|
||||
{
|
||||
if (pc.Text == "abc.")
|
||||
break;
|
||||
if (bln)
|
||||
{
|
||||
pc.Text = pc.Text.ToUpper();
|
||||
}
|
||||
else
|
||||
{
|
||||
pc.Text = pc.Text.ToLower();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Characters the or number.
|
||||
/// </summary>
|
||||
private void CharOrNum()
|
||||
{
|
||||
foreach (Control item in this.tableLayoutPanel2.Controls)
|
||||
{
|
||||
if (item is Panel)
|
||||
{
|
||||
foreach (Control pc in item.Controls)
|
||||
{
|
||||
if (pc is Label)
|
||||
{
|
||||
string strTag = pc.Text;
|
||||
pc.Text = pc.Tag.ToString();
|
||||
pc.Tag = strTag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Enum KeyBorderCharType
|
||||
/// </summary>
|
||||
public enum KeyBorderCharType
|
||||
{
|
||||
/// <summary>
|
||||
/// The character
|
||||
/// </summary>
|
||||
CHAR = 1,
|
||||
/// <summary>
|
||||
/// The number
|
||||
/// </summary>
|
||||
NUMBER = 2
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderAll.resx
Normal file
120
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderAll.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
1074
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderNum.Designer.cs
generated
Normal file
1074
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderNum.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
121
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderNum.cs
Normal file
121
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderNum.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCKeyBorderNum.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCKeyBorderNum.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public partial class UCKeyBorderNum : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The use custom event
|
||||
/// </summary>
|
||||
private bool useCustomEvent = false;
|
||||
/// <summary>
|
||||
/// 是否使用自定义的事件来接收按键,当为true时将不再向系统发送按键请求
|
||||
/// </summary>
|
||||
/// <value><c>true</c> if [use custom event]; otherwise, <c>false</c>.</value>
|
||||
[Description("是否使用自定义的事件来接收按键,当为true时将不再向系统发送按键请求"), Category("自定义")]
|
||||
public bool UseCustomEvent
|
||||
{
|
||||
get { return useCustomEvent; }
|
||||
set { useCustomEvent = value; }
|
||||
}
|
||||
/// <summary>
|
||||
/// Occurs when [number click].
|
||||
/// </summary>
|
||||
[Description("数字点击事件"), Category("自定义")]
|
||||
public event EventHandler NumClick;
|
||||
/// <summary>
|
||||
/// Occurs when [backspace click].
|
||||
/// </summary>
|
||||
[Description("删除点击事件"), Category("自定义")]
|
||||
public event EventHandler BackspaceClick;
|
||||
/// <summary>
|
||||
/// Occurs when [enter click].
|
||||
/// </summary>
|
||||
[Description("回车点击事件"), Category("自定义")]
|
||||
public event EventHandler EnterClick;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCKeyBorderNum" /> class.
|
||||
/// </summary>
|
||||
public UCKeyBorderNum()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the Num control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void Num_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (NumClick != null)
|
||||
{
|
||||
NumClick(sender, e);
|
||||
}
|
||||
if (useCustomEvent)
|
||||
return;
|
||||
Label lbl = sender as Label;
|
||||
SendKeys.Send(lbl.Tag.ToString());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the Backspace control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void Backspace_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (BackspaceClick != null)
|
||||
{
|
||||
BackspaceClick(sender, e);
|
||||
}
|
||||
if (useCustomEvent)
|
||||
return;
|
||||
Label lbl = sender as Label;
|
||||
SendKeys.Send("{BACKSPACE}");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the Enter control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void Enter_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (EnterClick != null)
|
||||
{
|
||||
EnterClick(sender, e);
|
||||
}
|
||||
if (useCustomEvent)
|
||||
return;
|
||||
SendKeys.Send("{ENTER}");
|
||||
}
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderNum.resx
Normal file
120
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderNum.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
1359
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderPay.Designer.cs
generated
Normal file
1359
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderPay.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
306
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderPay.cs
Normal file
306
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderPay.cs
Normal file
@@ -0,0 +1,306 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 08-08-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCKeyBorderPay.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCKeyBorderPay.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public partial class UCKeyBorderPay : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// Occurs when [number click].
|
||||
/// </summary>
|
||||
[Description("数字点击事件"), Category("自定义")]
|
||||
public event EventHandler NumClick;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [cancel click].
|
||||
/// </summary>
|
||||
[Description("取消点击事件"), Category("自定义")]
|
||||
public event EventHandler CancelClick;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [ok click].
|
||||
/// </summary>
|
||||
[Description("确定点击事件"), Category("自定义")]
|
||||
public event EventHandler OKClick;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [backspace click].
|
||||
/// </summary>
|
||||
[Description("删除点击事件"), Category("自定义")]
|
||||
public event EventHandler BackspaceClick;
|
||||
|
||||
/// <summary>
|
||||
/// Occurs when [money click].
|
||||
/// </summary>
|
||||
[Description("金额点击事件"), Category("自定义")]
|
||||
public event EventHandler MoneyClick;
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCKeyBorderPay" /> class.
|
||||
/// </summary>
|
||||
public UCKeyBorderPay()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
#region 设置快速付款金额
|
||||
/// <summary>
|
||||
/// 功能描述:设置快速付款金额
|
||||
/// 作 者:HZH
|
||||
/// 创建日期:2019-03-07 11:41:04
|
||||
/// 任务编号:POS
|
||||
/// </summary>
|
||||
/// <param name="SorceMoney">SorceMoney</param>
|
||||
public void SetPayMoney(decimal SorceMoney)
|
||||
{
|
||||
List<decimal> list = new List<decimal>();
|
||||
decimal d = Math.Ceiling(SorceMoney);
|
||||
if (SorceMoney > 0m)
|
||||
{
|
||||
if (SorceMoney < 5m)
|
||||
{
|
||||
list.Add(5m);
|
||||
list.Add(10m);
|
||||
list.Add(20m);
|
||||
list.Add(50m);
|
||||
}
|
||||
else if (SorceMoney < 10m)
|
||||
{
|
||||
list.Add(10m);
|
||||
list.Add(20m);
|
||||
list.Add(50m);
|
||||
list.Add(100m);
|
||||
}
|
||||
else
|
||||
{
|
||||
int num = Convert.ToInt32(d % 10m);
|
||||
int num2 = Convert.ToInt32(Math.Floor(d / 10m) % 10m);
|
||||
int num3 = Convert.ToInt32(Math.Floor(d / 100m));
|
||||
int num4;
|
||||
if (num < 5)
|
||||
{
|
||||
num4 = num2 * 10 + 5;
|
||||
list.Add(num4 + num3 * 100);
|
||||
num4 = (num2 + 1) * 10;
|
||||
list.Add(num4 + num3 * 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
num4 = (num2 + 1) * 10;
|
||||
list.Add(num4 + num3 * 100);
|
||||
}
|
||||
if (num4 >= 0 && num4 < 10)
|
||||
{
|
||||
num4 = 10;
|
||||
if (list.Count < 4)
|
||||
{
|
||||
list.Add(num4 + num3 * 100);
|
||||
}
|
||||
num4 = 20;
|
||||
if (list.Count < 4)
|
||||
{
|
||||
list.Add(num4 + num3 * 100);
|
||||
}
|
||||
num4 = 50;
|
||||
if (list.Count < 4)
|
||||
{
|
||||
list.Add(num4 + num3 * 100);
|
||||
}
|
||||
num4 = 100;
|
||||
if (list.Count < 4)
|
||||
{
|
||||
list.Add(num4 + num3 * 100);
|
||||
}
|
||||
}
|
||||
else if (num4 >= 10 && num4 < 20)
|
||||
{
|
||||
num4 = 20;
|
||||
if (list.Count < 4)
|
||||
{
|
||||
list.Add(num4 + num3 * 100);
|
||||
}
|
||||
num4 = 50;
|
||||
if (list.Count < 4)
|
||||
{
|
||||
list.Add(num4 + num3 * 100);
|
||||
}
|
||||
num4 = 100;
|
||||
if (list.Count < 4)
|
||||
{
|
||||
list.Add(num4 + num3 * 100);
|
||||
}
|
||||
}
|
||||
else if (num4 >= 20 && num4 < 50)
|
||||
{
|
||||
num4 = 50;
|
||||
if (list.Count < 4)
|
||||
{
|
||||
list.Add(num4 + num3 * 100);
|
||||
}
|
||||
num4 = 100;
|
||||
if (list.Count < 4)
|
||||
{
|
||||
list.Add(num4 + num3 * 100);
|
||||
}
|
||||
}
|
||||
else if (num4 < 100)
|
||||
{
|
||||
num4 = 100;
|
||||
if (list.Count < 4)
|
||||
{
|
||||
list.Add(num4 + num3 * 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
SetFastMoneyToContrl(list);
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Sets the fast money to contrl.
|
||||
/// </summary>
|
||||
/// <param name="values">The values.</param>
|
||||
private void SetFastMoneyToContrl(List<decimal> values)
|
||||
{
|
||||
List<Label> lbl = new List<Label>() { lblFast1, lblFast2, lblFast3, lblFast4 };
|
||||
lblFast1.Tag = lblFast1.Text = "";
|
||||
lblFast2.Tag = lblFast2.Text = "";
|
||||
lblFast3.Tag = lblFast3.Text = "";
|
||||
lblFast4.Tag = lblFast4.Text = "";
|
||||
for (int i = 0; i < lbl.Count && i < values.Count; i++)
|
||||
{
|
||||
if (values[i].ToString("0.##").Length < 4)
|
||||
{
|
||||
lbl[i].Font = new System.Drawing.Font("Arial Unicode MS", 30F);
|
||||
}
|
||||
else
|
||||
{
|
||||
Graphics graphics = lbl[i].CreateGraphics();
|
||||
for (int j = 0; j < 5; j++)
|
||||
{
|
||||
SizeF sizeF = graphics.MeasureString(values[i].ToString("0.##"), new System.Drawing.Font("Arial Unicode MS", 30 - j * 5), 100, StringFormat.GenericTypographic);
|
||||
if (sizeF.Width <= lbl[i].Width - 20)
|
||||
{
|
||||
lbl[i].Font = new System.Drawing.Font("Arial Unicode MS", 30 - j * 5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
graphics.Dispose();
|
||||
}
|
||||
lbl[i].Tag = lbl[i].Text = values[i].ToString("0.##");
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the Num control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void Num_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (NumClick != null)
|
||||
NumClick((sender as Label).Tag, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the Backspace control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void Backspace_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (BackspaceClick != null)
|
||||
BackspaceClick((sender as Label).Tag, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the Cancel control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void Cancel_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (CancelClick != null)
|
||||
CancelClick((sender as Label).Tag, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the OK control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void OK_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (OKClick != null)
|
||||
OKClick((sender as Label).Tag, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the MouseDown event of the Money control.
|
||||
/// </summary>
|
||||
/// <param name="sender">The source of the event.</param>
|
||||
/// <param name="e">The <see cref="MouseEventArgs" /> instance containing the event data.</param>
|
||||
private void Money_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (MoneyClick != null)
|
||||
MoneyClick((sender as Label).Tag, e);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Money1s the click.
|
||||
/// </summary>
|
||||
public void Money1Click()
|
||||
{
|
||||
Money_MouseDown(lblFast1, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Money2s the click.
|
||||
/// </summary>
|
||||
public void Money2Click()
|
||||
{
|
||||
Money_MouseDown(lblFast2, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Money3s the click.
|
||||
/// </summary>
|
||||
public void Money3Click()
|
||||
{
|
||||
Money_MouseDown(lblFast3, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Money4s the click.
|
||||
/// </summary>
|
||||
public void Money4Click()
|
||||
{
|
||||
Money_MouseDown(lblFast4, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderPay.resx
Normal file
120
UsingControl/HZHControls/Controls/KeyBord/UCKeyBorderPay.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
257
UsingControl/HZHControls/Controls/LED/UCLEDData.Designer.cs
generated
Normal file
257
UsingControl/HZHControls/Controls/LED/UCLEDData.Designer.cs
generated
Normal file
@@ -0,0 +1,257 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 09-02-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCLEDData.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCLEDData.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
partial class UCLEDData
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.D1 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D2 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D3 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D4 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D5 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D6 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D7 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D8 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D9 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D10 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.ColumnCount = 10;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 10F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.D1, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D2, 1, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D3, 2, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D4, 3, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D5, 4, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D6, 5, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D7, 6, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D8, 7, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D9, 8, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D10, 9, 0);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 1;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 20F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(360, 58);
|
||||
this.tableLayoutPanel1.TabIndex = 0;
|
||||
//
|
||||
// D1
|
||||
//
|
||||
this.D1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D1.LineWidth = 8;
|
||||
this.D1.Location = new System.Drawing.Point(3, 3);
|
||||
this.D1.Name = "D1";
|
||||
this.D1.Size = new System.Drawing.Size(30, 52);
|
||||
this.D1.TabIndex = 0;
|
||||
this.D1.Value = '2';
|
||||
//
|
||||
// D2
|
||||
//
|
||||
this.D2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D2.LineWidth = 8;
|
||||
this.D2.Location = new System.Drawing.Point(39, 3);
|
||||
this.D2.Name = "D2";
|
||||
this.D2.Size = new System.Drawing.Size(30, 52);
|
||||
this.D2.TabIndex = 1;
|
||||
this.D2.Value = '0';
|
||||
//
|
||||
// D3
|
||||
//
|
||||
this.D3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D3.LineWidth = 8;
|
||||
this.D3.Location = new System.Drawing.Point(75, 3);
|
||||
this.D3.Name = "D3";
|
||||
this.D3.Size = new System.Drawing.Size(30, 52);
|
||||
this.D3.TabIndex = 2;
|
||||
this.D3.Value = '1';
|
||||
//
|
||||
// D4
|
||||
//
|
||||
this.D4.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D4.LineWidth = 8;
|
||||
this.D4.Location = new System.Drawing.Point(111, 3);
|
||||
this.D4.Name = "D4";
|
||||
this.D4.Size = new System.Drawing.Size(30, 52);
|
||||
this.D4.TabIndex = 3;
|
||||
this.D4.Value = '9';
|
||||
//
|
||||
// D5
|
||||
//
|
||||
this.D5.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D5.LineWidth = 8;
|
||||
this.D5.Location = new System.Drawing.Point(147, 3);
|
||||
this.D5.Name = "D5";
|
||||
this.D5.Size = new System.Drawing.Size(30, 52);
|
||||
this.D5.TabIndex = 4;
|
||||
this.D5.Value = '-';
|
||||
//
|
||||
// D6
|
||||
//
|
||||
this.D6.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D6.LineWidth = 8;
|
||||
this.D6.Location = new System.Drawing.Point(183, 3);
|
||||
this.D6.Name = "D6";
|
||||
this.D6.Size = new System.Drawing.Size(30, 52);
|
||||
this.D6.TabIndex = 5;
|
||||
this.D6.Value = '0';
|
||||
//
|
||||
// D7
|
||||
//
|
||||
this.D7.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D7.LineWidth = 8;
|
||||
this.D7.Location = new System.Drawing.Point(219, 3);
|
||||
this.D7.Name = "D7";
|
||||
this.D7.Size = new System.Drawing.Size(30, 52);
|
||||
this.D7.TabIndex = 6;
|
||||
this.D7.Value = '8';
|
||||
//
|
||||
// D8
|
||||
//
|
||||
this.D8.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D8.LineWidth = 8;
|
||||
this.D8.Location = new System.Drawing.Point(255, 3);
|
||||
this.D8.Name = "D8";
|
||||
this.D8.Size = new System.Drawing.Size(30, 52);
|
||||
this.D8.TabIndex = 7;
|
||||
this.D8.Value = '-';
|
||||
//
|
||||
// D9
|
||||
//
|
||||
this.D9.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D9.LineWidth = 8;
|
||||
this.D9.Location = new System.Drawing.Point(291, 3);
|
||||
this.D9.Name = "D9";
|
||||
this.D9.Size = new System.Drawing.Size(30, 52);
|
||||
this.D9.TabIndex = 8;
|
||||
this.D9.Value = '0';
|
||||
//
|
||||
// D10
|
||||
//
|
||||
this.D10.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D10.LineWidth = 8;
|
||||
this.D10.Location = new System.Drawing.Point(327, 3);
|
||||
this.D10.Name = "D10";
|
||||
this.D10.Size = new System.Drawing.Size(30, 52);
|
||||
this.D10.TabIndex = 9;
|
||||
this.D10.Value = '1';
|
||||
//
|
||||
// UCLEDData
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.Name = "UCLEDData";
|
||||
this.Size = new System.Drawing.Size(360, 58);
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The table layout panel1
|
||||
/// </summary>
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
/// <summary>
|
||||
/// The d1
|
||||
/// </summary>
|
||||
private UCLEDNum D1;
|
||||
/// <summary>
|
||||
/// The d2
|
||||
/// </summary>
|
||||
private UCLEDNum D2;
|
||||
/// <summary>
|
||||
/// The d3
|
||||
/// </summary>
|
||||
private UCLEDNum D3;
|
||||
/// <summary>
|
||||
/// The d4
|
||||
/// </summary>
|
||||
private UCLEDNum D4;
|
||||
/// <summary>
|
||||
/// The d5
|
||||
/// </summary>
|
||||
private UCLEDNum D5;
|
||||
/// <summary>
|
||||
/// The d6
|
||||
/// </summary>
|
||||
private UCLEDNum D6;
|
||||
/// <summary>
|
||||
/// The d7
|
||||
/// </summary>
|
||||
private UCLEDNum D7;
|
||||
/// <summary>
|
||||
/// The d8
|
||||
/// </summary>
|
||||
private UCLEDNum D8;
|
||||
/// <summary>
|
||||
/// The d9
|
||||
/// </summary>
|
||||
private UCLEDNum D9;
|
||||
/// <summary>
|
||||
/// The D10
|
||||
/// </summary>
|
||||
private UCLEDNum D10;
|
||||
|
||||
}
|
||||
}
|
||||
113
UsingControl/HZHControls/Controls/LED/UCLEDData.cs
Normal file
113
UsingControl/HZHControls/Controls/LED/UCLEDData.cs
Normal file
@@ -0,0 +1,113 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 09-02-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCLEDData.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCLEDData.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public partial class UCLEDData : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The m value
|
||||
/// </summary>
|
||||
private DateTime m_value;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value.
|
||||
/// </summary>
|
||||
/// <value>The value.</value>
|
||||
[Description("值"), Category("自定义")]
|
||||
public DateTime Value
|
||||
{
|
||||
get { return m_value; }
|
||||
set
|
||||
{
|
||||
m_value = value;
|
||||
string str = value.ToString("yyyy-MM-dd");
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
((UCLEDNum)this.tableLayoutPanel1.Controls.Find("D" + (i + 1), false)[0]).Value = str[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m line width
|
||||
/// </summary>
|
||||
private int m_lineWidth = 8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the width of the line.
|
||||
/// </summary>
|
||||
/// <value>The width of the line.</value>
|
||||
[Description("线宽度,为了更好的显示效果,请使用偶数"), Category("自定义")]
|
||||
public int LineWidth
|
||||
{
|
||||
get { return m_lineWidth; }
|
||||
set
|
||||
{
|
||||
m_lineWidth = value;
|
||||
foreach (UCLEDNum c in this.tableLayoutPanel1.Controls)
|
||||
{
|
||||
c.LineWidth = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置控件的前景色。
|
||||
/// </summary>
|
||||
/// <value>The color of the fore.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Description("颜色"), Category("自定义")]
|
||||
public override System.Drawing.Color ForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ForeColor = value;
|
||||
foreach (UCLEDNum c in this.tableLayoutPanel1.Controls)
|
||||
{
|
||||
c.ForeColor = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCLEDData" /> class.
|
||||
/// </summary>
|
||||
public UCLEDData()
|
||||
{
|
||||
InitializeComponent();
|
||||
Value = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/LED/UCLEDData.resx
Normal file
120
UsingControl/HZHControls/Controls/LED/UCLEDData.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
391
UsingControl/HZHControls/Controls/LED/UCLEDDataTime.Designer.cs
generated
Normal file
391
UsingControl/HZHControls/Controls/LED/UCLEDDataTime.Designer.cs
generated
Normal file
@@ -0,0 +1,391 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 09-02-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCLEDDataTime.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCLEDDataTime.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
partial class UCLEDDataTime
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.tableLayoutPanel1 = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.D1 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D2 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D3 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D4 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D5 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D6 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D7 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D8 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D9 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D10 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D12 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D13 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D14 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D15 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D16 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D17 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D18 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.D19 = new HZH_Controls.Controls.UCLEDNum();
|
||||
this.tableLayoutPanel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tableLayoutPanel1
|
||||
//
|
||||
this.tableLayoutPanel1.ColumnCount = 19;
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 5.263158F));
|
||||
this.tableLayoutPanel1.Controls.Add(this.D1, 0, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D2, 1, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D3, 2, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D4, 3, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D5, 4, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D6, 5, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D7, 6, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D8, 7, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D9, 8, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D10, 9, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D12, 11, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D13, 12, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D14, 13, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D15, 14, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D16, 15, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D17, 16, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D18, 17, 0);
|
||||
this.tableLayoutPanel1.Controls.Add(this.D19, 18, 0);
|
||||
this.tableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableLayoutPanel1.Name = "tableLayoutPanel1";
|
||||
this.tableLayoutPanel1.RowCount = 1;
|
||||
this.tableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutPanel1.Size = new System.Drawing.Size(650, 58);
|
||||
this.tableLayoutPanel1.TabIndex = 1;
|
||||
//
|
||||
// D1
|
||||
//
|
||||
this.D1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D1.LineWidth = 8;
|
||||
this.D1.Location = new System.Drawing.Point(3, 3);
|
||||
this.D1.Name = "D1";
|
||||
this.D1.Size = new System.Drawing.Size(28, 52);
|
||||
this.D1.TabIndex = 0;
|
||||
this.D1.Value = '2';
|
||||
//
|
||||
// D2
|
||||
//
|
||||
this.D2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D2.LineWidth = 8;
|
||||
this.D2.Location = new System.Drawing.Point(37, 3);
|
||||
this.D2.Name = "D2";
|
||||
this.D2.Size = new System.Drawing.Size(28, 52);
|
||||
this.D2.TabIndex = 1;
|
||||
this.D2.Value = '0';
|
||||
//
|
||||
// D3
|
||||
//
|
||||
this.D3.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D3.LineWidth = 8;
|
||||
this.D3.Location = new System.Drawing.Point(71, 3);
|
||||
this.D3.Name = "D3";
|
||||
this.D3.Size = new System.Drawing.Size(28, 52);
|
||||
this.D3.TabIndex = 2;
|
||||
this.D3.Value = '1';
|
||||
//
|
||||
// D4
|
||||
//
|
||||
this.D4.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D4.LineWidth = 8;
|
||||
this.D4.Location = new System.Drawing.Point(105, 3);
|
||||
this.D4.Name = "D4";
|
||||
this.D4.Size = new System.Drawing.Size(28, 52);
|
||||
this.D4.TabIndex = 3;
|
||||
this.D4.Value = '9';
|
||||
//
|
||||
// D5
|
||||
//
|
||||
this.D5.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D5.LineWidth = 8;
|
||||
this.D5.Location = new System.Drawing.Point(139, 3);
|
||||
this.D5.Name = "D5";
|
||||
this.D5.Size = new System.Drawing.Size(28, 52);
|
||||
this.D5.TabIndex = 4;
|
||||
this.D5.Value = '-';
|
||||
//
|
||||
// D6
|
||||
//
|
||||
this.D6.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D6.LineWidth = 8;
|
||||
this.D6.Location = new System.Drawing.Point(173, 3);
|
||||
this.D6.Name = "D6";
|
||||
this.D6.Size = new System.Drawing.Size(28, 52);
|
||||
this.D6.TabIndex = 5;
|
||||
this.D6.Value = '0';
|
||||
//
|
||||
// D7
|
||||
//
|
||||
this.D7.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D7.LineWidth = 8;
|
||||
this.D7.Location = new System.Drawing.Point(207, 3);
|
||||
this.D7.Name = "D7";
|
||||
this.D7.Size = new System.Drawing.Size(28, 52);
|
||||
this.D7.TabIndex = 6;
|
||||
this.D7.Value = '8';
|
||||
//
|
||||
// D8
|
||||
//
|
||||
this.D8.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D8.LineWidth = 8;
|
||||
this.D8.Location = new System.Drawing.Point(241, 3);
|
||||
this.D8.Name = "D8";
|
||||
this.D8.Size = new System.Drawing.Size(28, 52);
|
||||
this.D8.TabIndex = 7;
|
||||
this.D8.Value = '-';
|
||||
//
|
||||
// D9
|
||||
//
|
||||
this.D9.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D9.LineWidth = 8;
|
||||
this.D9.Location = new System.Drawing.Point(275, 3);
|
||||
this.D9.Name = "D9";
|
||||
this.D9.Size = new System.Drawing.Size(28, 52);
|
||||
this.D9.TabIndex = 8;
|
||||
this.D9.Value = '0';
|
||||
//
|
||||
// D10
|
||||
//
|
||||
this.D10.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D10.LineWidth = 8;
|
||||
this.D10.Location = new System.Drawing.Point(309, 3);
|
||||
this.D10.Name = "D10";
|
||||
this.D10.Size = new System.Drawing.Size(28, 52);
|
||||
this.D10.TabIndex = 9;
|
||||
this.D10.Value = '1';
|
||||
//
|
||||
// D12
|
||||
//
|
||||
this.D12.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D12.LineWidth = 8;
|
||||
this.D12.Location = new System.Drawing.Point(377, 3);
|
||||
this.D12.Name = "D12";
|
||||
this.D12.Size = new System.Drawing.Size(28, 52);
|
||||
this.D12.TabIndex = 10;
|
||||
this.D12.Value = '2';
|
||||
//
|
||||
// D13
|
||||
//
|
||||
this.D13.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D13.LineWidth = 8;
|
||||
this.D13.Location = new System.Drawing.Point(411, 3);
|
||||
this.D13.Name = "D13";
|
||||
this.D13.Size = new System.Drawing.Size(28, 52);
|
||||
this.D13.TabIndex = 11;
|
||||
this.D13.Value = '3';
|
||||
//
|
||||
// D14
|
||||
//
|
||||
this.D14.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D14.LineWidth = 8;
|
||||
this.D14.Location = new System.Drawing.Point(445, 3);
|
||||
this.D14.Name = "D14";
|
||||
this.D14.Size = new System.Drawing.Size(28, 52);
|
||||
this.D14.TabIndex = 12;
|
||||
this.D14.Value = ':';
|
||||
//
|
||||
// D15
|
||||
//
|
||||
this.D15.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D15.LineWidth = 8;
|
||||
this.D15.Location = new System.Drawing.Point(479, 3);
|
||||
this.D15.Name = "D15";
|
||||
this.D15.Size = new System.Drawing.Size(28, 52);
|
||||
this.D15.TabIndex = 13;
|
||||
this.D15.Value = '0';
|
||||
//
|
||||
// D16
|
||||
//
|
||||
this.D16.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D16.LineWidth = 8;
|
||||
this.D16.Location = new System.Drawing.Point(513, 3);
|
||||
this.D16.Name = "D16";
|
||||
this.D16.Size = new System.Drawing.Size(28, 52);
|
||||
this.D16.TabIndex = 14;
|
||||
this.D16.Value = '1';
|
||||
//
|
||||
// D17
|
||||
//
|
||||
this.D17.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D17.LineWidth = 8;
|
||||
this.D17.Location = new System.Drawing.Point(547, 3);
|
||||
this.D17.Name = "D17";
|
||||
this.D17.Size = new System.Drawing.Size(28, 52);
|
||||
this.D17.TabIndex = 15;
|
||||
this.D17.Value = ':';
|
||||
//
|
||||
// D18
|
||||
//
|
||||
this.D18.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D18.LineWidth = 8;
|
||||
this.D18.Location = new System.Drawing.Point(581, 3);
|
||||
this.D18.Name = "D18";
|
||||
this.D18.Size = new System.Drawing.Size(28, 52);
|
||||
this.D18.TabIndex = 16;
|
||||
this.D18.Value = '5';
|
||||
//
|
||||
// D19
|
||||
//
|
||||
this.D19.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.D19.LineWidth = 8;
|
||||
this.D19.Location = new System.Drawing.Point(615, 3);
|
||||
this.D19.Name = "D19";
|
||||
this.D19.Size = new System.Drawing.Size(32, 52);
|
||||
this.D19.TabIndex = 17;
|
||||
this.D19.Value = '3';
|
||||
//
|
||||
// UCLEDDataTime
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
this.Controls.Add(this.tableLayoutPanel1);
|
||||
this.Name = "UCLEDDataTime";
|
||||
this.Size = new System.Drawing.Size(650, 58);
|
||||
this.tableLayoutPanel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// The table layout panel1
|
||||
/// </summary>
|
||||
private System.Windows.Forms.TableLayoutPanel tableLayoutPanel1;
|
||||
/// <summary>
|
||||
/// The d1
|
||||
/// </summary>
|
||||
private UCLEDNum D1;
|
||||
/// <summary>
|
||||
/// The d2
|
||||
/// </summary>
|
||||
private UCLEDNum D2;
|
||||
/// <summary>
|
||||
/// The d3
|
||||
/// </summary>
|
||||
private UCLEDNum D3;
|
||||
/// <summary>
|
||||
/// The d4
|
||||
/// </summary>
|
||||
private UCLEDNum D4;
|
||||
/// <summary>
|
||||
/// The d5
|
||||
/// </summary>
|
||||
private UCLEDNum D5;
|
||||
/// <summary>
|
||||
/// The d6
|
||||
/// </summary>
|
||||
private UCLEDNum D6;
|
||||
/// <summary>
|
||||
/// The d7
|
||||
/// </summary>
|
||||
private UCLEDNum D7;
|
||||
/// <summary>
|
||||
/// The d8
|
||||
/// </summary>
|
||||
private UCLEDNum D8;
|
||||
/// <summary>
|
||||
/// The d9
|
||||
/// </summary>
|
||||
private UCLEDNum D9;
|
||||
/// <summary>
|
||||
/// The D10
|
||||
/// </summary>
|
||||
private UCLEDNum D10;
|
||||
/// <summary>
|
||||
/// The D12
|
||||
/// </summary>
|
||||
private UCLEDNum D12;
|
||||
/// <summary>
|
||||
/// The D13
|
||||
/// </summary>
|
||||
private UCLEDNum D13;
|
||||
/// <summary>
|
||||
/// The D14
|
||||
/// </summary>
|
||||
private UCLEDNum D14;
|
||||
/// <summary>
|
||||
/// The D15
|
||||
/// </summary>
|
||||
private UCLEDNum D15;
|
||||
/// <summary>
|
||||
/// The D16
|
||||
/// </summary>
|
||||
private UCLEDNum D16;
|
||||
/// <summary>
|
||||
/// The D17
|
||||
/// </summary>
|
||||
private UCLEDNum D17;
|
||||
/// <summary>
|
||||
/// The D18
|
||||
/// </summary>
|
||||
private UCLEDNum D18;
|
||||
/// <summary>
|
||||
/// The D19
|
||||
/// </summary>
|
||||
private UCLEDNum D19;
|
||||
}
|
||||
}
|
||||
115
UsingControl/HZHControls/Controls/LED/UCLEDDataTime.cs
Normal file
115
UsingControl/HZHControls/Controls/LED/UCLEDDataTime.cs
Normal file
@@ -0,0 +1,115 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 09-02-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCLEDDataTime.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.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCLEDDataTime.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public partial class UCLEDDataTime : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The m value
|
||||
/// </summary>
|
||||
private DateTime m_value;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value.
|
||||
/// </summary>
|
||||
/// <value>The value.</value>
|
||||
[Description("值"), Category("自定义")]
|
||||
public DateTime Value
|
||||
{
|
||||
get { return m_value; }
|
||||
set
|
||||
{
|
||||
m_value = value;
|
||||
string str = value.ToString("yyyy-MM-dd HH:mm:ss");
|
||||
for (int i = 0; i < str.Length; i++)
|
||||
{
|
||||
if (i == 10)
|
||||
continue;
|
||||
((UCLEDNum)this.tableLayoutPanel1.Controls.Find("D" + (i + 1), false)[0]).Value = str[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m line width
|
||||
/// </summary>
|
||||
private int m_lineWidth = 8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the width of the line.
|
||||
/// </summary>
|
||||
/// <value>The width of the line.</value>
|
||||
[Description("线宽度,为了更好的显示效果,请使用偶数"), Category("自定义")]
|
||||
public int LineWidth
|
||||
{
|
||||
get { return m_lineWidth; }
|
||||
set
|
||||
{
|
||||
m_lineWidth = value;
|
||||
foreach (UCLEDNum c in this.tableLayoutPanel1.Controls)
|
||||
{
|
||||
c.LineWidth = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置控件的前景色。
|
||||
/// </summary>
|
||||
/// <value>The color of the fore.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Description("颜色"), Category("自定义")]
|
||||
public override System.Drawing.Color ForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ForeColor = value;
|
||||
foreach (UCLEDNum c in this.tableLayoutPanel1.Controls)
|
||||
{
|
||||
c.ForeColor = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCLEDDataTime" /> class.
|
||||
/// </summary>
|
||||
public UCLEDDataTime()
|
||||
{
|
||||
InitializeComponent();
|
||||
Value = DateTime.Now;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
UsingControl/HZHControls/Controls/LED/UCLEDDataTime.resx
Normal file
120
UsingControl/HZHControls/Controls/LED/UCLEDDataTime.resx
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
451
UsingControl/HZHControls/Controls/LED/UCLEDNum.cs
Normal file
451
UsingControl/HZHControls/Controls/LED/UCLEDNum.cs
Normal file
@@ -0,0 +1,451 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 09-02-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCLEDNum.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
|
||||
{
|
||||
/* 显示位置序号
|
||||
* ****1***
|
||||
* * *
|
||||
* 6 2
|
||||
* * *
|
||||
* ****7***
|
||||
* * *
|
||||
* 5 3
|
||||
* * *
|
||||
* ****4***
|
||||
*/
|
||||
/// <summary>
|
||||
/// Class UCLEDNum.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
public class UCLEDNum : UserControl
|
||||
{
|
||||
/// <summary>
|
||||
/// The m draw rect
|
||||
/// </summary>
|
||||
Rectangle m_drawRect = Rectangle.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// The m nums
|
||||
/// </summary>
|
||||
private static Dictionary<char, int[]> m_nums = new Dictionary<char, int[]>();
|
||||
/// <summary>
|
||||
/// Initializes static members of the <see cref="UCLEDNum" /> class.
|
||||
/// </summary>
|
||||
static UCLEDNum()
|
||||
{
|
||||
m_nums['0'] = new int[] { 1, 2, 3, 4, 5, 6 };
|
||||
m_nums['1'] = new int[] { 2, 3 };
|
||||
m_nums['2'] = new int[] { 1, 2, 5, 4, 7 };
|
||||
m_nums['3'] = new int[] { 1, 2, 7, 3, 4 };
|
||||
m_nums['4'] = new int[] { 2, 3, 6, 7 };
|
||||
m_nums['5'] = new int[] { 1, 6, 7, 3, 4 };
|
||||
m_nums['6'] = new int[] { 1, 6, 5, 4, 3, 7 };
|
||||
m_nums['7'] = new int[] { 1, 2, 3 };
|
||||
m_nums['8'] = new int[] { 1, 2, 3, 4, 5, 6, 7 };
|
||||
m_nums['9'] = new int[] { 1, 2, 3, 4, 7, 6 };
|
||||
m_nums['A'] = new int[] { 1, 2, 3, 5, 6, 7 };
|
||||
m_nums['b'] = new int[] { 3, 4, 5, 6, 7 };
|
||||
m_nums['C'] = new int[] { 1, 6, 5, 4 };
|
||||
m_nums['c'] = new int[] { 7, 5, 4 };
|
||||
m_nums['d'] = new int[] { 2, 3, 4, 5, 7 };
|
||||
m_nums['E'] = new int[] { 1, 4, 5, 6, 7 };
|
||||
m_nums['F'] = new int[] { 1, 5, 6, 7 };
|
||||
m_nums['H'] = new int[] { 2, 3, 5, 6, 7 };
|
||||
m_nums['h'] = new int[] { 3, 5, 6, 7 };
|
||||
m_nums['J'] = new int[] { 2, 3, 4 };
|
||||
m_nums['L'] = new int[] { 4, 5, 6 };
|
||||
m_nums['o'] = new int[] { 3, 4, 5, 7 };
|
||||
m_nums['P'] = new int[] { 1, 2, 5, 6, 7 };
|
||||
m_nums['r'] = new int[] { 5, 7 };
|
||||
m_nums['U'] = new int[] { 2, 3, 4, 5, 6 };
|
||||
m_nums['-'] = new int[] { 7 };
|
||||
m_nums[':'] = new int[0];
|
||||
m_nums['.'] = new int[0];
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="UCLEDNum" /> class.
|
||||
/// </summary>
|
||||
public UCLEDNum()
|
||||
{
|
||||
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);
|
||||
SizeChanged += LEDNum_SizeChanged;
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|
||||
Size = new System.Drawing.Size(40, 70);
|
||||
if (m_drawRect == Rectangle.Empty)
|
||||
m_drawRect = new Rectangle(1, 1, this.Width - 2, this.Height - 2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Handles the SizeChanged event of the LEDNum 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 LEDNum_SizeChanged(object sender, EventArgs e)
|
||||
{
|
||||
m_drawRect = new Rectangle(1, 1, this.Width - 2, this.Height - 2);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m value
|
||||
/// </summary>
|
||||
private char m_value = '0';
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the value.
|
||||
/// </summary>
|
||||
/// <value>The value.</value>
|
||||
[Description("值"), Category("自定义")]
|
||||
public char Value
|
||||
{
|
||||
get { return m_value; }
|
||||
set
|
||||
{
|
||||
if (!m_nums.ContainsKey(value))
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (m_value != value)
|
||||
{
|
||||
m_value = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the character value.
|
||||
/// </summary>
|
||||
/// <value>The character value.</value>
|
||||
public LEDNumChar ValueChar
|
||||
{
|
||||
get
|
||||
{
|
||||
return (LEDNumChar)((int)m_value);
|
||||
}
|
||||
set
|
||||
{
|
||||
Value = (char)value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The m line width
|
||||
/// </summary>
|
||||
private int m_lineWidth = 8;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the width of the line.
|
||||
/// </summary>
|
||||
/// <value>The width of the line.</value>
|
||||
[Description("线宽度,为了更好的显示效果,请使用偶数"), Category("自定义")]
|
||||
public int LineWidth
|
||||
{
|
||||
get { return m_lineWidth; }
|
||||
set
|
||||
{
|
||||
m_lineWidth = value;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取或设置控件的前景色。
|
||||
/// </summary>
|
||||
/// <value>The color of the fore.</value>
|
||||
/// <PermissionSet>
|
||||
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true" />
|
||||
/// </PermissionSet>
|
||||
[Description("颜色"), Category("自定义")]
|
||||
public override System.Drawing.Color ForeColor
|
||||
{
|
||||
get
|
||||
{
|
||||
return base.ForeColor;
|
||||
}
|
||||
set
|
||||
{
|
||||
base.ForeColor = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <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);
|
||||
e.Graphics.SetGDIHigh();
|
||||
if (m_value == '.')
|
||||
{
|
||||
Rectangle r2 = new Rectangle(m_drawRect.Left + (m_drawRect.Width - m_lineWidth) / 2, m_drawRect.Bottom - m_lineWidth * 2, m_lineWidth, m_lineWidth);
|
||||
e.Graphics.FillRectangle(new SolidBrush(ForeColor), r2);
|
||||
}
|
||||
else if (m_value == ':')
|
||||
{
|
||||
Rectangle r1 = new Rectangle(m_drawRect.Left + (m_drawRect.Width - m_lineWidth) / 2, m_drawRect.Top + (m_drawRect.Height / 2 - m_lineWidth) / 2, m_lineWidth, m_lineWidth);
|
||||
e.Graphics.FillRectangle(new SolidBrush(ForeColor), r1);
|
||||
Rectangle r2 = new Rectangle(m_drawRect.Left + (m_drawRect.Width - m_lineWidth) / 2, m_drawRect.Top + (m_drawRect.Height / 2 - m_lineWidth) / 2 + m_drawRect.Height / 2, m_lineWidth, m_lineWidth);
|
||||
e.Graphics.FillRectangle(new SolidBrush(ForeColor), r2);
|
||||
}
|
||||
else
|
||||
{
|
||||
int[] vs = m_nums[m_value];
|
||||
if (vs.Contains(1))
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLines(new Point[]
|
||||
{
|
||||
new Point(m_drawRect.Left + 2, m_drawRect.Top),
|
||||
new Point(m_drawRect.Right - 2, m_drawRect.Top),
|
||||
new Point(m_drawRect.Right - m_lineWidth-2, m_drawRect.Top+m_lineWidth),
|
||||
new Point(m_drawRect.Left + m_lineWidth+2, m_drawRect.Top+m_lineWidth),
|
||||
new Point(m_drawRect.Left + 2, m_drawRect.Top)
|
||||
});
|
||||
path.CloseAllFigures();
|
||||
e.Graphics.FillPath(new SolidBrush(ForeColor), path);
|
||||
}
|
||||
|
||||
if (vs.Contains(2))
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLines(new Point[]
|
||||
{
|
||||
new Point(m_drawRect.Right, m_drawRect.Top),
|
||||
new Point(m_drawRect.Right, m_drawRect.Top+(m_drawRect.Height-m_lineWidth-4)/2),
|
||||
new Point(m_drawRect.Right-m_lineWidth/2, m_drawRect.Top+(m_drawRect.Height-m_lineWidth-4)/2+m_lineWidth/2),
|
||||
new Point(m_drawRect.Right-m_lineWidth, m_drawRect.Top+(m_drawRect.Height-m_lineWidth-4)/2),
|
||||
new Point(m_drawRect.Right-m_lineWidth, m_drawRect.Top+m_lineWidth),
|
||||
new Point(m_drawRect.Right, m_drawRect.Top)
|
||||
});
|
||||
path.CloseAllFigures();
|
||||
e.Graphics.FillPath(new SolidBrush(ForeColor), path);
|
||||
}
|
||||
|
||||
if (vs.Contains(3))
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLines(new Point[]
|
||||
{
|
||||
new Point(m_drawRect.Right, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2),
|
||||
new Point(m_drawRect.Right, m_drawRect.Bottom),
|
||||
new Point(m_drawRect.Right-m_lineWidth, m_drawRect.Bottom-m_lineWidth),
|
||||
new Point(m_drawRect.Right-m_lineWidth, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2),
|
||||
new Point(m_drawRect.Right-m_lineWidth/2, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2-m_lineWidth/2),
|
||||
new Point(m_drawRect.Right, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2),
|
||||
});
|
||||
path.CloseAllFigures();
|
||||
e.Graphics.FillPath(new SolidBrush(ForeColor), path);
|
||||
}
|
||||
|
||||
if (vs.Contains(4))
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLines(new Point[]
|
||||
{
|
||||
new Point(m_drawRect.Left + 2, m_drawRect.Bottom),
|
||||
new Point(m_drawRect.Right - 2, m_drawRect.Bottom),
|
||||
new Point(m_drawRect.Right - m_lineWidth-2, m_drawRect.Bottom-m_lineWidth),
|
||||
new Point(m_drawRect.Left + m_lineWidth+2, m_drawRect.Bottom-m_lineWidth),
|
||||
new Point(m_drawRect.Left + 2, m_drawRect.Bottom)
|
||||
});
|
||||
path.CloseAllFigures();
|
||||
e.Graphics.FillPath(new SolidBrush(ForeColor), path);
|
||||
}
|
||||
|
||||
if (vs.Contains(5))
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLines(new Point[]
|
||||
{
|
||||
new Point(m_drawRect.Left, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2),
|
||||
new Point(m_drawRect.Left, m_drawRect.Bottom),
|
||||
new Point(m_drawRect.Left+m_lineWidth, m_drawRect.Bottom-m_lineWidth),
|
||||
new Point(m_drawRect.Left+m_lineWidth, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2),
|
||||
new Point(m_drawRect.Left+m_lineWidth/2, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2-m_lineWidth/2),
|
||||
new Point(m_drawRect.Left, m_drawRect.Bottom-(m_drawRect.Height-m_lineWidth-4)/2),
|
||||
});
|
||||
path.CloseAllFigures();
|
||||
e.Graphics.FillPath(new SolidBrush(ForeColor), path);
|
||||
}
|
||||
|
||||
|
||||
if (vs.Contains(6))
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLines(new Point[]
|
||||
{
|
||||
new Point(m_drawRect.Left, m_drawRect.Top),
|
||||
new Point(m_drawRect.Left, m_drawRect.Top+(m_drawRect.Height-m_lineWidth-4)/2),
|
||||
new Point(m_drawRect.Left+m_lineWidth/2, m_drawRect.Top+(m_drawRect.Height-m_lineWidth-4)/2+m_lineWidth/2),
|
||||
new Point(m_drawRect.Left+m_lineWidth, m_drawRect.Top+(m_drawRect.Height-m_lineWidth-4)/2),
|
||||
new Point(m_drawRect.Left+m_lineWidth, m_drawRect.Top+m_lineWidth),
|
||||
new Point(m_drawRect.Left, m_drawRect.Top)
|
||||
});
|
||||
path.CloseAllFigures();
|
||||
e.Graphics.FillPath(new SolidBrush(ForeColor), path);
|
||||
}
|
||||
|
||||
if (vs.Contains(7))
|
||||
{
|
||||
GraphicsPath path = new GraphicsPath();
|
||||
path.AddLines(new Point[]
|
||||
{
|
||||
new Point(m_drawRect.Left+m_lineWidth/2, m_drawRect.Height/2+1),
|
||||
new Point(m_drawRect.Left+m_lineWidth, m_drawRect.Height/2-m_lineWidth/2+1),
|
||||
new Point(m_drawRect.Right-m_lineWidth, m_drawRect.Height/2-m_lineWidth/2+1),
|
||||
new Point(m_drawRect.Right-m_lineWidth/2, m_drawRect.Height/2+1),
|
||||
new Point(m_drawRect.Right-m_lineWidth, m_drawRect.Height/2+m_lineWidth/2+1),
|
||||
new Point(m_drawRect.Left+m_lineWidth, m_drawRect.Height/2+m_lineWidth/2+1),
|
||||
new Point(m_drawRect.Left+m_lineWidth/2, m_drawRect.Height/2+1)
|
||||
});
|
||||
path.CloseAllFigures();
|
||||
e.Graphics.FillPath(new SolidBrush(ForeColor), path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>Enum LEDNumChar</summary>
|
||||
public enum LEDNumChar : int
|
||||
{
|
||||
/// <summary>
|
||||
/// The character 0
|
||||
/// </summary>
|
||||
CHAR_0 = (int)'0',
|
||||
/// <summary>
|
||||
/// The character 1
|
||||
/// </summary>
|
||||
CHAR_1 = (int)'1',
|
||||
/// <summary>
|
||||
/// The character 2
|
||||
/// </summary>
|
||||
CHAR_2 = (int)'2',
|
||||
/// <summary>
|
||||
/// The character 3
|
||||
/// </summary>
|
||||
CHAR_3 = (int)'3',
|
||||
/// <summary>
|
||||
/// The character 4
|
||||
/// </summary>
|
||||
CHAR_4 = (int)'4',
|
||||
CHAR_5 = (int)'5',
|
||||
/// <summary>
|
||||
/// The character 6
|
||||
/// </summary>
|
||||
CHAR_6 = (int)'6',
|
||||
/// <summary>
|
||||
/// The character 7
|
||||
/// </summary>
|
||||
CHAR_7 = (int)'7',
|
||||
/// <summary>
|
||||
/// The character 8
|
||||
/// </summary>
|
||||
CHAR_8 = (int)'8',
|
||||
/// <summary>
|
||||
/// The character 9
|
||||
/// </summary>
|
||||
CHAR_9 = (int)'9',
|
||||
/// <summary>
|
||||
/// The character a
|
||||
/// </summary>
|
||||
CHAR_A = (int)'A',
|
||||
/// <summary>
|
||||
/// The character b
|
||||
/// </summary>
|
||||
CHAR_b = (int)'b',
|
||||
/// <summary>
|
||||
/// The character c
|
||||
/// </summary>
|
||||
CHAR_C = (int)'C',
|
||||
/// <summary>
|
||||
/// The character c
|
||||
/// </summary>
|
||||
CHAR_c = (int)'c',
|
||||
/// <summary>
|
||||
/// The character d
|
||||
/// </summary>
|
||||
CHAR_d = (int)'d',
|
||||
/// <summary>
|
||||
/// The character e
|
||||
/// </summary>
|
||||
CHAR_E = (int)'E',
|
||||
/// <summary>
|
||||
/// The character f
|
||||
/// </summary>
|
||||
CHAR_F = (int)'F',
|
||||
/// <summary>
|
||||
/// The character h
|
||||
/// </summary>
|
||||
CHAR_H = (int)'H',
|
||||
/// <summary>
|
||||
/// The character h
|
||||
/// </summary>
|
||||
CHAR_h = (int)'h',
|
||||
/// <summary>
|
||||
/// The character j
|
||||
/// </summary>
|
||||
CHAR_J = (int)'J',
|
||||
/// <summary>
|
||||
/// The character l
|
||||
/// </summary>
|
||||
CHAR_L = (int)'L',
|
||||
/// <summary>
|
||||
/// The character o
|
||||
/// </summary>
|
||||
CHAR_o = (int)'o',
|
||||
/// <summary>
|
||||
/// The character p
|
||||
/// </summary>
|
||||
CHAR_P = (int)'P',
|
||||
/// <summary>
|
||||
/// The character r
|
||||
/// </summary>
|
||||
CHAR_r = (int)'r',
|
||||
/// <summary>
|
||||
/// The character u
|
||||
/// </summary>
|
||||
CHAR_U = (int)'U',
|
||||
/// <summary>
|
||||
/// The character horizontal line
|
||||
/// </summary>
|
||||
CHAR_HorizontalLine = (int)'-',
|
||||
/// <summary>
|
||||
/// The character colon
|
||||
/// </summary>
|
||||
CHAR_Colon = (int)':',
|
||||
/// <summary>
|
||||
/// The character dot
|
||||
/// </summary>
|
||||
CHAR_Dot = (int)'.',
|
||||
}
|
||||
}
|
||||
65
UsingControl/HZHControls/Controls/LED/UCLEDNums.Designer.cs
generated
Normal file
65
UsingControl/HZHControls/Controls/LED/UCLEDNums.Designer.cs
generated
Normal file
@@ -0,0 +1,65 @@
|
||||
// ***********************************************************************
|
||||
// Assembly : HZH_Controls
|
||||
// Created : 09-02-2019
|
||||
//
|
||||
// ***********************************************************************
|
||||
// <copyright file="UCLEDNums.Designer.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.
|
||||
// ***********************************************************************
|
||||
namespace HZH_Controls.Controls
|
||||
{
|
||||
/// <summary>
|
||||
/// Class UCLEDNums.
|
||||
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||
/// </summary>
|
||||
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||
partial class UCLEDNums
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// UCLEDNums
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Name = "UCLEDNums";
|
||||
this.Size = new System.Drawing.Size(150, 58);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user