添加项目文件。
@@ -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
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Base class for the button renderers
|
||||||
|
/// </summary>
|
||||||
|
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 *)
|
||||||
|
/// <summary>
|
||||||
|
/// Update the rectangles for drawing
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draw the button object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Gr"></param>
|
||||||
|
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 *)
|
||||||
|
/// <summary>
|
||||||
|
/// Get the associated button object
|
||||||
|
/// </summary>
|
||||||
|
public LBButton Button
|
||||||
|
{
|
||||||
|
get { return this.Control as LBButton; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region (* Virtual method *)
|
||||||
|
/// <summary>
|
||||||
|
/// Draw the background of the control
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Gr"></param>
|
||||||
|
/// <param name="rc"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draw the body of the control
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Gr"></param>
|
||||||
|
/// <param name="rc"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draw the text of the control
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Gr"></param>
|
||||||
|
/// <param name="rc"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Manager for color
|
||||||
|
/// </summary>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The m LST freeze control
|
||||||
|
/// </summary>
|
||||||
|
static Dictionary<Control, bool> m_lstFreezeControl = new Dictionary<Control, bool>();
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the Disposed event of the control control.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The source of the event.</param>
|
||||||
|
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||||
|
static void control_Disposed(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (m_lstFreezeControl.ContainsKey((Control)sender))
|
||||||
|
m_lstFreezeControl.Remove((Control)sender);
|
||||||
|
}
|
||||||
|
catch { }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置GDI高质量模式抗锯齿
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">The g.</param>
|
||||||
|
public static void SetGDIHigh(this Graphics g)
|
||||||
|
{
|
||||||
|
g.SmoothingMode = SmoothingMode.AntiAlias; //使绘图质量最高,即消除锯齿
|
||||||
|
g.InterpolationMode = InterpolationMode.HighQualityBicubic;
|
||||||
|
g.CompositingQuality = CompositingQuality.HighQuality;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据矩形和圆得到一个圆角矩形Path
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rect">The rect.</param>
|
||||||
|
/// <param name="cornerRadius">The corner radius.</param>
|
||||||
|
/// <returns>GraphicsPath.</returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
namespace JYControl
|
||||||
|
{
|
||||||
|
partial class LBIndustrialCtrlBase
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 组件设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要修改
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
components = new System.ComponentModel.Container();
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Base class for the IndustrialCtrls
|
||||||
|
/// </summary>
|
||||||
|
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 *)
|
||||||
|
/// <summary>
|
||||||
|
/// Default renderer of the control
|
||||||
|
/// </summary>
|
||||||
|
private ILBRenderer _defaultRenderer = null;
|
||||||
|
[Browsable(false)]
|
||||||
|
public ILBRenderer DefaultRenderer
|
||||||
|
{
|
||||||
|
get { return this._defaultRenderer; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// User defined renderer
|
||||||
|
/// </summary>
|
||||||
|
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 *)
|
||||||
|
/// <summary>
|
||||||
|
/// Font change event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
[System.ComponentModel.EditorBrowsableAttribute()]
|
||||||
|
protected override void OnFontChanged(EventArgs e)
|
||||||
|
{
|
||||||
|
// Calculate dimensions
|
||||||
|
this.CalculateDimensions();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// SizeChanged event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
[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();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resize event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
protected override void OnResize(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnResize(e);
|
||||||
|
// Calculate al the data for
|
||||||
|
// drawing the control
|
||||||
|
this.CalculateDimensions();
|
||||||
|
// Redraw
|
||||||
|
this.Invalidate();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Paint event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
[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 *)
|
||||||
|
/// <summary>
|
||||||
|
/// Call from the constructor to create the default renderer
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
protected virtual ILBRenderer CreateDefaultRenderer()
|
||||||
|
{
|
||||||
|
return new LBRendererBase();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calculate the dimensions of the control
|
||||||
|
/// </summary>
|
||||||
|
protected virtual void CalculateDimensions()
|
||||||
|
{
|
||||||
|
this.DefaultRenderer.Update();
|
||||||
|
|
||||||
|
// Update the data in the renderer
|
||||||
|
if (this.Renderer != null)
|
||||||
|
this.Renderer.Update();
|
||||||
|
|
||||||
|
this.Invalidate();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Base class for the controls renderer
|
||||||
|
/// </summary>
|
||||||
|
public class LBRendererBase : ILBRenderer
|
||||||
|
{
|
||||||
|
#region (* Constructor *)
|
||||||
|
public LBRendererBase()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region (* IDisposable implementation *)
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
this.OnDispose();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region (* Properties *)
|
||||||
|
/// <summary>
|
||||||
|
/// Associated control
|
||||||
|
/// </summary>
|
||||||
|
protected object _control = null;
|
||||||
|
public object Control
|
||||||
|
{
|
||||||
|
set { this._control = value; }
|
||||||
|
get { return this._control; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region (* Virtual methods *)
|
||||||
|
/// <summary>
|
||||||
|
/// Dispose the resource of the object
|
||||||
|
/// </summary>
|
||||||
|
public virtual void OnDispose()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Update the renderer
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual bool Update()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Drawing method
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Gr"></param>
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Base class for the led renderers
|
||||||
|
/// </summary>
|
||||||
|
public class LBLedRenderer : LBRendererBase
|
||||||
|
{
|
||||||
|
#region (* Variables *)
|
||||||
|
private RectangleF drawRect;
|
||||||
|
private RectangleF rectLed;
|
||||||
|
private RectangleF rectLabel;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region (* Properies *)
|
||||||
|
/// <summary>
|
||||||
|
/// Get the associated led object
|
||||||
|
/// </summary>
|
||||||
|
public LBLed Led
|
||||||
|
{
|
||||||
|
get { return this.Control as LBLed; }
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region (* Overrided method *)
|
||||||
|
/// <summary>
|
||||||
|
/// Update the rectangles for drawing
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draw the led object
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Gr"></param>
|
||||||
|
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 *)
|
||||||
|
/// <summary>
|
||||||
|
/// Draw the background of the control
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Gr"></param>
|
||||||
|
/// <param name="rc"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draw the body of the control
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Gr"></param>
|
||||||
|
/// <param name="rc"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draw the text of the control
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Gr"></param>
|
||||||
|
/// <param name="rc"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Enum ComboBoxButtonState
|
||||||
|
/// </summary>
|
||||||
|
public enum ComboBoxButtonState
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The state system none
|
||||||
|
/// </summary>
|
||||||
|
STATE_SYSTEM_NONE,
|
||||||
|
/// <summary>
|
||||||
|
/// The state system invisible
|
||||||
|
/// </summary>
|
||||||
|
STATE_SYSTEM_INVISIBLE = 32768,
|
||||||
|
/// <summary>
|
||||||
|
/// The state system pressed
|
||||||
|
/// </summary>
|
||||||
|
STATE_SYSTEM_PRESSED = 8
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Struct RECT
|
||||||
|
/// </summary>
|
||||||
|
public struct RECT
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The left
|
||||||
|
/// </summary>
|
||||||
|
public int Left;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The top
|
||||||
|
/// </summary>
|
||||||
|
public int Top;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The right
|
||||||
|
/// </summary>
|
||||||
|
public int Right;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The bottom
|
||||||
|
/// </summary>
|
||||||
|
public int Bottom;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the rect.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The rect.</value>
|
||||||
|
public Rectangle Rect
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new Rectangle(this.Left, this.Top, this.Right - this.Left, this.Bottom - this.Top);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the size.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The size.</value>
|
||||||
|
public Size Size
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return new Size(this.Right - this.Left, this.Bottom - this.Top);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="RECT" /> struct.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="left">The left.</param>
|
||||||
|
/// <param name="top">The top.</param>
|
||||||
|
/// <param name="right">The right.</param>
|
||||||
|
/// <param name="bottom">The bottom.</param>
|
||||||
|
public RECT(int left, int top, int right, int bottom)
|
||||||
|
{
|
||||||
|
this.Left = left;
|
||||||
|
this.Top = top;
|
||||||
|
this.Right = right;
|
||||||
|
this.Bottom = bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="RECT" /> struct.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rect">The rect.</param>
|
||||||
|
public RECT(Rectangle rect)
|
||||||
|
{
|
||||||
|
this.Left = rect.Left;
|
||||||
|
this.Top = rect.Top;
|
||||||
|
this.Right = rect.Right;
|
||||||
|
this.Bottom = rect.Bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Froms the xywh.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="x">The x.</param>
|
||||||
|
/// <param name="y">The y.</param>
|
||||||
|
/// <param name="width">The width.</param>
|
||||||
|
/// <param name="height">The height.</param>
|
||||||
|
/// <returns>NativeMethods.RECT.</returns>
|
||||||
|
public static NativeMethods.RECT FromXYWH(int x, int y, int width, int height)
|
||||||
|
{
|
||||||
|
return new NativeMethods.RECT(x, y, x + width, y + height);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Froms the rectangle.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rect">The rect.</param>
|
||||||
|
/// <returns>NativeMethods.RECT.</returns>
|
||||||
|
public static NativeMethods.RECT FromRectangle(Rectangle rect)
|
||||||
|
{
|
||||||
|
return new NativeMethods.RECT(rect.Left, rect.Top, rect.Right, rect.Bottom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Struct PAINTSTRUCT
|
||||||
|
/// </summary>
|
||||||
|
public struct PAINTSTRUCT
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The HDC
|
||||||
|
/// </summary>
|
||||||
|
public IntPtr hdc;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The f erase
|
||||||
|
/// </summary>
|
||||||
|
public int fErase;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The rc paint
|
||||||
|
/// </summary>
|
||||||
|
public NativeMethods.RECT rcPaint;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The f restore
|
||||||
|
/// </summary>
|
||||||
|
public int fRestore;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The f inc update
|
||||||
|
/// </summary>
|
||||||
|
public int fIncUpdate;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The reserved1
|
||||||
|
/// </summary>
|
||||||
|
public int Reserved1;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The reserved2
|
||||||
|
/// </summary>
|
||||||
|
public int Reserved2;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The reserved3
|
||||||
|
/// </summary>
|
||||||
|
public int Reserved3;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The reserved4
|
||||||
|
/// </summary>
|
||||||
|
public int Reserved4;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The reserved5
|
||||||
|
/// </summary>
|
||||||
|
public int Reserved5;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The reserved6
|
||||||
|
/// </summary>
|
||||||
|
public int Reserved6;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The reserved7
|
||||||
|
/// </summary>
|
||||||
|
public int Reserved7;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The reserved8
|
||||||
|
/// </summary>
|
||||||
|
public int Reserved8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Struct ComboBoxInfo
|
||||||
|
/// </summary>
|
||||||
|
public struct ComboBoxInfo
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The cb size
|
||||||
|
/// </summary>
|
||||||
|
public int cbSize;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The rc item
|
||||||
|
/// </summary>
|
||||||
|
public NativeMethods.RECT rcItem;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The rc button
|
||||||
|
/// </summary>
|
||||||
|
public NativeMethods.RECT rcButton;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The state button
|
||||||
|
/// </summary>
|
||||||
|
public NativeMethods.ComboBoxButtonState stateButton;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The HWND combo
|
||||||
|
/// </summary>
|
||||||
|
public IntPtr hwndCombo;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The HWND edit
|
||||||
|
/// </summary>
|
||||||
|
public IntPtr hwndEdit;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The HWND list
|
||||||
|
/// </summary>
|
||||||
|
public IntPtr hwndList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The wm paint
|
||||||
|
/// </summary>
|
||||||
|
public const int WM_PAINT = 15;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The wm setredraw
|
||||||
|
/// </summary>
|
||||||
|
public const int WM_SETREDRAW = 11;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The false
|
||||||
|
/// </summary>
|
||||||
|
public static readonly IntPtr FALSE = IntPtr.Zero;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The true
|
||||||
|
/// </summary>
|
||||||
|
public static readonly IntPtr TRUE = new IntPtr(1);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the ComboBox information.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hwndCombo">The HWND combo.</param>
|
||||||
|
/// <param name="info">The information.</param>
|
||||||
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern bool GetComboBoxInfo(IntPtr hwndCombo, ref NativeMethods.ComboBoxInfo info);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the window rect.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hwnd">The HWND.</param>
|
||||||
|
/// <param name="lpRect">The lp rect.</param>
|
||||||
|
/// <returns>System.Int32.</returns>
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern int GetWindowRect(IntPtr hwnd, ref NativeMethods.RECT lpRect);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Begins the paint.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hWnd">The h WND.</param>
|
||||||
|
/// <param name="ps">The ps.</param>
|
||||||
|
/// <returns>IntPtr.</returns>
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern IntPtr BeginPaint(IntPtr hWnd, ref NativeMethods.PAINTSTRUCT ps);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Ends the paint.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hWnd">The h WND.</param>
|
||||||
|
/// <param name="ps">The ps.</param>
|
||||||
|
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern bool EndPaint(IntPtr hWnd, ref NativeMethods.PAINTSTRUCT ps);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sends the message.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hWnd">The h WND.</param>
|
||||||
|
/// <param name="msg">The MSG.</param>
|
||||||
|
/// <param name="wParam">The w parameter.</param>
|
||||||
|
/// <param name="lParam">The l parameter.</param>
|
||||||
|
[DllImport("user32.dll")]
|
||||||
|
public static extern void SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Renderer interface for all
|
||||||
|
/// LBSoft.IndustrialCtrls renderer
|
||||||
|
/// </summary>
|
||||||
|
public interface ILBRenderer : IDisposable
|
||||||
|
{
|
||||||
|
object Control
|
||||||
|
{
|
||||||
|
set;
|
||||||
|
get;
|
||||||
|
}
|
||||||
|
bool Update();
|
||||||
|
void Draw(Graphics Gr);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class UCBlower.
|
||||||
|
/// Implements the <see cref="System.Windows.Forms.UserControl" />
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="System.Windows.Forms.UserControl" />
|
||||||
|
public class Blower : UserControl
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The entrance direction
|
||||||
|
/// </summary>
|
||||||
|
private BlowerEntranceDirection entranceDirection = BlowerEntranceDirection.None;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the entrance direction.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The entrance direction.</value>
|
||||||
|
[Description("入口方向"), Category("自定义")]
|
||||||
|
public BlowerEntranceDirection EntranceDirection
|
||||||
|
{
|
||||||
|
get { return entranceDirection; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
entranceDirection = value;
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The exit direction
|
||||||
|
/// </summary>
|
||||||
|
private BlowerExitDirection exitDirection = BlowerExitDirection.Right;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the exit direction.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The exit direction.</value>
|
||||||
|
[Description("出口方向"), Category("自定义")]
|
||||||
|
public BlowerExitDirection ExitDirection
|
||||||
|
{
|
||||||
|
get { return exitDirection; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
exitDirection = value;
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The blower color
|
||||||
|
/// </summary>
|
||||||
|
private Color blowerColor = Color.FromArgb(255, 77, 59);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the color of the blower.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The color of the blower.</value>
|
||||||
|
[Description("风机颜色"), Category("自定义")]
|
||||||
|
public Color BlowerColor
|
||||||
|
{
|
||||||
|
get { return blowerColor; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
blowerColor = value;
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The fan color
|
||||||
|
/// </summary>
|
||||||
|
private Color fanColor = Color.FromArgb(3, 169, 243);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the color of the fan.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The color of the fan.</value>
|
||||||
|
[Description("风叶颜色"), Category("自定义")]
|
||||||
|
public Color FanColor
|
||||||
|
{
|
||||||
|
get { return fanColor; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
fanColor = value;
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否显示底座
|
||||||
|
/// </summary>
|
||||||
|
private bool isDZ = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否显示底座
|
||||||
|
/// </summary>
|
||||||
|
/// <value>是否显示底座</value>
|
||||||
|
[Description("是否显示底座"), Category("自定义")]
|
||||||
|
public bool IsDZ
|
||||||
|
{
|
||||||
|
get { return isDZ; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
isDZ = value;
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The m rect working
|
||||||
|
/// </summary>
|
||||||
|
Rectangle m_rectWorking;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="Blower" /> class.
|
||||||
|
/// </summary>
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the SizeChanged event of the UCBlower control.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The source of the event.</param>
|
||||||
|
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||||
|
void UCBlower_SizeChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
int intMin = Math.Min(this.Width, this.Height);
|
||||||
|
m_rectWorking = new Rectangle((this.Width - (intMin / 2 * 2)) / 2, (this.Height - (intMin / 2 * 2)) / 2, (intMin / 2 * 2), (intMin / 2 * 2));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 引发 <see cref="E:System.Windows.Forms.Control.Paint" /> 事件。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">包含事件数据的 <see cref="T:System.Windows.Forms.PaintEventArgs" />。</param>
|
||||||
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnPaint(e);
|
||||||
|
var g = e.Graphics;
|
||||||
|
g.SetGDIHigh();
|
||||||
|
GraphicsPath pathLineIn = new GraphicsPath();
|
||||||
|
GraphicsPath pathLineOut = new GraphicsPath();
|
||||||
|
int intLinePenWidth = 0;
|
||||||
|
|
||||||
|
switch (exitDirection)
|
||||||
|
{
|
||||||
|
case BlowerExitDirection.Left:
|
||||||
|
g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(0, m_rectWorking.Top, this.Width / 2, m_rectWorking.Height / 2 - 5));
|
||||||
|
intLinePenWidth = m_rectWorking.Height / 2 - 5;
|
||||||
|
pathLineOut.AddLine(new Point(-10, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) / 2), new Point(m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) / 2));
|
||||||
|
g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(1, m_rectWorking.Top - 2), new Point(1, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) + 2));
|
||||||
|
break;
|
||||||
|
case BlowerExitDirection.Right:
|
||||||
|
g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(this.Width / 2, m_rectWorking.Top, this.Width / 2, m_rectWorking.Height / 2 - 5));
|
||||||
|
intLinePenWidth = m_rectWorking.Height / 2 - 5;
|
||||||
|
pathLineOut.AddLine(new Point(this.Width + 10, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) / 2), new Point(m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) / 2));
|
||||||
|
g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(this.Width - 2, m_rectWorking.Top - 2), new Point(this.Width - 2, m_rectWorking.Top + (m_rectWorking.Height / 2 - 5) + 2));
|
||||||
|
break;
|
||||||
|
case BlowerExitDirection.Up:
|
||||||
|
g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(m_rectWorking.Right - (m_rectWorking.Width / 2 - 5), 0, m_rectWorking.Width / 2 - 5, this.Height / 2));
|
||||||
|
intLinePenWidth = m_rectWorking.Width / 2 - 5;
|
||||||
|
pathLineOut.AddLine(new Point(m_rectWorking.Right - (m_rectWorking.Width / 2 - 5) / 2, -10), new Point(m_rectWorking.Right - (m_rectWorking.Width / 2 - 5) / 2, m_rectWorking.Top + m_rectWorking.Height / 2));
|
||||||
|
g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(m_rectWorking.Right + 2, 1), new Point(m_rectWorking.Right - (m_rectWorking.Width / 2 - 5) - 2, 1));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (entranceDirection)
|
||||||
|
{
|
||||||
|
case BlowerEntranceDirection.Left:
|
||||||
|
g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(0, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5, this.Width / 2, m_rectWorking.Height / 2 - 5));
|
||||||
|
pathLineIn.AddLine(new Point(-10, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) / 2), new Point(m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) / 2));
|
||||||
|
g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(1, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 - 2), new Point(1, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) + 2));
|
||||||
|
break;
|
||||||
|
case BlowerEntranceDirection.Right:
|
||||||
|
g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(this.Width / 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5, this.Width / 2, m_rectWorking.Height / 2 - 5));
|
||||||
|
pathLineIn.AddLine(new Point(this.Width + 10, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) / 2), new Point(m_rectWorking.Left + m_rectWorking.Width / 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) / 2));
|
||||||
|
g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(this.Width - 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 - 2), new Point(this.Width - 2, m_rectWorking.Bottom - m_rectWorking.Height / 2 + 5 + (m_rectWorking.Height / 2 - 5) + 2));
|
||||||
|
break;
|
||||||
|
case BlowerEntranceDirection.Up:
|
||||||
|
g.FillRectangle(new SolidBrush(blowerColor), new Rectangle(m_rectWorking.Left, 0, m_rectWorking.Width / 2 - 5, this.Height / 2));
|
||||||
|
pathLineIn.AddLine(new Point(m_rectWorking.Left + (m_rectWorking.Width / 2 - 5) / 2, -10), new Point(m_rectWorking.Left + (m_rectWorking.Width / 2 - 5) / 2, m_rectWorking.Top + m_rectWorking.Height / 2));
|
||||||
|
g.DrawLine(new Pen(new SolidBrush(blowerColor), 3), new Point(m_rectWorking.Left - 2, 1), new Point(m_rectWorking.Left + (m_rectWorking.Width / 2 - 5) + 2, 1));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//渐变色
|
||||||
|
int _intPenWidth = intLinePenWidth;
|
||||||
|
int intCount = _intPenWidth / 2 / 4;
|
||||||
|
for (int i = 0; i < intCount; i++)
|
||||||
|
{
|
||||||
|
int _penWidth = _intPenWidth / 2 - 4 * i;
|
||||||
|
if (_penWidth <= 0)
|
||||||
|
_penWidth = 1;
|
||||||
|
if (entranceDirection != BlowerEntranceDirection.None)
|
||||||
|
g.DrawPath(new Pen(new SolidBrush(Color.FromArgb(40, Color.White.R, Color.White.G, Color.White.B)), _penWidth), pathLineIn);
|
||||||
|
g.DrawPath(new Pen(new SolidBrush(Color.FromArgb(40, Color.White.R, Color.White.G, Color.White.B)), _penWidth), pathLineOut);
|
||||||
|
if (_penWidth == 1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
//底座
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Enum BlowerEntranceDirection
|
||||||
|
/// </summary>
|
||||||
|
public enum BlowerEntranceDirection
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The none
|
||||||
|
/// </summary>
|
||||||
|
None,
|
||||||
|
/// <summary>
|
||||||
|
/// The left
|
||||||
|
/// </summary>
|
||||||
|
Left,
|
||||||
|
/// <summary>
|
||||||
|
/// The right
|
||||||
|
/// </summary>
|
||||||
|
Right,
|
||||||
|
/// <summary>
|
||||||
|
/// Up
|
||||||
|
/// </summary>
|
||||||
|
Up
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Enum BlowerExitDirection
|
||||||
|
/// </summary>
|
||||||
|
public enum BlowerExitDirection
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The none
|
||||||
|
/// </summary>
|
||||||
|
None,
|
||||||
|
/// <summary>
|
||||||
|
/// The left
|
||||||
|
/// </summary>
|
||||||
|
Left,
|
||||||
|
/// <summary>
|
||||||
|
/// The right
|
||||||
|
/// </summary>
|
||||||
|
Right,
|
||||||
|
/// <summary>
|
||||||
|
/// Up
|
||||||
|
/// </summary>
|
||||||
|
Up
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 旋转方向
|
||||||
|
/// </summary>
|
||||||
|
public enum TurnAround
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 不旋转
|
||||||
|
/// </summary>
|
||||||
|
None,
|
||||||
|
/// <summary>
|
||||||
|
/// 顺时针
|
||||||
|
/// </summary>
|
||||||
|
Clockwise,
|
||||||
|
/// <summary>
|
||||||
|
/// 逆时针
|
||||||
|
/// </summary>
|
||||||
|
Counterclockwise
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="timer1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
|
||||||
|
namespace JYControl
|
||||||
|
{
|
||||||
|
partial class CircleCountValue
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 组件设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要修改
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
components = new System.ComponentModel.Container();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 圆形进度条实心
|
||||||
|
/// </summary>
|
||||||
|
public CircleCountValue()
|
||||||
|
{
|
||||||
|
InitControl();
|
||||||
|
this.SizeChanged += delegate
|
||||||
|
{
|
||||||
|
this.Invalidate(); //重绘控件
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxValue = 500000; //进度最大值
|
||||||
|
private int countValue = 0;
|
||||||
|
/// <summary>
|
||||||
|
/// 进度值
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
[Category("控件属性")]
|
||||||
|
[Description("进度值,最大值500000")]
|
||||||
|
public int CountValue
|
||||||
|
{
|
||||||
|
get { return this.countValue; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value > this.maxValue)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.countValue = value;
|
||||||
|
this.Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化控件参数
|
||||||
|
/// </summary>
|
||||||
|
private void InitControl()
|
||||||
|
{
|
||||||
|
this.Width = 200;
|
||||||
|
this.Height = 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
//对Control进行绘制
|
||||||
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
|
{
|
||||||
|
DrawShape(e.Graphics); //绘制控件样式
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 画图
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">画图工具类</param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 圆形进度条实心
|
||||||
|
/// </summary>
|
||||||
|
public CircleProgramBar()
|
||||||
|
{
|
||||||
|
InitControl();
|
||||||
|
this.SizeChanged += delegate
|
||||||
|
{
|
||||||
|
this.Invalidate(); //重绘控件
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxValue = 1000; //进度最大值
|
||||||
|
private int progress = 0;
|
||||||
|
/// <summary>
|
||||||
|
/// 进度值
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
[Category("控件属性")]
|
||||||
|
[Description("进度值,最大值1000")]
|
||||||
|
public int Progress
|
||||||
|
{
|
||||||
|
get { return this.progress; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value > this.maxValue)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.progress = value;
|
||||||
|
this.Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化控件参数
|
||||||
|
/// </summary>
|
||||||
|
private void InitControl()
|
||||||
|
{
|
||||||
|
this.Width = 200;
|
||||||
|
this.Height = 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
//对Control进行绘制
|
||||||
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
|
{
|
||||||
|
DrawShape(e.Graphics); //绘制控件样式
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 画图
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">画图工具类</param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
namespace JYControl
|
||||||
|
{
|
||||||
|
partial class IO_Instructions
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 组件设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要修改
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
|
After Width: | Height: | Size: 321 B |
|
After Width: | Height: | Size: 333 B |
|
After Width: | Height: | Size: 362 B |
|
After Width: | Height: | Size: 1009 B |
|
After Width: | Height: | Size: 1.2 KiB |
|
After Width: | Height: | Size: 878 B |
|
After Width: | Height: | Size: 494 B |
|
After Width: | Height: | Size: 1.9 KiB |
@@ -0,0 +1,167 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{01A2AA2C-9B80-41AA-9F47-3CB67E60AF24}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>JYControl</RootNamespace>
|
||||||
|
<AssemblyName>JY.Control</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>..\..\..\..\JY.Inspection\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Windows.Forms" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="Base\ButtonRenderer.cs" />
|
||||||
|
<Compile Include="Base\ColorMng.cs" />
|
||||||
|
<Compile Include="Base\ControlHelper.cs" />
|
||||||
|
<Compile Include="Base\LBIndustrialCtrlBase.cs">
|
||||||
|
<SubType>UserControl</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Base\LBIndustrialCtrlBase.Designer.cs">
|
||||||
|
<DependentUpon>LBIndustrialCtrlBase.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Base\LedRenderer.cs" />
|
||||||
|
<Compile Include="Base\NativeMethods.cs" />
|
||||||
|
<Compile Include="Base\Renderer.cs" />
|
||||||
|
<Compile Include="Blower.cs">
|
||||||
|
<SubType>UserControl</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="CircleProgramBar.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="CircleCountValue.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="CircleCountValue.Designer.cs">
|
||||||
|
<DependentUpon>CircleCountValue.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="IO_Instructions.cs">
|
||||||
|
<SubType>UserControl</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="IO_Instructions.Designer.cs">
|
||||||
|
<DependentUpon>IO_Instructions.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="LBButton.cs">
|
||||||
|
<SubType>UserControl</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="LBButton.Designer.cs">
|
||||||
|
<DependentUpon>LBButton.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="LBLed.cs">
|
||||||
|
<SubType>UserControl</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="LBLed.Designer.cs">
|
||||||
|
<DependentUpon>LBLed.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="LedControl.cs">
|
||||||
|
<SubType>UserControl</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="LedControl.Designer.cs">
|
||||||
|
<DependentUpon>LedControl.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="LogManagerControl.cs">
|
||||||
|
<SubType>UserControl</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="LogManagerControl.Designer.cs">
|
||||||
|
<DependentUpon>LogManagerControl.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs">
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="PulseButton.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="PulseButton.Designer.cs">
|
||||||
|
<DependentUpon>PulseButton.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="RingProgramBar.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="RoundButton.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="RoundButton.Designer.cs">
|
||||||
|
<DependentUpon>RoundButton.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="TextBoxWatermark.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="TreeViewEx.cs">
|
||||||
|
<SubType>Component</SubType>
|
||||||
|
</Compile>
|
||||||
|
<Compile Include="TreeViewEx.Designer.cs">
|
||||||
|
<DependentUpon>TreeViewEx.cs</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Include="Blower.resx">
|
||||||
|
<DependentUpon>Blower.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="IO_Instructions.resx">
|
||||||
|
<DependentUpon>IO_Instructions.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="LBLed.resx">
|
||||||
|
<DependentUpon>LBLed.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="LedControl.resx">
|
||||||
|
<DependentUpon>LedControl.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="LogManagerControl.resx">
|
||||||
|
<DependentUpon>LogManagerControl.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
<EmbeddedResource Include="TreeViewEx.resx">
|
||||||
|
<DependentUpon>TreeViewEx.cs</DependentUpon>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Content Include="Image\list_add.png" />
|
||||||
|
<Content Include="Image\list_subtract.png" />
|
||||||
|
<Content Include="Image\tips.png" />
|
||||||
|
<Content Include="Image\下载.png" />
|
||||||
|
<Content Include="Image\增加.png" />
|
||||||
|
<Content Include="Image\查询.png" />
|
||||||
|
<Content Include="Image\设置.png" />
|
||||||
|
<Content Include="Image\运行中.png" />
|
||||||
|
</ItemGroup>
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ProjectView>ProjectFiles</ProjectView>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
namespace JYControl
|
||||||
|
{
|
||||||
|
partial class LBButton
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 组件设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要修改
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
components = new System.ComponentModel.Container();
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Description of LBButton.
|
||||||
|
/// </summary>
|
||||||
|
public partial class LBButton : LBIndustrialCtrlBase
|
||||||
|
{
|
||||||
|
#region (* Enumeratives *)
|
||||||
|
/// <summary>
|
||||||
|
/// Button styles
|
||||||
|
/// </summary>
|
||||||
|
public enum ButtonStyle
|
||||||
|
{
|
||||||
|
Circular = 0,
|
||||||
|
Rectangular = 1,
|
||||||
|
Elliptical = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Button states
|
||||||
|
/// </summary>
|
||||||
|
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 *)
|
||||||
|
/// <summary>
|
||||||
|
/// Timer event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mouse down event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Mouse up event
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
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 *)
|
||||||
|
/// <summary>
|
||||||
|
/// Event for the state changed
|
||||||
|
/// </summary>
|
||||||
|
public event ButtonChangeState ButtonChangeState;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method for call the delagetes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
protected virtual void OnButtonChangeState(LBButtonEventArgs e)
|
||||||
|
{
|
||||||
|
if (this.ButtonChangeState != null)
|
||||||
|
this.ButtonChangeState(this, e);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Event for the repetition of state
|
||||||
|
/// </summary>
|
||||||
|
public event ButtonRepeatState ButtonRepeatState;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Method for call the delagetes
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
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 *)
|
||||||
|
/// <summary>
|
||||||
|
/// Class for events delegates
|
||||||
|
/// </summary>
|
||||||
|
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
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
namespace JYControl
|
||||||
|
{
|
||||||
|
partial class LBLed
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 组件设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要修改
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
this.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class for the Led control.
|
||||||
|
/// </summary>
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="tmrBlink.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
namespace JYControl
|
||||||
|
{
|
||||||
|
partial class LedControl
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 组件设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要修改
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// LedControl
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.Name = "LedControl";
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
@@ -0,0 +1,78 @@
|
|||||||
|
namespace JYControl
|
||||||
|
{
|
||||||
|
partial class LogManagerControl
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 组件设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要修改
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 双缓冲ListView ,解决闪烁
|
||||||
|
/// </summary>
|
||||||
|
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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
||||||
@@ -0,0 +1,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")]
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// <auto-generated>
|
||||||
|
// 此代码由工具生成。
|
||||||
|
// 运行时版本:4.0.30319.42000
|
||||||
|
//
|
||||||
|
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||||
|
// 重新生成代码,这些更改将会丢失。
|
||||||
|
// </auto-generated>
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace JYControl.Properties {
|
||||||
|
using System;
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
||||||
|
/// </summary>
|
||||||
|
// 此类是由 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() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 返回此类使用的缓存的 ResourceManager 实例。
|
||||||
|
/// </summary>
|
||||||
|
[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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重写当前线程的 CurrentUICulture 属性,对
|
||||||
|
/// 使用此强类型资源类的所有资源查找执行重写。
|
||||||
|
/// </summary>
|
||||||
|
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||||
|
internal static global::System.Globalization.CultureInfo Culture {
|
||||||
|
get {
|
||||||
|
return resourceCulture;
|
||||||
|
}
|
||||||
|
set {
|
||||||
|
resourceCulture = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap list_add {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("list_add", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap list_subtract {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("list_subtract", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap tips {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("tips", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap 下载 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("下载", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap 增加 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("增加", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap 查询 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("查询", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap 设置 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("设置", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
|
||||||
|
/// </summary>
|
||||||
|
internal static System.Drawing.Bitmap 运行中 {
|
||||||
|
get {
|
||||||
|
object obj = ResourceManager.GetObject("运行中", resourceCulture);
|
||||||
|
return ((System.Drawing.Bitmap)(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,145 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||||
|
<data name="list_add" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Image\list_add.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="list_subtract" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Image\list_subtract.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="tips" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Image\tips.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="下载" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Image\下载.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="增加" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Image\增加.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="查询" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Image\查询.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="设置" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Image\设置.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
<data name="运行中" type="System.Resources.ResXFileRef, System.Windows.Forms">
|
||||||
|
<value>..\Image\运行中.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
|
||||||
|
</data>
|
||||||
|
</root>
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
namespace JYControl
|
||||||
|
{
|
||||||
|
partial class PulseButton
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 组件设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要修改
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
components = new System.ComponentModel.Container();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 --
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the top button color.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The top button color.</value>
|
||||||
|
[Browsable(true), DefaultValue(typeof(Color), "CornflowerBlue")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public Color ButtonColorTop { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the bottom button color.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The bottom button color.</value>
|
||||||
|
[Browsable(true), DefaultValue(typeof(Color), "DodgerBlue")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public Color ButtonColorBottom { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the color of the pulse.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The color of the pulse.</value>
|
||||||
|
[Browsable(true), DefaultValue(typeof(Color), "Black")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public Color PulseColor { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the type of the shape.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The type of the shape.</value>
|
||||||
|
[Browsable(true), DefaultValue(typeof(Shape), "Round")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public Shape ShapeType { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the corner radius.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The corner radius.</value>
|
||||||
|
[Browsable(true), DefaultValue(10)]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public int CornerRadius { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the color of the focus.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The color of the focus.</value>
|
||||||
|
[Browsable(true), DefaultValue(typeof(Color), "Orange")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public Color FocusColor { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the foreground color of the control.
|
||||||
|
/// </summary>
|
||||||
|
/// <value></value>
|
||||||
|
/// <returns>
|
||||||
|
/// The foreground <see cref="T:System.Drawing.Color"/> of the control. The default is the value of the <see cref="P:System.Windows.Forms.Control.DefaultForeColor"/> property.
|
||||||
|
/// </returns>
|
||||||
|
/// <PermissionSet>
|
||||||
|
/// <IPermission class="System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" version="1" Unrestricted="true"/>
|
||||||
|
/// </PermissionSet>
|
||||||
|
[Browsable(true), DefaultValue(typeof(Color), "White")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public new Color ForeColor
|
||||||
|
{
|
||||||
|
get { return base.ForeColor; }
|
||||||
|
set { base.ForeColor = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the number of pulses.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The number of pulses.</value>
|
||||||
|
[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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the width of the pulse.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The width of the pulse.</value>
|
||||||
|
[Browsable(true), DefaultValue(10)]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public int PulseWidth
|
||||||
|
{
|
||||||
|
get { return pulseWidth; }
|
||||||
|
set { pulseWidth = value; ArrangePulses(); }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the wave speed.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The speed of the pulses.</value>
|
||||||
|
[Browsable(true), DefaultValue(typeof(float), "0.3f")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public float PulseSpeed
|
||||||
|
{
|
||||||
|
get { return pulseSpeed; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value <= 0) return;
|
||||||
|
pulseSpeed = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the interval.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The interval.</value>
|
||||||
|
[Browsable(false), DefaultValue(50)]
|
||||||
|
public int Interval
|
||||||
|
{
|
||||||
|
get { return pulseTimer.Interval; }
|
||||||
|
set { pulseTimer.Interval = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region -- Constructor --
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="PulseButton"/> class.
|
||||||
|
/// </summary>
|
||||||
|
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 --
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the pulse timer tick.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The sender.</param>
|
||||||
|
/// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
|
||||||
|
private void PulseTimerTick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
pulseTimer.Enabled = false;
|
||||||
|
InflatePulses();
|
||||||
|
Invalidate();
|
||||||
|
pulseTimer.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region -- Protected overrides --
|
||||||
|
|
||||||
|
#region - Mouse -
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the <see cref="E:System.Windows.Forms.Control.MouseUp"/> event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data.</param>
|
||||||
|
protected override void OnMouseUp(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseUp(e);
|
||||||
|
if (e.Button != MouseButtons.Left) return;
|
||||||
|
pressed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the <see cref="E:System.Windows.Forms.Control.MouseDown"/> event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data.</param>
|
||||||
|
protected override void OnMouseDown(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseDown(e);
|
||||||
|
if (e.Button != MouseButtons.Left) return;
|
||||||
|
pressed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the <see cref="M:System.Windows.Forms.Control.OnMouseMove(System.Windows.Forms.MouseEventArgs)"/> event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="mevent">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data.</param>
|
||||||
|
protected override void OnMouseMove(MouseEventArgs mevent)
|
||||||
|
{
|
||||||
|
base.OnMouseMove(mevent);
|
||||||
|
mouseOver = centerRect.Contains(mevent.Location);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the <see cref="JYControl.OnMouseLeave"/> event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">A <see cref="EventArgs"/> that contains the event data.</param>
|
||||||
|
protected override void OnMouseLeave(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseLeave(e);
|
||||||
|
mouseOver = false;
|
||||||
|
pressed = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the <see cref="E:System.Windows.Forms.Control.EnabledChanged"/> event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
|
||||||
|
protected override void OnEnabledChanged(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnEnabledChanged(e);
|
||||||
|
pulseTimer.Enabled = Enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the <see cref="E:System.Windows.Forms.Control.Resize"/> event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">An <see cref="T:System.EventArgs"/> that contains the event data.</param>
|
||||||
|
protected override void OnResize(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnResize(e);
|
||||||
|
if (pulses == null || pulses.Length == 0) return;
|
||||||
|
ArrangePulses();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the <see cref="E:System.Windows.Forms.Control.Paint"/> event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">A <see cref="T:System.Windows.Forms.PaintEventArgs"/> that contains the event data.</param>
|
||||||
|
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 --
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws the border.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">The graphics object</param>
|
||||||
|
protected virtual void DrawBorder(Graphics g)
|
||||||
|
{
|
||||||
|
using (var pen = new Pen(!Focused ? Color.FromArgb(60, Color.Black) : FocusColor, 2))
|
||||||
|
PaintShape(g, pen, centerRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws the center.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">The graphics object</param>
|
||||||
|
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);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws the pulses.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">The graphics object</param>
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws the text.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">The graphics object</param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws the reflex.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">The graphics object</param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Draws the high light.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">The graphics object</param>
|
||||||
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Paints the shape.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">The graphics object</param>
|
||||||
|
/// <param name="p">The pen</param>
|
||||||
|
/// <param name="rectangle">The rectangle.</param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Paints the shape.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">The graphics object</param>
|
||||||
|
/// <param name="b">The brush</param>
|
||||||
|
/// <param name="rectangle">The rectangle.</param>
|
||||||
|
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 --
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a path of a rectangle with round corners.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">The graphics object</param>
|
||||||
|
/// <param name="rect">The rectangle</param>
|
||||||
|
/// <param name="radius">The corner radius</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the placement.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="align">The alignment of the element</param>
|
||||||
|
/// <param name="rect">A retangle</param>
|
||||||
|
/// <param name="element">The element to be placed</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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 --
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Arranges the pulses.
|
||||||
|
/// </summary>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Inflates the pulses.
|
||||||
|
/// </summary>
|
||||||
|
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
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 圆形进度条实心
|
||||||
|
/// </summary>
|
||||||
|
public RingProgramBar()
|
||||||
|
{
|
||||||
|
InitControl();
|
||||||
|
this.SizeChanged += delegate
|
||||||
|
{
|
||||||
|
this.Invalidate(); //重绘控件
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
int maxValue = 100; //进度最大值
|
||||||
|
private int progress = 0;
|
||||||
|
/// <summary>
|
||||||
|
/// 进度值
|
||||||
|
/// </summary>
|
||||||
|
[Category("控件属性")]
|
||||||
|
[Description("进度值,最大值100")]
|
||||||
|
public int Progress
|
||||||
|
{
|
||||||
|
get { return this.progress; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value > this.maxValue)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.progress = value;
|
||||||
|
this.Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化控件参数
|
||||||
|
/// </summary>
|
||||||
|
private void InitControl()
|
||||||
|
{
|
||||||
|
this.Width = 200;
|
||||||
|
this.Height = 200;
|
||||||
|
}
|
||||||
|
|
||||||
|
//对Control进行绘制
|
||||||
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
|
{
|
||||||
|
DrawShape(e.Graphics); //绘制控件样式
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 画图
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">画图工具类</param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
namespace JYControl
|
||||||
|
{
|
||||||
|
partial class RoundButton
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 组件设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要修改
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
components = new System.ComponentModel.Container();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 形状
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置或获取圆形按钮的圆的边距离方框边的距离
|
||||||
|
/// </summary>
|
||||||
|
[Browsable(true), DefaultValue(2)]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public int DistanceToBorder { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 填充色
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置按钮主体颜色
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The color of the focus.</value>
|
||||||
|
[Browsable(true), DefaultValue(typeof(Color), "DodgerBlue"), Description("按钮主体渐变起始颜色")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public Color ButtonCenterColorEnd { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置按钮主体颜色
|
||||||
|
/// </summary>
|
||||||
|
[Browsable(true), DefaultValue(typeof(Color), "CornflowerBlue"), Description("按钮主体渐变终点颜色")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public Color ButtonCenterColorStart { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置按钮主体颜色渐变方向
|
||||||
|
/// </summary>
|
||||||
|
[Browsable(true), DefaultValue(90), Description("按钮主体颜色渐变方向,X轴顺时针开始")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public int GradientAngle { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否显示中间标志
|
||||||
|
/// </summary>
|
||||||
|
[Browsable(true), DefaultValue(typeof(bool), "true"), Description("是否显示中间标志")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public bool IsShowIcon { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 按钮中间标志填充色
|
||||||
|
/// </summary>
|
||||||
|
[Browsable(true), DefaultValue(typeof(Color), "Black"), Description("按钮中间标志填充色")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public Color IconColor { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 边框
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置边框大小
|
||||||
|
/// </summary>
|
||||||
|
[Browsable(true), DefaultValue(4), Description("按钮边框大小")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public int BorderWidth { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置按钮边框颜色
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The color of the focus.</value>
|
||||||
|
[Browsable(true), DefaultValue(typeof(Color), "Black"), Description("按钮边框颜色")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public Color BorderColor { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置边框透明度
|
||||||
|
/// </summary>
|
||||||
|
[Browsable(true), DefaultValue(200), Description("设置边框透明度:0-255")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public int BorderTransparent { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取或设置按钮获取焦点后边框颜色
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The color of the focus.</value>
|
||||||
|
[Browsable(true), DefaultValue(typeof(Color), "Orange"), Description("按钮获得焦点后的边框颜色")]
|
||||||
|
[Category("Appearance")]
|
||||||
|
public Color FocusBorderColor { get; set; }
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region --构造函数--
|
||||||
|
/// <summary>
|
||||||
|
/// 构造函数
|
||||||
|
/// </summary>
|
||||||
|
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事件
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 控件绘制
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pevent"></param>
|
||||||
|
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 鼠标
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 鼠标点击事件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
protected override void OnMouseClick(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseClick(e);
|
||||||
|
buttonClicked = !buttonClicked;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the <see cref="E:System.Windows.Forms.Control.MouseUp"/> event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data.</param>
|
||||||
|
protected override void OnMouseUp(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseUp(e);
|
||||||
|
if (e.Button != MouseButtons.Left) return;
|
||||||
|
buttonPressed = false;
|
||||||
|
base.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Raises the <see cref="E:System.Windows.Forms.Control.MouseDown"/> event.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e">A <see cref="T:System.Windows.Forms.MouseEventArgs"/> that contains the event data.</param>
|
||||||
|
protected override void OnMouseDown(MouseEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseDown(e);
|
||||||
|
if (e.Button != MouseButtons.Left) return;
|
||||||
|
buttonPressed = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 鼠标进入按钮
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
protected override void OnMouseEnter(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseEnter(e);
|
||||||
|
mouseEnter = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 鼠标离开控件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
protected override void OnMouseLeave(EventArgs e)
|
||||||
|
{
|
||||||
|
base.OnMouseLeave(e);
|
||||||
|
mouseEnter = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region --自定义函数--
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 绘制中心区域标志
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g"></param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 重新确定控件大小
|
||||||
|
/// </summary>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 绘制高亮效果
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">Graphic对象</param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 绘制边框
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">Graphics对象</param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">Graphic对象</param>
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 绘制图形
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">Graphics对象</param>
|
||||||
|
/// <param name="pen">Pen对象</param>
|
||||||
|
/// <param name="rect">RectangleF对象</param>
|
||||||
|
protected virtual void PaintShape(Graphics g, Pen pen, RectangleF rect)
|
||||||
|
{
|
||||||
|
g.DrawEllipse(pen, rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 绘制图形
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="g">Graphics对象</param>
|
||||||
|
/// <param name="brush">Brush对象</param>
|
||||||
|
/// <param name="rect">Rectangle对象</param>
|
||||||
|
protected virtual void PaintShape(Graphics g, Brush brush, RectangleF rect)
|
||||||
|
{
|
||||||
|
g.FillEllipse(brush, rect);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// TextBox添加水印文字
|
||||||
|
/// </summary>
|
||||||
|
[ToolboxBitmap(typeof(TextBox))]
|
||||||
|
|
||||||
|
public class WatermarkTextBox : TextBox
|
||||||
|
{
|
||||||
|
private string _watermark;
|
||||||
|
private Color _watermarkColor = Color.DarkGray;
|
||||||
|
private const int WM_PAINT = 0xF;
|
||||||
|
|
||||||
|
public WatermarkTextBox()
|
||||||
|
: base()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 输入需要显示水印文字
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
[Category("控件属性")]
|
||||||
|
[Description("输入需要显示水印文字")]
|
||||||
|
[DefaultValue("")]
|
||||||
|
public string Watermark
|
||||||
|
{
|
||||||
|
get { return _watermark; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_watermark = value;
|
||||||
|
base.Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 改变水印文字的颜色
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
[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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
namespace JYControl
|
||||||
|
{
|
||||||
|
partial class TreeViewEx
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 必需的设计器变量。
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理所有正在使用的资源。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 组件设计器生成的代码
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设计器支持所需的方法 - 不要修改
|
||||||
|
/// 使用代码编辑器修改此方法的内容。
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// TreeViewEx
|
||||||
|
//
|
||||||
|
this.Name = "NaviButton";
|
||||||
|
this.Size = new System.Drawing.Size(133, 57);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Class TreeViewEx.
|
||||||
|
/// Implements the <see cref="System.Windows.Forms.TreeView" />
|
||||||
|
/// </summary>
|
||||||
|
/// <seealso cref="System.Windows.Forms.TreeView" />
|
||||||
|
public partial class TreeViewEx : TreeView
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The ws vscroll
|
||||||
|
/// </summary>
|
||||||
|
private const int WS_VSCROLL = 2097152;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The GWL style
|
||||||
|
/// </summary>
|
||||||
|
private const int GWL_STYLE = -16;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The LST tips
|
||||||
|
/// </summary>
|
||||||
|
private Dictionary<string, string> _lstTips = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The tip font
|
||||||
|
/// </summary>
|
||||||
|
private Font _tipFont = new Font("Arial Unicode MS", 12f);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The tip image
|
||||||
|
/// </summary>
|
||||||
|
private Image _tipImage = JYControl.Properties.Resources.tips;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The is show tip
|
||||||
|
/// </summary>
|
||||||
|
private bool _isShowTip = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The is show by custom model
|
||||||
|
/// </summary>
|
||||||
|
private bool _isShowByCustomModel = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The node height
|
||||||
|
/// </summary>
|
||||||
|
private int _nodeHeight = 50;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The node down pic
|
||||||
|
/// </summary>
|
||||||
|
private Image _nodeDownPic = JYControl.Properties.Resources.list_add;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The node up pic
|
||||||
|
/// </summary>
|
||||||
|
private Image _nodeUpPic = JYControl.Properties.Resources.list_subtract;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The node background color
|
||||||
|
/// </summary>
|
||||||
|
private Color _nodeBackgroundColor = Color.White;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The node fore color
|
||||||
|
/// </summary>
|
||||||
|
private Color _nodeForeColor = Color.FromArgb(62, 62, 62);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The node is show split line
|
||||||
|
/// </summary>
|
||||||
|
private bool _nodeIsShowSplitLine = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The node split line color
|
||||||
|
/// </summary>
|
||||||
|
private Color _nodeSplitLineColor = Color.FromArgb(232, 232, 232);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The m node selected color
|
||||||
|
/// </summary>
|
||||||
|
private Color m_nodeSelectedColor = Color.FromArgb(255, 77, 59);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The m node selected fore color
|
||||||
|
/// </summary>
|
||||||
|
private Color m_nodeSelectedForeColor = Color.White;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The parent node can select
|
||||||
|
/// </summary>
|
||||||
|
private bool _parentNodeCanSelect = true;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The tree font size
|
||||||
|
/// </summary>
|
||||||
|
private SizeF treeFontSize = SizeF.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The BLN has v bar
|
||||||
|
/// </summary>
|
||||||
|
private bool blnHasVBar = false;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the LST tips.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The LST tips.</value>
|
||||||
|
public Dictionary<string, string> LstTips
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._lstTips;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._lstTips = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the tip font.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The tip font.</value>
|
||||||
|
[Category("自定义属性"), Description("角标文字字体")]
|
||||||
|
public Font TipFont
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._tipFont;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._tipFont = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the tip image.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The tip image.</value>
|
||||||
|
[Category("自定义属性"), Description("是否显示角标")]
|
||||||
|
public Image TipImage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._tipImage;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._tipImage = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether this instance is show tip.
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if this instance is show tip; otherwise, <c>false</c>.</value>
|
||||||
|
[Category("自定义属性"), Description("是否显示角标")]
|
||||||
|
public bool IsShowTip
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._isShowTip;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._isShowTip = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether this instance is show by custom model.
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if this instance is show by custom model; otherwise, <c>false</c>.</value>
|
||||||
|
[Category("自定义属性"), Description("使用自定义模式")]
|
||||||
|
public bool IsShowByCustomModel
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._isShowByCustomModel;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._isShowByCustomModel = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the height of the node.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The height of the node.</value>
|
||||||
|
[Category("自定义属性"), Description("节点高度(IsShowByCustomModel=true时生效)")]
|
||||||
|
public int NodeHeight
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._nodeHeight;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._nodeHeight = value;
|
||||||
|
base.ItemHeight = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the node down pic.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The node down pic.</value>
|
||||||
|
[Category("自定义属性"), Description("下翻图标(IsShowByCustomModel=true时生效)")]
|
||||||
|
public Image NodeDownPic
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._nodeDownPic;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._nodeDownPic = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the node up pic.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The node up pic.</value>
|
||||||
|
[Category("自定义属性"), Description("上翻图标(IsShowByCustomModel=true时生效)")]
|
||||||
|
public Image NodeUpPic
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._nodeUpPic;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._nodeUpPic = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the color of the node background.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The color of the node background.</value>
|
||||||
|
[Category("自定义属性"), Description("节点背景颜色(IsShowByCustomModel=true时生效)")]
|
||||||
|
public Color NodeBackgroundColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._nodeBackgroundColor;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._nodeBackgroundColor = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the color of the node fore.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The color of the node fore.</value>
|
||||||
|
[Category("自定义属性"), Description("节点字体颜色(IsShowByCustomModel=true时生效)")]
|
||||||
|
public Color NodeForeColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._nodeForeColor;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._nodeForeColor = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether [node is show split line].
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if [node is show split line]; otherwise, <c>false</c>.</value>
|
||||||
|
[Category("自定义属性"), Description("节点是否显示分割线(IsShowByCustomModel=true时生效)")]
|
||||||
|
public bool NodeIsShowSplitLine
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._nodeIsShowSplitLine;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._nodeIsShowSplitLine = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the color of the node split line.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The color of the node split line.</value>
|
||||||
|
[Category("自定义属性"), Description("节点分割线颜色(IsShowByCustomModel=true时生效)")]
|
||||||
|
public Color NodeSplitLineColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._nodeSplitLineColor;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._nodeSplitLineColor = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the color of the node selected.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The color of the node selected.</value>
|
||||||
|
[Category("自定义属性"), Description("选中节点背景颜色(IsShowByCustomModel=true时生效)")]
|
||||||
|
public Color NodeSelectedColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.m_nodeSelectedColor;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.m_nodeSelectedColor = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets the color of the node selected fore.
|
||||||
|
/// </summary>
|
||||||
|
/// <value>The color of the node selected fore.</value>
|
||||||
|
[Category("自定义属性"), Description("选中节点字体颜色(IsShowByCustomModel=true时生效)")]
|
||||||
|
public Color NodeSelectedForeColor
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this.m_nodeSelectedForeColor;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this.m_nodeSelectedForeColor = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets or sets a value indicating whether [parent node can select].
|
||||||
|
/// </summary>
|
||||||
|
/// <value><c>true</c> if [parent node can select]; otherwise, <c>false</c>.</value>
|
||||||
|
[Category("自定义属性"), Description("父节点是否可选中")]
|
||||||
|
public bool ParentNodeCanSelect
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return this._parentNodeCanSelect;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
this._parentNodeCanSelect = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the <see cref="TreeViewEx" /> class.
|
||||||
|
/// </summary>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 重写 <see cref="M:System.Windows.Forms.Control.WndProc(System.Windows.Forms.Message@)" />。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="m">要处理的 Windows<see cref="T:System.Windows.Forms.Message" />。</param>
|
||||||
|
protected override void WndProc(ref Message m)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (m.Msg == 0x0014) // 禁掉清除背景消息WM_ERASEBKGND
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
|
base.WndProc(ref m);
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the AfterSelect event of the TreeViewEx control.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The source of the event.</param>
|
||||||
|
/// <param name="e">The <see cref="TreeViewEventArgs" /> instance containing the event data.</param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the SizeChanged event of the TreeViewEx control.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The source of the event.</param>
|
||||||
|
/// <param name="e">The <see cref="EventArgs" /> instance containing the event data.</param>
|
||||||
|
private void TreeViewEx_SizeChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.Refresh();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the NodeMouseClick event of the TreeViewEx control.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The source of the event.</param>
|
||||||
|
/// <param name="e">The <see cref="TreeNodeMouseClickEventArgs" /> instance containing the event data.</param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles the DrawNode event of the treeview control.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender">The source of the event.</param>
|
||||||
|
/// <param name="e">The <see cref="DrawTreeNodeEventArgs" /> instance containing the event data.</param>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the size of the font.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="font">The font.</param>
|
||||||
|
/// <param name="g">The g.</param>
|
||||||
|
/// <returns>SizeF.</returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the window long.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hwnd">The HWND.</param>
|
||||||
|
/// <param name="nIndex">Index of the n.</param>
|
||||||
|
/// <returns>System.Int32.</returns>
|
||||||
|
[DllImport("user32", CharSet = CharSet.Auto)]
|
||||||
|
private static extern int GetWindowLong(IntPtr hwnd, int nIndex);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determines whether [is vertical scroll bar visible].
|
||||||
|
/// </summary>
|
||||||
|
/// <returns><c>true</c> if [is vertical scroll bar visible]; otherwise, <c>false</c>.</returns>
|
||||||
|
private bool IsVerticalScrollBarVisible()
|
||||||
|
{
|
||||||
|
return base.IsHandleCreated && (TreeViewEx.GetWindowLong(base.Handle, -16) & 2097152) != 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="$this.TrayLargeIcon" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>False</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 保存报警数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="m"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
int AddAlarmData(AlarmData m);
|
||||||
|
/// <summary>
|
||||||
|
/// 缓存报警数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="m"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
///
|
||||||
|
int AddAlarmCacheData(string tablename, List<AlarmData> m);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询缓存表报警信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate1">开始时间</param>
|
||||||
|
/// <param name="strDate2">结束时间</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<AlarmData> GetAlarmCacheData();
|
||||||
|
/// <summary>
|
||||||
|
/// 删除未更新数据
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
int DeleteAlarmCacheData();
|
||||||
|
/// <summary>
|
||||||
|
/// 查询报警信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate1">开始时间</param>
|
||||||
|
/// <param name="strDate2">结束时间</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<AlarmData> GetAlarmData(string strDate1, string strDate2);
|
||||||
|
/// <summary>
|
||||||
|
/// 查询进站信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strCode"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<FeedingData> GetFeedingData(string strCode);
|
||||||
|
/// <summary>
|
||||||
|
/// 新增产品型号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">机型信息</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
int AddProductModel(ProductModel entity);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除本地型号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modeltype">型号</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
void DelProductModel(string modeltype);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取产品型号列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strProdType">产品型号</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<ProductModel> GetProductModelList(string strProdType = "");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存产品类型配置参数
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool AddProductParaList(List<ProductPara> list);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取产品参数通过产品型号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strModelType">产品型号</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<ProductPara> GetProductParaByProdModel(string strModelType);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标准轴参数保存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dt"></param>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <param name="strErr"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool InsertPLCConfigBase(List<PLCConfigBase> list);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取换型操作的基本参数
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<PLCConfigBase> GetPLCConfigBases();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取PLC换型参数绑定值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modelName">产品型号</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<PLCConfigPara> GetPLCConfigPara(string modelName);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 具体型号轴参数保存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dt"></param>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <param name="strErr"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool InsertPLCConfigParam(List<PLCConfigPara> list);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询历史数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strBarCode"></param>
|
||||||
|
/// <param name="strDate1"></param>
|
||||||
|
/// <param name="strDate2"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
DataTable GetTestData(int type,string strBarCode, string strDate1, string strDate2, string flag);
|
||||||
|
/// <summary>
|
||||||
|
/// 查询历史数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strBarCode"></param>
|
||||||
|
/// <param name="resultType"></param>
|
||||||
|
/// <param name="strDate1"></param>
|
||||||
|
/// <param name="strDate2"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
DataTable GetTestData2(int type,int resultType, string strBarCode, string strDate1, string strDate2, string flag);
|
||||||
|
/// <summary>
|
||||||
|
/// 查询CCD历史数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strWorkerNum"></param>
|
||||||
|
/// <param name="strDate1"></param>
|
||||||
|
/// <param name="strDate2"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
DataTable GetCCDData(string strWorkerNum, string strDate1, string strDate2);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询CCD历史数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strWorkerNum"></param>
|
||||||
|
/// <param name="strDate1"></param>
|
||||||
|
/// <param name="strDate2"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
DataTable GetBarInTime(string strBar);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新获取进站时间状态
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strBar"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
int UparInTime(string strBar);
|
||||||
|
/// <summary>
|
||||||
|
/// 按日期查询和时间查询投入产出信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate"></param>
|
||||||
|
/// <param name="Hour"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<HourprodEntity> GetProdTotal(string strDate, int Hour);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新指定时间的小时产出
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="enity">小时产出数据</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
int UpdateHourprodData(HourprodEntity enity);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存进托盘数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="m"></param>
|
||||||
|
/// <param name="strErr"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
int AddInPutTrayID(TrayTestEntry m, ref string strErr);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存空托盘排出数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="m"></param>
|
||||||
|
/// <param name="strErr"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
int AddOutTrayID(TrayTestEntry m, ref string strErr);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存上料数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="m"></param>
|
||||||
|
/// <param name="strErr"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
int AddFeedingData(FeedingData m, ref string strErr);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存下料数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="m"></param>
|
||||||
|
/// <param name="strErr"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
int AddBlankingData(BlankingData m, ref string strErr);
|
||||||
|
int AddCamInforData(CamInfor m, ref string strErr);
|
||||||
|
/// <summary>
|
||||||
|
/// 根据工位编码获取异常播报内容
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="code"></param>
|
||||||
|
/// <param name="needInsert">如果没有找到记录,是否需要插入</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
string GetAbnormalVoice(string code, bool needInsert = false);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<IRepository<BlankingData>, Repository<BlankingData>>();
|
||||||
|
|
||||||
|
services.AddScoped<IAlarmDataService, AlarmDataService>();
|
||||||
|
services.AddScoped<IBlankingDataService, BlankingDataService>();
|
||||||
|
services.AddScoped<IFeedingDataService, FeedingDataService>();
|
||||||
|
|
||||||
|
Provider = services.BuildServiceProvider();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<Import Project="..\packages\SixLabors.ImageSharp.3.1.11\build\SixLabors.ImageSharp.props" Condition="Exists('..\packages\SixLabors.ImageSharp.3.1.11\build\SixLabors.ImageSharp.props')" />
|
||||||
|
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||||
|
<PropertyGroup>
|
||||||
|
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||||
|
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||||
|
<ProjectGuid>{D5889580-58F9-467E-87D3-EFA37A300E67}</ProjectGuid>
|
||||||
|
<OutputType>Library</OutputType>
|
||||||
|
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||||
|
<RootNamespace>JY.DAL</RootNamespace>
|
||||||
|
<AssemblyName>JY.DAL</AssemblyName>
|
||||||
|
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
||||||
|
<FileAlignment>512</FileAlignment>
|
||||||
|
<Deterministic>true</Deterministic>
|
||||||
|
<TargetFrameworkProfile />
|
||||||
|
<NuGetPackageImportStamp>
|
||||||
|
</NuGetPackageImportStamp>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
||||||
|
<DebugSymbols>true</DebugSymbols>
|
||||||
|
<DebugType>full</DebugType>
|
||||||
|
<Optimize>false</Optimize>
|
||||||
|
<OutputPath>..\..\..\..\JY.Inspection\</OutputPath>
|
||||||
|
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
||||||
|
<DebugType>pdbonly</DebugType>
|
||||||
|
<Optimize>true</Optimize>
|
||||||
|
<OutputPath>bin\Release\</OutputPath>
|
||||||
|
<DefineConstants>TRACE</DefineConstants>
|
||||||
|
<ErrorReport>prompt</ErrorReport>
|
||||||
|
<WarningLevel>4</WarningLevel>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Reference Include="BouncyCastle.Cryptography, Version=2.0.0.0, Culture=neutral, PublicKeyToken=072edcf4a5328938, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\BouncyCastle.Cryptography.2.4.0\lib\net461\BouncyCastle.Cryptography.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="CsvHelper, Version=30.0.0.0, Culture=neutral, PublicKeyToken=8c4959082be5c823, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\CsvHelper.30.0.1\lib\net45\CsvHelper.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Dapper, Version=1.60.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Dapper.1.60.6\lib\net451\Dapper.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Enums.NET, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7ea1c1650d506225, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Enums.NET.5.0.0\lib\net461\Enums.NET.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="EPPlus, Version=8.0.8.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\EPPlus.8.0.8\lib\net462\EPPlus.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="EPPlus.Interfaces, Version=8.0.0.0, Culture=neutral, PublicKeyToken=a694d7f3b0907a61, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\EPPlus.Interfaces.8.0.0\lib\net462\EPPlus.Interfaces.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="ExtendedNumerics.BigDecimal, Version=2025.1001.2.129, Culture=neutral, PublicKeyToken=65f1315a45ad8949, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\ExtendedNumerics.BigDecimal.2025.1001.2.129\lib\net48\ExtendedNumerics.BigDecimal.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="ICSharpCode.SharpZipLib, Version=1.4.2.13, Culture=neutral, PublicKeyToken=1b03e6acf1164f73, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\SharpZipLib.1.4.2\lib\netstandard2.0\ICSharpCode.SharpZipLib.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="MathNet.Numerics, Version=5.0.0.0, Culture=neutral, PublicKeyToken=cd8b63ad3d691a37, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\MathNet.Numerics.Signed.5.0.0\lib\net48\MathNet.Numerics.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Bcl.AsyncInterfaces, Version=10.0.0.9, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.Bcl.AsyncInterfaces.10.0.9\lib\net462\Microsoft.Bcl.AsyncInterfaces.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.DependencyInjection, Version=10.0.0.9, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.10.0.9\lib\net462\Microsoft.Extensions.DependencyInjection.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Extensions.DependencyInjection.Abstractions, Version=10.0.0.9, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.Extensions.DependencyInjection.Abstractions.10.0.9\lib\net462\Microsoft.Extensions.DependencyInjection.Abstractions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.IO.RecyclableMemoryStream, Version=3.0.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.IO.RecyclableMemoryStream.3.0.1\lib\netstandard2.0\Microsoft.IO.RecyclableMemoryStream.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Microsoft.Owin, Version=4.2.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Microsoft.Owin.4.2.3\lib\net45\Microsoft.Owin.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="MySql.Data, Version=6.10.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\MySql.Data.6.10.9\lib\net452\MySql.Data.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="NPOI.Core, Version=2.7.4.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\NPOI.2.7.4\lib\net472\NPOI.Core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="NPOI.OOXML, Version=2.7.4.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\NPOI.2.7.4\lib\net472\NPOI.OOXML.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="NPOI.OpenXml4Net, Version=2.7.4.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\NPOI.2.7.4\lib\net472\NPOI.OpenXml4Net.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="NPOI.OpenXmlFormats, Version=2.7.4.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\NPOI.2.7.4\lib\net472\NPOI.OpenXmlFormats.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="Owin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=f0ebd12fd5e55cc5, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\Owin.1.0\lib\net40\Owin.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="PresentationCore" />
|
||||||
|
<Reference Include="SixLabors.Fonts, Version=1.0.0.0, Culture=neutral, PublicKeyToken=d998eea7b14cab13, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\SixLabors.Fonts.1.0.1\lib\netstandard2.0\SixLabors.Fonts.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="SqlSugar, Version=5.1.4.207, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\SqlSugar.5.1.4.207\lib\SqlSugar.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System" />
|
||||||
|
<Reference Include="System.Buffers, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Buffers.4.5.1\lib\net461\System.Buffers.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ComponentModel" />
|
||||||
|
<Reference Include="System.ComponentModel.Annotations, Version=4.2.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.ComponentModel.Annotations.5.0.0\lib\net461\System.ComponentModel.Annotations.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.ComponentModel.Composition" />
|
||||||
|
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||||
|
<Reference Include="System.Configuration" />
|
||||||
|
<Reference Include="System.Configuration.Install" />
|
||||||
|
<Reference Include="System.Core" />
|
||||||
|
<Reference Include="System.Drawing" />
|
||||||
|
<Reference Include="System.Drawing.Design" />
|
||||||
|
<Reference Include="System.Management" />
|
||||||
|
<Reference Include="System.Memory, Version=4.0.1.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Memory.4.5.5\lib\net461\System.Memory.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Numerics" />
|
||||||
|
<Reference Include="System.Numerics.Vectors, Version=4.1.4.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Numerics.Vectors.4.5.0\lib\net46\System.Numerics.Vectors.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Runtime.CompilerServices.Unsafe, Version=6.0.3.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Runtime.CompilerServices.Unsafe.6.1.2\lib\net462\System.Runtime.CompilerServices.Unsafe.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Security" />
|
||||||
|
<Reference Include="System.Security.Cryptography.Xml, Version=8.0.0.2, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Security.Cryptography.Xml.8.0.2\lib\net462\System.Security.Cryptography.Xml.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Text.Encoding.CodePages, Version=9.0.0.7, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Text.Encoding.CodePages.9.0.7\lib\net462\System.Text.Encoding.CodePages.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Threading.Tasks.Extensions, Version=4.2.4.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.Threading.Tasks.Extensions.4.6.3\lib\net462\System.Threading.Tasks.Extensions.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Transactions" />
|
||||||
|
<Reference Include="System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="System.Web" />
|
||||||
|
<Reference Include="System.Xml.Linq" />
|
||||||
|
<Reference Include="System.Data.DataSetExtensions" />
|
||||||
|
<Reference Include="Microsoft.CSharp" />
|
||||||
|
<Reference Include="System.Data" />
|
||||||
|
<Reference Include="System.Net.Http" />
|
||||||
|
<Reference Include="System.Xml" />
|
||||||
|
<Reference Include="ZString, Version=2.6.0.0, Culture=neutral, PublicKeyToken=df4c250b14d82627, processorArchitecture=MSIL">
|
||||||
|
<HintPath>..\packages\ZString.2.6.0\lib\netstandard2.0\ZString.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="IDbHelper.cs" />
|
||||||
|
<Compile Include="IocConfig.cs" />
|
||||||
|
<Compile Include="Service\BlankingDataService.cs" />
|
||||||
|
<Compile Include="SqlHelper.cs" />
|
||||||
|
<Compile Include="MySqlHelper.cs" />
|
||||||
|
<Compile Include="OpSqlDataBase.cs" />
|
||||||
|
<Compile Include="OpMysqlDataBase.cs" />
|
||||||
|
<Compile Include="ServiceLocator.cs" />
|
||||||
|
<Compile Include="Repository\DataContext.cs" />
|
||||||
|
<Compile Include="Repository\IRepository.cs" />
|
||||||
|
<Compile Include="Repository\Repository.cs" />
|
||||||
|
<Compile Include="Service\IService.cs" />
|
||||||
|
<Compile Include="Service\Service.cs" />
|
||||||
|
<Compile Include="Service\AlarmDataService.cs" />
|
||||||
|
<Compile Include="Service\FeedingDataService.cs" />
|
||||||
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<None Include="app.config" />
|
||||||
|
<None Include="packages.config" />
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\JY.Model\JY.Model.csproj">
|
||||||
|
<Project>{f7db3a93-fca2-479b-8b2e-380116aae9fc}</Project>
|
||||||
|
<Name>JY.Model</Name>
|
||||||
|
</ProjectReference>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup />
|
||||||
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
|
||||||
|
</PropertyGroup>
|
||||||
|
<Error Condition="!Exists('..\packages\SixLabors.ImageSharp.3.1.11\build\SixLabors.ImageSharp.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\SixLabors.ImageSharp.3.1.11\build\SixLabors.ImageSharp.props'))" />
|
||||||
|
</Target>
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<PropertyGroup>
|
||||||
|
<ProjectView>ProjectFiles</ProjectView>
|
||||||
|
</PropertyGroup>
|
||||||
|
</Project>
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ProdModel表映射,实体名和表名不一样实现映射
|
||||||
|
/// </summary>
|
||||||
|
public class AlarmDataMapping : ClassMapper<AlarmData>
|
||||||
|
{
|
||||||
|
public AlarmDataMapping()
|
||||||
|
{
|
||||||
|
Table("tb_alarm");
|
||||||
|
AutoMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// ProdModel表映射,实体名和表名不一样实现映射
|
||||||
|
/// </summary>
|
||||||
|
public class ProductModelMapping : ClassMapper<ProductModel>
|
||||||
|
{
|
||||||
|
public ProductModelMapping()
|
||||||
|
{
|
||||||
|
Table("tb_ProdModel");
|
||||||
|
AutoMap();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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<T> where T : class
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 数据库连接字符串
|
||||||
|
/// </summary>
|
||||||
|
private static readonly string connectionString = ConfigurationManager.ConnectionStrings["MysqlConn"].ConnectionString;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql">查询的sql</param>
|
||||||
|
/// <param name="param">替换参数</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<T> Query(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (MySqlConnection con = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.Query<T>(sql, param).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询第一个数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T QueryFirst(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (MySqlConnection con = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.QueryFirst<T>(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询第一个数据没有返回默认值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T QueryFirstOrDefault(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (MySqlConnection con = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.QueryFirstOrDefault<T>(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询单条数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T QuerySingle(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (MySqlConnection con = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.QuerySingle<T>(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询单条数据没有返回默认值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T QuerySingleOrDefault(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (MySqlConnection con = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.QuerySingleOrDefault<T>(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 增删改
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns>Number of rows affected</returns>
|
||||||
|
public static int Execute(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (MySqlConnection con = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.Execute(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reader获取数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IDataReader ExecuteReader(string sql, object param)
|
||||||
|
{
|
||||||
|
using (MySqlConnection con = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.ExecuteReader(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取数据返回DataTable
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Scalar获取数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static object ExecuteScalar(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (MySqlConnection con = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.ExecuteScalar(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Scalar获取数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T ExecuteScalarForT(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (MySqlConnection con = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.ExecuteScalar<T>(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 带参数的存储过程
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<T> ExecutePro(string proc, object param = null)
|
||||||
|
{
|
||||||
|
using (MySqlConnection con = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
List<T> list = con.Query<T>(proc,
|
||||||
|
param,
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
null,
|
||||||
|
CommandType.StoredProcedure).ToList();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 批量插入T数据,返回影响行数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="list">对象集合</param>
|
||||||
|
/// <returns>影响行数</returns>
|
||||||
|
public static int Insert(string strsql, List<T> list)
|
||||||
|
{
|
||||||
|
using (IDbConnection connection = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
//return connection.Execute("insert into Person(Name,Remark) values(@Name,@Remark)", list);
|
||||||
|
return connection.Execute(strsql, list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 事务1 - 全SQL
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sqlarr">多条SQL</param>
|
||||||
|
/// <param name="param">param</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 事务2 - 声明参数
|
||||||
|
///demo:
|
||||||
|
///dic.Add("Insert into Users values (@UserName, @Email, @Address)",
|
||||||
|
/// new { UserName = "jack", Email = "380234234@qq.com", Address = "上海" });
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Key">多条SQL</param>
|
||||||
|
/// <param name="Value">param</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int ExecuteTransaction(Dictionary<string, object> 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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class OpMysqlDataBase : IDbHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 保存报警数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="m"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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<AlarmData>.Execute(strSql);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除未更新数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate1">开始时间</param>
|
||||||
|
/// <param name="strDate2">结束时间</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int DeleteAlarmCacheData()
|
||||||
|
{
|
||||||
|
string strSql = $@"DELETE FROM tb_alarm WHERE Flag=0";
|
||||||
|
int result = MySqlHelper<object>.Execute(strSql);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 查询报警信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate1">开始时间</param>
|
||||||
|
/// <param name="strDate2">结束时间</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<AlarmData> GetAlarmData(string strDate1, string strDate2)
|
||||||
|
{
|
||||||
|
string strSql = $@" SELECT PLCAdress ,AlarmContent,AlarmCode,AlarmTime,StartUpTime ,BurningTime
|
||||||
|
FROM tb_alarm where AlarmTime >= '{ strDate1 }' and AlarmTime <= '{ strDate2 }' ";
|
||||||
|
var list = MySqlHelper<AlarmData>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询进站信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strCode"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<FeedingData> GetFeedingData(string strCode)
|
||||||
|
{
|
||||||
|
string strSql = $@" SELECT * FROM FeedingData where BarCode = '{strCode}' ORDER BY CreateTime";
|
||||||
|
var list = SqlHelper<FeedingData>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增产品型号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">机型信息</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int AddProductModel(ProductModel entity)
|
||||||
|
{
|
||||||
|
string strSql = $@"INSERT INTO `tb_productmodel`(`ModelName`, `Remark`)
|
||||||
|
VALUES ('{entity.ModelName}', '{entity.Remark}')";
|
||||||
|
int result = MySqlHelper<object>.Execute(strSql);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除本地型号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modeltype">型号</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public void DelProductModel(string modeltype)
|
||||||
|
{
|
||||||
|
string strSql = $"delete from tb_productmodel where ModelName='{modeltype}'";
|
||||||
|
MySqlHelper<object>.Execute(strSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取产品型号列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strProdType">产品型号</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<ProductModel> GetProductModelList(string strProdType = "")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string strSql = @"SELECT * FROM `tb_productmodel` ";
|
||||||
|
if (strProdType != "")
|
||||||
|
{
|
||||||
|
strSql += string.Format(" where ModelName='{0}'", strProdType);
|
||||||
|
}
|
||||||
|
strSql += " order by ModelName";
|
||||||
|
var list = MySqlHelper<ProductModel>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存产品类型配置参数
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool AddProductParaList(List<ProductPara> list)
|
||||||
|
{
|
||||||
|
List<string> listSql = new List<string>();
|
||||||
|
listSql.Add($@"delete from tb_paralist where ModelName='{list[0].ModelName}'");
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
listSql.Add($@"INSERT INTO `tb_paralist`(`ModelName`, `ParaName`, `ParaValue`, `Remark`, `UpdateTime`)
|
||||||
|
VALUES ('{item.ModelName}', '{item.ParaName}', '{item.ParaValue}', '{item.Remark}', '{item.UpdateTime}')");
|
||||||
|
}
|
||||||
|
var result = MySqlHelper<object>.ExecuteTransaction(listSql.ToArray());
|
||||||
|
|
||||||
|
if (result > 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取产品参数通过产品型号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strModelType">产品型号</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<ProductPara> GetProductParaByProdModel(string strModelType)
|
||||||
|
{
|
||||||
|
string strSql = $@"SELECT pb.ParaName, '{strModelType}' ModelName,pl.ParaValue,pl.Remark,pl.UpdateTime
|
||||||
|
FROM tb_parabase pb
|
||||||
|
left join (select * from tb_paralist where ModelName = '{strModelType}' ) as pl
|
||||||
|
on pb.ParaName = pl.ParaName; ";
|
||||||
|
|
||||||
|
var list = MySqlHelper<ProductPara>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标准轴参数保存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dt"></param>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <param name="strErr"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool InsertPLCConfigBase(List<PLCConfigBase> list)
|
||||||
|
{
|
||||||
|
List<string> listSql = new List<string>();
|
||||||
|
listSql.Add("delete from tb_plcconfigbase;");
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
listSql.Add($@"Insert into tb_plcconfigbase (PLCAddress,PLCRemark,OrderNum)
|
||||||
|
Values ('{item.PLCAddress}','{item.PLCRemark}',{item.OrderNum});");
|
||||||
|
}
|
||||||
|
var result = MySqlHelper<object>.ExecuteTransaction(listSql.ToArray());
|
||||||
|
if (result > 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取换型操作的基本参数
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<PLCConfigBase> GetPLCConfigBases()
|
||||||
|
{
|
||||||
|
string strSql = string.Format(@"SELECT * FROM `tb_plcconfigbase`
|
||||||
|
ORDER BY OrderNum");
|
||||||
|
var list = MySqlHelper<PLCConfigBase>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取PLC换型参数绑定值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modelName">产品型号</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<PLCConfigPara> GetPLCConfigPara(string modelName)
|
||||||
|
{
|
||||||
|
string strSql = $@"SELECT '{modelName}' ModelName,pb.PLCAddress,pc.PLCValue,pc.UpdateTime,pb.PLCRemark,pb.OrderNum
|
||||||
|
FROM tb_plcconfigbase pb
|
||||||
|
left join (select * from tb_plcconfig where ModelName='{modelName}') pc
|
||||||
|
on pb.PLCAddress = pc.PLCAddress
|
||||||
|
order by pb.OrderNum;";
|
||||||
|
var list = MySqlHelper<PLCConfigPara>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 具体型号轴参数保存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dt"></param>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <param name="strErr"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool InsertPLCConfigParam(List<PLCConfigPara> list)
|
||||||
|
{
|
||||||
|
List<string> listSql = new List<string>();
|
||||||
|
listSql.Add($"delete from tb_plcconfig where ModelName='{list[0].ModelName}';");
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
listSql.Add($@"INSERT INTO `tb_plcconfig`(`ModelName`, `PLCAddress`, `PLCValue`, `UpdateDate`)
|
||||||
|
Values ('{item.ModelName}','{item.PLCAddress}',{item.PLCValue}),'{item.UpdateData}';");
|
||||||
|
}
|
||||||
|
var result = MySqlHelper<object>.ExecuteTransaction(listSql.ToArray());
|
||||||
|
if (result > 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询历史数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strBarCode"></param>
|
||||||
|
/// <param name="strDate1"></param>
|
||||||
|
/// <param name="strDate2"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public DataTable GetTestData(int type, string strBarCode, string strDate1, string strDate2, string flag)
|
||||||
|
{
|
||||||
|
string strSql = @" SELECT
|
||||||
|
tb_testvr.TD 通道,
|
||||||
|
tb_testvr.BarCode 条码,
|
||||||
|
tb_testvr.Vol 电压,
|
||||||
|
tb_testvr.IMP 内阻,
|
||||||
|
tb_testvr.K K值,
|
||||||
|
tb_testvr.T 温度,
|
||||||
|
tb_testvr.Length 长度,
|
||||||
|
tb_testvr.Wide 宽度,
|
||||||
|
tb_testvr.LMDistance 极边距,
|
||||||
|
tb_testvr.Thickness 厚度,
|
||||||
|
tb_testvr.LCDistance 中心距,
|
||||||
|
DATE_FORMAT(tb_testvr.TestTime,'%Y-%m-%d %H:%i:%s') 测试时间,
|
||||||
|
tb_testvr.Result 结果,
|
||||||
|
tb_testvr.Remark 备注,
|
||||||
|
case when tb_testvr.Flag=1 then '已上传' else '未上传' end 上传状态,
|
||||||
|
tb_testvr.ProdType 测试型号,
|
||||||
|
tb_testvr.OCVType 测试类别,
|
||||||
|
tb_testvr.EquNo 设备编号,
|
||||||
|
tb_testvr.TaskCode 任务号
|
||||||
|
FROM
|
||||||
|
tb_testvr
|
||||||
|
where tb_testvr.TestTime >= '" + strDate1 + "' and tb_testvr.TestTime <= '" + strDate2 + "' ";
|
||||||
|
if (strBarCode != "")
|
||||||
|
{
|
||||||
|
strSql += " and tb_testvr.BarCode like '" + strBarCode + "%' ";
|
||||||
|
}
|
||||||
|
DataTable dt = MySqlHelper<object>.QueryTable(strSql);
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 查询历史数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strBarCode"></param>
|
||||||
|
/// <param name="strDate1"></param>
|
||||||
|
/// <param name="strDate2"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public DataTable GetTestData2(int type,int resultType, string strBarCode, string strDate1, string strDate2, string flag)
|
||||||
|
{
|
||||||
|
string strSql = @" SELECT
|
||||||
|
tb_testvr.TD 通道,
|
||||||
|
tb_testvr.BarCode 条码,
|
||||||
|
tb_testvr.Vol 电压,
|
||||||
|
tb_testvr.IMP 内阻,
|
||||||
|
tb_testvr.K K值,
|
||||||
|
tb_testvr.T 温度,
|
||||||
|
tb_testvr.Length 长度,
|
||||||
|
tb_testvr.Wide 宽度,
|
||||||
|
tb_testvr.LMDistance 极边距,
|
||||||
|
tb_testvr.Thickness 厚度,
|
||||||
|
tb_testvr.LCDistance 中心距,
|
||||||
|
DATE_FORMAT(tb_testvr.TestTime,'%Y-%m-%d %H:%i:%s') 测试时间,
|
||||||
|
tb_testvr.Result 结果,
|
||||||
|
tb_testvr.Remark 备注,
|
||||||
|
case when tb_testvr.Flag=1 then '已上传' else '未上传' end 上传状态,
|
||||||
|
tb_testvr.ProdType 测试型号,
|
||||||
|
tb_testvr.OCVType 测试类别,
|
||||||
|
tb_testvr.EquNo 设备编号,
|
||||||
|
tb_testvr.TaskCode 任务号
|
||||||
|
FROM
|
||||||
|
tb_testvr
|
||||||
|
where tb_testvr.TestTime >= '" + strDate1 + "' and tb_testvr.TestTime <= '" + strDate2 + "' ";
|
||||||
|
if (strBarCode != "")
|
||||||
|
{
|
||||||
|
strSql += " and tb_testvr.BarCode like '" + strBarCode + "%' ";
|
||||||
|
}
|
||||||
|
DataTable dt = MySqlHelper<object>.QueryTable(strSql);
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询CCD数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strWorkerNum"></param>
|
||||||
|
/// <param name="strDate1"></param>
|
||||||
|
/// <param name="strDate2"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public DataTable GetCCDData(string strWorkerNum, string strDate1, string strDate2)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
string strSql = string.Format(@"SELECT
|
||||||
|
date_format(data_run.Date, '%m-%d' ) 日期
|
||||||
|
,data_run.Class 班次
|
||||||
|
,data_run.Classtype 班别
|
||||||
|
,data_run.OrderNum 工单号
|
||||||
|
,data_run.Customer 客户名称
|
||||||
|
,sum(IFNULL(data_run.TotalNum,0)) 投入总数
|
||||||
|
,sum(IFNULL(data_run.OK,0)) 良品总数
|
||||||
|
,sum(IFNULL(data_run.NG,0)) 不良总数
|
||||||
|
,CAST(IFNULL(CONVERT(((CONVERT((sum(IFNULL(data_run.NG,0))),FLOAT)/CONVERT((sum(IFNULL(data_run.TotalNum,0))),FLOAT))*100),DOUBLE),0) as CHAR(10))+'%' 不良率
|
||||||
|
,sum(IFNULL(data_run.CanRepaired,0)) 质量缺陷
|
||||||
|
,sum(IFNULL(data_run.NotRepaired,0)) 非质量缺陷
|
||||||
|
,sum(IFNULL(data_run.OtherNG,0)) 其他不良
|
||||||
|
,sum(IFNULL(data_run.SideNG,0)) 侧面不良
|
||||||
|
,sum(IFNULL(data_run.PositiveNG,0)) 正极不良
|
||||||
|
,sum(IFNULL(data_run.NegativeNG,0)) 负极不良
|
||||||
|
,sum(IFNULL(data_run.ChongheNG,0)) 重合不良
|
||||||
|
,sum(IFNULL(data_run.CodeNG,0)) 喷码不良
|
||||||
|
,sum(IFNULL(data_run.SideDrumpack,0)) 侧面凹坑鼓包、变形
|
||||||
|
,sum(IFNULL(data_run.SideDirty,0)) 侧面脏污漏液
|
||||||
|
,sum(IFNULL(data_run.SideScratches,0)) 侧面凸点、划痕、破皮、膜内异物
|
||||||
|
,sum(IFNULL(data_run.DPNG,0)) 正极面垫不良多放、漏放
|
||||||
|
,sum(IFNULL(data_run.PositiveDamage,0)) 正极套膜不良含热缩不良、破损、褶皱、面垫翘起
|
||||||
|
,sum(IFNULL(data_run.PositiveDirty,0)) 正极套膜脏污
|
||||||
|
,sum(IFNULL(data_run.PositiveScratches,0)) 盖帽不良含漏液、盖帽脏污氧化生锈,划痕,变形
|
||||||
|
,sum(IFNULL(data_run.SizeNG,0)) 负极套膜尺寸不良
|
||||||
|
,sum(IFNULL(data_run.NegativeDamage,0)) 负极套膜不良含套膜褶皱变形、破损、褶皱
|
||||||
|
,sum(IFNULL(data_run.NegativeDirty,0)) 负极套膜脏污
|
||||||
|
,sum(IFNULL(data_run.NegativeScratches,0)) 底部不良含漏液、脏污、氧化生锈、划痕、变形
|
||||||
|
,data_run.Operator 操作员
|
||||||
|
from data_run where data_run.OrderNum='{0}'", strWorkerNum);
|
||||||
|
//if (strWorkerNum != "")
|
||||||
|
//{
|
||||||
|
// strSql += string.Format(@" and data_run.OrderNum='{0}'", strWorkerNum);
|
||||||
|
//}
|
||||||
|
//strSql += " GROUP BY data_run.Class";
|
||||||
|
DataTable dt = SqlHelper<object>.QueryTable(strSql);
|
||||||
|
return dt;
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 按日期查询和时间查询投入产出信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate"></param>
|
||||||
|
/// <param name="Hour"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<HourprodEntity> GetProdTotal(string strDate, int Hour)
|
||||||
|
{
|
||||||
|
string strSql = string.Format(@"SELECT
|
||||||
|
FDate
|
||||||
|
,FHour
|
||||||
|
,ProdIn
|
||||||
|
,ProdOut
|
||||||
|
,TestTime
|
||||||
|
FROM Tb_HourProd where FDate = '{0}'", strDate);
|
||||||
|
if (Hour > 0)
|
||||||
|
{
|
||||||
|
strSql += string.Format(" and FHour={0}", Hour);
|
||||||
|
}
|
||||||
|
var list = MySqlHelper<HourprodEntity>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新指定时间的小时产出
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="enity">小时产出数据</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int UpdateHourprodData(HourprodEntity enity)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string strSql = $@"select 1 from tb_hourprod where FDate='{enity.FDate}' and FHour={enity.FHour}";
|
||||||
|
var obj = MySqlHelper<object>.ExecuteScalar(strSql, null);
|
||||||
|
if (obj != null && obj.ToString().Trim() != "")
|
||||||
|
{
|
||||||
|
|
||||||
|
strSql = $@"update tb_hourprod set ProdIn='{enity.ProdIn}',ProdOut='{enity.ProdOut}', TestTime='{DateTime.Now}'
|
||||||
|
where FDate='{enity.FDate}' and FHour={enity.FHour}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strSql = $@"Insert into tb_hourprod(FDate, FHour, ProdIn, ProdOut, TestTime)
|
||||||
|
values ('{enity.FDate}', '{enity.FHour}', '{enity.ProdIn}', '{enity.ProdOut}', '{DateTime.Now}')";
|
||||||
|
}
|
||||||
|
int iresult = MySqlHelper<object>.Execute(strSql);
|
||||||
|
return iresult;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存进托盘数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate"></param>
|
||||||
|
/// <param name="Hour"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//public int AddInPutTrayID(TrayTestEntry m, ref string strErr)
|
||||||
|
//{
|
||||||
|
// string strSql = "INSERT INTO tb_InPutTrayID (TrayID,TestTime,Result,Remark)";
|
||||||
|
// strSql += string.Format(" values('{0}','{1}','{2}','{3}')", m.TrayID, m.TrayDate, m.TrayResult, m.TrayRemark);
|
||||||
|
// int list = MySqlHelper<AbnormalCellEntity>.Execute(strSql);
|
||||||
|
// return list;
|
||||||
|
//}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存空托盘排出数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate"></param>
|
||||||
|
/// <param name="Hour"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//public int AddOutTrayID(TrayTestEntry m, ref string strErr)
|
||||||
|
//{
|
||||||
|
// string strSql = "INSERT INTO tb_OutTrayID (TrayID,TestTime,Result,Remark)";
|
||||||
|
// strSql += string.Format(" values('{0}','{1}','{2}','{3}')", m.TrayID, m.TrayDate, m.TrayResult, m.TrayRemark);
|
||||||
|
// int list = MySqlHelper<GroovingData>.Execute(strSql);
|
||||||
|
// return list;
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 上料数据保存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate"></param>
|
||||||
|
/// <param name="Hour"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//public int AddTestCode(AbnormalCellEntity m, ref string strErr)
|
||||||
|
//{
|
||||||
|
// string strSql = "INSERT INTO tb_savebarcode(TD,BarCode,TestTime,NGPosition, NGType,Remark, Flag)";
|
||||||
|
// strSql += string.Format(" values({0},'{1}','{2}','{3}','{4}','{5}',{6})", m.TD, m.BarCode, m.strDate,m.NGPosition,m.NGType, m.Remark, m.Flag);
|
||||||
|
// int list = MySqlHelper<AbnormalCellEntity>.Execute(strSql);
|
||||||
|
// return list;
|
||||||
|
//}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 滚槽数据保存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate"></param>
|
||||||
|
/// <param name="Hour"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//public int AddGroovingData(GroovingData m, ref string strErr)
|
||||||
|
//{
|
||||||
|
// string strSql = "INSERT INTO tb_grooving(TD,BarCode,Gear,IsRetest, TestTime, Result, Remark,Worker, Flag)";
|
||||||
|
// strSql += string.Format(" values({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}',{8})", m.GradingTD, m.GradingBarCode, m.Gear,
|
||||||
|
// m.IsRetest, m.GradingstrDate, m.GradingResult, m.GradingRemark, m.StrWorker, m.Flag);
|
||||||
|
// int list = MySqlHelper<GroovingData>.Execute(strSql);
|
||||||
|
// return list;
|
||||||
|
//}
|
||||||
|
|
||||||
|
public int AddFeedingData(FeedingData m, ref string strErr)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AddBlankingData(BlankingData m, ref string strErr)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AddInPutTrayID(TrayTestEntry m, ref string strErr)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AddOutTrayID(TrayTestEntry m, ref string strErr)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
public int AddCamInforData(CamInfor m, ref string strErr)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AddAlarmCacheData(string tablename, List<AlarmData> m)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AlarmData> GetAlarmCacheData()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTable GetBarInTime(string strBar)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int UparInTime(string strBar)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public string GetAbnormalVoice(string code, bool needInsert = false)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,712 @@
|
|||||||
|
using JY.Model;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.DAL
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
public class OpSqlDataBase : IDbHelper
|
||||||
|
{
|
||||||
|
#region SQLServer
|
||||||
|
/// <summary>
|
||||||
|
/// 保存报警数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="m"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
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 = SqlHelper<AlarmData>.Execute(strSql);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存报警数据至缓存表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="m"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int AddAlarmCacheData(string tablename, List<AlarmData> m)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int list = SqlHelper<AlarmData>.BulkToDB(tablename, m);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询缓存表报警信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate1">开始时间</param>
|
||||||
|
/// <param name="strDate2">结束时间</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
///
|
||||||
|
public List<AlarmData> GetAlarmCacheData()
|
||||||
|
{
|
||||||
|
string strSql = $@" SELECT [AlarmGuid]
|
||||||
|
,[PLCAdress]
|
||||||
|
,[AlarmCode]
|
||||||
|
,[AlarmContent]
|
||||||
|
,[AlarmType]
|
||||||
|
,[AlarmDesc]
|
||||||
|
,[AlarmState]
|
||||||
|
,[StartTime]
|
||||||
|
,[EndTime]
|
||||||
|
,[Flag]
|
||||||
|
FROM tb_alarm where Flag =0";
|
||||||
|
var list = SqlHelper<AlarmData>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除未更新数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate1">开始时间</param>
|
||||||
|
/// <param name="strDate2">结束时间</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int DeleteAlarmCacheData()
|
||||||
|
{
|
||||||
|
string strSql = $@"DELETE FROM[dbo].[tb_alarm] WHERE [Flag]=0";
|
||||||
|
int result = SqlHelper<object>.Execute(strSql);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询报警信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate1">开始时间</param>
|
||||||
|
/// <param name="strDate2">结束时间</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<AlarmData> GetAlarmData(string strDate1, string strDate2)
|
||||||
|
{
|
||||||
|
string strSql = $@" SELECT AlarmGuid,PLCAdress ,AlarmContent,AlarmCode,AlarmType,StartTime ,EndTime
|
||||||
|
FROM tb_alarm where StartTime >= '{ strDate1 }' and StartTime <= '{ strDate2 }' ";
|
||||||
|
var list = SqlHelper<AlarmData>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询进站信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strCode"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<FeedingData> GetFeedingData(string strCode)
|
||||||
|
{
|
||||||
|
string strSql = $@" SELECT * FROM FeedingData where BarCode = '{strCode}' ORDER BY CreateTime desc";
|
||||||
|
var list = SqlHelper<FeedingData>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增产品型号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="entity">机型信息</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int AddProductModel(ProductModel entity)
|
||||||
|
{
|
||||||
|
string strSql = $@"INSERT INTO tb_productmodel (ModelName, Remark)
|
||||||
|
VALUES ('{entity.ModelName}', '{entity.Remark}')";
|
||||||
|
int result = SqlHelper<object>.Execute(strSql);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除本地型号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modeltype">型号</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public void DelProductModel(string modeltype)
|
||||||
|
{
|
||||||
|
string strSql = $"delete from tb_productmodel where ModelName='{modeltype}'";
|
||||||
|
SqlHelper<object>.Execute(strSql);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取产品型号列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strProdType">产品型号</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<ProductModel> GetProductModelList(string strProdType = "")
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string strSql = @"SELECT * FROM tb_productmodel ";
|
||||||
|
if (strProdType != "")
|
||||||
|
{
|
||||||
|
strSql += string.Format(" where ModelName='{0}'", strProdType);
|
||||||
|
}
|
||||||
|
strSql += " order by ModelName";
|
||||||
|
var list = SqlHelper<ProductModel>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存产品类型配置参数
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool AddProductParaList(List<ProductPara> list)
|
||||||
|
{
|
||||||
|
List<string> listSql = new List<string>();
|
||||||
|
listSql.Add($@"delete from tb_paralist where ModelName='{list[0].ModelName}'");
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
listSql.Add($@"INSERT INTO tb_paralist (ModelName, ParaName, ParaValue, Remark, UpdateTime)
|
||||||
|
VALUES ('{item.ModelName}', '{item.ParaName}', '{item.ParaValue}', '{item.Remark}', '{item.UpdateTime}')");
|
||||||
|
}
|
||||||
|
var result = SqlHelper<object>.ExecuteTransaction(listSql.ToArray());
|
||||||
|
|
||||||
|
if (result > 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取产品参数通过产品型号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strModelType">产品型号</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<ProductPara> GetProductParaByProdModel(string strModelType)
|
||||||
|
{
|
||||||
|
string strSql = $@"SELECT pb.ParaName, '{strModelType}' ModelName,pl.ParaValue,pl.Remark,pl.UpdateTime
|
||||||
|
FROM tb_parabase pb
|
||||||
|
left join (select * from tb_paralist where ModelName = '{strModelType}' ) as pl
|
||||||
|
on pb.ParaName = pl.ParaName; ";
|
||||||
|
|
||||||
|
var list = SqlHelper<ProductPara>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标准轴参数保存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dt"></param>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <param name="strErr"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool InsertPLCConfigBase(List<PLCConfigBase> list)
|
||||||
|
{
|
||||||
|
List<string> listSql = new List<string>();
|
||||||
|
listSql.Add("delete from tb_plcconfigbase;");
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
listSql.Add($@"Insert into tb_plcconfigbase (PLCAddress,PLCRemark,OrderNum)
|
||||||
|
Values ('{item.PLCAddress}','{item.PLCRemark}',{item.OrderNum});");
|
||||||
|
}
|
||||||
|
var result = SqlHelper<object>.ExecuteTransaction(listSql.ToArray());
|
||||||
|
if (result > 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取换型操作的基本参数
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<PLCConfigBase> GetPLCConfigBases()
|
||||||
|
{
|
||||||
|
string strSql = string.Format(@"SELECT * FROM tb_plcconfigbase
|
||||||
|
ORDER BY OrderNum");
|
||||||
|
var list = SqlHelper<PLCConfigBase>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 获取PLC换型参数绑定值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="modelName">产品型号</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<PLCConfigPara> GetPLCConfigPara(string modelName)
|
||||||
|
{
|
||||||
|
string strSql = $@"SELECT '{modelName}' ModelName,pb.PLCAddress,pc.PLCValue,pc.UpdateDate,pb.PLCRemark,pb.OrderNum
|
||||||
|
FROM tb_plcconfigbase pb
|
||||||
|
left join (select * from tb_plcconfig where ModelName='{modelName}') pc
|
||||||
|
on pb.PLCAddress = pc.PLCAddress
|
||||||
|
order by pb.OrderNum;";
|
||||||
|
var list = SqlHelper<PLCConfigPara>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 具体型号轴参数保存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dt"></param>
|
||||||
|
/// <param name=""></param>
|
||||||
|
/// <param name="strErr"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool InsertPLCConfigParam(List<PLCConfigPara> list)
|
||||||
|
{
|
||||||
|
List<string> listSql = new List<string>();
|
||||||
|
listSql.Add($"delete from tb_plcconfig where ModelName='{list[0].ModelName}';");
|
||||||
|
foreach (var item in list)
|
||||||
|
{
|
||||||
|
listSql.Add($@"INSERT INTO tb_plcconfig (ModelName, PLCAddress, PLCValue, UpdateDate)
|
||||||
|
Values ('{item.ModelName}','{item.PLCAddress}',{item.PLCValue},'{item.UpdateData}');");
|
||||||
|
}
|
||||||
|
var result = SqlHelper<object>.ExecuteTransaction(listSql.ToArray());
|
||||||
|
if (result > 0)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询历史数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strBarCode"></param>
|
||||||
|
/// <param name="strDate1"></param>
|
||||||
|
/// <param name="strDate2"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public DataTable GetTestData(int type, string strBarCode, string strDate1, string strDate2, string flag)
|
||||||
|
{
|
||||||
|
string strSql = "";
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
strSql = @"SELECT [ID] ID
|
||||||
|
,[TD] 通道
|
||||||
|
,[BarCode] 入站条码
|
||||||
|
,CONVERT(varchar, [CreateTime], 120) 进站时间
|
||||||
|
,[Result] 结果
|
||||||
|
,[Remark] 备注
|
||||||
|
,[Flag] 状态
|
||||||
|
FROM [dbo].[FeedingData]
|
||||||
|
where CreateTime >= '" + strDate1 + "' and CreateTime <= '" + strDate2 + "' ";
|
||||||
|
if (strBarCode != "")
|
||||||
|
{
|
||||||
|
strSql += " and BarCode like '%" + strBarCode + "%' ";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
strSql = @" SELECT [ID] ID
|
||||||
|
,[TD] 序号
|
||||||
|
,[WorkShift] 班次
|
||||||
|
,[ArrivalBarCode] 入站条码
|
||||||
|
,[DepartureBarCode] 出站条码
|
||||||
|
,[TMDB] 条码对比
|
||||||
|
,CONVERT(varchar, [OutTime], 120) 出站时间
|
||||||
|
,[CCD1] '正面(2D/3D)'
|
||||||
|
,[CCD2] '反面(2D/3D)'
|
||||||
|
,[CCD3] '左侧面(2D/3D)'
|
||||||
|
,[CCD4] '右侧面(2D/3D)'
|
||||||
|
,[CCD5] '顶面(2D/3D)'
|
||||||
|
,[CCD6] '底面(2D/3D)'
|
||||||
|
,[CCD7] 底WE1
|
||||||
|
,[CCD8] 底WE2
|
||||||
|
,[CCD9] 底WE3
|
||||||
|
,[CCD10] 底WE4
|
||||||
|
,[CCD11] 中ME1
|
||||||
|
,[CCD12] 中ME2
|
||||||
|
,[CCD13] 中ME3
|
||||||
|
,[CCD14] 中ME4
|
||||||
|
,[CCD15] '极柱(POS/NEG)'
|
||||||
|
,[CCD16] '防爆阀(PRO)'
|
||||||
|
,[Result] 综合结果
|
||||||
|
,[Remark] 备注
|
||||||
|
,[Flag] 状态
|
||||||
|
FROM [dbo].[BlankingData] where OutTime >= '" + strDate1 + "' and OutTime <= '" + strDate2 + "' ";
|
||||||
|
if (strBarCode != "")
|
||||||
|
{
|
||||||
|
strSql += " and DepartureBarCode like '%" + strBarCode + "' ";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DataTable dt = SqlHelper<object>.QueryTable(strSql);
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 查询历史数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strBarCode"></param>
|
||||||
|
/// <param name="strDate1"></param>
|
||||||
|
/// <param name="strDate2"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public DataTable GetTestData2(int type,int resultType, string strBarCode, string strDate1, string strDate2, string flag)
|
||||||
|
{
|
||||||
|
string strSql = "";
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
strSql = @"SELECT [ID] ID
|
||||||
|
,[TD] 通道
|
||||||
|
,[TDGroup] 主道
|
||||||
|
,[BarCode] 入站条码
|
||||||
|
,CONVERT(varchar, [CreateTime], 120) 进站时间
|
||||||
|
,[Result] 结果
|
||||||
|
,[Remark] 备注
|
||||||
|
,[Flag] 状态
|
||||||
|
FROM [dbo].[FeedingData]
|
||||||
|
where CreateTime >= '" + strDate1 + "' and CreateTime <= '" + strDate2 + "' ";
|
||||||
|
if (strBarCode != "")
|
||||||
|
{
|
||||||
|
strSql += " and BarCode like '%" + strBarCode + "%' ";
|
||||||
|
}
|
||||||
|
if (resultType == 1)
|
||||||
|
{
|
||||||
|
strSql += " and Result ='OK' ";
|
||||||
|
}
|
||||||
|
else if (resultType == 2)
|
||||||
|
{
|
||||||
|
strSql += " and Result = 'NG' ";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
strSql = @" SELECT [ID] ID
|
||||||
|
,[TD] 序号
|
||||||
|
,[WorkShift] 班次
|
||||||
|
,[TDGroup] 主道
|
||||||
|
,[ArrivalBarCode] 入站条码
|
||||||
|
,[DepartureBarCode] 出站条码
|
||||||
|
,[TMDB] 条码对比
|
||||||
|
,CONVERT(varchar, [OutTime], 120) 出站时间
|
||||||
|
,[CCD1] '正面(2D/3D)'
|
||||||
|
,[CCD2] '反面(2D/3D)'
|
||||||
|
,[CCD3] '左侧面(2D/3D)'
|
||||||
|
,[CCD4] '右侧面(2D/3D)'
|
||||||
|
,[CCD5] '顶面(2D/3D)'
|
||||||
|
,[CCD6] '底面(2D/3D)'
|
||||||
|
,[CCD7] 底WE1
|
||||||
|
,[CCD8] 底WE2
|
||||||
|
,[CCD9] 底WE3
|
||||||
|
,[CCD10] 底WE4
|
||||||
|
,[CCD11] 中ME1
|
||||||
|
,[CCD12] 中ME2
|
||||||
|
,[CCD13] 中ME3
|
||||||
|
,[CCD14] 中ME4
|
||||||
|
,[CCD15] '极柱(POS/NEG)'
|
||||||
|
,[CCD16] '防爆阀(PRO)'
|
||||||
|
,[Result] 综合结果
|
||||||
|
,[Remark] 备注
|
||||||
|
,[Flag] 状态
|
||||||
|
FROM [dbo].[BlankingData] where OutTime >= '" + strDate1 + "' and OutTime <= '" + strDate2 + "' ";
|
||||||
|
if (strBarCode != "")
|
||||||
|
{
|
||||||
|
strSql += " and DepartureBarCode like '%" + strBarCode + "' ";
|
||||||
|
}
|
||||||
|
if(resultType == 1)
|
||||||
|
{
|
||||||
|
strSql += " and Result ='OK' ";
|
||||||
|
}
|
||||||
|
else if (resultType == 2)
|
||||||
|
{
|
||||||
|
strSql += " and Result like '%NG%' ";
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DataTable dt = SqlHelper<object>.QueryTable(strSql);
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询CCD数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strWorkerNum"></param>
|
||||||
|
/// <param name="strDate1"></param>
|
||||||
|
/// <param name="strDate2"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public DataTable GetCCDData(string strWorkerNum, string strDate1, string strDate2)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
string strSql = string.Format(@"SELECT
|
||||||
|
|
||||||
|
data_run.OrderNum 工单号
|
||||||
|
,data_run.Customer 客户名称
|
||||||
|
,sum(IFNULL(data_run.TotalNum,0)) 投入总数
|
||||||
|
,sum(IFNULL(data_run.OK,0)) 良品总数
|
||||||
|
,sum(IFNULL(data_run.NG,0)) 不良总数
|
||||||
|
,CAST(IFNULL(CONVERT(((CONVERT((sum(IFNULL(data_run.NG,0))),FLOAT)/CONVERT((sum(IFNULL(data_run.TotalNum,0))),FLOAT))*100),DOUBLE),0) as CHAR(10))+'%' 不良率
|
||||||
|
,sum(IFNULL(data_run.CanRepaired,0)) 质量缺陷
|
||||||
|
,sum(IFNULL(data_run.NotRepaired,0)) 非质量缺陷
|
||||||
|
,sum(IFNULL(data_run.OtherNG,0)) 其他不良
|
||||||
|
,sum(IFNULL(data_run.SideNG,0)) 侧面不良
|
||||||
|
,sum(IFNULL(data_run.PositiveNG,0)) 正极不良
|
||||||
|
,sum(IFNULL(data_run.NegativeNG,0)) 负极不良
|
||||||
|
,sum(IFNULL(data_run.ChongheNG,0)) 重合不良
|
||||||
|
,sum(IFNULL(data_run.CodeNG,0)) 喷码不良
|
||||||
|
,sum(IFNULL(data_run.SideDrumpack,0)) 侧面凹坑鼓包、变形
|
||||||
|
,sum(IFNULL(data_run.SideDirty,0)) 侧面脏污漏液
|
||||||
|
,sum(IFNULL(data_run.SideScratches,0)) 侧面凸点、划痕、破皮、膜内异物
|
||||||
|
,sum(IFNULL(data_run.DPNG,0)) 正极面垫不良多放、漏放
|
||||||
|
,sum(IFNULL(data_run.PositiveDamage,0)) 正极套膜不良含热缩不良、破损、褶皱、面垫翘起
|
||||||
|
,sum(IFNULL(data_run.PositiveDirty,0)) 正极套膜脏污
|
||||||
|
,sum(IFNULL(data_run.PositiveScratches,0)) 盖帽不良含漏液、盖帽脏污氧化生锈,划痕,变形
|
||||||
|
,sum(IFNULL(data_run.SizeNG,0)) 负极套膜尺寸不良
|
||||||
|
,sum(IFNULL(data_run.NegativeDamage,0)) 负极套膜不良含套膜褶皱变形、破损、褶皱
|
||||||
|
,sum(IFNULL(data_run.NegativeDirty,0)) 负极套膜脏污
|
||||||
|
,sum(IFNULL(data_run.NegativeScratches,0)) 底部不良含漏液、脏污、氧化生锈、划痕、变形
|
||||||
|
,data_run.Operator 操作员
|
||||||
|
from data_run where data_run.OrderNum='{0}'", strWorkerNum);
|
||||||
|
//from data_run where data_run.Date>='{0}' and data_run.Date<='{1}'", strDate1, strDate2);
|
||||||
|
//if (strWorkerNum != "")
|
||||||
|
//{
|
||||||
|
// strSql += string.Format(@" and data_run.OrderNum='{0}'", strWorkerNum);
|
||||||
|
//}
|
||||||
|
//strSql += " GROUP BY data_run.Class";
|
||||||
|
//date_format(data_run.Date, '%m-%d') 日期
|
||||||
|
// ,data_run.Class 班次
|
||||||
|
// , data_run.Classtype 班别
|
||||||
|
DataTable dt = MySqlHelper<object>.QueryTable(strSql);
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 按日期查询和时间查询投入产出信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate"></param>
|
||||||
|
/// <param name="Hour"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<HourprodEntity> GetProdTotal(string strDate, int Hour)
|
||||||
|
{
|
||||||
|
string strSql = string.Format(@"SELECT
|
||||||
|
FDate
|
||||||
|
,FHour
|
||||||
|
,ProdIn
|
||||||
|
,ProdOut
|
||||||
|
,TestTime
|
||||||
|
FROM Tb_HourProd where FDate = '{0}'", strDate);
|
||||||
|
if (Hour > 0)
|
||||||
|
{
|
||||||
|
strSql += string.Format(" and FHour={0}", Hour);
|
||||||
|
}
|
||||||
|
var list = SqlHelper<HourprodEntity>.Query(strSql);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新指定时间的小时产出
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="enity">小时产出数据</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int UpdateHourprodData(HourprodEntity enity)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string strSql = $@"select 1 from tb_hourprod where FDate='{enity.FDate}' and FHour={enity.FHour}";
|
||||||
|
var obj = SqlHelper<object>.ExecuteScalar(strSql, null);
|
||||||
|
if (obj != null && obj.ToString().Trim() != "")
|
||||||
|
{
|
||||||
|
|
||||||
|
strSql = $@"update tb_hourprod set ProdIn='{enity.ProdIn}',ProdOut='{enity.ProdOut}', TestTime='{DateTime.Now}'
|
||||||
|
where FDate='{enity.FDate}' and FHour={enity.FHour}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strSql = $@"Insert into tb_hourprod(FDate, FHour, ProdIn, ProdOut, TestTime)
|
||||||
|
values ('{enity.FDate}', '{enity.FHour}', '{enity.ProdIn}', '{enity.ProdOut}', '{DateTime.Now}')";
|
||||||
|
}
|
||||||
|
int iresult = SqlHelper<object>.Execute(strSql);
|
||||||
|
return iresult;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存进托盘数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate"></param>
|
||||||
|
/// <param name="Hour"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int AddInPutTrayID(TrayTestEntry m, ref string strErr)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存空托盘排出数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate"></param>
|
||||||
|
/// <param name="Hour"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int AddOutTrayID(TrayTestEntry m, ref string strErr)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取电芯进站时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="m"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public DataTable GetBarInTime(string strBar)
|
||||||
|
{
|
||||||
|
DataTable dt = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string strsql = string.Format(@"SELECT Top(1) [BarCode] 条码
|
||||||
|
,CONVERT(varchar, [CreateTime], 120) 进站时间
|
||||||
|
FROM [dbo].[FeedingData]
|
||||||
|
where BarCode='{0}' order by ID DESC", strBar);
|
||||||
|
dt = SqlHelper<object>.QueryTable(strsql);
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新获取时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strBar"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int UparInTime(string strBar)
|
||||||
|
{
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string strsql = string.Format(@"UPDATE [dbo].[FeedingData] SET [Flag] = 1 WHERE [BarCode]='{0}' and Flag=0", strBar);
|
||||||
|
int iresult = SqlHelper<object>.Execute(strsql);
|
||||||
|
return iresult;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 出站外观数据保存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate"></param>
|
||||||
|
/// <param name="Hour"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int AddBlankingData(BlankingData m, ref string strErr)
|
||||||
|
{
|
||||||
|
string strSql = string.Format(@"INSERT INTO [dbo].[BlankingData]
|
||||||
|
([TD]
|
||||||
|
,[WorkShift]
|
||||||
|
,[ArrivalBarCode]
|
||||||
|
,[DepartureBarCode]
|
||||||
|
,[TMDB]
|
||||||
|
,[OutTime]
|
||||||
|
,[CCD1]
|
||||||
|
,[CCD2]
|
||||||
|
,[CCD3]
|
||||||
|
,[CCD4]
|
||||||
|
,[CCD5]
|
||||||
|
,[CCD6]
|
||||||
|
,[CCD7]
|
||||||
|
,[CCD8]
|
||||||
|
,[CCD9]
|
||||||
|
,[CCD10]
|
||||||
|
,[CCD11]
|
||||||
|
,[CCD12]
|
||||||
|
,[CCD13]
|
||||||
|
,[CCD14]
|
||||||
|
,[CCD15]
|
||||||
|
,[CCD16]
|
||||||
|
,[Result]
|
||||||
|
,[Remark]
|
||||||
|
,[Flag]
|
||||||
|
,[TDGroup])
|
||||||
|
VALUES");
|
||||||
|
strSql += string.Format("({0},'{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}',{24},{25})",
|
||||||
|
m.TD, m.WorkShift, m.ArrivalBarCode, m.DepartureBarCode, m.TMDB, m.OutTime, m.CCD1, m.CCD2, m.CCD3, m.CCD4, m.CCD5, m.CCD6, m.CCD7, m.CCD8, m.CCD9, m.CCD10, m.CCD11, m.CCD12, m.CCD13, m.CCD14, m.CCD15, m.CCD16
|
||||||
|
, m.Result, m.Remark, m.Flag,m.TDGroup);
|
||||||
|
int list = SqlHelper<BlankingData>.Execute(strSql);
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 电芯分档数据保存
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strDate"></param>
|
||||||
|
/// <param name="Hour"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int AddFeedingData(FeedingData m, ref string strErr)
|
||||||
|
{
|
||||||
|
string strSql = string.Format(@"INSERT INTO [dbo].[FeedingData] ([TD],[BarCode],[CreateTime],[Result],[Remark],[Flag],[TDGroup])");
|
||||||
|
strSql += string.Format(@" values({0},'{1}','{2}','{3}','{4}',{5},{6})", m.TD, m.BarCode, m.CreateTime, m.Result, m.Remark, m.Flag,m.TDGroup);
|
||||||
|
int list = SqlHelper<FeedingData>.Execute(strSql);
|
||||||
|
return list;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
public int AddCamInforData(CamInfor m, ref string strErr)
|
||||||
|
{
|
||||||
|
string strSql = string.Format(@"INSERT INTO [dbo].[CamInforData] ([TD],[BarCode],[CreateTime],
|
||||||
|
[CCD15],[CCD16],[CCD17],[CCD18],,[CCD19],[CCD20],[CCD21],[CCD22],[CCD23],[CCD24],[CCD25],[CCD26],[CCD27],[CCD28],[CCD29,[CCD30],[CCD31],[CCD32],[CCD33],[CCD34],[CCD35],[CCD36],[CCD37],[CCD38],[Result],[Remark],[Flag])");
|
||||||
|
strSql += string.Format(@" values({0},''{1}','{2}','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}','{11}','{12}','{13}','{14}','{15}','{16}','{17}','{18}','{19}','{20}','{21}','{22}','{23}','{24}','{25}','{26}','{27}',{28})"
|
||||||
|
, m.TD, m.BarCode, m.CreateTime, m.CCD15, m.CCD16, m.CCD17, m.CCD18, m.CCD19, m.CCD20, m.CCD21, m.CCD22, m.CCD23, m.CCD24, m.CCD25, m.CCD26, m.CCD27, m.CCD28, m.CCD29, m.CCD30, m.CCD31, m.CCD32, m.CCD33, m.CCD34, m.CCD35, m.CCD36, m.CCD37, m.CCD38
|
||||||
|
, m.Result, m.Remark, m.Flag);
|
||||||
|
int list = SqlHelper<CamInfor>.Execute(strSql);
|
||||||
|
return list;
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 根据工位编码获取异常播报内容
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="code"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public string GetAbnormalVoice(string code, bool needInsert = false)
|
||||||
|
{
|
||||||
|
string remark = "";
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string strSql = $"select Remark from tb_AbnormalVoice where code='{code}' order by ID desc";
|
||||||
|
DataTable dt = SqlHelper<object>.QueryTable(strSql);
|
||||||
|
if (dt != null && dt.Rows.Count > 0)
|
||||||
|
{
|
||||||
|
remark = Convert.ToString(dt.Rows[0][0]);
|
||||||
|
}
|
||||||
|
else if (needInsert)
|
||||||
|
{
|
||||||
|
strSql = $"insert tb_AbnormalVoice(Code,Remark) values('{code}','')";
|
||||||
|
SqlHelper<object>.Execute(strSql);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(remark))
|
||||||
|
{
|
||||||
|
remark = "没有播报内容,编码" + code;
|
||||||
|
}
|
||||||
|
return remark;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -0,0 +1,36 @@
|
|||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
// 有关程序集的一般信息由以下
|
||||||
|
// 控制。更改这些特性值可修改
|
||||||
|
// 与程序集关联的信息。
|
||||||
|
[assembly: AssemblyTitle("JY.DAL")]
|
||||||
|
[assembly: AssemblyDescription("")]
|
||||||
|
[assembly: AssemblyConfiguration("")]
|
||||||
|
[assembly: AssemblyCompany("")]
|
||||||
|
[assembly: AssemblyProduct("JY.DAL")]
|
||||||
|
[assembly: AssemblyCopyright("Copyright © 2021")]
|
||||||
|
[assembly: AssemblyTrademark("")]
|
||||||
|
[assembly: AssemblyCulture("")]
|
||||||
|
|
||||||
|
// 将 ComVisible 设置为 false 会使此程序集中的类型
|
||||||
|
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
|
||||||
|
//请将此类型的 ComVisible 特性设置为 true。
|
||||||
|
[assembly: ComVisible(false)]
|
||||||
|
|
||||||
|
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||||
|
[assembly: Guid("d5889580-58f9-467e-87d3-efa37a300e67")]
|
||||||
|
|
||||||
|
// 程序集的版本信息由下列四个值组成:
|
||||||
|
//
|
||||||
|
// 主版本
|
||||||
|
// 次版本
|
||||||
|
// 生成号
|
||||||
|
// 修订号
|
||||||
|
//
|
||||||
|
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
|
||||||
|
//通过使用 "*",如下所示:
|
||||||
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
|
[assembly: AssemblyVersion("1.0.0.0")]
|
||||||
|
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Configuration;
|
||||||
|
|
||||||
|
namespace JY.DAL.Repository
|
||||||
|
{
|
||||||
|
public static class DataContext
|
||||||
|
{
|
||||||
|
private static readonly Lazy<SqlSugarScope> _instance = new Lazy<SqlSugarScope>(() =>
|
||||||
|
{
|
||||||
|
string connectionString = ConfigurationManager.ConnectionStrings["CurDB"].ConnectionString;
|
||||||
|
return new SqlSugarScope(new ConnectionConfig
|
||||||
|
{
|
||||||
|
ConnectionString = connectionString,
|
||||||
|
DbType = DbType.SqlServer,
|
||||||
|
IsAutoCloseConnection = true,
|
||||||
|
InitKeyType = InitKeyType.Attribute
|
||||||
|
}, db =>
|
||||||
|
{
|
||||||
|
db.Aop.OnLogExecuting = (sql, pars) =>
|
||||||
|
{
|
||||||
|
#if DEBUG
|
||||||
|
Console.WriteLine($"SqlSugar SQL: {sql}");
|
||||||
|
#endif
|
||||||
|
};
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
public static SqlSugarScope Instance => _instance.Value;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
namespace JY.DAL.Repository
|
||||||
|
{
|
||||||
|
public interface IRepository<T> where T : class, new()
|
||||||
|
{
|
||||||
|
ISqlSugarClient Db { get; }
|
||||||
|
|
||||||
|
T GetById(object id);
|
||||||
|
|
||||||
|
T GetSingle(Expression<Func<T, bool>> predicate);
|
||||||
|
|
||||||
|
List<T> GetList();
|
||||||
|
|
||||||
|
List<T> GetList(Expression<Func<T, bool>> predicate);
|
||||||
|
|
||||||
|
List<T> GetListPaged(int pageIndex, int pageSize, out int totalCount, Expression<Func<T, bool>> predicate = null, string orderBy = null);
|
||||||
|
|
||||||
|
int Insert(T entity);
|
||||||
|
|
||||||
|
int Insert(List<T> entities);
|
||||||
|
|
||||||
|
int Update(T entity);
|
||||||
|
|
||||||
|
int Update(T entity, Expression<Func<T, bool>> whereExpression);
|
||||||
|
|
||||||
|
int Update(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression);
|
||||||
|
|
||||||
|
int Delete(object id);
|
||||||
|
|
||||||
|
int Delete(Expression<Func<T, bool>> predicate);
|
||||||
|
|
||||||
|
int Delete(List<T> entities);
|
||||||
|
|
||||||
|
bool Any(Expression<Func<T, bool>> predicate);
|
||||||
|
|
||||||
|
int Count(Expression<Func<T, bool>> predicate = null);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,102 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
namespace JY.DAL.Repository
|
||||||
|
{
|
||||||
|
public class Repository<T> : IRepository<T> where T : class, new()
|
||||||
|
{
|
||||||
|
public ISqlSugarClient Db => DataContext.Instance;
|
||||||
|
|
||||||
|
public T GetById(object id)
|
||||||
|
{
|
||||||
|
return Db.Queryable<T>().InSingle(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T GetSingle(Expression<Func<T, bool>> predicate)
|
||||||
|
{
|
||||||
|
return Db.Queryable<T>().Where(predicate).Single();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> GetList()
|
||||||
|
{
|
||||||
|
return Db.Queryable<T>().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> GetList(Expression<Func<T, bool>> predicate)
|
||||||
|
{
|
||||||
|
return Db.Queryable<T>().Where(predicate).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> GetListPaged(int pageIndex, int pageSize, out int totalCount, Expression<Func<T, bool>> predicate = null, string orderBy = null)
|
||||||
|
{
|
||||||
|
totalCount = 0;
|
||||||
|
var query = Db.Queryable<T>();
|
||||||
|
if (predicate != null)
|
||||||
|
{
|
||||||
|
query = query.Where(predicate);
|
||||||
|
}
|
||||||
|
if (!string.IsNullOrEmpty(orderBy))
|
||||||
|
{
|
||||||
|
query = query.OrderBy(orderBy);
|
||||||
|
}
|
||||||
|
return query.ToPageList(pageIndex, pageSize, ref totalCount);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(T entity)
|
||||||
|
{
|
||||||
|
return Db.Insertable(entity).ExecuteReturnIdentity();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(List<T> entities)
|
||||||
|
{
|
||||||
|
return Db.Insertable(entities).ExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Update(T entity)
|
||||||
|
{
|
||||||
|
return Db.Updateable(entity).ExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Update(T entity, Expression<Func<T, bool>> whereExpression)
|
||||||
|
{
|
||||||
|
return Db.Updateable(entity).Where(whereExpression).ExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Update(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression)
|
||||||
|
{
|
||||||
|
return Db.Updateable<T>().SetColumns(columns).Where(whereExpression).ExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Delete(object id)
|
||||||
|
{
|
||||||
|
return Db.Deleteable<T>().In(id).ExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Delete(Expression<Func<T, bool>> predicate)
|
||||||
|
{
|
||||||
|
return Db.Deleteable<T>().Where(predicate).ExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Delete(List<T> entities)
|
||||||
|
{
|
||||||
|
return Db.Deleteable(entities).ExecuteCommand();
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Any(Expression<Func<T, bool>> predicate)
|
||||||
|
{
|
||||||
|
return Db.Queryable<T>().Where(predicate).Any();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Count(Expression<Func<T, bool>> predicate = null)
|
||||||
|
{
|
||||||
|
var query = Db.Queryable<T>();
|
||||||
|
if (predicate != null)
|
||||||
|
{
|
||||||
|
query = query.Where(predicate);
|
||||||
|
}
|
||||||
|
return query.Count();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using JY.DAL.Repository;
|
||||||
|
using JY.Model;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
namespace JY.DAL.Service
|
||||||
|
{
|
||||||
|
public interface IAlarmDataService : IService<AlarmData>
|
||||||
|
{
|
||||||
|
List<AlarmData> GetAlarmDataByTime(string startTime, string endTime);
|
||||||
|
|
||||||
|
List<AlarmData> GetAlarmCacheData();
|
||||||
|
|
||||||
|
int DeleteAlarmCacheData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AlarmDataService : Service<AlarmData>, IAlarmDataService
|
||||||
|
{
|
||||||
|
public AlarmDataService(IRepository<AlarmData> repository) : base(repository)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AlarmData> GetAlarmDataByTime(string startTime, string endTime)
|
||||||
|
{
|
||||||
|
return _repository.GetList(x => x.StartTime >= Convert.ToDateTime(startTime) && x.StartTime <= Convert.ToDateTime(endTime));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AlarmData> GetAlarmCacheData()
|
||||||
|
{
|
||||||
|
return _repository.GetList(x => x.Flag == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int DeleteAlarmCacheData()
|
||||||
|
{
|
||||||
|
return _repository.Delete(x => x.Flag == 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using JY.DAL.Repository;
|
||||||
|
using JY.Model;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.DAL.Service
|
||||||
|
{
|
||||||
|
public interface IBlankingDataService : IService<BlankingData>
|
||||||
|
{
|
||||||
|
int AddBlankData(BlankingData data);
|
||||||
|
}
|
||||||
|
public class BlankingDataService : Service<BlankingData>, IBlankingDataService
|
||||||
|
{
|
||||||
|
public BlankingDataService(IRepository<BlankingData> repository) : base(repository)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AddBlankData(BlankingData data)
|
||||||
|
{
|
||||||
|
return _repository.Insert(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
using JY.DAL.Repository;
|
||||||
|
using JY.Model;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace JY.DAL.Service
|
||||||
|
{
|
||||||
|
public interface IFeedingDataService : IService<FeedingData>
|
||||||
|
{
|
||||||
|
List<FeedingData> GetFeedingData(string barCode);
|
||||||
|
|
||||||
|
int AddFeedingData(FeedingData data);
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FeedingDataService : Service<FeedingData>, IFeedingDataService
|
||||||
|
{
|
||||||
|
public FeedingDataService(IRepository<FeedingData> repository) : base(repository)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<FeedingData> GetFeedingData(string barCode)
|
||||||
|
{
|
||||||
|
return _repository.GetList(x => x.BarCode == barCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AddFeedingData(FeedingData data)
|
||||||
|
{
|
||||||
|
return _repository.Insert(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
namespace JY.DAL.Service
|
||||||
|
{
|
||||||
|
public interface IService<T> where T : class, new()
|
||||||
|
{
|
||||||
|
T GetById(object id);
|
||||||
|
|
||||||
|
T GetSingle(Expression<Func<T, bool>> predicate);
|
||||||
|
|
||||||
|
List<T> GetList();
|
||||||
|
|
||||||
|
List<T> GetList(Expression<Func<T, bool>> predicate);
|
||||||
|
|
||||||
|
List<T> GetListPaged(int pageIndex, int pageSize, out int totalCount, Expression<Func<T, bool>> predicate = null, string orderBy = null);
|
||||||
|
|
||||||
|
int Insert(T entity);
|
||||||
|
|
||||||
|
int Insert(List<T> entities);
|
||||||
|
|
||||||
|
int Update(T entity);
|
||||||
|
|
||||||
|
int Update(T entity, Expression<Func<T, bool>> whereExpression);
|
||||||
|
|
||||||
|
int Update(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression);
|
||||||
|
|
||||||
|
int Delete(object id);
|
||||||
|
|
||||||
|
int Delete(Expression<Func<T, bool>> predicate);
|
||||||
|
|
||||||
|
int Delete(List<T> entities);
|
||||||
|
|
||||||
|
bool Any(Expression<Func<T, bool>> predicate);
|
||||||
|
|
||||||
|
int Count(Expression<Func<T, bool>> predicate = null);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,92 @@
|
|||||||
|
using JY.DAL.Repository;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
|
||||||
|
namespace JY.DAL.Service
|
||||||
|
{
|
||||||
|
public class Service<T> : IService<T> where T : class, new()
|
||||||
|
{
|
||||||
|
protected readonly IRepository<T> _repository;
|
||||||
|
|
||||||
|
public Service(IRepository<T> repository)
|
||||||
|
{
|
||||||
|
_repository = repository;
|
||||||
|
}
|
||||||
|
|
||||||
|
public T GetById(object id)
|
||||||
|
{
|
||||||
|
return _repository.GetById(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public T GetSingle(Expression<Func<T, bool>> predicate)
|
||||||
|
{
|
||||||
|
return _repository.GetSingle(predicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> GetList()
|
||||||
|
{
|
||||||
|
return _repository.GetList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> GetList(Expression<Func<T, bool>> predicate)
|
||||||
|
{
|
||||||
|
return _repository.GetList(predicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<T> GetListPaged(int pageIndex, int pageSize, out int totalCount, Expression<Func<T, bool>> predicate = null, string orderBy = null)
|
||||||
|
{
|
||||||
|
return _repository.GetListPaged(pageIndex, pageSize, out totalCount, predicate, orderBy);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(T entity)
|
||||||
|
{
|
||||||
|
return _repository.Insert(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(List<T> entities)
|
||||||
|
{
|
||||||
|
return _repository.Insert(entities);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Update(T entity)
|
||||||
|
{
|
||||||
|
return _repository.Update(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Update(T entity, Expression<Func<T, bool>> whereExpression)
|
||||||
|
{
|
||||||
|
return _repository.Update(entity, whereExpression);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Update(Expression<Func<T, T>> columns, Expression<Func<T, bool>> whereExpression)
|
||||||
|
{
|
||||||
|
return _repository.Update(columns, whereExpression);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Delete(object id)
|
||||||
|
{
|
||||||
|
return _repository.Delete(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Delete(Expression<Func<T, bool>> predicate)
|
||||||
|
{
|
||||||
|
return _repository.Delete(predicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Delete(List<T> entities)
|
||||||
|
{
|
||||||
|
return _repository.Delete(entities);
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool Any(Expression<Func<T, bool>> predicate)
|
||||||
|
{
|
||||||
|
return _repository.Any(predicate);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Count(Expression<Func<T, bool>> predicate = null)
|
||||||
|
{
|
||||||
|
return _repository.Count(predicate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,109 @@
|
|||||||
|
using JY.DAL.Repository;
|
||||||
|
using JY.DAL.Service;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace JY.DAL
|
||||||
|
{
|
||||||
|
public static class ServiceLocator
|
||||||
|
{
|
||||||
|
private static readonly Dictionary<Type, object> _services = new Dictionary<Type, object>();
|
||||||
|
private static readonly Dictionary<Type, Func<object>> _serviceFactories = new Dictionary<Type, Func<object>>();
|
||||||
|
private static bool _isInitialized = false;
|
||||||
|
|
||||||
|
public static void Initialize()
|
||||||
|
{
|
||||||
|
if (_isInitialized) return;
|
||||||
|
|
||||||
|
RegisterRepositoryAndService();
|
||||||
|
|
||||||
|
_isInitialized = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void RegisterRepositoryAndService()
|
||||||
|
{
|
||||||
|
var assembly = Assembly.GetExecutingAssembly();
|
||||||
|
|
||||||
|
foreach (var type in assembly.GetTypes())
|
||||||
|
{
|
||||||
|
if (type.IsClass && !type.IsAbstract)
|
||||||
|
{
|
||||||
|
foreach (var iface in type.GetInterfaces())
|
||||||
|
{
|
||||||
|
if (iface.IsGenericType)
|
||||||
|
{
|
||||||
|
var genericDef = iface.GetGenericTypeDefinition();
|
||||||
|
if (genericDef == typeof(IRepository<>))
|
||||||
|
{
|
||||||
|
_serviceFactories[iface] = () => Activator.CreateInstance(type);
|
||||||
|
}
|
||||||
|
else if (genericDef == typeof(IService<>))
|
||||||
|
{
|
||||||
|
_serviceFactories[iface] = () =>
|
||||||
|
{
|
||||||
|
var repoType = typeof(IRepository<>).MakeGenericType(type.GetGenericArguments()[0]);
|
||||||
|
var repo = Get(repoType);
|
||||||
|
return Activator.CreateInstance(type, repo);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!iface.FullName.StartsWith("System."))
|
||||||
|
{
|
||||||
|
_serviceFactories[iface] = () => CreateInstanceWithDependencies(type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static object CreateInstanceWithDependencies(Type type)
|
||||||
|
{
|
||||||
|
var constructor = type.GetConstructors()[0];
|
||||||
|
var parameters = constructor.GetParameters();
|
||||||
|
var paramValues = new object[parameters.Length];
|
||||||
|
|
||||||
|
for (int i = 0; i < parameters.Length; i++)
|
||||||
|
{
|
||||||
|
paramValues[i] = Get(parameters[i].ParameterType);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Activator.CreateInstance(type, paramValues);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Register<T>(T instance)
|
||||||
|
{
|
||||||
|
_services[typeof(T)] = instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Register<T>(Func<T> factory)
|
||||||
|
{
|
||||||
|
_serviceFactories[typeof(T)] = () => factory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static T Get<T>()
|
||||||
|
{
|
||||||
|
return (T)Get(typeof(T));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static object Get(Type serviceType)
|
||||||
|
{
|
||||||
|
if (_services.TryGetValue(serviceType, out object instance))
|
||||||
|
{
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_serviceFactories.TryGetValue(serviceType, out Func<object> factory))
|
||||||
|
{
|
||||||
|
instance = factory();
|
||||||
|
_services[serviceType] = instance;
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new InvalidOperationException($"服务 {serviceType.Name} 未注册");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,345 @@
|
|||||||
|
using Dapper;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Data;
|
||||||
|
using MySql.Data.MySqlClient;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Data.SqlClient;
|
||||||
|
using System.Collections;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
|
namespace JY.DAL
|
||||||
|
{
|
||||||
|
public class SqlHelper<T> where T : class
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 数据库连接字符串
|
||||||
|
/// </summary>
|
||||||
|
private static readonly string connectionString = ConfigurationManager.ConnectionStrings["SqlConn"].ConnectionString;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询列表
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql">查询的sql</param>
|
||||||
|
/// <param name="param">替换参数</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<T> Query(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (SqlConnection con = new SqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.Query<T>(sql, param).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询第一个数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T QueryFirst(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (SqlConnection con = new SqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.QueryFirst<T>(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询第一个数据没有返回默认值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T QueryFirstOrDefault(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (SqlConnection con = new SqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.QueryFirstOrDefault<T>(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询单条数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T QuerySingle(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (SqlConnection con = new SqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.QuerySingle<T>(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 查询单条数据没有返回默认值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T QuerySingleOrDefault(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (SqlConnection con = new SqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.QuerySingleOrDefault<T>(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 增删改
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns>Number of rows affected</returns>
|
||||||
|
public static int Execute(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (SqlConnection con = new SqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.Execute(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Reader获取数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static IDataReader ExecuteReader(string sql, object param)
|
||||||
|
{
|
||||||
|
using (SqlConnection con = new SqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.ExecuteReader(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取数据返回DataTable
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DataTable QueryTable(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (SqlConnection con = new SqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
DataTable table = new DataTable();
|
||||||
|
var reader = con.ExecuteReader(sql, param);
|
||||||
|
table.Load(reader);
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Scalar获取数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static object ExecuteScalar(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (SqlConnection con = new SqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.ExecuteScalar(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Scalar获取数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static T ExecuteScalarForT(string sql, object param = null)
|
||||||
|
{
|
||||||
|
using (SqlConnection con = new SqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
return con.ExecuteScalar<T>(sql, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 带参数的存储过程
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sql"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<T> ExecutePro(string proc, object param = null)
|
||||||
|
{
|
||||||
|
using (SqlConnection con = new SqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
List<T> list = con.Query<T>(proc,
|
||||||
|
param,
|
||||||
|
null,
|
||||||
|
true,
|
||||||
|
null,
|
||||||
|
CommandType.StoredProcedure).ToList();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 批量插入T数据,返回影响行数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="list">对象集合</param>
|
||||||
|
/// <returns>影响行数</returns>
|
||||||
|
public static int Insert(string strsql, List<T> list)
|
||||||
|
{
|
||||||
|
using (IDbConnection connection = new SqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
//return connection.Execute("insert into Person(Name,Remark) values(@Name,@Remark)", list);
|
||||||
|
return connection.Execute(strsql, list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// list to datatable
|
||||||
|
/// </summary>
|
||||||
|
/// <typeparam name="T"></typeparam>
|
||||||
|
/// <param name="collection"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static DataTable ListToDt(IEnumerable<T> collection)
|
||||||
|
{
|
||||||
|
var props = typeof(T).GetProperties();
|
||||||
|
var dt = new DataTable();
|
||||||
|
dt.Columns.AddRange(props.Select(p => new
|
||||||
|
DataColumn(p.Name, p.PropertyType)).ToArray());
|
||||||
|
if (collection.Count() > 0)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < collection.Count(); i++)
|
||||||
|
{
|
||||||
|
ArrayList tempList = new ArrayList();
|
||||||
|
foreach (PropertyInfo pi in props)
|
||||||
|
{
|
||||||
|
object obj = pi.GetValue(collection.ElementAt(i), null);
|
||||||
|
tempList.Add(obj);
|
||||||
|
}
|
||||||
|
object[] array = tempList.ToArray();
|
||||||
|
dt.LoadDataRow(array, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批量插入SqlBulkCopy
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dt"></param>
|
||||||
|
/// <param name="tableName">表名</param>
|
||||||
|
public static void BatchInsertBySqlBulkCopy(DataTable dt, string tableName)
|
||||||
|
{
|
||||||
|
using (SqlBulkCopy sbc = new SqlBulkCopy(connectionString))
|
||||||
|
{
|
||||||
|
sbc.BatchSize = dt.Rows.Count;
|
||||||
|
sbc.BulkCopyTimeout = 10;
|
||||||
|
sbc.DestinationTableName = tableName;
|
||||||
|
|
||||||
|
sbc.ColumnMappings.Clear();
|
||||||
|
//sbc.ColumnMappings.Add("CustomerID", "CustomerID");
|
||||||
|
//sbc.ColumnMappings.Add("FirstName", "FirstName");
|
||||||
|
//sbc.ColumnMappings.Add("LastName", "LastName");
|
||||||
|
//sbc.ColumnMappings.Add("Address1", "Address1");
|
||||||
|
//sbc.ColumnMappings.Add("Address2", "Address2");
|
||||||
|
for (int i = 0; i < dt.Columns.Count; i++)
|
||||||
|
{
|
||||||
|
sbc.ColumnMappings.Add(dt.Columns[i].ColumnName, dt.Columns[i].ColumnName);
|
||||||
|
}
|
||||||
|
//全部写入数据库
|
||||||
|
sbc.WriteToServer(dt);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 批量插入数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dt"></param>
|
||||||
|
public static int BulkToDB(string tableName, List<T> list)
|
||||||
|
{
|
||||||
|
//int result = 0;
|
||||||
|
DataTable dt = ListToDt(list);
|
||||||
|
BatchInsertBySqlBulkCopy(dt, tableName);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 事务1 - 全SQL
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sqlarr">多条SQL</param>
|
||||||
|
/// <param name="param">param</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int ExecuteTransaction(string[] sqlarr)
|
||||||
|
{
|
||||||
|
using (SqlConnection con = new SqlConnection(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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 事务2 - 声明参数
|
||||||
|
///demo:
|
||||||
|
///dic.Add("Insert into Users values (@UserName, @Email, @Address)",
|
||||||
|
/// new { UserName = "jack", Email = "380234234@qq.com", Address = "上海" });
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Key">多条SQL</param>
|
||||||
|
/// <param name="Value">param</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int ExecuteTransaction(Dictionary<string, object> dic)
|
||||||
|
{
|
||||||
|
using (SqlConnection con = new SqlConnection(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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-9.0.0.7" newVersion="9.0.0.7" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-6.10.9.0" newVersion="6.10.9.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.2.4.0" newVersion="4.2.4.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<packages>
|
||||||
|
<package id="BouncyCastle.Cryptography" version="2.4.0" targetFramework="net48" />
|
||||||
|
<package id="CsvHelper" version="30.0.1" targetFramework="net452" requireReinstallation="true" />
|
||||||
|
<package id="Dapper" version="1.60.6" targetFramework="net452" />
|
||||||
|
<package id="Enums.NET" version="5.0.0" targetFramework="net48" />
|
||||||
|
<package id="EPPlus" version="8.0.8" targetFramework="net48" />
|
||||||
|
<package id="EPPlus.Interfaces" version="8.0.0" targetFramework="net48" />
|
||||||
|
<package id="ExtendedNumerics.BigDecimal" version="2025.1001.2.129" targetFramework="net48" />
|
||||||
|
<package id="MathNet.Numerics.Signed" version="5.0.0" targetFramework="net48" />
|
||||||
|
<package id="Microsoft.Bcl.AsyncInterfaces" version="10.0.9" targetFramework="net48" />
|
||||||
|
<package id="Microsoft.CSharp" version="4.3.0" targetFramework="net452" />
|
||||||
|
<package id="Microsoft.Extensions.DependencyInjection" version="10.0.9" targetFramework="net48" />
|
||||||
|
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="10.0.9" targetFramework="net48" />
|
||||||
|
<package id="Microsoft.IO.RecyclableMemoryStream" version="3.0.1" targetFramework="net48" />
|
||||||
|
<package id="Microsoft.Owin" version="4.2.3" targetFramework="net48" />
|
||||||
|
<package id="MySql.Data" version="6.10.9" targetFramework="net452" />
|
||||||
|
<package id="NPOI" version="2.7.4" targetFramework="net48" />
|
||||||
|
<package id="Owin" version="1.0" targetFramework="net452" />
|
||||||
|
<package id="SharpZipLib" version="1.4.2" targetFramework="net48" />
|
||||||
|
<package id="SixLabors.Fonts" version="1.0.1" targetFramework="net48" />
|
||||||
|
<package id="SixLabors.ImageSharp" version="3.1.11" targetFramework="net48" />
|
||||||
|
<package id="SqlSugar" version="5.1.4.207" targetFramework="net48" />
|
||||||
|
<package id="System.Buffers" version="4.5.1" targetFramework="net48" />
|
||||||
|
<package id="System.ComponentModel.Annotations" version="5.0.0" targetFramework="net48" />
|
||||||
|
<package id="System.Memory" version="4.5.5" targetFramework="net48" />
|
||||||
|
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
|
||||||
|
<package id="System.Runtime" version="4.3.1" targetFramework="net452" requireReinstallation="true" />
|
||||||
|
<package id="System.Runtime.CompilerServices.Unsafe" version="6.1.2" targetFramework="net48" />
|
||||||
|
<package id="System.Security.Cryptography.Xml" version="8.0.2" targetFramework="net48" />
|
||||||
|
<package id="System.Text.Encoding.CodePages" version="9.0.7" targetFramework="net48" />
|
||||||
|
<package id="System.Threading.Tasks.Extensions" version="4.6.3" targetFramework="net48" />
|
||||||
|
<package id="System.ValueTuple" version="4.3.0" targetFramework="net452" />
|
||||||
|
<package id="ZString" version="2.6.0" targetFramework="net48" />
|
||||||
|
</packages>
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<configuration>
|
||||||
|
<startup>
|
||||||
|
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8" />
|
||||||
|
</startup>
|
||||||
|
<connectionStrings>
|
||||||
|
<add name="MysqlConn" connectionString="Data Source='localhost';Database='data_run';User Id='root';Password='123456';charset='utf8';pooling=false;port=3306;" />
|
||||||
|
<add name="CurDB" connectionString="Server=localhost;Database=S1270;Uid=sa;Pwd=123456" />
|
||||||
|
</connectionStrings>
|
||||||
|
<runtime>
|
||||||
|
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-13.0.0.0" newVersion="13.0.0.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-6.0.3.0" newVersion="6.0.3.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Memory" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.1.2" newVersion="4.0.1.2" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="ICSharpCode.SharpZipLib" publicKeyToken="1b03e6acf1164f73" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-1.4.2.13" newVersion="1.4.2.13" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.0.3.0" newVersion="4.0.3.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Numerics.Vectors" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.1.4.0" newVersion="4.1.4.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Text.Encoding.CodePages" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-9.0.0.7" newVersion="9.0.0.7" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-6.10.9.0" newVersion="6.10.9.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
<dependentAssembly>
|
||||||
|
<assemblyIdentity name="System.Threading.Tasks.Extensions" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
|
||||||
|
<bindingRedirect oldVersion="0.0.0.0-4.2.4.0" newVersion="4.2.4.0" />
|
||||||
|
</dependentAssembly>
|
||||||
|
</assemblyBinding>
|
||||||
|
</runtime>
|
||||||
|
</configuration>
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using CsvHelper.Configuration.Attributes;
|
||||||
|
|
||||||
|
namespace JY.Inspection.Common
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 报警表单数据
|
||||||
|
/// </summary>
|
||||||
|
public class AlarmForm
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 报警地址
|
||||||
|
/// </summary>
|
||||||
|
[Name("寄存器地址")]
|
||||||
|
public string PLCAdress { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 报警内容
|
||||||
|
/// </summary>
|
||||||
|
[Name("报警信息")]
|
||||||
|
public string AlarmContent { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 报警代码
|
||||||
|
/// </summary>
|
||||||
|
[Name("故障代码")]
|
||||||
|
public string AlarmCode { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.Inspection.Common
|
||||||
|
{
|
||||||
|
public static class ByteUtil
|
||||||
|
{
|
||||||
|
public static byte[] ByteReverse(this byte[] Arrbyte)
|
||||||
|
{
|
||||||
|
byte[] ArrByte = Arrbyte.Select((x, i) => new { x, i }).GroupBy(x => x.i / 2).SelectMany(x => new byte[] { x.Last().x, x.First().x }).ToArray();
|
||||||
|
return ArrByte;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,100 @@
|
|||||||
|
using CsvHelper;
|
||||||
|
using JY.Utility;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace JY.Inspection
|
||||||
|
{
|
||||||
|
public class CSVHelper<T>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 读取CSV文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fileName">csv文件名</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<T> ReadCSV(string fileName, string strSeparator = "\t")
|
||||||
|
{
|
||||||
|
if (!File.Exists(fileName)) return null;
|
||||||
|
//Nuget获取CsvHelper
|
||||||
|
using (var reader = new StreamReader(fileName))
|
||||||
|
{
|
||||||
|
var cfg = new CsvHelper.Configuration.CsvConfiguration(CultureInfo.InvariantCulture)
|
||||||
|
{
|
||||||
|
Mode = CsvMode.Escape,
|
||||||
|
Escape = '\\',
|
||||||
|
Delimiter = strSeparator//设置分隔符号
|
||||||
|
};
|
||||||
|
using (var csv = new CsvReader(reader, cfg))
|
||||||
|
{
|
||||||
|
var list = csv.GetRecords<T>().ToList();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 写入数据到csv文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filePath">所需存储文件夹路径(取系统所设定值,不带日期文件夹)</param>
|
||||||
|
/// <param name="data">数据源</param>
|
||||||
|
/// <param name="flag">1进站,2出站,3智能电表.csv,4预警</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool WriteCSV(string filePath, List<T> data, int flag)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(filePath))
|
||||||
|
{
|
||||||
|
filePath = Application.StartupPath + "\\localData\\" + DateTime.Now.ToString("yyyyMMdd");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
filePath = filePath + "\\" + DateTime.Now.ToString("yyyyMMdd");
|
||||||
|
}
|
||||||
|
if (!Directory.Exists(filePath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(filePath);
|
||||||
|
}
|
||||||
|
switch (flag)
|
||||||
|
{
|
||||||
|
case 1:
|
||||||
|
filePath = filePath + "\\" + DateTime.Now.ToString("yyyyMMdd") + "进站.csv";
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
filePath = filePath + "\\" + DateTime.Now.ToString("yyyyMMdd") + "出站.csv";
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
filePath = filePath + "\\" + DateTime.Now.ToString("yyyyMMdd") + "智能电表.csv";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
filePath = filePath + "\\" + DateTime.Now.ToString("yyyyMMdd") + "报警.csv";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var cfg = new CsvHelper.Configuration.CsvConfiguration(CultureInfo.InvariantCulture);
|
||||||
|
if (File.Exists(filePath))
|
||||||
|
{
|
||||||
|
cfg.HasHeaderRecord = false;//是否将第一行作为标题
|
||||||
|
}
|
||||||
|
using (var writer = new StreamWriter(filePath, true, Encoding.GetEncoding("GB2312")))
|
||||||
|
{
|
||||||
|
using (var csv = new CsvWriter(writer, cfg))
|
||||||
|
{
|
||||||
|
csv.WriteRecords(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogHelper.Error(ex.ToString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.Inspection.Common
|
||||||
|
{
|
||||||
|
public class CollectionUtil
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 生成ushort List集合
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Num"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<short> GetListUShort(int Num)
|
||||||
|
{
|
||||||
|
List<short> list = new List<short>();
|
||||||
|
for (int i = 0; i < Num; i++)
|
||||||
|
{
|
||||||
|
list.Add(1);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.Inspection
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 与客户端的 连接通信类(包含了一个 与客户端 通信的 套接字,和线程)
|
||||||
|
/// </summary>
|
||||||
|
public class ConnectionClient
|
||||||
|
{
|
||||||
|
Socket sokMsg;
|
||||||
|
DGShowMsg dgShowMsg;//负责 向主窗体文本框显示消息的方法委托
|
||||||
|
DGShowMsg dgRemoveConnection;// 负责 从主窗体 中移除 当前连接
|
||||||
|
Thread threadMsg;
|
||||||
|
|
||||||
|
#region 构造函数
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sokMsg">通信套接字</param>
|
||||||
|
/// <param name="dgShowMsg">向主窗体文本框显示消息的方法委托</param>
|
||||||
|
public ConnectionClient(Socket sokMsg, DGShowMsg dgShowMsg, DGShowMsg dgRemoveConnection)
|
||||||
|
{
|
||||||
|
this.sokMsg = sokMsg;
|
||||||
|
this.dgShowMsg = dgShowMsg;
|
||||||
|
this.dgRemoveConnection = dgRemoveConnection;
|
||||||
|
|
||||||
|
this.threadMsg = new Thread(RecMsg);
|
||||||
|
this.threadMsg.IsBackground = true;
|
||||||
|
this.threadMsg.Start();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
bool isRec = true;
|
||||||
|
#region 02负责监听客户端发送来的消息
|
||||||
|
void RecMsg()
|
||||||
|
{
|
||||||
|
while (isRec)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
byte[] arrMsg = new byte[1024 * 1024 * 2];
|
||||||
|
//接收 对应 客户端发来的消息
|
||||||
|
int length = sokMsg.Receive(arrMsg);
|
||||||
|
//将接收到的消息数组里真实消息转成字符串
|
||||||
|
string strMsg = System.Text.Encoding.UTF8.GetString(arrMsg, 0, length);
|
||||||
|
//通过委托 显示消息到 窗体的文本框
|
||||||
|
dgShowMsg(strMsg);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
isRec = false;
|
||||||
|
//从主窗体中 移除 下拉框中对应的客户端选择项,同时 移除 集合中对应的 ConnectionClient对象
|
||||||
|
dgRemoveConnection(sokMsg.RemoteEndPoint.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 03向客户端发送消息
|
||||||
|
/// <summary>
|
||||||
|
/// 向客户端发送消息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strMsg"></param>
|
||||||
|
public void Send(string strMsg)
|
||||||
|
{
|
||||||
|
byte[] arrMsg = System.Text.Encoding.UTF8.GetBytes(strMsg);
|
||||||
|
byte[] arrMsgFinal = new byte[arrMsg.Length + 1];
|
||||||
|
|
||||||
|
arrMsgFinal[0] = 0;//设置 数据标识位等于0,代表 发送的是 文字
|
||||||
|
arrMsg.CopyTo(arrMsgFinal, 0);
|
||||||
|
|
||||||
|
sokMsg.Send(arrMsgFinal);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 04向客户端发送文件数据 +void SendFile(string strPath)
|
||||||
|
/// <summary>
|
||||||
|
/// 04向客户端发送文件数据
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strPath">文件路径</param>
|
||||||
|
public void SendFile(string strPath)
|
||||||
|
{
|
||||||
|
//通过文件流 读取文件内容
|
||||||
|
using (FileStream fs = new FileStream(strPath, FileMode.OpenOrCreate))
|
||||||
|
{
|
||||||
|
byte[] arrFile = new byte[1024 * 1024 * 2];
|
||||||
|
//读取文件内容到字节数组,并 获得 实际文件大小
|
||||||
|
int length = fs.Read(arrFile, 0, arrFile.Length);
|
||||||
|
//定义一个 新数组,长度为文件实际长度 +1
|
||||||
|
byte[] arrFileFina = new byte[length + 1];
|
||||||
|
arrFileFina[0] = 1;//设置 数据标识位等于1,代表 发送的是文件
|
||||||
|
//将 文件数据数组 复制到 新数组中,下标从1开始
|
||||||
|
//arrFile.CopyTo(arrFileFina, 1);
|
||||||
|
Buffer.BlockCopy(arrFile, 0, arrFileFina, 1, length);
|
||||||
|
//发送文件数据
|
||||||
|
sokMsg.Send(arrFileFina);//, 0, length + 1, SocketFlags.None);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 05向客户端发送闪屏
|
||||||
|
/// <summary>
|
||||||
|
/// 向客户端发送闪屏
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strMsg"></param>
|
||||||
|
public void SendShake()
|
||||||
|
{
|
||||||
|
byte[] arrMsgFinal = new byte[1];
|
||||||
|
arrMsgFinal[0] = 2;
|
||||||
|
sokMsg.Send(arrMsgFinal);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 06关闭与客户端连接
|
||||||
|
/// <summary>
|
||||||
|
/// 关闭与客户端连接
|
||||||
|
/// </summary>
|
||||||
|
public void CloseConnection()
|
||||||
|
{
|
||||||
|
isRec = false;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.Inspection
|
||||||
|
{
|
||||||
|
public delegate void DGShowMsg(string strMsg);
|
||||||
|
}
|
||||||
@@ -0,0 +1,127 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Sockets;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.Inspection
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设置电脑时间
|
||||||
|
/// </summary>
|
||||||
|
public class DateTimeSynchronization
|
||||||
|
{
|
||||||
|
[StructLayout(LayoutKind.Sequential)]
|
||||||
|
private struct Systemtime
|
||||||
|
{
|
||||||
|
public short year;
|
||||||
|
public short month;
|
||||||
|
public short dayOfWeek;
|
||||||
|
public short day;
|
||||||
|
public short hour;
|
||||||
|
public short minute;
|
||||||
|
public short second;
|
||||||
|
public short milliseconds;
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
private static extern bool SetLocalTime(ref Systemtime time);
|
||||||
|
|
||||||
|
private static uint swapEndian(ulong x)
|
||||||
|
{
|
||||||
|
return (uint)(((x & 0x000000ff) << 24) +
|
||||||
|
((x & 0x0000ff00) << 8) +
|
||||||
|
((x & 0x00ff0000) >> 8) +
|
||||||
|
((x & 0xff000000) >> 24));
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 手动设置系统时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dt">需要设置的时间</param>
|
||||||
|
/// <returns>返回系统时间设置状态,true为成功,false为失败</returns>
|
||||||
|
public static bool SetLocalDateTime(DateTime dt)
|
||||||
|
{
|
||||||
|
Systemtime st;
|
||||||
|
st.year = (short)dt.Year;
|
||||||
|
st.month = (short)dt.Month;
|
||||||
|
st.dayOfWeek = (short)dt.DayOfWeek;
|
||||||
|
st.day = (short)dt.Day;
|
||||||
|
st.hour = (short)dt.Hour;
|
||||||
|
st.minute = (short)dt.Minute;
|
||||||
|
st.second = (short)dt.Second;
|
||||||
|
st.milliseconds = (short)dt.Millisecond;
|
||||||
|
bool rt = SetLocalTime(ref st);
|
||||||
|
return rt;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static IPAddress iPAddress = null;
|
||||||
|
/// <summary>
|
||||||
|
/// 从NTP获取时间更新本地时间
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="host"></param>
|
||||||
|
/// <param name="syncDateTime"></param>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool Synchronization(string host, out DateTime syncDateTime, out string message)
|
||||||
|
{
|
||||||
|
syncDateTime = DateTime.Now;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
message = "";
|
||||||
|
if (iPAddress == null)
|
||||||
|
{
|
||||||
|
var iphostinfo = Dns.GetHostEntry(host);
|
||||||
|
var ntpServer = iphostinfo.AddressList[0];
|
||||||
|
iPAddress = ntpServer;
|
||||||
|
}
|
||||||
|
DateTime dtStart = DateTime.Now;
|
||||||
|
//NTP消息大小摘要是16字节 (RFC 2030)
|
||||||
|
byte[] ntpData = new byte[48];
|
||||||
|
//设置跳跃指示器、版本号和模式值
|
||||||
|
// LI = 0 (no warning), VN = 3 (IPv4 only), Mode = 3 (Client Mode)
|
||||||
|
ntpData[0] = 0x1B;
|
||||||
|
IPAddress ip = iPAddress;
|
||||||
|
// NTP服务给UDP分配的端口号是123
|
||||||
|
IPEndPoint ipEndPoint = new IPEndPoint(ip, 123);
|
||||||
|
// 使用UTP进行通讯
|
||||||
|
Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
|
||||||
|
socket.Connect(ipEndPoint);
|
||||||
|
socket.ReceiveTimeout = 3000;
|
||||||
|
socket.Send(ntpData);
|
||||||
|
socket.Receive(ntpData);
|
||||||
|
socket?.Close();
|
||||||
|
socket?.Dispose();
|
||||||
|
DateTime dtEnd = DateTime.Now;
|
||||||
|
//传输时间戳字段偏移量,以64位时间戳格式,应答离开客户端服务器的时间
|
||||||
|
const byte serverReplyTime = 40;
|
||||||
|
// 获得秒的部分
|
||||||
|
ulong intPart = BitConverter.ToUInt32(ntpData, serverReplyTime);
|
||||||
|
//获取秒的部分
|
||||||
|
ulong fractPart = BitConverter.ToUInt32(ntpData, serverReplyTime + 4);
|
||||||
|
//由big-endian 到 little-endian的转换
|
||||||
|
intPart = swapEndian(intPart);
|
||||||
|
fractPart = swapEndian(fractPart);
|
||||||
|
ulong milliseconds = (intPart * 1000) + ((fractPart * 1000) / 0x100000000UL);
|
||||||
|
// UTC时间
|
||||||
|
DateTime webTime = (new DateTime(1900, 1, 1, 0, 0, 0, DateTimeKind.Utc)).AddMilliseconds(milliseconds);
|
||||||
|
//本地时间
|
||||||
|
DateTime dt = webTime.ToLocalTime();
|
||||||
|
bool isSuccess = SetLocalDateTime(dt);
|
||||||
|
syncDateTime = dt;
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
message = ex.Message;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,120 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
|
namespace JY.Inspection
|
||||||
|
{
|
||||||
|
public class ServiceLog
|
||||||
|
{
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
Thread thread = new Thread(Init);
|
||||||
|
thread.IsBackground = true;
|
||||||
|
thread.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Init()
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DeleteFile(System.Environment.CurrentDirectory + @"\Logs\", 30); //删除该目录下 超过 30天的文件
|
||||||
|
}
|
||||||
|
catch (Exception err)
|
||||||
|
{
|
||||||
|
Console.WriteLine(err.Message, err.StackTrace);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Thread.Sleep(100000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void DeleteFile(string fileDirect, int saveDay)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DateTime nowTime = DateTime.Now;
|
||||||
|
string[] files = Directory.GetFiles(fileDirect, "*.txt", SearchOption.AllDirectories); //获取该目录下所有 .txt文件
|
||||||
|
foreach (string file in files)
|
||||||
|
{
|
||||||
|
FileInfo fileInfo = new FileInfo(file);
|
||||||
|
TimeSpan t = DateTime.Now - fileInfo.CreationTime; //当前时间 减去 文件创建时间
|
||||||
|
int day = t.Days;
|
||||||
|
if (day > saveDay) //保存的时间,单位:天
|
||||||
|
{
|
||||||
|
if (IsOccupy(fileInfo.FullName)) //判断文件是否被占用
|
||||||
|
{
|
||||||
|
System.IO.File.Delete(fileInfo.FullName); //删除文件
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
Log4Helper.WriteLog("文件被占用,无法操作!","错误提示");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception err)
|
||||||
|
{
|
||||||
|
Log4Helper.WriteLog("文件被占用,无法操作!",err);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
public static extern IntPtr _lopen(string lpPathName, int iReadWrite);
|
||||||
|
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
public static extern bool CloseHandle(IntPtr hObject);
|
||||||
|
|
||||||
|
public const int OF_READWRITE = 2;
|
||||||
|
public const int OF_SHARE_DENY_NONE = 0x40;
|
||||||
|
public readonly IntPtr HFILE_ERROR = new IntPtr(-1);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判断文件是否被占用
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="file"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private bool IsOccupy(string file)
|
||||||
|
{
|
||||||
|
bool result = true; //默认状态此文件未被占用
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//string vFileName = @"c:\temp\temp.bmp";
|
||||||
|
string vFileName = file;
|
||||||
|
if (!System.IO.File.Exists(vFileName))
|
||||||
|
{
|
||||||
|
//Logger.Info("文件都不存在!");
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
IntPtr vHandle = _lopen(vFileName, OF_READWRITE | OF_SHARE_DENY_NONE);
|
||||||
|
if (vHandle == HFILE_ERROR)
|
||||||
|
{
|
||||||
|
|
||||||
|
Log4Helper.WriteLog("文件被占用!", "错误提示");
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
CloseHandle(vHandle);
|
||||||
|
Log4Helper.WriteLog("没有被占用!", "错误提示");
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (Exception err)
|
||||||
|
{
|
||||||
|
result = false;
|
||||||
|
Log4Helper.WriteLog("判断文件是否被占用", err);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,157 @@
|
|||||||
|
using System;
|
||||||
|
using System.Data;
|
||||||
|
using System.Data.OleDb;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace JY.Infrastructure.Common
|
||||||
|
{
|
||||||
|
public class ExcelToSQL
|
||||||
|
{
|
||||||
|
//DBUnti _db = new DBUnti();
|
||||||
|
|
||||||
|
|
||||||
|
public bool ExcelToSql(ref string strErr)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OpenFileDialog fd = new OpenFileDialog();
|
||||||
|
fd.Filter = "导入SQL数据库|*.xlsx;*.xls";//打开文件对话框筛选器
|
||||||
|
if (fd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
bool b= TransferData(fd.FileName, "tb_hxconfigbase", ref strErr); //数据库表中名称
|
||||||
|
if (b)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
strErr = ex.Message;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Excel导入到Mysql
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="strErr"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool ExcelToStandardSQL(ref string strErr)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
strErr = "";
|
||||||
|
OpenFileDialog fd = new OpenFileDialog();
|
||||||
|
fd.Filter = "导入SQL数据库|*.xlsx;*.xls";//打开文件对话框筛选器
|
||||||
|
if (fd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
DataTable dt = GetExcelDatatable(fd.FileName, "mapTable");
|
||||||
|
bool b = OpDataBase.InsetMySqlData(dt,ref strErr);
|
||||||
|
if (strErr=="")
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
//TransferData(fd.FileName, "tb_hxconfigbase", _db.connstr,ref strErr); //数据库表中名称
|
||||||
|
}
|
||||||
|
strErr = "取消导入";
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
strErr = ex.Message;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Excel导入到SQLSERVER
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="excelFile"></param>
|
||||||
|
/// <param name="sheetName"></param>
|
||||||
|
/// <param name="strErr"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool TransferData(string excelFile, string sheetName, ref string strErr)
|
||||||
|
{
|
||||||
|
strErr = "";
|
||||||
|
DataSet ds = new DataSet();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string strConn = "";
|
||||||
|
strConn = "Provider = Microsoft.Jet.OLEDB.4.0; Data Source=" + excelFile + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'";
|
||||||
|
strConn = "Provider = Microsoft.ACE.OLEDB.12.0;Data Source=" + excelFile + ";Extended Properties='Excel 12.0;HDR=Yes;IMEX=1'";
|
||||||
|
OleDbConnection conn = new OleDbConnection(strConn);
|
||||||
|
conn.Open();
|
||||||
|
string strExcel = "";
|
||||||
|
OleDbDataAdapter myCommand;
|
||||||
|
strExcel = string.Format("select * from [{0}$]", sheetName);
|
||||||
|
myCommand = new OleDbDataAdapter(strExcel, strConn);
|
||||||
|
myCommand.Fill(ds, sheetName);
|
||||||
|
bool b= OpDataBase.InsetSqlData(ds, sheetName,ref strErr);
|
||||||
|
if (strErr=="")
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#region 屏蔽
|
||||||
|
////列出ds内存表内所有数据,通过For循环把ModelType项数据添加到List集合
|
||||||
|
//List<string> Mlist = new List<string>();
|
||||||
|
//for (int i=0;i<ds.Tables[0].Rows.Count;i++)
|
||||||
|
//{
|
||||||
|
// Mlist.Add(ds.Tables[0].Rows[i][0].ToString());
|
||||||
|
//}
|
||||||
|
//HashSet<string> typeSet = new HashSet<string>(Mlist);//去除List集合重复项
|
||||||
|
//foreach(var item in typeSet)
|
||||||
|
//{
|
||||||
|
// _sqldb.AddModelType(item, ref strErr);
|
||||||
|
//}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
//如果目标表不存在则创建,excel文件的第一行为列标题,从第二行开始全部都是数据记录
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
strErr = ex.Message;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTable GetExcelDatatable(string fileUrl, string table)
|
||||||
|
{
|
||||||
|
//office2007之前 仅支持.xls
|
||||||
|
//const string cmdText = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source={0};Extended Properties='Excel 8.0;IMEX=1';";
|
||||||
|
//支持.xls和.xlsx,即包括office2010等版本的 HDR=Yes代表第一行是标题,不是数据;
|
||||||
|
const string cmdText = "Provider=Microsoft.Ace.OleDb.12.0;Data Source={0};Extended Properties='Excel 12.0; HDR=Yes; IMEX=1'";
|
||||||
|
DataTable dt = null;
|
||||||
|
//建立连接
|
||||||
|
OleDbConnection conn = new OleDbConnection(string.Format(cmdText, fileUrl));
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//打开连接
|
||||||
|
if (conn.State == ConnectionState.Broken || conn.State == ConnectionState.Closed)
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
}
|
||||||
|
System.Data.DataTable schemaTable = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
|
||||||
|
//获取Excel的第一个Sheet名称
|
||||||
|
string sheetName = schemaTable.Rows[0]["TABLE_NAME"].ToString().Trim();
|
||||||
|
//查询sheet中的数据
|
||||||
|
string strSql = "select * from [" + sheetName + "]";
|
||||||
|
OleDbDataAdapter da = new OleDbDataAdapter(strSql, conn);
|
||||||
|
DataSet ds = new DataSet();
|
||||||
|
da.Fill(ds, table);
|
||||||
|
dt = ds.Tables[0];
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
catch (Exception exc)
|
||||||
|
{
|
||||||
|
throw exc;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
conn.Close();
|
||||||
|
conn.Dispose();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using NPOI;
|
||||||
|
using NPOI.HPSF;
|
||||||
|
using NPOI.HSSF;
|
||||||
|
using NPOI.HSSF.UserModel;
|
||||||
|
using NPOI.SS.UserModel;
|
||||||
|
using NPOI.POIFS;
|
||||||
|
using NPOI.Util;
|
||||||
|
using System.IO;
|
||||||
|
using System.Data;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.Infrastructure.Common
|
||||||
|
{
|
||||||
|
class ExportXls
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 由DataTable导出Excel
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourceTable">要导出数据的DataTable</param>
|
||||||
|
/// <returns>Excel工作表</returns>
|
||||||
|
public void ExportDataTableToExcel(DataTable sourceTable, string sheetName, string filepath)
|
||||||
|
{
|
||||||
|
|
||||||
|
FileStream file = new FileStream(filepath, FileMode.Create);
|
||||||
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
||||||
|
// MemoryStream ms = new MemoryStream();
|
||||||
|
ISheet sheet = workbook.CreateSheet(sheetName);
|
||||||
|
IRow headerRow = sheet.CreateRow(0);
|
||||||
|
// handling header.
|
||||||
|
foreach (DataColumn column in sourceTable.Columns)
|
||||||
|
|
||||||
|
headerRow.CreateCell(column.Ordinal).SetCellValue(column.ColumnName);
|
||||||
|
// handling value.
|
||||||
|
int rowIndex = 1;
|
||||||
|
|
||||||
|
foreach (DataRow row in sourceTable.Rows)
|
||||||
|
{
|
||||||
|
IRow dataRow = sheet.CreateRow(rowIndex);
|
||||||
|
foreach (DataColumn column in sourceTable.Columns)
|
||||||
|
{
|
||||||
|
dataRow.CreateCell(column.Ordinal).SetCellValue(row[column].ToString());
|
||||||
|
}
|
||||||
|
rowIndex++;
|
||||||
|
}
|
||||||
|
|
||||||
|
workbook.Write(file);
|
||||||
|
file.Close();
|
||||||
|
sheet = null;
|
||||||
|
headerRow = null;
|
||||||
|
workbook = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
using JY.Model;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace JY.Inspection
|
||||||
|
{
|
||||||
|
public class Global
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 错误日志路径
|
||||||
|
/// </summary>
|
||||||
|
public static string strErrorLogspath = System.Windows.Forms.Application.StartupPath + "\\Logs\\ErrorLogs";
|
||||||
|
|
||||||
|
public static string strSystemLogspath = System.Windows.Forms.Application.StartupPath + "\\Logs\\SystemLogs";
|
||||||
|
/// <summary>
|
||||||
|
/// MES路径日志
|
||||||
|
/// </summary>
|
||||||
|
public static string strMesLogspath = System.Windows.Forms.Application.StartupPath + "\\Logs\\MesLogs";
|
||||||
|
/// <summary>
|
||||||
|
/// PLC读取寄存器配置文件路径
|
||||||
|
/// </summary>
|
||||||
|
public static string ConfigPath = Path.Combine(System.Windows.Forms.Application.StartupPath, "ini\\PlcConfig.ini");
|
||||||
|
/// <summary>
|
||||||
|
/// 系统程序配置文件路径
|
||||||
|
/// </summary>
|
||||||
|
public static string iniFilePath = Path.Combine(System.Windows.Forms.Application.StartupPath, "ini\\Configure.ini");
|
||||||
|
|
||||||
|
public static string CollectItemCfgPath = Path.Combine(System.Windows.Forms.Application.StartupPath, @"Config/采集项参照表.xlsx");
|
||||||
|
|
||||||
|
|
||||||
|
public static SystemConfig systemConfig = new SystemConfig();
|
||||||
|
|
||||||
|
|
||||||
|
public static List<string> Instructions = new List<string>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
using log4net;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
namespace JY.Inspection
|
||||||
|
{
|
||||||
|
internal class Log4Helper
|
||||||
|
{
|
||||||
|
public static void WriteLog(Type t, Exception ex)
|
||||||
|
{
|
||||||
|
ILog log = LogManager.GetLogger(t);
|
||||||
|
log.Error(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteLog(Type t, string msg)
|
||||||
|
{
|
||||||
|
ILog log = LogManager.GetLogger(t);
|
||||||
|
log.Info(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteLog(string className, Exception ex)
|
||||||
|
{
|
||||||
|
ILog log = LogManager.GetLogger(className);
|
||||||
|
log.Error(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void WriteLog(string className, string msg)
|
||||||
|
{
|
||||||
|
ILog log = LogManager.GetLogger(className);
|
||||||
|
log.Info(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace JY.Inspection
|
||||||
|
{
|
||||||
|
public class MessageBoxTimeOut
|
||||||
|
{
|
||||||
|
private string _caption;
|
||||||
|
//public void Alert(string msg, FrmAlert.enmType type)
|
||||||
|
//{
|
||||||
|
// FrmAlert frm = new FrmAlert();
|
||||||
|
// frm.ShowAlert(msg, type);
|
||||||
|
//}
|
||||||
|
public void Show(string text, FrmAlert.enmType type)
|
||||||
|
{
|
||||||
|
this._caption = "信息提示";
|
||||||
|
StartTimer(3000);
|
||||||
|
//Alert(text, type);
|
||||||
|
|
||||||
|
MessageBox.Show(text,"信息提示");
|
||||||
|
}
|
||||||
|
private void StartTimer(int interval)
|
||||||
|
{
|
||||||
|
Timer timer = new Timer();
|
||||||
|
timer.Interval = interval;
|
||||||
|
timer.Tick += new EventHandler(Timer_Tick);
|
||||||
|
timer.Enabled = true;
|
||||||
|
}
|
||||||
|
private void Timer_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
KillMessageBox();
|
||||||
|
//停止计时器
|
||||||
|
((Timer)sender).Enabled = false;
|
||||||
|
}
|
||||||
|
[DllImport("User32.dll", EntryPoint = "FindWindow", CharSet = CharSet.Auto)]
|
||||||
|
private extern static IntPtr FindWindow(string lpClassName, string lpWindowName);
|
||||||
|
[DllImport("User32.dll", CharSet = CharSet.Auto)]
|
||||||
|
public static extern int PostMessage(IntPtr hWnd, int msg, IntPtr wParam, IntPtr lParam);
|
||||||
|
public const int WM_CLOSE = 0x10;
|
||||||
|
private void KillMessageBox()
|
||||||
|
{
|
||||||
|
//查找MessageBox的弹出窗口,注意对应标题
|
||||||
|
IntPtr ptr = FindWindow(null, this._caption);
|
||||||
|
if (ptr != IntPtr.Zero)
|
||||||
|
{
|
||||||
|
//查找到窗口则关闭
|
||||||
|
PostMessage(ptr, WM_CLOSE, IntPtr.Zero, IntPtr.Zero);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,443 @@
|
|||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace JY.Inspection
|
||||||
|
{
|
||||||
|
|
||||||
|
public enum Logstype//枚举类型
|
||||||
|
{
|
||||||
|
Message,
|
||||||
|
Warning,
|
||||||
|
Error
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 轻快型消息提示类
|
||||||
|
/// </summary>
|
||||||
|
public static class MessageTip
|
||||||
|
{
|
||||||
|
static readonly Image _iconOk;
|
||||||
|
static readonly Image _iconWarning;
|
||||||
|
static readonly Image _iconError;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 全局停留时长(毫秒),影响后续弹出的tip。默认500
|
||||||
|
/// </summary>
|
||||||
|
public static int DefaultDelay { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否允许上浮动画。默认true
|
||||||
|
/// </summary>
|
||||||
|
public static bool AllowFloating { get; set; }
|
||||||
|
|
||||||
|
static MessageTip()
|
||||||
|
{
|
||||||
|
DefaultDelay = 500;
|
||||||
|
AllowFloating = true;
|
||||||
|
|
||||||
|
Bitmap spriteImage;
|
||||||
|
using (var ms = new MemoryStream(Convert.FromBase64String(DefaultIconData)))
|
||||||
|
{
|
||||||
|
//不能直接用Img.FromMs得到的对象,怀疑因该方法得到的对象与源ms有瓜葛
|
||||||
|
//ms释放后会导致莫名问题,比如下面的Clone会引发内存不足异常
|
||||||
|
//而new Bitmap(Image)相当于基于Image重造了一个全新的bmp
|
||||||
|
spriteImage = new Bitmap(Image.FromStream(ms));
|
||||||
|
}
|
||||||
|
|
||||||
|
_iconOk = spriteImage.Clone(new Rectangle(0, 0, 32, 32), spriteImage.PixelFormat);
|
||||||
|
_iconWarning = spriteImage.Clone(new RectangleF(32, 0, 32, 32), spriteImage.PixelFormat);
|
||||||
|
_iconError = spriteImage.Clone(new RectangleF(64, 0, 32, 32), spriteImage.PixelFormat);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 显示良好消息,图标为绿勾 √
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">消息文本</param>
|
||||||
|
/// <param name="delay">消息停留时长(毫秒)。指定负数则使用 DefaultDelay</param>
|
||||||
|
public static void ShowOk(string text = null, int delay = -1)
|
||||||
|
{
|
||||||
|
Show(text, _iconOk, Color.SeaGreen, Color.White, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 显示警告消息,图标为黄色感叹号 !
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">消息文本</param>
|
||||||
|
/// <param name="delay">消息停留时长(毫秒)。指定负数则使用 DefaultDelay</param>
|
||||||
|
public static void ShowWarning(string text = null, int delay = -1)
|
||||||
|
{
|
||||||
|
Show(text, _iconWarning, Color.DarkOrange, Color.Black, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 显示出错消息,图标为红叉 X
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">消息文本</param>
|
||||||
|
/// <param name="delay">消息停留时长(毫秒)。指定负数则使用 DefaultDelay</param>
|
||||||
|
public static void ShowError(string text = null, int delay = -1)
|
||||||
|
{
|
||||||
|
Show(text, _iconError, Color.Red, Color.White, delay);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 显示消息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="text">消息文本</param>
|
||||||
|
/// <param name="icon">图标。不会进行缩放</param>
|
||||||
|
/// <param name="delay">消息停留时长(毫秒)。指定负数则使用 DefaultDelay</param>
|
||||||
|
public static void Show(string text, Image icon, Color bkColor, Color textColor, int delay = -1)
|
||||||
|
{
|
||||||
|
ThreadPool.QueueUserWorkItem(obj => new TipForm
|
||||||
|
{
|
||||||
|
TipText = text,
|
||||||
|
TipIcon = icon,
|
||||||
|
Delay = delay < 0 ? DefaultDelay : delay,
|
||||||
|
Floating = AllowFloating,
|
||||||
|
BkColor = bkColor,
|
||||||
|
TextColor= textColor,
|
||||||
|
BasePoint = Control.MousePosition //在鼠标点击的附近弹出
|
||||||
|
}.ShowDialog()); ;//要让创建浮动窗体的线程具有消息循环,所以要用ShowDialog
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 内置图标数据:√ ! X
|
||||||
|
/// </summary>
|
||||||
|
const string DefaultIconData = @"R0lGODlhYAAgANUAAOrcJ9LORebm5tJKShPLJLczM/z3s/XrkNfSOhS2JKaYMezeaMoREfhwcNS3
|
||||||
|
t7IREVSkWpWQZjCpPfz8+zS4RN3PZdTU1EjLWG9uaO/w7/Dke1HVYfHsx5UzM8Q8PLjYuqmmn8bl
|
||||||
|
yeO3txsbD+fck9DAUeDaVV1cHuHXMDGTOO3iSeHy4+BYWDvGTPn25O/hN5PIl8K1Pbfhu/z78nW/
|
||||||
|
fPb39lbeZ5/WpIAzM2HpcqITExGiIjV/N8S9luLbqf///yH5BAAAAAAALAAAAABgACAAAAb/wJ9w
|
||||||
|
SCwaj8ikcslsOp/QKFNUEEGpVqm2OQtUZlJqo+oUk7fHFUWmJWk0pKi4Mc4qxaw6uli7bNZRMxUG
|
||||||
|
BhUuT3gseWdIc4p6e0I0Fzk5EmxPboQHcU2Jiot2RZ+PjFs3LTk2G5aYTC6DBweFh0wFDaC5kERi
|
||||||
|
Ayy+v4oFeyEUNqsbrJdNmm8GcJ63A9PUA7s/VL/V0yymUWobNhfj4xsSTByxb7MVHNEN29xn2fG+
|
||||||
|
3lB9F+LkfstLFbMWaBAoq0KZWx4SJhzgoZuIbB4YLox4DwqNFuJaaGxxgQIMdIM0RMCAIYKGQu6a
|
||||||
|
OCjAQqHLAQUKSHSZsOKTG8YubNRIgUYT/4AHFpAkqaHghIMtPRRQuhAm06VQHSiRAQhJCAl/JCSQ
|
||||||
|
wJUChBogDQgcimHBggPtnqyEGbOt27c2hciQYMNfkRUSOu7Yu1fCVyYTAA5cMJKk2aJfEHVgC9et
|
||||||
|
UqlJqNowZlfIBAgULvDtK2FFEx+DzArFcCKCaLQ+rixVCpd1B1FG5k6mQNnVDxoUNmzewTUElxIH
|
||||||
|
BhMeMeJEiQBeFpQAo7YDa9YPdEiP+0M27evmMN2QQCNBgs0SbjgBHXSBCQQniJ9AjnxBhU4H2Uqf
|
||||||
|
L/21ErrXrydoIeHD1Q3e7eDdVh814QJwGpjAngLEKcBeeyWA5cli9FVYH2xEzPUHBS0MuP+fBClc
|
||||||
|
4KGA3B3FTAUaBICAigEocMIJCqy4ohcBwHeHczpEZyF99iGhIQUeetfCH0H6lYETByaIwJJLxvBi
|
||||||
|
DEwyaUIJtSThQAcFPBCdljl2uWV0PR7xQV4EDFhmAmWe6R0EnjlRQQULRLmkCW+cJ6eCBiUhApZa
|
||||||
|
9unnn312AJmYErRAwKFopplmAin45gQHJWgg56SUTpmSEVcyAKiWHXSwKaeDGjGmooeWemgKHzwR
|
||||||
|
mAkmoODqqygwOIICsL66Yp6j4KDpA7vuKuiVWu7KK6hJfJCCqcimUOCjJSxQ66vEEffsqyVcKoQD
|
||||||
|
umqqrbY4QJYprwxs+4CgxR6LLAEp+KT/agkmqAArANBG+yy8KARQgok/YBvuvvx2S4S+4PLLgL9I
|
||||||
|
GIvsDhDg+1kM7gLgMLwPR0BcBA8/jMLDMaQmRLYCh0vwvxx3jIMSBiMKwZGqxmDCCxW3rIIsKrTc
|
||||||
|
MgIxmKivyKGC3PHAOf8wQQ0ZZCAACObyYIEAQWdQw9ITNH2EDwzLLPXUFWc8xM37fnwE1h73/APQ
|
||||||
|
AlggNgg88NCD2EcLgLTSThtB6wsqvCD33HIDwDLLVDsc678dZO11EZl2jcTPQattuNpJK11D020T
|
||||||
|
MUEPCkQu+eSUV255DwrrS65Kum4eyRJNAy304aSXXrriTk8wOgg4gIB22okbjjbrICC9E/jnuEcR
|
||||||
|
+uiHB73076KT7rvTQQAAOw==";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 浮动消息层
|
||||||
|
/// </summary>
|
||||||
|
private class TipForm : Form
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 图标和文本之间的间距(像素)
|
||||||
|
/// </summary>
|
||||||
|
const int IconTextSpacing = 3;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 基准点。用于指导本窗体显示位置
|
||||||
|
/// </summary>
|
||||||
|
public Point BasePoint { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 显示文字
|
||||||
|
/// </summary>
|
||||||
|
string _tipText;
|
||||||
|
/// <summary>
|
||||||
|
/// 背景色
|
||||||
|
/// </summary>
|
||||||
|
Color _bkColor = Color.SeaGreen;
|
||||||
|
/// <summary>
|
||||||
|
/// 文字颜色
|
||||||
|
/// </summary>
|
||||||
|
Color _textColor=Color.Black;
|
||||||
|
/// <summary>
|
||||||
|
/// 提示图标
|
||||||
|
/// </summary>
|
||||||
|
public Image TipIcon { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 提示文本
|
||||||
|
/// </summary>
|
||||||
|
public string TipText
|
||||||
|
{
|
||||||
|
get { return _tipText ?? string.Empty; }
|
||||||
|
set { _tipText = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 文字显示颜色
|
||||||
|
/// </summary>
|
||||||
|
//[DefaultValue(500)]
|
||||||
|
public Color TextColor
|
||||||
|
{
|
||||||
|
get { return _textColor; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_textColor = value;
|
||||||
|
this.ForeColor = _textColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 停留时长(毫秒)
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(500)]
|
||||||
|
public int Delay { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 停留时长(毫秒)
|
||||||
|
/// </summary>
|
||||||
|
//[DefaultValue(Color.White)]
|
||||||
|
public Color BkColor
|
||||||
|
{
|
||||||
|
get { return _bkColor; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_bkColor = value;
|
||||||
|
this.BackColor = _bkColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 是否允许浮动
|
||||||
|
/// </summary>
|
||||||
|
[DefaultValue(true)]
|
||||||
|
public bool Floating { get; set; }
|
||||||
|
|
||||||
|
//显示后不激活,即不抢焦点
|
||||||
|
protected override bool ShowWithoutActivation
|
||||||
|
{
|
||||||
|
get { return true; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public TipForm()
|
||||||
|
{
|
||||||
|
//双缓冲。有必要
|
||||||
|
SetStyle(ControlStyles.UserPaint, true);
|
||||||
|
DoubleBuffered = true;
|
||||||
|
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
Delay = 500;
|
||||||
|
Floating = true;
|
||||||
|
BkColor = Color.White;
|
||||||
|
this._timer.Tick += timer_Tick;
|
||||||
|
this.Load += TipForm_Load;
|
||||||
|
this.Shown += TipForm_Shown;
|
||||||
|
this.FormClosing += TipForm_FormClosing;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据图标和文字处理窗体尺寸
|
||||||
|
/// </summary>
|
||||||
|
private void ProcessClientSize()
|
||||||
|
{
|
||||||
|
Size size = Size.Empty;
|
||||||
|
if (TipIcon != null)
|
||||||
|
{
|
||||||
|
size += TipIcon.Size;
|
||||||
|
}
|
||||||
|
if (TipText.Length != 0)
|
||||||
|
{
|
||||||
|
if (TipIcon != null)
|
||||||
|
{
|
||||||
|
size.Width += IconTextSpacing;//图标与文字的间距
|
||||||
|
}
|
||||||
|
var textSize = TextRenderer.MeasureText(TipText, this.Font);
|
||||||
|
size.Width += textSize.Width;
|
||||||
|
if (size.Height < textSize.Height) { size.Height = textSize.Height; }
|
||||||
|
}
|
||||||
|
this.ClientSize = size + Padding.Size;
|
||||||
|
}
|
||||||
|
private int x, y; //显示的坐标变量
|
||||||
|
/// <summary>
|
||||||
|
/// 根据基准点处理窗体显示位置
|
||||||
|
/// </summary>
|
||||||
|
private void ProcessLocation()
|
||||||
|
{
|
||||||
|
|
||||||
|
#region 弹窗显示在屏幕中间
|
||||||
|
this.y = (Screen.PrimaryScreen.Bounds.Height - 30 - this.Height) / 2;
|
||||||
|
this.x = (Screen.PrimaryScreen.Bounds.Width - 10 - this.Width) / 2;
|
||||||
|
this.Location = new Point(this.x, this.y);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 弹窗显示在屏幕右下角
|
||||||
|
//this.x = Screen.PrimaryScreen.WorkingArea.Width - this.Width + 15;
|
||||||
|
//this.y = Screen.PrimaryScreen.WorkingArea.Height - this.Height * i - 5 * i;
|
||||||
|
//this.Location = new Point(this.x, this.y);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 弹窗跟随鼠标位置
|
||||||
|
//var p = BasePoint;
|
||||||
|
//p.X -= Screen.PrimaryScreen.WorkingArea.Width - this.Width - 1000;//Screen.PrimaryScreen.WorkingArea.Width-this.Width / 2;
|
||||||
|
|
||||||
|
////横向处理。距离屏幕左右两边太近时的处理
|
||||||
|
//int screenWidth;
|
||||||
|
//if (p.X < 10)
|
||||||
|
//{
|
||||||
|
// p.X = 10;
|
||||||
|
//}
|
||||||
|
//else if (p.X + this.Width > (screenWidth = Screen.PrimaryScreen.Bounds.Width) - 10)
|
||||||
|
//{
|
||||||
|
// p.X = screenWidth - 10 - this.Width;
|
||||||
|
//}
|
||||||
|
|
||||||
|
////纵向处理。在鼠标上方显示
|
||||||
|
//p.Y -= this.Height + 20;
|
||||||
|
|
||||||
|
//this.Location = p;
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
void TipForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
ProcessClientSize();
|
||||||
|
ProcessLocation();
|
||||||
|
|
||||||
|
//上浮窗体动画。采用异步,以不阻塞透明渐变动画的进行
|
||||||
|
if (Floating)
|
||||||
|
{
|
||||||
|
ThreadPool.QueueUserWorkItem(obj =>
|
||||||
|
{
|
||||||
|
while (this.IsHandleCreated)
|
||||||
|
{
|
||||||
|
this.BeginInvoke(new Action<object>(arg =>
|
||||||
|
{
|
||||||
|
this.Top--;
|
||||||
|
Application.DoEvents();
|
||||||
|
}), (object)null);
|
||||||
|
|
||||||
|
Thread.Sleep(30);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//透明渐入动画。之所以不用异步是为了在完全显示后再开始Delay的计时
|
||||||
|
//不然如果Delay设置过低,还没等看清就渐隐了
|
||||||
|
this.Opacity = 0;
|
||||||
|
while (this.Opacity < 1)
|
||||||
|
{
|
||||||
|
this.Opacity += 0.1;
|
||||||
|
Application.DoEvents();
|
||||||
|
Thread.Sleep(10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TipForm_Shown(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//因为timer.Interval不能为0
|
||||||
|
if (Delay > 0)
|
||||||
|
{
|
||||||
|
_timer.Interval = Delay;
|
||||||
|
_timer.Start();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void timer_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
_timer.Stop();
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TipForm_FormClosing(object sender, FormClosingEventArgs e)
|
||||||
|
{
|
||||||
|
//透明渐隐动画
|
||||||
|
while (this.Opacity > 0)
|
||||||
|
{
|
||||||
|
this.Opacity -= 0.1;
|
||||||
|
Application.DoEvents();
|
||||||
|
Thread.Sleep(20);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnPaint(PaintEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnPaint(e);
|
||||||
|
|
||||||
|
var clip = GetPaddedRectangle();//得到作图区域
|
||||||
|
var g = e.Graphics;
|
||||||
|
//g.DrawRectangle(Pens.Red, clip);//debug
|
||||||
|
|
||||||
|
//画图标
|
||||||
|
if (TipIcon != null)
|
||||||
|
{
|
||||||
|
g.DrawImageUnscaled(TipIcon, clip.Location);
|
||||||
|
}
|
||||||
|
//画文本
|
||||||
|
if (TipText.Length != 0)
|
||||||
|
{
|
||||||
|
if (TipIcon != null)
|
||||||
|
{
|
||||||
|
clip.X += TipIcon.Width + IconTextSpacing;
|
||||||
|
}
|
||||||
|
TextRenderer.DrawText(g, TipText, this.Font, clip, this.ForeColor, TextFormatFlags.VerticalCenter);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void OnPaintBackground(PaintEventArgs e)
|
||||||
|
{
|
||||||
|
base.OnPaintBackground(e);
|
||||||
|
|
||||||
|
//画边框
|
||||||
|
ControlPaint.DrawBorder(e.Graphics, this.ClientRectangle, SystemColors.ControlDark, ButtonBorderStyle.Solid);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取刨去Padding的内容区
|
||||||
|
/// </summary>
|
||||||
|
private Rectangle GetPaddedRectangle()
|
||||||
|
{
|
||||||
|
Rectangle r = this.ClientRectangle;
|
||||||
|
r.X += this.Padding.Left;
|
||||||
|
r.Y += this.Padding.Top;
|
||||||
|
r.Width -= this.Padding.Horizontal;
|
||||||
|
r.Height -= this.Padding.Vertical;
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 设计器内容
|
||||||
|
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
_timer.Dispose();//这货必须显示释放
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this._timer = new System.Windows.Forms.Timer();
|
||||||
|
this.SuspendLayout();
|
||||||
|
|
||||||
|
this.AutoScaleMode = AutoScaleMode.None;
|
||||||
|
//this.ClientSize = new System.Drawing.Size(100, 100);
|
||||||
|
this.BackColor = Color.White;
|
||||||
|
this.Font = new Font(SystemFonts.MessageBoxFont.FontFamily, 12);
|
||||||
|
this.FormBorderStyle = FormBorderStyle.None;
|
||||||
|
this.Padding = new Padding(20, 10, 20, 10);
|
||||||
|
this.Name = "TipForm";
|
||||||
|
this.ShowInTaskbar = false;
|
||||||
|
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
private System.Windows.Forms.Timer _timer;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,193 @@
|
|||||||
|
using JY.Inspection.Entity;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace JY.Inspection.Common
|
||||||
|
{
|
||||||
|
public static class PLCAlarmParse
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 三菱将报警地址值转成报警List
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plcAddrSuffix">PLC地址值,如100</param>
|
||||||
|
/// <param name="byteData">PLC读取出来的值</param>
|
||||||
|
/// <param name="plcAddrPrefix">PLC地址类型,默认值R</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<AlarmStatus> MelsecByte2Status(int plcAddrSuffix, byte[] byteData, char plcAddrPrefix = 'R')
|
||||||
|
{
|
||||||
|
var listAlarmStatus = new List<AlarmStatus>();
|
||||||
|
// byte[]转为二进制字符串表示
|
||||||
|
string strResult = "";
|
||||||
|
for (int i = 0; i < byteData.Length; i++)
|
||||||
|
{
|
||||||
|
string strTemp = System.Convert.ToString(byteData[i], 2);
|
||||||
|
strTemp = strTemp.PadLeft(8, '0').StrReverse();
|
||||||
|
strResult += strTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < strResult.Length; i++)
|
||||||
|
{
|
||||||
|
var plcByte = i % 16;
|
||||||
|
//如果是16的倍数地址+1
|
||||||
|
if (plcByte % 16 == 0 && i != 0)
|
||||||
|
{
|
||||||
|
plcAddrSuffix++;
|
||||||
|
}
|
||||||
|
//将地址和状态添加到结果集
|
||||||
|
listAlarmStatus.Add(new AlarmStatus()
|
||||||
|
{
|
||||||
|
PLCAdress = $"{plcAddrPrefix}{plcAddrSuffix}.{plcByte.ToString("X")}",
|
||||||
|
Status = strResult[i] == '1'
|
||||||
|
});
|
||||||
|
//if (strResult[i] == '1')
|
||||||
|
// Console.WriteLine($"{plcAddrPrefix}{plcAddrSuffix}.{plcByte.ToString("X")}:{strResult[i]}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return listAlarmStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 欧姆龙NX系列Ethernet/IP通讯时将报警地址值转成报警List {直接读取标签地址/无需高低位互换}
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plcAddrSuffix">PLC地址值,如100</param>
|
||||||
|
/// <param name="byteData">PLC读取出来的值</param>
|
||||||
|
/// <param name="plcAddrPrefix">PLC地址类型,默认值R</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<AlarmStatus> OmronEIPByte2Status(int plcAddrSuffix, List<byte> byteData, char plcAddrPrefix = 'W')
|
||||||
|
{
|
||||||
|
var listAlarmStatus = new List<AlarmStatus>();
|
||||||
|
// byte[]转为二进制字符串表示
|
||||||
|
string strResult = "";
|
||||||
|
for (int i = 0; i < byteData.Count; i++)
|
||||||
|
{
|
||||||
|
string strTemp = System.Convert.ToString(byteData[i], 2);
|
||||||
|
strTemp = strTemp.PadLeft(8, '0').StrReverse();
|
||||||
|
strResult += strTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < strResult.Length; i++)
|
||||||
|
{
|
||||||
|
var plcByte = i % 16;
|
||||||
|
//如果是16的倍数地址+1
|
||||||
|
if (plcByte % 16 == 0 && i != 0)
|
||||||
|
{
|
||||||
|
plcAddrSuffix++;
|
||||||
|
}
|
||||||
|
//将地址和状态添加到结果集
|
||||||
|
listAlarmStatus.Add(new AlarmStatus()
|
||||||
|
{
|
||||||
|
PLCAdress = $"{plcAddrPrefix}6100[{plcAddrSuffix}].B[{plcByte.ToString()}]",
|
||||||
|
Status = strResult[i] == '1'
|
||||||
|
});
|
||||||
|
|
||||||
|
//if (strResult[i] == '1')
|
||||||
|
// Console.WriteLine($"{plcAddrPrefix}{plcAddrSuffix}.{plcByte.ToString("X")}:{strResult[i]}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return listAlarmStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 欧姆龙FINS通讯读取EM数据寄存器是时将报警地址值转成报警List
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plcAddrSuffix">PLC地址值,如100</param>
|
||||||
|
/// <param name="byteData">PLC读取出来的值</param>
|
||||||
|
/// <param name="plcAddrPrefix">PLC地址类型,默认值W</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<AlarmStatus> OmronFinsByte2Status(int plcAddrSuffix, byte[] byteData, char plcAddrPrefix = 'E')
|
||||||
|
{
|
||||||
|
var listAlarmStatus = new List<AlarmStatus>();
|
||||||
|
// byte[]转为二进制字符串表示
|
||||||
|
byte[] revBytes = SWAPbyte(byteData); //字节高低位互换
|
||||||
|
string strResult = "";
|
||||||
|
for (int i = 0; i < revBytes.Length; i++)
|
||||||
|
{
|
||||||
|
string strTemp = System.Convert.ToString(revBytes[i], 2);
|
||||||
|
strTemp = strTemp.PadLeft(8, '0').StrReverse();
|
||||||
|
strResult += strTemp;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < strResult.Length; i++)
|
||||||
|
{
|
||||||
|
var plcByte = i % 16;
|
||||||
|
//如果是16的倍数地址+1
|
||||||
|
if (plcByte % 16 == 0 && i != 0)
|
||||||
|
{
|
||||||
|
plcAddrSuffix++;
|
||||||
|
}
|
||||||
|
//将地址和状态添加到结果集
|
||||||
|
listAlarmStatus.Add(new AlarmStatus()
|
||||||
|
{
|
||||||
|
PLCAdress = $"{plcAddrPrefix}{plcAddrSuffix}.{plcByte.ToString("X")}",
|
||||||
|
Status = strResult[i] == '1'
|
||||||
|
});
|
||||||
|
//if (strResult[i] == '1')
|
||||||
|
// Console.WriteLine($"{plcAddrPrefix}{plcAddrSuffix}.{plcByte.ToString("X")}:{strResult[i]}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return listAlarmStatus;
|
||||||
|
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 欧姆龙FINS通讯读取W数据寄存器是时将报警地址值转成报警List
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="plcAddrSuffix">PLC地址值,如100</param>
|
||||||
|
/// <param name="byteData">PLC读取出来的值</param>
|
||||||
|
/// <param name="plcAddrPrefix">PLC地址类型,默认值W</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//public static List<AlarmStatus> OmronByte2Status(int plcAddrSuffix, byte[] byteData, char plcAddrPrefix = 'W')
|
||||||
|
//{
|
||||||
|
// var listAlarmStatus = new List<AlarmStatus>();
|
||||||
|
|
||||||
|
// var addrCount = byteData.Length / 2;
|
||||||
|
// // byte[]每个地址保存的都是bool值,只取双数index位
|
||||||
|
// for (int i = 0; i < addrCount; i++)
|
||||||
|
// {
|
||||||
|
// //将地址和状态添加到结果集
|
||||||
|
// listAlarmStatus.Add(new AlarmStatus()
|
||||||
|
// {
|
||||||
|
// PLCAdress = $"{plcAddrPrefix}{plcAddrSuffix + i}",
|
||||||
|
// Status = byteData[i * 2 + 1] == 1
|
||||||
|
|
||||||
|
// });
|
||||||
|
// //if (byteData[i * 2 + 1] == 1)
|
||||||
|
// // Console.WriteLine($"原始数据 PLC地址:{plcAddrPrefix}{plcAddrSuffix + i} 报警值:{byteData[i * 2 + 1]}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return listAlarmStatus;
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 字符串反转
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str">需要反转字符串.Reverse()</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string StrReverse(this string str)
|
||||||
|
{
|
||||||
|
return new string(str.Reverse().ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///byte字节高低位互换
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static byte[] SWAPbyte(byte[] data)
|
||||||
|
{
|
||||||
|
byte[] data2 = new byte[data.Length];
|
||||||
|
for (int i = 0; i < data.Length; i += 2)
|
||||||
|
{
|
||||||
|
data2[i] = data[i + 1];
|
||||||
|
data2[i + 1] = data[i];
|
||||||
|
}
|
||||||
|
return data2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.Inspection.Common
|
||||||
|
{
|
||||||
|
public class StrUtil
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 前端字节补0
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str"></param>
|
||||||
|
/// <param name="count"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetStartString(string str, int count)
|
||||||
|
{
|
||||||
|
string strRes = str;
|
||||||
|
int strCount = str.Length;
|
||||||
|
|
||||||
|
if (strCount != count)
|
||||||
|
{
|
||||||
|
strRes = str.PadLeft(count, '0');
|
||||||
|
|
||||||
|
}
|
||||||
|
return strRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 增加结尾字节长度
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="str"></param>
|
||||||
|
/// <param name="count"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetEndString(string str, int count)
|
||||||
|
{
|
||||||
|
string strRes = str;
|
||||||
|
int strCount = str.Length;
|
||||||
|
|
||||||
|
if (strCount != count)
|
||||||
|
{
|
||||||
|
|
||||||
|
strRes = str.PadRight(count, ' ');
|
||||||
|
|
||||||
|
}
|
||||||
|
return strRes;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 生成字符串List集合
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="Num"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<string> GetListString(int Num, string str)
|
||||||
|
{
|
||||||
|
List<string> list = new List<string>();
|
||||||
|
for (int i = 0; i < Num; i++)
|
||||||
|
{
|
||||||
|
list.Add(str);
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.Common.Helper
|
||||||
|
{
|
||||||
|
public class TxtHelper
|
||||||
|
{
|
||||||
|
static ReaderWriterLockSlim sucessLogWriteLockSlim = new ReaderWriterLockSlim();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 写入TEXT文本
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="fullName">文件名</param>
|
||||||
|
/// <param name="content">内容</param>
|
||||||
|
/// <returns>保存结果</returns>
|
||||||
|
public static bool WriteTxt(string fullName, string content)
|
||||||
|
{
|
||||||
|
FileStream fs = null;
|
||||||
|
StreamWriter sw = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string directory = fullName.Substring(0, fullName.LastIndexOf('\\'));
|
||||||
|
if (!Directory.Exists(directory))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
sucessLogWriteLockSlim.EnterWriteLock();//加锁防止抢占
|
||||||
|
if (!File.Exists(fullName))
|
||||||
|
{
|
||||||
|
fs = new FileStream(fullName, FileMode.Create, FileAccess.Write);
|
||||||
|
sw = new StreamWriter(fs, Encoding.UTF8);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fs = new FileStream(fullName, FileMode.Append, FileAccess.Write);
|
||||||
|
sw = new StreamWriter(fs, Encoding.UTF8);
|
||||||
|
}
|
||||||
|
|
||||||
|
sw.WriteLine(content);
|
||||||
|
|
||||||
|
sw.Close();
|
||||||
|
fs.Close();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
sw?.Close();
|
||||||
|
fs?.Close();
|
||||||
|
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
sucessLogWriteLockSlim.ExitWriteLock();
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,296 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.Inspection.Common
|
||||||
|
{
|
||||||
|
public class CurrentInfo
|
||||||
|
{
|
||||||
|
public static Autuority autuority = Autuority.Empty;
|
||||||
|
public static bool LoginOut = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
[Serializable]
|
||||||
|
public class User
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 序号
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
[Display(Name = "序号")]
|
||||||
|
public int Index { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 用户名
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
[Display(Name = "用户名")]
|
||||||
|
public string UserName { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 密码
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
[Display(Name = "密码")]
|
||||||
|
public string PassWord { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 权限
|
||||||
|
/// </summary>
|
||||||
|
///
|
||||||
|
[Display(Name = "权限")]
|
||||||
|
public Autuority Level { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 权限枚举
|
||||||
|
/// </summary>
|
||||||
|
public enum Autuority
|
||||||
|
{
|
||||||
|
管理员,//管理员
|
||||||
|
工程师,//工程师
|
||||||
|
操作员,//操作员
|
||||||
|
Empty,
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UserHelper
|
||||||
|
{
|
||||||
|
private string filePath = string.Empty;
|
||||||
|
public UserHelper(string path)
|
||||||
|
{
|
||||||
|
filePath = path;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 序列化到文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="listUser"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool SerializedUser(string path, List<User> listUser)
|
||||||
|
{
|
||||||
|
if (listUser == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
BinaryFormatter format = new BinaryFormatter();
|
||||||
|
using (FileStream fs = new FileStream(path, FileMode.Create, FileAccess.Write))
|
||||||
|
{
|
||||||
|
format.Serialize(fs, listUser);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 反序列化到文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<User> DeSerializedUser(string path)
|
||||||
|
{
|
||||||
|
BinaryFormatter format = new BinaryFormatter();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
using (FileStream fs = new FileStream(path, FileMode.Open, FileAccess.Read))
|
||||||
|
{
|
||||||
|
object o = format.Deserialize(fs);
|
||||||
|
return o as List<User>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建超级用户
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="listUser"></param>
|
||||||
|
public void CheckSupperUser(string path, List<User> listUser)
|
||||||
|
{
|
||||||
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
User user = new User()
|
||||||
|
{
|
||||||
|
Index = 0,
|
||||||
|
UserName = "Admin",
|
||||||
|
PassWord = "Admin",
|
||||||
|
Level = Autuority.管理员
|
||||||
|
};
|
||||||
|
listUser.Add(user);
|
||||||
|
SerializedUser(path, listUser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检查重复性
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="listUser"></param>
|
||||||
|
/// <param name="userNmae"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool CheckContainUser(List<User> listUser, string userNmae)
|
||||||
|
{
|
||||||
|
var user = from item in listUser
|
||||||
|
where item.UserName == userNmae
|
||||||
|
select item;
|
||||||
|
if (user.Count() > 0)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加用户
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="listUser"></param>
|
||||||
|
/// <param name="user"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool AddUser(string path, List<User> listUser, User user)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (CheckContainUser(listUser, user.UserName))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
listUser.Add(user);
|
||||||
|
SerializedUser(path, listUser);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="listUser"></param>
|
||||||
|
/// <param name="userNmae"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool DeleteUser(string path, List<User> listUser, string userNmae)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (listUser == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
int index = 0;
|
||||||
|
foreach (var item in listUser)
|
||||||
|
{
|
||||||
|
if (item.UserName == userNmae)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
if (index == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
listUser.RemoveAt(index);
|
||||||
|
SerializedUser(path, listUser);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改用户
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
/// <param name="listUser"></param>
|
||||||
|
/// <param name="user"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool EditUser(string path, List<User> listUser, User user)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (listUser == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
foreach (var item in listUser)
|
||||||
|
{
|
||||||
|
if (item.UserName == user.UserName)
|
||||||
|
{
|
||||||
|
item.PassWord = user.PassWord;
|
||||||
|
item.Level = user.Level;
|
||||||
|
SerializedUser(path, listUser);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public User CheckUserLogin(string path, string userName, string passWord, ref string strErr)
|
||||||
|
{
|
||||||
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<User> list = DeSerializedUser(path);
|
||||||
|
if (list == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
User user = new User();
|
||||||
|
if (string.IsNullOrEmpty(userName))
|
||||||
|
{
|
||||||
|
var res1 = from item in list
|
||||||
|
where item.PassWord == passWord
|
||||||
|
select item;
|
||||||
|
if (res1.Count() == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var item in res1)
|
||||||
|
{
|
||||||
|
user.UserName = item.UserName;
|
||||||
|
user.PassWord = item.PassWord;
|
||||||
|
user.Level = item.Level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var res = from item in list
|
||||||
|
where item.PassWord == passWord && item.UserName == userName
|
||||||
|
select item;
|
||||||
|
if (res.Count() == 0)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
foreach (var item in res)
|
||||||
|
{
|
||||||
|
user.UserName = item.UserName;
|
||||||
|
user.PassWord = item.PassWord;
|
||||||
|
user.Level = item.Level;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return user;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
[SystemConfig]
|
||||||
|
ComCount=2
|
||||||
|
|
||||||
|
[1#COMMUNICATION_SETTING]
|
||||||
|
Tgr_Count=1
|
||||||
|
Auto_Connect=True
|
||||||
|
Connect_Typt=2
|
||||||
|
Endsymbol=1
|
||||||
|
HeartBeat=False
|
||||||
|
HeartText=3000
|
||||||
|
HeartTime=1000
|
||||||
|
TCP_IP=127.0.0.1
|
||||||
|
TCP_Port=7321
|
||||||
|
COM_Port=COM3
|
||||||
|
COM_BaudRate=38400
|
||||||
|
COM_Parity=None
|
||||||
|
COM_DataBit=8
|
||||||
|
COM_StopBit=1
|
||||||
|
|
||||||
|
[2#COMMUNICATION_SETTING]
|
||||||
|
Tgr_Count=1
|
||||||
|
Auto_Connect=True
|
||||||
|
Connect_Typt=2
|
||||||
|
Endsymbol=0
|
||||||
|
HeartBeat=False
|
||||||
|
HeartText=3000
|
||||||
|
HeartTime=1000
|
||||||
|
TCP_IP=127.0.0.1
|
||||||
|
TCP_Port=8321
|
||||||
|
COM_Port=COM1
|
||||||
|
COM_BaudRate=9600
|
||||||
|
COM_Parity=None
|
||||||
|
COM_DataBit=8
|
||||||
|
COM_StopBit=1
|
||||||
|
|
||||||
|
[3#COMMUNICATION_SETTING]
|
||||||
|
Tgr_Count=3
|
||||||
|
Auto_Connect=True
|
||||||
|
Connect_Typt=3
|
||||||
|
Endsymbol=0
|
||||||
|
HeartBeat=False
|
||||||
|
HeartText=3000
|
||||||
|
HeartTime=1000
|
||||||
|
TCP_IP=127.0.0.3
|
||||||
|
TCP_Port=60000
|
||||||
|
COM_Port=COM1
|
||||||
|
COM_BaudRate=9600
|
||||||
|
COM_Parity=None
|
||||||
|
COM_DataBit=8
|
||||||
|
COM_StopBit=1
|
||||||
|
|
||||||
|
[4#COMMUNICATION_SETTING]
|
||||||
|
Tgr_Count=4
|
||||||
|
Auto_Connect=True
|
||||||
|
Connect_Typt=3
|
||||||
|
Endsymbol=0
|
||||||
|
HeartBeat=False
|
||||||
|
HeartText=3000
|
||||||
|
HeartTime=1000
|
||||||
|
TCP_IP=127.0.0.4
|
||||||
|
TCP_Port=60000
|
||||||
|
COM_Port=COM1
|
||||||
|
COM_BaudRate=9600
|
||||||
|
COM_Parity=None
|
||||||
|
COM_DataBit=8
|
||||||
|
COM_StopBit=1
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
[SYSTEM_CONFIGURE]
|
||||||
|
Company_Name=外观分档系统
|
||||||
|
Project_Name=外观分档系统
|
||||||
|
Project_FlowingText=外观分档系统
|
||||||
|
IsMesUP=1
|
||||||
|
IsSK=0
|
||||||
|
Worker_code=123
|
||||||
|
portName=COM2
|
||||||
|
baudRate=9600
|
||||||
|
ClassShift=2
|
||||||
|
No=0
|
||||||
|
TCP_IP=192.168.2.253
|
||||||
|
TCP_Port=1030
|
||||||
|
|
||||||
|
[MES配置]
|
||||||
|
siteCode=18J
|
||||||
|
lineCode=18J-BZ-181
|
||||||
|
equipCode=EVEDL18BZWGJ02
|
||||||
|
materialCode=81035332
|
||||||
|
productType=test
|
||||||
|
GradingMesUrl=http://10.22.167.141/core/api/public/eve/pm/eqm/new/grading
|
||||||
|
ResultProcessMesUrl=http://10.22.167.2/core/api/public/product/process/param/new/result
|
||||||
|
StationArrivalUrl=http://10.22.167.2/core/api/public/formation/section/arrival/bz
|
||||||
|
StationExitUrl=http://10.22.167.2/core/api/public/eve/pm/formation-section/bz
|
||||||
|
NGMessage=不分类,正面(2D/3D),反面(2D/3D),左侧面(2D/3D),右侧面(2D/3D),顶面(2D/3D),底面(2D/3D),底WE2,底WE2,底WE3,底WE4,中ME1,中ME2,中ME3,中ME1,极柱(POS/NEG),防爆阀(PRO),扫码NG,分档NG,其他
|
||||||
|
CCDResultMessage=不分类,NG,OK
|
||||||
|
Grading1=K77
|
||||||
|
Grading2=K77
|
||||||
|
Grading3=K77
|
||||||
|
Grading4=K77
|
||||||
|
Grading5=K77
|
||||||
|
Grading6=K77
|
||||||
|
TensionStrap1=5
|
||||||
|
TensionStrap2=6
|
||||||
|
TensionStrap3=7
|
||||||
|
TensionStrapCCDReslut1=1
|
||||||
|
TensionStrapCCDReslut2=1
|
||||||
|
TensionStrapCCDReslut3=1
|
||||||
|
TensionStrapCCDReslut4=1
|
||||||
|
StartNGFL=0
|
||||||
|
Grading=1
|
||||||
|
MesRequestTime=2
|
||||||
|
LoginTime=10
|
||||||
|
|
||||||
|
[统计计数]
|
||||||
|
ProdAllQty=0
|
||||||
|
ProdOKQty=0
|
||||||
|
ProdSanNgQty=0
|
||||||
|
ProdVolNgQty=0
|
||||||
|
ProdImpNgty=0
|
||||||
|
ProdBvolNgQty=0
|
||||||
|
ProdKvalueNgty=0
|
||||||
|
ProdLenthNgty=0
|
||||||
|
ProdWideNgty=0
|
||||||
|
ProdLMDNgty=0
|
||||||
|
ProdLCDNgty=0
|
||||||
|
ProdThinessNgty=0
|
||||||
|
ProdMESNgty=0
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
[SystemConfig]
|
||||||
|
ComCount=1
|
||||||
|
|
||||||
|
[1#PLCParameter]
|
||||||
|
Index=1
|
||||||
|
IP=192.168.2.50
|
||||||
|
Port=44818
|
||||||
|
JobCount=3
|
||||||
|
HeartBeat=True
|
||||||
|
HeartAddr=W100
|
||||||
|
ScanTime=50
|
||||||
|
Solt=0
|
||||||
|
|
||||||
|
1#ThreadName=ÉÏÁÏ
|
||||||
|
1#RecvAddr=W2000
|
||||||
|
1#RecvType=Short
|
||||||
|
1#WriteAddr=W2020
|
||||||
|
1#WriteType=Short
|
||||||
|
1#TriggerCmd=1
|
||||||
|
1#IsRead=True
|
||||||
|
1#ReadAddr=W2010
|
||||||
|
1#ReadType=Byte
|
||||||
|
1#ReadLength=80
|
||||||
|
|
||||||
|
2#ThreadName=ÏÂÁÏ
|
||||||
|
2#RecvAddr=W3000
|
||||||
|
2#RecvType=Short
|
||||||
|
2#WriteAddr=W3020
|
||||||
|
2#WriteType=Short
|
||||||
|
2#TriggerCmd=1
|
||||||
|
2#IsRead=True
|
||||||
|
2#ReadAddr=W3010
|
||||||
|
2#ReadType=Byte
|
||||||
|
2#ReadLength=118
|
||||||
|
|
||||||
|
3#ThreadName=±¨¾¯
|
||||||
|
3#RecvAddr=W6000
|
||||||
|
3#RecvType=Short
|
||||||
|
3#WriteAddr=W2006
|
||||||
|
3#WriteType=Short
|
||||||
|
3#TriggerCmd=1
|
||||||
|
3#IsRead=True
|
||||||
|
3#ReadAddr=W6100
|
||||||
|
3#ReadType=Byte
|
||||||
|
3#ReadLength=1
|
||||||
|
|
||||||
|
4#ThreadName=Òì³£²¥±¨
|
||||||
|
4#RecvAddr=W7000
|
||||||
|
4#RecvType=Short
|
||||||
|
4#WriteAddr=W7100
|
||||||
|
4#WriteType=Short
|
||||||
|
4#TriggerCmd=1
|
||||||
|
4#IsRead=True
|
||||||
|
4#ReadAddr=W7010
|
||||||
|
4#ReadType=Byte
|
||||||
|
4#ReadLength=1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace JY.Inspection.Entity
|
||||||
|
{
|
||||||
|
public class AlarmStatus
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 报警地址
|
||||||
|
/// </summary>
|
||||||
|
public string PLCAdress { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 报警状态
|
||||||
|
/// </summary>
|
||||||
|
public bool Status { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,107 @@
|
|||||||
|
using JY.Inspection.Common;
|
||||||
|
using JY.Inspection.ViewModel;
|
||||||
|
using JY.Utility;
|
||||||
|
using JYControl;
|
||||||
|
using MetroFramework.Forms;
|
||||||
|
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 JY.Inspection.Frm
|
||||||
|
{
|
||||||
|
public partial class FormMesDataSet : MetroForm
|
||||||
|
{
|
||||||
|
private FrmMesSettingVM _viewModel = null;
|
||||||
|
public FormMesDataSet()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
_viewModel = new FrmMesSettingVM();
|
||||||
|
SetDataBindings();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 数据绑定
|
||||||
|
private void SetDataBindings()
|
||||||
|
{
|
||||||
|
bindingSource1.DataSource = _viewModel;
|
||||||
|
|
||||||
|
tb_productType.DataBindings.Add(new Binding("Text", bindingSource1, "ProductType", true, DataSourceUpdateMode.OnPropertyChanged));
|
||||||
|
tb_StationArrival.DataBindings.Add(new Binding("Text", bindingSource1, "StationArrivalUrl", true, DataSourceUpdateMode.OnPropertyChanged));
|
||||||
|
tb_stationExit.DataBindings.Add(new Binding("Text", bindingSource1, "StationExitUrl", true, DataSourceUpdateMode.OnPropertyChanged));
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载MES配置文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void FormMesDataSet_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
txtsiteCode.Text = IniFileHelper.ReadIniData("MES配置", "siteCode");
|
||||||
|
txtlineCode.Text = IniFileHelper.ReadIniData("MES配置", "lineCode");
|
||||||
|
txtequipCode.Text = IniFileHelper.ReadIniData("MES配置", "equipCode");
|
||||||
|
txtmaterialCode.Text = IniFileHelper.ReadIniData("MES配置", "materialCode");
|
||||||
|
_viewModel.ProductType = IniFileHelper.ReadIniData("MES配置", "productType");
|
||||||
|
|
||||||
|
txtGradingMesUrl.Text = IniFileHelper.ReadIniData("MES配置", "GradingMesUrl");
|
||||||
|
txtResultProcessMesUrl.Text = IniFileHelper.ReadIniData("MES配置", "ResultProcessMesUrl");
|
||||||
|
_viewModel.StationArrivalUrl = IniFileHelper.ReadIniData("MES配置", "StationArrivalUrl");
|
||||||
|
_viewModel.StationExitUrl = IniFileHelper.ReadIniData("MES配置", "StationExitUrl");
|
||||||
|
|
||||||
|
LoginTime.Text = IniFileHelper.ReadIniData("MES配置", "LoginTime");
|
||||||
|
txtMesRequestTime.Text = IniFileHelper.ReadIniData("MES配置", "MesRequestTime");
|
||||||
|
|
||||||
|
ckStartZNDB.Checked = IniFileHelper.ReadIniData("MES配置", "StartZNDB") == "1" ? true : false;
|
||||||
|
chkIsMesUP.Checked = IniFileHelper.ReadIniData("SYSTEM_CONFIGURE", "IsMesUP") == "1" ? true : false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存MES配置文件信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void btnSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
IniFileHelper.WriteIniData("MES配置", "siteCode", txtsiteCode.Text.Trim());
|
||||||
|
IniFileHelper.WriteIniData("MES配置", "lineCode", txtlineCode.Text.Trim());
|
||||||
|
IniFileHelper.WriteIniData("MES配置", "equipCode", txtequipCode.Text.Trim());
|
||||||
|
IniFileHelper.WriteIniData("MES配置", "materialCode", txtmaterialCode.Text.Trim());
|
||||||
|
IniFileHelper.WriteIniData("MES配置", "productType", _viewModel.ProductType.Trim());
|
||||||
|
|
||||||
|
IniFileHelper.WriteIniData("MES配置", "GradingMesUrl", txtGradingMesUrl.Text.Trim());
|
||||||
|
IniFileHelper.WriteIniData("MES配置", "ResultProcessMesUrl", txtResultProcessMesUrl.Text.Trim());
|
||||||
|
IniFileHelper.WriteIniData("MES配置", "StationArrivalUrl", _viewModel.StationArrivalUrl.Trim());
|
||||||
|
IniFileHelper.WriteIniData("MES配置", "StationExitUrl", _viewModel.StationExitUrl.Trim());
|
||||||
|
|
||||||
|
IniFileHelper.WriteIniData("MES配置", "LoginTime", LoginTime.Text.Trim());
|
||||||
|
LogManagerControl.AddLog($"用户[{Global.systemConfig.userName}]设置权限超时时间[{LoginTime.Text.Trim()}]", LogAddtype.local, Logtype.Warning);
|
||||||
|
IniFileHelper.WriteIniData("MES配置", "MesRequestTime", txtMesRequestTime.Text.Trim());
|
||||||
|
|
||||||
|
IniFileHelper.WriteIniData("MES配置", "StartZNDB", ckStartZNDB.Checked ? "1" : "0");
|
||||||
|
//是否启用MES
|
||||||
|
IniFileHelper.WriteIniData("SYSTEM_CONFIGURE", "IsMesUP", chkIsMesUP.Checked ? "1" : "2");
|
||||||
|
MessageBox.Show("参数保存成功!", "系统提示");
|
||||||
|
this.DialogResult = DialogResult.OK;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnExit_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void linkLabel_editCollectItemCfg_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
|
||||||
|
{
|
||||||
|
System.Diagnostics.Process.Start(Global.CollectItemCfgPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,713 @@
|
|||||||
|
|
||||||
|
namespace JY.Inspection.Frm
|
||||||
|
{
|
||||||
|
partial class FormMesDataSet
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Required designer variable.
|
||||||
|
/// </summary>
|
||||||
|
private System.ComponentModel.IContainer components = null;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Clean up any resources being used.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||||
|
protected override void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (disposing && (components != null))
|
||||||
|
{
|
||||||
|
components.Dispose();
|
||||||
|
}
|
||||||
|
base.Dispose(disposing);
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Windows Form Designer generated code
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Required method for Designer support - do not modify
|
||||||
|
/// the contents of this method with the code editor.
|
||||||
|
/// </summary>
|
||||||
|
private void InitializeComponent()
|
||||||
|
{
|
||||||
|
this.components = new System.ComponentModel.Container();
|
||||||
|
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormMesDataSet));
|
||||||
|
this.btnExit = new MetroFramework.Controls.MetroButton();
|
||||||
|
this.metroLabel1 = new MetroFramework.Controls.MetroLabel();
|
||||||
|
this.txtlineCode = new MetroFramework.Controls.MetroTextBox();
|
||||||
|
this.btnSave = new MetroFramework.Controls.MetroButton();
|
||||||
|
this.metroLabel3 = new MetroFramework.Controls.MetroLabel();
|
||||||
|
this.txtequipCode = new MetroFramework.Controls.MetroTextBox();
|
||||||
|
this.txtsiteCode = new MetroFramework.Controls.MetroTextBox();
|
||||||
|
this.metroLabel2 = new MetroFramework.Controls.MetroLabel();
|
||||||
|
this.ckStartZNDB = new System.Windows.Forms.CheckBox();
|
||||||
|
this.txtmaterialCode = new MetroFramework.Controls.MetroTextBox();
|
||||||
|
this.metroLabel4 = new MetroFramework.Controls.MetroLabel();
|
||||||
|
this.txtGradingMesUrl = new MetroFramework.Controls.MetroTextBox();
|
||||||
|
this.metroLabel5 = new MetroFramework.Controls.MetroLabel();
|
||||||
|
this.txtResultProcessMesUrl = new MetroFramework.Controls.MetroTextBox();
|
||||||
|
this.metroLabel6 = new MetroFramework.Controls.MetroLabel();
|
||||||
|
this.groupBox1 = new System.Windows.Forms.GroupBox();
|
||||||
|
this.linkLabel_editCollectItemCfg = new System.Windows.Forms.LinkLabel();
|
||||||
|
this.metroLabel21 = new MetroFramework.Controls.MetroLabel();
|
||||||
|
this.LoginTime = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.metroLabel22 = new MetroFramework.Controls.MetroLabel();
|
||||||
|
this.metroLabel18 = new MetroFramework.Controls.MetroLabel();
|
||||||
|
this.txtMesRequestTime = new System.Windows.Forms.NumericUpDown();
|
||||||
|
this.metroLabel20 = new MetroFramework.Controls.MetroLabel();
|
||||||
|
this.chkIsMesUP = new System.Windows.Forms.CheckBox();
|
||||||
|
this.metroLabel7 = new MetroFramework.Controls.MetroLabel();
|
||||||
|
this.tb_productType = new MetroFramework.Controls.MetroTextBox();
|
||||||
|
this.metroPanel_top = new MetroFramework.Controls.MetroPanel();
|
||||||
|
this.metroPanel_mid = new MetroFramework.Controls.MetroPanel();
|
||||||
|
this.metroPanel_bottom = new MetroFramework.Controls.MetroPanel();
|
||||||
|
this.metroLabel8 = new MetroFramework.Controls.MetroLabel();
|
||||||
|
this.tb_StationArrival = new MetroFramework.Controls.MetroTextBox();
|
||||||
|
this.metroLabel9 = new MetroFramework.Controls.MetroLabel();
|
||||||
|
this.tb_stationExit = new MetroFramework.Controls.MetroTextBox();
|
||||||
|
this.bindingSource1 = new System.Windows.Forms.BindingSource(this.components);
|
||||||
|
this.groupBox1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.LoginTime)).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.txtMesRequestTime)).BeginInit();
|
||||||
|
this.metroPanel_top.SuspendLayout();
|
||||||
|
this.metroPanel_mid.SuspendLayout();
|
||||||
|
this.metroPanel_bottom.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).BeginInit();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// btnExit
|
||||||
|
//
|
||||||
|
this.btnExit.Location = new System.Drawing.Point(484, 40);
|
||||||
|
this.btnExit.Name = "btnExit";
|
||||||
|
this.btnExit.Size = new System.Drawing.Size(103, 37);
|
||||||
|
this.btnExit.TabIndex = 13;
|
||||||
|
this.btnExit.Text = "退出";
|
||||||
|
this.btnExit.UseSelectable = true;
|
||||||
|
this.btnExit.Click += new System.EventHandler(this.btnExit_Click);
|
||||||
|
//
|
||||||
|
// metroLabel1
|
||||||
|
//
|
||||||
|
this.metroLabel1.AutoSize = true;
|
||||||
|
this.metroLabel1.Location = new System.Drawing.Point(33, 53);
|
||||||
|
this.metroLabel1.Name = "metroLabel1";
|
||||||
|
this.metroLabel1.Size = new System.Drawing.Size(79, 19);
|
||||||
|
this.metroLabel1.TabIndex = 12;
|
||||||
|
this.metroLabel1.Text = "产线名称:";
|
||||||
|
//
|
||||||
|
// txtlineCode
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
this.txtlineCode.CustomButton.Image = null;
|
||||||
|
this.txtlineCode.CustomButton.Location = new System.Drawing.Point(123, 1);
|
||||||
|
this.txtlineCode.CustomButton.Name = "";
|
||||||
|
this.txtlineCode.CustomButton.Size = new System.Drawing.Size(16, 17);
|
||||||
|
this.txtlineCode.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||||
|
this.txtlineCode.CustomButton.TabIndex = 1;
|
||||||
|
this.txtlineCode.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||||
|
this.txtlineCode.CustomButton.UseSelectable = true;
|
||||||
|
this.txtlineCode.CustomButton.Visible = false;
|
||||||
|
this.txtlineCode.Lines = new string[0];
|
||||||
|
this.txtlineCode.Location = new System.Drawing.Point(118, 53);
|
||||||
|
this.txtlineCode.MaxLength = 32767;
|
||||||
|
this.txtlineCode.Name = "txtlineCode";
|
||||||
|
this.txtlineCode.PasswordChar = '\0';
|
||||||
|
this.txtlineCode.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||||
|
this.txtlineCode.SelectedText = "";
|
||||||
|
this.txtlineCode.SelectionLength = 0;
|
||||||
|
this.txtlineCode.SelectionStart = 0;
|
||||||
|
this.txtlineCode.ShortcutsEnabled = true;
|
||||||
|
this.txtlineCode.Size = new System.Drawing.Size(186, 23);
|
||||||
|
this.txtlineCode.TabIndex = 11;
|
||||||
|
this.txtlineCode.UseSelectable = true;
|
||||||
|
this.txtlineCode.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||||
|
this.txtlineCode.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||||
|
//
|
||||||
|
// btnSave
|
||||||
|
//
|
||||||
|
this.btnSave.Location = new System.Drawing.Point(68, 40);
|
||||||
|
this.btnSave.Name = "btnSave";
|
||||||
|
this.btnSave.Size = new System.Drawing.Size(112, 37);
|
||||||
|
this.btnSave.TabIndex = 10;
|
||||||
|
this.btnSave.Text = "保存";
|
||||||
|
this.btnSave.UseSelectable = true;
|
||||||
|
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||||
|
//
|
||||||
|
// metroLabel3
|
||||||
|
//
|
||||||
|
this.metroLabel3.AutoSize = true;
|
||||||
|
this.metroLabel3.Location = new System.Drawing.Point(33, 92);
|
||||||
|
this.metroLabel3.Name = "metroLabel3";
|
||||||
|
this.metroLabel3.Size = new System.Drawing.Size(79, 19);
|
||||||
|
this.metroLabel3.TabIndex = 25;
|
||||||
|
this.metroLabel3.Text = "设备编码:";
|
||||||
|
//
|
||||||
|
// txtequipCode
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
this.txtequipCode.CustomButton.Image = null;
|
||||||
|
this.txtequipCode.CustomButton.Location = new System.Drawing.Point(123, 1);
|
||||||
|
this.txtequipCode.CustomButton.Name = "";
|
||||||
|
this.txtequipCode.CustomButton.Size = new System.Drawing.Size(16, 17);
|
||||||
|
this.txtequipCode.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||||
|
this.txtequipCode.CustomButton.TabIndex = 1;
|
||||||
|
this.txtequipCode.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||||
|
this.txtequipCode.CustomButton.UseSelectable = true;
|
||||||
|
this.txtequipCode.CustomButton.Visible = false;
|
||||||
|
this.txtequipCode.Lines = new string[0];
|
||||||
|
this.txtequipCode.Location = new System.Drawing.Point(118, 88);
|
||||||
|
this.txtequipCode.MaxLength = 32767;
|
||||||
|
this.txtequipCode.Name = "txtequipCode";
|
||||||
|
this.txtequipCode.PasswordChar = '\0';
|
||||||
|
this.txtequipCode.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||||
|
this.txtequipCode.SelectedText = "";
|
||||||
|
this.txtequipCode.SelectionLength = 0;
|
||||||
|
this.txtequipCode.SelectionStart = 0;
|
||||||
|
this.txtequipCode.ShortcutsEnabled = true;
|
||||||
|
this.txtequipCode.Size = new System.Drawing.Size(186, 23);
|
||||||
|
this.txtequipCode.TabIndex = 26;
|
||||||
|
this.txtequipCode.UseSelectable = true;
|
||||||
|
this.txtequipCode.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||||
|
this.txtequipCode.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||||
|
//
|
||||||
|
// txtsiteCode
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
this.txtsiteCode.CustomButton.Image = null;
|
||||||
|
this.txtsiteCode.CustomButton.Location = new System.Drawing.Point(123, 1);
|
||||||
|
this.txtsiteCode.CustomButton.Name = "";
|
||||||
|
this.txtsiteCode.CustomButton.Size = new System.Drawing.Size(16, 17);
|
||||||
|
this.txtsiteCode.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||||
|
this.txtsiteCode.CustomButton.TabIndex = 1;
|
||||||
|
this.txtsiteCode.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||||
|
this.txtsiteCode.CustomButton.UseSelectable = true;
|
||||||
|
this.txtsiteCode.CustomButton.Visible = false;
|
||||||
|
this.txtsiteCode.Lines = new string[0];
|
||||||
|
this.txtsiteCode.Location = new System.Drawing.Point(118, 15);
|
||||||
|
this.txtsiteCode.MaxLength = 32767;
|
||||||
|
this.txtsiteCode.Name = "txtsiteCode";
|
||||||
|
this.txtsiteCode.PasswordChar = '\0';
|
||||||
|
this.txtsiteCode.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||||
|
this.txtsiteCode.SelectedText = "";
|
||||||
|
this.txtsiteCode.SelectionLength = 0;
|
||||||
|
this.txtsiteCode.SelectionStart = 0;
|
||||||
|
this.txtsiteCode.ShortcutsEnabled = true;
|
||||||
|
this.txtsiteCode.Size = new System.Drawing.Size(186, 23);
|
||||||
|
this.txtsiteCode.TabIndex = 28;
|
||||||
|
this.txtsiteCode.UseSelectable = true;
|
||||||
|
this.txtsiteCode.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||||
|
this.txtsiteCode.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||||
|
//
|
||||||
|
// metroLabel2
|
||||||
|
//
|
||||||
|
this.metroLabel2.AutoSize = true;
|
||||||
|
this.metroLabel2.Location = new System.Drawing.Point(33, 15);
|
||||||
|
this.metroLabel2.Name = "metroLabel2";
|
||||||
|
this.metroLabel2.Size = new System.Drawing.Size(79, 19);
|
||||||
|
this.metroLabel2.TabIndex = 27;
|
||||||
|
this.metroLabel2.Text = "工厂代码:";
|
||||||
|
//
|
||||||
|
// ckStartZNDB
|
||||||
|
//
|
||||||
|
this.ckStartZNDB.AutoSize = true;
|
||||||
|
this.ckStartZNDB.Location = new System.Drawing.Point(68, 6);
|
||||||
|
this.ckStartZNDB.Name = "ckStartZNDB";
|
||||||
|
this.ckStartZNDB.Size = new System.Drawing.Size(96, 16);
|
||||||
|
this.ckStartZNDB.TabIndex = 29;
|
||||||
|
this.ckStartZNDB.Text = "开启智能电表";
|
||||||
|
this.ckStartZNDB.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// txtmaterialCode
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
this.txtmaterialCode.CustomButton.Image = null;
|
||||||
|
this.txtmaterialCode.CustomButton.Location = new System.Drawing.Point(123, 1);
|
||||||
|
this.txtmaterialCode.CustomButton.Name = "";
|
||||||
|
this.txtmaterialCode.CustomButton.Size = new System.Drawing.Size(16, 17);
|
||||||
|
this.txtmaterialCode.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||||
|
this.txtmaterialCode.CustomButton.TabIndex = 1;
|
||||||
|
this.txtmaterialCode.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||||
|
this.txtmaterialCode.CustomButton.UseSelectable = true;
|
||||||
|
this.txtmaterialCode.CustomButton.Visible = false;
|
||||||
|
this.txtmaterialCode.Lines = new string[0];
|
||||||
|
this.txtmaterialCode.Location = new System.Drawing.Point(118, 129);
|
||||||
|
this.txtmaterialCode.MaxLength = 32767;
|
||||||
|
this.txtmaterialCode.Name = "txtmaterialCode";
|
||||||
|
this.txtmaterialCode.PasswordChar = '\0';
|
||||||
|
this.txtmaterialCode.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||||
|
this.txtmaterialCode.SelectedText = "";
|
||||||
|
this.txtmaterialCode.SelectionLength = 0;
|
||||||
|
this.txtmaterialCode.SelectionStart = 0;
|
||||||
|
this.txtmaterialCode.ShortcutsEnabled = true;
|
||||||
|
this.txtmaterialCode.Size = new System.Drawing.Size(186, 23);
|
||||||
|
this.txtmaterialCode.TabIndex = 31;
|
||||||
|
this.txtmaterialCode.UseSelectable = true;
|
||||||
|
this.txtmaterialCode.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||||
|
this.txtmaterialCode.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||||
|
//
|
||||||
|
// metroLabel4
|
||||||
|
//
|
||||||
|
this.metroLabel4.AutoSize = true;
|
||||||
|
this.metroLabel4.Location = new System.Drawing.Point(33, 127);
|
||||||
|
this.metroLabel4.Name = "metroLabel4";
|
||||||
|
this.metroLabel4.Size = new System.Drawing.Size(79, 19);
|
||||||
|
this.metroLabel4.TabIndex = 30;
|
||||||
|
this.metroLabel4.Text = "物料编码:";
|
||||||
|
//
|
||||||
|
// txtGradingMesUrl
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
this.txtGradingMesUrl.CustomButton.Image = null;
|
||||||
|
this.txtGradingMesUrl.CustomButton.Location = new System.Drawing.Point(376, 1);
|
||||||
|
this.txtGradingMesUrl.CustomButton.Name = "";
|
||||||
|
this.txtGradingMesUrl.CustomButton.Size = new System.Drawing.Size(16, 17);
|
||||||
|
this.txtGradingMesUrl.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||||
|
this.txtGradingMesUrl.CustomButton.TabIndex = 1;
|
||||||
|
this.txtGradingMesUrl.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||||
|
this.txtGradingMesUrl.CustomButton.UseSelectable = true;
|
||||||
|
this.txtGradingMesUrl.CustomButton.Visible = false;
|
||||||
|
this.txtGradingMesUrl.Lines = new string[0];
|
||||||
|
this.txtGradingMesUrl.Location = new System.Drawing.Point(176, 177);
|
||||||
|
this.txtGradingMesUrl.MaxLength = 32767;
|
||||||
|
this.txtGradingMesUrl.Name = "txtGradingMesUrl";
|
||||||
|
this.txtGradingMesUrl.PasswordChar = '\0';
|
||||||
|
this.txtGradingMesUrl.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||||
|
this.txtGradingMesUrl.SelectedText = "";
|
||||||
|
this.txtGradingMesUrl.SelectionLength = 0;
|
||||||
|
this.txtGradingMesUrl.SelectionStart = 0;
|
||||||
|
this.txtGradingMesUrl.ShortcutsEnabled = true;
|
||||||
|
this.txtGradingMesUrl.Size = new System.Drawing.Size(524, 23);
|
||||||
|
this.txtGradingMesUrl.TabIndex = 33;
|
||||||
|
this.txtGradingMesUrl.UseSelectable = true;
|
||||||
|
this.txtGradingMesUrl.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||||
|
this.txtGradingMesUrl.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||||
|
//
|
||||||
|
// metroLabel5
|
||||||
|
//
|
||||||
|
this.metroLabel5.AutoSize = true;
|
||||||
|
this.metroLabel5.Location = new System.Drawing.Point(29, 177);
|
||||||
|
this.metroLabel5.Name = "metroLabel5";
|
||||||
|
this.metroLabel5.Size = new System.Drawing.Size(135, 19);
|
||||||
|
this.metroLabel5.TabIndex = 32;
|
||||||
|
this.metroLabel5.Text = "分档查询接口地址:";
|
||||||
|
//
|
||||||
|
// txtResultProcessMesUrl
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
this.txtResultProcessMesUrl.CustomButton.Image = null;
|
||||||
|
this.txtResultProcessMesUrl.CustomButton.Location = new System.Drawing.Point(376, 1);
|
||||||
|
this.txtResultProcessMesUrl.CustomButton.Name = "";
|
||||||
|
this.txtResultProcessMesUrl.CustomButton.Size = new System.Drawing.Size(16, 17);
|
||||||
|
this.txtResultProcessMesUrl.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||||
|
this.txtResultProcessMesUrl.CustomButton.TabIndex = 1;
|
||||||
|
this.txtResultProcessMesUrl.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||||
|
this.txtResultProcessMesUrl.CustomButton.UseSelectable = true;
|
||||||
|
this.txtResultProcessMesUrl.CustomButton.Visible = false;
|
||||||
|
this.txtResultProcessMesUrl.Lines = new string[0];
|
||||||
|
this.txtResultProcessMesUrl.Location = new System.Drawing.Point(176, 214);
|
||||||
|
this.txtResultProcessMesUrl.MaxLength = 32767;
|
||||||
|
this.txtResultProcessMesUrl.Name = "txtResultProcessMesUrl";
|
||||||
|
this.txtResultProcessMesUrl.PasswordChar = '\0';
|
||||||
|
this.txtResultProcessMesUrl.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||||
|
this.txtResultProcessMesUrl.SelectedText = "";
|
||||||
|
this.txtResultProcessMesUrl.SelectionLength = 0;
|
||||||
|
this.txtResultProcessMesUrl.SelectionStart = 0;
|
||||||
|
this.txtResultProcessMesUrl.ShortcutsEnabled = true;
|
||||||
|
this.txtResultProcessMesUrl.Size = new System.Drawing.Size(524, 23);
|
||||||
|
this.txtResultProcessMesUrl.TabIndex = 35;
|
||||||
|
this.txtResultProcessMesUrl.UseSelectable = true;
|
||||||
|
this.txtResultProcessMesUrl.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||||
|
this.txtResultProcessMesUrl.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||||
|
//
|
||||||
|
// metroLabel6
|
||||||
|
//
|
||||||
|
this.metroLabel6.AutoSize = true;
|
||||||
|
this.metroLabel6.Location = new System.Drawing.Point(3, 214);
|
||||||
|
this.metroLabel6.Name = "metroLabel6";
|
||||||
|
this.metroLabel6.Size = new System.Drawing.Size(163, 19);
|
||||||
|
this.metroLabel6.TabIndex = 34;
|
||||||
|
this.metroLabel6.Text = "结果加工参数接口地址:";
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
this.groupBox1.Controls.Add(this.metroPanel_top);
|
||||||
|
this.groupBox1.Controls.Add(this.metroPanel_mid);
|
||||||
|
this.groupBox1.Controls.Add(this.metroPanel_bottom);
|
||||||
|
this.groupBox1.Location = new System.Drawing.Point(23, 63);
|
||||||
|
this.groupBox1.Name = "groupBox1";
|
||||||
|
this.groupBox1.Size = new System.Drawing.Size(719, 492);
|
||||||
|
this.groupBox1.TabIndex = 36;
|
||||||
|
this.groupBox1.TabStop = false;
|
||||||
|
this.groupBox1.Text = "MES配置";
|
||||||
|
//
|
||||||
|
// linkLabel_editCollectItemCfg
|
||||||
|
//
|
||||||
|
this.linkLabel_editCollectItemCfg.AutoSize = true;
|
||||||
|
this.linkLabel_editCollectItemCfg.Location = new System.Drawing.Point(482, 7);
|
||||||
|
this.linkLabel_editCollectItemCfg.Margin = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||||
|
this.linkLabel_editCollectItemCfg.Name = "linkLabel_editCollectItemCfg";
|
||||||
|
this.linkLabel_editCollectItemCfg.Size = new System.Drawing.Size(101, 12);
|
||||||
|
this.linkLabel_editCollectItemCfg.TabIndex = 182;
|
||||||
|
this.linkLabel_editCollectItemCfg.TabStop = true;
|
||||||
|
this.linkLabel_editCollectItemCfg.Text = "配置采集项参照表";
|
||||||
|
this.linkLabel_editCollectItemCfg.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel_editCollectItemCfg_LinkClicked);
|
||||||
|
//
|
||||||
|
// metroLabel21
|
||||||
|
//
|
||||||
|
this.metroLabel21.AutoSize = true;
|
||||||
|
this.metroLabel21.Location = new System.Drawing.Point(573, 127);
|
||||||
|
this.metroLabel21.Name = "metroLabel21";
|
||||||
|
this.metroLabel21.Size = new System.Drawing.Size(31, 19);
|
||||||
|
this.metroLabel21.TabIndex = 180;
|
||||||
|
this.metroLabel21.Text = "min";
|
||||||
|
this.metroLabel21.Visible = false;
|
||||||
|
//
|
||||||
|
// LoginTime
|
||||||
|
//
|
||||||
|
this.LoginTime.Location = new System.Drawing.Point(491, 127);
|
||||||
|
this.LoginTime.Maximum = new decimal(new int[] {
|
||||||
|
1000,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.LoginTime.Name = "LoginTime";
|
||||||
|
this.LoginTime.Size = new System.Drawing.Size(76, 21);
|
||||||
|
this.LoginTime.TabIndex = 179;
|
||||||
|
this.LoginTime.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||||
|
this.LoginTime.Value = new decimal(new int[] {
|
||||||
|
1,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.LoginTime.Visible = false;
|
||||||
|
//
|
||||||
|
// metroLabel22
|
||||||
|
//
|
||||||
|
this.metroLabel22.AutoSize = true;
|
||||||
|
this.metroLabel22.Location = new System.Drawing.Point(378, 127);
|
||||||
|
this.metroLabel22.Name = "metroLabel22";
|
||||||
|
this.metroLabel22.Size = new System.Drawing.Size(107, 19);
|
||||||
|
this.metroLabel22.TabIndex = 176;
|
||||||
|
this.metroLabel22.Text = "权限登录时长:";
|
||||||
|
this.metroLabel22.Visible = false;
|
||||||
|
//
|
||||||
|
// metroLabel18
|
||||||
|
//
|
||||||
|
this.metroLabel18.AutoSize = true;
|
||||||
|
this.metroLabel18.Location = new System.Drawing.Point(573, 53);
|
||||||
|
this.metroLabel18.Name = "metroLabel18";
|
||||||
|
this.metroLabel18.Size = new System.Drawing.Size(14, 19);
|
||||||
|
this.metroLabel18.TabIndex = 97;
|
||||||
|
this.metroLabel18.Text = "s";
|
||||||
|
//
|
||||||
|
// txtMesRequestTime
|
||||||
|
//
|
||||||
|
this.txtMesRequestTime.DecimalPlaces = 1;
|
||||||
|
this.txtMesRequestTime.Increment = new decimal(new int[] {
|
||||||
|
5,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
65536});
|
||||||
|
this.txtMesRequestTime.Location = new System.Drawing.Point(491, 53);
|
||||||
|
this.txtMesRequestTime.Maximum = new decimal(new int[] {
|
||||||
|
1000,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
0});
|
||||||
|
this.txtMesRequestTime.Minimum = new decimal(new int[] {
|
||||||
|
5,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
65536});
|
||||||
|
this.txtMesRequestTime.Name = "txtMesRequestTime";
|
||||||
|
this.txtMesRequestTime.Size = new System.Drawing.Size(76, 21);
|
||||||
|
this.txtMesRequestTime.TabIndex = 96;
|
||||||
|
this.txtMesRequestTime.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
|
||||||
|
this.txtMesRequestTime.Value = new decimal(new int[] {
|
||||||
|
5,
|
||||||
|
0,
|
||||||
|
0,
|
||||||
|
65536});
|
||||||
|
//
|
||||||
|
// metroLabel20
|
||||||
|
//
|
||||||
|
this.metroLabel20.AutoSize = true;
|
||||||
|
this.metroLabel20.Location = new System.Drawing.Point(352, 53);
|
||||||
|
this.metroLabel20.Name = "metroLabel20";
|
||||||
|
this.metroLabel20.Size = new System.Drawing.Size(133, 19);
|
||||||
|
this.metroLabel20.TabIndex = 49;
|
||||||
|
this.metroLabel20.Text = "请求MES超时时长:";
|
||||||
|
//
|
||||||
|
// chkIsMesUP
|
||||||
|
//
|
||||||
|
this.chkIsMesUP.AutoSize = true;
|
||||||
|
this.chkIsMesUP.Enabled = false;
|
||||||
|
this.chkIsMesUP.Location = new System.Drawing.Point(279, 6);
|
||||||
|
this.chkIsMesUP.Name = "chkIsMesUP";
|
||||||
|
this.chkIsMesUP.Size = new System.Drawing.Size(90, 16);
|
||||||
|
this.chkIsMesUP.TabIndex = 36;
|
||||||
|
this.chkIsMesUP.Text = "开启MES模式";
|
||||||
|
this.chkIsMesUP.UseVisualStyleBackColor = true;
|
||||||
|
//
|
||||||
|
// metroLabel7
|
||||||
|
//
|
||||||
|
this.metroLabel7.AutoSize = true;
|
||||||
|
this.metroLabel7.Location = new System.Drawing.Point(406, 15);
|
||||||
|
this.metroLabel7.Name = "metroLabel7";
|
||||||
|
this.metroLabel7.Size = new System.Drawing.Size(79, 19);
|
||||||
|
this.metroLabel7.TabIndex = 183;
|
||||||
|
this.metroLabel7.Text = "产品类型:";
|
||||||
|
//
|
||||||
|
// tb_productType
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
this.tb_productType.CustomButton.Image = null;
|
||||||
|
this.tb_productType.CustomButton.Location = new System.Drawing.Point(164, 1);
|
||||||
|
this.tb_productType.CustomButton.Name = "";
|
||||||
|
this.tb_productType.CustomButton.Size = new System.Drawing.Size(21, 21);
|
||||||
|
this.tb_productType.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||||
|
this.tb_productType.CustomButton.TabIndex = 1;
|
||||||
|
this.tb_productType.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||||
|
this.tb_productType.CustomButton.UseSelectable = true;
|
||||||
|
this.tb_productType.CustomButton.Visible = false;
|
||||||
|
this.tb_productType.Lines = new string[0];
|
||||||
|
this.tb_productType.Location = new System.Drawing.Point(491, 15);
|
||||||
|
this.tb_productType.MaxLength = 32767;
|
||||||
|
this.tb_productType.Name = "tb_productType";
|
||||||
|
this.tb_productType.PasswordChar = '\0';
|
||||||
|
this.tb_productType.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||||
|
this.tb_productType.SelectedText = "";
|
||||||
|
this.tb_productType.SelectionLength = 0;
|
||||||
|
this.tb_productType.SelectionStart = 0;
|
||||||
|
this.tb_productType.ShortcutsEnabled = true;
|
||||||
|
this.tb_productType.Size = new System.Drawing.Size(186, 23);
|
||||||
|
this.tb_productType.TabIndex = 184;
|
||||||
|
this.tb_productType.UseSelectable = true;
|
||||||
|
this.tb_productType.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||||
|
this.tb_productType.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||||
|
//
|
||||||
|
// metroPanel_top
|
||||||
|
//
|
||||||
|
this.metroPanel_top.Controls.Add(this.tb_productType);
|
||||||
|
this.metroPanel_top.Controls.Add(this.metroLabel18);
|
||||||
|
this.metroPanel_top.Controls.Add(this.metroLabel21);
|
||||||
|
this.metroPanel_top.Controls.Add(this.metroLabel7);
|
||||||
|
this.metroPanel_top.Controls.Add(this.LoginTime);
|
||||||
|
this.metroPanel_top.Controls.Add(this.txtMesRequestTime);
|
||||||
|
this.metroPanel_top.Controls.Add(this.metroLabel2);
|
||||||
|
this.metroPanel_top.Controls.Add(this.metroLabel22);
|
||||||
|
this.metroPanel_top.Controls.Add(this.metroLabel1);
|
||||||
|
this.metroPanel_top.Controls.Add(this.metroLabel3);
|
||||||
|
this.metroPanel_top.Controls.Add(this.metroLabel4);
|
||||||
|
this.metroPanel_top.Controls.Add(this.metroLabel20);
|
||||||
|
this.metroPanel_top.Controls.Add(this.txtsiteCode);
|
||||||
|
this.metroPanel_top.Controls.Add(this.txtlineCode);
|
||||||
|
this.metroPanel_top.Controls.Add(this.txtequipCode);
|
||||||
|
this.metroPanel_top.Controls.Add(this.txtmaterialCode);
|
||||||
|
this.metroPanel_top.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.metroPanel_top.HorizontalScrollbarBarColor = true;
|
||||||
|
this.metroPanel_top.HorizontalScrollbarHighlightOnWheel = false;
|
||||||
|
this.metroPanel_top.HorizontalScrollbarSize = 10;
|
||||||
|
this.metroPanel_top.Location = new System.Drawing.Point(3, 17);
|
||||||
|
this.metroPanel_top.Name = "metroPanel_top";
|
||||||
|
this.metroPanel_top.Size = new System.Drawing.Size(713, 163);
|
||||||
|
this.metroPanel_top.TabIndex = 185;
|
||||||
|
this.metroPanel_top.VerticalScrollbarBarColor = true;
|
||||||
|
this.metroPanel_top.VerticalScrollbarHighlightOnWheel = false;
|
||||||
|
this.metroPanel_top.VerticalScrollbarSize = 10;
|
||||||
|
//
|
||||||
|
// metroPanel_mid
|
||||||
|
//
|
||||||
|
this.metroPanel_mid.Controls.Add(this.tb_stationExit);
|
||||||
|
this.metroPanel_mid.Controls.Add(this.metroLabel9);
|
||||||
|
this.metroPanel_mid.Controls.Add(this.tb_StationArrival);
|
||||||
|
this.metroPanel_mid.Controls.Add(this.metroLabel8);
|
||||||
|
this.metroPanel_mid.Controls.Add(this.txtResultProcessMesUrl);
|
||||||
|
this.metroPanel_mid.Controls.Add(this.txtGradingMesUrl);
|
||||||
|
this.metroPanel_mid.Controls.Add(this.metroLabel6);
|
||||||
|
this.metroPanel_mid.Controls.Add(this.metroLabel5);
|
||||||
|
this.metroPanel_mid.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.metroPanel_mid.HorizontalScrollbarBarColor = true;
|
||||||
|
this.metroPanel_mid.HorizontalScrollbarHighlightOnWheel = false;
|
||||||
|
this.metroPanel_mid.HorizontalScrollbarSize = 10;
|
||||||
|
this.metroPanel_mid.Location = new System.Drawing.Point(3, 17);
|
||||||
|
this.metroPanel_mid.Name = "metroPanel_mid";
|
||||||
|
this.metroPanel_mid.Size = new System.Drawing.Size(713, 379);
|
||||||
|
this.metroPanel_mid.TabIndex = 186;
|
||||||
|
this.metroPanel_mid.VerticalScrollbarBarColor = true;
|
||||||
|
this.metroPanel_mid.VerticalScrollbarHighlightOnWheel = false;
|
||||||
|
this.metroPanel_mid.VerticalScrollbarSize = 10;
|
||||||
|
//
|
||||||
|
// metroPanel_bottom
|
||||||
|
//
|
||||||
|
this.metroPanel_bottom.Controls.Add(this.linkLabel_editCollectItemCfg);
|
||||||
|
this.metroPanel_bottom.Controls.Add(this.ckStartZNDB);
|
||||||
|
this.metroPanel_bottom.Controls.Add(this.chkIsMesUP);
|
||||||
|
this.metroPanel_bottom.Controls.Add(this.btnSave);
|
||||||
|
this.metroPanel_bottom.Controls.Add(this.btnExit);
|
||||||
|
this.metroPanel_bottom.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||||
|
this.metroPanel_bottom.HorizontalScrollbarBarColor = true;
|
||||||
|
this.metroPanel_bottom.HorizontalScrollbarHighlightOnWheel = false;
|
||||||
|
this.metroPanel_bottom.HorizontalScrollbarSize = 10;
|
||||||
|
this.metroPanel_bottom.Location = new System.Drawing.Point(3, 396);
|
||||||
|
this.metroPanel_bottom.Name = "metroPanel_bottom";
|
||||||
|
this.metroPanel_bottom.Size = new System.Drawing.Size(713, 93);
|
||||||
|
this.metroPanel_bottom.TabIndex = 187;
|
||||||
|
this.metroPanel_bottom.VerticalScrollbarBarColor = true;
|
||||||
|
this.metroPanel_bottom.VerticalScrollbarHighlightOnWheel = false;
|
||||||
|
this.metroPanel_bottom.VerticalScrollbarSize = 10;
|
||||||
|
//
|
||||||
|
// metroLabel8
|
||||||
|
//
|
||||||
|
this.metroLabel8.AutoSize = true;
|
||||||
|
this.metroLabel8.Location = new System.Drawing.Point(29, 250);
|
||||||
|
this.metroLabel8.Name = "metroLabel8";
|
||||||
|
this.metroLabel8.Size = new System.Drawing.Size(135, 19);
|
||||||
|
this.metroLabel8.TabIndex = 36;
|
||||||
|
this.metroLabel8.Text = "产品进站接口地址:";
|
||||||
|
//
|
||||||
|
// tb_StationArrival
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
this.tb_StationArrival.CustomButton.Image = null;
|
||||||
|
this.tb_StationArrival.CustomButton.Location = new System.Drawing.Point(502, 1);
|
||||||
|
this.tb_StationArrival.CustomButton.Name = "";
|
||||||
|
this.tb_StationArrival.CustomButton.Size = new System.Drawing.Size(21, 21);
|
||||||
|
this.tb_StationArrival.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||||
|
this.tb_StationArrival.CustomButton.TabIndex = 1;
|
||||||
|
this.tb_StationArrival.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||||
|
this.tb_StationArrival.CustomButton.UseSelectable = true;
|
||||||
|
this.tb_StationArrival.CustomButton.Visible = false;
|
||||||
|
this.tb_StationArrival.Lines = new string[0];
|
||||||
|
this.tb_StationArrival.Location = new System.Drawing.Point(176, 250);
|
||||||
|
this.tb_StationArrival.MaxLength = 32767;
|
||||||
|
this.tb_StationArrival.Name = "tb_StationArrival";
|
||||||
|
this.tb_StationArrival.PasswordChar = '\0';
|
||||||
|
this.tb_StationArrival.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||||
|
this.tb_StationArrival.SelectedText = "";
|
||||||
|
this.tb_StationArrival.SelectionLength = 0;
|
||||||
|
this.tb_StationArrival.SelectionStart = 0;
|
||||||
|
this.tb_StationArrival.ShortcutsEnabled = true;
|
||||||
|
this.tb_StationArrival.Size = new System.Drawing.Size(524, 23);
|
||||||
|
this.tb_StationArrival.TabIndex = 37;
|
||||||
|
this.tb_StationArrival.UseSelectable = true;
|
||||||
|
this.tb_StationArrival.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||||
|
this.tb_StationArrival.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||||
|
//
|
||||||
|
// metroLabel9
|
||||||
|
//
|
||||||
|
this.metroLabel9.AutoSize = true;
|
||||||
|
this.metroLabel9.Location = new System.Drawing.Point(29, 283);
|
||||||
|
this.metroLabel9.Name = "metroLabel9";
|
||||||
|
this.metroLabel9.Size = new System.Drawing.Size(135, 19);
|
||||||
|
this.metroLabel9.TabIndex = 38;
|
||||||
|
this.metroLabel9.Text = "产品出站接口地址:";
|
||||||
|
//
|
||||||
|
// tb_stationExit
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
this.tb_stationExit.CustomButton.Image = null;
|
||||||
|
this.tb_stationExit.CustomButton.Location = new System.Drawing.Point(502, 1);
|
||||||
|
this.tb_stationExit.CustomButton.Name = "";
|
||||||
|
this.tb_stationExit.CustomButton.Size = new System.Drawing.Size(21, 21);
|
||||||
|
this.tb_stationExit.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||||
|
this.tb_stationExit.CustomButton.TabIndex = 1;
|
||||||
|
this.tb_stationExit.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||||
|
this.tb_stationExit.CustomButton.UseSelectable = true;
|
||||||
|
this.tb_stationExit.CustomButton.Visible = false;
|
||||||
|
this.tb_stationExit.Lines = new string[0];
|
||||||
|
this.tb_stationExit.Location = new System.Drawing.Point(176, 283);
|
||||||
|
this.tb_stationExit.MaxLength = 32767;
|
||||||
|
this.tb_stationExit.Name = "tb_stationExit";
|
||||||
|
this.tb_stationExit.PasswordChar = '\0';
|
||||||
|
this.tb_stationExit.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||||
|
this.tb_stationExit.SelectedText = "";
|
||||||
|
this.tb_stationExit.SelectionLength = 0;
|
||||||
|
this.tb_stationExit.SelectionStart = 0;
|
||||||
|
this.tb_stationExit.ShortcutsEnabled = true;
|
||||||
|
this.tb_stationExit.Size = new System.Drawing.Size(524, 23);
|
||||||
|
this.tb_stationExit.TabIndex = 39;
|
||||||
|
this.tb_stationExit.UseSelectable = true;
|
||||||
|
this.tb_stationExit.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||||
|
this.tb_stationExit.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||||
|
//
|
||||||
|
// FormMesDataSet
|
||||||
|
//
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(763, 578);
|
||||||
|
this.Controls.Add(this.groupBox1);
|
||||||
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.MinimizeBox = false;
|
||||||
|
this.Name = "FormMesDataSet";
|
||||||
|
this.Resizable = false;
|
||||||
|
this.Text = "系统参数设置";
|
||||||
|
this.Load += new System.EventHandler(this.FormMesDataSet_Load);
|
||||||
|
this.groupBox1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.LoginTime)).EndInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.txtMesRequestTime)).EndInit();
|
||||||
|
this.metroPanel_top.ResumeLayout(false);
|
||||||
|
this.metroPanel_top.PerformLayout();
|
||||||
|
this.metroPanel_mid.ResumeLayout(false);
|
||||||
|
this.metroPanel_mid.PerformLayout();
|
||||||
|
this.metroPanel_bottom.ResumeLayout(false);
|
||||||
|
this.metroPanel_bottom.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.bindingSource1)).EndInit();
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private MetroFramework.Controls.MetroButton btnExit;
|
||||||
|
private MetroFramework.Controls.MetroLabel metroLabel1;
|
||||||
|
private MetroFramework.Controls.MetroTextBox txtlineCode;
|
||||||
|
private MetroFramework.Controls.MetroButton btnSave;
|
||||||
|
private MetroFramework.Controls.MetroLabel metroLabel3;
|
||||||
|
private MetroFramework.Controls.MetroTextBox txtequipCode;
|
||||||
|
private MetroFramework.Controls.MetroTextBox txtsiteCode;
|
||||||
|
private MetroFramework.Controls.MetroLabel metroLabel2;
|
||||||
|
private System.Windows.Forms.CheckBox ckStartZNDB;
|
||||||
|
private MetroFramework.Controls.MetroTextBox txtmaterialCode;
|
||||||
|
private MetroFramework.Controls.MetroLabel metroLabel4;
|
||||||
|
private MetroFramework.Controls.MetroTextBox txtGradingMesUrl;
|
||||||
|
private MetroFramework.Controls.MetroLabel metroLabel5;
|
||||||
|
private MetroFramework.Controls.MetroTextBox txtResultProcessMesUrl;
|
||||||
|
private MetroFramework.Controls.MetroLabel metroLabel6;
|
||||||
|
private System.Windows.Forms.GroupBox groupBox1;
|
||||||
|
private System.Windows.Forms.CheckBox chkIsMesUP;
|
||||||
|
private MetroFramework.Controls.MetroLabel metroLabel20;
|
||||||
|
private MetroFramework.Controls.MetroLabel metroLabel21;
|
||||||
|
private System.Windows.Forms.NumericUpDown LoginTime;
|
||||||
|
private MetroFramework.Controls.MetroLabel metroLabel22;
|
||||||
|
private MetroFramework.Controls.MetroLabel metroLabel18;
|
||||||
|
private System.Windows.Forms.NumericUpDown txtMesRequestTime;
|
||||||
|
private System.Windows.Forms.LinkLabel linkLabel_editCollectItemCfg;
|
||||||
|
private MetroFramework.Controls.MetroLabel metroLabel7;
|
||||||
|
private MetroFramework.Controls.MetroTextBox tb_productType;
|
||||||
|
private MetroFramework.Controls.MetroPanel metroPanel_bottom;
|
||||||
|
private MetroFramework.Controls.MetroPanel metroPanel_mid;
|
||||||
|
private MetroFramework.Controls.MetroPanel metroPanel_top;
|
||||||
|
private MetroFramework.Controls.MetroTextBox tb_stationExit;
|
||||||
|
private MetroFramework.Controls.MetroLabel metroLabel9;
|
||||||
|
private MetroFramework.Controls.MetroTextBox tb_StationArrival;
|
||||||
|
private MetroFramework.Controls.MetroLabel metroLabel8;
|
||||||
|
private System.Windows.Forms.BindingSource bindingSource1;
|
||||||
|
}
|
||||||
|
}
|
||||||