diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..511e45d
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,50 @@
+################################################################################
+# 此 .gitignore 文件已由 Microsoft(R) Visual Studio 自动创建。
+################################################################################
+
+/.vs
+/SocketHelper/obj/Debug
+/SocketHelper/obj/Release
+/SimpleServer/obj/x86
+/PLCCommunication/obj/Debug
+/JY.Control/obj
+/JY.Utility/obj
+/PLCCommunication/obj/Release
+/SimpleServer/obj
+/JY.Model/obj/Release
+/JY.MES/obj/Release
+/JY.MES/obj/Debug
+/JY.DAL/bin/Debug
+/JY.DAL/obj/Debug
+/JY.Inspection/bin/Debug
+/JY.Control/bin/Debug
+/JY.MES/bin/Debug
+/JY.Model/bin/Debug
+/JY.Utility/bin/Debug
+/packages/BouncyCastle.Cryptography.2.4.0
+/packages
+/PLCCommunication/bin/Debug
+/SimpleServer/bin/Debug
+/SocketHelper/bin/Debug
+/JY.Model/obj/Debug
+/JY.Inspection/obj/Debug
+/JY.Inspection/obj/Release
+/JY.Inspection/bin/Debug.rar
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+[Ww][Ii][Nn]32/
+[Aa][Rr][Mm]/
+[Aa][Rr][Mm]64/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+[Ll]ogs/
+/JY.DAL/obj/Release/JY.DAL.csproj.AssemblyReference.cache
+/JY.Inspection/obj/Debug/JY.Inspection.csproj.AssemblyReference.cache
diff --git a/HC.md b/HC.md
new file mode 100644
index 0000000..e9d0cb5
--- /dev/null
+++ b/HC.md
@@ -0,0 +1,5 @@
+
+# 数据读取流程
+ReceiveEvent += OmronRegEvent_Job1
+
+(81, 282)
\ No newline at end of file
diff --git a/JY.Control/Base/ButtonRenderer.cs b/JY.Control/Base/ButtonRenderer.cs
new file mode 100644
index 0000000..8668c7c
--- /dev/null
+++ b/JY.Control/Base/ButtonRenderer.cs
@@ -0,0 +1,260 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JYControl
+{
+ ///
+ /// Base class for the button renderers
+ ///
+ public class LBButtonRenderer : LBRendererBase
+ {
+ #region (* Variables *)
+ protected RectangleF rectCtrl;
+ protected RectangleF rectBody;
+ protected RectangleF rectText;
+ protected float drawRatio = 1.0F;
+ #endregion
+
+ #region (* Constructor *)
+ public LBButtonRenderer()
+ {
+ this.rectCtrl = new RectangleF(0, 0, 0, 0);
+ }
+ #endregion
+
+ #region (* Overrided methods *)
+ ///
+ /// Update the rectangles for drawing
+ ///
+ ///
+ public override bool Update()
+ {
+ // Check Button object
+ if (this.Button == null)
+ throw new NullReferenceException("Invalid 'Button' object");
+
+ // Control rectangle
+ this.rectCtrl.X = 0;
+ this.rectCtrl.Y = 0;
+ this.rectCtrl.Width = this.Button.Width;
+ this.rectCtrl.Height = this.Button.Height;
+
+ if (this.Button.Style == LBButton.ButtonStyle.Circular)
+ {
+ if (rectCtrl.Width < rectCtrl.Height)
+ rectCtrl.Height = rectCtrl.Width;
+ else if (rectCtrl.Width > rectCtrl.Height)
+ rectCtrl.Width = rectCtrl.Height;
+
+ if (rectCtrl.Width < 10)
+ rectCtrl.Width = 10;
+ if (rectCtrl.Height < 10)
+ rectCtrl.Height = 10;
+ }
+
+ this.rectBody = this.rectCtrl;
+ this.rectBody.Width -= 1;
+ this.rectBody.Height -= 1;
+
+ this.rectText = this.rectCtrl;
+ this.rectText.Width -= 2;
+ this.rectText.Height -= 2;
+
+ // Calculate ratio
+ drawRatio = (Math.Min(rectCtrl.Width, rectCtrl.Height)) / 200;
+ if (drawRatio == 0.0)
+ drawRatio = 1;
+
+ return true;
+ }
+
+ ///
+ /// Draw the button object
+ ///
+ ///
+ public override void Draw(Graphics Gr)
+ {
+ if (Gr == null)
+ throw new ArgumentNullException("Gr", "Invalid Graphics object");
+
+ if (this.Button == null)
+ throw new NullReferenceException("Invalid 'Button' object");
+
+ this.DrawBackground(Gr, this.rectCtrl);
+ this.DrawBody(Gr, this.rectBody);
+ this.DrawText(Gr, this.rectText);
+ }
+ #endregion
+
+ #region (* Properies *)
+ ///
+ /// Get the associated button object
+ ///
+ public LBButton Button
+ {
+ get { return this.Control as LBButton; }
+ }
+ #endregion
+
+ #region (* Virtual method *)
+ ///
+ /// Draw the background of the control
+ ///
+ ///
+ ///
+ ///
+ public virtual bool DrawBackground(Graphics Gr, RectangleF rc)
+ {
+ if (this.Button == null)
+ return false;
+
+ Color c = this.Button.BackColor;
+ SolidBrush br = new SolidBrush(c);
+ Pen pen = new Pen(c);
+
+ Rectangle _rcTmp = new Rectangle(0, 0, this.Button.Width, this.Button.Height);
+ Gr.DrawRectangle(pen, _rcTmp);
+ Gr.FillRectangle(br, rc);
+
+ br.Dispose();
+ pen.Dispose();
+
+ return true;
+ }
+
+ ///
+ /// Draw the body of the control
+ ///
+ ///
+ ///
+ ///
+ public virtual bool DrawBody(Graphics Gr, RectangleF rc)
+ {
+ if (this.Button == null)
+ return false;
+
+ Color bodyColor = this.Button.ButtonColor;
+ Color cDark = LBColorManager.StepColor(bodyColor, 20);
+
+ LinearGradientBrush br1 = new LinearGradientBrush(rc,
+ bodyColor,
+ cDark,
+ 45);
+
+ if ((this.Button.Style == LBButton.ButtonStyle.Circular) ||
+ (this.Button.Style == LBButton.ButtonStyle.Elliptical))
+ {
+ Gr.FillEllipse(br1, rc);
+ }
+ else
+ {
+ GraphicsPath path = this.RoundedRect(rc, 15F);
+ Gr.FillPath(br1, path);
+ path.Dispose();
+ }
+
+ if (this.Button.State == LBButton.ButtonState.Pressed)
+ {
+ RectangleF _rc = rc;
+ _rc.Inflate(-15F * this.drawRatio, -15F * drawRatio);
+ LinearGradientBrush br2 = new LinearGradientBrush(_rc,
+ cDark,
+ bodyColor,
+ 45);
+ if ((this.Button.Style == LBButton.ButtonStyle.Circular) ||
+ (this.Button.Style == LBButton.ButtonStyle.Elliptical))
+ {
+ Gr.FillEllipse(br2, _rc);
+ }
+ else
+ {
+ GraphicsPath path = this.RoundedRect(_rc, 10F);
+ Gr.FillPath(br2, path);
+ path.Dispose();
+ }
+
+ br2.Dispose();
+ }
+
+ br1.Dispose();
+ return true;
+ }
+
+ ///
+ /// Draw the text of the control
+ ///
+ ///
+ ///
+ ///
+ public virtual bool DrawText(Graphics Gr, RectangleF rc)
+ {
+ if (this.Button == null)
+ return false;
+
+ //Draw Strings
+ Font font = new Font(this.Button.Font.FontFamily,
+ this.Button.Font.Size * this.drawRatio,
+ this.Button.Font.Style);
+
+ String str = this.Button.Label;
+
+ Color bodyColor = this.Button.ButtonColor;
+ Color cDark = LBColorManager.StepColor(bodyColor, 20);
+
+ SizeF size = Gr.MeasureString(str, font);
+
+ SolidBrush br1 = new SolidBrush(bodyColor);
+ SolidBrush br2 = new SolidBrush(cDark);
+
+ Gr.DrawString(str,
+ font,
+ br1,
+ rc.Left + ((rc.Width * 0.5F) - (float)(size.Width * 0.5F)) + (float)(1 * this.drawRatio),
+ rc.Top + ((rc.Height * 0.5F) - (float)(size.Height * 0.5)) + (float)(1 * this.drawRatio));
+
+ Gr.DrawString(str,
+ font,
+ br2,
+ rc.Left + ((rc.Width * 0.5F) - (float)(size.Width * 0.5F)),
+ rc.Top + ((rc.Height * 0.5F) - (float)(size.Height * 0.5)));
+
+ br1.Dispose();
+ br2.Dispose();
+ font.Dispose();
+
+ return false;
+ }
+ #endregion
+
+ #region (* Protected Methods *)
+ protected GraphicsPath RoundedRect(RectangleF rect, float radius)
+ {
+ RectangleF baseRect = rect;
+ float diameter = (radius * this.drawRatio) * 2.0f;
+ SizeF sizeF = new SizeF(diameter, diameter);
+ RectangleF arc = new RectangleF(baseRect.Location, sizeF);
+ GraphicsPath path = new GraphicsPath();
+
+ // top left arc
+ path.AddArc(arc, 180, 90);
+ // top right arc
+ arc.X = baseRect.Right - diameter;
+ path.AddArc(arc, 270, 90);
+ // bottom right arc
+ arc.Y = baseRect.Bottom - diameter;
+ path.AddArc(arc, 0, 90);
+ // bottom left arc
+ arc.X = baseRect.Left;
+ path.AddArc(arc, 90, 90);
+
+ path.CloseFigure();
+ return path;
+ }
+ #endregion
+ }
+}
diff --git a/JY.Control/Base/ColorMng.cs b/JY.Control/Base/ColorMng.cs
new file mode 100644
index 0000000..ac2c07c
--- /dev/null
+++ b/JY.Control/Base/ColorMng.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JYControl
+{
+ ///
+ /// Manager for color
+ ///
+ public class LBColorManager : Object
+ {
+ public static double BlendColour(double fg, double bg, double alpha)
+ {
+ double result = bg + (alpha * (fg - bg));
+ if (result < 0.0)
+ result = 0.0;
+ if (result > 255)
+ result = 255;
+ return result;
+ }
+
+ public static Color StepColor(Color clr, int alpha)
+ {
+ if (alpha == 100)
+ return clr;
+
+ byte a = clr.A;
+ byte r = clr.R;
+ byte g = clr.G;
+ byte b = clr.B;
+ float bg = 0;
+
+ int _alpha = Math.Min(alpha, 200);
+ _alpha = Math.Max(alpha, 0);
+ double ialpha = ((double)(_alpha - 100.0)) / 100.0;
+
+ if (ialpha > 100)
+ {
+ // blend with white
+ bg = 255.0F;
+ ialpha = 1.0F - ialpha; // 0 = transparent fg; 1 = opaque fg
+ }
+ else
+ {
+ // blend with black
+ bg = 0.0F;
+ ialpha = 1.0F + ialpha; // 0 = transparent fg; 1 = opaque fg
+ }
+
+ r = (byte)(LBColorManager.BlendColour(r, bg, ialpha));
+ g = (byte)(LBColorManager.BlendColour(g, bg, ialpha));
+ b = (byte)(LBColorManager.BlendColour(b, bg, ialpha));
+
+ return Color.FromArgb(a, r, g, b);
+ }
+ };
+}
diff --git a/JY.Control/Base/ControlHelper.cs b/JY.Control/Base/ControlHelper.cs
new file mode 100644
index 0000000..744ba64
--- /dev/null
+++ b/JY.Control/Base/ControlHelper.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace JYControl
+{
+ public static class ControlHelper
+ {
+ ///
+ /// The m LST freeze control
+ ///
+ static Dictionary m_lstFreezeControl = new Dictionary();
+
+ public static void FreezeControl(Control control, bool blnToFreeze)
+ {
+ if (blnToFreeze && control.IsHandleCreated && control.Visible && !control.IsDisposed && (!m_lstFreezeControl.ContainsKey(control) || (m_lstFreezeControl.ContainsKey(control) && m_lstFreezeControl[control] == false)))
+ {
+ m_lstFreezeControl[control] = true;
+ control.Disposed += control_Disposed;
+ NativeMethods.SendMessage(control.Handle, 11, 0, 0);
+ }
+ else if (!blnToFreeze && !control.IsDisposed && m_lstFreezeControl.ContainsKey(control) && m_lstFreezeControl[control] == true)
+ {
+ m_lstFreezeControl.Remove(control);
+ NativeMethods.SendMessage(control.Handle, 11, 1, 0);
+ control.Invalidate(true);
+ }
+ }
+
+ ///
+ /// Handles the Disposed event of the control control.
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ static void control_Disposed(object sender, EventArgs e)
+ {
+ try
+ {
+ if (m_lstFreezeControl.ContainsKey((Control)sender))
+ m_lstFreezeControl.Remove((Control)sender);
+ }
+ catch { }
+ }
+
+ ///
+ /// 设置GDI高质量模式抗锯齿
+ ///
+ /// The g.
+ public static void SetGDIHigh(this Graphics g)
+ {
+ g.SmoothingMode = SmoothingMode.AntiAlias; //使绘图质量最高,即消除锯齿
+ g.InterpolationMode = InterpolationMode.HighQualityBicubic;
+ g.CompositingQuality = CompositingQuality.HighQuality;
+ }
+
+ ///
+ /// 根据矩形和圆得到一个圆角矩形Path
+ ///
+ /// The rect.
+ /// The corner radius.
+ /// GraphicsPath.
+ public static GraphicsPath CreateRoundedRectanglePath(this Rectangle rect, int cornerRadius)
+ {
+ GraphicsPath roundedRect = new GraphicsPath();
+ roundedRect.AddArc(rect.X, rect.Y, cornerRadius * 2, cornerRadius * 2, 180, 90);
+ roundedRect.AddLine(rect.X + cornerRadius, rect.Y, rect.Right - cornerRadius * 2, rect.Y);
+ roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y, cornerRadius * 2, cornerRadius * 2, 270, 90);
+ roundedRect.AddLine(rect.Right, rect.Y + cornerRadius * 2, rect.Right, rect.Y + rect.Height - cornerRadius * 2);
+ roundedRect.AddArc(rect.X + rect.Width - cornerRadius * 2, rect.Y + rect.Height - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 0, 90);
+ roundedRect.AddLine(rect.Right - cornerRadius * 2, rect.Bottom, rect.X + cornerRadius * 2, rect.Bottom);
+ roundedRect.AddArc(rect.X, rect.Bottom - cornerRadius * 2, cornerRadius * 2, cornerRadius * 2, 90, 90);
+ roundedRect.AddLine(rect.X, rect.Bottom - cornerRadius * 2, rect.X, rect.Y + cornerRadius * 2);
+ roundedRect.CloseFigure();
+ return roundedRect;
+ }
+ }
+}
diff --git a/JY.Control/Base/LBIndustrialCtrlBase.Designer.cs b/JY.Control/Base/LBIndustrialCtrlBase.Designer.cs
new file mode 100644
index 0000000..95752e4
--- /dev/null
+++ b/JY.Control/Base/LBIndustrialCtrlBase.Designer.cs
@@ -0,0 +1,37 @@
+namespace JYControl
+{
+ partial class LBIndustrialCtrlBase
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region 组件设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ }
+
+ #endregion
+ }
+}
diff --git a/JY.Control/Base/LBIndustrialCtrlBase.cs b/JY.Control/Base/LBIndustrialCtrlBase.cs
new file mode 100644
index 0000000..44616e9
--- /dev/null
+++ b/JY.Control/Base/LBIndustrialCtrlBase.cs
@@ -0,0 +1,249 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace JYControl
+{
+ ///
+ /// Base class for the IndustrialCtrls
+ ///
+ public partial class LBIndustrialCtrlBase : UserControl
+ {
+ #region (* Constructor *)
+ public LBIndustrialCtrlBase()
+ {
+ InitializeComponent();
+
+ // Set the styles for drawing
+ SetStyle(ControlStyles.AllPaintingInWmPaint |
+ ControlStyles.ResizeRedraw |
+ ControlStyles.DoubleBuffer |
+ ControlStyles.SupportsTransparentBackColor,
+ true);
+
+ // Transparent background
+ this.BackColor = Color.Transparent;
+
+ // Creation of the default renderer
+ this._defaultRenderer = CreateDefaultRenderer();
+ if (this._defaultRenderer != null)
+ this._defaultRenderer.Control = this;
+ }
+ #endregion
+
+ #region (* Properties *)
+ ///
+ /// Default renderer of the control
+ ///
+ private ILBRenderer _defaultRenderer = null;
+ [Browsable(false)]
+ public ILBRenderer DefaultRenderer
+ {
+ get { return this._defaultRenderer; }
+ }
+
+ ///
+ /// User defined renderer
+ ///
+ private ILBRenderer _renderer = null;
+ [Browsable(false)]
+ public ILBRenderer Renderer
+ {
+ set
+ {
+ // set the renderer
+ this._renderer = value;
+ if (this._renderer != null)
+ {
+ // Set the control tu the renderer
+ this._renderer.Control = this;
+ // Update the renderer
+ this._renderer.Update();
+ }
+
+ // Redraw the renderer
+ Invalidate();
+ }
+ get { return this._renderer; }
+ }
+ #endregion
+
+ #region (* Events delegates *)
+ ///
+ /// Font change event
+ ///
+ ///
+ [System.ComponentModel.EditorBrowsableAttribute()]
+ protected override void OnFontChanged(EventArgs e)
+ {
+ // Calculate dimensions
+ this.CalculateDimensions();
+ }
+ ///
+ /// SizeChanged event
+ ///
+ ///
+ [System.ComponentModel.EditorBrowsableAttribute()]
+ protected override void OnSizeChanged(EventArgs e)
+ {
+ // Default
+ base.OnSizeChanged(e);
+ // Calculate al the data for
+ // drawing the control
+ this.CalculateDimensions();
+ // Redraw
+ this.Invalidate();
+ }
+
+ ///
+ /// Resize event
+ ///
+ ///
+ protected override void OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+ // Calculate al the data for
+ // drawing the control
+ this.CalculateDimensions();
+ // Redraw
+ this.Invalidate();
+ }
+ ///
+ /// Paint event
+ ///
+ ///
+ [System.ComponentModel.EditorBrowsableAttribute()]
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ // Rectangle of the control
+ RectangleF _rc = new RectangleF(0, 0, this.Width, this.Height);
+ e.Graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+
+ // Call the default renderer if the user
+ // rendere is null
+ if (this.Renderer == null)
+ {
+ this.DefaultRenderer.Draw(e.Graphics);
+ return;
+ }
+
+ // Draw with the user renderer
+ this.Renderer.Draw(e.Graphics);
+ }
+ #endregion
+
+ #region (* Virtual method *)
+ ///
+ /// Call from the constructor to create the default renderer
+ ///
+ ///
+ protected virtual ILBRenderer CreateDefaultRenderer()
+ {
+ return new LBRendererBase();
+ }
+
+ ///
+ /// Calculate the dimensions of the control
+ ///
+ protected virtual void CalculateDimensions()
+ {
+ this.DefaultRenderer.Update();
+
+ // Update the data in the renderer
+ if (this.Renderer != null)
+ this.Renderer.Update();
+
+ this.Invalidate();
+ }
+ #endregion
+ }
+
+ ///
+ /// Base class for the controls renderer
+ ///
+ public class LBRendererBase : ILBRenderer
+ {
+ #region (* Constructor *)
+ public LBRendererBase()
+ {
+ }
+ #endregion
+
+ #region (* IDisposable implementation *)
+ public void Dispose()
+ {
+ this.OnDispose();
+ }
+ #endregion
+
+ #region (* Properties *)
+ ///
+ /// Associated control
+ ///
+ protected object _control = null;
+ public object Control
+ {
+ set { this._control = value; }
+ get { return this._control; }
+ }
+ #endregion
+
+ #region (* Virtual methods *)
+ ///
+ /// Dispose the resource of the object
+ ///
+ public virtual void OnDispose()
+ {
+ }
+
+ ///
+ /// Update the renderer
+ ///
+ ///
+ public virtual bool Update()
+ {
+ return false;
+ }
+
+ ///
+ /// Drawing method
+ ///
+ ///
+ public virtual void Draw(Graphics Gr)
+ {
+ // Check the graphics
+ if (Gr == null)
+ throw new ArgumentNullException("Gr");
+
+ // Check the control
+ Control ctrl = this.Control as Control;
+ if (ctrl == null)
+ throw new NullReferenceException("Associated control is not valid");
+
+ // Default drawing
+ Rectangle rc = ctrl.Bounds;
+
+ Gr.FillRectangle(Brushes.White, ctrl.Bounds);
+ Gr.DrawRectangle(Pens.Black, ctrl.Bounds);
+
+ Gr.DrawLine(Pens.Red,
+ ctrl.Left,
+ ctrl.Top,
+ ctrl.Right,
+ ctrl.Bottom);
+
+ Gr.DrawLine(Pens.Red,
+ ctrl.Right,
+ ctrl.Top,
+ ctrl.Left,
+ ctrl.Bottom);
+ }
+ #endregion
+ }
+}
diff --git a/JY.Control/Base/LedRenderer.cs b/JY.Control/Base/LedRenderer.cs
new file mode 100644
index 0000000..3199d60
--- /dev/null
+++ b/JY.Control/Base/LedRenderer.cs
@@ -0,0 +1,271 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JYControl
+{
+ ///
+ /// Base class for the led renderers
+ ///
+ public class LBLedRenderer : LBRendererBase
+ {
+ #region (* Variables *)
+ private RectangleF drawRect;
+ private RectangleF rectLed;
+ private RectangleF rectLabel;
+ #endregion
+
+ #region (* Properies *)
+ ///
+ /// Get the associated led object
+ ///
+ public LBLed Led
+ {
+ get { return this.Control as LBLed; }
+ }
+ #endregion
+
+ #region (* Overrided method *)
+ ///
+ /// Update the rectangles for drawing
+ ///
+ ///
+ public override bool Update()
+ {
+ // Check Led object
+ if (this.Led == null)
+ throw new NullReferenceException("Invalid 'Led' object");
+
+ // Dati del rettangolo
+ float x, y, w, h;
+ x = 0;
+ y = 0;
+ w = this.Led.Size.Width;
+ h = this.Led.Size.Height;
+
+ // Rettangolo di disegno
+ drawRect.X = x;
+ drawRect.Y = y;
+ drawRect.Width = w - 2;
+ drawRect.Height = h - 2;
+ if (drawRect.Width <= 0)
+ drawRect.Width = 20;
+ if (drawRect.Height <= 0)
+ drawRect.Height = 20;
+
+ this.rectLed = drawRect;
+ this.rectLabel = drawRect;
+
+ if (this.Led.LabelPosition == LBLed.LedLabelPosition.Bottom)
+ {
+ this.rectLed.X = (this.rectLed.Width * 0.5F) - (this.Led.LedSize.Width * 0.5F);
+ this.rectLed.Width = this.Led.LedSize.Width;
+ this.rectLed.Height = this.Led.LedSize.Height;
+
+ this.rectLabel.Y = this.rectLed.Bottom;
+ }
+
+ else if (this.Led.LabelPosition == LBLed.LedLabelPosition.Top)
+ {
+ this.rectLed.X = (this.rectLed.Width * 0.5F) - (this.Led.LedSize.Width * 0.5F);
+ this.rectLed.Y = this.rectLed.Height - this.Led.LedSize.Height;
+ this.rectLed.Width = this.Led.LedSize.Width;
+ this.rectLed.Height = this.Led.LedSize.Height;
+
+ this.rectLabel.Height = this.rectLed.Top;
+ }
+
+ else if (this.Led.LabelPosition == LBLed.LedLabelPosition.Left)
+ {
+ this.rectLed.X = this.rectLed.Width - this.Led.LedSize.Width;
+ this.rectLed.Width = this.Led.LedSize.Width;
+ this.rectLed.Height = this.Led.LedSize.Height;
+
+ this.rectLabel.Width = this.rectLabel.Width - this.rectLed.Width;
+ }
+
+ else if (this.Led.LabelPosition == LBLed.LedLabelPosition.Right)
+ {
+ this.rectLed.Width = this.Led.LedSize.Width;
+ this.rectLed.Height = this.Led.LedSize.Height;
+
+ this.rectLabel.X = this.rectLed.Right;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Draw the led object
+ ///
+ ///
+ public override void Draw(Graphics Gr)
+ {
+ if (Gr == null)
+ throw new ArgumentNullException("Gr");
+
+ LBLed ctrl = this.Led;
+ if (ctrl == null)
+ throw new NullReferenceException("Associated control is not valid");
+
+ Rectangle rc = ctrl.Bounds;
+
+ this.DrawBackground(Gr, rc);
+
+ if (this.rectLed.Width <= 0)
+ this.rectLed.Width = rectLabel.Width;
+ if (this.rectLed.Height <= 0)
+ this.rectLed.Height = ctrl.LedSize.Height;
+
+ this.DrawLed(Gr, this.rectLed);
+
+ this.DrawLabel(Gr, this.rectLabel);
+ }
+ #endregion
+
+ #region (* Virtual method *)
+ ///
+ /// Draw the background of the control
+ ///
+ ///
+ ///
+ ///
+ public virtual bool DrawBackground(Graphics Gr, RectangleF rc)
+ {
+ if (this.Led == null)
+ return false;
+
+ Color c = this.Led.BackColor;
+ SolidBrush br = new SolidBrush(c);
+ Pen pen = new Pen(c);
+
+ Rectangle _rcTmp = new Rectangle(0, 0, this.Led.Width, this.Led.Height);
+ Gr.DrawRectangle(pen, _rcTmp);
+ Gr.FillRectangle(br, rc);
+
+ br.Dispose();
+ pen.Dispose();
+
+ return true;
+ }
+
+ ///
+ /// Draw the body of the control
+ ///
+ ///
+ ///
+ ///
+ public virtual bool DrawLed(Graphics Gr, RectangleF rc)
+ {
+ if (this.Led == null)
+ return false;
+
+ Color cDarkOff = LBColorManager.StepColor(Color.LightGray, 20);
+ Color cDarkOn = LBColorManager.StepColor(this.Led.LedColor, 60);
+
+ LinearGradientBrush brOff = new LinearGradientBrush(rc,
+ Color.Gray,
+ cDarkOff,
+ 45);
+
+ LinearGradientBrush brOn = new LinearGradientBrush(rc,
+ this.Led.LedColor,
+ cDarkOn,
+ 45);
+ if (this.Led.State == LBLed.LedState.Blink)
+ {
+ if (this.Led.BlinkIsOn == false)
+ {
+ if (this.Led.Style == LBLed.LedStyle.Circular)
+ Gr.FillEllipse(brOff, rc);
+ else if (this.Led.Style == LBLed.LedStyle.Rectangular)
+ Gr.FillRectangle(brOff, rc);
+ }
+ else
+ {
+ if (this.Led.Style == LBLed.LedStyle.Circular)
+ Gr.FillEllipse(brOn, rc);
+ else if (this.Led.Style == LBLed.LedStyle.Rectangular)
+ Gr.FillRectangle(brOn, rc);
+ }
+ }
+ else
+ {
+ if (this.Led.State == LBLed.LedState.Off)
+ {
+ if (this.Led.Style == LBLed.LedStyle.Circular)
+ Gr.FillEllipse(brOff, rc);
+ else if (this.Led.Style == LBLed.LedStyle.Rectangular)
+ Gr.FillRectangle(brOff, rc);
+ }
+ else
+ {
+ if (this.Led.Style == LBLed.LedStyle.Circular)
+ Gr.FillEllipse(brOn, rc);
+ else if (this.Led.Style == LBLed.LedStyle.Rectangular)
+ Gr.FillRectangle(brOn, rc);
+ }
+ }
+
+ brOff.Dispose();
+ brOn.Dispose();
+
+ return true;
+ }
+
+ ///
+ /// Draw the text of the control
+ ///
+ ///
+ ///
+ ///
+ public virtual bool DrawLabel(Graphics Gr, RectangleF rc)
+ {
+ if (this.Led == null)
+ return false;
+
+ if (this.Led.Label == String.Empty)
+ return false;
+
+ SizeF size = Gr.MeasureString(this.Led.Label, this.Led.Font);
+
+ SolidBrush br1 = new SolidBrush(this.Led.ForeColor);
+
+ float hPos = 0;
+ float vPos = 0;
+ switch (this.Led.LabelPosition)
+ {
+ case LBLed.LedLabelPosition.Top:
+ hPos = (float)(rc.Width * 0.5F) - (float)(size.Width * 0.5F);
+ vPos = rc.Bottom - size.Height;
+ break;
+
+ case LBLed.LedLabelPosition.Bottom:
+ hPos = (float)(rc.Width * 0.5F) - (float)(size.Width * 0.5F);
+ break;
+
+ case LBLed.LedLabelPosition.Left:
+ hPos = rc.Width - size.Width;
+ vPos = (float)(rc.Height * 0.5F) - (float)(size.Height * 0.5F);
+ break;
+
+ case LBLed.LedLabelPosition.Right:
+ vPos = (float)(rc.Height * 0.5F) - (float)(size.Height * 0.5F);
+ break;
+ }
+
+ Gr.DrawString(this.Led.Label,
+ this.Led.Font,
+ br1,
+ rc.Left + hPos,
+ rc.Top + vPos);
+
+ return true;
+ }
+ #endregion
+ }
+}
diff --git a/JY.Control/Base/NativeMethods.cs b/JY.Control/Base/NativeMethods.cs
new file mode 100644
index 0000000..bbe027e
--- /dev/null
+++ b/JY.Control/Base/NativeMethods.cs
@@ -0,0 +1,310 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JYControl
+{
+ internal class NativeMethods
+ {
+ ///
+ /// Enum ComboBoxButtonState
+ ///
+ public enum ComboBoxButtonState
+ {
+ ///
+ /// The state system none
+ ///
+ STATE_SYSTEM_NONE,
+ ///
+ /// The state system invisible
+ ///
+ STATE_SYSTEM_INVISIBLE = 32768,
+ ///
+ /// The state system pressed
+ ///
+ STATE_SYSTEM_PRESSED = 8
+ }
+
+ ///
+ /// Struct RECT
+ ///
+ public struct RECT
+ {
+ ///
+ /// The left
+ ///
+ public int Left;
+
+ ///
+ /// The top
+ ///
+ public int Top;
+
+ ///
+ /// The right
+ ///
+ public int Right;
+
+ ///
+ /// The bottom
+ ///
+ public int Bottom;
+
+ ///
+ /// Gets the rect.
+ ///
+ /// The rect.
+ public Rectangle Rect
+ {
+ get
+ {
+ return new Rectangle(this.Left, this.Top, this.Right - this.Left, this.Bottom - this.Top);
+ }
+ }
+
+ ///
+ /// Gets the size.
+ ///
+ /// The size.
+ public Size Size
+ {
+ get
+ {
+ return new Size(this.Right - this.Left, this.Bottom - this.Top);
+ }
+ }
+
+ ///
+ /// Initializes a new instance of the struct.
+ ///
+ /// The left.
+ /// The top.
+ /// The right.
+ /// The bottom.
+ public RECT(int left, int top, int right, int bottom)
+ {
+ this.Left = left;
+ this.Top = top;
+ this.Right = right;
+ this.Bottom = bottom;
+ }
+
+ ///
+ /// Initializes a new instance of the struct.
+ ///
+ /// The rect.
+ public RECT(Rectangle rect)
+ {
+ this.Left = rect.Left;
+ this.Top = rect.Top;
+ this.Right = rect.Right;
+ this.Bottom = rect.Bottom;
+ }
+
+ ///
+ /// Froms the xywh.
+ ///
+ /// The x.
+ /// The y.
+ /// The width.
+ /// The height.
+ /// NativeMethods.RECT.
+ public static NativeMethods.RECT FromXYWH(int x, int y, int width, int height)
+ {
+ return new NativeMethods.RECT(x, y, x + width, y + height);
+ }
+
+ ///
+ /// Froms the rectangle.
+ ///
+ /// The rect.
+ /// NativeMethods.RECT.
+ public static NativeMethods.RECT FromRectangle(Rectangle rect)
+ {
+ return new NativeMethods.RECT(rect.Left, rect.Top, rect.Right, rect.Bottom);
+ }
+ }
+
+ ///
+ /// Struct PAINTSTRUCT
+ ///
+ public struct PAINTSTRUCT
+ {
+ ///
+ /// The HDC
+ ///
+ public IntPtr hdc;
+
+ ///
+ /// The f erase
+ ///
+ public int fErase;
+
+ ///
+ /// The rc paint
+ ///
+ public NativeMethods.RECT rcPaint;
+
+ ///
+ /// The f restore
+ ///
+ public int fRestore;
+
+ ///
+ /// The f inc update
+ ///
+ public int fIncUpdate;
+
+ ///
+ /// The reserved1
+ ///
+ public int Reserved1;
+
+ ///
+ /// The reserved2
+ ///
+ public int Reserved2;
+
+ ///
+ /// The reserved3
+ ///
+ public int Reserved3;
+
+ ///
+ /// The reserved4
+ ///
+ public int Reserved4;
+
+ ///
+ /// The reserved5
+ ///
+ public int Reserved5;
+
+ ///
+ /// The reserved6
+ ///
+ public int Reserved6;
+
+ ///
+ /// The reserved7
+ ///
+ public int Reserved7;
+
+ ///
+ /// The reserved8
+ ///
+ public int Reserved8;
+ }
+
+ ///
+ /// Struct ComboBoxInfo
+ ///
+ public struct ComboBoxInfo
+ {
+ ///
+ /// The cb size
+ ///
+ public int cbSize;
+
+ ///
+ /// The rc item
+ ///
+ public NativeMethods.RECT rcItem;
+
+ ///
+ /// The rc button
+ ///
+ public NativeMethods.RECT rcButton;
+
+ ///
+ /// The state button
+ ///
+ public NativeMethods.ComboBoxButtonState stateButton;
+
+ ///
+ /// The HWND combo
+ ///
+ public IntPtr hwndCombo;
+
+ ///
+ /// The HWND edit
+ ///
+ public IntPtr hwndEdit;
+
+ ///
+ /// The HWND list
+ ///
+ public IntPtr hwndList;
+ }
+
+ ///
+ /// The wm paint
+ ///
+ public const int WM_PAINT = 15;
+
+ ///
+ /// The wm setredraw
+ ///
+ public const int WM_SETREDRAW = 11;
+
+ ///
+ /// The false
+ ///
+ public static readonly IntPtr FALSE = IntPtr.Zero;
+
+ ///
+ /// The true
+ ///
+ public static readonly IntPtr TRUE = new IntPtr(1);
+
+ ///
+ /// Gets the ComboBox information.
+ ///
+ /// The HWND combo.
+ /// The information.
+ /// true if XXXX, false otherwise.
+ [DllImport("user32.dll")]
+ public static extern bool GetComboBoxInfo(IntPtr hwndCombo, ref NativeMethods.ComboBoxInfo info);
+
+ ///
+ /// Gets the window rect.
+ ///
+ /// The HWND.
+ /// The lp rect.
+ /// System.Int32.
+ [DllImport("user32.dll")]
+ public static extern int GetWindowRect(IntPtr hwnd, ref NativeMethods.RECT lpRect);
+
+ ///
+ /// Begins the paint.
+ ///
+ /// The h WND.
+ /// The ps.
+ /// IntPtr.
+ [DllImport("user32.dll")]
+ public static extern IntPtr BeginPaint(IntPtr hWnd, ref NativeMethods.PAINTSTRUCT ps);
+
+ ///
+ /// Ends the paint.
+ ///
+ /// The h WND.
+ /// The ps.
+ /// true if XXXX, false otherwise.
+ [DllImport("user32.dll")]
+ public static extern bool EndPaint(IntPtr hWnd, ref NativeMethods.PAINTSTRUCT ps);
+
+ ///
+ /// Sends the message.
+ ///
+ /// The h WND.
+ /// The MSG.
+ /// The w parameter.
+ /// The l parameter.
+ [DllImport("user32.dll")]
+ public static extern void SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
+ }
+}
diff --git a/JY.Control/Base/Renderer.cs b/JY.Control/Base/Renderer.cs
new file mode 100644
index 0000000..7f473ec
--- /dev/null
+++ b/JY.Control/Base/Renderer.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JYControl
+{
+ ///
+ /// Renderer interface for all
+ /// LBSoft.IndustrialCtrls renderer
+ ///
+ public interface ILBRenderer : IDisposable
+ {
+ object Control
+ {
+ set;
+ get;
+ }
+ bool Update();
+ void Draw(Graphics Gr);
+ }
+}
diff --git a/JY.Control/Blower.cs b/JY.Control/Blower.cs
new file mode 100644
index 0000000..fef35e5
--- /dev/null
+++ b/JY.Control/Blower.cs
@@ -0,0 +1,402 @@
+
+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 JYControl
+{
+ ///
+ /// Class UCBlower.
+ /// Implements the
+ ///
+ ///
+ public class Blower : UserControl
+ {
+ ///
+ /// The entrance direction
+ ///
+ private BlowerEntranceDirection entranceDirection = BlowerEntranceDirection.None;
+
+ ///
+ /// Gets or sets the entrance direction.
+ ///
+ /// The entrance direction.
+ [Description("入口方向"), Category("自定义")]
+ public BlowerEntranceDirection EntranceDirection
+ {
+ get { return entranceDirection; }
+ set
+ {
+ entranceDirection = value;
+ Refresh();
+ }
+ }
+
+ ///
+ /// The exit direction
+ ///
+ private BlowerExitDirection exitDirection = BlowerExitDirection.Right;
+
+ ///
+ /// Gets or sets the exit direction.
+ ///
+ /// The exit direction.
+ [Description("出口方向"), Category("自定义")]
+ public BlowerExitDirection ExitDirection
+ {
+ get { return exitDirection; }
+ set
+ {
+ exitDirection = value;
+ Refresh();
+ }
+ }
+
+ ///
+ /// The blower color
+ ///
+ private Color blowerColor = Color.FromArgb(255, 77, 59);
+
+ ///
+ /// Gets or sets the color of the blower.
+ ///
+ /// The color of the blower.
+ [Description("风机颜色"), Category("自定义")]
+ public Color BlowerColor
+ {
+ get { return blowerColor; }
+ set
+ {
+ blowerColor = value;
+ Refresh();
+ }
+ }
+
+ ///
+ /// The fan color
+ ///
+ private Color fanColor = Color.FromArgb(3, 169, 243);
+
+ ///
+ /// Gets or sets the color of the fan.
+ ///
+ /// The color of the fan.
+ [Description("风叶颜色"), Category("自定义")]
+ public Color FanColor
+ {
+ get { return fanColor; }
+ set
+ {
+ fanColor = value;
+ Refresh();
+ }
+ }
+ TurnAround turnAround = JYControl.TurnAround.None;
+ [Description("风叶旋转方向,None表示不旋转"), Category("自定义")]
+ public TurnAround TurnAround
+ {
+ get { return turnAround; }
+ set
+ {
+ turnAround = value;
+ if (value == JYControl.TurnAround.None)
+ {
+ timer1.Enabled = false;
+ jiaodu = 0;
+ Refresh();
+ }
+ else
+ timer1.Enabled = true;
+ }
+ }
+
+ private int turnSpeed = 100;
+ private int jiaodu = 0;
+ private Timer timer1;
+ private IContainer components;
+
+ [Description("风叶旋转速度,100-1000,值越小 速度越快"), Category("自定义")]
+ public int TurnSpeed
+ {
+ get { return turnSpeed; }
+ set
+ {
+ if (value < 0 || value > 1000)
+ return;
+ turnSpeed = value;
+ timer1.Interval = value;
+ }
+ }
+
+ ///
+ /// 是否显示底座
+ ///
+ private bool isDZ = false;
+
+ ///
+ /// 是否显示底座
+ ///
+ /// 是否显示底座
+ [Description("是否显示底座"), Category("自定义")]
+ public bool IsDZ
+ {
+ get { return isDZ; }
+ set
+ {
+ isDZ = value;
+ Refresh();
+ }
+ }
+
+ ///
+ /// The m rect working
+ ///
+ Rectangle m_rectWorking;
+
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public Blower()
+ {
+ InitializeComponent();
+ 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);
+
+ }
+
+ ///
+ /// Handles the SizeChanged event of the UCBlower control.
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ void UCBlower_SizeChanged(object sender, EventArgs e)
+ {
+ int intMin = Math.Min(this.Width, this.Height);
+ m_rectWorking = new Rectangle((this.Width - (intMin / 2 * 2)) / 2, (this.Height - (intMin / 2 * 2)) / 2, (intMin / 2 * 2), (intMin / 2 * 2));
+ }
+
+ ///
+ /// 引发 事件。
+ ///
+ /// 包含事件数据的 。
+ 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;
+ }
+
+ //底座
+ if (isDZ)
+ {
+ 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 + jiaodu;
+ 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));
+ }
+
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.timer1 = new System.Windows.Forms.Timer(this.components);
+ this.SuspendLayout();
+ //
+ // timer1
+ //
+ this.timer1.Tick += new System.EventHandler(this.timer1_Tick);
+ //
+ // UCBlower
+ //
+ this.Name = "Blower";
+ this.ResumeLayout(false);
+
+ }
+
+ private void timer1_Tick(object sender, EventArgs e)
+ {
+ if (turnAround == JYControl.TurnAround.Clockwise)
+ {
+ jiaodu += 15;
+ if (jiaodu == 45)
+ jiaodu = 0;
+ }
+ else if (turnAround == JYControl.TurnAround.Counterclockwise)
+ {
+ jiaodu -= 15;
+ if (jiaodu == -45)
+ jiaodu = 0;
+ }
+
+ Refresh();
+ }
+ }
+ ///
+ /// Enum BlowerEntranceDirection
+ ///
+ public enum BlowerEntranceDirection
+ {
+ ///
+ /// The none
+ ///
+ None,
+ ///
+ /// The left
+ ///
+ Left,
+ ///
+ /// The right
+ ///
+ Right,
+ ///
+ /// Up
+ ///
+ Up
+ }
+
+ ///
+ /// Enum BlowerExitDirection
+ ///
+ public enum BlowerExitDirection
+ {
+ ///
+ /// The none
+ ///
+ None,
+ ///
+ /// The left
+ ///
+ Left,
+ ///
+ /// The right
+ ///
+ Right,
+ ///
+ /// Up
+ ///
+ Up
+ }
+ ///
+ /// 旋转方向
+ ///
+ public enum TurnAround
+ {
+ ///
+ /// 不旋转
+ ///
+ None,
+ ///
+ /// 顺时针
+ ///
+ Clockwise,
+ ///
+ /// 逆时针
+ ///
+ Counterclockwise
+ }
+}
diff --git a/JY.Control/Blower.resx b/JY.Control/Blower.resx
new file mode 100644
index 0000000..1f666f2
--- /dev/null
+++ b/JY.Control/Blower.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/JY.Control/CircleCountValue.Designer.cs b/JY.Control/CircleCountValue.Designer.cs
new file mode 100644
index 0000000..4aac48f
--- /dev/null
+++ b/JY.Control/CircleCountValue.Designer.cs
@@ -0,0 +1,37 @@
+
+namespace JYControl
+{
+ partial class CircleCountValue
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region 组件设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ }
+
+ #endregion
+ }
+}
diff --git a/JY.Control/CircleCountValue.cs b/JY.Control/CircleCountValue.cs
new file mode 100644
index 0000000..f722c61
--- /dev/null
+++ b/JY.Control/CircleCountValue.cs
@@ -0,0 +1,144 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace JYControl
+{
+ public partial class CircleCountValue : Control
+ {
+ //这个写最上面是因为我自己也不懂是啥意思,只知道界面控件重绘容易产生闪烁的问题,这个加了就不会有
+ //解决控件批量更新时带来的闪烁
+ protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x02000000; return cp; } }
+
+ //-------------------颜色
+ private Color bgColor = Color.FromArgb(224, 224, 224); //背景边框颜色
+ private Color sectorColor = Color.FromArgb(109, 179, 63); //扇形颜色
+ [Category("控件属性")]
+ [Description("背景边框颜色")]
+ public Color BgColor
+ {
+ get { return this.bgColor; }
+ set
+ {
+ this.bgColor = value;
+ this.Invalidate();
+ }
+ }
+
+ [Category("控件属性")]
+ [Description("扇形颜色")]
+ public Color SectorColor
+ {
+ get { return this.sectorColor; }
+ set
+ {
+ this.sectorColor = value;
+ this.Invalidate();
+ }
+ }
+
+ private int borderWidth = 2;//边框宽度
+ [Category("控件属性")]
+ [Description("边框宽度")]
+ public int BorderWidth
+ {
+ get { return this.borderWidth; }
+ set
+ {
+ this.borderWidth = value;
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// 圆形进度条实心
+ ///
+ public CircleCountValue()
+ {
+ InitControl();
+ this.SizeChanged += delegate
+ {
+ this.Invalidate(); //重绘控件
+ };
+ }
+
+ int maxValue = 500000; //进度最大值
+ private int countValue = 0;
+ ///
+ /// 进度值
+ ///
+ ///
+ [Category("控件属性")]
+ [Description("进度值,最大值500000")]
+ public int CountValue
+ {
+ get { return this.countValue; }
+ set
+ {
+ if (value > this.maxValue)
+ {
+ return;
+ }
+ this.countValue = value;
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// 初始化控件参数
+ ///
+ private void InitControl()
+ {
+ this.Width = 200;
+ this.Height = 200;
+ }
+
+ //对Control进行绘制
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ DrawShape(e.Graphics); //绘制控件样式
+ }
+
+ ///
+ /// 画图
+ ///
+ /// 画图工具类
+ private void DrawShape(Graphics g)
+ {
+ if (this.Width < borderWidth * 4 || this.Height < borderWidth * 4)
+ {
+ return;
+ }
+ g.SmoothingMode = SmoothingMode.AntiAlias; //消除锯齿,也就是抗锯齿什么鬼东西
+ g.InterpolationMode = InterpolationMode.HighQualityBicubic;
+ g.CompositingQuality = CompositingQuality.HighQuality;
+
+
+ RectangleF bg_rectangle = new RectangleF(0 + borderWidth, 0 + borderWidth, Width - borderWidth * 2, Height - borderWidth * 2); //控件整体坐标
+
+ g.DrawEllipse(new Pen(bgColor, borderWidth), bg_rectangle); //画背景圆
+
+
+
+ Rectangle rl = new Rectangle(0 + borderWidth * 2, 0 + borderWidth * 2, this.Width - borderWidth * 4, this.Height - borderWidth * 4);
+
+ decimal topAngle = (this.countValue * 1.0M / this.maxValue) * 360M;//计算进度条划过的度数
+ g.FillPie(new SolidBrush(sectorColor), rl, 0, (float)topAngle); //填充扇形
+
+ //SizeF proValSize = g.MeasureString(this.progress.ToString() + "%", this.Font);//计算文字的范围
+ SizeF proValSize = g.MeasureString(this.countValue.ToString(), this.Font);//计算文字的范围
+
+ //g.DrawString(this.progress.ToString() + "%", this.Font, new SolidBrush(this.ForeColor),
+ g.DrawString(this.countValue.ToString(), this.Font, new SolidBrush(this.ForeColor),
+ bg_rectangle.X + bg_rectangle.Width / 2 - proValSize.Width / 2, bg_rectangle.Y + bg_rectangle.Height / 2 - proValSize.Height / 2);
+ }
+
+
+ }
+}
+
diff --git a/JY.Control/CircleProgramBar.cs b/JY.Control/CircleProgramBar.cs
new file mode 100644
index 0000000..9a17658
--- /dev/null
+++ b/JY.Control/CircleProgramBar.cs
@@ -0,0 +1,141 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace JYControl
+{
+ public class CircleProgramBar : Control
+ {
+ //这个写最上面是因为我自己也不懂是啥意思,只知道界面控件重绘容易产生闪烁的问题,这个加了就不会有
+ //解决控件批量更新时带来的闪烁
+ protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x02000000; return cp; } }
+
+ //-------------------颜色
+ private Color bgColor = Color.FromArgb(224, 224, 224); //背景边框颜色
+ private Color sectorColor = Color.FromArgb(109, 179, 63); //扇形颜色
+ [Category("控件属性")]
+ [Description("背景边框颜色")]
+ public Color BgColor
+ {
+ get { return this.bgColor; }
+ set
+ {
+ this.bgColor = value;
+ this.Invalidate();
+ }
+ }
+
+ [Category("控件属性")]
+ [Description("扇形颜色")]
+ public Color SectorColor
+ {
+ get { return this.sectorColor; }
+ set
+ {
+ this.sectorColor = value;
+ this.Invalidate();
+ }
+ }
+
+ private int borderWidth = 2;//边框宽度
+ [Category("控件属性")]
+ [Description("边框宽度")]
+ public int BorderWidth {
+ get { return this.borderWidth; }
+ set {
+ this.borderWidth = value;
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// 圆形进度条实心
+ ///
+ public CircleProgramBar()
+ {
+ InitControl();
+ this.SizeChanged += delegate
+ {
+ this.Invalidate(); //重绘控件
+ };
+ }
+
+ int maxValue = 1000; //进度最大值
+ private int progress = 0;
+ ///
+ /// 进度值
+ ///
+ ///
+ [Category("控件属性")]
+ [Description("进度值,最大值1000")]
+ public int Progress
+ {
+ get { return this.progress; }
+ set
+ {
+ if (value > this.maxValue)
+ {
+ return;
+ }
+ this.progress = value;
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// 初始化控件参数
+ ///
+ private void InitControl()
+ {
+ this.Width = 200;
+ this.Height = 200;
+ }
+
+ //对Control进行绘制
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ DrawShape(e.Graphics); //绘制控件样式
+ }
+
+ ///
+ /// 画图
+ ///
+ /// 画图工具类
+ private void DrawShape(Graphics g)
+ {
+ if (this.Width < borderWidth*4 || this.Height < borderWidth*4)
+ {
+ return;
+ }
+ g.SmoothingMode = SmoothingMode.AntiAlias; //消除锯齿,也就是抗锯齿什么鬼东西
+ g.InterpolationMode = InterpolationMode.HighQualityBicubic;
+ g.CompositingQuality = CompositingQuality.HighQuality;
+
+
+ RectangleF bg_rectangle = new RectangleF(0+ borderWidth, 0+ borderWidth, Width- borderWidth*2, Height- borderWidth*2); //控件整体坐标
+
+ g.DrawEllipse(new Pen(bgColor,borderWidth), bg_rectangle); //画背景圆
+
+
+
+ Rectangle rl = new Rectangle(0+ borderWidth*2, 0 + borderWidth*2, this.Width- borderWidth*4, this.Height- borderWidth*4);
+
+ decimal topAngle = (this.progress * 1.0M / this.maxValue) * 360M;//计算进度条划过的度数
+ g.FillPie(new SolidBrush(sectorColor), rl, 0, (float)topAngle); //填充扇形
+
+ //SizeF proValSize = g.MeasureString(this.progress.ToString() + "%", this.Font);//计算文字的范围
+ SizeF proValSize = g.MeasureString(this.progress.ToString(), this.Font);//计算文字的范围
+
+ //g.DrawString(this.progress.ToString() + "%", this.Font, new SolidBrush(this.ForeColor),
+ g.DrawString(this.progress.ToString(), this.Font, new SolidBrush(this.ForeColor),
+ bg_rectangle.X + bg_rectangle.Width / 2 - proValSize.Width / 2, bg_rectangle.Y + bg_rectangle.Height / 2 - proValSize.Height / 2);
+ }
+
+
+ }
+}
diff --git a/JY.Control/IO_Instructions.Designer.cs b/JY.Control/IO_Instructions.Designer.cs
new file mode 100644
index 0000000..92434a0
--- /dev/null
+++ b/JY.Control/IO_Instructions.Designer.cs
@@ -0,0 +1,83 @@
+namespace JYControl
+{
+ partial class IO_Instructions
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region 组件设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ this.ledControl = new JYControl.LedControl();
+ this.LabelX = new System.Windows.Forms.Label();
+ this.SuspendLayout();
+ //
+ // ledControl
+ //
+ this.ledControl.BorderWidth = 5;
+ this.ledControl.CenterColor = System.Drawing.Color.White;
+ this.ledControl.FlashInterval = 500;
+ this.ledControl.GapWidth = 5;
+ this.ledControl.IsBorder = false;
+ this.ledControl.IsFlash = false;
+ this.ledControl.IsHighLight = false;
+ this.ledControl.LampColor = new System.Drawing.Color[] {
+ System.Drawing.Color.Green,
+ System.Drawing.Color.Yellow};
+ this.ledControl.LedColor = System.Drawing.Color.Green;
+ this.ledControl.LedFalseColor = System.Drawing.Color.Red;
+ this.ledControl.LedStatus = true;
+ this.ledControl.LedTrueColor = System.Drawing.Color.Green;
+ this.ledControl.Location = new System.Drawing.Point(0, 0);
+ this.ledControl.Name = "ledControl";
+ this.ledControl.Size = new System.Drawing.Size(16, 16);
+ this.ledControl.TabIndex = 0;
+ //
+ // LabelX
+ //
+ this.LabelX.AutoSize = true;
+ this.LabelX.Location = new System.Drawing.Point(29, 3);
+ this.LabelX.Name = "LabelX";
+ this.LabelX.Size = new System.Drawing.Size(29, 12);
+ this.LabelX.TabIndex = 2;
+ this.LabelX.Text = "描述";
+ //
+ // IO_Instructions
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.LabelX);
+ this.Controls.Add(this.ledControl);
+ this.Name = "IO_Instructions";
+ this.Size = new System.Drawing.Size(72, 18);
+ this.ResumeLayout(false);
+ this.PerformLayout();
+
+ }
+
+ #endregion
+
+ private LedControl ledControl;
+ private System.Windows.Forms.Label LabelX;
+ }
+}
diff --git a/JY.Control/IO_Instructions.cs b/JY.Control/IO_Instructions.cs
new file mode 100644
index 0000000..2487389
--- /dev/null
+++ b/JY.Control/IO_Instructions.cs
@@ -0,0 +1,136 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace JYControl
+{
+ public partial class IO_Instructions : UserControl
+ {
+ public IO_Instructions()
+ {
+ InitializeComponent();
+
+ }
+
+ public int IO_Value;
+ public string mstrCaption = "";
+ public string mstrText = "输入描述";
+ public bool Reversal, GreenOrRed;
+
+
+
+ [Category("jason控件属性")]
+ [Description("是否开启反转")]
+ public bool AAReversal
+ {
+ get
+ {
+ return Reversal;
+ }
+ set
+ {
+ Reversal = value;
+ }
+ }
+
+ [Category("jason控件属性")]
+ [Description("颜色变更绿色或者红色")]
+ public bool AAGreenOrRed
+ {
+ get
+ {
+ return GreenOrRed;
+ }
+ set
+ {
+ GreenOrRed = value;
+ }
+ }
+
+ [Category("jason控件属性")]
+ [Description("控件名称")]
+ public string AAName
+ {
+ get
+ {
+ return mstrCaption;
+ }
+ set
+ {
+ mstrCaption = value;
+ }
+ }
+
+ [Category("jason控件属性")]
+ [Description("控件描述")]
+ public string AAText
+ {
+ get
+ {
+ return mstrText;
+ }
+ set
+ {
+ mstrText = value;
+ LabelX.Text = AAText;
+ }
+ }
+
+ [Category("jason控件属性")]
+ [Description("控件IO值")]
+ public int AAValue
+ {
+ get
+ {
+ return IO_Value;
+ }
+ set
+ {
+ IO_Value = value;
+ if (value == 1)
+ {
+ if (Reversal)
+ {
+ if (GreenOrRed)
+ { ledControl.LedTrueColor = Color.Red; }
+ else
+ { ledControl.LedTrueColor = Color.Green; }
+ }
+ else
+ {
+ if (GreenOrRed)
+ { ledControl.LedTrueColor = Color.Transparent; }
+ else
+ { ledControl.LedTrueColor = Color.Lime; }
+ }
+
+
+ }
+ else
+ {
+ if (Reversal)
+ {
+ if (GreenOrRed)
+ { ledControl.LedTrueColor = Color.Lime; }
+ else
+ { ledControl.LedTrueColor = Color.Red; }
+ }
+ else
+ {
+ if (GreenOrRed)
+ { ledControl.LedTrueColor = Color.Red; }
+ else
+ { ledControl.LedTrueColor = Color.Transparent; }
+ }
+ }
+
+ }
+ }
+ }
+}
diff --git a/JY.Control/IO_Instructions.resx b/JY.Control/IO_Instructions.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/JY.Control/IO_Instructions.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/JY.Control/Image/list_add.png b/JY.Control/Image/list_add.png
new file mode 100644
index 0000000..24d6534
Binary files /dev/null and b/JY.Control/Image/list_add.png differ
diff --git a/JY.Control/Image/list_subtract.png b/JY.Control/Image/list_subtract.png
new file mode 100644
index 0000000..ad178da
Binary files /dev/null and b/JY.Control/Image/list_subtract.png differ
diff --git a/JY.Control/Image/tips.png b/JY.Control/Image/tips.png
new file mode 100644
index 0000000..bb8b8c5
Binary files /dev/null and b/JY.Control/Image/tips.png differ
diff --git a/JY.Control/Image/下载.png b/JY.Control/Image/下载.png
new file mode 100644
index 0000000..4b1f906
Binary files /dev/null and b/JY.Control/Image/下载.png differ
diff --git a/JY.Control/Image/增加.png b/JY.Control/Image/增加.png
new file mode 100644
index 0000000..1dcc8b4
Binary files /dev/null and b/JY.Control/Image/增加.png differ
diff --git a/JY.Control/Image/查询.png b/JY.Control/Image/查询.png
new file mode 100644
index 0000000..2a5d785
Binary files /dev/null and b/JY.Control/Image/查询.png differ
diff --git a/JY.Control/Image/设置.png b/JY.Control/Image/设置.png
new file mode 100644
index 0000000..cbe57d1
Binary files /dev/null and b/JY.Control/Image/设置.png differ
diff --git a/JY.Control/Image/运行中.png b/JY.Control/Image/运行中.png
new file mode 100644
index 0000000..84b49fa
Binary files /dev/null and b/JY.Control/Image/运行中.png differ
diff --git a/JY.Control/JY.Control.csproj b/JY.Control/JY.Control.csproj
new file mode 100644
index 0000000..cfee48d
--- /dev/null
+++ b/JY.Control/JY.Control.csproj
@@ -0,0 +1,167 @@
+
+
+
+
+ Debug
+ AnyCPU
+ {01A2AA2C-9B80-41AA-9F47-3CB67E60AF24}
+ Library
+ Properties
+ JYControl
+ JY.Control
+ v4.8
+ 512
+ true
+
+
+
+ true
+ full
+ false
+ ..\..\..\..\JY.Inspection\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ UserControl
+
+
+ LBIndustrialCtrlBase.cs
+
+
+
+
+
+ UserControl
+
+
+ Component
+
+
+ Component
+
+
+ CircleCountValue.cs
+
+
+ UserControl
+
+
+ IO_Instructions.cs
+
+
+ UserControl
+
+
+ LBButton.cs
+
+
+ UserControl
+
+
+ LBLed.cs
+
+
+ UserControl
+
+
+ LedControl.cs
+
+
+ UserControl
+
+
+ LogManagerControl.cs
+
+
+
+ True
+ True
+ Resources.resx
+
+
+ Component
+
+
+ PulseButton.cs
+
+
+ Component
+
+
+ Component
+
+
+ RoundButton.cs
+
+
+ Component
+
+
+ Component
+
+
+ TreeViewEx.cs
+
+
+
+
+ Blower.cs
+
+
+ IO_Instructions.cs
+
+
+ LBLed.cs
+
+
+ LedControl.cs
+
+
+ LogManagerControl.cs
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+
+
+ TreeViewEx.cs
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/JY.Control/JY.Control.csproj.user b/JY.Control/JY.Control.csproj.user
new file mode 100644
index 0000000..0b24643
--- /dev/null
+++ b/JY.Control/JY.Control.csproj.user
@@ -0,0 +1,6 @@
+
+
+
+ ProjectFiles
+
+
\ No newline at end of file
diff --git a/JY.Control/LBButton.Designer.cs b/JY.Control/LBButton.Designer.cs
new file mode 100644
index 0000000..74f35c4
--- /dev/null
+++ b/JY.Control/LBButton.Designer.cs
@@ -0,0 +1,37 @@
+namespace JYControl
+{
+ partial class LBButton
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region 组件设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ }
+
+ #endregion
+ }
+}
diff --git a/JY.Control/LBButton.cs b/JY.Control/LBButton.cs
new file mode 100644
index 0000000..e6de017
--- /dev/null
+++ b/JY.Control/LBButton.cs
@@ -0,0 +1,294 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace JYControl
+{
+ ///
+ /// Description of LBButton.
+ ///
+ public partial class LBButton : LBIndustrialCtrlBase
+ {
+ #region (* Enumeratives *)
+ ///
+ /// Button styles
+ ///
+ public enum ButtonStyle
+ {
+ Circular = 0,
+ Rectangular = 1,
+ Elliptical = 2,
+ }
+
+ ///
+ /// Button states
+ ///
+ public enum ButtonState
+ {
+ Normal = 0,
+ Pressed,
+ }
+ #endregion
+
+ #region (* Properties variables *)
+ private ButtonStyle buttonStyle = ButtonStyle.Circular;
+ private ButtonState buttonState = ButtonState.Normal;
+ private Color buttonColor = Color.Red;
+ private string label = String.Empty;
+ private bool enableRepeatState = false;
+ private int startRepeatInterval = 500;
+ private int repeatInterval = 100;
+ #endregion
+
+ #region (* Variables *)
+ private Timer tmrRepeat = null;
+ #endregion
+
+ #region (* Constructor *)
+ public LBButton()
+ {
+ // Initialization
+ InitializeComponent();
+
+ // Properties initialization
+ this.buttonColor = Color.Red;
+ this.Size = new Size(50, 50);
+
+ // Timer
+ this.tmrRepeat = new Timer();
+ this.tmrRepeat.Enabled = false;
+ this.tmrRepeat.Interval = this.startRepeatInterval;
+ this.tmrRepeat.Tick += this.Timer_Tick;
+ }
+ #endregion
+
+ #region (* Overrided methods *)
+ protected override ILBRenderer CreateDefaultRenderer()
+ {
+ return new LBButtonRenderer();
+ }
+ #endregion
+
+ #region (* Properties *)
+ [
+ Category("Button"),
+ Description("Style of the button")
+ ]
+ public ButtonStyle Style
+ {
+ set
+ {
+ this.buttonStyle = value;
+ this.CalculateDimensions();
+ }
+ get { return this.buttonStyle; }
+ }
+
+ [
+ Category("Button"),
+ Description("Color of the body of the button")
+ ]
+ public Color ButtonColor
+ {
+ get { return buttonColor; }
+ set
+ {
+ buttonColor = value;
+ Invalidate();
+ }
+ }
+
+ [
+ Category("Button"),
+ Description("Label of the button"),
+ ]
+ public string Label
+ {
+ get { return this.label; }
+ set
+ {
+ this.label = value;
+ Invalidate();
+ }
+ }
+
+ [
+ Category("Button"),
+ Description("State of the button")
+ ]
+ public ButtonState State
+ {
+ set
+ {
+ this.buttonState = value;
+ this.Invalidate();
+ }
+ get { return this.buttonState; }
+ }
+
+ [
+ Category("Button"),
+ Description("Enable/Disable the repetition of the event if the button is pressed")
+ ]
+ public bool RepeatState
+ {
+ set { this.enableRepeatState = value; }
+ get { return this.enableRepeatState; }
+ }
+
+ [
+ Category("Button"),
+ Description("Interval to wait in ms for start the repetition")
+ ]
+ public int StartRepeatInterval
+ {
+ set { this.startRepeatInterval = value; }
+ get { return this.startRepeatInterval; }
+ }
+
+ [
+ Category("Button"),
+ Description("Interva in ms for the repetition")
+ ]
+ public int RepeatInterval
+ {
+ set { this.repeatInterval = value; }
+ get { return this.repeatInterval; }
+ }
+ #endregion
+
+ #region (* Events delegates *)
+ ///
+ /// Timer event
+ ///
+ ///
+ ///
+ void Timer_Tick(object sender, EventArgs e)
+ {
+ this.tmrRepeat.Enabled = false;
+
+ // Update the interval
+ if (tmrRepeat.Interval == this.startRepeatInterval)
+ this.tmrRepeat.Interval = this.repeatInterval;
+
+ // Call the delagate
+ LBButtonEventArgs ev = new LBButtonEventArgs();
+ ev.State = this.State;
+ this.OnButtonRepeatState(ev);
+
+ this.tmrRepeat.Enabled = true;
+ }
+
+ ///
+ /// Mouse down event
+ ///
+ ///
+ ///
+ void OnMouseDown(object sender, MouseEventArgs e)
+ {
+ // Change the state
+ this.State = ButtonState.Pressed;
+ this.Invalidate();
+
+ // Call the delagates
+ LBButtonEventArgs ev = new LBButtonEventArgs();
+ ev.State = this.State;
+ this.OnButtonChangeState(ev);
+
+ // Enable the repeat timer
+ if (this.RepeatState != false)
+ {
+ this.tmrRepeat.Interval = this.StartRepeatInterval;
+ this.tmrRepeat.Enabled = true;
+ }
+ }
+
+ ///
+ /// Mouse up event
+ ///
+ ///
+ ///
+ void OnMuoseUp(object sender, MouseEventArgs e)
+ {
+ // Change the state
+ this.State = ButtonState.Normal;
+ this.Invalidate();
+
+ // Call the delagates
+ LBButtonEventArgs ev = new LBButtonEventArgs();
+ ev.State = this.State;
+ this.OnButtonChangeState(ev);
+
+ // Disable the timer
+ this.tmrRepeat.Enabled = false;
+ }
+ #endregion
+
+ #region (* Fire events *)
+ ///
+ /// Event for the state changed
+ ///
+ public event ButtonChangeState ButtonChangeState;
+
+ ///
+ /// Method for call the delagetes
+ ///
+ ///
+ protected virtual void OnButtonChangeState(LBButtonEventArgs e)
+ {
+ if (this.ButtonChangeState != null)
+ this.ButtonChangeState(this, e);
+ }
+
+ ///
+ /// Event for the repetition of state
+ ///
+ public event ButtonRepeatState ButtonRepeatState;
+
+ ///
+ /// Method for call the delagetes
+ ///
+ ///
+ protected virtual void OnButtonRepeatState(LBButtonEventArgs e)
+ {
+ if (this.ButtonRepeatState != null)
+ this.ButtonRepeatState(this, e);
+ }
+ #endregion
+ }
+
+ #region (* Classes for event and event delagates args *)
+
+ #region (* Event args class *)
+ ///
+ /// Class for events delegates
+ ///
+ public class LBButtonEventArgs : EventArgs
+ {
+ private LBButton.ButtonState state;
+
+ public LBButtonEventArgs()
+ {
+ }
+
+ public LBButton.ButtonState State
+ {
+ get { return this.state; }
+ set { this.state = value; }
+ }
+ }
+ #endregion
+
+ #region (* Delegates *)
+ public delegate void ButtonChangeState(object sender, LBButtonEventArgs e);
+ public delegate void ButtonRepeatState(object sender, LBButtonEventArgs e);
+ #endregion
+
+ #endregion
+}
diff --git a/JY.Control/LBLed.Designer.cs b/JY.Control/LBLed.Designer.cs
new file mode 100644
index 0000000..9b0ff6c
--- /dev/null
+++ b/JY.Control/LBLed.Designer.cs
@@ -0,0 +1,53 @@
+namespace JYControl
+{
+ partial class LBLed
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region 组件设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ this.components = new System.ComponentModel.Container();
+ this.tmrBlink = new System.Windows.Forms.Timer(this.components);
+ this.SuspendLayout();
+ //
+ // tmrBlink
+ //
+ this.tmrBlink.Interval = 500;
+ this.tmrBlink.Tick += new System.EventHandler(this.OnBlink);
+ //
+ // LBLed
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Name = "LBLed";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.Timer tmrBlink;
+ }
+}
diff --git a/JY.Control/LBLed.cs b/JY.Control/LBLed.cs
new file mode 100644
index 0000000..88b6fd1
--- /dev/null
+++ b/JY.Control/LBLed.cs
@@ -0,0 +1,214 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace JYControl
+{
+ ///
+ /// Class for the Led control.
+ ///
+ public partial class LBLed : LBIndustrialCtrlBase
+ {
+ #region (* Enumeratives *)
+ public enum LedState
+ {
+ Off = 0,
+ On,
+ Blink,
+ }
+
+ public enum LedLabelPosition
+ {
+ Left = 0,
+ Top,
+ Right,
+ Bottom,
+ }
+
+ public enum LedStyle
+ {
+ Circular = 0,
+ Rectangular,
+ }
+
+ #endregion
+
+ #region (* Properties variables *)
+ private Color ledColor;
+ private LedState state;
+ private LedStyle style;
+ private LedLabelPosition labelPosition;
+ private String label = "Led";
+ private SizeF ledSize;
+ private int blinkInterval = 500;
+ #endregion
+
+ #region (* Class variables *)
+ //private Timer tmrBlink;
+ private bool blinkIsOn = false;
+ #endregion
+
+ #region (* Constructor *)
+ public LBLed()
+ {
+ InitializeComponent();
+
+ this.Size = new Size(20, 20);
+ this.ledColor = Color.Red;
+ this.state = LBLed.LedState.Off;
+ this.style = LBLed.LedStyle.Circular;
+ this.blinkIsOn = false;
+ this.ledSize = new SizeF(10F, 10F);
+ this.labelPosition = LedLabelPosition.Top;
+ }
+ #endregion
+
+ #region (* Properties *)
+ [
+ Category("Led"),
+ Description("改变LED灯样式")
+ ]
+ public LedStyle Style
+ {
+ get { return style; }
+ set
+ {
+ style = value;
+ this.CalculateDimensions();
+ }
+ }
+ [
+ Category("Led"),
+ Description("改变LED灯颜色")
+ ]
+ public Color LedColor
+ {
+ get { return ledColor; }
+ set
+ {
+ ledColor = value;
+ Invalidate();
+ }
+ }
+
+
+ [
+ Category("Led"),
+ Description("改变LED灯状态")
+ ]
+ public LedState State
+ {
+ get { return state; }
+ set
+ {
+ state = value;
+ if (state == LedState.Blink)
+ {
+ this.blinkIsOn = true;
+ this.tmrBlink.Interval = this.BlinkInterval;
+ this.tmrBlink.Start();
+ }
+ else
+ {
+ this.blinkIsOn = true;
+ this.tmrBlink.Stop();
+ }
+
+ Invalidate();
+ }
+ }
+
+
+ [
+ Category("Led"),
+ Description("Size of the led")
+ ]
+ public SizeF LedSize
+ {
+ get { return this.ledSize; }
+ set
+ {
+ this.ledSize = value;
+ this.CalculateDimensions();
+ Invalidate();
+ }
+ }
+
+
+ [
+ Category("Led"),
+ Description("Label of the led")
+ ]
+ public String Label
+ {
+ get { return this.label; }
+ set
+ {
+ this.label = value;
+ Invalidate();
+ }
+ }
+
+
+ [
+ Category("Led"),
+ Description("Position of the label of the led")
+ ]
+ public LedLabelPosition LabelPosition
+ {
+ get { return this.labelPosition; }
+ set
+ {
+ this.labelPosition = value;
+ this.CalculateDimensions();
+ Invalidate();
+ }
+ }
+
+
+ [
+ Category("Led"),
+ Description("Interval for the blink state of the led")
+ ]
+ public int BlinkInterval
+ {
+ get { return this.blinkInterval; }
+ set { this.blinkInterval = value; }
+ }
+
+ [Browsable(false)]
+ public bool BlinkIsOn
+ {
+ get { return this.blinkIsOn; }
+ }
+ #endregion
+
+ #region (* Events delegates *)
+ void OnBlink(object sender, EventArgs e)
+ {
+ if (this.State == LedState.Blink)
+ {
+ if (this.blinkIsOn == false)
+ this.blinkIsOn = true;
+ else
+ this.blinkIsOn = false;
+
+ this.Invalidate();
+ }
+ }
+ #endregion
+
+ #region (* Overrided methods *)
+ protected override ILBRenderer CreateDefaultRenderer()
+ {
+ return new LBLedRenderer();
+ }
+ #endregion
+ }
+}
diff --git a/JY.Control/LBLed.resx b/JY.Control/LBLed.resx
new file mode 100644
index 0000000..5b87100
--- /dev/null
+++ b/JY.Control/LBLed.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ 17, 17
+
+
\ No newline at end of file
diff --git a/JY.Control/LedControl.Designer.cs b/JY.Control/LedControl.Designer.cs
new file mode 100644
index 0000000..48d61d8
--- /dev/null
+++ b/JY.Control/LedControl.Designer.cs
@@ -0,0 +1,44 @@
+namespace JYControl
+{
+ partial class LedControl
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region 组件设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ this.SuspendLayout();
+ //
+ // LedControl
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Name = "LedControl";
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+ }
+}
diff --git a/JY.Control/LedControl.cs b/JY.Control/LedControl.cs
new file mode 100644
index 0000000..9afcfeb
--- /dev/null
+++ b/JY.Control/LedControl.cs
@@ -0,0 +1,426 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace JYControl
+{
+ public partial class LedControl : UserControl
+ {
+ public LedControl()
+ {
+ InitializeComponent();
+ #region 【1】设置双缓冲等属性
+ 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);
+ timer.Enabled = true;
+ timer.Tick += Timer_Tick;
+ #endregion
+ }
+
+ private void Timer_Tick(object sender, EventArgs e)
+ {
+ intColorIndex++;
+
+ if (intColorIndex >= lampColor.Length)
+ {
+ intColorIndex = 0;
+ }
+ this.Invalidate();
+ }
+
+ #region 【2】定义三个字段
+
+ private Graphics g;
+
+ private Pen p;
+
+ private SolidBrush sb;
+
+ Timer timer = new Timer();
+
+ private int intColorIndex = 0;
+
+ #endregion
+
+ #region 【3】添加一个设置Graphics的方法
+ private void SetGraphics(Graphics g)
+ {
+ //设置画布的属性
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
+ g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
+ g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.ClearTypeGridFit;
+ g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
+ }
+
+ #endregion
+
+
+ #region 【4】根据实际控件分析的结果,创建属性
+
+ private Color ledTrueColor = Color.Green;
+
+ [Category("jason控件属性")]
+
+ [Description("TRUE的时候LED指示灯颜色")]
+
+ public Color LedTrueColor
+ {
+ get { return ledTrueColor; }
+ set
+ {
+ ledTrueColor = value;
+ this.Invalidate();
+ }
+ }
+ #endregion
+
+ private Color ledFalseColor = Color.Red;
+
+ [Category("jason控件属性")]
+
+ [Description("False的时候LED指示灯颜色")]
+
+ public Color LedFalseColor
+
+ {
+ get { return ledFalseColor; }
+ set
+
+ {
+ ledFalseColor = value;
+ this.Invalidate();
+ }
+
+ }
+
+ private bool ledStatus = true;
+ [Category("jason控件属性")]
+ [Description("当前的状态")]
+ public bool LedStatus
+ {
+ get { return ledStatus; }
+
+ set
+
+ {
+ ledStatus = value;
+ this.Invalidate();
+ }
+ }
+
+ private Color ledColor = Color.Green;
+ [Category("jason控件属性")]
+ [Description("LED指示灯演示")]
+ public Color LedColor
+ {
+ get { return ledColor; }
+ set
+
+ {
+ ledColor = value;
+ this.Invalidate();
+ }
+ }
+ private bool isBorder = true;
+
+ [Category("jason控件属性")]
+
+ [Description("是否有边框")]
+
+ public bool IsBorder
+
+ {
+
+ get { return isBorder; }
+
+ set
+
+ {
+
+ isBorder = value;
+
+ this.Invalidate();
+
+ }
+
+ }
+
+ private int borderWidth = 5;
+
+ [Category("jason控件属性")]
+
+ [Description("圆环的宽度")]
+
+ public int BorderWidth
+
+ {
+
+ get { return borderWidth; }
+
+ set
+
+ {
+
+ borderWidth = value;
+
+ this.Invalidate();
+
+ }
+
+ }
+
+ private int gapWidth = 5;
+
+ [Category("jason控件属性")]
+
+ [Description("间隙的宽度")]
+
+ public int GapWidth
+
+ {
+
+ get { return gapWidth; }
+
+ set
+
+ {
+
+ gapWidth = value;
+
+ this.Invalidate();
+
+ }
+
+ }
+
+ private bool isHighLight = true;
+
+ [Category("jason控件属性")]
+
+ [Description("是否高亮")]
+
+ public bool IsHighLight
+
+ {
+
+ get { return isHighLight; }
+
+ set
+
+ {
+
+ isHighLight = value;
+
+ this.Invalidate();
+
+ }
+
+ }
+
+ private Color centerColor = Color.White;
+
+ [Category("jason控件属性")]
+
+ [Description("渐变中心的颜色")]
+
+ public Color CenterColor
+
+ {
+
+ get { return centerColor; }
+
+ set
+
+ {
+
+ centerColor = value;
+
+ this.Invalidate();
+
+ }
+
+ }
+
+ private bool isFlash = true;
+
+ [Category("jason控件属性")]
+
+ [Description("是否闪烁")]
+
+ public bool IsFlash
+
+ {
+
+ get { return isFlash; }
+
+ set
+
+ {
+
+ isFlash = value;
+
+ this.Invalidate();
+
+ }
+
+ }
+
+ private int flashInterval = 500;
+
+ [Category("jason控件属性")]
+
+ [Description("闪烁的频率")]
+
+ public int FlashInterval
+
+ {
+
+ get { return flashInterval; }
+
+ set
+
+ {
+
+ flashInterval = value;
+
+ timer.Interval = flashInterval;//timer的时间间隔要放在这里
+
+ this.Invalidate();
+
+ }
+
+ }
+
+ private Color[] lampColor = new Color[] { };
+
+ [Category("jason控件属性")]
+
+ [Description("闪烁灯的几种颜色,当需要闪烁时,至少需要2个及以上颜色,不需要闪烁则至少需要1个颜色")]
+
+ public Color[] LampColor
+
+ {
+
+ get { return lampColor; }
+
+ set
+
+ {
+
+ if (value == null || value.Length <= 0)
+
+ return;
+
+ lampColor = value;
+
+ this.Invalidate();
+
+ }
+
+ }
+
+ #region 【5】创建重绘的事件
+
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ base.OnPaint(e);
+
+ g = e.Graphics;//获取画布
+
+ SetGraphics(g);//设置画布
+
+ #region 1,画一个圆
+
+ int LEDWidth = Math.Min(this.Width, this.Height);
+
+ Color color = ledStatus ? ledTrueColor : ledFalseColor;
+
+ if (isFlash)
+
+ {
+
+ lampColor = new Color[] { color, Color.Yellow };
+
+ color = lampColor[intColorIndex];
+
+ }
+
+ sb = new SolidBrush(color);
+
+ RectangleF rec = new RectangleF(1, 1, LEDWidth - 2, LEDWidth - 2);//创建矩形
+
+ g.FillEllipse(sb, rec);//画圆
+
+ #endregion
+
+ #region 2,在圆里面画一个圆环
+
+ //如果有边框,那就画一个圆环
+
+ if (isBorder)//参数这里用字段或属性都可以,如果用属性,程序要都走一些判断的代码
+
+ {
+
+ p = new Pen(this.BackColor, borderWidth);//使用背景色
+
+ //p = new Pen(Color.Red, borderWidth);
+
+ float x = 1 + gapWidth + borderWidth * 0.5f;
+
+ rec = new RectangleF(x, x, LEDWidth - 2 * x, LEDWidth - 2 * x);
+
+ g.DrawEllipse(p, rec);//画圆环
+
+ }
+
+ #endregion
+
+ #region 3,渐变色绘制,是否高亮
+
+ if (isHighLight)
+
+ {
+
+ GraphicsPath gp = new GraphicsPath();
+
+ float x = isBorder ? 1 + gapWidth + borderWidth : 1;//使用三元运算来判断,优化代码
+
+ rec = new RectangleF(x, x, LEDWidth - 2 * x, LEDWidth - 2 * x);
+
+ gp.AddEllipse(rec);//把矩形添加到路径
+
+ //渐变色画刷,高亮
+
+ PathGradientBrush pgb = new PathGradientBrush(gp);//把路径传入
+
+ Color[] surroundColor = new Color[] { color };
+
+ pgb.CenterColor = this.centerColor;
+
+ //设置有多少组颜色来渐变
+
+ pgb.SurroundColors = surroundColor;
+
+ g.FillPath(pgb, gp);
+
+ }
+
+ #endregion
+
+ }
+
+ #endregion
+
+ }
+}
diff --git a/JY.Control/LedControl.resx b/JY.Control/LedControl.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/JY.Control/LedControl.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/JY.Control/LogManagerControl.Designer.cs b/JY.Control/LogManagerControl.Designer.cs
new file mode 100644
index 0000000..1d8c960
--- /dev/null
+++ b/JY.Control/LogManagerControl.Designer.cs
@@ -0,0 +1,78 @@
+namespace JYControl
+{
+ partial class LogManagerControl
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region 组件设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ this.listView1 = new System.Windows.Forms.ListView();
+ this.time = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.message = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
+ this.SuspendLayout();
+ //
+ // listView1
+ //
+ this.listView1.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
+ this.time,
+ this.message});
+ this.listView1.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.listView1.Font = new System.Drawing.Font("微软雅黑", 12F);
+ this.listView1.HideSelection = false;
+ this.listView1.Location = new System.Drawing.Point(0, 0);
+ this.listView1.Name = "listView1";
+ this.listView1.Size = new System.Drawing.Size(1103, 235);
+ this.listView1.TabIndex = 0;
+ this.listView1.UseCompatibleStateImageBehavior = false;
+ this.listView1.View = System.Windows.Forms.View.Details;
+ //
+ // time
+ //
+ this.time.Text = "时间";
+ this.time.Width = 120;
+ //
+ // message
+ //
+ this.message.Text = "信息";
+ this.message.Width = 2000;
+ //
+ // LogManagerControl
+ //
+ this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
+ this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
+ this.Controls.Add(this.listView1);
+ this.Name = "LogManagerControl";
+ this.Size = new System.Drawing.Size(1103, 235);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+
+ private System.Windows.Forms.ListView listView1;
+ private System.Windows.Forms.ColumnHeader time;
+ private System.Windows.Forms.ColumnHeader message;
+ }
+}
diff --git a/JY.Control/LogManagerControl.cs b/JY.Control/LogManagerControl.cs
new file mode 100644
index 0000000..d3593b8
--- /dev/null
+++ b/JY.Control/LogManagerControl.cs
@@ -0,0 +1,182 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+using System.IO;
+
+namespace JYControl
+{
+ public enum Logtype//枚举类型
+ {
+ Message,
+ Warning,
+ Error
+ }
+
+ public enum LogAddtype//枚举类型
+ {
+ MES,
+ local,
+ }
+
+ public partial class LogManagerControl : UserControl
+ {
+ static bool _newErrorInfo = false;
+ static int _ErrorCount = 0;
+ public LogManagerControl()
+ {
+ InitializeComponent();
+ this.DoubleBuffered = true;
+ this.SetStyle(ControlStyles.OptimizedDoubleBuffer | ControlStyles.UserPaint |
+ ControlStyles.AllPaintingInWmPaint,
+ true);
+ this.UpdateStyles();
+ }
+
+ private static readonly string logMesPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs", "MESLogs");
+ private static readonly string loglocalPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Logs", "localLogs");
+ private static LogManagerControl _manager = new LogManagerControl();
+
+ delegate void DoAddMessage(string message, LogAddtype logAddtype, Logtype logType = Logtype.Message);
+ //delegate void DoDelete();
+ public static void AddLog(string strLog, LogAddtype logAddtype, Logtype logType = Logtype.Message)
+ {
+ if (_manager.listView1.InvokeRequired)
+ {
+ DoAddMessage dam = new DoAddMessage(AddLog);
+ _manager.listView1.Invoke(dam, strLog,logAddtype, logType);
+ }
+ else
+ {
+ string strDate = DateTime.Now.ToString("HH:mm:ss:ff");
+ ListViewItem item = new ListViewItem();
+ switch (logType)
+ {
+ case Logtype.Message:
+ if (strLog.Contains("接收到客户端连接") || strLog.Contains("TCP服务器启动监听成功"))
+ {
+ item.ForeColor = Color.White;
+ item.BackColor = Color.SeaGreen;
+ }
+ break;
+ case Logtype.Warning:
+ item.BackColor = Color.Yellow;
+ strLog = "警告:" + strLog;
+ break;
+ case Logtype.Error:
+ item.BackColor = Color.Red;
+ item.ForeColor = Color.White;
+ strLog = "错误:" + strLog;
+ _newErrorInfo = true;
+ _ErrorCount++;
+
+ break;
+ default:
+ break;
+ }
+ item.Text = strDate;
+ item.SubItems.Add(strLog);
+ _manager.listView1.BeginUpdate();
+
+
+ _manager.listView1.Items.Insert(0, item);//添加在第一行
+ //_manager.listView1.Items.Add(item);//添加在最后一行
+ int ff = _manager.listView1.Items.Count - 1;
+ if (_manager.listView1.Items.Count > 150)
+ {
+ _manager.listView1.Items.RemoveAt(ff);
+ }
+ //_manager.listView1.Items[_manager.listView1.Items.Count - 1].EnsureVisible();
+
+ _manager.listView1.EndUpdate();
+
+ switch (logAddtype)
+ {
+ case LogAddtype.MES:
+ if (!Directory.Exists(logMesPath))
+ {
+ Directory.CreateDirectory(logMesPath);
+ }
+ using (StreamWriter sw = new StreamWriter(logMesPath+DateTime.Now.ToString("yyyyMMdd") + ".txt", true))
+ {
+ sw.WriteLine(strDate + " " + logType.ToString() + " " + strLog);
+ }
+ break;
+ case LogAddtype.local:
+ if (!Directory.Exists(loglocalPath))
+ {
+ Directory.CreateDirectory(loglocalPath);
+ }
+ using (StreamWriter sw = new StreamWriter(loglocalPath+DateTime.Now.ToString("yyyyMMdd") + ".txt", true))
+ {
+ sw.WriteLine(strDate + " " + logType.ToString() + " " + strLog);
+ }
+ break;
+ default:
+ break;
+ }
+ //添加日志到log文件中
+ }
+ }
+
+ public static void ClearLog()
+ {
+ //if (_manager.listView1.InvokeRequired)
+ //{
+ // DoDelete dam = new DoDelete(ClearLog);
+ // _manager.listView1.Invoke(dam);
+ //}
+ //else
+ //{
+ //if (_manager.listView1.Items.Count > 200)
+ //{
+ // _manager.listView1.Items.RemoveAt(item);
+ //}
+ _manager.listView1.Items.Clear();
+ //}
+ }
+
+ ///
+ /// 双缓冲ListView ,解决闪烁
+ ///
+ public class DoubleBufferListView : System.Windows.Forms.ListView
+ {
+ public DoubleBufferListView()
+ {
+ SetStyle(ControlStyles.DoubleBuffer |
+ ControlStyles.OptimizedDoubleBuffer |
+ ControlStyles.AllPaintingInWmPaint, true);
+ UpdateStyles();
+ }
+ }
+
+ protected override void WndProc(ref Message m)
+ {
+ if (m.Msg == 0x0014) // 禁掉清除背景消息
+ return;
+ base.WndProc(ref m);
+ }
+
+ public static bool HasNewErrorInfo
+ {
+ get { return _newErrorInfo; }
+ set { _newErrorInfo = value; }
+ }
+ public static int ErrorInfoCount
+ {
+ get { return _ErrorCount; }
+ set { _ErrorCount = 0; }
+ }
+
+ public static LogManagerControl Manager
+ {
+ get { return LogManagerControl._manager; }
+ set { LogManagerControl._manager = value; }
+ }
+ }
+}
diff --git a/JY.Control/LogManagerControl.resx b/JY.Control/LogManagerControl.resx
new file mode 100644
index 0000000..1af7de1
--- /dev/null
+++ b/JY.Control/LogManagerControl.resx
@@ -0,0 +1,120 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/JY.Control/Properties/AssemblyInfo.cs b/JY.Control/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..12e2396
--- /dev/null
+++ b/JY.Control/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// 有关程序集的一般信息由以下
+// 控制。更改这些特性值可修改
+// 与程序集关联的信息。
+[assembly: AssemblyTitle("JY.Control")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("JY.Control")]
+[assembly: AssemblyCopyright("Copyright © 2022")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// 将 ComVisible 设置为 false 会使此程序集中的类型
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
+//请将此类型的 ComVisible 特性设置为 true。
+[assembly: ComVisible(false)]
+
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
+[assembly: Guid("01a2aa2c-9b80-41aa-9f47-3cb67e60af24")]
+
+// 程序集的版本信息由下列四个值组成:
+//
+// 主版本
+// 次版本
+// 生成号
+// 修订号
+//
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
+//通过使用 "*",如下所示:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/JY.Control/Properties/Resources.Designer.cs b/JY.Control/Properties/Resources.Designer.cs
new file mode 100644
index 0000000..44a8341
--- /dev/null
+++ b/JY.Control/Properties/Resources.Designer.cs
@@ -0,0 +1,143 @@
+//------------------------------------------------------------------------------
+//
+// 此代码由工具生成。
+// 运行时版本:4.0.30319.42000
+//
+// 对此文件的更改可能会导致不正确的行为,并且如果
+// 重新生成代码,这些更改将会丢失。
+//
+//------------------------------------------------------------------------------
+
+namespace JYControl.Properties {
+ using System;
+
+
+ ///
+ /// 一个强类型的资源类,用于查找本地化的字符串等。
+ ///
+ // 此类是由 StronglyTypedResourceBuilder
+ // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
+ // 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
+ // (以 /str 作为命令选项),或重新生成 VS 项目。
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources() {
+ }
+
+ ///
+ /// 返回此类使用的缓存的 ResourceManager 实例。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager {
+ get {
+ if (object.ReferenceEquals(resourceMan, null)) {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("JYControl.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// 重写当前线程的 CurrentUICulture 属性,对
+ /// 使用此强类型资源类的所有资源查找执行重写。
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture {
+ get {
+ return resourceCulture;
+ }
+ set {
+ resourceCulture = value;
+ }
+ }
+
+ ///
+ /// 查找 System.Drawing.Bitmap 类型的本地化资源。
+ ///
+ internal static System.Drawing.Bitmap list_add {
+ get {
+ object obj = ResourceManager.GetObject("list_add", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// 查找 System.Drawing.Bitmap 类型的本地化资源。
+ ///
+ internal static System.Drawing.Bitmap list_subtract {
+ get {
+ object obj = ResourceManager.GetObject("list_subtract", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// 查找 System.Drawing.Bitmap 类型的本地化资源。
+ ///
+ internal static System.Drawing.Bitmap tips {
+ get {
+ object obj = ResourceManager.GetObject("tips", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// 查找 System.Drawing.Bitmap 类型的本地化资源。
+ ///
+ internal static System.Drawing.Bitmap 下载 {
+ get {
+ object obj = ResourceManager.GetObject("下载", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// 查找 System.Drawing.Bitmap 类型的本地化资源。
+ ///
+ internal static System.Drawing.Bitmap 增加 {
+ get {
+ object obj = ResourceManager.GetObject("增加", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// 查找 System.Drawing.Bitmap 类型的本地化资源。
+ ///
+ internal static System.Drawing.Bitmap 查询 {
+ get {
+ object obj = ResourceManager.GetObject("查询", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// 查找 System.Drawing.Bitmap 类型的本地化资源。
+ ///
+ internal static System.Drawing.Bitmap 设置 {
+ get {
+ object obj = ResourceManager.GetObject("设置", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+
+ ///
+ /// 查找 System.Drawing.Bitmap 类型的本地化资源。
+ ///
+ internal static System.Drawing.Bitmap 运行中 {
+ get {
+ object obj = ResourceManager.GetObject("运行中", resourceCulture);
+ return ((System.Drawing.Bitmap)(obj));
+ }
+ }
+ }
+}
diff --git a/JY.Control/Properties/Resources.resx b/JY.Control/Properties/Resources.resx
new file mode 100644
index 0000000..9948e75
--- /dev/null
+++ b/JY.Control/Properties/Resources.resx
@@ -0,0 +1,145 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+
+ ..\Image\list_add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Image\list_subtract.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Image\tips.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Image\下载.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Image\增加.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Image\查询.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Image\设置.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
+ ..\Image\运行中.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
+
+
\ No newline at end of file
diff --git a/JY.Control/PulseButton.Designer.cs b/JY.Control/PulseButton.Designer.cs
new file mode 100644
index 0000000..5063f66
--- /dev/null
+++ b/JY.Control/PulseButton.Designer.cs
@@ -0,0 +1,36 @@
+namespace JYControl
+{
+ partial class PulseButton
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region 组件设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ }
+
+ #endregion
+ }
+}
diff --git a/JY.Control/PulseButton.cs b/JY.Control/PulseButton.cs
new file mode 100644
index 0000000..f870d12
--- /dev/null
+++ b/JY.Control/PulseButton.cs
@@ -0,0 +1,554 @@
+using System;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Drawing.Text;
+using System.Windows.Forms;
+
+namespace JYControl
+{
+ public partial class PulseButton : Button
+ {
+ #region -- Members --
+ private readonly Timer pulseTimer;
+ private RectangleF[] pulses;
+ private RectangleF centerRect;
+ private Color[] pulseColors;
+ private int pulseWidth;
+ private bool mouseOver;
+ private bool pressed;
+ private float pulseSpeed;
+
+ public enum Shape
+ {
+ Round,
+ Rectangle
+ }
+ #endregion
+
+ #region -- Properties --
+
+ ///
+ /// Gets or sets the top button color.
+ ///
+ /// The top button color.
+ [Browsable(true), DefaultValue(typeof(Color), "CornflowerBlue")]
+ [Category("Appearance")]
+ public Color ButtonColorTop { get; set; }
+
+ ///
+ /// Gets or sets the bottom button color.
+ ///
+ /// The bottom button color.
+ [Browsable(true), DefaultValue(typeof(Color), "DodgerBlue")]
+ [Category("Appearance")]
+ public Color ButtonColorBottom { get; set; }
+
+ ///
+ /// Gets or sets the color of the pulse.
+ ///
+ /// The color of the pulse.
+ [Browsable(true), DefaultValue(typeof(Color), "Black")]
+ [Category("Appearance")]
+ public Color PulseColor { get; set; }
+
+ ///
+ /// Gets or sets the type of the shape.
+ ///
+ /// The type of the shape.
+ [Browsable(true), DefaultValue(typeof(Shape), "Round")]
+ [Category("Appearance")]
+ public Shape ShapeType { get; set; }
+
+ ///
+ /// Gets or sets the corner radius.
+ ///
+ /// The corner radius.
+ [Browsable(true), DefaultValue(10)]
+ [Category("Appearance")]
+ public int CornerRadius { get; set; }
+
+ ///
+ /// Gets or sets the color of the focus.
+ ///
+ /// The color of the focus.
+ [Browsable(true), DefaultValue(typeof(Color), "Orange")]
+ [Category("Appearance")]
+ public Color FocusColor { get; set; }
+
+ ///
+ /// Gets or sets the foreground color of the control.
+ ///
+ ///
+ ///
+ /// The foreground of the control. The default is the value of the property.
+ ///
+ ///
+ ///
+ ///
+ [Browsable(true), DefaultValue(typeof(Color), "White")]
+ [Category("Appearance")]
+ public new Color ForeColor
+ {
+ get { return base.ForeColor; }
+ set { base.ForeColor = value; }
+ }
+
+ ///
+ /// Gets or sets the number of pulses.
+ ///
+ /// The number of pulses.
+ [Browsable(true), DefaultValue(3)]
+ [Category("Appearance")]
+ public int NumberOfPulses
+ {
+ get { return pulses.Length; }
+ set
+ {
+ if (value <= 0) return;
+ pulses = new RectangleF[value];
+ pulseColors = new Color[value];
+ ArrangePulses();
+ }
+ }
+
+ ///
+ /// Gets or sets the width of the pulse.
+ ///
+ /// The width of the pulse.
+ [Browsable(true), DefaultValue(10)]
+ [Category("Appearance")]
+ public int PulseWidth
+ {
+ get { return pulseWidth; }
+ set { pulseWidth = value; ArrangePulses(); }
+ }
+
+ ///
+ /// Gets or sets the wave speed.
+ ///
+ /// The speed of the pulses.
+ [Browsable(true), DefaultValue(typeof(float), "0.3f")]
+ [Category("Appearance")]
+ public float PulseSpeed
+ {
+ get { return pulseSpeed; }
+ set
+ {
+ if (value <= 0) return;
+ pulseSpeed = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the interval.
+ ///
+ /// The interval.
+ [Browsable(false), DefaultValue(50)]
+ public int Interval
+ {
+ get { return pulseTimer.Interval; }
+ set { pulseTimer.Interval = value; }
+ }
+
+ #endregion
+
+ #region -- Constructor --
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public PulseButton()
+ {
+ // Control styles
+ SetStyle(ControlStyles.SupportsTransparentBackColor, true);
+ SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
+ SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle(ControlStyles.ResizeRedraw, true);
+ SetStyle(ControlStyles.UserPaint, true);
+ InitializeComponent();
+ // Layout & initialization
+ SuspendLayout();
+ pulseWidth = 10;
+ PulseSpeed = .3f;
+ ButtonColorTop = Color.CornflowerBlue;
+ ButtonColorBottom = Color.DodgerBlue;
+ FocusColor = Color.Orange;
+ PulseColor = Color.Black;
+ ShapeType = Shape.Round;
+ CornerRadius = 10;
+ Image = null;
+ base.TextAlign = ContentAlignment.MiddleCenter;
+ Size = new Size(40, 40);
+ // Timer
+ pulseTimer = new Timer { Interval = 50 };
+ pulseTimer.Tick += PulseTimerTick;
+ pulses = new RectangleF[3];
+ pulseColors = new Color[3];
+ ArrangePulses();
+ pulseTimer.Enabled = true;
+ ResumeLayout(true);
+ }
+
+ #endregion
+
+ #region -- EventHandlers --
+
+ ///
+ /// Handles the pulse timer tick.
+ ///
+ /// The sender.
+ /// The instance containing the event data.
+ private void PulseTimerTick(object sender, EventArgs e)
+ {
+ pulseTimer.Enabled = false;
+ InflatePulses();
+ Invalidate();
+ pulseTimer.Enabled = true;
+ }
+
+ #endregion
+
+ #region -- Protected overrides --
+
+ #region - Mouse -
+
+ ///
+ /// Raises the event.
+ ///
+ /// A that contains the event data.
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ base.OnMouseUp(e);
+ if (e.Button != MouseButtons.Left) return;
+ pressed = false;
+ }
+
+ ///
+ /// Raises the event.
+ ///
+ /// A that contains the event data.
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+ if (e.Button != MouseButtons.Left) return;
+ pressed = true;
+ }
+
+ ///
+ /// Raises the event.
+ ///
+ /// A that contains the event data.
+ protected override void OnMouseMove(MouseEventArgs mevent)
+ {
+ base.OnMouseMove(mevent);
+ mouseOver = centerRect.Contains(mevent.Location);
+ }
+
+ ///
+ /// Raises the event.
+ ///
+ /// A that contains the event data.
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ base.OnMouseLeave(e);
+ mouseOver = false;
+ pressed = false;
+ }
+
+ #endregion
+
+ ///
+ /// Raises the event.
+ ///
+ /// An that contains the event data.
+ protected override void OnEnabledChanged(EventArgs e)
+ {
+ base.OnEnabledChanged(e);
+ pulseTimer.Enabled = Enabled;
+ }
+
+ ///
+ /// Raises the event.
+ ///
+ /// An that contains the event data.
+ protected override void OnResize(EventArgs e)
+ {
+ base.OnResize(e);
+ if (pulses == null || pulses.Length == 0) return;
+ ArrangePulses();
+ }
+
+ ///
+ /// Raises the event.
+ ///
+ /// A that contains the event data.
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ //base.OnPaint(e);
+ base.OnPaintBackground(e);
+ // Set Graphics interpolation and smoothing
+ Graphics g = e.Graphics;
+ g.InterpolationMode = InterpolationMode.HighQualityBicubic;
+ g.SmoothingMode = SmoothingMode.AntiAlias;
+
+ // Draw pulses
+ DrawPulses(g);
+
+ if (centerRect.IsEmpty) return;
+ // Draw center
+ DrawCenter(g);
+
+ // Draw border
+ DrawBorder(g);
+ // Image
+ if (Image != null)
+ g.DrawImage(Image, centerRect);
+
+ // Draw highlight
+ if (mouseOver)
+ DrawHighLight(g);
+ // Reflex
+ if (!pressed) DrawReflex(g);
+ // Text
+ DrawText(g);
+ }
+
+ #endregion
+
+ #region -- Protected virtual methods --
+
+ ///
+ /// Draws the border.
+ ///
+ /// The graphics object
+ protected virtual void DrawBorder(Graphics g)
+ {
+ using (var pen = new Pen(!Focused ? Color.FromArgb(60, Color.Black) : FocusColor, 2))
+ PaintShape(g, pen, centerRect);
+ }
+
+ ///
+ /// Draws the center.
+ ///
+ /// The graphics object
+ protected virtual void DrawCenter(Graphics g)
+ {
+ if (Enabled)
+ {
+ using (var lgb = new LinearGradientBrush(centerRect, ButtonColorTop, ButtonColorBottom,
+ LinearGradientMode.Vertical))
+ {
+ PaintShape(g, lgb, centerRect);
+ }
+ }
+ else
+ {
+ using (var lgb = new SolidBrush(Color.Gray))
+ PaintShape(g, lgb, centerRect);
+
+ }
+ }
+
+ ///
+ /// Draws the pulses.
+ ///
+ /// The graphics object
+ protected virtual void DrawPulses(Graphics g)
+ {
+ if (!Enabled) return;
+ for (var i = 0; i < pulses.Length; i++)
+ {
+ using (var sb = new SolidBrush(pulseColors[i]))
+ {
+ PaintShape(g, sb, pulses[i]);
+ }
+ }
+ }
+
+ ///
+ /// Draws the text.
+ ///
+ /// The graphics object
+ protected virtual void DrawText(Graphics g)
+ {
+ var format = new StringFormat(StringFormat.GenericDefault) { Trimming = StringTrimming.EllipsisCharacter };
+ format.FormatFlags |= StringFormatFlags.MeasureTrailingSpaces;
+ format.FormatFlags ^= StringFormatFlags.LineLimit;
+ format.HotkeyPrefix = HotkeyPrefix.Show;
+ SizeF size = g.MeasureString(Text, Font, new SizeF(centerRect.Width, centerRect.Height), format);
+ RectangleF textRect = GetAlignPlacement(TextAlign, centerRect, size);
+ using (var sb = new SolidBrush(ForeColor))
+ g.DrawString(Text, Font, sb, textRect, format);
+ }
+
+ ///
+ /// Draws the reflex.
+ ///
+ /// The graphics object
+ protected virtual void DrawReflex(Graphics g)
+ {
+ using (var path = new GraphicsPath())
+ {
+ RectangleF rect = centerRect;
+ rect.Height = rect.Height / 2;
+ if (ShapeType == Shape.Round)
+ {
+ path.AddArc(centerRect, -180, 180);
+ RectangleF reflexRectangle = rect;
+ reflexRectangle.Offset(0, rect.Height);
+ reflexRectangle.Height /= 6;
+ path.AddArc(reflexRectangle, 0, 180);
+ path.CloseFigure();
+ }
+ else
+ {
+ rect.Height += rect.Height / 6;
+ path.AddRectangle(rect);
+ }
+ RectangleF area = path.GetBounds();
+ using (var lgb = new LinearGradientBrush(area, Color.FromArgb(30, Color.White),
+ Color.FromArgb(60, Color.White), -90))
+ {
+ g.FillPath(lgb, path);
+ }
+ }
+ }
+
+ ///
+ /// Draws the high light.
+ ///
+ /// The graphics object
+ protected virtual void DrawHighLight(Graphics g)
+ {
+ RectangleF highlightRect = centerRect;
+ highlightRect.Inflate(-2, -2);
+ using (var pen = new Pen(Color.FromArgb(60, Color.White), 4))
+ {
+ if (ShapeType == Shape.Round)
+ g.DrawEllipse(pen, highlightRect);
+ else
+ g.DrawPath(pen, GetRoundRect(g, highlightRect, CornerRadius));
+ }
+ }
+
+ ///
+ /// Paints the shape.
+ ///
+ /// The graphics object
+ /// The pen
+ /// The rectangle.
+ protected virtual void PaintShape(Graphics g, Pen p, RectangleF rectangle)
+ {
+ if (ShapeType == Shape.Round)
+ g.DrawEllipse(p, rectangle);
+ else
+ using (var path = GetRoundRect(g, rectangle, CornerRadius))
+ g.DrawPath(p, path);
+ }
+
+ ///
+ /// Paints the shape.
+ ///
+ /// The graphics object
+ /// The brush
+ /// The rectangle.
+ protected virtual void PaintShape(Graphics g, Brush b, RectangleF rectangle)
+ {
+ if (ShapeType == Shape.Round)
+ g.FillEllipse(b, rectangle);
+ else
+ using (var path = GetRoundRect(g, rectangle, CornerRadius))
+ g.FillPath(b, path);
+ }
+
+ #endregion
+
+ #region -- Public static methods --
+
+ ///
+ /// Gets a path of a rectangle with round corners.
+ ///
+ /// The graphics object
+ /// The rectangle
+ /// The corner radius
+ ///
+ public static GraphicsPath GetRoundRect(Graphics g, RectangleF rect, float radius)
+ {
+ var gp = new GraphicsPath();
+ var diameter = radius * 2;
+ gp.AddArc(rect.X + rect.Width - diameter, rect.Y, diameter, diameter, 270, 90);
+ gp.AddArc(rect.X + rect.Width - diameter, rect.Y + rect.Height - diameter, diameter, diameter, 0, 90);
+ gp.AddArc(rect.X, rect.Y + rect.Height - diameter, diameter, diameter, 90, 90);
+ gp.AddArc(rect.X, rect.Y, diameter, diameter, 180, 90);
+ gp.CloseFigure();
+ return gp;
+ }
+
+ ///
+ /// Gets the placement.
+ ///
+ /// The alignment of the element
+ /// A retangle
+ /// The element to be placed
+ ///
+ public static RectangleF GetAlignPlacement(ContentAlignment align, RectangleF rect, SizeF element)
+ {
+ // Left & Top (default)
+ float lft = rect.Left;
+ float top = rect.Y;
+ // Right
+ if ((align & (ContentAlignment.BottomRight | ContentAlignment.MiddleRight | ContentAlignment.TopRight)) != 0)
+ lft = rect.Right - element.Width;
+ // Center
+ else if ((align & (ContentAlignment.BottomCenter | ContentAlignment.MiddleCenter | ContentAlignment.TopCenter)) != 0)
+ lft = (rect.Width / 2) - (element.Width / 2) + rect.Left;
+ // Bottom
+ if ((align & (ContentAlignment.BottomCenter | ContentAlignment.BottomLeft | ContentAlignment.BottomRight)) != 0)
+ top = rect.Bottom - element.Height;
+ // Middle
+ else if ((align & (ContentAlignment.MiddleCenter | ContentAlignment.MiddleLeft | ContentAlignment.MiddleRight)) != 0)
+ top = (rect.Height / 2) - (element.Height / 2) + rect.Y;
+
+ return new RectangleF(lft, top, element.Width, element.Height);
+ }
+
+ #endregion
+
+ #region -- Private methods --
+
+ ///
+ /// Arranges the pulses.
+ ///
+ private void ArrangePulses()
+ {
+ centerRect = new RectangleF(pulseWidth, pulseWidth, Width - 2 * pulseWidth, Height - 2 * pulseWidth);
+ for (var i = 1; i <= pulses.Length; i++)
+ {
+ pulses[i - 1] = new RectangleF(
+ pulseWidth * i / (float)pulses.Length,
+ pulseWidth * i / (float)pulses.Length,
+ Width - 2 * pulseWidth * i / pulses.Length,
+ Height - 2 * pulseWidth * i / pulses.Length
+ );
+ pulseColors[i - 1] = Color.FromArgb((int)(Math.Min(pulses[i - 1].X * 255 / pulseWidth, 255)), Color.White);
+ }
+ }
+
+ ///
+ /// Inflates the pulses.
+ ///
+ private void InflatePulses()
+ {
+ for (var i = 0; i < pulses.Length; i++)
+ {
+ pulses[i].Inflate(PulseSpeed, PulseSpeed);
+ if (pulses[i].Width > Width || pulses[i].Height > Height || pulses[i].X < 0 || pulses[i].Y < 0)
+ pulses[i] = new RectangleF(pulseWidth, pulseWidth, Width - 2 * pulseWidth, Height - 2 * pulseWidth);
+ pulseColors[i] = Color.FromArgb((int)(Math.Min(pulses[i].X * 255 / pulseWidth, 255)), PulseColor);
+ }
+ }
+
+ #endregion
+
+ }
+}
diff --git a/JY.Control/RingProgramBar.cs b/JY.Control/RingProgramBar.cs
new file mode 100644
index 0000000..dde63df
--- /dev/null
+++ b/JY.Control/RingProgramBar.cs
@@ -0,0 +1,141 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+
+namespace JYControl
+{
+ public class RingProgramBar : Control
+ {
+ //这个写最上面是因为我自己也不懂是啥意思,只知道界面控件高速的重绘容易产生闪烁的问题,这个加了就不会有
+ protected override CreateParams CreateParams { get { CreateParams cp = base.CreateParams; cp.ExStyle |= 0x02000000; return cp; } }
+
+ //-------------------颜色
+ private Color bgColor = Color.FromArgb(224, 224, 224); //背景边框颜色
+ private Color sectorColor = Color.FromArgb(109, 179, 63); //扇形颜色
+
+ [Category("控件属性")]
+ [Description("背景边框颜色")]
+ public Color BgColor
+ {
+ get { return this.bgColor; }
+ set
+ {
+ this.bgColor = value;
+ this.Invalidate();
+ }
+ }
+
+ [Category("控件属性")]
+ [Description("扇形颜色")]
+ public Color SectorColor
+ {
+ get { return this.sectorColor; }
+ set
+ {
+ this.sectorColor = value;
+ this.Invalidate();
+ }
+ }
+
+ private int borderWidth = 2; //边框宽度
+
+ [Category("控件属性")]
+ [Description("边框宽度")]
+ public int BorderWidth
+ {
+ get { return this.borderWidth; }
+ set
+ {
+ this.borderWidth = value;
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// 圆形进度条实心
+ ///
+ public RingProgramBar()
+ {
+ InitControl();
+ this.SizeChanged += delegate
+ {
+ this.Invalidate(); //重绘控件
+ };
+ }
+
+ int maxValue = 100; //进度最大值
+ private int progress = 0;
+ ///
+ /// 进度值
+ ///
+ [Category("控件属性")]
+ [Description("进度值,最大值100")]
+ public int Progress
+ {
+ get { return this.progress; }
+ set
+ {
+ if (value > this.maxValue)
+ {
+ return;
+ }
+ this.progress = value;
+ this.Invalidate();
+ }
+ }
+
+ ///
+ /// 初始化控件参数
+ ///
+ private void InitControl()
+ {
+ this.Width = 200;
+ this.Height = 200;
+ }
+
+ //对Control进行绘制
+ protected override void OnPaint(PaintEventArgs e)
+ {
+ DrawShape(e.Graphics); //绘制控件样式
+ }
+
+ ///
+ /// 画图
+ ///
+ /// 画图工具类
+ private void DrawShape(Graphics g)
+ {
+ if (this.Width < borderWidth*4 || this.Height < borderWidth*4)
+ {
+ return;
+ }
+ g.SmoothingMode = SmoothingMode.AntiAlias; //消除锯齿,也就是抗锯齿什么鬼东西
+ g.InterpolationMode = InterpolationMode.HighQualityBicubic;
+ g.CompositingQuality = CompositingQuality.HighQuality;
+
+ RectangleF bg_rectangle = new RectangleF(0+ borderWidth, 0+ borderWidth, Width - borderWidth * 2, Height - borderWidth * 2); //控件整体坐标
+
+ g.DrawEllipse(new Pen(bgColor, borderWidth), bg_rectangle); //画背景圆
+
+ Rectangle rl = new Rectangle(0 + borderWidth , 0 + borderWidth , this.Width - borderWidth * 2, this.Height - borderWidth * 2);
+
+ decimal topAngle = (this.progress * 1.0M / this.maxValue) * 360M;//计算进度条划过的度数
+ g.DrawArc(new Pen(sectorColor,borderWidth), rl, 0, (float)topAngle); //填充环形
+
+
+ SizeF fs = g.MeasureString(this.progress.ToString() + "%", this.Font);//计算文字的范围
+ //SizeF fs = g.MeasureString(this.progress.ToString(), this.Font);//计算文字的范围
+
+ g.DrawString(this.progress.ToString() + "%", this.Font, new SolidBrush(this.ForeColor),
+ //g.DrawString(this.progress.ToString(), this.Font, new SolidBrush(this.ForeColor),
+ bg_rectangle.X + bg_rectangle.Width / 2 - fs.Width / 2, bg_rectangle.Y + bg_rectangle.Height / 2 - fs.Height / 2);
+ }
+
+
+ }
+}
diff --git a/JY.Control/RoundButton.Designer.cs b/JY.Control/RoundButton.Designer.cs
new file mode 100644
index 0000000..aadb0ce
--- /dev/null
+++ b/JY.Control/RoundButton.Designer.cs
@@ -0,0 +1,36 @@
+namespace JYControl
+{
+ partial class RoundButton
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region 组件设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ }
+
+ #endregion
+ }
+}
diff --git a/JY.Control/RoundButton.cs b/JY.Control/RoundButton.cs
new file mode 100644
index 0000000..87aff66
--- /dev/null
+++ b/JY.Control/RoundButton.cs
@@ -0,0 +1,383 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Data;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace JYControl
+{
+ //public partial class RoundButton : Button
+ //{
+ // public RoundButton()
+ // {
+ // InitializeComponent();
+ // }
+
+ // protected override void OnPaint(PaintEventArgs pe)
+ // {
+ // base.OnPaint(pe);
+ // }
+ //}
+ public partial class RoundButton : Button
+ {
+ #region --成员变量--
+
+ RectangleF rect = new RectangleF();//控件矩形
+ bool mouseEnter;//鼠标是否进入控件区域的标志
+ bool buttonPressed;//按钮是否按下
+ bool buttonClicked;//按钮是否被点击
+ #endregion
+
+ #region --属性--
+
+ #region 形状
+
+ ///
+ /// 设置或获取圆形按钮的圆的边距离方框边的距离
+ ///
+ [Browsable(true), DefaultValue(2)]
+ [Category("Appearance")]
+ public int DistanceToBorder { get; set; }
+
+ #endregion
+
+ #region 填充色
+
+ ///
+ /// 获取或设置按钮主体颜色
+ ///
+ /// The color of the focus.
+ [Browsable(true), DefaultValue(typeof(Color), "DodgerBlue"), Description("按钮主体渐变起始颜色")]
+ [Category("Appearance")]
+ public Color ButtonCenterColorEnd { get; set; }
+
+ ///
+ /// 获取或设置按钮主体颜色
+ ///
+ [Browsable(true), DefaultValue(typeof(Color), "CornflowerBlue"), Description("按钮主体渐变终点颜色")]
+ [Category("Appearance")]
+ public Color ButtonCenterColorStart { get; set; }
+
+ ///
+ /// 获取或设置按钮主体颜色渐变方向
+ ///
+ [Browsable(true), DefaultValue(90), Description("按钮主体颜色渐变方向,X轴顺时针开始")]
+ [Category("Appearance")]
+ public int GradientAngle { get; set; }
+
+ ///
+ /// 是否显示中间标志
+ ///
+ [Browsable(true), DefaultValue(typeof(bool), "true"), Description("是否显示中间标志")]
+ [Category("Appearance")]
+ public bool IsShowIcon { get; set; }
+
+ ///
+ /// 按钮中间标志填充色
+ ///
+ [Browsable(true), DefaultValue(typeof(Color), "Black"), Description("按钮中间标志填充色")]
+ [Category("Appearance")]
+ public Color IconColor { get; set; }
+
+
+ #endregion
+
+ #region 边框
+
+ ///
+ /// 获取或设置边框大小
+ ///
+ [Browsable(true), DefaultValue(4), Description("按钮边框大小")]
+ [Category("Appearance")]
+ public int BorderWidth { get; set; }
+
+ ///
+ /// 获取或设置按钮边框颜色
+ ///
+ /// The color of the focus.
+ [Browsable(true), DefaultValue(typeof(Color), "Black"), Description("按钮边框颜色")]
+ [Category("Appearance")]
+ public Color BorderColor { get; set; }
+
+ ///
+ /// 获取或设置边框透明度
+ ///
+ [Browsable(true), DefaultValue(200), Description("设置边框透明度:0-255")]
+ [Category("Appearance")]
+ public int BorderTransparent { get; set; }
+
+ ///
+ /// 获取或设置按钮获取焦点后边框颜色
+ ///
+ /// The color of the focus.
+ [Browsable(true), DefaultValue(typeof(Color), "Orange"), Description("按钮获得焦点后的边框颜色")]
+ [Category("Appearance")]
+ public Color FocusBorderColor { get; set; }
+
+ #endregion
+
+ #endregion
+
+ #region --构造函数--
+ ///
+ /// 构造函数
+ ///
+ public RoundButton()
+ {
+ // 控件风格
+ SetStyle(ControlStyles.SupportsTransparentBackColor, true);
+ SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
+ SetStyle(ControlStyles.AllPaintingInWmPaint, true);
+ SetStyle(ControlStyles.ResizeRedraw, true);
+ SetStyle(ControlStyles.UserPaint, true);
+ //初始值设定
+ this.Height = this.Width = 80;
+
+ DistanceToBorder = 4;
+ ButtonCenterColorStart = Color.CornflowerBlue;
+ ButtonCenterColorEnd = Color.DodgerBlue;
+ BorderColor = Color.Black;
+ FocusBorderColor = Color.Orange;
+ IconColor = Color.Black;
+ BorderWidth = 4;
+ BorderTransparent = 200;
+ GradientAngle = 90;
+
+ mouseEnter = false;
+ buttonPressed = false;
+ buttonClicked = false;
+ IsShowIcon = true;
+
+ InitializeComponent();
+ }
+ #endregion
+
+ #region --重写部分事件--
+
+ #region OnPaint事件
+
+ ///
+ /// 控件绘制
+ ///
+ ///
+ protected override void OnPaint(PaintEventArgs pevent)
+ {
+ //base.OnPaint(pevent);
+ base.OnPaintBackground(pevent);
+
+ Graphics g = pevent.Graphics;
+ g.InterpolationMode = InterpolationMode.HighQualityBicubic;
+ g.SmoothingMode = SmoothingMode.AntiAlias;//抗锯齿
+
+ myResize();//调整圆形区域
+
+ var brush = new LinearGradientBrush(rect, ButtonCenterColorStart, ButtonCenterColorEnd, GradientAngle);
+
+ PaintShape(g, brush, rect);//绘制按钮中心区域
+
+ DrawBorder(g);//绘制边框
+
+ DrawStateIcon(g);//绘制按钮功能标志
+
+ if (mouseEnter)
+ {
+ DrawHighLight(g);//绘制高亮区域
+ DrawStateIcon(g);//绘制按钮功能标志
+ }
+ }
+
+ #endregion
+
+ #region 鼠标
+
+ ///
+ /// 鼠标点击事件
+ ///
+ ///
+ protected override void OnMouseClick(MouseEventArgs e)
+ {
+ base.OnMouseClick(e);
+ buttonClicked = !buttonClicked;
+ }
+ ///
+ /// Raises the event.
+ ///
+ /// A that contains the event data.
+ protected override void OnMouseUp(MouseEventArgs e)
+ {
+ base.OnMouseUp(e);
+ if (e.Button != MouseButtons.Left) return;
+ buttonPressed = false;
+ base.Invalidate();
+ }
+
+ ///
+ /// Raises the event.
+ ///
+ /// A that contains the event data.
+ protected override void OnMouseDown(MouseEventArgs e)
+ {
+ base.OnMouseDown(e);
+ if (e.Button != MouseButtons.Left) return;
+ buttonPressed = true;
+ }
+
+ ///
+ /// 鼠标进入按钮
+ ///
+ ///
+ protected override void OnMouseEnter(EventArgs e)
+ {
+ base.OnMouseEnter(e);
+ mouseEnter = true;
+ }
+
+ ///
+ /// 鼠标离开控件
+ ///
+ ///
+ protected override void OnMouseLeave(EventArgs e)
+ {
+ base.OnMouseLeave(e);
+ mouseEnter = false;
+ }
+
+ #endregion
+ #endregion
+
+ #region --自定义函数--
+
+ ///
+ /// 绘制中心区域标志
+ ///
+ ///
+ private void DrawStateIcon(Graphics g)
+ {
+ if (IsShowIcon)
+ {
+ if (buttonClicked)
+ {
+ GraphicsPath startIconPath = new GraphicsPath();
+ int W = base.Width / 3;
+ Point p1 = new Point(W, W);
+ Point p2 = new Point(2 * W, W);
+ Point p3 = new Point(2 * W, 2 * W);
+ Point p4 = new Point(W, 2 * W);
+ Point[] pts = { p1, p2, p3, p4 };
+ startIconPath.AddLines(pts);
+ Brush brush = new SolidBrush(IconColor);
+ g.FillPath(brush, startIconPath);
+ }
+ else
+ {
+ GraphicsPath stopIconPath = new GraphicsPath();
+ int W = base.Width / 4;
+ Point p1 = new Point(3 * W / 2, W);
+ Point p2 = new Point(3 * W / 2, 3 * W);
+ Point p3 = new Point(3 * W, 2 * W);
+ Point[] pts = { p1, p2, p3, };
+ stopIconPath.AddLines(pts);
+ Brush brush = new SolidBrush(IconColor);
+ g.FillPath(brush, stopIconPath);
+ }
+ }
+ }
+
+ ///
+ /// 重新确定控件大小
+ ///
+ protected void myResize()
+ {
+ int x = DistanceToBorder;
+ int y = DistanceToBorder;
+ int width = this.Width - 2 * DistanceToBorder;
+ int height = this.Height - 2 * DistanceToBorder;
+ rect = new RectangleF(x, y, width, height);
+ }
+
+ ///
+ /// 绘制高亮效果
+ ///
+ /// Graphic对象
+ protected virtual void DrawHighLight(Graphics g)
+ {
+ RectangleF highlightRect = rect;
+ highlightRect.Inflate(-BorderWidth / 2, -BorderWidth / 2);
+ Brush brush = Brushes.DodgerBlue;
+ if (buttonPressed)
+ {
+ brush = new LinearGradientBrush(rect, ButtonCenterColorStart, ButtonCenterColorEnd, GradientAngle);
+ }
+
+ else
+ {
+ brush = new LinearGradientBrush(rect, Color.FromArgb(60, Color.White),
+ Color.FromArgb(60, Color.White), GradientAngle);
+ }
+ PaintShape(g, brush, highlightRect);
+ }
+
+ ///
+ /// 绘制边框
+ ///
+ /// Graphics对象
+ protected virtual void DrawBorder(Graphics g)
+ {
+ Pen p = new Pen(BorderColor);
+ if (Focused)
+ {
+ p.Color = FocusBorderColor;//外圈获取焦点后的颜色
+ p.Width = BorderWidth;
+ PaintShape(g, p, rect);
+ }
+ else
+ {
+ p.Width = BorderWidth;
+ PaintShape(g, p, rect);
+ }
+
+ }
+
+ ///
+ ///
+ ///
+ /// Graphic对象
+ protected virtual void DrawPressState(Graphics g)
+ {
+ RectangleF pressedRect = rect;
+ pressedRect.Inflate(-2, -2);
+ Brush brush = new LinearGradientBrush(rect, Color.FromArgb(60, Color.White),
+ Color.FromArgb(60, Color.White), GradientAngle);
+ PaintShape(g, brush, pressedRect);
+ }
+
+ ///
+ /// 绘制图形
+ ///
+ /// Graphics对象
+ /// Pen对象
+ /// RectangleF对象
+ protected virtual void PaintShape(Graphics g, Pen pen, RectangleF rect)
+ {
+ g.DrawEllipse(pen, rect);
+ }
+
+ ///
+ /// 绘制图形
+ ///
+ /// Graphics对象
+ /// Brush对象
+ /// Rectangle对象
+ protected virtual void PaintShape(Graphics g, Brush brush, RectangleF rect)
+ {
+ g.FillEllipse(brush, rect);
+ }
+
+ #endregion
+ }
+}
diff --git a/JY.Control/TextBoxWatermark.cs b/JY.Control/TextBoxWatermark.cs
new file mode 100644
index 0000000..861a905
--- /dev/null
+++ b/JY.Control/TextBoxWatermark.cs
@@ -0,0 +1,98 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Drawing;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows.Forms;
+
+namespace JYControl
+{
+ ///
+ /// TextBox添加水印文字
+ ///
+ [ToolboxBitmap(typeof(TextBox))]
+
+ public class WatermarkTextBox : TextBox
+ {
+ private string _watermark;
+ private Color _watermarkColor = Color.DarkGray;
+ private const int WM_PAINT = 0xF;
+
+ public WatermarkTextBox()
+ : base()
+ {
+ }
+ ///
+ /// 输入需要显示水印文字
+ ///
+ ///
+ [Category("控件属性")]
+ [Description("输入需要显示水印文字")]
+ [DefaultValue("")]
+ public string Watermark
+ {
+ get { return _watermark; }
+ set
+ {
+ _watermark = value;
+ base.Invalidate();
+ }
+ }
+
+ ///
+ /// 改变水印文字的颜色
+ ///
+ ///
+ [Category("控件属性")]
+ [Description("改变水印文字的颜色")]
+ [DefaultValue(typeof(Color), "DarkGray")]
+ public Color WatermarkColor
+ {
+ get { return _watermarkColor; }
+ set
+ {
+ _watermarkColor = value;
+ base.Invalidate();
+ }
+ }
+
+ protected override void WndProc(ref Message m)
+ {
+ base.WndProc(ref m);
+ if (m.Msg == WM_PAINT)
+ {
+ WmPaint(ref m);
+ }
+ }
+
+ private void WmPaint(ref Message m)
+ {
+ using (Graphics graphics = Graphics.FromHwnd(base.Handle))
+ {
+ if (Text.Length == 0
+ && !string.IsNullOrEmpty(_watermark)
+ && !Focused)
+ {
+ TextFormatFlags format =
+ TextFormatFlags.EndEllipsis |
+ TextFormatFlags.VerticalCenter;
+
+ if (RightToLeft == RightToLeft.Yes)
+ {
+ format |= TextFormatFlags.RightToLeft | TextFormatFlags.Right;
+ }
+
+ TextRenderer.DrawText(
+ graphics,
+ _watermark,
+ Font,
+ base.ClientRectangle,
+ _watermarkColor,
+ format);
+ }
+ }
+ }
+ }
+}
diff --git a/JY.Control/TreeViewEx.Designer.cs b/JY.Control/TreeViewEx.Designer.cs
new file mode 100644
index 0000000..e163d88
--- /dev/null
+++ b/JY.Control/TreeViewEx.Designer.cs
@@ -0,0 +1,43 @@
+namespace JYControl
+{
+ partial class TreeViewEx
+ {
+ ///
+ /// 必需的设计器变量。
+ ///
+ private System.ComponentModel.IContainer components = null;
+
+ ///
+ /// 清理所有正在使用的资源。
+ ///
+ /// 如果应释放托管资源,为 true;否则为 false。
+ protected override void Dispose(bool disposing)
+ {
+ if (disposing && (components != null))
+ {
+ components.Dispose();
+ }
+ base.Dispose(disposing);
+ }
+
+ #region 组件设计器生成的代码
+
+ ///
+ /// 设计器支持所需的方法 - 不要修改
+ /// 使用代码编辑器修改此方法的内容。
+ ///
+ private void InitializeComponent()
+ {
+ this.SuspendLayout();
+ //
+ // TreeViewEx
+ //
+ this.Name = "NaviButton";
+ this.Size = new System.Drawing.Size(133, 57);
+ this.ResumeLayout(false);
+
+ }
+
+ #endregion
+ }
+}
diff --git a/JY.Control/TreeViewEx.cs b/JY.Control/TreeViewEx.cs
new file mode 100644
index 0000000..841017d
--- /dev/null
+++ b/JY.Control/TreeViewEx.cs
@@ -0,0 +1,649 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel;
+using System.Diagnostics;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Windows.Forms;
+using JYControl.Properties;
+
+namespace JYControl
+{
+ ///
+ /// Class TreeViewEx.
+ /// Implements the
+ ///
+ ///
+ public partial class TreeViewEx : TreeView
+ {
+
+ ///
+ /// The ws vscroll
+ ///
+ private const int WS_VSCROLL = 2097152;
+
+ ///
+ /// The GWL style
+ ///
+ private const int GWL_STYLE = -16;
+
+ ///
+ /// The LST tips
+ ///
+ private Dictionary _lstTips = new Dictionary();
+
+ ///
+ /// The tip font
+ ///
+ private Font _tipFont = new Font("Arial Unicode MS", 12f);
+
+ ///
+ /// The tip image
+ ///
+ private Image _tipImage = JYControl.Properties.Resources.tips;
+
+ ///
+ /// The is show tip
+ ///
+ private bool _isShowTip = false;
+
+ ///
+ /// The is show by custom model
+ ///
+ private bool _isShowByCustomModel = true;
+
+ ///
+ /// The node height
+ ///
+ private int _nodeHeight = 50;
+
+ ///
+ /// The node down pic
+ ///
+ private Image _nodeDownPic = JYControl.Properties.Resources.list_add;
+
+ ///
+ /// The node up pic
+ ///
+ private Image _nodeUpPic = JYControl.Properties.Resources.list_subtract;
+
+ ///
+ /// The node background color
+ ///
+ private Color _nodeBackgroundColor = Color.White;
+
+ ///
+ /// The node fore color
+ ///
+ private Color _nodeForeColor = Color.FromArgb(62, 62, 62);
+
+ ///
+ /// The node is show split line
+ ///
+ private bool _nodeIsShowSplitLine = false;
+
+ ///
+ /// The node split line color
+ ///
+ private Color _nodeSplitLineColor = Color.FromArgb(232, 232, 232);
+
+ ///
+ /// The m node selected color
+ ///
+ private Color m_nodeSelectedColor = Color.FromArgb(255, 77, 59);
+
+ ///
+ /// The m node selected fore color
+ ///
+ private Color m_nodeSelectedForeColor = Color.White;
+
+ ///
+ /// The parent node can select
+ ///
+ private bool _parentNodeCanSelect = true;
+
+ ///
+ /// The tree font size
+ ///
+ private SizeF treeFontSize = SizeF.Empty;
+
+ ///
+ /// The BLN has v bar
+ ///
+ private bool blnHasVBar = false;
+
+ ///
+ /// Gets or sets the LST tips.
+ ///
+ /// The LST tips.
+ public Dictionary LstTips
+ {
+ get
+ {
+ return this._lstTips;
+ }
+ set
+ {
+ this._lstTips = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the tip font.
+ ///
+ /// The tip font.
+ [Category("自定义属性"), Description("角标文字字体")]
+ public Font TipFont
+ {
+ get
+ {
+ return this._tipFont;
+ }
+ set
+ {
+ this._tipFont = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the tip image.
+ ///
+ /// The tip image.
+ [Category("自定义属性"), Description("是否显示角标")]
+ public Image TipImage
+ {
+ get
+ {
+ return this._tipImage;
+ }
+ set
+ {
+ this._tipImage = value;
+ }
+ }
+
+ ///
+ /// Gets or sets a value indicating whether this instance is show tip.
+ ///
+ /// true if this instance is show tip; otherwise, false.
+ [Category("自定义属性"), Description("是否显示角标")]
+ public bool IsShowTip
+ {
+ get
+ {
+ return this._isShowTip;
+ }
+ set
+ {
+ this._isShowTip = value;
+ }
+ }
+
+ ///
+ /// Gets or sets a value indicating whether this instance is show by custom model.
+ ///
+ /// true if this instance is show by custom model; otherwise, false.
+ [Category("自定义属性"), Description("使用自定义模式")]
+ public bool IsShowByCustomModel
+ {
+ get
+ {
+ return this._isShowByCustomModel;
+ }
+ set
+ {
+ this._isShowByCustomModel = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the height of the node.
+ ///
+ /// The height of the node.
+ [Category("自定义属性"), Description("节点高度(IsShowByCustomModel=true时生效)")]
+ public int NodeHeight
+ {
+ get
+ {
+ return this._nodeHeight;
+ }
+ set
+ {
+ this._nodeHeight = value;
+ base.ItemHeight = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the node down pic.
+ ///
+ /// The node down pic.
+ [Category("自定义属性"), Description("下翻图标(IsShowByCustomModel=true时生效)")]
+ public Image NodeDownPic
+ {
+ get
+ {
+ return this._nodeDownPic;
+ }
+ set
+ {
+ this._nodeDownPic = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the node up pic.
+ ///
+ /// The node up pic.
+ [Category("自定义属性"), Description("上翻图标(IsShowByCustomModel=true时生效)")]
+ public Image NodeUpPic
+ {
+ get
+ {
+ return this._nodeUpPic;
+ }
+ set
+ {
+ this._nodeUpPic = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the color of the node background.
+ ///
+ /// The color of the node background.
+ [Category("自定义属性"), Description("节点背景颜色(IsShowByCustomModel=true时生效)")]
+ public Color NodeBackgroundColor
+ {
+ get
+ {
+ return this._nodeBackgroundColor;
+ }
+ set
+ {
+ this._nodeBackgroundColor = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the color of the node fore.
+ ///
+ /// The color of the node fore.
+ [Category("自定义属性"), Description("节点字体颜色(IsShowByCustomModel=true时生效)")]
+ public Color NodeForeColor
+ {
+ get
+ {
+ return this._nodeForeColor;
+ }
+ set
+ {
+ this._nodeForeColor = value;
+ }
+ }
+
+ ///
+ /// Gets or sets a value indicating whether [node is show split line].
+ ///
+ /// true if [node is show split line]; otherwise, false.
+ [Category("自定义属性"), Description("节点是否显示分割线(IsShowByCustomModel=true时生效)")]
+ public bool NodeIsShowSplitLine
+ {
+ get
+ {
+ return this._nodeIsShowSplitLine;
+ }
+ set
+ {
+ this._nodeIsShowSplitLine = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the color of the node split line.
+ ///
+ /// The color of the node split line.
+ [Category("自定义属性"), Description("节点分割线颜色(IsShowByCustomModel=true时生效)")]
+ public Color NodeSplitLineColor
+ {
+ get
+ {
+ return this._nodeSplitLineColor;
+ }
+ set
+ {
+ this._nodeSplitLineColor = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the color of the node selected.
+ ///
+ /// The color of the node selected.
+ [Category("自定义属性"), Description("选中节点背景颜色(IsShowByCustomModel=true时生效)")]
+ public Color NodeSelectedColor
+ {
+ get
+ {
+ return this.m_nodeSelectedColor;
+ }
+ set
+ {
+ this.m_nodeSelectedColor = value;
+ }
+ }
+
+ ///
+ /// Gets or sets the color of the node selected fore.
+ ///
+ /// The color of the node selected fore.
+ [Category("自定义属性"), Description("选中节点字体颜色(IsShowByCustomModel=true时生效)")]
+ public Color NodeSelectedForeColor
+ {
+ get
+ {
+ return this.m_nodeSelectedForeColor;
+ }
+ set
+ {
+ this.m_nodeSelectedForeColor = value;
+ }
+ }
+
+ ///
+ /// Gets or sets a value indicating whether [parent node can select].
+ ///
+ /// true if [parent node can select]; otherwise, false.
+ [Category("自定义属性"), Description("父节点是否可选中")]
+ public bool ParentNodeCanSelect
+ {
+ get
+ {
+ return this._parentNodeCanSelect;
+ }
+ set
+ {
+ this._parentNodeCanSelect = value;
+ }
+ }
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public TreeViewEx()
+ {
+ base.HideSelection = false;
+ base.DrawMode = TreeViewDrawMode.OwnerDrawAll;
+ base.DrawNode += new DrawTreeNodeEventHandler(this.treeview_DrawNode);
+ base.NodeMouseClick += new TreeNodeMouseClickEventHandler(this.TreeViewEx_NodeMouseClick);
+ base.SizeChanged += new EventHandler(this.TreeViewEx_SizeChanged);
+ base.AfterSelect += new TreeViewEventHandler(this.TreeViewEx_AfterSelect);
+ base.FullRowSelect = true;
+ base.ShowLines = false;
+ base.ShowPlusMinus = false;
+ base.ShowRootLines = false;
+ this.BackColor = Color.White;
+ this.BorderStyle = System.Windows.Forms.BorderStyle.None;
+ DoubleBuffered = true;
+ }
+ ///
+ /// 重写 。
+ ///
+ /// 要处理的 Windows。
+ protected override void WndProc(ref Message m)
+ {
+
+ if (m.Msg == 0x0014) // 禁掉清除背景消息WM_ERASEBKGND
+
+ return;
+
+ base.WndProc(ref m);
+
+ }
+ ///
+ /// Handles the AfterSelect event of the TreeViewEx control.
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void TreeViewEx_AfterSelect(object sender, TreeViewEventArgs e)
+ {
+ try
+ {
+ if (e.Node != null)
+ {
+ if (!this._parentNodeCanSelect)
+ {
+ if (e.Node.Nodes.Count > 0)
+ {
+ e.Node.Expand();
+ base.SelectedNode = e.Node.Nodes[0];
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ ///
+ /// Handles the SizeChanged event of the TreeViewEx control.
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void TreeViewEx_SizeChanged(object sender, EventArgs e)
+ {
+ this.Refresh();
+ }
+
+ ///
+ /// Handles the NodeMouseClick event of the TreeViewEx control.
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void TreeViewEx_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e)
+ {
+ try
+ {
+ if (e.Node != null)
+ {
+ if (e.Node.Nodes.Count > 0)
+ {
+ if (e.Node.IsExpanded)
+ {
+ e.Node.Collapse();
+ }
+ else
+ {
+ e.Node.Expand();
+ }
+ }
+ if (base.SelectedNode != null)
+ {
+ if (base.SelectedNode == e.Node && e.Node.IsExpanded)
+ {
+ if (!this._parentNodeCanSelect)
+ {
+ if (e.Node.Nodes.Count > 0)
+ {
+ base.SelectedNode = e.Node.Nodes[0];
+ }
+ }
+ }
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ ///
+ /// Handles the DrawNode event of the treeview control.
+ ///
+ /// The source of the event.
+ /// The instance containing the event data.
+ private void treeview_DrawNode(object sender, DrawTreeNodeEventArgs e)
+ {
+ try
+ {
+
+ if (e.Node == null || !this._isShowByCustomModel || (e.Node.Bounds.Width <= 0 && e.Node.Bounds.Height <= 0 && e.Node.Bounds.X <= 0 && e.Node.Bounds.Y <= 0))
+ {
+ e.DrawDefault = true;
+ }
+ else
+ {
+ e.Graphics.SetGDIHigh();
+ if (base.Nodes.IndexOf(e.Node) == 0)
+ {
+ this.blnHasVBar = this.IsVerticalScrollBarVisible();
+ }
+ Font font = e.Node.NodeFont;
+ if (font == null)
+ {
+ font = ((TreeView)sender).Font;
+ }
+ if (this.treeFontSize == SizeF.Empty)
+ {
+ this.treeFontSize = this.GetFontSize(font, e.Graphics);
+ }
+ bool flag = false;
+ int intLeft = 0;
+ if (CheckBoxes)
+ {
+ intLeft = 20;
+ }
+ int num = 0;
+ if (base.ImageList != null && base.ImageList.Images.Count > 0 && e.Node.ImageIndex >= 0 && e.Node.ImageIndex < base.ImageList.Images.Count)
+ {
+ flag = true;
+ num = (e.Bounds.Height - base.ImageList.ImageSize.Height) / 2;
+ intLeft += base.ImageList.ImageSize.Width;
+ }
+
+ intLeft += e.Node.Level * Indent;
+
+ if ((e.State == TreeNodeStates.Selected || e.State == TreeNodeStates.Focused || e.State == (TreeNodeStates.Focused | TreeNodeStates.Selected)) && (this._parentNodeCanSelect || e.Node.Nodes.Count <= 0))
+ {
+ e.Graphics.FillRectangle(new SolidBrush(this.m_nodeSelectedColor), new Rectangle(new Point(0, e.Node.Bounds.Y), new Size(base.Width, e.Node.Bounds.Height)));
+ e.Graphics.DrawString(e.Node.Text, font, new SolidBrush(this.m_nodeSelectedForeColor), (float)e.Bounds.X + intLeft, (float)e.Bounds.Y + ((float)this._nodeHeight - this.treeFontSize.Height) / 2f);
+ }
+ else
+ {
+ e.Graphics.FillRectangle(new SolidBrush(this._nodeBackgroundColor), new Rectangle(new Point(0, e.Node.Bounds.Y), new Size(base.Width, e.Node.Bounds.Height)));
+ e.Graphics.DrawString(e.Node.Text, font, new SolidBrush(this._nodeForeColor), (float)e.Bounds.X + intLeft, (float)e.Bounds.Y + ((float)this._nodeHeight - this.treeFontSize.Height) / 2f);
+ }
+ if (CheckBoxes)
+ {
+ Rectangle rectCheck = new Rectangle(e.Bounds.X + 3 + e.Node.Level * Indent, e.Bounds.Y + (e.Bounds.Height - 16) / 2, 16, 16);
+ GraphicsPath pathCheck = rectCheck.CreateRoundedRectanglePath(3);
+ e.Graphics.FillPath(new SolidBrush(Color.FromArgb(247, 247, 247)), pathCheck);
+ if (e.Node.Checked)
+ {
+ e.Graphics.DrawLines(new Pen(new SolidBrush(m_nodeSelectedColor), 2), new Point[]
+ {
+ new Point(rectCheck.Left+2,rectCheck.Top+8),
+ new Point(rectCheck.Left+6,rectCheck.Top+12),
+ new Point(rectCheck.Right-4,rectCheck.Top+4)
+ });
+ }
+
+ e.Graphics.DrawPath(new Pen(new SolidBrush(Color.FromArgb(200, 200, 200))), pathCheck);
+ }
+ if (flag)
+ {
+ int num2 = e.Bounds.X - num - base.ImageList.ImageSize.Width;
+ if (num2 < 0)
+ {
+ num2 = 3;
+ }
+ e.Graphics.DrawImage(base.ImageList.Images[e.Node.ImageIndex], new Rectangle(new Point(num2 + intLeft - base.ImageList.ImageSize.Width, e.Bounds.Y + num), base.ImageList.ImageSize));
+ }
+ if (this._nodeIsShowSplitLine)
+ {
+ e.Graphics.DrawLine(new Pen(this._nodeSplitLineColor, 1f), new Point(0, e.Bounds.Y + this._nodeHeight - 1), new Point(base.Width, e.Bounds.Y + this._nodeHeight - 1));
+ }
+ bool flag2 = false;
+ if (e.Node.Nodes.Count > 0)
+ {
+ if (e.Node.IsExpanded && this._nodeUpPic != null)
+ {
+ e.Graphics.DrawImage(this._nodeUpPic, new Rectangle(base.Width - (this.blnHasVBar ? 50 : 30), e.Bounds.Y + (this._nodeHeight - 20) / 2, 20, 20));
+ }
+ else if (this._nodeDownPic != null)
+ {
+ e.Graphics.DrawImage(this._nodeDownPic, new Rectangle(base.Width - (this.blnHasVBar ? 50 : 30), e.Bounds.Y + (this._nodeHeight - 20) / 2, 20, 20));
+ }
+ flag2 = true;
+ }
+ if (this._isShowTip && this._lstTips.ContainsKey(e.Node.Name) && !string.IsNullOrWhiteSpace(this._lstTips[e.Node.Name]))
+ {
+ int num3 = base.Width - (this.blnHasVBar ? 50 : 30) - (flag2 ? 20 : 0);
+ int num4 = e.Bounds.Y + (this._nodeHeight - 20) / 2;
+ e.Graphics.DrawImage(this._tipImage, new Rectangle(num3, num4, 20, 20));
+ SizeF sizeF = e.Graphics.MeasureString(this._lstTips[e.Node.Name], this._tipFont, 100, StringFormat.GenericTypographic);
+ e.Graphics.DrawString(this._lstTips[e.Node.Name], this._tipFont, new SolidBrush(Color.White), (float)(num3 + 10) - sizeF.Width / 2f - 3f, (float)(num4 + 10) - sizeF.Height / 2f);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ }
+
+ ///
+ /// Gets the size of the font.
+ ///
+ /// The font.
+ /// The g.
+ /// SizeF.
+ private SizeF GetFontSize(Font font, Graphics g = null)
+ {
+ SizeF result;
+ try
+ {
+ bool flag = false;
+ if (g == null)
+ {
+ g = base.CreateGraphics();
+ flag = true;
+ }
+ SizeF sizeF = g.MeasureString("a", font, 100, StringFormat.GenericTypographic);
+ if (flag)
+ {
+ g.Dispose();
+ }
+ result = sizeF;
+ }
+ catch (Exception ex)
+ {
+ throw ex;
+ }
+ return result;
+ }
+
+ ///
+ /// Gets the window long.
+ ///
+ /// The HWND.
+ /// Index of the n.
+ /// System.Int32.
+ [DllImport("user32", CharSet = CharSet.Auto)]
+ private static extern int GetWindowLong(IntPtr hwnd, int nIndex);
+
+ ///
+ /// Determines whether [is vertical scroll bar visible].
+ ///
+ /// true if [is vertical scroll bar visible]; otherwise, false.
+ private bool IsVerticalScrollBarVisible()
+ {
+ return base.IsHandleCreated && (TreeViewEx.GetWindowLong(base.Handle, -16) & 2097152) != 0;
+ }
+ }
+}
diff --git a/JY.Control/TreeViewEx.resx b/JY.Control/TreeViewEx.resx
new file mode 100644
index 0000000..e5858cc
--- /dev/null
+++ b/JY.Control/TreeViewEx.resx
@@ -0,0 +1,123 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ False
+
+
\ No newline at end of file
diff --git a/JY.DAL/IDbHelper.cs b/JY.DAL/IDbHelper.cs
new file mode 100644
index 0000000..06ef540
--- /dev/null
+++ b/JY.DAL/IDbHelper.cs
@@ -0,0 +1,213 @@
+using JY.Model;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JY.DAL
+{
+ public interface IDbHelper
+ {
+ ///
+ /// 保存报警数据
+ ///
+ ///
+ ///
+ int AddAlarmData(AlarmData m);
+ ///
+ /// 缓存报警数据
+ ///
+ ///
+ ///
+ ///
+ int AddAlarmCacheData(string tablename, List m);
+
+ ///
+ /// 查询缓存表报警信息
+ ///
+ /// 开始时间
+ /// 结束时间
+ ///
+ List GetAlarmCacheData();
+ ///
+ /// 删除未更新数据
+ ///
+ ///
+ int DeleteAlarmCacheData();
+ ///
+ /// 查询报警信息
+ ///
+ /// 开始时间
+ /// 结束时间
+ ///
+ List GetAlarmData(string strDate1, string strDate2);
+ ///
+ /// 查询进站信息
+ ///
+ ///
+ ///
+ List GetFeedingData(string strCode);
+ ///
+ /// 新增产品型号
+ ///
+ /// 机型信息
+ ///
+ int AddProductModel(ProductModel entity);
+
+ ///
+ /// 删除本地型号
+ ///
+ /// 型号
+ ///
+ void DelProductModel(string modeltype);
+
+ ///
+ /// 获取产品型号列表
+ ///
+ /// 产品型号
+ ///
+ List GetProductModelList(string strProdType = "");
+
+ ///
+ /// 保存产品类型配置参数
+ ///
+ ///
+ bool AddProductParaList(List list);
+
+ ///
+ /// 获取产品参数通过产品型号
+ ///
+ /// 产品型号
+ ///
+ List GetProductParaByProdModel(string strModelType);
+
+ ///
+ /// 标准轴参数保存
+ ///
+ ///
+ ///
+ ///
+ ///
+ bool InsertPLCConfigBase(List list);
+
+ ///
+ /// 获取换型操作的基本参数
+ ///
+ ///
+ List GetPLCConfigBases();
+
+ ///
+ /// 获取PLC换型参数绑定值
+ ///
+ /// 产品型号
+ ///
+ List GetPLCConfigPara(string modelName);
+
+ ///
+ /// 具体型号轴参数保存
+ ///
+ ///
+ ///
+ ///
+ ///
+ bool InsertPLCConfigParam(List list);
+
+ ///
+ /// 查询历史数据
+ ///
+ ///
+ ///
+ ///
+ ///
+ DataTable GetTestData(int type,string strBarCode, string strDate1, string strDate2, string flag);
+ ///
+ /// 查询历史数据
+ ///
+ ///
+ ///
+ ///
+ ///
+ ///
+ DataTable GetTestData2(int type,int resultType, string strBarCode, string strDate1, string strDate2, string flag);
+ ///
+ /// 查询CCD历史数据
+ ///
+ ///
+ ///
+ ///
+ ///
+ DataTable GetCCDData(string strWorkerNum, string strDate1, string strDate2);
+
+ ///
+ /// 查询CCD历史数据
+ ///
+ ///
+ ///
+ ///
+ ///
+ DataTable GetBarInTime(string strBar);
+
+ ///
+ /// 更新获取进站时间状态
+ ///
+ ///
+ ///
+ int UparInTime(string strBar);
+ ///
+ /// 按日期查询和时间查询投入产出信息
+ ///
+ ///
+ ///
+ ///
+ List GetProdTotal(string strDate, int Hour);
+
+ ///
+ /// 更新指定时间的小时产出
+ ///
+ /// 小时产出数据
+ ///
+ int UpdateHourprodData(HourprodEntity enity);
+
+ ///
+ /// 保存进托盘数据
+ ///
+ ///
+ ///
+ ///
+ int AddInPutTrayID(TrayTestEntry m, ref string strErr);
+
+ ///
+ /// 保存空托盘排出数据
+ ///
+ ///
+ ///
+ ///
+ int AddOutTrayID(TrayTestEntry m, ref string strErr);
+
+ ///
+ /// 保存上料数据
+ ///
+ ///
+ ///
+ ///
+ int AddFeedingData(FeedingData m, ref string strErr);
+
+ ///
+ /// 保存下料数据
+ ///
+ ///
+ ///
+ ///
+ int AddBlankingData(BlankingData m, ref string strErr);
+ int AddCamInforData(CamInfor m, ref string strErr);
+ ///
+ /// 根据工位编码获取异常播报内容
+ ///
+ ///
+ /// 如果没有找到记录,是否需要插入
+ ///
+ string GetAbnormalVoice(string code, bool needInsert = false);
+ }
+}
diff --git a/JY.DAL/IocConfig.cs b/JY.DAL/IocConfig.cs
new file mode 100644
index 0000000..0c9d026
--- /dev/null
+++ b/JY.DAL/IocConfig.cs
@@ -0,0 +1,32 @@
+using JY.DAL.Repository;
+using JY.DAL.Service;
+using JY.Model;
+using Microsoft.Extensions.DependencyInjection;
+using SqlSugar;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JY.DAL
+{
+ public static class IocConfig
+ {
+ public static ServiceProvider Provider { get; private set; }
+
+ public static void Initialize()
+ {
+ var services = new ServiceCollection();
+ //services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
+ services.AddScoped(typeof(IRepository<>), typeof(Repository<>));
+ services.AddScoped, Repository>();
+
+ services.AddScoped();
+ services.AddScoped();
+ services.AddScoped();
+
+ Provider = services.BuildServiceProvider();
+ }
+ }
+}
diff --git a/JY.DAL/JY.DAL.csproj b/JY.DAL/JY.DAL.csproj
new file mode 100644
index 0000000..9dbd8fb
--- /dev/null
+++ b/JY.DAL/JY.DAL.csproj
@@ -0,0 +1,192 @@
+
+
+
+
+
+ Debug
+ AnyCPU
+ {D5889580-58F9-467E-87D3-EFA37A300E67}
+ Library
+ Properties
+ JY.DAL
+ JY.DAL
+ v4.8
+ 512
+ true
+
+
+
+
+
+ true
+ full
+ false
+ ..\..\..\..\JY.Inspection\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\packages\BouncyCastle.Cryptography.2.4.0\lib\net461\BouncyCastle.Cryptography.dll
+
+
+ ..\packages\CsvHelper.30.0.1\lib\net45\CsvHelper.dll
+
+
+ ..\packages\Dapper.1.60.6\lib\net451\Dapper.dll
+
+
+ ..\packages\Enums.NET.5.0.0\lib\net461\Enums.NET.dll
+
+
+ ..\packages\EPPlus.8.0.8\lib\net462\EPPlus.dll
+
+
+ ..\packages\EPPlus.Interfaces.8.0.0\lib\net462\EPPlus.Interfaces.dll
+
+
+ ..\packages\ExtendedNumerics.BigDecimal.2025.1001.2.129\lib\net48\ExtendedNumerics.BigDecimal.dll
+
+
+ ..\packages\SharpZipLib.1.4.2\lib\netstandard2.0\ICSharpCode.SharpZipLib.dll
+
+
+ ..\packages\MathNet.Numerics.Signed.5.0.0\lib\net48\MathNet.Numerics.dll
+
+
+ ..\packages\Microsoft.Bcl.AsyncInterfaces.10.0.9\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll
+
+
+ ..\packages\Microsoft.Extensions.DependencyInjection.10.0.9\lib\net462\Microsoft.Extensions.DependencyInjection.dll
+
+
+ ..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.10.0.9\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll
+
+
+ ..\packages\Microsoft.IO.RecyclableMemoryStream.3.0.1\lib\netstandard2.0\Microsoft.IO.RecyclableMemoryStream.dll
+
+
+ ..\packages\Microsoft.Owin.4.2.3\lib\net45\Microsoft.Owin.dll
+
+
+ ..\packages\MySql.Data.6.10.9\lib\net452\MySql.Data.dll
+
+
+ ..\packages\NPOI.2.7.4\lib\net472\NPOI.Core.dll
+
+
+ ..\packages\NPOI.2.7.4\lib\net472\NPOI.OOXML.dll
+
+
+ ..\packages\NPOI.2.7.4\lib\net472\NPOI.OpenXml4Net.dll
+
+
+ ..\packages\NPOI.2.7.4\lib\net472\NPOI.OpenXmlFormats.dll
+
+
+ ..\packages\Owin.1.0\lib\net40\Owin.dll
+
+
+
+ ..\packages\SixLabors.Fonts.1.0.1\lib\netstandard2.0\SixLabors.Fonts.dll
+
+
+ ..\packages\SqlSugar.5.1.4.207\lib\SqlSugar.dll
+
+
+
+ ..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll
+
+
+
+ ..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll
+
+
+
+
+
+
+
+
+
+
+ ..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll
+
+
+
+ ..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll
+
+
+ ..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll
+
+
+
+ ..\packages\System.Security.Cryptography.Xml.8.0.2\lib\net462\System.Security.Cryptography.Xml.dll
+
+
+ ..\packages\System.Text.Encoding.CodePages.9.0.7\lib\net462\System.Text.Encoding.CodePages.dll
+
+
+ ..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll
+
+
+
+ ..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll
+
+
+
+
+
+
+
+
+
+ ..\packages\ZString.2.6.0\lib\netstandard2.0\ZString.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {f7db3a93-fca2-479b-8b2e-380116aae9fc}
+ JY.Model
+
+
+
+
+
+
+ 这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。
+
+
+
+
\ No newline at end of file
diff --git a/JY.DAL/JY.DAL.csproj.user b/JY.DAL/JY.DAL.csproj.user
new file mode 100644
index 0000000..0b24643
--- /dev/null
+++ b/JY.DAL/JY.DAL.csproj.user
@@ -0,0 +1,6 @@
+
+
+
+ ProjectFiles
+
+
\ No newline at end of file
diff --git a/JY.DAL/Mapper/AlarmDataMapping.cs b/JY.DAL/Mapper/AlarmDataMapping.cs
new file mode 100644
index 0000000..2b3e4ea
--- /dev/null
+++ b/JY.DAL/Mapper/AlarmDataMapping.cs
@@ -0,0 +1,22 @@
+using DapperExtensions.Mapper;
+using JY.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JY.DAL.Mapper
+{
+ ///
+ /// ProdModel表映射,实体名和表名不一样实现映射
+ ///
+ public class AlarmDataMapping : ClassMapper
+ {
+ public AlarmDataMapping()
+ {
+ Table("tb_alarm");
+ AutoMap();
+ }
+ }
+}
diff --git a/JY.DAL/Mapper/ProductModelMapping.cs b/JY.DAL/Mapper/ProductModelMapping.cs
new file mode 100644
index 0000000..5609f8e
--- /dev/null
+++ b/JY.DAL/Mapper/ProductModelMapping.cs
@@ -0,0 +1,22 @@
+using DapperExtensions.Mapper;
+using JY.Model;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JY.DAL.Mapper
+{
+ ///
+ /// ProdModel表映射,实体名和表名不一样实现映射
+ ///
+ public class ProductModelMapping : ClassMapper
+ {
+ public ProductModelMapping()
+ {
+ Table("tb_ProdModel");
+ AutoMap();
+ }
+ }
+}
diff --git a/JY.DAL/MySQLHelper.cs b/JY.DAL/MySQLHelper.cs
new file mode 100644
index 0000000..7b78cb2
--- /dev/null
+++ b/JY.DAL/MySQLHelper.cs
@@ -0,0 +1,271 @@
+using Dapper;
+using System;
+using System.Collections.Generic;
+using System.Configuration;
+using System.Data;
+using MySql.Data.MySqlClient;
+using System.Linq;
+
+namespace JY.DAL
+{
+ public class MySqlHelper where T : class
+ {
+ ///
+ /// 数据库连接字符串
+ ///
+ private static readonly string connectionString = ConfigurationManager.ConnectionStrings["MysqlConn"].ConnectionString;
+
+ ///
+ /// 查询列表
+ ///
+ /// 查询的sql
+ /// 替换参数
+ ///
+ public static List Query(string sql, object param = null)
+ {
+ using (MySqlConnection con = new MySqlConnection(connectionString))
+ {
+ return con.Query(sql, param).ToList();
+ }
+ }
+
+ ///
+ /// 查询第一个数据
+ ///
+ ///
+ ///
+ ///
+ public static T QueryFirst(string sql, object param = null)
+ {
+ using (MySqlConnection con = new MySqlConnection(connectionString))
+ {
+ return con.QueryFirst(sql, param);
+ }
+ }
+
+ ///
+ /// 查询第一个数据没有返回默认值
+ ///
+ ///
+ ///
+ ///
+ public static T QueryFirstOrDefault(string sql, object param = null)
+ {
+ using (MySqlConnection con = new MySqlConnection(connectionString))
+ {
+ return con.QueryFirstOrDefault(sql, param);
+ }
+ }
+
+ ///
+ /// 查询单条数据
+ ///
+ ///
+ ///
+ ///
+ public static T QuerySingle(string sql, object param = null)
+ {
+ using (MySqlConnection con = new MySqlConnection(connectionString))
+ {
+ return con.QuerySingle(sql, param);
+ }
+ }
+
+ ///
+ /// 查询单条数据没有返回默认值
+ ///
+ ///
+ ///
+ ///
+ public static T QuerySingleOrDefault(string sql, object param = null)
+ {
+ using (MySqlConnection con = new MySqlConnection(connectionString))
+ {
+ return con.QuerySingleOrDefault(sql, param);
+ }
+ }
+
+ ///
+ /// 增删改
+ ///
+ ///
+ ///
+ /// Number of rows affected
+ public static int Execute(string sql, object param = null)
+ {
+ using (MySqlConnection con = new MySqlConnection(connectionString))
+ {
+ return con.Execute(sql, param);
+ }
+ }
+
+ ///
+ /// Reader获取数据
+ ///
+ ///
+ ///
+ ///
+ public static IDataReader ExecuteReader(string sql, object param)
+ {
+ using (MySqlConnection con = new MySqlConnection(connectionString))
+ {
+ return con.ExecuteReader(sql, param);
+ }
+ }
+
+ ///
+ /// 获取数据返回DataTable
+ ///
+ ///
+ ///
+ ///
+ public static DataTable QueryTable(string sql, object param = null)
+ {
+ using (MySqlConnection con = new MySqlConnection(connectionString))
+ {
+ DataTable table = new DataTable();
+ var reader = con.ExecuteReader(sql, param);
+ table.Load(reader);
+ return table;
+ }
+ }
+
+ ///
+ /// Scalar获取数据
+ ///
+ ///
+ ///
+ ///
+ public static object ExecuteScalar(string sql, object param = null)
+ {
+ using (MySqlConnection con = new MySqlConnection(connectionString))
+ {
+ return con.ExecuteScalar(sql, param);
+ }
+ }
+
+ ///
+ /// Scalar获取数据
+ ///
+ ///
+ ///
+ ///
+ public static T ExecuteScalarForT(string sql, object param = null)
+ {
+ using (MySqlConnection con = new MySqlConnection(connectionString))
+ {
+ return con.ExecuteScalar(sql, param);
+ }
+ }
+
+ ///
+ /// 带参数的存储过程
+ ///
+ ///
+ ///
+ ///
+ public static List ExecutePro(string proc, object param = null)
+ {
+ using (MySqlConnection con = new MySqlConnection(connectionString))
+ {
+ List list = con.Query(proc,
+ param,
+ null,
+ true,
+ null,
+ CommandType.StoredProcedure).ToList();
+ return list;
+ }
+ }
+ ///
+ /// 批量插入T数据,返回影响行数
+ ///
+ /// 对象集合
+ /// 影响行数
+ public static int Insert(string strsql, List list)
+ {
+ using (IDbConnection connection = new MySqlConnection(connectionString))
+ {
+ //return connection.Execute("insert into Person(Name,Remark) values(@Name,@Remark)", list);
+ return connection.Execute(strsql, list);
+ }
+ }
+
+ ///
+ /// 事务1 - 全SQL
+ ///
+ /// 多条SQL
+ /// param
+ ///
+ public static int ExecuteTransaction(string[] sqlarr)
+ {
+ using (MySqlConnection con = new MySqlConnection(connectionString))
+ {
+ con.Open();
+ using (var transaction = con.BeginTransaction())
+ {
+ try
+ {
+ int result = 0;
+ foreach (var sql in sqlarr)
+ {
+ result += con.Execute(sql, null, transaction);
+ }
+
+ transaction.Commit();
+ return result;
+ }
+ catch (Exception ex)
+ {
+ transaction.Rollback();
+ throw ex;
+ }
+ finally
+ {
+ con.Close();
+ }
+ }
+ }
+ }
+
+ ///
+ /// 事务2 - 声明参数
+ ///demo:
+ ///dic.Add("Insert into Users values (@UserName, @Email, @Address)",
+ /// new { UserName = "jack", Email = "380234234@qq.com", Address = "上海" });
+ ///
+ /// 多条SQL
+ /// param
+ ///
+ public static int ExecuteTransaction(Dictionary dic)
+ {
+ using (MySqlConnection con = new MySqlConnection(connectionString))
+ {
+ con.Open();
+ using (var transaction = con.BeginTransaction())
+ {
+ try
+ {
+ int result = 0;
+ foreach (var sql in dic)
+ {
+ result += con.Execute(sql.Key, sql.Value, transaction);
+ }
+
+ transaction.Commit();
+ return result;
+ }
+ catch (Exception ex)
+ {
+ transaction.Rollback();
+ throw ex;
+ }
+ finally
+ {
+ con.Close();
+ }
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/JY.DAL/OpMysqlDataBase.cs b/JY.DAL/OpMysqlDataBase.cs
new file mode 100644
index 0000000..35078e6
--- /dev/null
+++ b/JY.DAL/OpMysqlDataBase.cs
@@ -0,0 +1,525 @@
+using JY.Model;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace JY.DAL
+{
+ ///
+ ///
+ ///
+ public class OpMysqlDataBase : IDbHelper
+ {
+ ///
+ /// 保存报警数据
+ ///
+ ///
+ ///
+ public int AddAlarmData(AlarmData m)
+ {
+
+ string strSql = string.Format(@"INSERT INTO tb_alarm (AlarmGuid,PLCAdress,AlarmCode,AlarmContent
+ ,AlarmType,AlarmDesc,AlarmState,StartTime,EndTime,Flag)
+ values('{0}','{1}','{2}','{3}','{4}',{5},'{6}','{7}','{8}',{9})"
+ , m.AlarmGuid, m.PLCAdress, m.AlarmCode, m.AlarmContent, m.AlarmType, m.AlarmDesc, m.AlarmState
+ , m.StartTime, m.EndTime, m.Flag);
+ int result = MySqlHelper.Execute(strSql);
+ return result;
+ }
+
+
+ ///
+ /// 删除未更新数据
+ ///
+ /// 开始时间
+ /// 结束时间
+ ///
+ public int DeleteAlarmCacheData()
+ {
+ string strSql = $@"DELETE FROM tb_alarm WHERE Flag=0";
+ int result = MySqlHelper