Browse Source

AddNewControls

master
yibo 7 years ago
parent
commit
306ef6fe42
46 changed files with 3063 additions and 30 deletions
  1. +108
    -0
      Test/Form1.Designer.cs
  2. +44
    -0
      Test/Form1.cs
  3. +129
    -0
      Test/Form1.resx
  4. +22
    -0
      Test/Program.cs
  5. +36
    -0
      Test/Properties/AssemblyInfo.cs
  6. +71
    -0
      Test/Properties/Resources.Designer.cs
  7. +117
    -0
      Test/Properties/Resources.resx
  8. +30
    -0
      Test/Properties/Settings.Designer.cs
  9. +7
    -0
      Test/Properties/Settings.settings
  10. +92
    -0
      Test/Test.csproj
  11. +11
    -5
      WinFormControl.sln
  12. +79
    -0
      WinFormControl/NetStateWatch.Designer.cs
  13. +84
    -0
      WinFormControl/NetStateWatch.cs
  14. +120
    -0
      WinFormControl/NetStateWatch.resx
  15. +1
    -1
      WinFormControl/Properties/AssemblyInfo.cs
  16. +30
    -0
      WinFormControl/Properties/Resources.Designer.cs
  17. +9
    -0
      WinFormControl/Properties/Resources.resx
  18. BIN
      WinFormControl/Resources/disable.png
  19. BIN
      WinFormControl/Resources/greenCircle.png
  20. BIN
      WinFormControl/Resources/redCircle.png
  21. BIN
      WinFormControl/Sounds/click.wav
  22. BIN
      WinFormControl/Sounds/di.wav
  23. BIN
      WinFormControl/Sounds/error.wav
  24. BIN
      WinFormControl/Sounds/longSucc.wav
  25. BIN
      WinFormControl/Sounds/shotSucc.wav
  26. +35
    -6
      WinFormControl/UButton.cs
  27. +43
    -0
      WinFormControl/UDataGridView.cs
  28. +73
    -0
      WinFormControl/UScanPanel.Designer.cs
  29. +92
    -0
      WinFormControl/UScanPanel.cs
  30. +120
    -0
      WinFormControl/UScanPanel.resx
  31. +113
    -0
      WinFormControl/UWeightControl.Designer.cs
  32. +286
    -0
      WinFormControl/UWeightControl.cs
  33. +144
    -0
      WinFormControl/UWeightControl.resx
  34. +0
    -0
      WinFormControl/Utils/ControlUtil.cs
  35. +69
    -0
      WinFormControl/Utils/DataFormatBase.cs
  36. +36
    -0
      WinFormControl/Utils/IND560DataFormat.cs
  37. +33
    -0
      WinFormControl/Utils/SoundPalyUtil.cs
  38. +100
    -0
      WinFormControl/Utils/Xk3124DataFormat.cs
  39. +107
    -0
      WinFormControl/Utils/Xk3190A9DataFormat.cs
  40. +102
    -0
      WinFormControl/Utils/Xk3190D10DataFormat.cs
  41. +41
    -0
      WinFormControl/Utils/XmlUtil.cs
  42. +39
    -0
      WinFormControl/WeightContext.cs
  43. +104
    -0
      WinFormControl/WeightSettingFrom.cs
  44. +310
    -0
      WinFormControl/WeightSettingFrom.designer.cs
  45. +137
    -0
      WinFormControl/WeightSettingFrom.resx
  46. +89
    -18
      WinFormControl/WinFormControl.csproj

+ 108
- 0
Test/Form1.Designer.cs View File

@ -0,0 +1,108 @@
namespace Test
{
partial class Form1
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.comboBox1 = new System.Windows.Forms.ComboBox();
this.uButton1 = new WinFormControl.UButton();
this.uScanPanel1 = new WinFormControl.UScanPanel();
this.uWeightControl1 = new WinFormControl.UWeightControl();
this.SuspendLayout();
//
// comboBox1
//
this.comboBox1.Font = new System.Drawing.Font("宋体", 15F);
this.comboBox1.FormattingEnabled = true;
this.comboBox1.Location = new System.Drawing.Point(53, 239);
this.comboBox1.Name = "comboBox1";
this.comboBox1.Size = new System.Drawing.Size(121, 28);
this.comboBox1.TabIndex = 3;
//
// uButton1
//
this.uButton1.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("uButton1.BackgroundImage")));
this.uButton1.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(155)))), ((int)(((byte)(214)))));
this.uButton1.FlatAppearance.BorderSize = 0;
this.uButton1.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.uButton1.ForeColor = System.Drawing.Color.Black;
this.uButton1.Location = new System.Drawing.Point(254, 239);
this.uButton1.Name = "uButton1";
this.uButton1.PlaySound = true;
this.uButton1.Size = new System.Drawing.Size(130, 47);
this.uButton1.SoundType = WinFormControl.SoundType.Di;
this.uButton1.TabIndex = 2;
this.uButton1.Text = "uButton1";
this.uButton1.UseVisualStyleBackColor = true;
this.uButton1.Click += new System.EventHandler(this.uButton1_Click);
//
// uScanPanel1
//
this.uScanPanel1.BackColor = System.Drawing.Color.Transparent;
this.uScanPanel1.Location = new System.Drawing.Point(101, 182);
this.uScanPanel1.Name = "uScanPanel1";
this.uScanPanel1.Size = new System.Drawing.Size(303, 32);
this.uScanPanel1.TabIndex = 1;
this.uScanPanel1.BeforeScan += new System.Action(this.uScanPanel1_BeforeScan);
this.uScanPanel1.AfterScan += new System.Action(this.uScanPanel1_AfterScan);
//
// uWeightControl1
//
this.uWeightControl1.BackColor = System.Drawing.Color.Transparent;
this.uWeightControl1.Location = new System.Drawing.Point(2, 12);
this.uWeightControl1.Name = "uWeightControl1";
this.uWeightControl1.Size = new System.Drawing.Size(348, 78);
this.uWeightControl1.TabIndex = 0;
this.uWeightControl1.WeightFalg = "Test";
this.uWeightControl1.ReceivedValue += new System.Action<decimal>(this.uWeightControl1_ReceivedValue);
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(604, 363);
this.Controls.Add(this.comboBox1);
this.Controls.Add(this.uButton1);
this.Controls.Add(this.uScanPanel1);
this.Controls.Add(this.uWeightControl1);
this.KeyPreview = true;
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
}
#endregion
private WinFormControl.UWeightControl uWeightControl1;
private WinFormControl.UScanPanel uScanPanel1;
private WinFormControl.UButton uButton1;
private System.Windows.Forms.ComboBox comboBox1;
}
}

+ 44
- 0
Test/Form1.cs View File

@ -0,0 +1,44 @@
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;
using WinFormControl;
namespace Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
comboBox1.DataSource = Enum.GetNames(typeof(SoundType));
}
private void uWeightControl1_ReceivedValue(decimal obj)
{
MessageBox.Show(obj.ToString());
}
private void uScanPanel1_BeforeScan()
{
//throw new Exception("dddddd");
}
private void uScanPanel1_AfterScan()
{
MessageBox.Show(uScanPanel1.TextBox.Text);
}
private void uButton1_Click(object sender, EventArgs e)
{
//SoundType sy;
//if (Enum.TryParse(comboBox1.SelectedValue.ToString(), out sy))
// SoundPalyUtil.PlaySound(sy);
}
}
}

+ 129
- 0
Test/Form1.resx View File

@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="uButton1.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwCAIAAABhdOiYAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wwAADsMBx2+oZAAAAHNJREFUaEPt0AENACAMwDAkowVB14aDz0CTKui5b1gICoKCoCAoCAqCgqAgKAgK
goKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAg
KAgKgoKg1ZsPvpCB0hBohjQAAAAASUVORK5CYII=
</value>
</data>
</root>

+ 22
- 0
Test/Program.cs View File

@ -0,0 +1,22 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Test
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}

