增加日志功能;关于窗体
This commit is contained in:
+48
@@ -0,0 +1,48 @@
|
||||
namespace HexcalMC
|
||||
{
|
||||
partial class Lamp
|
||||
{
|
||||
/// <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();
|
||||
//
|
||||
// Lamp
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Font = new System.Drawing.Font("宋体", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134)));
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "Lamp";
|
||||
this.Size = new System.Drawing.Size(144, 121);
|
||||
this.Load += new System.EventHandler(this.Lamp_Load);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
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.Drawing.Drawing2D;
|
||||
|
||||
namespace HexcalMC
|
||||
{
|
||||
public partial class Lamp : UserControl
|
||||
{
|
||||
public Lamp()
|
||||
{
|
||||
InitializeComponent();
|
||||
base.SetStyle(ControlStyles.ResizeRedraw, true);
|
||||
this.DoubleBuffered = true;
|
||||
}
|
||||
|
||||
private void Lamp_Load(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private static Color[] COLORS = new Color[]
|
||||
{
|
||||
Color.Green,
|
||||
Color.Orange,
|
||||
Color.Red,
|
||||
Color.White,
|
||||
Color.Silver,
|
||||
Color.Transparent,
|
||||
Color.Yellow,
|
||||
Color.Blue
|
||||
};
|
||||
|
||||
private const int OK = 0;
|
||||
private const int WARN = 1;
|
||||
private const int ERROR = 2;
|
||||
private const int DEBUG = 4;
|
||||
private const int UNDEF = -1;
|
||||
private int _state = -1;
|
||||
|
||||
|
||||
private string Dtext = "";
|
||||
private bool _shadow = false;
|
||||
|
||||
/// <summary> 设置颜色 </summary>
|
||||
public int State
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._state;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._state = value;
|
||||
this.Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> 设置文字 </summary>
|
||||
public string LText
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Dtext;
|
||||
}
|
||||
set
|
||||
{
|
||||
this.Dtext = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> 设置阴影 </summary>
|
||||
public bool Shadow
|
||||
{
|
||||
get
|
||||
{
|
||||
return this._shadow;
|
||||
}
|
||||
set
|
||||
{
|
||||
this._shadow = value;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnPaint(PaintEventArgs gr)
|
||||
{
|
||||
base.OnPaint(gr);
|
||||
int num = Math.Min(base.Width, base.Height);
|
||||
bool flag = num >= 8;
|
||||
if (flag)
|
||||
{
|
||||
this.DrawLamp(gr.Graphics, num);
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawLamp(Graphics g, int rad)
|
||||
{
|
||||
g.SmoothingMode = SmoothingMode.AntiAlias;
|
||||
RectangleF rect = new RectangleF(1f, 1f, (float)(rad - 5), (float)(rad - 5));
|
||||
float num = rect.Width / 12f;
|
||||
RectangleF rect2 = new RectangleF(rect.Location, rect.Size);
|
||||
rect2.Inflate(1f, 1f);
|
||||
if (_shadow)
|
||||
{
|
||||
rect2.X += num;
|
||||
rect2.Y += num;
|
||||
g.FillEllipse(Brushes.Gray, rect2);
|
||||
rect2.X -= num;
|
||||
rect2.Y -= num;
|
||||
}
|
||||
g.FillEllipse(Brushes.Black, rect2);
|
||||
|
||||
if (_state != -1)
|
||||
{
|
||||
using (GraphicsPath graphicsPath = new GraphicsPath())
|
||||
{
|
||||
graphicsPath.AddEllipse(rect);
|
||||
int x = (int)(rect.X + rect.Width / 3f);
|
||||
int y = (int)(rect.Y + rect.Height / 3f);
|
||||
Color color = Lamp.COLORS[_state];
|
||||
using (PathGradientBrush pathGradientBrush = new PathGradientBrush(graphicsPath))
|
||||
{
|
||||
pathGradientBrush.CenterColor = Color.Snow;
|
||||
pathGradientBrush.CenterPoint = new Point(x, y);
|
||||
pathGradientBrush.SurroundColors = new Color[]
|
||||
{
|
||||
color
|
||||
};
|
||||
g.FillPath(pathGradientBrush, graphicsPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
using (Brush brush = new SolidBrush(this.BackColor))
|
||||
{
|
||||
g.FillEllipse(brush, rect);
|
||||
}
|
||||
}
|
||||
|
||||
if (Dtext.Length > 0)
|
||||
{
|
||||
float emSize = rect.Height / 6f;
|
||||
Font font = new Font("Microsoft Sans Serif", emSize, FontStyle.Bold, GraphicsUnit.Point, 0);
|
||||
int num2 = (int)font.GetHeight();
|
||||
int y2 = (int)rect.Height / 2 - num2 / 2;
|
||||
int num3 = (int)g.MeasureString(Dtext, font).Width;
|
||||
int num4 = (int)(rect.Width - (float)num3) / 2;
|
||||
bool flag3 = num4 < 0;
|
||||
if (flag3)
|
||||
{
|
||||
num4 = 0;
|
||||
}
|
||||
g.DrawString(Dtext, font, Brushes.Black, new Point(num4, y2));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class LampColor
|
||||
{
|
||||
public const int OK = 0;
|
||||
public const int WARN = 1;
|
||||
public const int ERROR = 2;
|
||||
public const int DEBUG = 4;
|
||||
public const int UNDEF = -1;
|
||||
|
||||
public const int Green = 0;
|
||||
public const int Orange = 1;
|
||||
public const int Red = 2;
|
||||
public const int White = 3;
|
||||
public const int Silver = 4;
|
||||
public const int Transparent = 5;
|
||||
public const int Yellow = 6;
|
||||
public const int Blue = 7;
|
||||
}
|
||||
}
|
||||
@@ -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>
|
||||
+68
@@ -0,0 +1,68 @@
|
||||
namespace BaseFunction
|
||||
{
|
||||
partial class ResultPicture
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ResultPicture));
|
||||
this.picBox_Result = new System.Windows.Forms.PictureBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.picBox_Result)).BeginInit();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// picBox_Result
|
||||
//
|
||||
this.picBox_Result.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(192)))), ((int)(((byte)(255)))));
|
||||
this.picBox_Result.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.picBox_Result.Image = ((System.Drawing.Image)(resources.GetObject("picBox_Result.Image")));
|
||||
this.picBox_Result.Location = new System.Drawing.Point(0, 0);
|
||||
this.picBox_Result.Name = "picBox_Result";
|
||||
this.picBox_Result.Size = new System.Drawing.Size(160, 160);
|
||||
this.picBox_Result.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
|
||||
this.picBox_Result.TabIndex = 0;
|
||||
this.picBox_Result.TabStop = false;
|
||||
this.picBox_Result.Click += new System.EventHandler(this.picBox_Result_Click);
|
||||
//
|
||||
// ResultPicture
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 16F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.picBox_Result);
|
||||
this.Font = new System.Drawing.Font("宋体", 16F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Pixel, ((byte)(134)));
|
||||
this.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4);
|
||||
this.Name = "ResultPicture";
|
||||
this.Size = new System.Drawing.Size(160, 160);
|
||||
((System.ComponentModel.ISupportInitialize)(this.picBox_Result)).EndInit();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox picBox_Result;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace BaseFunction
|
||||
{
|
||||
public partial class ResultPicture : UserControl
|
||||
{
|
||||
public ResultPicture()
|
||||
{
|
||||
try
|
||||
{
|
||||
InitializeComponent();
|
||||
picBox_Result.Image = null;
|
||||
picBox_Result.BackColor = Color.FromArgb(((int)(((byte)(19)))), ((int)(((byte)(46)))), ((int)(((byte)(53)))));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void picBox_Result_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
/// <summary> 结果显示类型, True=合格,false=超差 </summary>
|
||||
public void SetResultPicture(bool bOK)
|
||||
{
|
||||
try
|
||||
{
|
||||
picBox_Result.Image = bOK ? ImageDfn.IMG_ResultOK : ImageDfn.IMG_ResultNG;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
/// <summary> 结果显示类型, 1=合格,2=超差,3=其他,4=无工件, 9=无图片 </summary>
|
||||
public void SetResultPicture(int ShowType = 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
switch (ShowType)
|
||||
{
|
||||
case 1: picBox_Result.Image = ImageDfn.IMG_ResultOK; break;
|
||||
case 2: picBox_Result.Image = ImageDfn.IMG_ResultNG; break;
|
||||
case 3: picBox_Result.Image = ImageDfn.IMG_Other; break;
|
||||
case 4: picBox_Result.Image = ImageDfn.IMG_Null; break;
|
||||
case 5: picBox_Result.Image = ImageDfn.IMG_Waiting; break;
|
||||
case 9: picBox_Result.Image = null; break;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public void SetSize(int SizeWidth = 160, int SizeHeight = 160)
|
||||
{
|
||||
try
|
||||
{
|
||||
this.Width = SizeWidth;
|
||||
this.Height = SizeHeight;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user