+ 36
- 0
Test/Properties/AssemblyInfo.cs View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Test")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Test")]
[assembly: AssemblyCopyright("Copyright © 2018")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("82822c1e-a8f4-41db-8045-0e447500b163")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

+ 71
- 0
Test/Properties/Resources.Designer.cs View File

@ -0,0 +1,71 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本: 4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace Test.Properties
{
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.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 ((resourceMan == null))
{
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Test.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;
}
}
}
}

+ 117
- 0
Test/Properties/Resources.resx View File

@ -0,0 +1,117 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

+ 30
- 0
Test/Properties/Settings.Designer.cs View File

@ -0,0 +1,30 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Test.Properties
{
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
{
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default
{
get
{
return defaultInstance;
}
}
}
}

+ 7
- 0
Test/Properties/Settings.settings View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

+ 92
- 0
Test/Test.csproj View File

@ -0,0 +1,92 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" 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>{19454EB5-F255-4A8C-A925-9A43A0E92264}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Test</RootNamespace>
<AssemblyName>Test</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<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.Design" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\WinFormControl\WinFormControl.csproj">
<Project>{5f1ac749-68db-43e2-8895-886ecc04d7da}</Project>
<Name>WinFormControl</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

+ 11
- 5
WinFormControl.sln View File

@ -3,7 +3,9 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormControl", "WinFormControl\WinFormControl.csproj", "{45A6C56B-C815-4AEA-B0C4-68C122FD3139}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Test", "Test\Test.csproj", "{19454EB5-F255-4A8C-A925-9A43A0E92264}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WinFormControl", "WinFormControl\WinFormControl.csproj", "{5F1AC749-68DB-43E2-8895-886ECC04D7DA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -11,10 +13,14 @@ Global
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{45A6C56B-C815-4AEA-B0C4-68C122FD3139}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{45A6C56B-C815-4AEA-B0C4-68C122FD3139}.Debug|Any CPU.Build.0 = Debug|Any CPU
{45A6C56B-C815-4AEA-B0C4-68C122FD3139}.Release|Any CPU.ActiveCfg = Release|Any CPU
{45A6C56B-C815-4AEA-B0C4-68C122FD3139}.Release|Any CPU.Build.0 = Release|Any CPU
{19454EB5-F255-4A8C-A925-9A43A0E92264}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{19454EB5-F255-4A8C-A925-9A43A0E92264}.Debug|Any CPU.Build.0 = Debug|Any CPU
{19454EB5-F255-4A8C-A925-9A43A0E92264}.Release|Any CPU.ActiveCfg = Release|Any CPU
{19454EB5-F255-4A8C-A925-9A43A0E92264}.Release|Any CPU.Build.0 = Release|Any CPU
{5F1AC749-68DB-43E2-8895-886ECC04D7DA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5F1AC749-68DB-43E2-8895-886ECC04D7DA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5F1AC749-68DB-43E2-8895-886ECC04D7DA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{5F1AC749-68DB-43E2-8895-886ECC04D7DA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE


+ 79
- 0
WinFormControl/NetStateWatch.Designer.cs View File

@ -0,0 +1,79 @@
namespace WinFormControl
{
partial class NetStateWatch
{
/// <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.uLabel1 = new WinFormControl.ULabel();
this.picNetStatus = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.picNetStatus)).BeginInit();
this.SuspendLayout();
//
// uLabel1
//
this.uLabel1.AutoSize = true;
this.uLabel1.BackColor = System.Drawing.Color.Transparent;
this.uLabel1.Font = new System.Drawing.Font("宋体", 15F);
this.uLabel1.ForeColor = System.Drawing.Color.Black;
this.uLabel1.Location = new System.Drawing.Point(3, 9);
this.uLabel1.Name = "uLabel1";
this.uLabel1.Size = new System.Drawing.Size(49, 20);
this.uLabel1.TabIndex = 44;
this.uLabel1.Text = "网络";
//
// picNetStatus
//
this.picNetStatus.ErrorImage = null;
this.picNetStatus.Image = global::WinFormControl.Properties.Resources.redCircle;
this.picNetStatus.InitialImage = null;
this.picNetStatus.Location = new System.Drawing.Point(52, 2);
this.picNetStatus.Name = "picNetStatus";
this.picNetStatus.Size = new System.Drawing.Size(34, 34);
this.picNetStatus.TabIndex = 43;
this.picNetStatus.TabStop = false;
//
// NetStateWatch
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Transparent;
this.Controls.Add(this.uLabel1);
this.Controls.Add(this.picNetStatus);
this.Name = "NetStateWatch";
this.Size = new System.Drawing.Size(90, 39);
((System.ComponentModel.ISupportInitialize)(this.picNetStatus)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private ULabel uLabel1;
private System.Windows.Forms.PictureBox picNetStatus;
}
}

+ 84
- 0
WinFormControl/NetStateWatch.cs View File

@ -0,0 +1,84 @@
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.Threading;
namespace WinFormControl
{
/// <summary>
/// Must Give Func GetConnectState A Value;
/// </summary>
public partial class NetStateWatch : UserControl
{
private Thread _tcCheckNetStatus;
public NetStateWatch()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (GetConnectState == null)
return;
_tcCheckNetStatus = new Thread(CheckNetStatus);
_tcCheckNetStatus.Start();
ParentForm.FormClosing += delegate
{
if (_tcCheckNetStatus != null && _tcCheckNetStatus.IsAlive)
{
_tcCheckNetStatus.Abort();
}
};
}
[Browsable(true)]
public Func<bool> GetConnectState;
[Browsable(false)]
public bool NetState { get; private set; }
[Browsable(true), Description("连接状态改变事件")]
public event Action<bool> NetStateChanged;
private bool laseConnection = false;
private void CheckNetStatus()
{
while (true)
{
try
{
NetState = GetConnectState();
if (NetState && laseConnection)
{
Thread.Sleep(1000);
continue;
}
if (NetStateChanged != null)
NetStateChanged(NetState);
var img = Properties.Resources.redCircle;
if (NetState)
img = Properties.Resources.greenCircle;
this.Invoke(new Action(delegate()
{
picNetStatus.Image = img;
picNetStatus.Refresh();
}));
laseConnection = NetState;
}
catch
{
}
Thread.Sleep(1000);
}
}
}
}

+ 120
- 0
WinFormControl/NetStateWatch.resx View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

+ 1
- 1
WinFormControl/Properties/AssemblyInfo.cs View File

@ -20,7 +20,7 @@ using System.Runtime.InteropServices;
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("747dea7e-a712-427e-ac75-fe1b69ec9b42")]
[assembly: Guid("7f771e26-f0d0-4d1d-885d-642fe81c06ae")]
// 程序集的版本信息由下面四个值组成:
//


+ 30
- 0
WinFormControl/Properties/Resources.Designer.cs View File

@ -60,6 +60,26 @@ namespace WinFormControl.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap disable {
get {
object obj = ResourceManager.GetObject("disable", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap greenCircle {
get {
object obj = ResourceManager.GetObject("greenCircle", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
@ -70,6 +90,16 @@ namespace WinFormControl.Properties {
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>
internal static System.Drawing.Bitmap redCircle {
get {
object obj = ResourceManager.GetObject("redCircle", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源。
/// </summary>


+ 9
- 0
WinFormControl/Properties/Resources.resx View File

@ -118,9 +118,18 @@
<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="disable" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\disable.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="greenCircle" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\greenCircle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="onclickBtn" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\onclickBtn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="redCircle" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\redCircle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="simpleBtn" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\simpleBtn.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>

BIN
WinFormControl/Resources/disable.png View File

Before After
Width: 96  |  Height: 48  |  Size: 221 B

BIN
WinFormControl/Resources/greenCircle.png View File

Before After
Width: 32  |  Height: 32  |  Size: 1.3 KiB

BIN
WinFormControl/Resources/redCircle.png View File

Before After
Width: 32  |  Height: 32  |  Size: 1.2 KiB

BIN
WinFormControl/Sounds/click.wav View File


BIN
WinFormControl/Sounds/di.wav View File


BIN
WinFormControl/Sounds/error.wav View File


BIN
WinFormControl/Sounds/longSucc.wav View File


BIN
WinFormControl/Sounds/shotSucc.wav View File


+ 35
- 6
WinFormControl/UButton.cs View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Text;
@ -16,26 +17,54 @@ namespace WinFormControl
base.InitLayout();
this.BackgroundImage = Resources.simpleBtn;
this.ForeColor = Color.Black;
this.BackColor = Color.Transparent;
this.FlatStyle = FlatStyle.Flat;
this.FlatAppearance.BorderSize = 0;
this.FlatAppearance.BorderColor = Color.FromArgb(45, 155, 214);
}
[Browsable(true), Category("Sound"), Description("是否播放声音")]
public bool PlaySound { get; set; }
[Browsable(true), Category("Sound"), Description("声音类型")]
public SoundType SoundType { get; set; }
protected override void OnMouseDown(MouseEventArgs mevent)
{
if (mevent.Button == MouseButtons.Left)
{
this.BackgroundImage = Resources.onclickBtn;
this.ForeColor = Color.White;
}
base.OnMouseDown(mevent);
}
protected override void OnClick(EventArgs e)
{
this.BackgroundImage = Resources.onclickBtn;
this.ForeColor = Color.White;
this.Refresh();
try
{
this.Enabled = false;
if (PlaySound)
SoundPalyUtil.PlaySound(SoundType);
base.OnClick(e);
}
finally
{
System.Threading.Thread.Sleep(200);
this.Enabled = true;
}
}
protected override void OnEnabledChanged(EventArgs e)
{
base.OnEnabledChanged(e);
if (Enabled)
{
this.BackgroundImage = Resources.simpleBtn;
this.ForeColor = Color.Black;
this.Refresh();
}
else
{
this.BackgroundImage = Resources.disable;
}
}
}


+ 43
- 0
WinFormControl/UDataGridView.cs View File

@ -0,0 +1,43 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace WinFormControl
{
public class UDataGridView : DataGridView
{
public UDataGridView()
{
this.AllowUserToAddRows = false;
this.AllowUserToDeleteRows = false;
this.AllowUserToResizeColumns = false;
this.AllowUserToResizeRows = false;
this.BackgroundColor = System.Drawing.Color.White;
this.ColumnHeadersHeight = 24;
this.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
this.MultiSelect = false;
this.RowHeadersVisible = false;
this.RowTemplate.Height = 23;
this.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.AlternatingRowsDefaultCellStyle = new DataGridViewCellStyle() { BackColor = System.Drawing.Color.FromArgb(235, 235, 235) };
this.ColumnHeadersDefaultCellStyle = new DataGridViewCellStyle()
{
Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter,
Font = new System.Drawing.Font("宋体", 12F),
ForeColor = System.Drawing.Color.White,
WrapMode = System.Windows.Forms.DataGridViewTriState.True,
};
this.RowsDefaultCellStyle = new DataGridViewCellStyle()
{
SelectionBackColor = System.Drawing.Color.FromArgb(66, 163, 218),
Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134)
};
}
}
}

+ 73
- 0
WinFormControl/UScanPanel.Designer.cs View File

@ -0,0 +1,73 @@
namespace WinFormControl
{
partial class UScanPanel
{
/// <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.textBox1 = new System.Windows.Forms.TextBox();
this.uLabel1 = new WinFormControl.ULabel();
this.SuspendLayout();
//
// textBox1
//
this.textBox1.Font = new System.Drawing.Font("宋体", 15F);
this.textBox1.Location = new System.Drawing.Point(64, 1);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(235, 30);
this.textBox1.TabIndex = 0;
//
// uLabel1
//
this.uLabel1.AutoSize = true;
this.uLabel1.BackColor = System.Drawing.Color.Transparent;
this.uLabel1.Font = new System.Drawing.Font("宋体", 15F);
this.uLabel1.Location = new System.Drawing.Point(3, 4);
this.uLabel1.Name = "uLabel1";
this.uLabel1.Size = new System.Drawing.Size(69, 20);
this.uLabel1.TabIndex = 1;
this.uLabel1.Text = "扫码:";
//
// UScanPanel
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Transparent;
this.Controls.Add(this.textBox1);
this.Controls.Add(this.uLabel1);
this.Name = "UScanPanel";
this.Size = new System.Drawing.Size(303, 32);
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.TextBox textBox1;
private ULabel uLabel1;
}
}

+ 92
- 0
WinFormControl/UScanPanel.cs View File

@ -0,0 +1,92 @@
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;
namespace WinFormControl
{
public partial class UScanPanel : UserControl
{
[Browsable(true), Description("标签")]
public ULabel Label { get { return uLabel1; } }
[Browsable(true), Description("文本框")]
public TextBox TextBox { get { return textBox1; } }
[Browsable(true), Description("扫码前的动作")]
public event Action BeforeScan;
[Browsable(true), Description("扫码后的动作")]
public event Action AfterScan;
public UScanPanel()
{
InitializeComponent();
}
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
if (!ParentForm.KeyPreview)
ParentForm.KeyPreview = true;
ParentForm.KeyPress += ParentForm_KeyPress;
}
bool reading = false;
private void ParentForm_KeyPress(object sender, KeyPressEventArgs e)
{
if (!reading)
{
if (BeforeScan != null)
BeforeScan();
textBox1.Text = string.Empty;
}
if (!textBox1.Focused)
{
textBox1.Focus();
textBox1.Text = e.KeyChar.ToString();
textBox1.Select(textBox1.TextLength, 0);
}
if (e.KeyChar == (char)Keys.Enter)
{
e.Handled = true;
var code = ParseCode(textBox1.Text);
textBox1.Text = code;
textBox1.Select(textBox1.TextLength, 0);
reading = false;
if (AfterScan != null)
AfterScan();
}
else
reading = true;
}
static string ParseCode(string url)
{
if (url.Contains("?"))
{
var arr = url.Split(new char[] { '?' }, StringSplitOptions.RemoveEmptyEntries);
if (arr.Length > 1)
{
var list = arr[1].Split(new char[] { '&' }, StringSplitOptions.RemoveEmptyEntries);
foreach (var item in list)
{
var l = item.Split(new char[] { '=' }, StringSplitOptions.RemoveEmptyEntries);
if (l.Length == 2 && l[0].ToUpper() == "CODE")
return l[1].Trim();
}
return string.Empty;
}
return string.Empty;
}
return url.Trim();
}
}
}

+ 120
- 0
WinFormControl/UScanPanel.resx View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

+ 113
- 0
WinFormControl/UWeightControl.Designer.cs View File

@ -0,0 +1,113 @@
namespace WinFormControl
{
partial class UWeightControl
{
/// <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(UWeightControl));
this.weightSwitch = new System.Windows.Forms.Button();
this.panel2 = new System.Windows.Forms.Panel();
this.lblChengZhong = new System.Windows.Forms.Label();
this.settingBtn = new WinFormControl.UButton();
this.panel2.SuspendLayout();
this.SuspendLayout();
//
// weightSwitch
//
this.weightSwitch.BackColor = System.Drawing.Color.Transparent;
this.weightSwitch.BackgroundImage = global::WinFormControl.Properties.Resources.simpleBtn;
this.weightSwitch.FlatAppearance.BorderSize = 0;
this.weightSwitch.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.weightSwitch.Font = new System.Drawing.Font("宋体", 15F);
this.weightSwitch.Location = new System.Drawing.Point(231, 43);
this.weightSwitch.Name = "weightSwitch";
this.weightSwitch.Size = new System.Drawing.Size(111, 34);
this.weightSwitch.TabIndex = 2;
this.weightSwitch.Text = "启用称重";
this.weightSwitch.UseVisualStyleBackColor = false;
this.weightSwitch.Click += new System.EventHandler(this.weightSwitch_Click);
//
// panel2
//
this.panel2.BackColor = System.Drawing.Color.Black;
this.panel2.Controls.Add(this.lblChengZhong);
this.panel2.Location = new System.Drawing.Point(0, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(224, 78);
this.panel2.TabIndex = 33;
//
// lblChengZhong
//
this.lblChengZhong.AutoSize = true;
this.lblChengZhong.Font = new System.Drawing.Font("宋体", 30F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblChengZhong.ForeColor = System.Drawing.Color.Red;
this.lblChengZhong.Location = new System.Drawing.Point(15, 18);
this.lblChengZhong.Name = "lblChengZhong";
this.lblChengZhong.Size = new System.Drawing.Size(97, 40);
this.lblChengZhong.TabIndex = 0;
this.lblChengZhong.Text = "0.00";
//
// settingBtn
//
this.settingBtn.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("settingBtn.BackgroundImage")));
this.settingBtn.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(155)))), ((int)(((byte)(214)))));
this.settingBtn.FlatAppearance.BorderSize = 0;
this.settingBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.settingBtn.Font = new System.Drawing.Font("宋体", 15F);
this.settingBtn.ForeColor = System.Drawing.Color.Black;
this.settingBtn.Location = new System.Drawing.Point(231, 0);
this.settingBtn.Name = "settingBtn";
this.settingBtn.Size = new System.Drawing.Size(111, 34);
this.settingBtn.TabIndex = 41;
this.settingBtn.Text = "称 设 置";
this.settingBtn.UseVisualStyleBackColor = true;
this.settingBtn.Click += new System.EventHandler(this.settingBtn_Click);
//
// UWeightControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.Transparent;
this.Controls.Add(this.settingBtn);
this.Controls.Add(this.panel2);
this.Controls.Add(this.weightSwitch);
this.Name = "UWeightControl";
this.Size = new System.Drawing.Size(349, 78);
this.panel2.ResumeLayout(false);
this.panel2.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button weightSwitch;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.Label lblChengZhong;
private UButton settingBtn;
}
}

+ 286
- 0
WinFormControl/UWeightControl.cs View File

@ -0,0 +1,286 @@
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 WinFormControl.Properties;
using System.Threading;
using System.IO.Ports;
using System.Collections.Concurrent;
namespace WinFormControl
{
public partial class UWeightControl : UserControl
{
WeightConfig config;
SerialPort weightPort;
IDataFormat _dataFormat;
Thread _inQueryThread;
private bool _mainProcessIsRun;
readonly StringBuilder _dataStrBuilder = new StringBuilder();
private bool switchOn;
[Browsable(true), Description("称设置标识")]
public string WeightFalg { get; set; }
[Browsable(true), Description("读取到值的事件")]
public event Action<decimal> ReceivedValue;
public UWeightControl()
{
InitializeComponent();
weightSwitch.FlatAppearance.BorderColor = Color.FromArgb(45, 155, 214);
}
[Browsable(false)]
public decimal Weight { get { return decimal.Parse(lblChengZhong.Text); } }
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
ParentForm.FormClosing += delegate
{
if (_inQueryThread != null && _inQueryThread.IsAlive)
{
DisableWeight();
}
};
}
private void settingBtn_Click(object sender, EventArgs e)
{
if (new WeightSettingFrom(WeightFalg).ShowDialog() == DialogResult.OK)
config = WeightConfig.Init(WeightFalg);
}
private void weightSwitch_Click(object sender, EventArgs e)
{
try
{
if (config == null)
{
config = WeightConfig.Init(WeightFalg);
WeighAvgControl.config = config;
}
settingBtn.Enabled = switchOn;
switchOn = !switchOn;
if (switchOn)
{
weightSwitch.BackgroundImage = Resources.onclickBtn;
weightSwitch.ForeColor = Color.White;
weightSwitch.Text = "停止称重";
OpenSerialPort();
_mainProcessIsRun = true;
ReadData();
}
else
{
weightSwitch.BackgroundImage = Resources.simpleBtn;
weightSwitch.ForeColor = Color.Black;
weightSwitch.Text = "启用称重";
DisableWeight();
}
}
catch
{
settingBtn.Enabled = !switchOn;
switchOn = !switchOn;
}
}
void OpenSerialPort()
{
if (!switchOn)
return;
if (config.RateSet == null)
throw new Exception("请先配置称相关信息");
weightPort = new SerialPort();
weightPort.PortName = config.ComSet;
weightPort.BaudRate = config.RateSet.Value;
weightPort.DataBits = config.BitSet.Value;
weightPort.ReadBufferSize = 4096 * 100;
if (!string.IsNullOrEmpty(config.Format))
format = "{0:{format}}".Replace("{format}", config.Format);
switch (config.WeightSet)
{
case "IND560":
_dataFormat = new IND560DataFormat();
break;
case "Xk3124":
case "IND231":
_dataFormat = new Xk3124DataFormat();
break;
case "Xk3190A9":
_dataFormat = new Xk3190A9DataFormat();
break;
default:
_dataFormat = new Xk3190D10DataFormat();
break;
}
if (!weightPort.IsOpen)
{
try
{
weightPort.Open();
}
catch (InvalidOperationException)
{
throw new Exception("指定的端口已打开");
}
catch (UnauthorizedAccessException)
{
throw new Exception("对端口的访问被拒绝");
}
}
}
void ReadData()
{
_inQueryThread = new Thread(InQuery);
_inQueryThread.Start();
}
string format = "{0:0.00}";
private void InQuery()
{
while (_mainProcessIsRun)
{
int availableCount = weightPort.BytesToRead;
if (availableCount == 0)
{
Thread.Sleep(10);
}
char[] buffer = new char[availableCount];
if (!weightPort.IsOpen)
{
continue;
}
weightPort.Read(buffer, 0, availableCount);
foreach (var c in buffer)
{
if (c == _dataFormat.Beginchar)
{
_dataStrBuilder.Clear();
_dataStrBuilder.Append(c);
}
else if (c == _dataFormat.Endchar && _dataStrBuilder.Length == _dataFormat.DataLength - 1)
{
_dataStrBuilder.Append(c);
bool isStatic;
string str;
if (_dataFormat.ParseAscii(_dataStrBuilder.ToString(), out str, out isStatic))
{
if (config.WeightType == 0)
{
if (string.IsNullOrEmpty(str))
str = "0";
this.Invoke(new Action(delegate()
{
var v = decimal.Parse(str);
lblChengZhong.Text = string.Format(format, v);
if (str != "0")
{
if (ReceivedValue != null)
ReceivedValue(v);
}
}));
}
else
{
decimal num = 0;
if (decimal.TryParse(str, out num))
{
this.Invoke(new Action(delegate()
{
lblChengZhong.Text = string.Format(format, num);
}));
WeighAvgControl.Add(num, isStatic);
}
if (WeighAvgControl.TryGetValue(out num))
{
this.Invoke(new Action(delegate()
{
if (str != "0")
{
if (ReceivedValue != null)
ReceivedValue(num);
}
}));
}
}
}
_dataStrBuilder.Clear();
}
else if (_dataStrBuilder.Length != 0)
{
_dataStrBuilder.Append(c);
}
}
}
}
private class WeighAvgControl
{
public static WeightConfig config;
public static bool TryGetValue(out decimal result)
{
List<Tuple<decimal, bool>> list;
if (mWeighList.TryDequeue(out list))
{
var r = list.Where(x => x.Item2).Select(x => x.Item1).GroupBy(x => x);
var firstOrDefault = r.OrderByDescending(x => x.Count()).FirstOrDefault();
if (firstOrDefault != null)
{
result = firstOrDefault.Key;
return true;
}
result = 0;
return false;
}
result = 0;
return false;
}
static ConcurrentQueue<List<Tuple<decimal, bool>>> mWeighList = new ConcurrentQueue<List<Tuple<decimal, bool>>>();
static List<Tuple<decimal, bool>> _list = new List<Tuple<decimal, bool>>();
public static void Add(decimal value, bool isStatic)
{
if (value >= config.MinWeight && value <= config.MaxWeight)
{
_list.Add(new Tuple<decimal, bool>(value, isStatic));
}
else
{
if (_list.Count > 0)
{
mWeighList.Enqueue(_list);
_list = new List<Tuple<decimal, bool>>();
}
}
}
}
void DisableWeight()
{
_mainProcessIsRun = false;
lblChengZhong.Text = string.Format(format, 0);
format = "{0:0.00}";
Thread.Sleep(10);
if (_inQueryThread.IsAlive)
{
_inQueryThread.Abort();
}
if (weightPort.IsOpen)
weightPort.Close();
}
}
}

+ 144
- 0
WinFormControl/UWeightControl.resx View File

@ -0,0 +1,144 @@
<?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="weightSwitch.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="panel2.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="lblChengZhong.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<metadata name="settingBtn.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="settingBtn.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwCAIAAABhdOiYAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wwAADsMBx2+oZAAAAHNJREFUaEPt0AENACAMwDAkowVB14aDz0CTKui5b1gICoKCoCAoCAqCgqAgKAgK
goKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAg
KAgKgoKg1ZsPvpCB0hBohjQAAAAASUVORK5CYII=
</value>
</data>
<metadata name="$this.Locked" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

WinFormControl/ControlUtil.cs → WinFormControl/Utils/ControlUtil.cs View File


+ 69
- 0
WinFormControl/Utils/DataFormatBase.cs View File

@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WinFormControl
{
interface IDataFormat
{
char Beginchar { get; }
char Endchar { get; }
int DataLength { get; }
bool ParseAscii(string buf, out string weight, out bool isStatic);
bool ParseAscii(string buf, out string weight, out bool isStatic, out string subStr);
}
internal abstract class DataFormatBase : IDataFormat
{
public abstract int DataLength
{
get;
}
public abstract char Beginchar
{
get;
}
public abstract char Endchar
{
get;
}
public const short BUFSIZE = 36;
// 根据开始字符找出 一个完整的数据帧
public string FindDataFrame(string buf, int fSize)
{
var bufSize = buf.Length;
if (fSize > bufSize)
{
return string.Empty;
}
int index = buf.IndexOf(Beginchar); // 查找开始字符的索引
if (index < 0 || (index + fSize) > bufSize)
{
return string.Empty;
}
string data = buf.Substring(index, fSize);
// 检查结束字符
if (data[fSize - 1] != Endchar)
{
return string.Empty;
}
return data;
}
public abstract string ParseData(string buf, out bool isStatic);
public abstract bool ParseAscii(string buf, out string weight, out bool isStatic);
public abstract bool ParseAscii(string buf, out string weight, out bool isStatic, out string subStr);
}
}

+ 36
- 0
WinFormControl/Utils/IND560DataFormat.cs View File

@ -0,0 +1,36 @@
namespace WinFormControl
{
internal class IND560DataFormat : DataFormatBase {
public override int DataLength {
get { return 10; }
}
public override char Beginchar {
get { return (char)0x0A; }//这种数据没有固定的开始标志
}
public override char Endchar {
get { return (char)0x0D; }
}
public override string ParseData(string buf, out bool isStatic)
{
isStatic = false;
return string.Empty;
}
public override bool ParseAscii(string buf, out string weight, out bool isStatic) {
isStatic = true;
weight = buf.Replace("kg", "").Replace((char)0x0D, (char)0x20).Replace((char)0x0A, (char)0x20);
weight = weight.Trim();
return true;
}
public override bool ParseAscii(string buf, out string weight, out bool isStatic, out string subStr) {
weight = "";
isStatic = false;
subStr = "";
return false;
}
}
}

+ 33
- 0
WinFormControl/Utils/SoundPalyUtil.cs View File

@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Media;
using System.Text;
using System.Threading.Tasks;
namespace WinFormControl
{
public static class SoundPalyUtil
{
static SoundPlayer player = new SoundPlayer();
public static void PlaySound(SoundType type)
{
var fileName = Path.Combine(Directory.GetCurrentDirectory(), string.Format(@"Sounds\{0}.wav", type.ToString()));
if (!File.Exists(fileName))
return;
player.SoundLocation = fileName;
player.Load();
player.Play();
}
}
public enum SoundType
{
Click,
Di,
Error,
ShotSucc,
LongSucc,
}
}

+ 100
- 0
WinFormControl/Utils/Xk3124DataFormat.cs View File

@ -0,0 +1,100 @@
using System.Text;
namespace WinFormControl
{
internal class Xk3124DataFormat : DataFormatBase
{
public override int DataLength {
get { return 17; }
}
public override char Beginchar
{
get { return (char)0x02; }
}
public override char Endchar
{
get { return (char)0x0D; ; }
}
public override string ParseData(string buf, out bool isStatic) {
StringBuilder str = new StringBuilder();
char swa = buf[1]; // 状态字A
char swb = buf[2]; // 状态字B
int dotIndex = (swa & 0x07) - 2; // 小数点位置
bool isPositive = (((swb >> 1) & 0x01) == 0); // 符号:是否为正数
isStatic = (((swb >> 3) & 0x01) == 0);
char[] num = new char[6];
for (int i = 0; i < 6; i++) {
num[i] = buf[i + 4];
}
if (dotIndex < 0) { // 不考虑精确到十,百位
return str.ToString();
}
for (int i = 0; i < 6 - dotIndex; i++) {
str.Append(num[i]);
}
str.Append('.');
for (int i = 0; i < dotIndex; i++) {
str.Append(num[6 - dotIndex + i]);
}
// 去掉空格
string result = str.ToString().Trim();
// 取消前面多余的0
for (int i = 0; i < result.Length; i++) {
if (result[i] != '0') {
result = result.Substring(i, result.Length - i);
break;
}
}
if (result.IndexOf('.') == 0) {
result = result.Insert(0, "0");
}
if (result.IndexOf('.') == result.Length - 1) {
result = result.Remove(result.IndexOf('.'), 1);
}
if (!isPositive) { // 负数
result = result.Insert(0, "-");
}
return result;
}
public override bool ParseAscii(string buf, out string weight, out bool isStatic) {
isStatic = false;
weight = FindDataFrame(buf, DataLength );
if (string.IsNullOrEmpty(weight)) {
return false;
}
weight = ParseData(weight, out isStatic);
return true;
}
public override bool ParseAscii(string buf, out string weight, out bool isStatic, out string subStr) {
weight = "";
isStatic = false;
subStr = "";
return false;
}
}
//IND560单次读入
}

+ 107
- 0
WinFormControl/Utils/Xk3190A9DataFormat.cs View File

@ -0,0 +1,107 @@
namespace WinFormControl
{
internal class Xk3190A9DataFormat : DataFormatBase
{
public override int DataLength {
get { return 12; }
}
public override char Beginchar {
get { return (char)0x02; }
}
public override char Endchar {
get { return (char)0x03;}
}
public override string ParseData(string buf, out bool isStatic) {
string weight;
// 小数位数0-4
int dot = (short)(0x0F & buf[8]);
weight = buf.Substring(2, 6).Trim();
// insert dot
weight = InsertDot(weight, dot);
isStatic = true; // 默认 为 稳定
// buffer[1] 符号位
if (buf[1] == '-') {
weight = weight.Insert(0, "-");
}
return weight;
}
public override bool ParseAscii(string buf, out string weight, out bool isStatic) {
isStatic = false;
weight = FindDataFrame(buf, DataLength );
if (string.IsNullOrEmpty(weight)) {
return false;
}
weight = ParseData(weight, out isStatic);
return true;
}
private static string InsertDot(string weight, int dotBits) {
string str = weight.TrimStart(new[] {
'0'
});
str = str.Trim();
if (dotBits > 0) {
//str = str.Insert(str.Length - dotBits, ".");
if (string.IsNullOrEmpty(str)) {
str = "0";
str = str.Insert(str.Length, ".");
for (int i = 0; i < dotBits; i++) {
str = str.Insert(str.Length, "0");
}
} else
str = str.Insert(str.Length - dotBits, ".");
}
if (str.IndexOf(".") == 0) {
str = str.Insert(0, "0");
}
return str;
}
public override bool ParseAscii(string buf, out string weight, out bool isStatic, out string subStr) {
isStatic = false;
weight = FindDataFrame(buf, DataLength , out subStr);
if (string.IsNullOrEmpty(weight)) {
return false;
}
weight = ParseData(weight, out isStatic);
return true;
}
// 根据开始字符找出 一个完整的数据帧
public string FindDataFrame(string buf, int fSize , out string subStr) {
var bufSize = buf.Length;
subStr = "";
int index = buf.IndexOf(Beginchar); // 查找开始字符的索引
if (index < 0 || (index + fSize) > bufSize) {
return string.Empty;
}
string data = buf.Substring(index, fSize);
subStr = buf.Substring(index + fSize);
// 检查结束字符
if (data[fSize - 1] != Endchar) {
return string.Empty;
}
return data;
}
}
}

+ 102
- 0
WinFormControl/Utils/Xk3190D10DataFormat.cs View File

@ -0,0 +1,102 @@
namespace WinFormControl
{
internal class Xk3190D10DataFormat : DataFormatBase
{
public override int DataLength {
get { return 12; }
}
public override char Beginchar {
get { return (char)0x02; }
}
public override char Endchar {
get { return (char)0x0D; ; }
}
public override string ParseData(string buf, out bool isStatic) {
string weight;
// 小数位数0-4
int dot = (short)(0x0F & buf[8]);
weight = buf.Substring(2, 6).Trim();
// insert dot
weight = InsertDot(weight, dot);
isStatic = true; // 默认 为 稳定
// buffer[1] 符号位
if (buf[1] == '-') {
weight = weight.Insert(0, "-");
} else {
}
return weight;
}
public override bool ParseAscii(string buf, out string weight, out bool isStatic) {
isStatic = false;
weight = FindDataFrame(buf, DataLength);
if (string.IsNullOrEmpty(weight)) {
return false;
}
weight = ParseData(weight, out isStatic);
return true;
}
private static string InsertDot(string weight, int dotBits) {
string str = weight.TrimStart(new[] {
'0'
});
str = str.Trim();
if (dotBits > 0) {
//str = str.Insert(str.Length - dotBits, ".");
if (string.IsNullOrEmpty(str)) {
str = "0";
str = str.Insert(str.Length, ".");
for (int i = 0; i < dotBits; i++) {
str = str.Insert(str.Length, "0");
}
} else
str = str.Insert(str.Length - dotBits, ".");
}
if (str.IndexOf(".") == 0) {
str = str.Insert(0, "0");
}
return str;
}
public override bool ParseAscii(string buf, out string weight, out bool isStatic, out string subStr) {
isStatic = false;
weight = FindDataFrame(buf, DataLength );
subStr = "";
if (string.IsNullOrEmpty(weight)) {
return false;
}
weight = ParseData(weight, out isStatic);
return true;
}
#region 1.3 验证int奇数偶数
/// <summary>
/// 1.3 验证int奇数偶数
/// </summary>
/// <param name="num"></param>
/// <returns></returns>
public bool isJO(int num) {
int a = num % 2;
if (a == 0)
return true;
else
return false;
}
#endregion
}
}

+ 41
- 0
WinFormControl/Utils/XmlUtil.cs View File

@ -0,0 +1,41 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Serialization;
namespace WinFormControl
{
internal static class XmlUtil
{
static string currentPath = Directory.GetCurrentDirectory();
public static void SerializerObjToFile(object obj, string fileName)
{
fileName = Path.Combine(currentPath, fileName + ".xml");
var ser = new XmlSerializer(obj.GetType());
using (var stream = File.Open(fileName, FileMode.Create))
{
ser.Serialize(stream, obj);
}
}
public static T DeserializeFromFile<T>(string fileName)
where T : new()
{
fileName = Path.Combine(currentPath, fileName + ".xml");
if (!File.Exists(fileName))
{
return new T();
}
using (var reader = new StreamReader(fileName))
{
var xs = new XmlSerializer(typeof(T));
object obj = xs.Deserialize(reader);
reader.Close();
return (T)obj;
}
}
}
}

+ 39
- 0
WinFormControl/WeightContext.cs View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace WinFormControl
{
public class WeightConfig
{
public string WeightSet { get; set; }
public string ComSet { get; set; }
public int? RateSet { get; set; }
public int? BitSet { get; set; }
public string Format { get; set; }
public decimal? Discont { get; set; }
public int WeightType { get; set; }
public decimal MinWeight { get; set; }
public decimal MaxWeight { get; set; }
public static WeightConfig Init(string flag)
{
return XmlUtil.DeserializeFromFile<WeightConfig>(flag + "WeightConfig");
}
public void Save(string flag)
{
XmlUtil.SerializerObjToFile(this, flag + "WeightConfig");
}
}
}

+ 104
- 0
WinFormControl/WeightSettingFrom.cs View File

@ -0,0 +1,104 @@
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 WinFormControl
{
public partial class WeightSettingFrom : Form
{
List<string> weight = new List<string> { "IND560", "Xk3124", "Xk3190A9", "Xk3190D10", "IND231" };
List<string> com = new List<string> { "COM1", "COM2", "COM3", "COM4", "COM5" };
List<string> rate = new List<string> { "1200", "2400", "4800", "7200", "9600" };
List<string> bit = new List<string> { "5", "6", "7", "8" };
List<string> weightRead = new List<string> { "稳定读取", "连续发送" };
string _flag;
WeightConfig config;
public WeightSettingFrom(string flag)
{
this._flag = flag;
InitializeComponent();
weightSet.DataSource = weight;
comSet.DataSource = com;
rateSet.DataSource = rate;
bitSet.DataSource = bit;
weightReadType.DataSource = weightRead;
config = WeightConfig.Init(flag);
if (!string.IsNullOrEmpty(config.WeightSet))
weightSet.SelectedIndex = weight.IndexOf(config.WeightSet);
else
weightSet.SelectedIndex = 0;
if (!string.IsNullOrEmpty(config.ComSet))
comSet.SelectedIndex = com.IndexOf(config.ComSet);
else
comSet.SelectedIndex = 0;
if (config.RateSet.HasValue)
rateSet.SelectedIndex = rate.IndexOf(config.RateSet.ToString());
else
rateSet.SelectedIndex = 2;
if (config.BitSet.HasValue)
bitSet.SelectedIndex = bit.IndexOf(config.BitSet.ToString());
else
bitSet.SelectedIndex = 3;
if (string.IsNullOrEmpty(config.Format))
format.Text = "0.00";
else
format.Text = config.Format;
if (config.Discont == null)
discont.Text = "0.00";
else
discont.Text = config.Discont.ToString();
weightReadType.SelectedIndex = config.WeightType;
minInput.Text = config.MinWeight.ToString();
maxInput.Text = config.MaxWeight.ToString();
}
bool changed;
private void saveBtn_Click(object sender, EventArgs e)
{
config.WeightSet = weight[this.weightSet.SelectedIndex];
config.ComSet = com[this.comSet.SelectedIndex];
config.RateSet = int.Parse(rate[this.rateSet.SelectedIndex]);
config.BitSet = int.Parse(bit[this.bitSet.SelectedIndex]);
config.Format = format.Text;
config.WeightType = weightReadType.SelectedIndex;
if (config.WeightType == 1)
{
decimal min = 0;
decimal max = 0;
if (!decimal.TryParse(minInput.Text.Trim(), out min))
throw new Exception("连续发送时 必须输入有效区间");
if (!decimal.TryParse(maxInput.Text.Trim(), out max))
throw new Exception("连续发送时 必须输入有效区间");
config.MinWeight = min;
config.MaxWeight = max;
}
if (!string.IsNullOrEmpty(discont.Text))
{
decimal v;
if (decimal.TryParse(discont.Text, out v))
config.Discont = v;
else
throw new Exception("扣重格式输入不正确");
}
else
config.Discont = 0;
config.Save(_flag);
changed = true;
UMessageBox.Show("保存成功!");
}
private void closeBtn_Click(object sender, EventArgs e)
{
if (changed)
DialogResult = DialogResult.OK;
Close();
}
}
}

+ 310
- 0
WinFormControl/WeightSettingFrom.designer.cs View File

@ -0,0 +1,310 @@
namespace WinFormControl
{
partial class WeightSettingFrom
{
/// <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()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WeightSettingFrom));
this.maxInput = new WinFormControl.UTextBoxWithPad();
this.minInput = new WinFormControl.UTextBoxWithPad();
this.label8 = new WinFormControl.ULabel();
this.weightReadType = new System.Windows.Forms.ComboBox();
this.label7 = new WinFormControl.ULabel();
this.discont = new WinFormControl.UTextBoxWithPad();
this.format = new WinFormControl.UTextBoxWithPad();
this.label6 = new WinFormControl.ULabel();
this.label5 = new WinFormControl.ULabel();
this.closeBtn = new WinFormControl.UButton();
this.saveBtn = new WinFormControl.UButton();
this.bitSet = new System.Windows.Forms.ComboBox();
this.rateSet = new System.Windows.Forms.ComboBox();
this.comSet = new System.Windows.Forms.ComboBox();
this.weightSet = new System.Windows.Forms.ComboBox();
this.label4 = new WinFormControl.ULabel();
this.label3 = new WinFormControl.ULabel();
this.label2 = new WinFormControl.ULabel();
this.label1 = new WinFormControl.ULabel();
this.SuspendLayout();
//
// maxInput
//
this.maxInput.Font = new System.Drawing.Font("宋体", 12F);
this.maxInput.Location = new System.Drawing.Point(262, 370);
this.maxInput.Name = "maxInput";
this.maxInput.Size = new System.Drawing.Size(55, 26);
this.maxInput.TabIndex = 67;
this.maxInput.Type = WinFormControl.UTextBoxWithPad.TextBoxType.Number;
//
// minInput
//
this.minInput.Font = new System.Drawing.Font("宋体", 12F);
this.minInput.Location = new System.Drawing.Point(196, 370);
this.minInput.Name = "minInput";
this.minInput.Size = new System.Drawing.Size(55, 26);
this.minInput.TabIndex = 66;
this.minInput.Type = WinFormControl.UTextBoxWithPad.TextBoxType.Number;
//
// label8
//
this.label8.AutoSize = true;
this.label8.BackColor = System.Drawing.Color.Transparent;
this.label8.Font = new System.Drawing.Font("宋体", 15F);
this.label8.Location = new System.Drawing.Point(74, 370);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(109, 20);
this.label8.TabIndex = 65;
this.label8.Text = "有效区间:";
//
// weightReadType
//
this.weightReadType.Font = new System.Drawing.Font("宋体", 15F);
this.weightReadType.FormattingEnabled = true;
this.weightReadType.Location = new System.Drawing.Point(196, 323);
this.weightReadType.Name = "weightReadType";
this.weightReadType.Size = new System.Drawing.Size(121, 28);
this.weightReadType.TabIndex = 64;
//
// label7
//
this.label7.AutoSize = true;
this.label7.BackColor = System.Drawing.Color.Transparent;
this.label7.Font = new System.Drawing.Font("宋体", 15F);
this.label7.Location = new System.Drawing.Point(74, 326);
this.label7.Name = "label7";
this.label7.Size = new System.Drawing.Size(109, 20);
this.label7.TabIndex = 63;
this.label7.Text = "读取方式:";
//
// discont
//
this.discont.Font = new System.Drawing.Font("宋体", 14F);
this.discont.Location = new System.Drawing.Point(196, 274);
this.discont.Name = "discont";
this.discont.Size = new System.Drawing.Size(121, 29);
this.discont.TabIndex = 62;
this.discont.Type = WinFormControl.UTextBoxWithPad.TextBoxType.Number;
//
// format
//
this.format.Font = new System.Drawing.Font("宋体", 14F);
this.format.Location = new System.Drawing.Point(196, 226);
this.format.Name = "format";
this.format.Size = new System.Drawing.Size(121, 29);
this.format.TabIndex = 61;
this.format.Type = WinFormControl.UTextBoxWithPad.TextBoxType.Number;
//
// label6
//
this.label6.AutoSize = true;
this.label6.BackColor = System.Drawing.Color.Transparent;
this.label6.Font = new System.Drawing.Font("宋体", 15F);
this.label6.Location = new System.Drawing.Point(74, 283);
this.label6.Name = "label6";
this.label6.Size = new System.Drawing.Size(69, 20);
this.label6.TabIndex = 60;
this.label6.Text = "扣重:";
//
// label5
//
this.label5.AutoSize = true;
this.label5.BackColor = System.Drawing.Color.Transparent;
this.label5.Font = new System.Drawing.Font("宋体", 15F);
this.label5.Location = new System.Drawing.Point(74, 232);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(109, 20);
this.label5.TabIndex = 59;
this.label5.Text = "显示格式:";
//
// closeBtn
//
this.closeBtn.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("closeBtn.BackgroundImage")));
this.closeBtn.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(155)))), ((int)(((byte)(214)))));
this.closeBtn.FlatAppearance.BorderSize = 0;
this.closeBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.closeBtn.Font = new System.Drawing.Font("宋体", 15F);
this.closeBtn.ForeColor = System.Drawing.Color.Black;
this.closeBtn.Location = new System.Drawing.Point(218, 416);
this.closeBtn.Name = "closeBtn";
this.closeBtn.Size = new System.Drawing.Size(90, 34);
this.closeBtn.TabIndex = 58;
this.closeBtn.Text = "关闭";
this.closeBtn.UseVisualStyleBackColor = true;
this.closeBtn.Click += new System.EventHandler(this.closeBtn_Click);
//
// saveBtn
//
this.saveBtn.BackgroundImage = ((System.Drawing.Image)(resources.GetObject("saveBtn.BackgroundImage")));
this.saveBtn.FlatAppearance.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(45)))), ((int)(((byte)(155)))), ((int)(((byte)(214)))));
this.saveBtn.FlatAppearance.BorderSize = 0;
this.saveBtn.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.saveBtn.Font = new System.Drawing.Font("宋体", 15F);
this.saveBtn.ForeColor = System.Drawing.Color.Black;
this.saveBtn.Location = new System.Drawing.Point(105, 416);
this.saveBtn.Name = "saveBtn";
this.saveBtn.Size = new System.Drawing.Size(90, 34);
this.saveBtn.TabIndex = 57;
this.saveBtn.Text = "保存";
this.saveBtn.UseVisualStyleBackColor = true;
this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click);
//
// bitSet
//
this.bitSet.Font = new System.Drawing.Font("宋体", 15F);
this.bitSet.FormattingEnabled = true;
this.bitSet.Location = new System.Drawing.Point(196, 179);
this.bitSet.Name = "bitSet";
this.bitSet.Size = new System.Drawing.Size(121, 28);
this.bitSet.TabIndex = 54;
//
// rateSet
//
this.rateSet.Font = new System.Drawing.Font("宋体", 15F);
this.rateSet.FormattingEnabled = true;
this.rateSet.Location = new System.Drawing.Point(196, 127);
this.rateSet.Name = "rateSet";
this.rateSet.Size = new System.Drawing.Size(121, 28);
this.rateSet.TabIndex = 55;
//
// comSet
//
this.comSet.Font = new System.Drawing.Font("宋体", 15F);
this.comSet.FormattingEnabled = true;
this.comSet.Location = new System.Drawing.Point(196, 77);
this.comSet.Name = "comSet";
this.comSet.Size = new System.Drawing.Size(121, 28);
this.comSet.TabIndex = 56;
//
// weightSet
//
this.weightSet.Font = new System.Drawing.Font("宋体", 15F);
this.weightSet.FormattingEnabled = true;
this.weightSet.Location = new System.Drawing.Point(196, 29);
this.weightSet.Name = "weightSet";
this.weightSet.Size = new System.Drawing.Size(121, 28);
this.weightSet.TabIndex = 53;
//
// label4
//
this.label4.AutoSize = true;
this.label4.BackColor = System.Drawing.Color.Transparent;
this.label4.Font = new System.Drawing.Font("宋体", 15F);
this.label4.Location = new System.Drawing.Point(74, 182);
this.label4.Name = "label4";
this.label4.Size = new System.Drawing.Size(89, 20);
this.label4.TabIndex = 52;
this.label4.Text = "数据位:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.BackColor = System.Drawing.Color.Transparent;
this.label3.Font = new System.Drawing.Font("宋体", 15F);
this.label3.Location = new System.Drawing.Point(74, 130);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(89, 20);
this.label3.TabIndex = 51;
this.label3.Text = "波特率:";
//
// label2
//
this.label2.AutoSize = true;
this.label2.BackColor = System.Drawing.Color.Transparent;
this.label2.Font = new System.Drawing.Font("宋体", 15F);
this.label2.Location = new System.Drawing.Point(74, 80);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(89, 20);
this.label2.TabIndex = 50;
this.label2.Text = "端口号:";
//
// label1
//
this.label1.AutoSize = true;
this.label1.BackColor = System.Drawing.Color.Transparent;
this.label1.Font = new System.Drawing.Font("宋体", 15F);
this.label1.Location = new System.Drawing.Point(74, 32);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(89, 20);
this.label1.TabIndex = 49;
this.label1.Text = "称型号:";
//
// WeightSettingFrom
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(391, 481);
this.ControlBox = false;
this.Controls.Add(this.maxInput);
this.Controls.Add(this.minInput);
this.Controls.Add(this.label8);
this.Controls.Add(this.weightReadType);
this.Controls.Add(this.label7);
this.Controls.Add(this.discont);
this.Controls.Add(this.format);
this.Controls.Add(this.label6);
this.Controls.Add(this.label5);
this.Controls.Add(this.closeBtn);
this.Controls.Add(this.saveBtn);
this.Controls.Add(this.bitSet);
this.Controls.Add(this.rateSet);
this.Controls.Add(this.comSet);
this.Controls.Add(this.weightSet);
this.Controls.Add(this.label4);
this.Controls.Add(this.label3);
this.Controls.Add(this.label2);
this.Controls.Add(this.label1);
this.Name = "WeightSettingFrom";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "称设置";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private UTextBoxWithPad maxInput;
private UTextBoxWithPad minInput;
private ULabel label8;
private System.Windows.Forms.ComboBox weightReadType;
private ULabel label7;
private UTextBoxWithPad discont;
private UTextBoxWithPad format;
private ULabel label6;
private ULabel label5;
private UButton closeBtn;
private UButton saveBtn;
private System.Windows.Forms.ComboBox bitSet;
private System.Windows.Forms.ComboBox rateSet;
private System.Windows.Forms.ComboBox comSet;
private System.Windows.Forms.ComboBox weightSet;
private ULabel label4;
private ULabel label3;
private ULabel label2;
private ULabel label1;
}
}

+ 137
- 0
WinFormControl/WeightSettingFrom.resx View File

@ -0,0 +1,137 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="closeBtn.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwCAIAAABhdOiYAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wwAADsMBx2+oZAAAAHNJREFUaEPt0AENACAMwDAkowVB14aDz0CTKui5b1gICoKCoCAoCAqCgqAgKAgK
goKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAg
KAgKgoKg1ZsPvpCB0hBohjQAAAAASUVORK5CYII=
</value>
</data>
<data name="saveBtn.BackgroundImage" type="System.Drawing.Bitmap, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>
iVBORw0KGgoAAAANSUhEUgAAAGAAAAAwCAIAAABhdOiYAAAABGdBTUEAALGPC/xhBQAAAAlwSFlzAAAO
wwAADsMBx2+oZAAAAHNJREFUaEPt0AENACAMwDAkowVB14aDz0CTKui5b1gICoKCoCAoCAqCgqAgKAgK
goKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAgKAgKgoKgICgICoKCoCAoCAqCgqAg
KAgKgoKg1ZsPvpCB0hBohjQAAAAASUVORK5CYII=
</value>
</data>
</root>

+ 89
- 18
WinFormControl/WinFormControl.csproj View File

@ -4,7 +4,7 @@
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{45A6C56B-C815-4AEA-B0C4-68C122FD3139}</ProjectGuid>
<ProjectGuid>{5F1AC749-68DB-43E2-8895-886ECC04D7DA}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>WinFormControl</RootNamespace>
@ -34,72 +34,143 @@
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Design" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="ControlUtil.cs" />
<Compile Include="NumberPad.xaml.cs">
<DependentUpon>NumberPad.xaml</DependentUpon>
</Compile>
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="NetStateWatch.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="NetStateWatch.Designer.cs">
<DependentUpon>NetStateWatch.cs</DependentUpon>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="UScanPanel.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UScanPanel.Designer.cs">
<DependentUpon>UScanPanel.cs</DependentUpon>
</Compile>
<Compile Include="Utils\ControlUtil.cs" />
<Compile Include="NumberPad.xaml.cs">
<DependentUpon>NumberPad.xaml</DependentUpon>
</Compile>
<Compile Include="UButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UDataGridView.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="ULabel.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="UMessageBox.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="UMessageBox.Designer.cs">
<Compile Include="UMessageBox.designer.cs">
<DependentUpon>UMessageBox.cs</DependentUpon>
</Compile>
<Compile Include="UTextBoxWithPad.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Utils\DataFormatBase.cs" />
<Compile Include="Utils\IND560DataFormat.cs" />
<Compile Include="Utils\SoundPalyUtil.cs" />
<Compile Include="Utils\Xk3124DataFormat.cs" />
<Compile Include="Utils\Xk3190A9DataFormat.cs" />
<Compile Include="Utils\Xk3190D10DataFormat.cs" />
<Compile Include="UWeightControl.cs">
<SubType>UserControl</SubType>
</Compile>
<Compile Include="UWeightControl.Designer.cs">
<DependentUpon>UWeightControl.cs</DependentUpon>
</Compile>
<Compile Include="VirtualKeyPad.xaml.cs">
<DependentUpon>VirtualKeyPad.xaml</DependentUpon>
</Compile>
<Compile Include="WeightContext.cs" />
<Compile Include="WeightSettingFrom.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="WeightSettingFrom.designer.cs">
<DependentUpon>WeightSettingFrom.cs</DependentUpon>
</Compile>
<Compile Include="Utils\XmlUtil.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\onclickBtn.png" />
<EmbeddedResource Include="NetStateWatch.resx">
<DependentUpon>NetStateWatch.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="UMessageBox.resx">
<DependentUpon>UMessageBox.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UScanPanel.resx">
<DependentUpon>UScanPanel.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="UWeightControl.resx">
<DependentUpon>UWeightControl.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="WeightSettingFrom.resx">
<DependentUpon>WeightSettingFrom.cs</DependentUpon>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<None Include="Resources\greenCircle.png" />
</ItemGroup>
<ItemGroup>
<Page Include="NumberPad.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="VirtualKeyPad.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="UMessageBox.resx">
<DependentUpon>UMessageBox.cs</DependentUpon>
</EmbeddedResource>
<None Include="Resources\onclickBtn.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\simpleBtn.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\redCircle.png" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\disable.png" />
</ItemGroup>
<ItemGroup>
<None Include="Sounds\click.wav" />
</ItemGroup>
<ItemGroup>
<None Include="Sounds\di.wav" />
</ItemGroup>
<ItemGroup>
<None Include="Sounds\error.wav" />
</ItemGroup>
<ItemGroup>
<None Include="Sounds\longSucc.wav" />
</ItemGroup>
<ItemGroup>
<None Include="Sounds\shotSucc.wav" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.


Loading…
Cancel
Save