合并修改
This commit is contained in:
commit
efcf79ea0d
@ -142,4 +142,7 @@
|
|||||||
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
<value>17, 17</value>
|
<value>17, 17</value>
|
||||||
</metadata>
|
</metadata>
|
||||||
|
<metadata name="$this.TrayHeight" type="System.Int32, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||||
|
<value>25</value>
|
||||||
|
</metadata>
|
||||||
</root>
|
</root>
|
160
CanFly/UI/SizePanel/SizeBaseGuideControl.cs
Normal file
160
CanFly/UI/SizePanel/SizeBaseGuideControl.cs
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
using CanFly.Canvas.Shape;
|
||||||
|
using CanFly.Canvas.UI;
|
||||||
|
using CanFly.Helper;
|
||||||
|
using DH.Commons.Base;
|
||||||
|
using HalconDotNet;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace CanFly.UI.SizePanel
|
||||||
|
{
|
||||||
|
|
||||||
|
public class SizeBaseGuideControl : UserControl
|
||||||
|
{
|
||||||
|
public Action? OnControlCloseEvent;
|
||||||
|
|
||||||
|
public event Action<string,string> OnDataPassed;
|
||||||
|
|
||||||
|
|
||||||
|
private string _currentImageFile;
|
||||||
|
|
||||||
|
public string CurrentImageFile;
|
||||||
|
|
||||||
|
public CameraBase cameraBase;
|
||||||
|
|
||||||
|
protected string _hScriptsDir = Path.Combine(Environment.CurrentDirectory, "hscripts");
|
||||||
|
|
||||||
|
protected HObject? hImage = null;
|
||||||
|
|
||||||
|
protected FlyCanvas _canvas;
|
||||||
|
|
||||||
|
private HDevEngineTool? tool = null;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void DataToTriggerEvent(string input,string output)
|
||||||
|
{
|
||||||
|
|
||||||
|
OnDataPassed?.Invoke(input, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void UpdateShape(FlyShape shape)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual string GetScriptFileName()
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 执行Halcon脚本
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="inputImg">输入图像</param>
|
||||||
|
/// <param name="inputDic">输入参数</param>
|
||||||
|
/// <param name="outputParamKeys">输出参数</param>
|
||||||
|
protected void ExecuteHScript(
|
||||||
|
Dictionary<string, HObject> inputImg,
|
||||||
|
Dictionary<string, HTuple> inputDic,
|
||||||
|
List<string> outputParamKeys,
|
||||||
|
Action<Exception>? exceptionHandler = null)
|
||||||
|
{
|
||||||
|
|
||||||
|
string filePath = Path.Combine(_hScriptsDir, GetScriptFileName());
|
||||||
|
if (!File.Exists(filePath))
|
||||||
|
{
|
||||||
|
MessageBox.Show($"文件 {filePath} 不存在");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (tool == null)
|
||||||
|
{
|
||||||
|
tool = new HDevEngineTool(_hScriptsDir);
|
||||||
|
tool.LoadProcedure(Path.GetFileNameWithoutExtension(GetScriptFileName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//tool.InputImageDic["INPUT_Image"] = hImage;
|
||||||
|
//tool.InputTupleDic["XCenter"] = _x;
|
||||||
|
//tool.InputTupleDic["YCenter"] = _y;
|
||||||
|
//tool.InputTupleDic["Radius"] = _r;
|
||||||
|
|
||||||
|
tool.InputImageDic = inputImg;
|
||||||
|
tool.InputTupleDic = inputDic;
|
||||||
|
|
||||||
|
|
||||||
|
Dictionary<string, HTuple> outputParams = new Dictionary<string, HTuple>();
|
||||||
|
|
||||||
|
|
||||||
|
if (!tool.RunProcedure(out string error, out int timeElasped))
|
||||||
|
{
|
||||||
|
OnExecuteHScriptResult(false, outputParams, timeElasped);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 0; i < outputParamKeys.Count; i++)
|
||||||
|
{
|
||||||
|
string k = outputParamKeys[i];
|
||||||
|
outputParams[k] = tool.GetResultTuple(k);
|
||||||
|
}
|
||||||
|
|
||||||
|
OnExecuteHScriptResult(true, outputParams, timeElasped);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
exceptionHandler?.Invoke(ex);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
hImage?.Dispose();
|
||||||
|
hImage = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Halcon脚本执行结果回调函数,重写该方法以自行处理算法执行结果
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="success">算法执行是否成功</param>
|
||||||
|
/// <param name="resultDic">算法输出结果</param>
|
||||||
|
/// <param name="timeElasped">算法耗时,单位:ms</param>
|
||||||
|
protected virtual void OnExecuteHScriptResult(bool success, Dictionary<string, HTuple> resultDic, int timeElasped)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void OpenImageFile(Action<Bitmap> callback)
|
||||||
|
{
|
||||||
|
OpenFileDialog ofd = new OpenFileDialog();
|
||||||
|
ofd.Filter = "图像文件|*.jpg;*.jpeg;*.png";
|
||||||
|
ofd.Multiselect = false;
|
||||||
|
if (ofd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
CurrentImageFile = ofd.FileName;
|
||||||
|
Bitmap bitmap = (Bitmap)Image.FromFile(CurrentImageFile);
|
||||||
|
callback?.Invoke(bitmap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void OnControlClose()
|
||||||
|
{
|
||||||
|
OnControlCloseEvent?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
CanFly/UI/SizePanel/SizeBaseGuideControl.resx
Normal file
120
CanFly/UI/SizePanel/SizeBaseGuideControl.resx
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
</root>
|
77
CanFly/UI/SizePanel/SizeCtrlTitleBar.Designer.cs
generated
Normal file
77
CanFly/UI/SizePanel/SizeCtrlTitleBar.Designer.cs
generated
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
namespace CanFly.UI.SizePanel
|
||||||
|
{
|
||||||
|
partial class SizeCtrlTitleBar
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
btnClose = new PictureBox();
|
||||||
|
j = new Label();
|
||||||
|
((System.ComponentModel.ISupportInitialize)btnClose).BeginInit();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// btnClose
|
||||||
|
//
|
||||||
|
btnClose.Dock = DockStyle.Right;
|
||||||
|
btnClose.Image = XKRS.CanFly.Properties.Resources.Close;
|
||||||
|
btnClose.Location = new Point(516, 3);
|
||||||
|
btnClose.Name = "btnClose";
|
||||||
|
btnClose.Size = new Size(30, 30);
|
||||||
|
btnClose.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||||
|
btnClose.TabIndex = 1;
|
||||||
|
btnClose.TabStop = false;
|
||||||
|
btnClose.Click += btnClose_Click;
|
||||||
|
//
|
||||||
|
// j
|
||||||
|
//
|
||||||
|
j.Dock = DockStyle.Fill;
|
||||||
|
j.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Bold);
|
||||||
|
j.Location = new Point(3, 3);
|
||||||
|
j.Name = "j";
|
||||||
|
j.Size = new Size(513, 30);
|
||||||
|
j.TabIndex = 2;
|
||||||
|
j.Text = "标题";
|
||||||
|
j.TextAlign = ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// SizeCtrlTitleBar
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
Controls.Add(j);
|
||||||
|
Controls.Add(btnClose);
|
||||||
|
MinimumSize = new Size(0, 36);
|
||||||
|
Name = "SizeCtrlTitleBar";
|
||||||
|
Padding = new Padding(3);
|
||||||
|
Size = new Size(549, 36);
|
||||||
|
((System.ComponentModel.ISupportInitialize)btnClose).EndInit();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private PictureBox btnClose;
|
||||||
|
private Label j;
|
||||||
|
}
|
||||||
|
}
|
38
CanFly/UI/SizePanel/SizeCtrlTitleBar.cs
Normal file
38
CanFly/UI/SizePanel/SizeCtrlTitleBar.cs
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
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 CanFly.UI.SizePanel
|
||||||
|
{
|
||||||
|
public partial class SizeCtrlTitleBar : UserControl
|
||||||
|
{
|
||||||
|
public event Action? OnCloseClicked;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
[DisplayName("Title")]
|
||||||
|
public string Title
|
||||||
|
{
|
||||||
|
get { return this.j.Text; }
|
||||||
|
set { this.j.Text = value; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SizeCtrlTitleBar()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.Dock = DockStyle.Top;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnClose_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OnCloseClicked?.Invoke();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
364
CanFly/UI/SizePanel/SizeGuideCircleCtrl.Designer.cs
generated
Normal file
364
CanFly/UI/SizePanel/SizeGuideCircleCtrl.Designer.cs
generated
Normal file
@ -0,0 +1,364 @@
|
|||||||
|
namespace CanFly.UI.SizePanel
|
||||||
|
{
|
||||||
|
partial class SizeGuideCircleCtrl
|
||||||
|
{
|
||||||
|
/// <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(SizeGuideCircleCtrl));
|
||||||
|
splitContainer = new SplitContainer();
|
||||||
|
panel1 = new Panel();
|
||||||
|
canvas = new Canvas.UI.FlyCanvas();
|
||||||
|
statusStrip1 = new StatusStrip();
|
||||||
|
lblStatus = new ToolStripStatusLabel();
|
||||||
|
btnClose = new PictureBox();
|
||||||
|
label4 = new Label();
|
||||||
|
btnExecute = new Button();
|
||||||
|
lblElapsed = new Label();
|
||||||
|
ctrlTitleBar = new SizeCtrlTitleBar();
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
label1 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
label3 = new Label();
|
||||||
|
tbR = new TextBox();
|
||||||
|
tbY = new TextBox();
|
||||||
|
tbX = new TextBox();
|
||||||
|
btnLoadImage = new Button();
|
||||||
|
btnCreateCircle = new Button();
|
||||||
|
btnSave = new Button();
|
||||||
|
label6 = new Label();
|
||||||
|
lblResult = new Label();
|
||||||
|
panelGuide = new Panel();
|
||||||
|
((System.ComponentModel.ISupportInitialize)splitContainer).BeginInit();
|
||||||
|
splitContainer.Panel1.SuspendLayout();
|
||||||
|
splitContainer.Panel2.SuspendLayout();
|
||||||
|
splitContainer.SuspendLayout();
|
||||||
|
panel1.SuspendLayout();
|
||||||
|
statusStrip1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)btnClose).BeginInit();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
panelGuide.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// splitContainer
|
||||||
|
//
|
||||||
|
splitContainer.Dock = DockStyle.Fill;
|
||||||
|
splitContainer.Location = new Point(0, 0);
|
||||||
|
splitContainer.Name = "splitContainer";
|
||||||
|
//
|
||||||
|
// splitContainer.Panel1
|
||||||
|
//
|
||||||
|
splitContainer.Panel1.Controls.Add(panelGuide);
|
||||||
|
splitContainer.Panel1MinSize = 150;
|
||||||
|
//
|
||||||
|
// splitContainer.Panel2
|
||||||
|
//
|
||||||
|
splitContainer.Panel2.Controls.Add(panel1);
|
||||||
|
splitContainer.Size = new Size(1280, 640);
|
||||||
|
splitContainer.SplitterDistance = 200;
|
||||||
|
splitContainer.TabIndex = 12;
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
panel1.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
panel1.Controls.Add(canvas);
|
||||||
|
panel1.Controls.Add(statusStrip1);
|
||||||
|
panel1.Dock = DockStyle.Fill;
|
||||||
|
panel1.Location = new Point(0, 0);
|
||||||
|
panel1.Name = "panel1";
|
||||||
|
panel1.Size = new Size(1076, 640);
|
||||||
|
panel1.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// canvas
|
||||||
|
//
|
||||||
|
canvas.AllowMultiSelect = false;
|
||||||
|
canvas.CreateMode = Canvas.Shape.ShapeTypeEnum.Polygon;
|
||||||
|
canvas.Dock = DockStyle.Fill;
|
||||||
|
canvas.Enabled = false;
|
||||||
|
canvas.FillDrawing = false;
|
||||||
|
canvas.Location = new Point(0, 0);
|
||||||
|
canvas.Margin = new Padding(2);
|
||||||
|
canvas.Name = "canvas";
|
||||||
|
canvas.OutsideShapes = (List<Canvas.Shape.FlyShape>)resources.GetObject("canvas.OutsideShapes");
|
||||||
|
canvas.Scale = 1F;
|
||||||
|
canvas.Shapes = (List<Canvas.Shape.FlyShape>)resources.GetObject("canvas.Shapes");
|
||||||
|
canvas.Size = new Size(1074, 616);
|
||||||
|
canvas.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// statusStrip1
|
||||||
|
//
|
||||||
|
statusStrip1.Items.AddRange(new ToolStripItem[] { lblStatus });
|
||||||
|
statusStrip1.Location = new Point(0, 616);
|
||||||
|
statusStrip1.Name = "statusStrip1";
|
||||||
|
statusStrip1.Size = new Size(1074, 22);
|
||||||
|
statusStrip1.TabIndex = 1;
|
||||||
|
statusStrip1.Text = "statusStrip1";
|
||||||
|
//
|
||||||
|
// lblStatus
|
||||||
|
//
|
||||||
|
lblStatus.Name = "lblStatus";
|
||||||
|
lblStatus.Size = new Size(44, 17);
|
||||||
|
lblStatus.Text = " ";
|
||||||
|
//
|
||||||
|
// btnClose
|
||||||
|
//
|
||||||
|
btnClose.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||||
|
btnClose.Image = XKRS.CanFly.Properties.Resources.Close;
|
||||||
|
btnClose.InitialImage = XKRS.CanFly.Properties.Resources.Close;
|
||||||
|
btnClose.Location = new Point(1102, 3);
|
||||||
|
btnClose.Name = "btnClose";
|
||||||
|
btnClose.Size = new Size(33, 33);
|
||||||
|
btnClose.SizeMode = PictureBoxSizeMode.StretchImage;
|
||||||
|
btnClose.TabIndex = 5;
|
||||||
|
btnClose.TabStop = false;
|
||||||
|
btnClose.Click += btnClose_Click;
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(6, 307);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(44, 17);
|
||||||
|
label4.TabIndex = 3;
|
||||||
|
label4.Text = "耗时:";
|
||||||
|
//
|
||||||
|
// btnExecute
|
||||||
|
//
|
||||||
|
btnExecute.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnExecute.Location = new Point(6, 272);
|
||||||
|
btnExecute.Name = "btnExecute";
|
||||||
|
btnExecute.Size = new Size(186, 32);
|
||||||
|
btnExecute.TabIndex = 2;
|
||||||
|
btnExecute.Text = "执行";
|
||||||
|
btnExecute.UseVisualStyleBackColor = true;
|
||||||
|
btnExecute.Click += btnExecute_Click;
|
||||||
|
//
|
||||||
|
// lblElapsed
|
||||||
|
//
|
||||||
|
lblElapsed.AutoSize = true;
|
||||||
|
lblElapsed.Location = new Point(56, 307);
|
||||||
|
lblElapsed.Name = "lblElapsed";
|
||||||
|
lblElapsed.Size = new Size(32, 17);
|
||||||
|
lblElapsed.TabIndex = 4;
|
||||||
|
lblElapsed.Text = "0ms";
|
||||||
|
//
|
||||||
|
// ctrlTitleBar
|
||||||
|
//
|
||||||
|
ctrlTitleBar.Dock = DockStyle.Top;
|
||||||
|
ctrlTitleBar.Location = new Point(0, 0);
|
||||||
|
ctrlTitleBar.MinimumSize = new Size(0, 36);
|
||||||
|
ctrlTitleBar.Name = "ctrlTitleBar";
|
||||||
|
ctrlTitleBar.Padding = new Padding(3);
|
||||||
|
ctrlTitleBar.Size = new Size(198, 36);
|
||||||
|
ctrlTitleBar.TabIndex = 11;
|
||||||
|
ctrlTitleBar.Title = "圆形测量";
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(tbX);
|
||||||
|
groupBox1.Controls.Add(tbY);
|
||||||
|
groupBox1.Controls.Add(tbR);
|
||||||
|
groupBox1.Controls.Add(label3);
|
||||||
|
groupBox1.Controls.Add(label2);
|
||||||
|
groupBox1.Controls.Add(label1);
|
||||||
|
groupBox1.Dock = DockStyle.Top;
|
||||||
|
groupBox1.Location = new Point(0, 36);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Size = new Size(198, 116);
|
||||||
|
groupBox1.TabIndex = 12;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "圆参数";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(6, 25);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(19, 17);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "X:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(6, 54);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(18, 17);
|
||||||
|
label2.TabIndex = 1;
|
||||||
|
label2.Text = "Y:";
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(3, 83);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(44, 17);
|
||||||
|
label3.TabIndex = 2;
|
||||||
|
label3.Text = "半径:";
|
||||||
|
//
|
||||||
|
// tbR
|
||||||
|
//
|
||||||
|
tbR.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbR.Location = new Point(56, 80);
|
||||||
|
tbR.Name = "tbR";
|
||||||
|
tbR.Size = new Size(136, 23);
|
||||||
|
tbR.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// tbY
|
||||||
|
//
|
||||||
|
tbY.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbY.Location = new Point(56, 51);
|
||||||
|
tbY.Name = "tbY";
|
||||||
|
tbY.Size = new Size(136, 23);
|
||||||
|
tbY.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// tbX
|
||||||
|
//
|
||||||
|
tbX.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbX.Location = new Point(56, 22);
|
||||||
|
tbX.Name = "tbX";
|
||||||
|
tbX.Size = new Size(136, 23);
|
||||||
|
tbX.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// btnLoadImage
|
||||||
|
//
|
||||||
|
btnLoadImage.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnLoadImage.Location = new Point(6, 158);
|
||||||
|
btnLoadImage.Name = "btnLoadImage";
|
||||||
|
btnLoadImage.Size = new Size(186, 32);
|
||||||
|
btnLoadImage.TabIndex = 13;
|
||||||
|
btnLoadImage.Text = "打开图片";
|
||||||
|
btnLoadImage.UseVisualStyleBackColor = true;
|
||||||
|
btnLoadImage.Click += btnLoadImage_Click;
|
||||||
|
//
|
||||||
|
// btnCreateCircle
|
||||||
|
//
|
||||||
|
btnCreateCircle.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnCreateCircle.Location = new Point(6, 196);
|
||||||
|
btnCreateCircle.Name = "btnCreateCircle";
|
||||||
|
btnCreateCircle.Size = new Size(186, 32);
|
||||||
|
btnCreateCircle.TabIndex = 14;
|
||||||
|
btnCreateCircle.Text = "创建圆形";
|
||||||
|
btnCreateCircle.UseVisualStyleBackColor = true;
|
||||||
|
btnCreateCircle.Click += btnCreateCircle_Click;
|
||||||
|
//
|
||||||
|
// btnSave
|
||||||
|
//
|
||||||
|
btnSave.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnSave.Location = new Point(9, 397);
|
||||||
|
btnSave.Name = "btnSave";
|
||||||
|
btnSave.Size = new Size(186, 32);
|
||||||
|
btnSave.TabIndex = 15;
|
||||||
|
btnSave.Text = "保存数据";
|
||||||
|
btnSave.UseVisualStyleBackColor = true;
|
||||||
|
btnSave.Click += btnSave_Click;
|
||||||
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
label6.AutoSize = true;
|
||||||
|
label6.Location = new Point(6, 338);
|
||||||
|
label6.Name = "label6";
|
||||||
|
label6.Size = new Size(44, 17);
|
||||||
|
label6.TabIndex = 16;
|
||||||
|
label6.Text = "结果:";
|
||||||
|
//
|
||||||
|
// lblResult
|
||||||
|
//
|
||||||
|
lblResult.AutoSize = true;
|
||||||
|
lblResult.Location = new Point(56, 338);
|
||||||
|
lblResult.Name = "lblResult";
|
||||||
|
lblResult.Size = new Size(20, 17);
|
||||||
|
lblResult.TabIndex = 17;
|
||||||
|
lblResult.Text = "无";
|
||||||
|
//
|
||||||
|
// panelGuide
|
||||||
|
//
|
||||||
|
panelGuide.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
panelGuide.Controls.Add(lblResult);
|
||||||
|
panelGuide.Controls.Add(label6);
|
||||||
|
panelGuide.Controls.Add(btnSave);
|
||||||
|
panelGuide.Controls.Add(btnCreateCircle);
|
||||||
|
panelGuide.Controls.Add(btnLoadImage);
|
||||||
|
panelGuide.Controls.Add(groupBox1);
|
||||||
|
panelGuide.Controls.Add(ctrlTitleBar);
|
||||||
|
panelGuide.Controls.Add(lblElapsed);
|
||||||
|
panelGuide.Controls.Add(btnExecute);
|
||||||
|
panelGuide.Controls.Add(label4);
|
||||||
|
panelGuide.Dock = DockStyle.Fill;
|
||||||
|
panelGuide.Location = new Point(0, 0);
|
||||||
|
panelGuide.Name = "panelGuide";
|
||||||
|
panelGuide.Size = new Size(200, 640);
|
||||||
|
panelGuide.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// GuideCircleCtrl
|
||||||
|
//
|
||||||
|
Controls.Add(splitContainer);
|
||||||
|
Controls.Add(btnClose);
|
||||||
|
Name = "GuideCircleCtrl";
|
||||||
|
Size = new Size(1280, 640);
|
||||||
|
splitContainer.Panel1.ResumeLayout(false);
|
||||||
|
splitContainer.Panel2.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)splitContainer).EndInit();
|
||||||
|
splitContainer.ResumeLayout(false);
|
||||||
|
panel1.ResumeLayout(false);
|
||||||
|
panel1.PerformLayout();
|
||||||
|
statusStrip1.ResumeLayout(false);
|
||||||
|
statusStrip1.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)btnClose).EndInit();
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
groupBox1.PerformLayout();
|
||||||
|
panelGuide.ResumeLayout(false);
|
||||||
|
panelGuide.PerformLayout();
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private SplitContainer splitContainer;
|
||||||
|
private Panel panel1;
|
||||||
|
private Canvas.UI.FlyCanvas canvas;
|
||||||
|
private StatusStrip statusStrip1;
|
||||||
|
private ToolStripStatusLabel lblStatus;
|
||||||
|
private PictureBox btnClose;
|
||||||
|
private Panel panelGuide;
|
||||||
|
private Label lblResult;
|
||||||
|
private Label label6;
|
||||||
|
private Button btnSave;
|
||||||
|
private Button btnCreateCircle;
|
||||||
|
private Button btnLoadImage;
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private TextBox tbX;
|
||||||
|
private TextBox tbY;
|
||||||
|
private TextBox tbR;
|
||||||
|
private Label label3;
|
||||||
|
private Label label2;
|
||||||
|
private Label label1;
|
||||||
|
private SizeCtrlTitleBar ctrlTitleBar;
|
||||||
|
private Label lblElapsed;
|
||||||
|
private Button btnExecute;
|
||||||
|
private Label label4;
|
||||||
|
}
|
||||||
|
}
|
361
CanFly/UI/SizePanel/SizeGuideCircleCtrl.cs
Normal file
361
CanFly/UI/SizePanel/SizeGuideCircleCtrl.cs
Normal file
@ -0,0 +1,361 @@
|
|||||||
|
using CanFly.Canvas.Shape;
|
||||||
|
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 CanFly.Canvas.Helper;
|
||||||
|
using CanFly.Helper;
|
||||||
|
using HalconDotNet;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using CanFly.Canvas.UI;
|
||||||
|
|
||||||
|
|
||||||
|
namespace CanFly.UI.SizePanel
|
||||||
|
{
|
||||||
|
public partial class SizeGuideCircleCtrl : SizeBaseGuideControl
|
||||||
|
{
|
||||||
|
|
||||||
|
private float _x;
|
||||||
|
private float _y;
|
||||||
|
private float _r;
|
||||||
|
private FlyShape? _circle;
|
||||||
|
|
||||||
|
|
||||||
|
protected override string GetScriptFileName() => "CircleMeasure.hdvp";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public SizeGuideCircleCtrl()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
|
||||||
|
this.canvas.mouseMoved += Canvas_mouseMoved;
|
||||||
|
this.canvas.OnShapeUpdateEvent += UpdateShape;
|
||||||
|
this.canvas.selectionChanged += Canvas_selectionChanged;
|
||||||
|
|
||||||
|
this.canvas.OnShapeMoving += Canvas_OnShapeMoving;
|
||||||
|
this.canvas.newShape += Canvas_newShape;
|
||||||
|
|
||||||
|
this.ctrlTitleBar.OnCloseClicked += OnControlClose;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected override void UpdateShape(FlyShape shape)
|
||||||
|
{
|
||||||
|
this._circle = shape;
|
||||||
|
|
||||||
|
_x = shape.Points[0].X;
|
||||||
|
_y = shape.Points[0].Y;
|
||||||
|
_r = PointHelper.Distance(shape.Points[0], shape.Points[1]);
|
||||||
|
|
||||||
|
this.tbX.Text = shape.Points[0].X.ToString("F3");
|
||||||
|
this.tbY.Text = shape.Points[0].Y.ToString("F3");
|
||||||
|
this.tbR.Text = _r.ToString("F3");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void btnExecute_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
if (this.canvas.pixmap == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先打开图片");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(this.tbX.Text.Trim().Length == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先创建圆形");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
this.canvas.OutsideShapes.Clear();
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
|
||||||
|
flag = new List<double>();
|
||||||
|
x = new List<double>();
|
||||||
|
y = new List<double>();
|
||||||
|
r = new List<double>();
|
||||||
|
Dictionary<string, HObject> inputImg = new Dictionary<string, HObject>();
|
||||||
|
|
||||||
|
if (hImage == null)
|
||||||
|
{
|
||||||
|
HOperatorSet.ReadImage(out hImage, CurrentImageFile);
|
||||||
|
}
|
||||||
|
inputImg["INPUT_Image"] = hImage;
|
||||||
|
|
||||||
|
Dictionary<string, HTuple> inputPara = new Dictionary<string, HTuple>();
|
||||||
|
|
||||||
|
|
||||||
|
inputPara["XCenter"] = _x;
|
||||||
|
inputPara["YCenter"] = _y;
|
||||||
|
inputPara["Radius"] = _r;
|
||||||
|
|
||||||
|
|
||||||
|
List<string> outputKeys = new List<string>()
|
||||||
|
{
|
||||||
|
"OUTPUT_PreTreatedImage",
|
||||||
|
"OUTPUT_Flag",
|
||||||
|
"RXCenter",
|
||||||
|
"RYCenter",
|
||||||
|
"RRadius"
|
||||||
|
};
|
||||||
|
|
||||||
|
ExecuteHScript(
|
||||||
|
inputImg,
|
||||||
|
inputPara,
|
||||||
|
outputKeys);
|
||||||
|
|
||||||
|
}
|
||||||
|
List<double> flag = new List<double>(), x=new List<double>(),y=new List<double>(),r=new List<double>();
|
||||||
|
|
||||||
|
protected override void OnExecuteHScriptResult(
|
||||||
|
bool success,
|
||||||
|
Dictionary<string, HTuple> resultDic,
|
||||||
|
int timeElasped)
|
||||||
|
{
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
"OUTPUT_Flag",
|
||||||
|
"RXCenter",
|
||||||
|
"RYCenter",
|
||||||
|
"RRadius"
|
||||||
|
*/
|
||||||
|
|
||||||
|
//取图?????
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
flag = resultDic["OUTPUT_Flag"].HTupleToDouble();
|
||||||
|
x = resultDic["RXCenter"].HTupleToDouble();
|
||||||
|
y = resultDic["RYCenter"].HTupleToDouble();
|
||||||
|
r = resultDic["RRadius"].HTupleToDouble();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (flag.Count > 0)
|
||||||
|
{
|
||||||
|
lblResult.Text = flag[0].ToString();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lblResult.Text = "无";
|
||||||
|
}
|
||||||
|
if (flag.Count > 0 && x.Count > 0 && y.Count > 0 && r.Count > 0)
|
||||||
|
{
|
||||||
|
|
||||||
|
//detectResult.VisionImageSet.MLImage = resultDic["RRadius"].GetResultObject("OUTPUT_PreTreatedImage");
|
||||||
|
this.canvas.DrawCircle(new PointF((float)x[0], (float)y[0]), (float)r[0]);
|
||||||
|
lblElapsed.Text = $"{timeElasped} ms";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Test()
|
||||||
|
{
|
||||||
|
string filePath = Path.Combine(_hScriptsDir, GetScriptFileName());
|
||||||
|
if (!File.Exists(filePath))
|
||||||
|
{
|
||||||
|
MessageBox.Show($"文件 {filePath} 不存在");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
HDevEngineTool tool = new HDevEngineTool(_hScriptsDir);
|
||||||
|
tool.LoadProcedure(Path.GetFileNameWithoutExtension(GetScriptFileName()));
|
||||||
|
|
||||||
|
|
||||||
|
if (hImage == null)
|
||||||
|
{
|
||||||
|
HOperatorSet.ReadImage(out hImage, CurrentImageFile);
|
||||||
|
}
|
||||||
|
|
||||||
|
tool.InputImageDic["INPUT_Image"] = hImage;
|
||||||
|
tool.InputTupleDic["XCenter"] = _x;
|
||||||
|
tool.InputTupleDic["YCenter"] = _y;
|
||||||
|
tool.InputTupleDic["Radius"] = _r;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!tool.RunProcedure(out string error, out int timeElasped))
|
||||||
|
{
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
|
||||||
|
HTuple hFlag = tool.GetResultTuple("OUTPUT_Flag");
|
||||||
|
|
||||||
|
var flag = tool.GetResultTuple("OUTPUT_Flag").HTupleToDouble();
|
||||||
|
List<double> x = tool.GetResultTuple("RXCenter").HTupleToDouble();
|
||||||
|
var y = tool.GetResultTuple("RYCenter").HTupleToDouble();
|
||||||
|
var r = tool.GetResultTuple("RRadius").HTupleToDouble();
|
||||||
|
if (flag.Count > 0)
|
||||||
|
{
|
||||||
|
lblResult.Text = flag[0].ToString();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lblResult.Text = "无";
|
||||||
|
}
|
||||||
|
if (flag.Count > 0 && x.Count > 0 && y.Count > 0 && r.Count > 0)
|
||||||
|
{
|
||||||
|
this.canvas.DrawCircle(new PointF((float)x[0], (float)y[0]), (float)r[0]);
|
||||||
|
lblElapsed.Text = $"{timeElasped} ms";
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
Debug.WriteLine("");
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
hImage?.Dispose();
|
||||||
|
hImage = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void btnClose_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OnControlCloseEvent?.Invoke();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnLoadImage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OpenImageFile(bitmap =>
|
||||||
|
{
|
||||||
|
this.canvas.LoadPixmap(bitmap);
|
||||||
|
this.canvas.Enabled = true;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_mouseMoved(PointF pos)
|
||||||
|
{
|
||||||
|
if (InvokeRequired)
|
||||||
|
{
|
||||||
|
Invoke(Canvas_mouseMoved, pos);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lblStatus.Text = $"X:{pos.X}, Y:{pos.Y}";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_selectionChanged(List<FlyShape> shapes)
|
||||||
|
{
|
||||||
|
//if (shapes.Count != 1)
|
||||||
|
//{
|
||||||
|
// // panelGuide.Controls.Clear();
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
//SwitchGuideForm(shapes[0].ShapeType);
|
||||||
|
// Canvas_OnShapeUpdateEvent(shapes[0]);
|
||||||
|
|
||||||
|
if (shapes.Count != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UpdateShape(shapes[0]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_OnShapeMoving(List<FlyShape> shapes)
|
||||||
|
{
|
||||||
|
if (shapes.Count != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateShape(shapes[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnCreateCircle_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (this.canvas.pixmap == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先打开图片");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.tbX.Text = string.Empty;
|
||||||
|
this.tbY.Text = string.Empty;
|
||||||
|
this.tbR.Text = string.Empty;
|
||||||
|
this.canvas.Shapes.Clear();
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
this.canvas.StartDraw(ShapeTypeEnum.Circle);
|
||||||
|
this.canvas.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_newShape()
|
||||||
|
{
|
||||||
|
|
||||||
|
this.canvas.StopDraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (lblResult.Text.Equals("无"))
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先进行绘制");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(lblResult.Text != "0")
|
||||||
|
{
|
||||||
|
MessageBox.Show("测量计算错误,无法保存");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//List<double> x = tool.GetResultTuple("RXCenter").HTupleToDouble();
|
||||||
|
//var y = tool.GetResultTuple("RYCenter").HTupleToDouble();
|
||||||
|
//var r = tool.GetResultTuple("RRadius").HTupleToDouble();
|
||||||
|
//tool.InputTupleDic["XCenter"] = _x;
|
||||||
|
//tool.InputTupleDic["YCenter"] = _y;
|
||||||
|
//tool.InputTupleDic["Radius"] = _r;
|
||||||
|
string inputput = $"XCenter:{string.Join(";", _x)};YCenter:{string.Join(";", _y)};RRadius:{string.Join(";", _r)}";
|
||||||
|
string output = $"RXCenter:{string.Join(";", x[0])};RYCenter:{string.Join(";", y[0])};RRadius:{string.Join(";", r[0])}";
|
||||||
|
|
||||||
|
DataToTriggerEvent(inputput,output);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
145
CanFly/UI/SizePanel/SizeGuideCircleCtrl.resx
Normal file
145
CanFly/UI/SizePanel/SizeGuideCircleCtrl.resx
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<data name="canvas.OutsideShapes" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>
|
||||||
|
AAEAAAD/////AQAAAAAAAAAMAgAAAERDYW5GbHkuQ2FudmFzLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1
|
||||||
|
cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAQBAAAAdlN5c3RlbS5Db2xsZWN0aW9ucy5HZW5l
|
||||||
|
cmljLkxpc3RgMVtbQ2FuRmx5LkNhbnZhcy5TaGFwZS5GbHlTaGFwZSwgQ2FuRmx5LkNhbnZhcywgQ3Vs
|
||||||
|
dHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsXV0DAAAABl9pdGVtcwVfc2l6ZQhfdmVyc2lv
|
||||||
|
bgQAAB5DYW5GbHkuQ2FudmFzLlNoYXBlLkZseVNoYXBlW10CAAAACAgJAwAAAAAAAAAAAAAADAQAAAAz
|
||||||
|
Q2FuRmx5LkNhbnZhcywgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsBwMAAAAAAQAA
|
||||||
|
AAAAAAAEHENhbkZseS5DYW52YXMuU2hhcGUuRmx5U2hhcGUEAAAACw==
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<data name="canvas.Shapes" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>
|
||||||
|
AAEAAAD/////AQAAAAAAAAAMAgAAAERDYW5GbHkuQ2FudmFzLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1
|
||||||
|
cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAQBAAAAdlN5c3RlbS5Db2xsZWN0aW9ucy5HZW5l
|
||||||
|
cmljLkxpc3RgMVtbQ2FuRmx5LkNhbnZhcy5TaGFwZS5GbHlTaGFwZSwgQ2FuRmx5LkNhbnZhcywgQ3Vs
|
||||||
|
dHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsXV0DAAAABl9pdGVtcwVfc2l6ZQhfdmVyc2lv
|
||||||
|
bgQAAB5DYW5GbHkuQ2FudmFzLlNoYXBlLkZseVNoYXBlW10CAAAACAgJAwAAAAAAAAAAAAAADAQAAAAz
|
||||||
|
Q2FuRmx5LkNhbnZhcywgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsBwMAAAAAAQAA
|
||||||
|
AAAAAAAEHENhbkZseS5DYW52YXMuU2hhcGUuRmx5U2hhcGUEAAAACw==
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
471
CanFly/UI/SizePanel/SizeGuideHeightCtrl.Designer.cs
generated
Normal file
471
CanFly/UI/SizePanel/SizeGuideHeightCtrl.Designer.cs
generated
Normal file
@ -0,0 +1,471 @@
|
|||||||
|
namespace CanFly.UI.SizePanel
|
||||||
|
{
|
||||||
|
partial class SizeGuideHeightCtrl
|
||||||
|
{
|
||||||
|
/// <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(SizeGuideHeightCtrl));
|
||||||
|
splitter1 = new AntdUI.Splitter();
|
||||||
|
panel1 = new AntdUI.Panel();
|
||||||
|
canvas = new Canvas.UI.FlyCanvas();
|
||||||
|
panel2 = new AntdUI.Panel();
|
||||||
|
ctrlTitleBar = new GuidePanel.CtrlTitleBar();
|
||||||
|
statusStrip1 = new StatusStrip();
|
||||||
|
lblStatus = new ToolStripStatusLabel();
|
||||||
|
groupBox2 = new GroupBox();
|
||||||
|
tbLineX1 = new AntdUI.Input();
|
||||||
|
label1 = new AntdUI.Label();
|
||||||
|
label4 = new AntdUI.Label();
|
||||||
|
tbLineY1 = new AntdUI.Input();
|
||||||
|
label3 = new AntdUI.Label();
|
||||||
|
tbLineY2 = new AntdUI.Input();
|
||||||
|
label5 = new AntdUI.Label();
|
||||||
|
tbLineX2 = new AntdUI.Input();
|
||||||
|
label6 = new AntdUI.Label();
|
||||||
|
label7 = new AntdUI.Label();
|
||||||
|
tbwidth = new AntdUI.Input();
|
||||||
|
tbheight = new AntdUI.Input();
|
||||||
|
label2 = new AntdUI.Label();
|
||||||
|
CamName = new AntdUI.Input();
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
switch1 = new AntdUI.Switch();
|
||||||
|
label8 = new AntdUI.Label();
|
||||||
|
button1 = new AntdUI.Button();
|
||||||
|
button2 = new AntdUI.Button();
|
||||||
|
button3 = new AntdUI.Button();
|
||||||
|
label9 = new AntdUI.Label();
|
||||||
|
lblElapsed = new AntdUI.Label();
|
||||||
|
lblResult = new AntdUI.Label();
|
||||||
|
label12 = new AntdUI.Label();
|
||||||
|
btnSave = new AntdUI.Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)splitter1).BeginInit();
|
||||||
|
splitter1.Panel1.SuspendLayout();
|
||||||
|
splitter1.Panel2.SuspendLayout();
|
||||||
|
splitter1.SuspendLayout();
|
||||||
|
panel1.SuspendLayout();
|
||||||
|
panel2.SuspendLayout();
|
||||||
|
statusStrip1.SuspendLayout();
|
||||||
|
groupBox2.SuspendLayout();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// splitter1
|
||||||
|
//
|
||||||
|
splitter1.Dock = DockStyle.Fill;
|
||||||
|
splitter1.Location = new Point(0, 0);
|
||||||
|
splitter1.Name = "splitter1";
|
||||||
|
//
|
||||||
|
// splitter1.Panel1
|
||||||
|
//
|
||||||
|
splitter1.Panel1.Controls.Add(panel2);
|
||||||
|
//
|
||||||
|
// splitter1.Panel2
|
||||||
|
//
|
||||||
|
splitter1.Panel2.Controls.Add(panel1);
|
||||||
|
splitter1.Size = new Size(1280, 640);
|
||||||
|
splitter1.SplitterDistance = 286;
|
||||||
|
splitter1.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
panel1.Controls.Add(statusStrip1);
|
||||||
|
panel1.Controls.Add(canvas);
|
||||||
|
panel1.Dock = DockStyle.Fill;
|
||||||
|
panel1.Location = new Point(0, 0);
|
||||||
|
panel1.Name = "panel1";
|
||||||
|
panel1.Size = new Size(990, 640);
|
||||||
|
panel1.TabIndex = 0;
|
||||||
|
panel1.Text = "panel1";
|
||||||
|
//
|
||||||
|
// canvas
|
||||||
|
//
|
||||||
|
canvas.AllowMultiSelect = false;
|
||||||
|
canvas.CreateMode = Canvas.Shape.ShapeTypeEnum.Polygon;
|
||||||
|
canvas.Dock = DockStyle.Fill;
|
||||||
|
canvas.FillDrawing = false;
|
||||||
|
canvas.Location = new Point(0, 0);
|
||||||
|
canvas.Margin = new Padding(2);
|
||||||
|
canvas.Name = "canvas";
|
||||||
|
canvas.OutsideShapes = (List<Canvas.Shape.FlyShape>)resources.GetObject("canvas.OutsideShapes");
|
||||||
|
canvas.Scale = 1F;
|
||||||
|
canvas.Shapes = (List<Canvas.Shape.FlyShape>)resources.GetObject("canvas.Shapes");
|
||||||
|
canvas.Size = new Size(990, 640);
|
||||||
|
canvas.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// panel2
|
||||||
|
//
|
||||||
|
panel2.Controls.Add(btnSave);
|
||||||
|
panel2.Controls.Add(lblResult);
|
||||||
|
panel2.Controls.Add(label12);
|
||||||
|
panel2.Controls.Add(lblElapsed);
|
||||||
|
panel2.Controls.Add(label9);
|
||||||
|
panel2.Controls.Add(button3);
|
||||||
|
panel2.Controls.Add(button2);
|
||||||
|
panel2.Controls.Add(groupBox1);
|
||||||
|
panel2.Controls.Add(groupBox2);
|
||||||
|
panel2.Controls.Add(ctrlTitleBar);
|
||||||
|
panel2.Dock = DockStyle.Fill;
|
||||||
|
panel2.Location = new Point(0, 0);
|
||||||
|
panel2.Name = "panel2";
|
||||||
|
panel2.Size = new Size(286, 640);
|
||||||
|
panel2.TabIndex = 0;
|
||||||
|
panel2.Text = "panel2";
|
||||||
|
//
|
||||||
|
// ctrlTitleBar
|
||||||
|
//
|
||||||
|
ctrlTitleBar.Dock = DockStyle.Top;
|
||||||
|
ctrlTitleBar.Location = new Point(0, 0);
|
||||||
|
ctrlTitleBar.MinimumSize = new Size(0, 36);
|
||||||
|
ctrlTitleBar.Name = "ctrlTitleBar";
|
||||||
|
ctrlTitleBar.Padding = new Padding(3);
|
||||||
|
ctrlTitleBar.Size = new Size(286, 36);
|
||||||
|
ctrlTitleBar.TabIndex = 12;
|
||||||
|
ctrlTitleBar.Title = "高度测量";
|
||||||
|
//
|
||||||
|
// statusStrip1
|
||||||
|
//
|
||||||
|
statusStrip1.Items.AddRange(new ToolStripItem[] { lblStatus });
|
||||||
|
statusStrip1.Location = new Point(0, 618);
|
||||||
|
statusStrip1.Name = "statusStrip1";
|
||||||
|
statusStrip1.Size = new Size(990, 22);
|
||||||
|
statusStrip1.TabIndex = 2;
|
||||||
|
statusStrip1.Text = "statusStrip1";
|
||||||
|
//
|
||||||
|
// lblStatus
|
||||||
|
//
|
||||||
|
lblStatus.Name = "lblStatus";
|
||||||
|
lblStatus.Size = new Size(44, 17);
|
||||||
|
lblStatus.Text = " ";
|
||||||
|
//
|
||||||
|
// groupBox2
|
||||||
|
//
|
||||||
|
groupBox2.Controls.Add(tbheight);
|
||||||
|
groupBox2.Controls.Add(tbwidth);
|
||||||
|
groupBox2.Controls.Add(label7);
|
||||||
|
groupBox2.Controls.Add(label6);
|
||||||
|
groupBox2.Controls.Add(label3);
|
||||||
|
groupBox2.Controls.Add(tbLineY2);
|
||||||
|
groupBox2.Controls.Add(label5);
|
||||||
|
groupBox2.Controls.Add(tbLineX2);
|
||||||
|
groupBox2.Controls.Add(label4);
|
||||||
|
groupBox2.Controls.Add(tbLineY1);
|
||||||
|
groupBox2.Controls.Add(label1);
|
||||||
|
groupBox2.Controls.Add(tbLineX1);
|
||||||
|
groupBox2.Dock = DockStyle.Top;
|
||||||
|
groupBox2.Location = new Point(0, 36);
|
||||||
|
groupBox2.Name = "groupBox2";
|
||||||
|
groupBox2.Size = new Size(286, 229);
|
||||||
|
groupBox2.TabIndex = 14;
|
||||||
|
groupBox2.TabStop = false;
|
||||||
|
groupBox2.Text = "线参数";
|
||||||
|
//
|
||||||
|
// tbLineX1
|
||||||
|
//
|
||||||
|
tbLineX1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLineX1.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
|
tbLineX1.Location = new Point(62, 22);
|
||||||
|
tbLineX1.Name = "tbLineX1";
|
||||||
|
tbLineX1.Radius = 3;
|
||||||
|
tbLineX1.Size = new Size(214, 32);
|
||||||
|
tbLineX1.TabIndex = 17;
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.Location = new Point(6, 22);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(38, 32);
|
||||||
|
label1.TabIndex = 19;
|
||||||
|
label1.Text = " X1:";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.Location = new Point(6, 60);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(38, 32);
|
||||||
|
label4.TabIndex = 23;
|
||||||
|
label4.Text = " Y1:";
|
||||||
|
//
|
||||||
|
// tbLineY1
|
||||||
|
//
|
||||||
|
tbLineY1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLineY1.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
|
tbLineY1.Location = new Point(62, 60);
|
||||||
|
tbLineY1.Name = "tbLineY1";
|
||||||
|
tbLineY1.Radius = 3;
|
||||||
|
tbLineY1.Size = new Size(214, 32);
|
||||||
|
tbLineY1.TabIndex = 22;
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.Location = new Point(6, 136);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(38, 32);
|
||||||
|
label3.TabIndex = 27;
|
||||||
|
label3.Text = " Y2:";
|
||||||
|
//
|
||||||
|
// tbLineY2
|
||||||
|
//
|
||||||
|
tbLineY2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLineY2.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
|
tbLineY2.Location = new Point(62, 136);
|
||||||
|
tbLineY2.Name = "tbLineY2";
|
||||||
|
tbLineY2.Radius = 3;
|
||||||
|
tbLineY2.Size = new Size(214, 32);
|
||||||
|
tbLineY2.TabIndex = 26;
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
label5.Location = new Point(6, 98);
|
||||||
|
label5.Name = "label5";
|
||||||
|
label5.Size = new Size(38, 32);
|
||||||
|
label5.TabIndex = 25;
|
||||||
|
label5.Text = " X2:";
|
||||||
|
//
|
||||||
|
// tbLineX2
|
||||||
|
//
|
||||||
|
tbLineX2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLineX2.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
|
tbLineX2.Location = new Point(62, 98);
|
||||||
|
tbLineX2.Name = "tbLineX2";
|
||||||
|
tbLineX2.Radius = 3;
|
||||||
|
tbLineX2.Size = new Size(214, 32);
|
||||||
|
tbLineX2.TabIndex = 24;
|
||||||
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
label6.Location = new Point(6, 174);
|
||||||
|
label6.Name = "label6";
|
||||||
|
label6.Size = new Size(50, 32);
|
||||||
|
label6.TabIndex = 28;
|
||||||
|
label6.Text = " 宽:";
|
||||||
|
//
|
||||||
|
// label7
|
||||||
|
//
|
||||||
|
label7.Location = new Point(145, 177);
|
||||||
|
label7.Name = "label7";
|
||||||
|
label7.Size = new Size(29, 32);
|
||||||
|
label7.TabIndex = 29;
|
||||||
|
label7.Text = "高:";
|
||||||
|
//
|
||||||
|
// tbwidth
|
||||||
|
//
|
||||||
|
tbwidth.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbwidth.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
|
tbwidth.Location = new Point(62, 177);
|
||||||
|
tbwidth.Name = "tbwidth";
|
||||||
|
tbwidth.Radius = 3;
|
||||||
|
tbwidth.Size = new Size(77, 32);
|
||||||
|
tbwidth.TabIndex = 30;
|
||||||
|
//
|
||||||
|
// tbheight
|
||||||
|
//
|
||||||
|
tbheight.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbheight.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
|
tbheight.Location = new Point(180, 177);
|
||||||
|
tbheight.Name = "tbheight";
|
||||||
|
tbheight.Radius = 3;
|
||||||
|
tbheight.Size = new Size(96, 32);
|
||||||
|
tbheight.TabIndex = 31;
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.Location = new Point(6, 22);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(55, 32);
|
||||||
|
label2.TabIndex = 1;
|
||||||
|
label2.Text = "相机名:";
|
||||||
|
//
|
||||||
|
// CamName
|
||||||
|
//
|
||||||
|
CamName.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
CamName.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||||
|
CamName.Location = new Point(64, 22);
|
||||||
|
CamName.Name = "CamName";
|
||||||
|
CamName.Radius = 3;
|
||||||
|
CamName.ReadOnly = true;
|
||||||
|
CamName.Size = new Size(212, 32);
|
||||||
|
CamName.TabIndex = 18;
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(button1);
|
||||||
|
groupBox1.Controls.Add(label8);
|
||||||
|
groupBox1.Controls.Add(switch1);
|
||||||
|
groupBox1.Controls.Add(label2);
|
||||||
|
groupBox1.Controls.Add(CamName);
|
||||||
|
groupBox1.Dock = DockStyle.Top;
|
||||||
|
groupBox1.Location = new Point(0, 265);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Size = new Size(286, 105);
|
||||||
|
groupBox1.TabIndex = 19;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "相机控制";
|
||||||
|
//
|
||||||
|
// switch1
|
||||||
|
//
|
||||||
|
switch1.Location = new Point(67, 60);
|
||||||
|
switch1.Name = "switch1";
|
||||||
|
switch1.Size = new Size(72, 32);
|
||||||
|
switch1.TabIndex = 19;
|
||||||
|
switch1.Text = "switch1";
|
||||||
|
//
|
||||||
|
// label8
|
||||||
|
//
|
||||||
|
label8.Location = new Point(6, 60);
|
||||||
|
label8.Name = "label8";
|
||||||
|
label8.Size = new Size(55, 32);
|
||||||
|
label8.TabIndex = 20;
|
||||||
|
label8.Text = "硬触发:";
|
||||||
|
//
|
||||||
|
// button1
|
||||||
|
//
|
||||||
|
button1.Location = new Point(145, 60);
|
||||||
|
button1.Name = "button1";
|
||||||
|
button1.Size = new Size(131, 32);
|
||||||
|
button1.TabIndex = 21;
|
||||||
|
button1.Text = "软触发一次";
|
||||||
|
//
|
||||||
|
// button2
|
||||||
|
//
|
||||||
|
button2.Location = new Point(0, 376);
|
||||||
|
button2.Name = "button2";
|
||||||
|
button2.Size = new Size(276, 37);
|
||||||
|
button2.TabIndex = 22;
|
||||||
|
button2.Text = "创建矩形";
|
||||||
|
button2.Type = AntdUI.TTypeMini.Primary;
|
||||||
|
//
|
||||||
|
// button3
|
||||||
|
//
|
||||||
|
button3.Location = new Point(0, 419);
|
||||||
|
button3.Name = "button3";
|
||||||
|
button3.Size = new Size(276, 36);
|
||||||
|
button3.TabIndex = 23;
|
||||||
|
button3.Text = "执行";
|
||||||
|
button3.Type = AntdUI.TTypeMini.Primary;
|
||||||
|
//
|
||||||
|
// label9
|
||||||
|
//
|
||||||
|
label9.Location = new Point(6, 461);
|
||||||
|
label9.Name = "label9";
|
||||||
|
label9.Size = new Size(50, 23);
|
||||||
|
label9.TabIndex = 24;
|
||||||
|
label9.Text = "耗时:";
|
||||||
|
//
|
||||||
|
// lblElapsed
|
||||||
|
//
|
||||||
|
lblElapsed.Location = new Point(67, 461);
|
||||||
|
lblElapsed.Name = "lblElapsed";
|
||||||
|
lblElapsed.Size = new Size(72, 23);
|
||||||
|
lblElapsed.TabIndex = 25;
|
||||||
|
lblElapsed.Text = "0 ms";
|
||||||
|
//
|
||||||
|
// lblResult
|
||||||
|
//
|
||||||
|
lblResult.Location = new Point(67, 490);
|
||||||
|
lblResult.Name = "lblResult";
|
||||||
|
lblResult.Size = new Size(72, 23);
|
||||||
|
lblResult.TabIndex = 27;
|
||||||
|
lblResult.Text = "无";
|
||||||
|
//
|
||||||
|
// label12
|
||||||
|
//
|
||||||
|
label12.Location = new Point(6, 490);
|
||||||
|
label12.Name = "label12";
|
||||||
|
label12.Size = new Size(50, 23);
|
||||||
|
label12.TabIndex = 26;
|
||||||
|
label12.Text = "结果:";
|
||||||
|
//
|
||||||
|
// btnSave
|
||||||
|
//
|
||||||
|
btnSave.Location = new Point(0, 519);
|
||||||
|
btnSave.Name = "btnSave";
|
||||||
|
btnSave.Size = new Size(276, 36);
|
||||||
|
btnSave.TabIndex = 28;
|
||||||
|
btnSave.Text = "保存数据";
|
||||||
|
btnSave.Type = AntdUI.TTypeMini.Primary;
|
||||||
|
//
|
||||||
|
// SizeGuideHeightCtrl
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
Controls.Add(splitter1);
|
||||||
|
Name = "SizeGuideHeightCtrl";
|
||||||
|
Size = new Size(1280, 640);
|
||||||
|
Load += GuideLineCircleCtrl_Load;
|
||||||
|
splitter1.Panel1.ResumeLayout(false);
|
||||||
|
splitter1.Panel2.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)splitter1).EndInit();
|
||||||
|
splitter1.ResumeLayout(false);
|
||||||
|
panel1.ResumeLayout(false);
|
||||||
|
panel1.PerformLayout();
|
||||||
|
panel2.ResumeLayout(false);
|
||||||
|
statusStrip1.ResumeLayout(false);
|
||||||
|
statusStrip1.PerformLayout();
|
||||||
|
groupBox2.ResumeLayout(false);
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private TextBox tbRectWidth1;
|
||||||
|
private AntdUI.Splitter splitter1;
|
||||||
|
private AntdUI.Panel panel1;
|
||||||
|
private Canvas.UI.FlyCanvas canvas;
|
||||||
|
private AntdUI.Panel panel2;
|
||||||
|
private GuidePanel.CtrlTitleBar ctrlTitleBar;
|
||||||
|
private StatusStrip statusStrip1;
|
||||||
|
private ToolStripStatusLabel lblStatus;
|
||||||
|
private GroupBox groupBox2;
|
||||||
|
|
||||||
|
private Canvas.UI.FlyCanvas flyCanvas1;
|
||||||
|
private AntdUI.Input tbLineX1;
|
||||||
|
private AntdUI.Label label1;
|
||||||
|
private AntdUI.Label label3;
|
||||||
|
private AntdUI.Input tbLineY2;
|
||||||
|
private AntdUI.Label label5;
|
||||||
|
private AntdUI.Input tbLineX2;
|
||||||
|
private AntdUI.Label label4;
|
||||||
|
private AntdUI.Input tbLineY1;
|
||||||
|
private AntdUI.Label label7;
|
||||||
|
private AntdUI.Label label6;
|
||||||
|
private AntdUI.Input tbwidth;
|
||||||
|
private AntdUI.Input tbheight;
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private AntdUI.Label label2;
|
||||||
|
private AntdUI.Input CamName;
|
||||||
|
private AntdUI.Button button1;
|
||||||
|
private AntdUI.Label label8;
|
||||||
|
private AntdUI.Switch switch1;
|
||||||
|
private AntdUI.Button button2;
|
||||||
|
private AntdUI.Button button3;
|
||||||
|
private AntdUI.Label lblElapsed;
|
||||||
|
private AntdUI.Label label9;
|
||||||
|
private AntdUI.Label lblResult;
|
||||||
|
private AntdUI.Label label12;
|
||||||
|
private AntdUI.Button btnSave;
|
||||||
|
}
|
||||||
|
}
|
346
CanFly/UI/SizePanel/SizeGuideHeightCtrl.cs
Normal file
346
CanFly/UI/SizePanel/SizeGuideHeightCtrl.cs
Normal file
@ -0,0 +1,346 @@
|
|||||||
|
using CanFly.Canvas.Helper;
|
||||||
|
using CanFly.Canvas.Shape;
|
||||||
|
using CanFly.Canvas.UI;
|
||||||
|
using CanFly.Helper;
|
||||||
|
using HalconDotNet;
|
||||||
|
using OpenCvSharp;
|
||||||
|
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 CanFly.UI.SizePanel
|
||||||
|
{
|
||||||
|
public partial class SizeGuideHeightCtrl : SizeBaseGuideControl
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private FlyShape? _line;
|
||||||
|
|
||||||
|
|
||||||
|
private float _lineX1;
|
||||||
|
private float _lineY1;
|
||||||
|
private float _lineX2;
|
||||||
|
private float _lineY2;
|
||||||
|
float width, height;
|
||||||
|
private float _lineWidth;
|
||||||
|
private PointF[] _rectPoints = new PointF[4];
|
||||||
|
//private float _LineLX=new float();
|
||||||
|
//private float _LineLY =new float();
|
||||||
|
//private float _LineRX =new float();
|
||||||
|
//private float _LineRY =new float();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected override string GetScriptFileName() => "HeightMeasure.hdvp";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public SizeGuideHeightCtrl()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
this.canvas.mouseMoved += Canvas_mouseMoved;
|
||||||
|
this.canvas.OnShapeUpdateEvent += UpdateShape;
|
||||||
|
this.canvas.selectionChanged += Canvas_selectionChanged;
|
||||||
|
|
||||||
|
this.canvas.OnShapeMoving += Canvas_OnShapeMoving;
|
||||||
|
this.canvas.newShape += Canvas_newShape;
|
||||||
|
|
||||||
|
this.ctrlTitleBar.OnCloseClicked += OnControlClose;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected override void UpdateShape(FlyShape shape)
|
||||||
|
{
|
||||||
|
switch (shape.ShapeType)
|
||||||
|
{
|
||||||
|
case ShapeTypeEnum.Rectangle:
|
||||||
|
this._line = shape;
|
||||||
|
|
||||||
|
var pts = this._line.Points;
|
||||||
|
|
||||||
|
_lineX1 = pts[0].X;
|
||||||
|
_lineY1 = pts[0].Y;
|
||||||
|
_lineX2 = pts[1].X;
|
||||||
|
_lineY2 = pts[1].Y;
|
||||||
|
_lineWidth = shape.LineVirtualRectWidth;
|
||||||
|
_rectPoints = shape.LineVirtualRectPoints;
|
||||||
|
//_LineLX = (shape.LineVirtualRectPoints[0].X + shape.LineVirtualRectPoints[3].X) / 2;
|
||||||
|
//_LineLY = (shape.LineVirtualRectPoints[0].Y + shape.LineVirtualRectPoints[3].Y) / 2;
|
||||||
|
//_LineRX = (shape.LineVirtualRectPoints[1].X + shape.LineVirtualRectPoints[2].X) / 2;
|
||||||
|
//_LineRY = (shape.LineVirtualRectPoints[1].Y + shape.LineVirtualRectPoints[2].Y) / 2;
|
||||||
|
|
||||||
|
width = Math.Abs(_lineX2 - _lineX1);
|
||||||
|
height = Math.Abs(_lineY2 - _lineY1);
|
||||||
|
|
||||||
|
|
||||||
|
tbLineX1.Text = _lineX1.ToString("F3");
|
||||||
|
tbLineY1.Text = _lineY1.ToString("F3");
|
||||||
|
tbLineX2.Text = _lineX2.ToString("F3");
|
||||||
|
tbLineY2.Text = _lineY2.ToString("F3");
|
||||||
|
tbwidth.Text = width.ToString();
|
||||||
|
tbheight.Text = height.ToString();
|
||||||
|
// NumRectWidth1.Value = (decimal)_lineWidth;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void GuideLineCircleCtrl_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_mouseMoved(PointF pos)
|
||||||
|
{
|
||||||
|
if (InvokeRequired)
|
||||||
|
{
|
||||||
|
Invoke(Canvas_mouseMoved, pos);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lblStatus.Text = $"X:{pos.X}, Y:{pos.Y}";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_selectionChanged(List<FlyShape> shapes)
|
||||||
|
{
|
||||||
|
//if (shapes.Count != 1)
|
||||||
|
//{
|
||||||
|
// // panelGuide.Controls.Clear();
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
//SwitchGuideForm(shapes[0].ShapeType);
|
||||||
|
// Canvas_OnShapeUpdateEvent(shapes[0]);
|
||||||
|
|
||||||
|
if (shapes.Count != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UpdateShape(shapes[0]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_OnShapeMoving(List<FlyShape> shapes)
|
||||||
|
{
|
||||||
|
if (shapes.Count != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateShape(shapes[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void btnCreateLine_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (this.canvas.pixmap == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先打开图片");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tbLineX1.Text = string.Empty;
|
||||||
|
tbLineY1.Text = string.Empty;
|
||||||
|
tbLineX2.Text = string.Empty;
|
||||||
|
tbLineY2.Text = string.Empty; ;
|
||||||
|
tbwidth.Text = string.Empty; ;
|
||||||
|
tbheight.Text = string.Empty; ;
|
||||||
|
this.canvas.Shapes.RemoveAll(shp => shp.ShapeType == ShapeTypeEnum.Rectangle);
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
this.canvas.StartDraw(ShapeTypeEnum.Rectangle);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void btnLoadImage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OpenImageFile(bitmap =>
|
||||||
|
{
|
||||||
|
this.canvas.LoadPixmap(bitmap);
|
||||||
|
this.canvas.Enabled = true;
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_newShape()
|
||||||
|
{
|
||||||
|
this.canvas.StopDraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnExecute_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (this.canvas.pixmap == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先打开图片");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.tbLineX1.Text.Trim().Length == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先创建矩形");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.canvas.OutsideShapes.Clear();
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
|
||||||
|
|
||||||
|
flag = new List<double>();
|
||||||
|
|
||||||
|
Line1Para = new List<double>();
|
||||||
|
Line2Para = new List<double>();
|
||||||
|
iHeight = new List<double>();
|
||||||
|
Dictionary<string, HObject> inputImg = new Dictionary<string, HObject>();
|
||||||
|
|
||||||
|
if (hImage == null)
|
||||||
|
{
|
||||||
|
HOperatorSet.ReadImage(out hImage, CurrentImageFile);
|
||||||
|
}
|
||||||
|
inputImg["INPUT_Image"] = hImage;
|
||||||
|
|
||||||
|
|
||||||
|
Dictionary<string, HTuple> inputPara = new Dictionary<string, HTuple>();
|
||||||
|
|
||||||
|
|
||||||
|
inputPara["row"] = _lineY1;
|
||||||
|
inputPara["column"] = _lineX1;
|
||||||
|
inputPara["Width"] = width;
|
||||||
|
inputPara["Height"] = height;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
List<string> outputKeys = new List<string>()
|
||||||
|
{
|
||||||
|
"OUTPUT_PreTreatedImage",
|
||||||
|
"OUTPUT_Flag",
|
||||||
|
|
||||||
|
"Line1Para",
|
||||||
|
"Line2Para",
|
||||||
|
"iHeight"
|
||||||
|
};
|
||||||
|
|
||||||
|
ExecuteHScript(
|
||||||
|
inputImg,
|
||||||
|
inputPara,
|
||||||
|
outputKeys);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<double> flag = new List<double>();
|
||||||
|
List<double> Line1Para = new List<double>();
|
||||||
|
List<double> Line2Para = new List<double>();
|
||||||
|
|
||||||
|
List<double> iHeight = new List<double>();
|
||||||
|
|
||||||
|
|
||||||
|
protected override void OnExecuteHScriptResult(
|
||||||
|
bool success,
|
||||||
|
Dictionary<string, HTuple> resultDic,
|
||||||
|
int timeElasped)
|
||||||
|
{
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
"OUTPUT_Flag",
|
||||||
|
"RXCenter",
|
||||||
|
"RYCenter",
|
||||||
|
"RRadius"
|
||||||
|
*/
|
||||||
|
|
||||||
|
flag = resultDic["OUTPUT_Flag"].HTupleToDouble();
|
||||||
|
|
||||||
|
Line1Para = resultDic["Line1Para"].HTupleToDouble();
|
||||||
|
Line2Para = resultDic["Line2Para"].HTupleToDouble();
|
||||||
|
// EndRow = resultDic["EndRow"].HTupleToDouble();
|
||||||
|
//EndCloumn = resultDic["EndColumn"].HTupleToDouble();
|
||||||
|
iHeight = resultDic["iHeight"].HTupleToDouble();
|
||||||
|
|
||||||
|
if (flag.Count > 0)
|
||||||
|
{
|
||||||
|
lblResult.Text = flag[0].ToString();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lblResult.Text = "无";
|
||||||
|
}
|
||||||
|
if (flag.Count > 0 && Line1Para.Count == 4 && Line2Para.Count == 4 && iHeight.Count > 0)
|
||||||
|
{
|
||||||
|
float width = 0;
|
||||||
|
this.canvas.DrawLine(new PointF((float)Line1Para[1], (float)Line1Para[0]), new PointF((float)Line1Para[3], (float)Line1Para[2]), 0);
|
||||||
|
this.canvas.DrawLine(new PointF((float)Line2Para[1], (float)Line2Para[0]), new PointF((float)Line2Para[3], (float)Line2Para[2]), 0);
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
lblElapsed.Text = $"{timeElasped} ms";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void btnSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (lblResult.Text.Equals("无"))
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先进行绘制");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (lblResult.Text != "0")
|
||||||
|
{
|
||||||
|
MessageBox.Show("测量计算错误,无法保存");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string input = $"row:{string.Join(";", _lineY1)};column:{string.Join(";", _lineX1)};" +
|
||||||
|
$"Width:{string.Join(";", width)};Height:{string.Join(";", height)}";
|
||||||
|
|
||||||
|
string output = $"iHeight:{string.Join(";", iHeight[0])}";
|
||||||
|
DataToTriggerEvent(input, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void tbLineX1_TextChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
148
CanFly/UI/SizePanel/SizeGuideHeightCtrl.resx
Normal file
148
CanFly/UI/SizePanel/SizeGuideHeightCtrl.resx
Normal file
@ -0,0 +1,148 @@
|
|||||||
|
<?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="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
<data name="canvas.OutsideShapes" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>
|
||||||
|
AAEAAAD/////AQAAAAAAAAAMAgAAAERDYW5GbHkuQ2FudmFzLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1
|
||||||
|
cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAQBAAAAdlN5c3RlbS5Db2xsZWN0aW9ucy5HZW5l
|
||||||
|
cmljLkxpc3RgMVtbQ2FuRmx5LkNhbnZhcy5TaGFwZS5GbHlTaGFwZSwgQ2FuRmx5LkNhbnZhcywgQ3Vs
|
||||||
|
dHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsXV0DAAAABl9pdGVtcwVfc2l6ZQhfdmVyc2lv
|
||||||
|
bgQAAB5DYW5GbHkuQ2FudmFzLlNoYXBlLkZseVNoYXBlW10CAAAACAgJAwAAAAAAAAAAAAAADAQAAAAz
|
||||||
|
Q2FuRmx5LkNhbnZhcywgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsBwMAAAAAAQAA
|
||||||
|
AAAAAAAEHENhbkZseS5DYW52YXMuU2hhcGUuRmx5U2hhcGUEAAAACw==
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<data name="canvas.Shapes" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>
|
||||||
|
AAEAAAD/////AQAAAAAAAAAMAgAAAERDYW5GbHkuQ2FudmFzLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1
|
||||||
|
cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAQBAAAAdlN5c3RlbS5Db2xsZWN0aW9ucy5HZW5l
|
||||||
|
cmljLkxpc3RgMVtbQ2FuRmx5LkNhbnZhcy5TaGFwZS5GbHlTaGFwZSwgQ2FuRmx5LkNhbnZhcywgQ3Vs
|
||||||
|
dHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsXV0DAAAABl9pdGVtcwVfc2l6ZQhfdmVyc2lv
|
||||||
|
bgQAAB5DYW5GbHkuQ2FudmFzLlNoYXBlLkZseVNoYXBlW10CAAAACAgJAwAAAAAAAAAAAAAADAQAAAAz
|
||||||
|
Q2FuRmx5LkNhbnZhcywgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsBwMAAAAAAQAA
|
||||||
|
AAAAAAAEHENhbkZseS5DYW52YXMuU2hhcGUuRmx5U2hhcGUEAAAACw==
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
550
CanFly/UI/SizePanel/SizeGuideLineCircleCtrl.Designer.cs
generated
Normal file
550
CanFly/UI/SizePanel/SizeGuideLineCircleCtrl.Designer.cs
generated
Normal file
@ -0,0 +1,550 @@
|
|||||||
|
namespace CanFly.UI.SizePanel
|
||||||
|
{
|
||||||
|
partial class SizeGuideLineCircleCtrl
|
||||||
|
{
|
||||||
|
/// <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(SizeGuideLineCircleCtrl));
|
||||||
|
lblElapsed = new Label();
|
||||||
|
label4 = new Label();
|
||||||
|
splitContainer = new SplitContainer();
|
||||||
|
panelGuide = new Panel();
|
||||||
|
lblDistance = new Label();
|
||||||
|
label17 = new Label();
|
||||||
|
lblResult = new Label();
|
||||||
|
label15 = new Label();
|
||||||
|
btnCreateLine = new Button();
|
||||||
|
btnCreateCircle = new Button();
|
||||||
|
btnLoadImage = new Button();
|
||||||
|
label9 = new Label();
|
||||||
|
btnExecute = new Button();
|
||||||
|
label10 = new Label();
|
||||||
|
groupBox2 = new GroupBox();
|
||||||
|
NumRectWidth1 = new NumericUpDown();
|
||||||
|
label11 = new Label();
|
||||||
|
tbLineX2 = new TextBox();
|
||||||
|
label8 = new Label();
|
||||||
|
tbLineY2 = new TextBox();
|
||||||
|
label5 = new Label();
|
||||||
|
tbLineX1 = new TextBox();
|
||||||
|
tbLineY1 = new TextBox();
|
||||||
|
label6 = new Label();
|
||||||
|
label7 = new Label();
|
||||||
|
groupBox1 = new GroupBox();
|
||||||
|
tbCircleX = new TextBox();
|
||||||
|
tbCircleY = new TextBox();
|
||||||
|
tbCircleR = new TextBox();
|
||||||
|
label3 = new Label();
|
||||||
|
label2 = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
ctrlTitleBar = new SizeCtrlTitleBar();
|
||||||
|
panel1 = new Panel();
|
||||||
|
canvas = new Canvas.UI.FlyCanvas();
|
||||||
|
statusStrip1 = new StatusStrip();
|
||||||
|
lblStatus = new ToolStripStatusLabel();
|
||||||
|
btnSave = new Button();
|
||||||
|
((System.ComponentModel.ISupportInitialize)splitContainer).BeginInit();
|
||||||
|
splitContainer.Panel1.SuspendLayout();
|
||||||
|
splitContainer.Panel2.SuspendLayout();
|
||||||
|
splitContainer.SuspendLayout();
|
||||||
|
panelGuide.SuspendLayout();
|
||||||
|
groupBox2.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)NumRectWidth1).BeginInit();
|
||||||
|
groupBox1.SuspendLayout();
|
||||||
|
panel1.SuspendLayout();
|
||||||
|
statusStrip1.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// lblElapsed
|
||||||
|
//
|
||||||
|
lblElapsed.AutoSize = true;
|
||||||
|
lblElapsed.Location = new Point(50, 328);
|
||||||
|
lblElapsed.Name = "lblElapsed";
|
||||||
|
lblElapsed.Size = new Size(32, 17);
|
||||||
|
lblElapsed.TabIndex = 9;
|
||||||
|
lblElapsed.Text = "0ms";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(0, 328);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(44, 17);
|
||||||
|
label4.TabIndex = 8;
|
||||||
|
label4.Text = "耗时:";
|
||||||
|
//
|
||||||
|
// splitContainer
|
||||||
|
//
|
||||||
|
splitContainer.Dock = DockStyle.Fill;
|
||||||
|
splitContainer.Location = new Point(0, 0);
|
||||||
|
splitContainer.Name = "splitContainer";
|
||||||
|
//
|
||||||
|
// splitContainer.Panel1
|
||||||
|
//
|
||||||
|
splitContainer.Panel1.Controls.Add(panelGuide);
|
||||||
|
splitContainer.Panel1MinSize = 150;
|
||||||
|
//
|
||||||
|
// splitContainer.Panel2
|
||||||
|
//
|
||||||
|
splitContainer.Panel2.Controls.Add(panel1);
|
||||||
|
splitContainer.Size = new Size(1280, 640);
|
||||||
|
splitContainer.SplitterDistance = 200;
|
||||||
|
splitContainer.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// panelGuide
|
||||||
|
//
|
||||||
|
panelGuide.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
panelGuide.Controls.Add(btnSave);
|
||||||
|
panelGuide.Controls.Add(lblDistance);
|
||||||
|
panelGuide.Controls.Add(label17);
|
||||||
|
panelGuide.Controls.Add(lblResult);
|
||||||
|
panelGuide.Controls.Add(label15);
|
||||||
|
panelGuide.Controls.Add(btnCreateLine);
|
||||||
|
panelGuide.Controls.Add(btnCreateCircle);
|
||||||
|
panelGuide.Controls.Add(btnLoadImage);
|
||||||
|
panelGuide.Controls.Add(label9);
|
||||||
|
panelGuide.Controls.Add(btnExecute);
|
||||||
|
panelGuide.Controls.Add(label10);
|
||||||
|
panelGuide.Controls.Add(groupBox2);
|
||||||
|
panelGuide.Controls.Add(groupBox1);
|
||||||
|
panelGuide.Controls.Add(ctrlTitleBar);
|
||||||
|
panelGuide.Dock = DockStyle.Fill;
|
||||||
|
panelGuide.Location = new Point(0, 0);
|
||||||
|
panelGuide.Name = "panelGuide";
|
||||||
|
panelGuide.Size = new Size(200, 640);
|
||||||
|
panelGuide.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// lblDistance
|
||||||
|
//
|
||||||
|
lblDistance.AutoSize = true;
|
||||||
|
lblDistance.Location = new Point(54, 505);
|
||||||
|
lblDistance.Name = "lblDistance";
|
||||||
|
lblDistance.Size = new Size(15, 17);
|
||||||
|
lblDistance.TabIndex = 29;
|
||||||
|
lblDistance.Text = "0";
|
||||||
|
//
|
||||||
|
// label17
|
||||||
|
//
|
||||||
|
label17.AutoSize = true;
|
||||||
|
label17.Location = new Point(6, 505);
|
||||||
|
label17.Name = "label17";
|
||||||
|
label17.Size = new Size(44, 17);
|
||||||
|
label17.TabIndex = 28;
|
||||||
|
label17.Text = "距离:";
|
||||||
|
//
|
||||||
|
// lblResult
|
||||||
|
//
|
||||||
|
lblResult.AutoSize = true;
|
||||||
|
lblResult.Location = new Point(54, 479);
|
||||||
|
lblResult.Name = "lblResult";
|
||||||
|
lblResult.Size = new Size(20, 17);
|
||||||
|
lblResult.TabIndex = 27;
|
||||||
|
lblResult.Text = "无";
|
||||||
|
//
|
||||||
|
// label15
|
||||||
|
//
|
||||||
|
label15.AutoSize = true;
|
||||||
|
label15.Location = new Point(6, 479);
|
||||||
|
label15.Name = "label15";
|
||||||
|
label15.Size = new Size(44, 17);
|
||||||
|
label15.TabIndex = 26;
|
||||||
|
label15.Text = "结果:";
|
||||||
|
//
|
||||||
|
// btnCreateLine
|
||||||
|
//
|
||||||
|
btnCreateLine.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnCreateLine.Location = new Point(6, 406);
|
||||||
|
btnCreateLine.Name = "btnCreateLine";
|
||||||
|
btnCreateLine.Size = new Size(186, 32);
|
||||||
|
btnCreateLine.TabIndex = 20;
|
||||||
|
btnCreateLine.Text = "创建直线";
|
||||||
|
btnCreateLine.UseVisualStyleBackColor = true;
|
||||||
|
btnCreateLine.Click += btnCreateLine_Click;
|
||||||
|
//
|
||||||
|
// btnCreateCircle
|
||||||
|
//
|
||||||
|
btnCreateCircle.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnCreateCircle.Location = new Point(6, 368);
|
||||||
|
btnCreateCircle.Name = "btnCreateCircle";
|
||||||
|
btnCreateCircle.Size = new Size(186, 32);
|
||||||
|
btnCreateCircle.TabIndex = 19;
|
||||||
|
btnCreateCircle.Text = "创建圆形";
|
||||||
|
btnCreateCircle.UseVisualStyleBackColor = true;
|
||||||
|
btnCreateCircle.Click += btnCreateCircle_Click;
|
||||||
|
//
|
||||||
|
// btnLoadImage
|
||||||
|
//
|
||||||
|
btnLoadImage.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnLoadImage.Location = new Point(6, 330);
|
||||||
|
btnLoadImage.Name = "btnLoadImage";
|
||||||
|
btnLoadImage.Size = new Size(186, 32);
|
||||||
|
btnLoadImage.TabIndex = 18;
|
||||||
|
btnLoadImage.Text = "打开图片";
|
||||||
|
btnLoadImage.UseVisualStyleBackColor = true;
|
||||||
|
btnLoadImage.Click += btnLoadImage_Click;
|
||||||
|
//
|
||||||
|
// label9
|
||||||
|
//
|
||||||
|
label9.AutoSize = true;
|
||||||
|
label9.Location = new Point(56, 525);
|
||||||
|
label9.Name = "label9";
|
||||||
|
label9.Size = new Size(32, 17);
|
||||||
|
label9.TabIndex = 17;
|
||||||
|
label9.Text = "0ms";
|
||||||
|
//
|
||||||
|
// btnExecute
|
||||||
|
//
|
||||||
|
btnExecute.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnExecute.Location = new Point(6, 444);
|
||||||
|
btnExecute.Name = "btnExecute";
|
||||||
|
btnExecute.Size = new Size(186, 32);
|
||||||
|
btnExecute.TabIndex = 15;
|
||||||
|
btnExecute.Text = "执行";
|
||||||
|
btnExecute.UseVisualStyleBackColor = true;
|
||||||
|
btnExecute.Click += btnExecute_Click;
|
||||||
|
//
|
||||||
|
// label10
|
||||||
|
//
|
||||||
|
label10.AutoSize = true;
|
||||||
|
label10.Location = new Point(6, 525);
|
||||||
|
label10.Name = "label10";
|
||||||
|
label10.Size = new Size(44, 17);
|
||||||
|
label10.TabIndex = 16;
|
||||||
|
label10.Text = "耗时:";
|
||||||
|
//
|
||||||
|
// groupBox2
|
||||||
|
//
|
||||||
|
groupBox2.Controls.Add(NumRectWidth1);
|
||||||
|
groupBox2.Controls.Add(label11);
|
||||||
|
groupBox2.Controls.Add(tbLineX2);
|
||||||
|
groupBox2.Controls.Add(label8);
|
||||||
|
groupBox2.Controls.Add(tbLineY2);
|
||||||
|
groupBox2.Controls.Add(label5);
|
||||||
|
groupBox2.Controls.Add(tbLineX1);
|
||||||
|
groupBox2.Controls.Add(tbLineY1);
|
||||||
|
groupBox2.Controls.Add(label6);
|
||||||
|
groupBox2.Controls.Add(label7);
|
||||||
|
groupBox2.Dock = DockStyle.Top;
|
||||||
|
groupBox2.Location = new Point(0, 152);
|
||||||
|
groupBox2.Name = "groupBox2";
|
||||||
|
groupBox2.Size = new Size(198, 172);
|
||||||
|
groupBox2.TabIndex = 13;
|
||||||
|
groupBox2.TabStop = false;
|
||||||
|
groupBox2.Text = "线参数";
|
||||||
|
//
|
||||||
|
// NumRectWidth1
|
||||||
|
//
|
||||||
|
NumRectWidth1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
NumRectWidth1.Location = new Point(56, 138);
|
||||||
|
NumRectWidth1.Maximum = new decimal(new int[] { 9000, 0, 0, 0 });
|
||||||
|
NumRectWidth1.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||||
|
NumRectWidth1.Name = "NumRectWidth1";
|
||||||
|
NumRectWidth1.Size = new Size(136, 23);
|
||||||
|
NumRectWidth1.TabIndex = 13;
|
||||||
|
NumRectWidth1.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// label11
|
||||||
|
//
|
||||||
|
label11.AutoSize = true;
|
||||||
|
label11.Location = new Point(6, 140);
|
||||||
|
label11.Name = "label11";
|
||||||
|
label11.Size = new Size(35, 17);
|
||||||
|
label11.TabIndex = 12;
|
||||||
|
label11.Text = "宽度:";
|
||||||
|
//
|
||||||
|
// tbLineX2
|
||||||
|
//
|
||||||
|
tbLineX2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLineX2.Location = new Point(56, 80);
|
||||||
|
tbLineX2.Name = "tbLineX2";
|
||||||
|
tbLineX2.Size = new Size(136, 23);
|
||||||
|
tbLineX2.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// label8
|
||||||
|
//
|
||||||
|
label8.AutoSize = true;
|
||||||
|
label8.Location = new Point(6, 83);
|
||||||
|
label8.Name = "label8";
|
||||||
|
label8.Size = new Size(26, 17);
|
||||||
|
label8.TabIndex = 8;
|
||||||
|
label8.Text = "X2:";
|
||||||
|
//
|
||||||
|
// tbLineY2
|
||||||
|
//
|
||||||
|
tbLineY2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLineY2.Location = new Point(56, 109);
|
||||||
|
tbLineY2.Name = "tbLineY2";
|
||||||
|
tbLineY2.Size = new Size(136, 23);
|
||||||
|
tbLineY2.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
label5.AutoSize = true;
|
||||||
|
label5.Location = new Point(6, 112);
|
||||||
|
label5.Name = "label5";
|
||||||
|
label5.Size = new Size(25, 17);
|
||||||
|
label5.TabIndex = 6;
|
||||||
|
label5.Text = "Y2:";
|
||||||
|
//
|
||||||
|
// tbLineX1
|
||||||
|
//
|
||||||
|
tbLineX1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLineX1.Location = new Point(56, 22);
|
||||||
|
tbLineX1.Name = "tbLineX1";
|
||||||
|
tbLineX1.Size = new Size(136, 23);
|
||||||
|
tbLineX1.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// tbLineY1
|
||||||
|
//
|
||||||
|
tbLineY1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLineY1.Location = new Point(56, 51);
|
||||||
|
tbLineY1.Name = "tbLineY1";
|
||||||
|
tbLineY1.Size = new Size(136, 23);
|
||||||
|
tbLineY1.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
label6.AutoSize = true;
|
||||||
|
label6.Location = new Point(6, 54);
|
||||||
|
label6.Name = "label6";
|
||||||
|
label6.Size = new Size(25, 17);
|
||||||
|
label6.TabIndex = 1;
|
||||||
|
label6.Text = "Y1:";
|
||||||
|
//
|
||||||
|
// label7
|
||||||
|
//
|
||||||
|
label7.AutoSize = true;
|
||||||
|
label7.Location = new Point(6, 25);
|
||||||
|
label7.Name = "label7";
|
||||||
|
label7.Size = new Size(26, 17);
|
||||||
|
label7.TabIndex = 0;
|
||||||
|
label7.Text = "X1:";
|
||||||
|
//
|
||||||
|
// groupBox1
|
||||||
|
//
|
||||||
|
groupBox1.Controls.Add(tbCircleX);
|
||||||
|
groupBox1.Controls.Add(tbCircleY);
|
||||||
|
groupBox1.Controls.Add(tbCircleR);
|
||||||
|
groupBox1.Controls.Add(label3);
|
||||||
|
groupBox1.Controls.Add(label2);
|
||||||
|
groupBox1.Controls.Add(label1);
|
||||||
|
groupBox1.Dock = DockStyle.Top;
|
||||||
|
groupBox1.Location = new Point(0, 36);
|
||||||
|
groupBox1.Name = "groupBox1";
|
||||||
|
groupBox1.Size = new Size(198, 116);
|
||||||
|
groupBox1.TabIndex = 12;
|
||||||
|
groupBox1.TabStop = false;
|
||||||
|
groupBox1.Text = "圆参数";
|
||||||
|
//
|
||||||
|
// tbCircleX
|
||||||
|
//
|
||||||
|
tbCircleX.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbCircleX.Location = new Point(56, 22);
|
||||||
|
tbCircleX.Name = "tbCircleX";
|
||||||
|
tbCircleX.Size = new Size(136, 23);
|
||||||
|
tbCircleX.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// tbCircleY
|
||||||
|
//
|
||||||
|
tbCircleY.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbCircleY.Location = new Point(56, 51);
|
||||||
|
tbCircleY.Name = "tbCircleY";
|
||||||
|
tbCircleY.Size = new Size(136, 23);
|
||||||
|
tbCircleY.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// tbCircleR
|
||||||
|
//
|
||||||
|
tbCircleR.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbCircleR.Location = new Point(56, 80);
|
||||||
|
tbCircleR.Name = "tbCircleR";
|
||||||
|
tbCircleR.Size = new Size(136, 23);
|
||||||
|
tbCircleR.TabIndex = 3;
|
||||||
|
//
|
||||||
|
// label3
|
||||||
|
//
|
||||||
|
label3.AutoSize = true;
|
||||||
|
label3.Location = new Point(3, 83);
|
||||||
|
label3.Name = "label3";
|
||||||
|
label3.Size = new Size(44, 17);
|
||||||
|
label3.TabIndex = 2;
|
||||||
|
label3.Text = "半径:";
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(6, 54);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(18, 17);
|
||||||
|
label2.TabIndex = 1;
|
||||||
|
label2.Text = "Y:";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(6, 25);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(19, 17);
|
||||||
|
label1.TabIndex = 0;
|
||||||
|
label1.Text = "X:";
|
||||||
|
//
|
||||||
|
// ctrlTitleBar
|
||||||
|
//
|
||||||
|
ctrlTitleBar.Dock = DockStyle.Top;
|
||||||
|
ctrlTitleBar.Location = new Point(0, 0);
|
||||||
|
ctrlTitleBar.MinimumSize = new Size(0, 36);
|
||||||
|
ctrlTitleBar.Name = "ctrlTitleBar";
|
||||||
|
ctrlTitleBar.Padding = new Padding(3);
|
||||||
|
ctrlTitleBar.Size = new Size(198, 36);
|
||||||
|
ctrlTitleBar.TabIndex = 11;
|
||||||
|
ctrlTitleBar.Title = "线圆测量";
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
panel1.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
panel1.Controls.Add(canvas);
|
||||||
|
panel1.Controls.Add(statusStrip1);
|
||||||
|
panel1.Dock = DockStyle.Fill;
|
||||||
|
panel1.Location = new Point(0, 0);
|
||||||
|
panel1.Name = "panel1";
|
||||||
|
panel1.Size = new Size(1076, 640);
|
||||||
|
panel1.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// canvas
|
||||||
|
//
|
||||||
|
canvas.AllowMultiSelect = false;
|
||||||
|
canvas.CreateMode = Canvas.Shape.ShapeTypeEnum.Polygon;
|
||||||
|
canvas.Dock = DockStyle.Fill;
|
||||||
|
canvas.Enabled = false;
|
||||||
|
canvas.FillDrawing = false;
|
||||||
|
canvas.Location = new Point(0, 0);
|
||||||
|
canvas.Margin = new Padding(2);
|
||||||
|
canvas.Name = "canvas";
|
||||||
|
canvas.OutsideShapes = (List<Canvas.Shape.FlyShape>)resources.GetObject("canvas.OutsideShapes");
|
||||||
|
canvas.Scale = 1F;
|
||||||
|
canvas.Shapes = (List<Canvas.Shape.FlyShape>)resources.GetObject("canvas.Shapes");
|
||||||
|
canvas.Size = new Size(1074, 616);
|
||||||
|
canvas.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// statusStrip1
|
||||||
|
//
|
||||||
|
statusStrip1.Items.AddRange(new ToolStripItem[] { lblStatus });
|
||||||
|
statusStrip1.Location = new Point(0, 616);
|
||||||
|
statusStrip1.Name = "statusStrip1";
|
||||||
|
statusStrip1.Size = new Size(1074, 22);
|
||||||
|
statusStrip1.TabIndex = 1;
|
||||||
|
statusStrip1.Text = "statusStrip1";
|
||||||
|
//
|
||||||
|
// lblStatus
|
||||||
|
//
|
||||||
|
lblStatus.Name = "lblStatus";
|
||||||
|
lblStatus.Size = new Size(44, 17);
|
||||||
|
lblStatus.Text = " ";
|
||||||
|
//
|
||||||
|
// btnSave
|
||||||
|
//
|
||||||
|
btnSave.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnSave.Location = new Point(6, 545);
|
||||||
|
btnSave.Name = "btnSave";
|
||||||
|
btnSave.Size = new Size(186, 32);
|
||||||
|
btnSave.TabIndex = 30;
|
||||||
|
btnSave.Text = "保存数据";
|
||||||
|
btnSave.UseVisualStyleBackColor = true;
|
||||||
|
btnSave.Click += btnSave_Click;
|
||||||
|
//
|
||||||
|
// GuideLineCircleCtrl
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
Controls.Add(splitContainer);
|
||||||
|
Controls.Add(lblElapsed);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Name = "GuideLineCircleCtrl";
|
||||||
|
Size = new Size(1280, 640);
|
||||||
|
Load += GuideLineCircleCtrl_Load;
|
||||||
|
splitContainer.Panel1.ResumeLayout(false);
|
||||||
|
splitContainer.Panel2.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)splitContainer).EndInit();
|
||||||
|
splitContainer.ResumeLayout(false);
|
||||||
|
panelGuide.ResumeLayout(false);
|
||||||
|
panelGuide.PerformLayout();
|
||||||
|
groupBox2.ResumeLayout(false);
|
||||||
|
groupBox2.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)NumRectWidth1).EndInit();
|
||||||
|
groupBox1.ResumeLayout(false);
|
||||||
|
groupBox1.PerformLayout();
|
||||||
|
panel1.ResumeLayout(false);
|
||||||
|
panel1.PerformLayout();
|
||||||
|
statusStrip1.ResumeLayout(false);
|
||||||
|
statusStrip1.PerformLayout();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label lblElapsed;
|
||||||
|
private Label label4;
|
||||||
|
|
||||||
|
private SplitContainer splitContainer;
|
||||||
|
private Panel panelGuide;
|
||||||
|
private Panel panel1;
|
||||||
|
private Canvas.UI.FlyCanvas canvas;
|
||||||
|
private StatusStrip statusStrip1;
|
||||||
|
private ToolStripStatusLabel lblStatus;
|
||||||
|
private GroupBox groupBox2;
|
||||||
|
private TextBox tbLineX2;
|
||||||
|
private Label label8;
|
||||||
|
private TextBox tbLineY2;
|
||||||
|
private Label label5;
|
||||||
|
private TextBox tbLineX1;
|
||||||
|
private TextBox tbLineY1;
|
||||||
|
private Label label6;
|
||||||
|
private Label label7;
|
||||||
|
private GroupBox groupBox1;
|
||||||
|
private TextBox tbCircleX;
|
||||||
|
private TextBox tbCircleY;
|
||||||
|
private TextBox tbCircleR;
|
||||||
|
private Label label3;
|
||||||
|
private Label label2;
|
||||||
|
private Label label1;
|
||||||
|
private SizeCtrlTitleBar ctrlTitleBar;
|
||||||
|
private Button btnCreateCircle;
|
||||||
|
private Button btnLoadImage;
|
||||||
|
private Label label9;
|
||||||
|
private Button btnExecute;
|
||||||
|
private Label label10;
|
||||||
|
private Button btnCreateLine;
|
||||||
|
private TextBox tbRectWidth1;
|
||||||
|
private Label label11;
|
||||||
|
private NumericUpDown NumRectWidth1;
|
||||||
|
private Label lblDistance;
|
||||||
|
private Label label17;
|
||||||
|
private Label lblResult;
|
||||||
|
private Label label15;
|
||||||
|
private Button btnSave;
|
||||||
|
}
|
||||||
|
}
|
449
CanFly/UI/SizePanel/SizeGuideLineCircleCtrl.cs
Normal file
449
CanFly/UI/SizePanel/SizeGuideLineCircleCtrl.cs
Normal file
@ -0,0 +1,449 @@
|
|||||||
|
using CanFly.Canvas.Helper;
|
||||||
|
using CanFly.Canvas.Shape;
|
||||||
|
using CanFly.Canvas.UI;
|
||||||
|
using CanFly.Helper;
|
||||||
|
using HalconDotNet;
|
||||||
|
using OpenCvSharp;
|
||||||
|
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 CanFly.UI.SizePanel
|
||||||
|
{
|
||||||
|
public partial class SizeGuideLineCircleCtrl : SizeBaseGuideControl
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
private FlyShape? _circle;
|
||||||
|
private FlyShape? _line;
|
||||||
|
|
||||||
|
|
||||||
|
private float _lineX1;
|
||||||
|
private float _lineY1;
|
||||||
|
private float _lineX2;
|
||||||
|
private float _lineY2;
|
||||||
|
private float _lineWidth;
|
||||||
|
|
||||||
|
|
||||||
|
private float _circleX;
|
||||||
|
private float _circleY;
|
||||||
|
private float _circleR;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected override string GetScriptFileName() => "LineToCircle.hdvp";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public SizeGuideLineCircleCtrl()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
this.canvas.mouseMoved += Canvas_mouseMoved;
|
||||||
|
this.canvas.OnShapeUpdateEvent += UpdateShape;
|
||||||
|
this.canvas.selectionChanged += Canvas_selectionChanged;
|
||||||
|
|
||||||
|
this.canvas.OnShapeMoving += Canvas_OnShapeMoving;
|
||||||
|
this.canvas.newShape += Canvas_newShape;
|
||||||
|
|
||||||
|
this.ctrlTitleBar.OnCloseClicked += OnControlClose;
|
||||||
|
|
||||||
|
NumRectWidth1.ValueChanged -= NumRectWidth1_ValueChanged;
|
||||||
|
NumRectWidth1.Value = 40;
|
||||||
|
NumRectWidth1.ValueChanged += NumRectWidth1_ValueChanged;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected override void UpdateShape(FlyShape shape)
|
||||||
|
{
|
||||||
|
switch (shape.ShapeType)
|
||||||
|
{
|
||||||
|
case ShapeTypeEnum.Line:
|
||||||
|
this._line = shape;
|
||||||
|
_line.IsDrawLineVirtualRect = true;
|
||||||
|
var pts = this._line.Points;
|
||||||
|
|
||||||
|
_lineX1 = pts[0].X;
|
||||||
|
_lineY1 = pts[0].Y;
|
||||||
|
_lineX2 = pts[1].X;
|
||||||
|
_lineY2 = pts[1].Y;
|
||||||
|
_lineWidth = shape.LineVirtualRectWidth;
|
||||||
|
|
||||||
|
tbLineX1.Text = _lineX1.ToString("F3");
|
||||||
|
tbLineY1.Text = _lineY1.ToString("F3");
|
||||||
|
tbLineX2.Text = _lineX2.ToString("F3");
|
||||||
|
tbLineY2.Text = _lineY2.ToString("F3");
|
||||||
|
// NumRectWidth1.Value = (decimal)_lineWidth;
|
||||||
|
break;
|
||||||
|
case ShapeTypeEnum.Circle:
|
||||||
|
this._circle = shape;
|
||||||
|
|
||||||
|
_circleX = shape.Points[0].X;
|
||||||
|
_circleY = shape.Points[0].Y;
|
||||||
|
_circleR = PointHelper.Distance(shape.Points[0], shape.Points[1]);
|
||||||
|
|
||||||
|
this.tbCircleX.Text = _circleX.ToString("F3");
|
||||||
|
this.tbCircleY.Text = _circleY.ToString("F3");
|
||||||
|
this.tbCircleR.Text = _circleR.ToString("F3");
|
||||||
|
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void GuideLineCircleCtrl_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_mouseMoved(PointF pos)
|
||||||
|
{
|
||||||
|
if (InvokeRequired)
|
||||||
|
{
|
||||||
|
Invoke(Canvas_mouseMoved, pos);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lblStatus.Text = $"X:{pos.X}, Y:{pos.Y}";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_selectionChanged(List<FlyShape> shapes)
|
||||||
|
{
|
||||||
|
//if (shapes.Count != 1)
|
||||||
|
//{
|
||||||
|
// // panelGuide.Controls.Clear();
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
//SwitchGuideForm(shapes[0].ShapeType);
|
||||||
|
// Canvas_OnShapeUpdateEvent(shapes[0]);
|
||||||
|
|
||||||
|
if (shapes.Count != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UpdateShape(shapes[0]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_OnShapeMoving(List<FlyShape> shapes)
|
||||||
|
{
|
||||||
|
if (shapes.Count != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateShape(shapes[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void btnCreateCircle_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (this.canvas.pixmap == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先打开图片");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.tbCircleX.Text = string.Empty;
|
||||||
|
this.tbCircleY.Text = string.Empty;
|
||||||
|
this.tbCircleR.Text = string.Empty;
|
||||||
|
this.canvas.Shapes.RemoveAll(shp => shp.ShapeType == ShapeTypeEnum.Circle);
|
||||||
|
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
this.canvas.StartDraw(ShapeTypeEnum.Circle);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void btnCreateLine_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (this.canvas.pixmap == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先打开图片");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tbLineX1.Text = string.Empty;
|
||||||
|
tbLineY1.Text = string.Empty;
|
||||||
|
tbLineX2.Text = string.Empty;
|
||||||
|
tbLineY2.Text = string.Empty;
|
||||||
|
|
||||||
|
this.canvas.Shapes.RemoveAll(shp => shp.ShapeType == ShapeTypeEnum.Line);
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
this.canvas.StartDraw(ShapeTypeEnum.Line);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void btnLoadImage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OpenImageFile(bitmap =>
|
||||||
|
{
|
||||||
|
this.canvas.LoadPixmap(bitmap);
|
||||||
|
this.canvas.Enabled = true;
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_newShape()
|
||||||
|
{
|
||||||
|
this.canvas.StopDraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string strarrayX=string.Empty;
|
||||||
|
string strarrayY=string.Empty;
|
||||||
|
private void btnExecute_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (this.canvas.pixmap == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先打开图片");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.tbLineX1.Text.Trim().Length == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先创建直线");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.tbLineX1.Text.Trim().Length == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先创建圆形");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.canvas.OutsideShapes.Clear();
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
|
||||||
|
flag = new List<double>();
|
||||||
|
Distance = new List<double>();
|
||||||
|
fRowCenter = new List<double>();
|
||||||
|
fColCenter = new List<double>();
|
||||||
|
fRadius = new List<double>();
|
||||||
|
RowBegin = new List<double>();
|
||||||
|
ColBegin = new List<double>();
|
||||||
|
RowEnd = new List<double>();
|
||||||
|
ColEnd = new List<double>();
|
||||||
|
Dictionary<string, HObject> inputImg = new Dictionary<string, HObject>();
|
||||||
|
|
||||||
|
if (hImage == null)
|
||||||
|
{
|
||||||
|
HOperatorSet.ReadImage(out hImage, CurrentImageFile);
|
||||||
|
}
|
||||||
|
inputImg["INPUT_Image"] = hImage;
|
||||||
|
|
||||||
|
Dictionary<string, HTuple> inputPara = new Dictionary<string, HTuple>();
|
||||||
|
|
||||||
|
PointF[] Points = this._line.LineVirtualRectPoints;
|
||||||
|
PointF Point1 = Points[0];
|
||||||
|
PointF Point2 = Points[1];
|
||||||
|
PointF Point3 = Points[2];
|
||||||
|
PointF Point4 = Points[3];
|
||||||
|
PointF Point5 = Points[0];
|
||||||
|
|
||||||
|
float x1 = Point1.X;
|
||||||
|
float y1 = Point1.Y;
|
||||||
|
|
||||||
|
float x2 = Point2.X;
|
||||||
|
float y2 = Point2.Y;
|
||||||
|
|
||||||
|
float x3 = Point3.X;
|
||||||
|
float y3 = Point3.Y;
|
||||||
|
|
||||||
|
float x4 = Point4.X;
|
||||||
|
float y4 = Point4.Y;
|
||||||
|
|
||||||
|
float x5 = Point5.X;
|
||||||
|
float y5 = Point5.Y;
|
||||||
|
|
||||||
|
|
||||||
|
float[] arrayX = new float[] { x1, x2, x3, x4, x5 };
|
||||||
|
HTuple hTupleArrayX = new HTuple(arrayX);
|
||||||
|
|
||||||
|
float[] arrayY = new float[] { y1, y2, y3, y4, y5 };
|
||||||
|
HTuple hTupleArrayY = new HTuple(arrayY);
|
||||||
|
|
||||||
|
strarrayX=string.Join(",", arrayX);
|
||||||
|
strarrayY=string.Join(",", arrayY);
|
||||||
|
|
||||||
|
inputPara["LX"] = _lineX1;
|
||||||
|
inputPara["LY"] = _lineY1;
|
||||||
|
inputPara["RX"] = _lineX2;
|
||||||
|
inputPara["RY"] = _lineY2;
|
||||||
|
inputPara["XCenter"] = _circleX;
|
||||||
|
inputPara["YCenter"] = _circleY;
|
||||||
|
inputPara["Radius"] = _circleR;
|
||||||
|
inputPara["Line_XRect"] = hTupleArrayX;
|
||||||
|
inputPara["Line_YRect"] = hTupleArrayY;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
List<string> outputKeys = new List<string>()
|
||||||
|
{
|
||||||
|
"OUTPUT_Flag",
|
||||||
|
"distance",
|
||||||
|
"fRowCenter",
|
||||||
|
"fColCenter",
|
||||||
|
"fRadius",
|
||||||
|
"RowBegin",
|
||||||
|
"ColBegin",
|
||||||
|
"RowEnd",
|
||||||
|
"ColEnd"
|
||||||
|
};
|
||||||
|
|
||||||
|
ExecuteHScript(
|
||||||
|
inputImg,
|
||||||
|
inputPara,
|
||||||
|
outputKeys);
|
||||||
|
|
||||||
|
}
|
||||||
|
List<double> flag = new List<double>();
|
||||||
|
List<double> Distance = new List<double>();
|
||||||
|
List<double> fRowCenter = new List<double>();
|
||||||
|
List<double> fColCenter = new List<double>();
|
||||||
|
List<double> fRadius = new List<double>();
|
||||||
|
List<double> RowBegin = new List<double>();
|
||||||
|
List<double> ColBegin = new List<double>();
|
||||||
|
List<double> RowEnd = new List<double>();
|
||||||
|
List<double> ColEnd = new List<double>();
|
||||||
|
protected override void OnExecuteHScriptResult(
|
||||||
|
bool success,
|
||||||
|
Dictionary<string, HTuple> resultDic,
|
||||||
|
int timeElasped)
|
||||||
|
{
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//"OUTPUT_Flag",
|
||||||
|
// "distance",
|
||||||
|
// "fRowCenter",
|
||||||
|
// "fColCenter",
|
||||||
|
// "fRadius",
|
||||||
|
// "RowBegin",
|
||||||
|
// "ColBegin",
|
||||||
|
// "RowEnd",
|
||||||
|
// "ColEnd"
|
||||||
|
|
||||||
|
flag = resultDic["OUTPUT_Flag"].HTupleToDouble();
|
||||||
|
Distance = resultDic["distance"].HTupleToDouble();
|
||||||
|
fRowCenter = resultDic["fRowCenter"].HTupleToDouble();
|
||||||
|
fColCenter = resultDic["fColCenter"].HTupleToDouble();
|
||||||
|
fRadius = resultDic["fRadius"].HTupleToDouble();
|
||||||
|
RowBegin = resultDic["RowBegin"].HTupleToDouble();
|
||||||
|
ColBegin = resultDic["ColBegin"].HTupleToDouble();
|
||||||
|
RowEnd = resultDic["RowEnd"].HTupleToDouble();
|
||||||
|
ColEnd = resultDic["ColEnd"].HTupleToDouble();
|
||||||
|
|
||||||
|
|
||||||
|
if (flag.Count > 0)
|
||||||
|
{
|
||||||
|
lblResult.Text = flag[0].ToString();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lblResult.Text = "无";
|
||||||
|
}
|
||||||
|
if (Distance.Count > 0)
|
||||||
|
{
|
||||||
|
lblDistance.Text = Distance[0].ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lblDistance.Text = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag.Count > 0 && Distance.Count > 0 && fRowCenter.Count > 0 && fColCenter.Count > 0 && fRadius.Count > 0 && RowBegin.Count > 0 && ColBegin.Count > 0 && RowEnd.Count > 0 && ColEnd.Count > 0)
|
||||||
|
{
|
||||||
|
float width = 0;
|
||||||
|
this.canvas.DrawLine(new PointF((float)ColBegin[0], (float)RowBegin[0]), new PointF((float)ColEnd[0], (float)RowEnd[0]), width);
|
||||||
|
this.canvas.DrawCircle(new PointF((float)fColCenter[0], (float)fRowCenter[0]), (float)fRadius[0]);
|
||||||
|
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
lblElapsed.Text = $"{timeElasped} ms";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void NumRectWidth1_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_line != null)
|
||||||
|
{
|
||||||
|
//_line1.IsDrawLineVirtualRect = true;
|
||||||
|
_line.LineVirtualRectWidth = (float)NumRectWidth1.Value;
|
||||||
|
UpdateShape(_line);
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (lblResult.Text.Equals("无"))
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先进行绘制");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (lblResult.Text != "0")
|
||||||
|
{
|
||||||
|
MessageBox.Show("测量计算错误,无法保存");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string input = $"LX:{_lineX1};" +
|
||||||
|
$"LY:{_lineY1};" +
|
||||||
|
$"RX:{_lineX2};" +
|
||||||
|
$"RY:{_lineY2};" +
|
||||||
|
$"XCenter:{_circleX};" +
|
||||||
|
$"YCenter:{_circleY};" +
|
||||||
|
$"Radius:{_circleR};" +
|
||||||
|
$"Line_XRect:{strarrayX};"+
|
||||||
|
$"Line_YRect:{strarrayY}";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
string result = $"distance:{Distance[0]};";
|
||||||
|
DataToTriggerEvent(input, result);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
145
CanFly/UI/SizePanel/SizeGuideLineCircleCtrl.resx
Normal file
145
CanFly/UI/SizePanel/SizeGuideLineCircleCtrl.resx
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<data name="canvas.OutsideShapes" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>
|
||||||
|
AAEAAAD/////AQAAAAAAAAAMAgAAAERDYW5GbHkuQ2FudmFzLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1
|
||||||
|
cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAQBAAAAdlN5c3RlbS5Db2xsZWN0aW9ucy5HZW5l
|
||||||
|
cmljLkxpc3RgMVtbQ2FuRmx5LkNhbnZhcy5TaGFwZS5GbHlTaGFwZSwgQ2FuRmx5LkNhbnZhcywgQ3Vs
|
||||||
|
dHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsXV0DAAAABl9pdGVtcwVfc2l6ZQhfdmVyc2lv
|
||||||
|
bgQAAB5DYW5GbHkuQ2FudmFzLlNoYXBlLkZseVNoYXBlW10CAAAACAgJAwAAAAAAAAAAAAAADAQAAAAz
|
||||||
|
Q2FuRmx5LkNhbnZhcywgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsBwMAAAAAAQAA
|
||||||
|
AAAAAAAEHENhbkZseS5DYW52YXMuU2hhcGUuRmx5U2hhcGUEAAAACw==
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<data name="canvas.Shapes" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>
|
||||||
|
AAEAAAD/////AQAAAAAAAAAMAgAAAERDYW5GbHkuQ2FudmFzLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1
|
||||||
|
cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAQBAAAAdlN5c3RlbS5Db2xsZWN0aW9ucy5HZW5l
|
||||||
|
cmljLkxpc3RgMVtbQ2FuRmx5LkNhbnZhcy5TaGFwZS5GbHlTaGFwZSwgQ2FuRmx5LkNhbnZhcywgQ3Vs
|
||||||
|
dHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsXV0DAAAABl9pdGVtcwVfc2l6ZQhfdmVyc2lv
|
||||||
|
bgQAAB5DYW5GbHkuQ2FudmFzLlNoYXBlLkZseVNoYXBlW10CAAAACAgJAwAAAAAAAAAAAAAADAQAAAAz
|
||||||
|
Q2FuRmx5LkNhbnZhcywgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsBwMAAAAAAQAA
|
||||||
|
AAAAAAAEHENhbkZseS5DYW52YXMuU2hhcGUuRmx5U2hhcGUEAAAACw==
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
427
CanFly/UI/SizePanel/SizeGuideLineCtrl.Designer.cs
generated
Normal file
427
CanFly/UI/SizePanel/SizeGuideLineCtrl.Designer.cs
generated
Normal file
@ -0,0 +1,427 @@
|
|||||||
|
namespace CanFly.UI.SizePanel
|
||||||
|
{
|
||||||
|
partial class SizeGuideLineCtrl
|
||||||
|
{
|
||||||
|
/// <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(SizeGuideLineCtrl));
|
||||||
|
lblElapsed = new Label();
|
||||||
|
label4 = new Label();
|
||||||
|
splitContainer = new SplitContainer();
|
||||||
|
panelGuide = new Panel();
|
||||||
|
btnSave = new Button();
|
||||||
|
lblResult = new Label();
|
||||||
|
label1 = new Label();
|
||||||
|
btnCreateLine = new Button();
|
||||||
|
btnLoadImage = new Button();
|
||||||
|
label9 = new Label();
|
||||||
|
btnExecute = new Button();
|
||||||
|
label10 = new Label();
|
||||||
|
groupBox2 = new GroupBox();
|
||||||
|
NumRectWidth1 = new NumericUpDown();
|
||||||
|
label11 = new Label();
|
||||||
|
tbLineX2 = new TextBox();
|
||||||
|
label8 = new Label();
|
||||||
|
tbLineY2 = new TextBox();
|
||||||
|
label5 = new Label();
|
||||||
|
tbLineX1 = new TextBox();
|
||||||
|
tbLineY1 = new TextBox();
|
||||||
|
label6 = new Label();
|
||||||
|
label7 = new Label();
|
||||||
|
ctrlTitleBar = new SizeCtrlTitleBar();
|
||||||
|
panel1 = new Panel();
|
||||||
|
canvas = new Canvas.UI.FlyCanvas();
|
||||||
|
statusStrip1 = new StatusStrip();
|
||||||
|
lblStatus = new ToolStripStatusLabel();
|
||||||
|
((System.ComponentModel.ISupportInitialize)splitContainer).BeginInit();
|
||||||
|
splitContainer.Panel1.SuspendLayout();
|
||||||
|
splitContainer.Panel2.SuspendLayout();
|
||||||
|
splitContainer.SuspendLayout();
|
||||||
|
panelGuide.SuspendLayout();
|
||||||
|
groupBox2.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)NumRectWidth1).BeginInit();
|
||||||
|
panel1.SuspendLayout();
|
||||||
|
statusStrip1.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// lblElapsed
|
||||||
|
//
|
||||||
|
lblElapsed.AutoSize = true;
|
||||||
|
lblElapsed.Location = new Point(50, 328);
|
||||||
|
lblElapsed.Name = "lblElapsed";
|
||||||
|
lblElapsed.Size = new Size(32, 17);
|
||||||
|
lblElapsed.TabIndex = 9;
|
||||||
|
lblElapsed.Text = "0ms";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(0, 328);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(44, 17);
|
||||||
|
label4.TabIndex = 8;
|
||||||
|
label4.Text = "耗时:";
|
||||||
|
//
|
||||||
|
// splitContainer
|
||||||
|
//
|
||||||
|
splitContainer.Dock = DockStyle.Fill;
|
||||||
|
splitContainer.Location = new Point(0, 0);
|
||||||
|
splitContainer.Name = "splitContainer";
|
||||||
|
//
|
||||||
|
// splitContainer.Panel1
|
||||||
|
//
|
||||||
|
splitContainer.Panel1.Controls.Add(panelGuide);
|
||||||
|
splitContainer.Panel1MinSize = 150;
|
||||||
|
//
|
||||||
|
// splitContainer.Panel2
|
||||||
|
//
|
||||||
|
splitContainer.Panel2.Controls.Add(panel1);
|
||||||
|
splitContainer.Size = new Size(1280, 640);
|
||||||
|
splitContainer.SplitterDistance = 200;
|
||||||
|
splitContainer.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// panelGuide
|
||||||
|
//
|
||||||
|
panelGuide.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
panelGuide.Controls.Add(btnSave);
|
||||||
|
panelGuide.Controls.Add(lblResult);
|
||||||
|
panelGuide.Controls.Add(label1);
|
||||||
|
panelGuide.Controls.Add(btnCreateLine);
|
||||||
|
panelGuide.Controls.Add(btnLoadImage);
|
||||||
|
panelGuide.Controls.Add(label9);
|
||||||
|
panelGuide.Controls.Add(btnExecute);
|
||||||
|
panelGuide.Controls.Add(label10);
|
||||||
|
panelGuide.Controls.Add(groupBox2);
|
||||||
|
panelGuide.Controls.Add(ctrlTitleBar);
|
||||||
|
panelGuide.Dock = DockStyle.Fill;
|
||||||
|
panelGuide.Location = new Point(0, 0);
|
||||||
|
panelGuide.Name = "panelGuide";
|
||||||
|
panelGuide.Size = new Size(200, 640);
|
||||||
|
panelGuide.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// btnSave
|
||||||
|
//
|
||||||
|
btnSave.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnSave.Location = new Point(6, 390);
|
||||||
|
btnSave.Name = "btnSave";
|
||||||
|
btnSave.Size = new Size(186, 32);
|
||||||
|
btnSave.TabIndex = 23;
|
||||||
|
btnSave.Text = "保存数据";
|
||||||
|
btnSave.UseVisualStyleBackColor = true;
|
||||||
|
btnSave.Click += btnSave_Click;
|
||||||
|
//
|
||||||
|
// lblResult
|
||||||
|
//
|
||||||
|
lblResult.AutoSize = true;
|
||||||
|
lblResult.Location = new Point(59, 354);
|
||||||
|
lblResult.Name = "lblResult";
|
||||||
|
lblResult.Size = new Size(20, 17);
|
||||||
|
lblResult.TabIndex = 22;
|
||||||
|
lblResult.Text = "无";
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(9, 354);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(44, 17);
|
||||||
|
label1.TabIndex = 21;
|
||||||
|
label1.Text = "结果:";
|
||||||
|
//
|
||||||
|
// btnCreateLine
|
||||||
|
//
|
||||||
|
btnCreateLine.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnCreateLine.Location = new Point(9, 252);
|
||||||
|
btnCreateLine.Name = "btnCreateLine";
|
||||||
|
btnCreateLine.Size = new Size(186, 32);
|
||||||
|
btnCreateLine.TabIndex = 20;
|
||||||
|
btnCreateLine.Text = "创建直线";
|
||||||
|
btnCreateLine.UseVisualStyleBackColor = true;
|
||||||
|
btnCreateLine.Click += btnCreateLine_Click;
|
||||||
|
//
|
||||||
|
// btnLoadImage
|
||||||
|
//
|
||||||
|
btnLoadImage.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnLoadImage.Location = new Point(6, 214);
|
||||||
|
btnLoadImage.Name = "btnLoadImage";
|
||||||
|
btnLoadImage.Size = new Size(186, 32);
|
||||||
|
btnLoadImage.TabIndex = 18;
|
||||||
|
btnLoadImage.Text = "打开图片";
|
||||||
|
btnLoadImage.UseVisualStyleBackColor = true;
|
||||||
|
btnLoadImage.Click += btnLoadImage_Click;
|
||||||
|
//
|
||||||
|
// label9
|
||||||
|
//
|
||||||
|
label9.AutoSize = true;
|
||||||
|
label9.Location = new Point(59, 325);
|
||||||
|
label9.Name = "label9";
|
||||||
|
label9.Size = new Size(32, 17);
|
||||||
|
label9.TabIndex = 17;
|
||||||
|
label9.Text = "0ms";
|
||||||
|
//
|
||||||
|
// btnExecute
|
||||||
|
//
|
||||||
|
btnExecute.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnExecute.Location = new Point(9, 290);
|
||||||
|
btnExecute.Name = "btnExecute";
|
||||||
|
btnExecute.Size = new Size(186, 32);
|
||||||
|
btnExecute.TabIndex = 15;
|
||||||
|
btnExecute.Text = "执行";
|
||||||
|
btnExecute.UseVisualStyleBackColor = true;
|
||||||
|
btnExecute.Click += btnExecute_Click;
|
||||||
|
//
|
||||||
|
// label10
|
||||||
|
//
|
||||||
|
label10.AutoSize = true;
|
||||||
|
label10.Location = new Point(9, 325);
|
||||||
|
label10.Name = "label10";
|
||||||
|
label10.Size = new Size(44, 17);
|
||||||
|
label10.TabIndex = 16;
|
||||||
|
label10.Text = "耗时:";
|
||||||
|
//
|
||||||
|
// groupBox2
|
||||||
|
//
|
||||||
|
groupBox2.Controls.Add(NumRectWidth1);
|
||||||
|
groupBox2.Controls.Add(label11);
|
||||||
|
groupBox2.Controls.Add(tbLineX2);
|
||||||
|
groupBox2.Controls.Add(label8);
|
||||||
|
groupBox2.Controls.Add(tbLineY2);
|
||||||
|
groupBox2.Controls.Add(label5);
|
||||||
|
groupBox2.Controls.Add(tbLineX1);
|
||||||
|
groupBox2.Controls.Add(tbLineY1);
|
||||||
|
groupBox2.Controls.Add(label6);
|
||||||
|
groupBox2.Controls.Add(label7);
|
||||||
|
groupBox2.Dock = DockStyle.Top;
|
||||||
|
groupBox2.Location = new Point(0, 36);
|
||||||
|
groupBox2.Name = "groupBox2";
|
||||||
|
groupBox2.Size = new Size(198, 172);
|
||||||
|
groupBox2.TabIndex = 13;
|
||||||
|
groupBox2.TabStop = false;
|
||||||
|
groupBox2.Text = "线参数";
|
||||||
|
//
|
||||||
|
// NumRectWidth1
|
||||||
|
//
|
||||||
|
NumRectWidth1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
NumRectWidth1.Location = new Point(56, 138);
|
||||||
|
NumRectWidth1.Maximum = new decimal(new int[] { 9000, 0, 0, 0 });
|
||||||
|
NumRectWidth1.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||||
|
NumRectWidth1.Name = "NumRectWidth1";
|
||||||
|
NumRectWidth1.Size = new Size(136, 23);
|
||||||
|
NumRectWidth1.TabIndex = 13;
|
||||||
|
NumRectWidth1.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// label11
|
||||||
|
//
|
||||||
|
label11.AutoSize = true;
|
||||||
|
label11.Location = new Point(6, 140);
|
||||||
|
label11.Name = "label11";
|
||||||
|
label11.Size = new Size(35, 17);
|
||||||
|
label11.TabIndex = 12;
|
||||||
|
label11.Text = "宽度:";
|
||||||
|
//
|
||||||
|
// tbLineX2
|
||||||
|
//
|
||||||
|
tbLineX2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLineX2.Location = new Point(56, 80);
|
||||||
|
tbLineX2.Name = "tbLineX2";
|
||||||
|
tbLineX2.Size = new Size(136, 23);
|
||||||
|
tbLineX2.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// label8
|
||||||
|
//
|
||||||
|
label8.AutoSize = true;
|
||||||
|
label8.Location = new Point(6, 83);
|
||||||
|
label8.Name = "label8";
|
||||||
|
label8.Size = new Size(26, 17);
|
||||||
|
label8.TabIndex = 8;
|
||||||
|
label8.Text = "X2:";
|
||||||
|
//
|
||||||
|
// tbLineY2
|
||||||
|
//
|
||||||
|
tbLineY2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLineY2.Location = new Point(56, 109);
|
||||||
|
tbLineY2.Name = "tbLineY2";
|
||||||
|
tbLineY2.Size = new Size(136, 23);
|
||||||
|
tbLineY2.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
label5.AutoSize = true;
|
||||||
|
label5.Location = new Point(6, 112);
|
||||||
|
label5.Name = "label5";
|
||||||
|
label5.Size = new Size(25, 17);
|
||||||
|
label5.TabIndex = 6;
|
||||||
|
label5.Text = "Y2:";
|
||||||
|
//
|
||||||
|
// tbLineX1
|
||||||
|
//
|
||||||
|
tbLineX1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLineX1.Location = new Point(56, 22);
|
||||||
|
tbLineX1.Name = "tbLineX1";
|
||||||
|
tbLineX1.Size = new Size(136, 23);
|
||||||
|
tbLineX1.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// tbLineY1
|
||||||
|
//
|
||||||
|
tbLineY1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLineY1.Location = new Point(56, 51);
|
||||||
|
tbLineY1.Name = "tbLineY1";
|
||||||
|
tbLineY1.Size = new Size(136, 23);
|
||||||
|
tbLineY1.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
label6.AutoSize = true;
|
||||||
|
label6.Location = new Point(6, 54);
|
||||||
|
label6.Name = "label6";
|
||||||
|
label6.Size = new Size(25, 17);
|
||||||
|
label6.TabIndex = 1;
|
||||||
|
label6.Text = "Y1:";
|
||||||
|
//
|
||||||
|
// label7
|
||||||
|
//
|
||||||
|
label7.AutoSize = true;
|
||||||
|
label7.Location = new Point(6, 25);
|
||||||
|
label7.Name = "label7";
|
||||||
|
label7.Size = new Size(26, 17);
|
||||||
|
label7.TabIndex = 0;
|
||||||
|
label7.Text = "X1:";
|
||||||
|
//
|
||||||
|
// ctrlTitleBar
|
||||||
|
//
|
||||||
|
ctrlTitleBar.Dock = DockStyle.Top;
|
||||||
|
ctrlTitleBar.Location = new Point(0, 0);
|
||||||
|
ctrlTitleBar.MinimumSize = new Size(0, 36);
|
||||||
|
ctrlTitleBar.Name = "ctrlTitleBar";
|
||||||
|
ctrlTitleBar.Padding = new Padding(3);
|
||||||
|
ctrlTitleBar.Size = new Size(198, 36);
|
||||||
|
ctrlTitleBar.TabIndex = 11;
|
||||||
|
ctrlTitleBar.Title = "直线测量";
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
panel1.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
panel1.Controls.Add(canvas);
|
||||||
|
panel1.Controls.Add(statusStrip1);
|
||||||
|
panel1.Dock = DockStyle.Fill;
|
||||||
|
panel1.Location = new Point(0, 0);
|
||||||
|
panel1.Name = "panel1";
|
||||||
|
panel1.Size = new Size(1076, 640);
|
||||||
|
panel1.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// canvas
|
||||||
|
//
|
||||||
|
canvas.AllowMultiSelect = false;
|
||||||
|
canvas.CreateMode = Canvas.Shape.ShapeTypeEnum.Polygon;
|
||||||
|
canvas.Dock = DockStyle.Fill;
|
||||||
|
canvas.Enabled = false;
|
||||||
|
canvas.FillDrawing = false;
|
||||||
|
canvas.Location = new Point(0, 0);
|
||||||
|
canvas.Margin = new Padding(2);
|
||||||
|
canvas.Name = "canvas";
|
||||||
|
canvas.OutsideShapes = (List<Canvas.Shape.FlyShape>)resources.GetObject("canvas.OutsideShapes");
|
||||||
|
canvas.Scale = 1F;
|
||||||
|
canvas.Shapes = (List<Canvas.Shape.FlyShape>)resources.GetObject("canvas.Shapes");
|
||||||
|
canvas.Size = new Size(1074, 616);
|
||||||
|
canvas.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// statusStrip1
|
||||||
|
//
|
||||||
|
statusStrip1.Items.AddRange(new ToolStripItem[] { lblStatus });
|
||||||
|
statusStrip1.Location = new Point(0, 616);
|
||||||
|
statusStrip1.Name = "statusStrip1";
|
||||||
|
statusStrip1.Size = new Size(1074, 22);
|
||||||
|
statusStrip1.TabIndex = 1;
|
||||||
|
statusStrip1.Text = "statusStrip1";
|
||||||
|
//
|
||||||
|
// lblStatus
|
||||||
|
//
|
||||||
|
lblStatus.Name = "lblStatus";
|
||||||
|
lblStatus.Size = new Size(44, 17);
|
||||||
|
lblStatus.Text = " ";
|
||||||
|
//
|
||||||
|
// GuideLineCtrl
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
Controls.Add(splitContainer);
|
||||||
|
Controls.Add(lblElapsed);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Name = "GuideLineCtrl";
|
||||||
|
Size = new Size(1280, 640);
|
||||||
|
Load += GuideLineCircleCtrl_Load;
|
||||||
|
splitContainer.Panel1.ResumeLayout(false);
|
||||||
|
splitContainer.Panel2.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)splitContainer).EndInit();
|
||||||
|
splitContainer.ResumeLayout(false);
|
||||||
|
panelGuide.ResumeLayout(false);
|
||||||
|
panelGuide.PerformLayout();
|
||||||
|
groupBox2.ResumeLayout(false);
|
||||||
|
groupBox2.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)NumRectWidth1).EndInit();
|
||||||
|
panel1.ResumeLayout(false);
|
||||||
|
panel1.PerformLayout();
|
||||||
|
statusStrip1.ResumeLayout(false);
|
||||||
|
statusStrip1.PerformLayout();
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private Label lblElapsed;
|
||||||
|
private Label label4;
|
||||||
|
|
||||||
|
private SplitContainer splitContainer;
|
||||||
|
private Panel panelGuide;
|
||||||
|
private Panel panel1;
|
||||||
|
private Canvas.UI.FlyCanvas canvas;
|
||||||
|
private StatusStrip statusStrip1;
|
||||||
|
private ToolStripStatusLabel lblStatus;
|
||||||
|
private GroupBox groupBox2;
|
||||||
|
private TextBox tbLineX2;
|
||||||
|
private Label label8;
|
||||||
|
private TextBox tbLineY2;
|
||||||
|
private Label label5;
|
||||||
|
private TextBox tbLineX1;
|
||||||
|
private TextBox tbLineY1;
|
||||||
|
private Label label6;
|
||||||
|
private Label label7;
|
||||||
|
private SizeCtrlTitleBar ctrlTitleBar;
|
||||||
|
private Button btnLoadImage;
|
||||||
|
private Label label9;
|
||||||
|
private Button btnExecute;
|
||||||
|
private Label label10;
|
||||||
|
private Button btnCreateLine;
|
||||||
|
private TextBox tbRectWidth1;
|
||||||
|
private Label label11;
|
||||||
|
private NumericUpDown NumRectWidth1;
|
||||||
|
private Label lblResult;
|
||||||
|
private Label label1;
|
||||||
|
private Button btnSave;
|
||||||
|
}
|
||||||
|
}
|
387
CanFly/UI/SizePanel/SizeGuideLineCtrl.cs
Normal file
387
CanFly/UI/SizePanel/SizeGuideLineCtrl.cs
Normal file
@ -0,0 +1,387 @@
|
|||||||
|
using CanFly.Canvas.Helper;
|
||||||
|
using CanFly.Canvas.Shape;
|
||||||
|
using CanFly.Canvas.UI;
|
||||||
|
using CanFly.Helper;
|
||||||
|
using HalconDotNet;
|
||||||
|
using OpenCvSharp;
|
||||||
|
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 CanFly.UI.SizePanel
|
||||||
|
{
|
||||||
|
public partial class SizeGuideLineCtrl : SizeBaseGuideControl
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private FlyShape? _line;
|
||||||
|
|
||||||
|
|
||||||
|
private float _lineX1;
|
||||||
|
private float _lineY1;
|
||||||
|
private float _lineX2;
|
||||||
|
private float _lineY2;
|
||||||
|
private float _lineWidth;
|
||||||
|
private PointF[] _rectPoints = new PointF[4];
|
||||||
|
//private float _LineLX=new float();
|
||||||
|
//private float _LineLY =new float();
|
||||||
|
//private float _LineRX =new float();
|
||||||
|
//private float _LineRY =new float();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected override string GetScriptFileName() => "Line_detect.hdvp";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public SizeGuideLineCtrl()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
this.canvas.mouseMoved += Canvas_mouseMoved;
|
||||||
|
this.canvas.OnShapeUpdateEvent += UpdateShape;
|
||||||
|
this.canvas.selectionChanged += Canvas_selectionChanged;
|
||||||
|
|
||||||
|
this.canvas.OnShapeMoving += Canvas_OnShapeMoving;
|
||||||
|
this.canvas.newShape += Canvas_newShape;
|
||||||
|
|
||||||
|
this.ctrlTitleBar.OnCloseClicked += OnControlClose;
|
||||||
|
|
||||||
|
NumRectWidth1.ValueChanged -= NumRectWidth1_ValueChanged;
|
||||||
|
NumRectWidth1.Value = 40;
|
||||||
|
NumRectWidth1.ValueChanged += NumRectWidth1_ValueChanged;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected override void UpdateShape(FlyShape shape)
|
||||||
|
{
|
||||||
|
switch (shape.ShapeType)
|
||||||
|
{
|
||||||
|
case ShapeTypeEnum.Line:
|
||||||
|
this._line = shape;
|
||||||
|
_line.IsDrawLineVirtualRect = true;
|
||||||
|
var pts = this._line.Points;
|
||||||
|
|
||||||
|
_lineX1 = pts[0].X;
|
||||||
|
_lineY1 = pts[0].Y;
|
||||||
|
_lineX2 = pts[1].X;
|
||||||
|
_lineY2 = pts[1].Y;
|
||||||
|
_lineWidth = shape.LineVirtualRectWidth;
|
||||||
|
_rectPoints = shape.LineVirtualRectPoints;
|
||||||
|
//_LineLX = (shape.LineVirtualRectPoints[0].X + shape.LineVirtualRectPoints[3].X) / 2;
|
||||||
|
//_LineLY = (shape.LineVirtualRectPoints[0].Y + shape.LineVirtualRectPoints[3].Y) / 2;
|
||||||
|
//_LineRX = (shape.LineVirtualRectPoints[1].X + shape.LineVirtualRectPoints[2].X) / 2;
|
||||||
|
//_LineRY = (shape.LineVirtualRectPoints[1].Y + shape.LineVirtualRectPoints[2].Y) / 2;
|
||||||
|
|
||||||
|
tbLineX1.Text = _lineX1.ToString("F3");
|
||||||
|
tbLineY1.Text = _lineY1.ToString("F3");
|
||||||
|
tbLineX2.Text = _lineX2.ToString("F3");
|
||||||
|
tbLineY2.Text = _lineY2.ToString("F3");
|
||||||
|
// NumRectWidth1.Value = (decimal)_lineWidth;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void GuideLineCircleCtrl_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_mouseMoved(PointF pos)
|
||||||
|
{
|
||||||
|
if (InvokeRequired)
|
||||||
|
{
|
||||||
|
Invoke(Canvas_mouseMoved, pos);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lblStatus.Text = $"X:{pos.X}, Y:{pos.Y}";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_selectionChanged(List<FlyShape> shapes)
|
||||||
|
{
|
||||||
|
//if (shapes.Count != 1)
|
||||||
|
//{
|
||||||
|
// // panelGuide.Controls.Clear();
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
//SwitchGuideForm(shapes[0].ShapeType);
|
||||||
|
// Canvas_OnShapeUpdateEvent(shapes[0]);
|
||||||
|
|
||||||
|
if (shapes.Count != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UpdateShape(shapes[0]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_OnShapeMoving(List<FlyShape> shapes)
|
||||||
|
{
|
||||||
|
if (shapes.Count != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateShape(shapes[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void btnCreateLine_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (this.canvas.pixmap == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先打开图片");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbLineX1.Text = string.Empty;
|
||||||
|
tbLineY1.Text = string.Empty;
|
||||||
|
tbLineX2.Text = string.Empty;
|
||||||
|
tbLineY2.Text = string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
this.canvas.Shapes.RemoveAll(shp => shp.ShapeType == ShapeTypeEnum.Line);
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
this.canvas.StartDraw(ShapeTypeEnum.Line);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void btnLoadImage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OpenImageFile(bitmap =>
|
||||||
|
{
|
||||||
|
this.canvas.LoadPixmap(bitmap);
|
||||||
|
this.canvas.Enabled = true;
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_newShape()
|
||||||
|
{
|
||||||
|
this.canvas.StopDraw();
|
||||||
|
}
|
||||||
|
string strarrayX = string.Empty;
|
||||||
|
string strarrayY = string.Empty;
|
||||||
|
private void btnExecute_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (this.canvas.pixmap == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先打开图片");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.tbLineX1.Text.Trim().Length == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先创建直线");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.canvas.OutsideShapes.Clear();
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
|
||||||
|
|
||||||
|
flag = new List<double>();
|
||||||
|
RowBegin = new List<double>();
|
||||||
|
ColBegin = new List<double>();
|
||||||
|
RowEnd = new List<double>();
|
||||||
|
ColEnd = new List<double>();
|
||||||
|
Dictionary<string, HObject> inputImg = new Dictionary<string, HObject>();
|
||||||
|
|
||||||
|
if (hImage == null)
|
||||||
|
{
|
||||||
|
HOperatorSet.ReadImage(out hImage, CurrentImageFile);
|
||||||
|
}
|
||||||
|
inputImg["INPUT_Image"] = hImage;
|
||||||
|
// 创建一维数组
|
||||||
|
|
||||||
|
Dictionary<string, HTuple> inputPara = new Dictionary<string, HTuple>();
|
||||||
|
|
||||||
|
// 获取矩形的 4 个点
|
||||||
|
PointF[] Points = this._line.LineVirtualRectPoints;
|
||||||
|
PointF Point1 = Points[0];
|
||||||
|
PointF Point2 = Points[1];
|
||||||
|
PointF Point3 = Points[2];
|
||||||
|
PointF Point4 = Points[3];
|
||||||
|
PointF Point5 = Points[0];
|
||||||
|
|
||||||
|
float x1 = Point1.X;
|
||||||
|
float y1 = Point1.Y;
|
||||||
|
|
||||||
|
float x2 = Point2.X;
|
||||||
|
float y2 = Point2.Y;
|
||||||
|
|
||||||
|
float x3 = Point3.X;
|
||||||
|
float y3 = Point3.Y;
|
||||||
|
|
||||||
|
float x4 = Point4.X;
|
||||||
|
float y4 = Point4.Y;
|
||||||
|
|
||||||
|
float x5 = Point5.X;
|
||||||
|
float y5 = Point5.Y;
|
||||||
|
|
||||||
|
|
||||||
|
float[] arrayX = new float[] { x1, x2, x3, x4, x5 };
|
||||||
|
HTuple hTupleArrayX = new HTuple(arrayX);
|
||||||
|
|
||||||
|
float[] arrayY = new float[] { y1, y2, y3, y4, y5 };
|
||||||
|
HTuple hTupleArrayY = new HTuple(arrayY);
|
||||||
|
|
||||||
|
strarrayX = string.Join(",", arrayX);
|
||||||
|
strarrayY = string.Join(",", arrayY);
|
||||||
|
|
||||||
|
inputPara["LX"] = _lineX1;
|
||||||
|
inputPara["LY"] = _lineY1;
|
||||||
|
inputPara["RX"] = _lineX2;
|
||||||
|
inputPara["RY"] = _lineY2;
|
||||||
|
inputPara["XRect"] = hTupleArrayX;
|
||||||
|
inputPara["YRect"] = hTupleArrayY;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
List<string> outputKeys = new List<string>()
|
||||||
|
{
|
||||||
|
"OUTPUT_Flag",
|
||||||
|
"RowBegin",
|
||||||
|
"ColBegin",
|
||||||
|
"RowEnd",
|
||||||
|
"ColEnd"
|
||||||
|
};
|
||||||
|
|
||||||
|
ExecuteHScript(
|
||||||
|
inputImg,
|
||||||
|
inputPara,
|
||||||
|
outputKeys);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
List<double> flag = new List<double>();
|
||||||
|
List<double> RowBegin = new List<double>();
|
||||||
|
List<double> ColBegin = new List<double>();
|
||||||
|
List<double> RowEnd = new List<double>();
|
||||||
|
List<double> ColEnd = new List<double>();
|
||||||
|
|
||||||
|
|
||||||
|
protected override void OnExecuteHScriptResult(
|
||||||
|
bool success,
|
||||||
|
Dictionary<string, HTuple> resultDic,
|
||||||
|
int timeElasped)
|
||||||
|
{
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
"OUTPUT_Flag",
|
||||||
|
"RXCenter",
|
||||||
|
"RYCenter",
|
||||||
|
"RRadius"
|
||||||
|
*/
|
||||||
|
|
||||||
|
flag = resultDic["OUTPUT_Flag"].HTupleToDouble();
|
||||||
|
RowBegin = resultDic["RowBegin"].HTupleToDouble();
|
||||||
|
ColBegin = resultDic["ColBegin"].HTupleToDouble();
|
||||||
|
RowEnd = resultDic["RowEnd"].HTupleToDouble();
|
||||||
|
ColEnd = resultDic["ColEnd"].HTupleToDouble();
|
||||||
|
if (flag.Count > 0)
|
||||||
|
{
|
||||||
|
lblResult.Text = flag[0].ToString();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lblResult.Text = "无";
|
||||||
|
}
|
||||||
|
if (flag.Count > 0 && RowBegin.Count > 0 && ColBegin.Count > 0 && RowEnd.Count > 0 && ColEnd.Count > 0)
|
||||||
|
{
|
||||||
|
float width = 0;
|
||||||
|
this.canvas.DrawLine(new PointF((float)ColBegin[0], (float)RowBegin[0]), new PointF((float)ColEnd[0], (float)RowEnd[0]), width);
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
lblElapsed.Text = $"{timeElasped} ms";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void NumRectWidth1_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_line != null)
|
||||||
|
{
|
||||||
|
//_line1.IsDrawLineVirtualRect = true;
|
||||||
|
_line.LineVirtualRectWidth = (float)NumRectWidth1.Value;
|
||||||
|
UpdateShape(_line);
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (lblResult.Text.Equals("无"))
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先进行绘制");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (lblResult.Text != "0")
|
||||||
|
{
|
||||||
|
MessageBox.Show("测量计算错误,无法保存");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//flag = resultDic["OUTPUT_Flag"].HTupleToDouble();
|
||||||
|
//RowBegin = resultDic["RowBegin"].HTupleToDouble();
|
||||||
|
//ColBegin = resultDic["ColBegin"].HTupleToDouble();
|
||||||
|
//RowEnd = resultDic["RowEnd"].HTupleToDouble();
|
||||||
|
//ColEnd = resultDic["ColEnd"].HTupleToDouble();
|
||||||
|
|
||||||
|
|
||||||
|
string input = $"LX:{_lineX1};" +
|
||||||
|
$"LY:{_lineY1};" +
|
||||||
|
$"RX:{_lineX2};" +
|
||||||
|
$"RY:{_lineY2};" +
|
||||||
|
$"Line_XRect:{strarrayX};" +
|
||||||
|
$"Line_YRect:{strarrayY}";
|
||||||
|
|
||||||
|
|
||||||
|
string result = $"RowBegin:{string.Join(";", RowBegin[0])};ColBegin:{string.Join(";", ColBegin[0])};RowEnd:{string.Join(";", RowEnd[0])};ColEnd:{string.Join(";", ColEnd[0])}";
|
||||||
|
|
||||||
|
DataToTriggerEvent(input, result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
145
CanFly/UI/SizePanel/SizeGuideLineCtrl.resx
Normal file
145
CanFly/UI/SizePanel/SizeGuideLineCtrl.resx
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<data name="canvas.OutsideShapes" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>
|
||||||
|
AAEAAAD/////AQAAAAAAAAAMAgAAAERDYW5GbHkuQ2FudmFzLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1
|
||||||
|
cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAQBAAAAdlN5c3RlbS5Db2xsZWN0aW9ucy5HZW5l
|
||||||
|
cmljLkxpc3RgMVtbQ2FuRmx5LkNhbnZhcy5TaGFwZS5GbHlTaGFwZSwgQ2FuRmx5LkNhbnZhcywgQ3Vs
|
||||||
|
dHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsXV0DAAAABl9pdGVtcwVfc2l6ZQhfdmVyc2lv
|
||||||
|
bgQAAB5DYW5GbHkuQ2FudmFzLlNoYXBlLkZseVNoYXBlW10CAAAACAgJAwAAAAAAAAAAAAAADAQAAAAz
|
||||||
|
Q2FuRmx5LkNhbnZhcywgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsBwMAAAAAAQAA
|
||||||
|
AAAAAAAEHENhbkZseS5DYW52YXMuU2hhcGUuRmx5U2hhcGUEAAAACw==
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<data name="canvas.Shapes" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>
|
||||||
|
AAEAAAD/////AQAAAAAAAAAMAgAAAERDYW5GbHkuQ2FudmFzLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1
|
||||||
|
cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAQBAAAAdlN5c3RlbS5Db2xsZWN0aW9ucy5HZW5l
|
||||||
|
cmljLkxpc3RgMVtbQ2FuRmx5LkNhbnZhcy5TaGFwZS5GbHlTaGFwZSwgQ2FuRmx5LkNhbnZhcywgQ3Vs
|
||||||
|
dHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsXV0DAAAABl9pdGVtcwVfc2l6ZQhfdmVyc2lv
|
||||||
|
bgQAAB5DYW5GbHkuQ2FudmFzLlNoYXBlLkZseVNoYXBlW10CAAAACAgJAwAAAAAAAAAAAAAADAQAAAAz
|
||||||
|
Q2FuRmx5LkNhbnZhcywgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsBwMAAAAAAQAA
|
||||||
|
AAAAAAAEHENhbkZseS5DYW52YXMuU2hhcGUuRmx5U2hhcGUEAAAACw==
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
570
CanFly/UI/SizePanel/SizeGuideLineLineCtrl.Designer.cs
generated
Normal file
570
CanFly/UI/SizePanel/SizeGuideLineLineCtrl.Designer.cs
generated
Normal file
@ -0,0 +1,570 @@
|
|||||||
|
namespace CanFly.UI.SizePanel
|
||||||
|
{
|
||||||
|
partial class SizeGuideLineLineCtrl
|
||||||
|
{
|
||||||
|
/// <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(SizeGuideLineLineCtrl));
|
||||||
|
lblStatus = new ToolStripStatusLabel();
|
||||||
|
panel1 = new Panel();
|
||||||
|
canvas = new Canvas.UI.FlyCanvas();
|
||||||
|
statusStrip1 = new StatusStrip();
|
||||||
|
ctrlTitleBar = new SizeCtrlTitleBar();
|
||||||
|
tbLine1X2 = new TextBox();
|
||||||
|
label8 = new Label();
|
||||||
|
tbLine1Y2 = new TextBox();
|
||||||
|
label5 = new Label();
|
||||||
|
label10 = new Label();
|
||||||
|
tbLine1X1 = new TextBox();
|
||||||
|
tbLine1Y1 = new TextBox();
|
||||||
|
label6 = new Label();
|
||||||
|
label7 = new Label();
|
||||||
|
btnLoadImage = new Button();
|
||||||
|
label9 = new Label();
|
||||||
|
btnExecute = new Button();
|
||||||
|
panelGuide = new Panel();
|
||||||
|
lblDistance = new Label();
|
||||||
|
label17 = new Label();
|
||||||
|
lblResult = new Label();
|
||||||
|
label15 = new Label();
|
||||||
|
groupBox3 = new GroupBox();
|
||||||
|
NumRectWidth2 = new NumericUpDown();
|
||||||
|
label2 = new Label();
|
||||||
|
tbLine2X2 = new TextBox();
|
||||||
|
label11 = new Label();
|
||||||
|
tbLine2Y2 = new TextBox();
|
||||||
|
label12 = new Label();
|
||||||
|
tbLine2X1 = new TextBox();
|
||||||
|
tbLine2Y1 = new TextBox();
|
||||||
|
label13 = new Label();
|
||||||
|
label14 = new Label();
|
||||||
|
groupBox2 = new GroupBox();
|
||||||
|
NumRectWidth1 = new NumericUpDown();
|
||||||
|
label1 = new Label();
|
||||||
|
splitContainer = new SplitContainer();
|
||||||
|
lblElapsed = new Label();
|
||||||
|
label4 = new Label();
|
||||||
|
btnSave = new Button();
|
||||||
|
panel1.SuspendLayout();
|
||||||
|
statusStrip1.SuspendLayout();
|
||||||
|
panelGuide.SuspendLayout();
|
||||||
|
groupBox3.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)NumRectWidth2).BeginInit();
|
||||||
|
groupBox2.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)NumRectWidth1).BeginInit();
|
||||||
|
((System.ComponentModel.ISupportInitialize)splitContainer).BeginInit();
|
||||||
|
splitContainer.Panel1.SuspendLayout();
|
||||||
|
splitContainer.Panel2.SuspendLayout();
|
||||||
|
splitContainer.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// lblStatus
|
||||||
|
//
|
||||||
|
lblStatus.Name = "lblStatus";
|
||||||
|
lblStatus.Size = new Size(44, 17);
|
||||||
|
lblStatus.Text = " ";
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
panel1.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
panel1.Controls.Add(canvas);
|
||||||
|
panel1.Controls.Add(statusStrip1);
|
||||||
|
panel1.Dock = DockStyle.Fill;
|
||||||
|
panel1.Location = new Point(0, 0);
|
||||||
|
panel1.Name = "panel1";
|
||||||
|
panel1.Size = new Size(1076, 640);
|
||||||
|
panel1.TabIndex = 1;
|
||||||
|
//
|
||||||
|
// canvas
|
||||||
|
//
|
||||||
|
canvas.AllowMultiSelect = false;
|
||||||
|
canvas.CreateMode = Canvas.Shape.ShapeTypeEnum.Polygon;
|
||||||
|
canvas.Dock = DockStyle.Fill;
|
||||||
|
canvas.Enabled = false;
|
||||||
|
canvas.FillDrawing = false;
|
||||||
|
canvas.Location = new Point(0, 0);
|
||||||
|
canvas.Margin = new Padding(2);
|
||||||
|
canvas.Name = "canvas";
|
||||||
|
canvas.OutsideShapes = (List<Canvas.Shape.FlyShape>)resources.GetObject("canvas.OutsideShapes");
|
||||||
|
canvas.Scale = 1F;
|
||||||
|
canvas.Shapes = (List<Canvas.Shape.FlyShape>)resources.GetObject("canvas.Shapes");
|
||||||
|
canvas.Size = new Size(1074, 616);
|
||||||
|
canvas.TabIndex = 2;
|
||||||
|
//
|
||||||
|
// statusStrip1
|
||||||
|
//
|
||||||
|
statusStrip1.Items.AddRange(new ToolStripItem[] { lblStatus });
|
||||||
|
statusStrip1.Location = new Point(0, 616);
|
||||||
|
statusStrip1.Name = "statusStrip1";
|
||||||
|
statusStrip1.Size = new Size(1074, 22);
|
||||||
|
statusStrip1.TabIndex = 1;
|
||||||
|
statusStrip1.Text = "statusStrip1";
|
||||||
|
//
|
||||||
|
// ctrlTitleBar
|
||||||
|
//
|
||||||
|
ctrlTitleBar.Dock = DockStyle.Top;
|
||||||
|
ctrlTitleBar.Location = new Point(0, 0);
|
||||||
|
ctrlTitleBar.MinimumSize = new Size(0, 36);
|
||||||
|
ctrlTitleBar.Name = "ctrlTitleBar";
|
||||||
|
ctrlTitleBar.Padding = new Padding(3);
|
||||||
|
ctrlTitleBar.Size = new Size(198, 36);
|
||||||
|
ctrlTitleBar.TabIndex = 11;
|
||||||
|
ctrlTitleBar.Title = "线线测量";
|
||||||
|
//
|
||||||
|
// tbLine1X2
|
||||||
|
//
|
||||||
|
tbLine1X2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLine1X2.Location = new Point(56, 80);
|
||||||
|
tbLine1X2.Name = "tbLine1X2";
|
||||||
|
tbLine1X2.Size = new Size(134, 23);
|
||||||
|
tbLine1X2.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// label8
|
||||||
|
//
|
||||||
|
label8.AutoSize = true;
|
||||||
|
label8.Location = new Point(6, 83);
|
||||||
|
label8.Name = "label8";
|
||||||
|
label8.Size = new Size(26, 17);
|
||||||
|
label8.TabIndex = 8;
|
||||||
|
label8.Text = "X2:";
|
||||||
|
//
|
||||||
|
// tbLine1Y2
|
||||||
|
//
|
||||||
|
tbLine1Y2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLine1Y2.Location = new Point(56, 109);
|
||||||
|
tbLine1Y2.Name = "tbLine1Y2";
|
||||||
|
tbLine1Y2.Size = new Size(134, 23);
|
||||||
|
tbLine1Y2.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// label5
|
||||||
|
//
|
||||||
|
label5.AutoSize = true;
|
||||||
|
label5.Location = new Point(6, 112);
|
||||||
|
label5.Name = "label5";
|
||||||
|
label5.Size = new Size(25, 17);
|
||||||
|
label5.TabIndex = 6;
|
||||||
|
label5.Text = "Y2:";
|
||||||
|
//
|
||||||
|
// label10
|
||||||
|
//
|
||||||
|
label10.AutoSize = true;
|
||||||
|
label10.Location = new Point(6, 521);
|
||||||
|
label10.Name = "label10";
|
||||||
|
label10.Size = new Size(44, 17);
|
||||||
|
label10.TabIndex = 16;
|
||||||
|
label10.Text = "耗时:";
|
||||||
|
//
|
||||||
|
// tbLine1X1
|
||||||
|
//
|
||||||
|
tbLine1X1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLine1X1.Location = new Point(56, 22);
|
||||||
|
tbLine1X1.Name = "tbLine1X1";
|
||||||
|
tbLine1X1.Size = new Size(134, 23);
|
||||||
|
tbLine1X1.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// tbLine1Y1
|
||||||
|
//
|
||||||
|
tbLine1Y1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLine1Y1.Location = new Point(56, 51);
|
||||||
|
tbLine1Y1.Name = "tbLine1Y1";
|
||||||
|
tbLine1Y1.Size = new Size(134, 23);
|
||||||
|
tbLine1Y1.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// label6
|
||||||
|
//
|
||||||
|
label6.AutoSize = true;
|
||||||
|
label6.Location = new Point(6, 54);
|
||||||
|
label6.Name = "label6";
|
||||||
|
label6.Size = new Size(25, 17);
|
||||||
|
label6.TabIndex = 1;
|
||||||
|
label6.Text = "Y1:";
|
||||||
|
//
|
||||||
|
// label7
|
||||||
|
//
|
||||||
|
label7.AutoSize = true;
|
||||||
|
label7.Location = new Point(6, 25);
|
||||||
|
label7.Name = "label7";
|
||||||
|
label7.Size = new Size(26, 17);
|
||||||
|
label7.TabIndex = 0;
|
||||||
|
label7.Text = "X1:";
|
||||||
|
//
|
||||||
|
// btnLoadImage
|
||||||
|
//
|
||||||
|
btnLoadImage.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnLoadImage.Location = new Point(6, 394);
|
||||||
|
btnLoadImage.Name = "btnLoadImage";
|
||||||
|
btnLoadImage.Size = new Size(184, 32);
|
||||||
|
btnLoadImage.TabIndex = 18;
|
||||||
|
btnLoadImage.Text = "打开图片";
|
||||||
|
btnLoadImage.UseVisualStyleBackColor = true;
|
||||||
|
btnLoadImage.Click += btnLoadImage_Click;
|
||||||
|
//
|
||||||
|
// label9
|
||||||
|
//
|
||||||
|
label9.AutoSize = true;
|
||||||
|
label9.Location = new Point(54, 521);
|
||||||
|
label9.Name = "label9";
|
||||||
|
label9.Size = new Size(32, 17);
|
||||||
|
label9.TabIndex = 17;
|
||||||
|
label9.Text = "0ms";
|
||||||
|
//
|
||||||
|
// btnExecute
|
||||||
|
//
|
||||||
|
btnExecute.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnExecute.Location = new Point(5, 432);
|
||||||
|
btnExecute.Name = "btnExecute";
|
||||||
|
btnExecute.Size = new Size(184, 32);
|
||||||
|
btnExecute.TabIndex = 15;
|
||||||
|
btnExecute.Text = "执行";
|
||||||
|
btnExecute.UseVisualStyleBackColor = true;
|
||||||
|
btnExecute.Click += btnExecute_Click;
|
||||||
|
//
|
||||||
|
// panelGuide
|
||||||
|
//
|
||||||
|
panelGuide.BorderStyle = BorderStyle.FixedSingle;
|
||||||
|
panelGuide.Controls.Add(btnSave);
|
||||||
|
panelGuide.Controls.Add(lblDistance);
|
||||||
|
panelGuide.Controls.Add(label17);
|
||||||
|
panelGuide.Controls.Add(lblResult);
|
||||||
|
panelGuide.Controls.Add(label15);
|
||||||
|
panelGuide.Controls.Add(groupBox3);
|
||||||
|
panelGuide.Controls.Add(btnLoadImage);
|
||||||
|
panelGuide.Controls.Add(label9);
|
||||||
|
panelGuide.Controls.Add(btnExecute);
|
||||||
|
panelGuide.Controls.Add(label10);
|
||||||
|
panelGuide.Controls.Add(groupBox2);
|
||||||
|
panelGuide.Controls.Add(ctrlTitleBar);
|
||||||
|
panelGuide.Dock = DockStyle.Fill;
|
||||||
|
panelGuide.Location = new Point(0, 0);
|
||||||
|
panelGuide.Name = "panelGuide";
|
||||||
|
panelGuide.Size = new Size(200, 640);
|
||||||
|
panelGuide.TabIndex = 0;
|
||||||
|
//
|
||||||
|
// lblDistance
|
||||||
|
//
|
||||||
|
lblDistance.AutoSize = true;
|
||||||
|
lblDistance.Location = new Point(54, 493);
|
||||||
|
lblDistance.Name = "lblDistance";
|
||||||
|
lblDistance.Size = new Size(15, 17);
|
||||||
|
lblDistance.TabIndex = 25;
|
||||||
|
lblDistance.Text = "0";
|
||||||
|
//
|
||||||
|
// label17
|
||||||
|
//
|
||||||
|
label17.AutoSize = true;
|
||||||
|
label17.Location = new Point(6, 493);
|
||||||
|
label17.Name = "label17";
|
||||||
|
label17.Size = new Size(44, 17);
|
||||||
|
label17.TabIndex = 24;
|
||||||
|
label17.Text = "距离:";
|
||||||
|
//
|
||||||
|
// lblResult
|
||||||
|
//
|
||||||
|
lblResult.AutoSize = true;
|
||||||
|
lblResult.Location = new Point(54, 467);
|
||||||
|
lblResult.Name = "lblResult";
|
||||||
|
lblResult.Size = new Size(20, 17);
|
||||||
|
lblResult.TabIndex = 23;
|
||||||
|
lblResult.Text = "无";
|
||||||
|
//
|
||||||
|
// label15
|
||||||
|
//
|
||||||
|
label15.AutoSize = true;
|
||||||
|
label15.Location = new Point(6, 467);
|
||||||
|
label15.Name = "label15";
|
||||||
|
label15.Size = new Size(44, 17);
|
||||||
|
label15.TabIndex = 22;
|
||||||
|
label15.Text = "结果:";
|
||||||
|
//
|
||||||
|
// groupBox3
|
||||||
|
//
|
||||||
|
groupBox3.Controls.Add(NumRectWidth2);
|
||||||
|
groupBox3.Controls.Add(label2);
|
||||||
|
groupBox3.Controls.Add(tbLine2X2);
|
||||||
|
groupBox3.Controls.Add(label11);
|
||||||
|
groupBox3.Controls.Add(tbLine2Y2);
|
||||||
|
groupBox3.Controls.Add(label12);
|
||||||
|
groupBox3.Controls.Add(tbLine2X1);
|
||||||
|
groupBox3.Controls.Add(tbLine2Y1);
|
||||||
|
groupBox3.Controls.Add(label13);
|
||||||
|
groupBox3.Controls.Add(label14);
|
||||||
|
groupBox3.Dock = DockStyle.Top;
|
||||||
|
groupBox3.Location = new Point(0, 216);
|
||||||
|
groupBox3.Name = "groupBox3";
|
||||||
|
groupBox3.Size = new Size(198, 172);
|
||||||
|
groupBox3.TabIndex = 21;
|
||||||
|
groupBox3.TabStop = false;
|
||||||
|
groupBox3.Text = "线2参数";
|
||||||
|
//
|
||||||
|
// NumRectWidth2
|
||||||
|
//
|
||||||
|
NumRectWidth2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
NumRectWidth2.Location = new Point(53, 138);
|
||||||
|
NumRectWidth2.Maximum = new decimal(new int[] { 9000, 0, 0, 0 });
|
||||||
|
NumRectWidth2.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||||
|
NumRectWidth2.Name = "NumRectWidth2";
|
||||||
|
NumRectWidth2.Size = new Size(136, 23);
|
||||||
|
NumRectWidth2.TabIndex = 13;
|
||||||
|
NumRectWidth2.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// label2
|
||||||
|
//
|
||||||
|
label2.AutoSize = true;
|
||||||
|
label2.Location = new Point(6, 140);
|
||||||
|
label2.Name = "label2";
|
||||||
|
label2.Size = new Size(35, 17);
|
||||||
|
label2.TabIndex = 12;
|
||||||
|
label2.Text = "宽度:";
|
||||||
|
//
|
||||||
|
// tbLine2X2
|
||||||
|
//
|
||||||
|
tbLine2X2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLine2X2.Location = new Point(56, 80);
|
||||||
|
tbLine2X2.Name = "tbLine2X2";
|
||||||
|
tbLine2X2.Size = new Size(134, 23);
|
||||||
|
tbLine2X2.TabIndex = 9;
|
||||||
|
//
|
||||||
|
// label11
|
||||||
|
//
|
||||||
|
label11.AutoSize = true;
|
||||||
|
label11.Location = new Point(6, 83);
|
||||||
|
label11.Name = "label11";
|
||||||
|
label11.Size = new Size(26, 17);
|
||||||
|
label11.TabIndex = 8;
|
||||||
|
label11.Text = "X2:";
|
||||||
|
//
|
||||||
|
// tbLine2Y2
|
||||||
|
//
|
||||||
|
tbLine2Y2.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLine2Y2.Location = new Point(56, 109);
|
||||||
|
tbLine2Y2.Name = "tbLine2Y2";
|
||||||
|
tbLine2Y2.Size = new Size(136, 23);
|
||||||
|
tbLine2Y2.TabIndex = 7;
|
||||||
|
//
|
||||||
|
// label12
|
||||||
|
//
|
||||||
|
label12.AutoSize = true;
|
||||||
|
label12.Location = new Point(6, 112);
|
||||||
|
label12.Name = "label12";
|
||||||
|
label12.Size = new Size(25, 17);
|
||||||
|
label12.TabIndex = 6;
|
||||||
|
label12.Text = "Y2:";
|
||||||
|
//
|
||||||
|
// tbLine2X1
|
||||||
|
//
|
||||||
|
tbLine2X1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLine2X1.Location = new Point(56, 22);
|
||||||
|
tbLine2X1.Name = "tbLine2X1";
|
||||||
|
tbLine2X1.Size = new Size(134, 23);
|
||||||
|
tbLine2X1.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// tbLine2Y1
|
||||||
|
//
|
||||||
|
tbLine2Y1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
tbLine2Y1.Location = new Point(56, 51);
|
||||||
|
tbLine2Y1.Name = "tbLine2Y1";
|
||||||
|
tbLine2Y1.Size = new Size(134, 23);
|
||||||
|
tbLine2Y1.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// label13
|
||||||
|
//
|
||||||
|
label13.AutoSize = true;
|
||||||
|
label13.Location = new Point(6, 54);
|
||||||
|
label13.Name = "label13";
|
||||||
|
label13.Size = new Size(25, 17);
|
||||||
|
label13.TabIndex = 1;
|
||||||
|
label13.Text = "Y1:";
|
||||||
|
//
|
||||||
|
// label14
|
||||||
|
//
|
||||||
|
label14.AutoSize = true;
|
||||||
|
label14.Location = new Point(6, 25);
|
||||||
|
label14.Name = "label14";
|
||||||
|
label14.Size = new Size(26, 17);
|
||||||
|
label14.TabIndex = 0;
|
||||||
|
label14.Text = "X1:";
|
||||||
|
//
|
||||||
|
// groupBox2
|
||||||
|
//
|
||||||
|
groupBox2.Controls.Add(NumRectWidth1);
|
||||||
|
groupBox2.Controls.Add(label1);
|
||||||
|
groupBox2.Controls.Add(tbLine1X2);
|
||||||
|
groupBox2.Controls.Add(label8);
|
||||||
|
groupBox2.Controls.Add(tbLine1Y2);
|
||||||
|
groupBox2.Controls.Add(label5);
|
||||||
|
groupBox2.Controls.Add(tbLine1X1);
|
||||||
|
groupBox2.Controls.Add(tbLine1Y1);
|
||||||
|
groupBox2.Controls.Add(label6);
|
||||||
|
groupBox2.Controls.Add(label7);
|
||||||
|
groupBox2.Dock = DockStyle.Top;
|
||||||
|
groupBox2.Location = new Point(0, 36);
|
||||||
|
groupBox2.Name = "groupBox2";
|
||||||
|
groupBox2.Size = new Size(198, 180);
|
||||||
|
groupBox2.TabIndex = 13;
|
||||||
|
groupBox2.TabStop = false;
|
||||||
|
groupBox2.Text = "线1参数";
|
||||||
|
//
|
||||||
|
// NumRectWidth1
|
||||||
|
//
|
||||||
|
NumRectWidth1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
NumRectWidth1.Location = new Point(54, 138);
|
||||||
|
NumRectWidth1.Maximum = new decimal(new int[] { 9000, 0, 0, 0 });
|
||||||
|
NumRectWidth1.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||||
|
NumRectWidth1.Name = "NumRectWidth1";
|
||||||
|
NumRectWidth1.Size = new Size(135, 23);
|
||||||
|
NumRectWidth1.TabIndex = 11;
|
||||||
|
NumRectWidth1.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||||
|
//
|
||||||
|
// label1
|
||||||
|
//
|
||||||
|
label1.AutoSize = true;
|
||||||
|
label1.Location = new Point(6, 140);
|
||||||
|
label1.Name = "label1";
|
||||||
|
label1.Size = new Size(35, 17);
|
||||||
|
label1.TabIndex = 10;
|
||||||
|
label1.Text = "宽度:";
|
||||||
|
//
|
||||||
|
// splitContainer
|
||||||
|
//
|
||||||
|
splitContainer.Dock = DockStyle.Fill;
|
||||||
|
splitContainer.Location = new Point(0, 0);
|
||||||
|
splitContainer.Name = "splitContainer";
|
||||||
|
//
|
||||||
|
// splitContainer.Panel1
|
||||||
|
//
|
||||||
|
splitContainer.Panel1.Controls.Add(panelGuide);
|
||||||
|
splitContainer.Panel1MinSize = 150;
|
||||||
|
//
|
||||||
|
// splitContainer.Panel2
|
||||||
|
//
|
||||||
|
splitContainer.Panel2.Controls.Add(panel1);
|
||||||
|
splitContainer.Size = new Size(1280, 640);
|
||||||
|
splitContainer.SplitterDistance = 200;
|
||||||
|
splitContainer.TabIndex = 11;
|
||||||
|
//
|
||||||
|
// lblElapsed
|
||||||
|
//
|
||||||
|
lblElapsed.AutoSize = true;
|
||||||
|
lblElapsed.Location = new Point(50, 328);
|
||||||
|
lblElapsed.Name = "lblElapsed";
|
||||||
|
lblElapsed.Size = new Size(32, 17);
|
||||||
|
lblElapsed.TabIndex = 13;
|
||||||
|
lblElapsed.Text = "0ms";
|
||||||
|
//
|
||||||
|
// label4
|
||||||
|
//
|
||||||
|
label4.AutoSize = true;
|
||||||
|
label4.Location = new Point(0, 328);
|
||||||
|
label4.Name = "label4";
|
||||||
|
label4.Size = new Size(44, 17);
|
||||||
|
label4.TabIndex = 12;
|
||||||
|
label4.Text = "耗时:";
|
||||||
|
//
|
||||||
|
// btnSave
|
||||||
|
//
|
||||||
|
btnSave.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||||
|
btnSave.Location = new Point(3, 541);
|
||||||
|
btnSave.Name = "btnSave";
|
||||||
|
btnSave.Size = new Size(186, 32);
|
||||||
|
btnSave.TabIndex = 26;
|
||||||
|
btnSave.Text = "保存数据";
|
||||||
|
btnSave.UseVisualStyleBackColor = true;
|
||||||
|
btnSave.Click += btnSave_Click;
|
||||||
|
//
|
||||||
|
// GuideLineLineCtrl
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
Controls.Add(splitContainer);
|
||||||
|
Controls.Add(lblElapsed);
|
||||||
|
Controls.Add(label4);
|
||||||
|
Name = "GuideLineLineCtrl";
|
||||||
|
Size = new Size(1280, 640);
|
||||||
|
panel1.ResumeLayout(false);
|
||||||
|
panel1.PerformLayout();
|
||||||
|
statusStrip1.ResumeLayout(false);
|
||||||
|
statusStrip1.PerformLayout();
|
||||||
|
panelGuide.ResumeLayout(false);
|
||||||
|
panelGuide.PerformLayout();
|
||||||
|
groupBox3.ResumeLayout(false);
|
||||||
|
groupBox3.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)NumRectWidth2).EndInit();
|
||||||
|
groupBox2.ResumeLayout(false);
|
||||||
|
groupBox2.PerformLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)NumRectWidth1).EndInit();
|
||||||
|
splitContainer.Panel1.ResumeLayout(false);
|
||||||
|
splitContainer.Panel2.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)splitContainer).EndInit();
|
||||||
|
splitContainer.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private ToolStripStatusLabel lblStatus;
|
||||||
|
private Panel panel1;
|
||||||
|
private Canvas.UI.FlyCanvas canvas;
|
||||||
|
private StatusStrip statusStrip1;
|
||||||
|
private SizeCtrlTitleBar ctrlTitleBar;
|
||||||
|
private TextBox tbLine1X2;
|
||||||
|
private Label label8;
|
||||||
|
private TextBox tbLine1Y2;
|
||||||
|
private Label label5;
|
||||||
|
private Label label10;
|
||||||
|
private TextBox tbLine1X1;
|
||||||
|
private TextBox tbLine1Y1;
|
||||||
|
private Label label6;
|
||||||
|
private Label label7;
|
||||||
|
private Button btnLoadImage;
|
||||||
|
private Label label9;
|
||||||
|
private Button btnExecute;
|
||||||
|
private Panel panelGuide;
|
||||||
|
private GroupBox groupBox2;
|
||||||
|
private SplitContainer splitContainer;
|
||||||
|
private Label lblElapsed;
|
||||||
|
private Label label4;
|
||||||
|
private GroupBox groupBox3;
|
||||||
|
private TextBox tbLine2X2;
|
||||||
|
private Label label11;
|
||||||
|
private TextBox tbLine2Y2;
|
||||||
|
private Label label12;
|
||||||
|
private TextBox tbLine2X1;
|
||||||
|
private TextBox tbLine2Y1;
|
||||||
|
private Label label13;
|
||||||
|
private Label label14;
|
||||||
|
private Label label1;
|
||||||
|
private Label label2;
|
||||||
|
private NumericUpDown NumRectWidth2;
|
||||||
|
private NumericUpDown NumRectWidth1;
|
||||||
|
private Label lblDistance;
|
||||||
|
private Label label17;
|
||||||
|
private Label lblResult;
|
||||||
|
private Label label15;
|
||||||
|
private Button btnSave;
|
||||||
|
}
|
||||||
|
}
|
526
CanFly/UI/SizePanel/SizeGuideLineLineCtrl.cs
Normal file
526
CanFly/UI/SizePanel/SizeGuideLineLineCtrl.cs
Normal file
@ -0,0 +1,526 @@
|
|||||||
|
using CanFly.Canvas.Helper;
|
||||||
|
using CanFly.Canvas.Shape;
|
||||||
|
using CanFly.Helper;
|
||||||
|
using HalconDotNet;
|
||||||
|
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 CanFly.UI.SizePanel
|
||||||
|
{
|
||||||
|
public partial class SizeGuideLineLineCtrl : SizeBaseGuideControl
|
||||||
|
{
|
||||||
|
private FlyShape? _line1;
|
||||||
|
private FlyShape? _line2;
|
||||||
|
|
||||||
|
private float _line1X1;
|
||||||
|
private float _line1Y1;
|
||||||
|
private float _line1X2;
|
||||||
|
private float _line1Y2;
|
||||||
|
private float _lineWidth;
|
||||||
|
|
||||||
|
private float _line2X1;
|
||||||
|
private float _line2Y1;
|
||||||
|
private float _line2X2;
|
||||||
|
private float _line2Y2;
|
||||||
|
private float _line2Width;
|
||||||
|
|
||||||
|
protected override string GetScriptFileName() => "LineToLine.hdvp";
|
||||||
|
|
||||||
|
|
||||||
|
public SizeGuideLineLineCtrl()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
this.canvas.mouseMoved += Canvas_mouseMoved;
|
||||||
|
this.canvas.OnShapeUpdateEvent += UpdateShape;
|
||||||
|
this.canvas.selectionChanged += Canvas_selectionChanged;
|
||||||
|
|
||||||
|
this.canvas.OnShapeMoving += Canvas_OnShapeMoving;
|
||||||
|
this.canvas.newShape += Canvas_newShape;
|
||||||
|
|
||||||
|
this.ctrlTitleBar.OnCloseClicked += OnControlClose;
|
||||||
|
NumRectWidth1.ValueChanged -= NumRectWidth1_ValueChanged;
|
||||||
|
NumRectWidth1.Value = 40;
|
||||||
|
NumRectWidth1.ValueChanged += NumRectWidth1_ValueChanged;
|
||||||
|
|
||||||
|
NumRectWidth2.ValueChanged -= NumericUpDown2_ValueChanged;
|
||||||
|
NumRectWidth2.Value = 40;
|
||||||
|
NumRectWidth2.ValueChanged += NumericUpDown2_ValueChanged;
|
||||||
|
|
||||||
|
}
|
||||||
|
protected override void UpdateShape(FlyShape shape)
|
||||||
|
{
|
||||||
|
switch (shape.ShapeType)
|
||||||
|
{
|
||||||
|
case ShapeTypeEnum.Line:
|
||||||
|
// 判断是否为第一条直线或第二条直线
|
||||||
|
if (_line1 == shape)
|
||||||
|
{
|
||||||
|
//_line1 = shape;
|
||||||
|
var pts1 = _line1.Points;
|
||||||
|
_line1X1 = pts1[0].X;
|
||||||
|
_line1Y1 = pts1[0].Y;
|
||||||
|
_line1X2 = pts1[1].X;
|
||||||
|
_line1Y2 = pts1[1].Y;
|
||||||
|
_lineWidth = _line1.LineVirtualRectWidth;
|
||||||
|
|
||||||
|
tbLine1X1.Text = _line1X1.ToString("F3");
|
||||||
|
tbLine1Y1.Text = _line1Y1.ToString("F3");
|
||||||
|
tbLine1X2.Text = _line1X2.ToString("F3");
|
||||||
|
tbLine1Y2.Text = _line1Y2.ToString("F3");
|
||||||
|
//NumRectWidth1.Value = (decimal)_lineWidth;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//_line2 = shape;
|
||||||
|
var pts2 = _line2.Points;
|
||||||
|
_line2X1 = pts2[0].X;
|
||||||
|
_line2Y1 = pts2[0].Y;
|
||||||
|
_line2X2 = pts2[1].X;
|
||||||
|
_line2Y2 = pts2[1].Y;
|
||||||
|
_line2Width = _line2.LineVirtualRectWidth;
|
||||||
|
|
||||||
|
tbLine2X1.Text = _line2X1.ToString("F3");
|
||||||
|
tbLine2Y1.Text = _line2Y1.ToString("F3");
|
||||||
|
tbLine2X2.Text = _line2X2.ToString("F3");
|
||||||
|
tbLine2Y2.Text = _line2Y2.ToString("F3");
|
||||||
|
// NumRectWidth2.Value = (decimal)_line2Width;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void GuideLineCircleCtrl_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_mouseMoved(PointF pos)
|
||||||
|
{
|
||||||
|
if (InvokeRequired)
|
||||||
|
{
|
||||||
|
Invoke(Canvas_mouseMoved, pos);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lblStatus.Text = $"X:{pos.X}, Y:{pos.Y}";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_selectionChanged(List<FlyShape> shapes)
|
||||||
|
{
|
||||||
|
//if (shapes.Count != 1)
|
||||||
|
//{
|
||||||
|
// // panelGuide.Controls.Clear();
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
//SwitchGuideForm(shapes[0].ShapeType);
|
||||||
|
// Canvas_OnShapeUpdateEvent(shapes[0]);
|
||||||
|
|
||||||
|
if (shapes.Count != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
UpdateShape(shapes[0]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_OnShapeMoving(List<FlyShape> shapes)
|
||||||
|
{
|
||||||
|
if (shapes.Count != 1)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UpdateShape(shapes[0]);
|
||||||
|
}
|
||||||
|
private void Canvas_newShape()
|
||||||
|
{
|
||||||
|
// 自动切换到下一条直线绘制
|
||||||
|
if (_line1 == null)
|
||||||
|
{
|
||||||
|
_line1 = this.canvas.Shapes.LastOrDefault(shp => shp.ShapeType == ShapeTypeEnum.Line);
|
||||||
|
}
|
||||||
|
else if (_line2 == null)
|
||||||
|
{
|
||||||
|
_line2 = this.canvas.Shapes.LastOrDefault(shp => shp.ShapeType == ShapeTypeEnum.Line);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 停止绘制模式,用户可以根据需要重新启用
|
||||||
|
this.canvas.StopDraw();
|
||||||
|
//this.canvas.StopDraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnCreateLineOne_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// this.canvas.Shapes.RemoveAll(shp => shp == _line1); // 移除第一条直线
|
||||||
|
this._line1 = null;
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
this.canvas.StartDraw(ShapeTypeEnum.Line); // 启动绘制模式
|
||||||
|
this.canvas.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnCreateLineTwo_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
// this.canvas.Shapes.RemoveAll(shp => shp == _line2); // 移除第二条直线
|
||||||
|
this._line2 = null;
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
this.canvas.StartDraw(ShapeTypeEnum.Line); // 启动绘制模式
|
||||||
|
this.canvas.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnExecute_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (this.canvas.pixmap == null)
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先打开图片");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.canvas.OutsideShapes.Clear();
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
|
||||||
|
flag = new List<double>();
|
||||||
|
Distance = new List<double>();
|
||||||
|
Line1_RowBegin = new List<double>();
|
||||||
|
Line1_ColBegin = new List<double>();
|
||||||
|
Line1_RowEnd = new List<double>();
|
||||||
|
Line1_ColEnd = new List<double>();
|
||||||
|
Line2_RowBegin = new List<double>();
|
||||||
|
Line2_ColBegin = new List<double>();
|
||||||
|
Line2_RowEnd = new List<double>();
|
||||||
|
Line2_ColEnd = new List<double>();
|
||||||
|
Dictionary<string, HObject> inputImg = new Dictionary<string, HObject>();
|
||||||
|
|
||||||
|
if (hImage == null)
|
||||||
|
{
|
||||||
|
HOperatorSet.ReadImage(out hImage, CurrentImageFile);
|
||||||
|
}
|
||||||
|
inputImg["INPUT_Image"] = hImage;
|
||||||
|
|
||||||
|
Dictionary<string, HTuple> inputPara = new Dictionary<string, HTuple>();
|
||||||
|
|
||||||
|
|
||||||
|
// 获取矩形的 4 个点
|
||||||
|
PointF[] Points = this._line1.LineVirtualRectPoints;
|
||||||
|
if (Points.Count() < 4)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PointF Point1 = Points[0];
|
||||||
|
PointF Point2 = Points[1];
|
||||||
|
PointF Point3 = Points[2];
|
||||||
|
PointF Point4 = Points[3];
|
||||||
|
PointF Point5 = Points[0];
|
||||||
|
|
||||||
|
float x1 = Point1.X;
|
||||||
|
float y1 = Point1.Y;
|
||||||
|
|
||||||
|
float x2 = Point2.X;
|
||||||
|
float y2 = Point2.Y;
|
||||||
|
|
||||||
|
float x3 = Point3.X;
|
||||||
|
float y3 = Point3.Y;
|
||||||
|
|
||||||
|
float x4 = Point4.X;
|
||||||
|
float y4 = Point4.Y;
|
||||||
|
|
||||||
|
float x5 = Point5.X;
|
||||||
|
float y5 = Point5.Y;
|
||||||
|
|
||||||
|
|
||||||
|
float[] array1X = new float[] { x1, x2, x3, x4, x5 };
|
||||||
|
HTuple hTupleArray1X = new HTuple(array1X);
|
||||||
|
|
||||||
|
float[] array1Y = new float[] { y1, y2, y3, y4, y5 };
|
||||||
|
HTuple hTupleArray1Y = new HTuple(array1Y);
|
||||||
|
|
||||||
|
|
||||||
|
strarray1X = string.Join(",", array1X);
|
||||||
|
strarray1Y = string.Join(",", array1Y);
|
||||||
|
|
||||||
|
|
||||||
|
// 获取矩形的 4 个点
|
||||||
|
PointF[] Points2 = this._line2.LineVirtualRectPoints;
|
||||||
|
if (Points2.Count() < 4)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
PointF Point21 = Points2[0];
|
||||||
|
PointF Point22 = Points2[1];
|
||||||
|
PointF Point23 = Points2[2];
|
||||||
|
PointF Point24 = Points2[3];
|
||||||
|
PointF Point25 = Points2[0];
|
||||||
|
|
||||||
|
float x21 = Point21.X;
|
||||||
|
float y21 = Point21.Y;
|
||||||
|
|
||||||
|
float x22 = Point22.X;
|
||||||
|
float y22 = Point22.Y;
|
||||||
|
|
||||||
|
float x23 = Point23.X;
|
||||||
|
float y23 = Point23.Y;
|
||||||
|
|
||||||
|
float x24 = Point24.X;
|
||||||
|
float y24 = Point24.Y;
|
||||||
|
|
||||||
|
float x25 = Point25.X;
|
||||||
|
float y25 = Point25.Y;
|
||||||
|
|
||||||
|
|
||||||
|
float[] array2X = new float[] { x21, x22, x23, x24, x25 };
|
||||||
|
HTuple hTupleArray2X = new HTuple(array2X);
|
||||||
|
|
||||||
|
float[] array2Y = new float[] { y21, y22, y23, y24, y25 };
|
||||||
|
HTuple hTupleArray2Y = new HTuple(array2Y);
|
||||||
|
|
||||||
|
|
||||||
|
strarray2X = string.Join(",", array2X);
|
||||||
|
strarray2Y = string.Join(",", array2Y);
|
||||||
|
|
||||||
|
inputPara["Line1_LX"] = _line1X1;
|
||||||
|
inputPara["Line1_LY"] = _line1Y1;
|
||||||
|
inputPara["Line1_RX"] = _line1X2;
|
||||||
|
inputPara["Line1_RY"] = _line1Y2;
|
||||||
|
|
||||||
|
inputPara["Line2_LX"] = _line2X1;
|
||||||
|
inputPara["Line2_LY"] = _line2Y1;
|
||||||
|
inputPara["Line2_RX"] = _line2X2;
|
||||||
|
inputPara["Line2_RY"] = _line2Y2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
inputPara["Line1_XRect"] = hTupleArray1X;
|
||||||
|
inputPara["Line1_YRect"] = hTupleArray1Y;
|
||||||
|
|
||||||
|
inputPara["Line2_XRect"] = hTupleArray2X;
|
||||||
|
inputPara["Line2_YRect"] = hTupleArray2Y;
|
||||||
|
|
||||||
|
List<string> outputKeys = new List<string>()
|
||||||
|
{
|
||||||
|
"OUTPUT_Flag",
|
||||||
|
"Distance",
|
||||||
|
"Line1_RowBegin",
|
||||||
|
"Line1_ColBegin",
|
||||||
|
"Line1_RowEnd",
|
||||||
|
"Line1_ColEnd",
|
||||||
|
"Line2_RowBegin",
|
||||||
|
"Line2_ColBegin",
|
||||||
|
"Line2_RowEnd",
|
||||||
|
"Line2_ColEnd"
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
ExecuteHScript(
|
||||||
|
inputImg,
|
||||||
|
inputPara,
|
||||||
|
outputKeys);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void btnLoadImage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
OpenImageFile(bitmap =>
|
||||||
|
{
|
||||||
|
this.canvas.LoadPixmap(bitmap);
|
||||||
|
this.canvas.Enabled = true;
|
||||||
|
_line1 = new FlyShape();
|
||||||
|
_line2 = new FlyShape();
|
||||||
|
_line1.AddPoint(new Point(10, 10));
|
||||||
|
_line1.AddPoint(new Point(50, 10));
|
||||||
|
_line2.AddPoint(new Point(10, 20));
|
||||||
|
_line2.AddPoint(new Point(60, 20));
|
||||||
|
_line1.ShapeType = ShapeTypeEnum.Line;
|
||||||
|
_line2.ShapeType = ShapeTypeEnum.Line;
|
||||||
|
|
||||||
|
_line1.IsDrawLineVirtualRect = true;
|
||||||
|
_line1.LineVirtualRectWidth = 40;
|
||||||
|
_line2.IsDrawLineVirtualRect = true;
|
||||||
|
_line2.LineVirtualRectWidth = 40;
|
||||||
|
|
||||||
|
canvas.Shapes.Add(_line1);
|
||||||
|
canvas.Shapes.Add(_line2);
|
||||||
|
canvas.Invalidate();
|
||||||
|
|
||||||
|
UpdateShape(_line1);
|
||||||
|
UpdateShape(_line2);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
string strarray1X = string.Empty;
|
||||||
|
string strarray1Y = string.Empty;
|
||||||
|
string strarray2X = string.Empty;
|
||||||
|
string strarray2Y = string.Empty;
|
||||||
|
List<double> flag =new List<double>();
|
||||||
|
List<double> Distance = new List<double>();
|
||||||
|
List<double> Line1_RowBegin = new List<double>();
|
||||||
|
List<double> Line1_ColBegin = new List<double>();
|
||||||
|
List<double> Line1_RowEnd = new List<double>();
|
||||||
|
List<double> Line1_ColEnd = new List<double>();
|
||||||
|
List<double> Line2_RowBegin = new List<double>();
|
||||||
|
List<double> Line2_ColBegin = new List<double>();
|
||||||
|
List<double> Line2_RowEnd = new List<double>();
|
||||||
|
List<double> Line2_ColEnd = new List<double>();
|
||||||
|
protected override void OnExecuteHScriptResult(
|
||||||
|
bool success,
|
||||||
|
Dictionary<string, HTuple> resultDic,
|
||||||
|
int timeElasped)
|
||||||
|
{
|
||||||
|
if (!success)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//"OUTPUT_Flag",
|
||||||
|
// "Distance",
|
||||||
|
// "Line1_RowBegin",
|
||||||
|
// "Line1_ColBegin",
|
||||||
|
// "Line1_RowEnd",
|
||||||
|
// "Line1_ColEnd",
|
||||||
|
// "Line2_RowBegin",
|
||||||
|
// "Line2_ColBegin",
|
||||||
|
// "Line2_RowEnd",
|
||||||
|
// "Line2_ColEnd"
|
||||||
|
|
||||||
|
|
||||||
|
flag = resultDic["OUTPUT_Flag"].HTupleToDouble();
|
||||||
|
Distance = resultDic["Distance"].HTupleToDouble();
|
||||||
|
Line1_RowBegin = resultDic["Line1_RowBegin"].HTupleToDouble();
|
||||||
|
Line1_ColBegin = resultDic["Line1_ColBegin"].HTupleToDouble();
|
||||||
|
Line1_RowEnd = resultDic["Line1_RowEnd"].HTupleToDouble();
|
||||||
|
Line1_ColEnd = resultDic["Line1_ColEnd"].HTupleToDouble();
|
||||||
|
Line2_RowBegin = resultDic["Line2_RowBegin"].HTupleToDouble();
|
||||||
|
Line2_ColBegin = resultDic["Line2_ColBegin"].HTupleToDouble();
|
||||||
|
Line2_RowEnd = resultDic["Line2_RowEnd"].HTupleToDouble();
|
||||||
|
Line2_ColEnd = resultDic["Line2_ColEnd"].HTupleToDouble();
|
||||||
|
|
||||||
|
if (flag.Count > 0)
|
||||||
|
{
|
||||||
|
lblResult.Text = flag[0].ToString();
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lblResult.Text = "无";
|
||||||
|
}
|
||||||
|
if (Distance.Count > 0)
|
||||||
|
{
|
||||||
|
lblDistance.Text = Distance[0].ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
lblDistance.Text = "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag.Count > 0 && Distance.Count > 0 && Line1_RowBegin.Count > 0 && Line1_ColBegin.Count > 0 && Line1_RowEnd.Count > 0 && Line1_ColEnd.Count > 0 && Line2_RowBegin.Count > 0 && Line2_ColBegin.Count > 0 && Line2_RowEnd.Count > 0 && Line2_ColEnd.Count > 0)
|
||||||
|
{
|
||||||
|
float width = 0;
|
||||||
|
this.canvas.DrawLine(new PointF((float)Line1_ColBegin[0], (float)Line1_RowBegin[0]), new PointF((float)Line1_ColEnd[0], (float)Line1_RowEnd[0]), width);
|
||||||
|
this.canvas.DrawLine(new PointF((float)Line2_ColBegin[0], (float)Line2_RowBegin[0]), new PointF((float)Line2_ColEnd[0], (float)Line2_RowEnd[0]), width);
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
lblElapsed.Text = $"{timeElasped} ms";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NumRectWidth1_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_line1 != null)
|
||||||
|
{
|
||||||
|
//_line1.IsDrawLineVirtualRect = true;
|
||||||
|
_line1.LineVirtualRectWidth = (float)NumRectWidth1.Value;
|
||||||
|
UpdateShape(_line1);
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void NumericUpDown2_ValueChanged(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (_line2 != null)
|
||||||
|
{
|
||||||
|
// _line2.IsDrawLineVirtualRect = true;
|
||||||
|
_line2.LineVirtualRectWidth = (float)NumRectWidth2.Value;
|
||||||
|
UpdateShape(_line2);
|
||||||
|
this.canvas.Invalidate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
if (lblResult.Text.Equals("无"))
|
||||||
|
{
|
||||||
|
MessageBox.Show("请先进行绘制");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (lblResult.Text != "0")
|
||||||
|
{
|
||||||
|
MessageBox.Show("测量计算错误,无法保存");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//inputPara["Line1_LX"] = _line1X1;
|
||||||
|
//inputPara["Line1_LY"] = _line1Y1;
|
||||||
|
//inputPara["Line1_RX"] = _line1X2;
|
||||||
|
//inputPara["Line1_RY"] = _line1Y2;
|
||||||
|
|
||||||
|
//inputPara["Line2_LX"] = _line2X1;
|
||||||
|
//inputPara["Line2_LY"] = _line2Y1;
|
||||||
|
//inputPara["Line2_RX"] = _line2X2;
|
||||||
|
//inputPara["Line2_RY"] = _line2Y2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//inputPara["Line1_XRect"] = hTupleArray1X;
|
||||||
|
//inputPara["Line1_YRect"] = hTupleArray1Y;
|
||||||
|
|
||||||
|
//inputPara["Line2_XRect"] = hTupleArray2X;
|
||||||
|
//inputPara["Line2_YRect"] = hTupleArray2Y;
|
||||||
|
|
||||||
|
|
||||||
|
string input = $"Line1_LX:{_line1X1};" +
|
||||||
|
$"Line1_LY:{_line1Y1};" +
|
||||||
|
$"Line1_RX:{_line1X2};" +
|
||||||
|
$"Line1_RY:{_line1Y2};" +
|
||||||
|
$"Line2_LX:{_line2X1};" +
|
||||||
|
$"Line2_LY:{_line2Y1};" +
|
||||||
|
$"Line2_RX:{_line2X2};" +
|
||||||
|
$"Line2_RY:{_line2Y2};" +
|
||||||
|
$"Line1_XRect:{strarray1X};" +
|
||||||
|
$"Line1_YRect:{strarray1Y};" +
|
||||||
|
$"Line2_XRect:{strarray2X};" +
|
||||||
|
$"Line2_YRect:{strarray2Y}"
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
string result = $"Distance:{Distance[0]}";
|
||||||
|
|
||||||
|
|
||||||
|
DataToTriggerEvent(input, result);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
145
CanFly/UI/SizePanel/SizeGuideLineLineCtrl.resx
Normal file
145
CanFly/UI/SizePanel/SizeGuideLineLineCtrl.resx
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<data name="canvas.OutsideShapes" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>
|
||||||
|
AAEAAAD/////AQAAAAAAAAAMAgAAAERDYW5GbHkuQ2FudmFzLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1
|
||||||
|
cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAQBAAAAdlN5c3RlbS5Db2xsZWN0aW9ucy5HZW5l
|
||||||
|
cmljLkxpc3RgMVtbQ2FuRmx5LkNhbnZhcy5TaGFwZS5GbHlTaGFwZSwgQ2FuRmx5LkNhbnZhcywgQ3Vs
|
||||||
|
dHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsXV0DAAAABl9pdGVtcwVfc2l6ZQhfdmVyc2lv
|
||||||
|
bgQAAB5DYW5GbHkuQ2FudmFzLlNoYXBlLkZseVNoYXBlW10CAAAACAgJAwAAAAAAAAAAAAAADAQAAAAz
|
||||||
|
Q2FuRmx5LkNhbnZhcywgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsBwMAAAAAAQAA
|
||||||
|
AAAAAAAEHENhbkZseS5DYW52YXMuU2hhcGUuRmx5U2hhcGUEAAAACw==
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<data name="canvas.Shapes" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>
|
||||||
|
AAEAAAD/////AQAAAAAAAAAMAgAAAERDYW5GbHkuQ2FudmFzLCBWZXJzaW9uPTEuMC4wLjAsIEN1bHR1
|
||||||
|
cmU9bmV1dHJhbCwgUHVibGljS2V5VG9rZW49bnVsbAQBAAAAdlN5c3RlbS5Db2xsZWN0aW9ucy5HZW5l
|
||||||
|
cmljLkxpc3RgMVtbQ2FuRmx5LkNhbnZhcy5TaGFwZS5GbHlTaGFwZSwgQ2FuRmx5LkNhbnZhcywgQ3Vs
|
||||||
|
dHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsXV0DAAAABl9pdGVtcwVfc2l6ZQhfdmVyc2lv
|
||||||
|
bgQAAB5DYW5GbHkuQ2FudmFzLlNoYXBlLkZseVNoYXBlW10CAAAACAgJAwAAAAAAAAAAAAAADAQAAAAz
|
||||||
|
Q2FuRmx5LkNhbnZhcywgQ3VsdHVyZT1uZXV0cmFsLCBQdWJsaWNLZXlUb2tlbj1udWxsBwMAAAAAAQAA
|
||||||
|
AAAAAAAEHENhbkZseS5DYW52YXMuU2hhcGUuRmx5U2hhcGUEAAAACw==
|
||||||
|
</value>
|
||||||
|
</data>
|
||||||
|
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
93
CanFly/UI/UIMain/FrmMainSize.Designer.cs
generated
Normal file
93
CanFly/UI/UIMain/FrmMainSize.Designer.cs
generated
Normal file
@ -0,0 +1,93 @@
|
|||||||
|
|
||||||
|
|
||||||
|
namespace XKRS.CanFly
|
||||||
|
{
|
||||||
|
partial class FrmMainSize
|
||||||
|
{
|
||||||
|
/// <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()
|
||||||
|
{
|
||||||
|
statusStrip1 = new StatusStrip();
|
||||||
|
panelContent = new Panel();
|
||||||
|
pageHeader1 = new AntdUI.PageHeader();
|
||||||
|
panelContent.SuspendLayout();
|
||||||
|
SuspendLayout();
|
||||||
|
//
|
||||||
|
// statusStrip1
|
||||||
|
//
|
||||||
|
statusStrip1.Location = new Point(0, 808);
|
||||||
|
statusStrip1.Name = "statusStrip1";
|
||||||
|
statusStrip1.Size = new Size(1185, 22);
|
||||||
|
statusStrip1.TabIndex = 4;
|
||||||
|
statusStrip1.Text = "statusStrip1";
|
||||||
|
//
|
||||||
|
// panelContent
|
||||||
|
//
|
||||||
|
panelContent.Controls.Add(pageHeader1);
|
||||||
|
panelContent.Dock = DockStyle.Fill;
|
||||||
|
panelContent.Location = new Point(0, 0);
|
||||||
|
panelContent.Margin = new Padding(4, 3, 4, 3);
|
||||||
|
panelContent.Name = "panelContent";
|
||||||
|
panelContent.Size = new Size(1185, 808);
|
||||||
|
panelContent.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// pageHeader1
|
||||||
|
//
|
||||||
|
pageHeader1.BackColor = Color.FromArgb(46, 108, 227);
|
||||||
|
pageHeader1.Dock = DockStyle.Top;
|
||||||
|
pageHeader1.Location = new Point(0, 0);
|
||||||
|
pageHeader1.Mode = AntdUI.TAMode.Dark;
|
||||||
|
pageHeader1.Name = "pageHeader1";
|
||||||
|
pageHeader1.ShowButton = true;
|
||||||
|
pageHeader1.ShowIcon = true;
|
||||||
|
pageHeader1.Size = new Size(1185, 33);
|
||||||
|
pageHeader1.TabIndex = 2;
|
||||||
|
pageHeader1.Text = "尺寸测量";
|
||||||
|
//
|
||||||
|
// FrmMainSize
|
||||||
|
//
|
||||||
|
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||||
|
AutoScaleMode = AutoScaleMode.Font;
|
||||||
|
ClientSize = new Size(1185, 830);
|
||||||
|
Controls.Add(panelContent);
|
||||||
|
Controls.Add(statusStrip1);
|
||||||
|
FormBorderStyle = FormBorderStyle.FixedSingle;
|
||||||
|
Margin = new Padding(2, 3, 2, 3);
|
||||||
|
Name = "FrmMainSize";
|
||||||
|
StartPosition = FormStartPosition.CenterScreen;
|
||||||
|
Text = "尺寸测量";
|
||||||
|
Load += FrmMain_Load;
|
||||||
|
panelContent.ResumeLayout(false);
|
||||||
|
ResumeLayout(false);
|
||||||
|
PerformLayout();
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private StatusStrip statusStrip1;
|
||||||
|
private Panel panelContent;
|
||||||
|
private AntdUI.PageHeader pageHeader1;
|
||||||
|
}
|
||||||
|
}
|
440
CanFly/UI/UIMain/FrmMainSize.cs
Normal file
440
CanFly/UI/UIMain/FrmMainSize.cs
Normal file
@ -0,0 +1,440 @@
|
|||||||
|
using AntdUI;
|
||||||
|
using CanFly.Canvas.Shape;
|
||||||
|
using CanFly.Helper;
|
||||||
|
using CanFly.UI;
|
||||||
|
using CanFly.UI.GuidePanel;
|
||||||
|
using CanFly.UI.SizePanel;
|
||||||
|
using CanFly.Util;
|
||||||
|
using DH.Commons.Base;
|
||||||
|
using HalconDotNet;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
|
||||||
|
namespace XKRS.CanFly
|
||||||
|
{
|
||||||
|
|
||||||
|
public partial class FrmMainSize : Window
|
||||||
|
{
|
||||||
|
|
||||||
|
private string _currentImageFile = "";
|
||||||
|
private System.Windows.Forms.Timer _statusTimer = new System.Windows.Forms.Timer();
|
||||||
|
private SizeBaseGuideControl? _currentGuideCtrl;
|
||||||
|
|
||||||
|
|
||||||
|
private SizeGuideCircleCtrl guideCircleCtrl = new SizeGuideCircleCtrl();
|
||||||
|
private SizeGuideLineCircleCtrl guideLineCircleCtrl = new SizeGuideLineCircleCtrl();
|
||||||
|
private SizeGuideLineLineCtrl guideLineLineCtrl = new SizeGuideLineLineCtrl();
|
||||||
|
private SizeGuideLineCtrl guideLineCtrl = new SizeGuideLineCtrl();
|
||||||
|
private SizeGuideHeightCtrl guideHeightCtrl = new SizeGuideHeightCtrl();
|
||||||
|
string Type=string.Empty;
|
||||||
|
|
||||||
|
|
||||||
|
public string inputtext=string.Empty;
|
||||||
|
public string outtext = string.Empty;
|
||||||
|
DetectionConfig DetectionConfig;
|
||||||
|
public FrmMainSize(string type,DetectionConfig detectionConfig)
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
|
||||||
|
DetectionConfig = detectionConfig;
|
||||||
|
Type=type;
|
||||||
|
|
||||||
|
guideCircleCtrl.Dock = DockStyle.Fill;
|
||||||
|
guideCircleCtrl.OnControlCloseEvent -= () => panelContent.Controls.Clear();
|
||||||
|
guideCircleCtrl.OnControlCloseEvent += () => panelContent.Controls.Clear();
|
||||||
|
|
||||||
|
|
||||||
|
guideLineCircleCtrl.Dock = DockStyle.Fill;
|
||||||
|
guideLineCircleCtrl.OnControlCloseEvent -= () => panelContent.Controls.Clear();
|
||||||
|
guideLineCircleCtrl.OnControlCloseEvent += () => panelContent.Controls.Clear();
|
||||||
|
|
||||||
|
guideLineLineCtrl.Dock = DockStyle.Fill;
|
||||||
|
guideLineLineCtrl.OnControlCloseEvent -= () => panelContent.Controls.Clear();
|
||||||
|
guideLineLineCtrl.OnControlCloseEvent += () => panelContent.Controls.Clear();
|
||||||
|
|
||||||
|
guideLineCtrl.Dock = DockStyle.Fill;
|
||||||
|
guideLineCtrl.OnControlCloseEvent -= () => panelContent.Controls.Clear();
|
||||||
|
guideLineCtrl.OnControlCloseEvent += () => panelContent.Controls.Clear();
|
||||||
|
|
||||||
|
|
||||||
|
guideHeightCtrl.Dock = DockStyle.Fill;
|
||||||
|
guideHeightCtrl.OnControlCloseEvent -= () => panelContent.Controls.Clear();
|
||||||
|
guideHeightCtrl.OnControlCloseEvent += () => panelContent.Controls.Clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void FrmMain_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
switch (Type)
|
||||||
|
{
|
||||||
|
case "1":
|
||||||
|
SwitchMeasureMode(guideCircleCtrl);
|
||||||
|
break;
|
||||||
|
case "2":
|
||||||
|
SwitchMeasureMode(guideLineCtrl);
|
||||||
|
break;
|
||||||
|
case "3":
|
||||||
|
SwitchMeasureMode(guideLineLineCtrl);
|
||||||
|
break;
|
||||||
|
case "4":
|
||||||
|
SwitchMeasureMode(guideLineCircleCtrl);
|
||||||
|
break;
|
||||||
|
case "5":
|
||||||
|
SwitchMeasureMode(guideHeightCtrl);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void btnLoadImage_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//OpenFileDialog ofd = new OpenFileDialog();
|
||||||
|
//ofd.Filter = "图像文件|*.jpg;*.png";
|
||||||
|
//ofd.Multiselect = false;
|
||||||
|
//if (ofd.ShowDialog() == DialogResult.OK)
|
||||||
|
//{
|
||||||
|
// _currentImageFile = ofd.FileName;
|
||||||
|
// Bitmap bitmap = (Bitmap)Image.FromFile(_currentImageFile);
|
||||||
|
// this.canvas.LoadPixmap(bitmap);
|
||||||
|
// this.btnCreateCircle.Enabled = true;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void btnMeasureCircle_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//var contentCtrls = panelContent.Controls;
|
||||||
|
|
||||||
|
//if (contentCtrls.Count > 0)
|
||||||
|
//{
|
||||||
|
// if (contentCtrls[0] == guideCircleCtrl)
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//panelContent.Controls.Clear();
|
||||||
|
//panelContent.Controls.Add(guideCircleCtrl);
|
||||||
|
|
||||||
|
SwitchMeasureMode(guideCircleCtrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void btnMeasureLineCircle_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SwitchMeasureMode(guideLineCircleCtrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void SwitchMeasureMode(SizeBaseGuideControl control)
|
||||||
|
{
|
||||||
|
var contentCtrls = panelContent.Controls;
|
||||||
|
|
||||||
|
if (contentCtrls.Count > 0)
|
||||||
|
{
|
||||||
|
if (contentCtrls[0] == control)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
panelContent.Controls.Clear();
|
||||||
|
|
||||||
|
control.OnDataPassed -= Control_OnDataPassed;
|
||||||
|
control.OnDataPassed += Control_OnDataPassed;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//control.Dock = DockStyle.Fill;
|
||||||
|
//control.OnControlCloseEvent -= () => panelContent.Controls.Clear();
|
||||||
|
//control.OnControlCloseEvent += () => panelContent.Controls.Clear();
|
||||||
|
panelContent.Controls.Add(control);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Control_OnDataPassed(string obj,string obj1)
|
||||||
|
{
|
||||||
|
inputtext = obj;
|
||||||
|
outtext = obj1;
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnCreateRect_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//this.canvas.StartDraw(ShapeTypeEnum.Rectangle);
|
||||||
|
//this.btnCreateCircle.Enabled = false;
|
||||||
|
//this.btnStopDraw.Enabled = true;
|
||||||
|
//this.canvas.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void btnStopDraw_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//panelGuide.Controls.Clear();
|
||||||
|
StopDrawMode();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void StartDrawMode()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void StopDrawMode()
|
||||||
|
{
|
||||||
|
//this.canvas.StopDraw();
|
||||||
|
|
||||||
|
|
||||||
|
//this.btnStopDraw.Enabled = false;
|
||||||
|
//this.btnCreateCircle.Enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Status(string message, int delay = 5000)
|
||||||
|
{
|
||||||
|
//_statusTimer.Stop();
|
||||||
|
//// 显示消息
|
||||||
|
//lblStatus.Text = message;
|
||||||
|
|
||||||
|
//// 创建一个计时器
|
||||||
|
|
||||||
|
//_statusTimer.Interval = delay; // 设置延迟时间
|
||||||
|
//_statusTimer.Tick += (sender, e) =>
|
||||||
|
//{
|
||||||
|
// _statusTimer.Stop(); // 停止计时器
|
||||||
|
// lblStatus.Text = string.Empty; // 清空状态消息
|
||||||
|
//};
|
||||||
|
//_statusTimer.Start(); // 启动计时器
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_mouseMoved(PointF pos)
|
||||||
|
{
|
||||||
|
//if (InvokeRequired)
|
||||||
|
//{
|
||||||
|
// Invoke(Canvas_mouseMoved, pos);
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//lblStatus.Text = $"X:{pos.X}, Y:{pos.Y}";
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_selectionChanged(List<FlyShape> shapes)
|
||||||
|
{
|
||||||
|
if (shapes.Count != 1)
|
||||||
|
{
|
||||||
|
// panelGuide.Controls.Clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//SwitchGuideForm(shapes[0].ShapeType);
|
||||||
|
Canvas_OnShapeUpdateEvent(shapes[0]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void SwitchGuideForm(ShapeTypeEnum shapeType)
|
||||||
|
{
|
||||||
|
//if (_currentGuideCtrl == null)
|
||||||
|
//{
|
||||||
|
// switch (shapeType)
|
||||||
|
// {
|
||||||
|
// case ShapeTypeEnum.Point:
|
||||||
|
// break;
|
||||||
|
// case ShapeTypeEnum.Line:
|
||||||
|
// break;
|
||||||
|
// case ShapeTypeEnum.Rectangle:
|
||||||
|
// break;
|
||||||
|
// case ShapeTypeEnum.Circle:
|
||||||
|
// _currentGuideCtrl = new GuideCircleCtrl();
|
||||||
|
// _currentGuideCtrl.ImageFile = _currentImageFile;
|
||||||
|
// _currentGuideCtrl.OnDrawCircle += this.canvas.DrawCircle;
|
||||||
|
// _currentGuideCtrl.OnClose += () =>
|
||||||
|
// {
|
||||||
|
// panelGuide.Controls.Clear();
|
||||||
|
// StopDrawMode();
|
||||||
|
// };
|
||||||
|
// break;
|
||||||
|
// case ShapeTypeEnum.Polygon:
|
||||||
|
// break;
|
||||||
|
// case ShapeTypeEnum.LineStrip:
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
//_currentGuideCtrl?.AddToPanel(panelGuide);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_OnShapeMoving(List<FlyShape> shapes)
|
||||||
|
{
|
||||||
|
//if (shapes.Count != 1)
|
||||||
|
//{
|
||||||
|
// panelGuide.Controls.Clear();
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//_currentGuideCtrl?.UpdateShape(shapes[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Canvas_OnShapeUpdateEvent(FlyShape shape)
|
||||||
|
{
|
||||||
|
switch (shape.ShapeType)
|
||||||
|
{
|
||||||
|
case ShapeTypeEnum.Point:
|
||||||
|
break;
|
||||||
|
case ShapeTypeEnum.Line:
|
||||||
|
break;
|
||||||
|
case ShapeTypeEnum.Rectangle:
|
||||||
|
break;
|
||||||
|
case ShapeTypeEnum.Circle:
|
||||||
|
{
|
||||||
|
//_currentGuideCtrl?.UpdateShape(shape);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case ShapeTypeEnum.Polygon:
|
||||||
|
break;
|
||||||
|
case ShapeTypeEnum.LineStrip:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void btnTestOutsideDraw_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//Random random = new Random((int)DateTime.Now.Ticks);
|
||||||
|
|
||||||
|
//for (int i = 0; i < 10; i++)
|
||||||
|
//{
|
||||||
|
// // this.canvas.DrawCircle(new PointF(500, 500), 100);
|
||||||
|
|
||||||
|
// int x = random.Next() % 500;
|
||||||
|
// int y = random.Next() % 500;
|
||||||
|
// int r = random.Next() % 200;
|
||||||
|
|
||||||
|
// Debug.WriteLine($"X:{x}\tY:{y}\tR:{r}");
|
||||||
|
|
||||||
|
// this.canvas.DrawCircle(new PointF(x, y), r);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnTestClearDraw_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//this.canvas.ClearDraw();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private async void btnTestCircleMeasure_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//string dir = Path.Combine(Environment.CurrentDirectory, "hscripts");
|
||||||
|
//string file = "CircleMeasure.hdvp";
|
||||||
|
//string filePath = Path.Combine(dir, file);
|
||||||
|
//if (!File.Exists(filePath))
|
||||||
|
//{
|
||||||
|
// MessageBox.Show($"文件 {filePath} 不存在");
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//HObject? hImage = null;
|
||||||
|
|
||||||
|
//try
|
||||||
|
//{
|
||||||
|
// HDevEngineTool tool = new HDevEngineTool(dir);
|
||||||
|
// tool.LoadProcedure(Path.GetFileNameWithoutExtension(file));
|
||||||
|
|
||||||
|
// // string imageFile = Path.Combine(Environment.CurrentDirectory, "hscripts", "image.png");
|
||||||
|
|
||||||
|
// HOperatorSet.ReadImage(out hImage, _currentImageFile);
|
||||||
|
// tool.InputImageDic["INPUT_Image"] = hImage;
|
||||||
|
// tool.InputTupleDic["XCenter"] = 981.625;
|
||||||
|
// tool.InputTupleDic["YCenter"] = 931.823;
|
||||||
|
// tool.InputTupleDic["Radius"] = 900.141;
|
||||||
|
|
||||||
|
// Stopwatch sw = new Stopwatch();
|
||||||
|
// sw.Start();
|
||||||
|
// if (!tool.RunProcedure(out string error, out _))
|
||||||
|
// {
|
||||||
|
// throw new Exception();
|
||||||
|
// }
|
||||||
|
// sw.Stop();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// var flag = tool.GetResultTuple("OUTPUT_Flag").HTupleToDouble();
|
||||||
|
// List<double> x = tool.GetResultTuple("RXCenter").HTupleToDouble();
|
||||||
|
// var y = tool.GetResultTuple("RYCenter").HTupleToDouble();
|
||||||
|
// var r = tool.GetResultTuple("RRadius").HTupleToDouble();
|
||||||
|
|
||||||
|
// if (flag.Count > 0 && x.Count > 0 && y.Count > 0 && r.Count > 0)
|
||||||
|
// {
|
||||||
|
// this.canvas.DrawCircle(new PointF((float)x[0], (float)y[0]), (float)r[0]);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// //
|
||||||
|
// Debug.WriteLine("");
|
||||||
|
//}
|
||||||
|
//catch (Exception)
|
||||||
|
//{
|
||||||
|
// throw;
|
||||||
|
//}
|
||||||
|
//finally
|
||||||
|
//{
|
||||||
|
// hImage?.Dispose();
|
||||||
|
//}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnTest_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//this.canvas.DrawRectangle(new PointF(300, 300),
|
||||||
|
// new PointF(800, 500), 33f);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void btnRotateTest_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//if (this.canvas.Shapes.Count == 0)
|
||||||
|
//{
|
||||||
|
// return;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//this.canvas.Shapes[0]._currentRotateAngle += 10;
|
||||||
|
//this.canvas.Invalidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnMeasureLineline_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SwitchMeasureMode(guideLineLineCtrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnMeasureLine_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SwitchMeasureMode(guideLineCtrl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
123
CanFly/UI/UIMain/FrmMainSize.resx
Normal file
123
CanFly/UI/UIMain/FrmMainSize.resx
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<root>
|
||||||
|
<!--
|
||||||
|
Microsoft ResX Schema
|
||||||
|
|
||||||
|
Version 2.0
|
||||||
|
|
||||||
|
The primary goals of this format is to allow a simple XML format
|
||||||
|
that is mostly human readable. The generation and parsing of the
|
||||||
|
various data types are done through the TypeConverter classes
|
||||||
|
associated with the data types.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
... ado.net/XML headers & schema ...
|
||||||
|
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||||
|
<resheader name="version">2.0</resheader>
|
||||||
|
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||||
|
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||||
|
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||||
|
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||||
|
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||||
|
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||||
|
</data>
|
||||||
|
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||||
|
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||||
|
<comment>This is a comment</comment>
|
||||||
|
</data>
|
||||||
|
|
||||||
|
There are any number of "resheader" rows that contain simple
|
||||||
|
name/value pairs.
|
||||||
|
|
||||||
|
Each data row contains a name, and value. The row also contains a
|
||||||
|
type or mimetype. Type corresponds to a .NET class that support
|
||||||
|
text/value conversion through the TypeConverter architecture.
|
||||||
|
Classes that don't support this are serialized and stored with the
|
||||||
|
mimetype set.
|
||||||
|
|
||||||
|
The mimetype is used for serialized objects, and tells the
|
||||||
|
ResXResourceReader how to depersist the object. This is currently not
|
||||||
|
extensible. For a given mimetype the value must be set accordingly:
|
||||||
|
|
||||||
|
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||||
|
that the ResXResourceWriter will generate, however the reader can
|
||||||
|
read any of the formats listed below.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.binary.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.soap.base64
|
||||||
|
value : The object must be serialized with
|
||||||
|
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
|
||||||
|
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||||
|
value : The object must be serialized into a byte array
|
||||||
|
: using a System.ComponentModel.TypeConverter
|
||||||
|
: and then encoded with base64 encoding.
|
||||||
|
-->
|
||||||
|
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||||
|
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||||
|
<xsd:element name="root" msdata:IsDataSet="true">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:choice maxOccurs="unbounded">
|
||||||
|
<xsd:element name="metadata">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="assembly">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:attribute name="alias" type="xsd:string" />
|
||||||
|
<xsd:attribute name="name" type="xsd:string" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="data">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||||
|
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||||
|
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||||
|
<xsd:attribute ref="xml:space" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
<xsd:element name="resheader">
|
||||||
|
<xsd:complexType>
|
||||||
|
<xsd:sequence>
|
||||||
|
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||||
|
</xsd:sequence>
|
||||||
|
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:choice>
|
||||||
|
</xsd:complexType>
|
||||||
|
</xsd:element>
|
||||||
|
</xsd:schema>
|
||||||
|
<resheader name="resmimetype">
|
||||||
|
<value>text/microsoft-resx</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="version">
|
||||||
|
<value>2.0</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="reader">
|
||||||
|
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<resheader name="writer">
|
||||||
|
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||||
|
</resheader>
|
||||||
|
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||||
|
<value>17, 17</value>
|
||||||
|
</metadata>
|
||||||
|
</root>
|
@ -11,26 +11,20 @@
|
|||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<Compile Remove="Halcon\**" />
|
|
||||||
<EmbeddedResource Remove="Halcon\**" />
|
|
||||||
<None Remove="Halcon\**" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\CanFly.Canvas\CanFly.Canvas.csproj" />
|
<ProjectReference Include="..\CanFly.Canvas\CanFly.Canvas.csproj" />
|
||||||
|
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Folder Include="Halcon\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AntdUI" Version="1.8.9" />
|
||||||
<PackageReference Include="OpenCvSharp4" Version="4.10.0.20241108" />
|
<PackageReference Include="OpenCvSharp4" Version="4.10.0.20241108" />
|
||||||
<PackageReference Include="OpenCvSharp4.Extensions" Version="4.10.0.20241108" />
|
<PackageReference Include="OpenCvSharp4.Extensions" Version="4.10.0.20241108" />
|
||||||
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.10.0.20241108" />
|
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.10.0.20241108" />
|
||||||
|
@ -1,186 +0,0 @@
|
|||||||
using System.Collections;
|
|
||||||
using System.ComponentModel;
|
|
||||||
using System.Drawing;
|
|
||||||
using System.Drawing.Imaging;
|
|
||||||
using DH.Commons.Enums;
|
|
||||||
using HalconDotNet;
|
|
||||||
using OpenCvSharp;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace DH.Devices.Devices
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 视觉处理引擎:1.传统视觉 2.深度学习
|
|
||||||
/// CV深度学习 四大领域
|
|
||||||
/// Image Classification 图像分类:判别图中物体是什么,比如是猫还是狗;
|
|
||||||
/// Semantic Segmentation 语义分割:对图像进行像素级分类,预测每个像素属于的类别,不区分个体;
|
|
||||||
/// Object Detection 目标检测:寻找图像中的物体并进行定位;
|
|
||||||
/// Instance Segmentation 实例分割:定位图中每个物体,并进行像素级标注,区分不同个体;
|
|
||||||
/// </summary>
|
|
||||||
public abstract class VisionEngineBase
|
|
||||||
{
|
|
||||||
public List<DetectionConfig> DetectionConfigs = new List<DetectionConfig>();
|
|
||||||
#region event
|
|
||||||
public event Action<string, List<double>> OnCropParamsOutput;
|
|
||||||
public event Action<string, Bitmap, List<IShapeElement>> OnDetectionDone;
|
|
||||||
public event Action<string> OnDetectionWarningStop;//有无检测 需要报警停机
|
|
||||||
#endregion
|
|
||||||
//public VisionEngineInitialConfigBase IConfig
|
|
||||||
//{
|
|
||||||
// get => InitialConfig as VisionEngineInitialConfigBase;
|
|
||||||
//}
|
|
||||||
// public ImageSaveHelper ImageSaveHelper { get; set; } = new ImageSaveHelper();
|
|
||||||
public string BatchNO { get; set; }
|
|
||||||
|
|
||||||
public HTuple hv_ModelID;
|
|
||||||
|
|
||||||
public abstract DetectStationResult RunInference(Mat originImgSet, string detectionId = null);
|
|
||||||
|
|
||||||
//public abstract void SaveDetectResultAsync(DetectStationResult detectResult);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public virtual void DetectionDone(string detectionId, Bitmap image, List<IShapeElement> detectionResults)
|
|
||||||
{
|
|
||||||
OnDetectionDone?.Invoke(detectionId, image, detectionResults);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void DetectionWarningStop(string detectionDes)
|
|
||||||
{
|
|
||||||
OnDetectionWarningStop?.Invoke(detectionDes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public virtual void SaveImageAsync(string fullname, Bitmap saveMap, ImageFormat imageFormat)
|
|
||||||
{
|
|
||||||
if (saveMap != null)
|
|
||||||
{
|
|
||||||
//ImageSaveSet imageSaveSet = new ImageSaveSet()
|
|
||||||
//{
|
|
||||||
// FullName = fullname,
|
|
||||||
// SaveImage = saveMap.CopyBitmap(),
|
|
||||||
// ImageFormat = imageFormat.DeepSerializeClone()
|
|
||||||
//};
|
|
||||||
|
|
||||||
//ImageSaveHelper.ImageSaveAsync(imageSaveSet);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
public class CamModuleXY
|
|
||||||
{
|
|
||||||
[Category("图片行")]
|
|
||||||
[DisplayName("行")]
|
|
||||||
[Description("行")]
|
|
||||||
// [TypeConverter(typeof(DeviceIdSelectorConverter<CameraBase>))]
|
|
||||||
//[TypeConverter(typeof(CollectionCountConvert))]
|
|
||||||
public int PicRows { get; set; } = 1;
|
|
||||||
|
|
||||||
[Category("图片列")]
|
|
||||||
[DisplayName("列")]
|
|
||||||
[Description("列")]
|
|
||||||
// [TypeConverter(typeof(DeviceIdSelectorConverter<CameraBase>))]
|
|
||||||
//[TypeConverter(typeof(CollectionCountConvert))]
|
|
||||||
public int PicCols { get; set; } = 1;
|
|
||||||
|
|
||||||
public string GetDisplayText()
|
|
||||||
{
|
|
||||||
return "行:" + PicRows.ToString() + "列:" + PicCols.ToString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//public class RelatedCamera
|
|
||||||
//{
|
|
||||||
|
|
||||||
// [Category("关联相机")]
|
|
||||||
// [DisplayName("关联相机")]
|
|
||||||
// [Description("关联相机描述")]
|
|
||||||
// //[TypeConverter(typeof(DeviceIdSelectorConverter<CameraBase>))]
|
|
||||||
// //[TypeConverter(typeof(CollectionCountConvert))]
|
|
||||||
// public string CameraSourceId { get; set; } = "";
|
|
||||||
|
|
||||||
|
|
||||||
// //public string GetDisplayText()
|
|
||||||
// //{
|
|
||||||
// // using (var scope = GlobalVar.Container.BeginLifetimeScope())
|
|
||||||
// // {
|
|
||||||
// // List<IDevice> deviceList = scope.Resolve<List<IDevice>>();
|
|
||||||
// // IDevice CameraDevice = deviceList.FirstOrDefault(dev => dev.Id.Equals(CameraSourceId));
|
|
||||||
|
|
||||||
// // if (CameraDevice != null && CameraDevice is CameraBase)
|
|
||||||
// // {
|
|
||||||
// // return CameraDevice.Name;
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // }
|
|
||||||
// // return CameraSourceId;
|
|
||||||
// //}
|
|
||||||
//}
|
|
||||||
public class VisionEngineInitialConfigBase //: InitialConfigBase
|
|
||||||
{
|
|
||||||
[Category("深度学习检测配置")]
|
|
||||||
[DisplayName("检测配置集合")]
|
|
||||||
[Description("检测配置集合")]
|
|
||||||
//[TypeConverter(typeof(CollectionCountConvert))]
|
|
||||||
//[Editor(typeof(ComplexCollectionEditor<DetectionConfig>), typeof(UITypeEditor))]
|
|
||||||
public List<DetectionConfig> DetectionConfigs { get; set; } = new List<DetectionConfig>();
|
|
||||||
|
|
||||||
[Category("深度学习检测配置")]
|
|
||||||
[DisplayName("标签分类")]
|
|
||||||
[Description("标签分类,A_NG,B_TBD...")]
|
|
||||||
// [TypeConverter(typeof(CollectionCountConvert))]
|
|
||||||
// [Editor(typeof(ComplexCollectionEditor<RecongnitionLabelCategory>), typeof(UITypeEditor))]
|
|
||||||
public List<RecongnitionLabelCategory> RecongnitionLabelCategoryList { get; set; } = new List<RecongnitionLabelCategory>();
|
|
||||||
|
|
||||||
[Category("深度学习检测配置")]
|
|
||||||
[DisplayName("检测标签定义集合")]
|
|
||||||
[Description("定义检测标签的集合,例如:Seg/Detection模式:断裂、油污、划伤...;Class模式:ok、ng、上面、下面、套环、正常...")]
|
|
||||||
// [TypeConverter(typeof(CollectionCountConvert))]
|
|
||||||
// [Editor(typeof(ComplexCollectionEditor<RecongnitionLabel>), typeof(UITypeEditor))]
|
|
||||||
public List<RecongnitionLabel> RecongnitionLabelList { get; set; } = new List<RecongnitionLabel>();
|
|
||||||
|
|
||||||
[Category("深度学习检测配置")]
|
|
||||||
[DisplayName("标签置信度")]
|
|
||||||
[Description("标签置信度,过滤小于改置信度的标签,大于该设置的标签才能识别")]
|
|
||||||
public float Score { get; set; } = 0.5f;
|
|
||||||
|
|
||||||
[Category("深度学习检测配置")]
|
|
||||||
[DisplayName("CPU线程数量")]
|
|
||||||
[Description("用于深度学习的CPU线程数量,不要设置太大,会单独占用线程,影响其他程序运行")]
|
|
||||||
public int CPUNums { get; set; } = 1;
|
|
||||||
|
|
||||||
//[Category("深度学习检测配置")]
|
|
||||||
//[DisplayName("检测项GPU指定")]
|
|
||||||
//[Description("将检测项指定到GPU")]
|
|
||||||
// [TypeConverter(typeof(CollectionCountConvert))]
|
|
||||||
// [Editor(typeof(ComplexCollectionEditor<DetectionGPUConfig>), typeof(UITypeEditor))]
|
|
||||||
// public List<DetectionGPUConfig> DetectionGPUList { get; set; } = new List<DetectionGPUConfig>();
|
|
||||||
|
|
||||||
// [Category("数据保存配置")]
|
|
||||||
//[DisplayName("是否保存检测明细CSV")]
|
|
||||||
//[Description("是否保存 检测明细CSV")]
|
|
||||||
//public override bool IsEnableCSV { get; set; } = true;
|
|
||||||
|
|
||||||
//[Category("数据保存配置")]
|
|
||||||
//[DisplayName("是否保存检测图片")]
|
|
||||||
//[Description("是否保存 检测图片,总开关")]
|
|
||||||
//public bool IsSaveImage { get; set; } = true;
|
|
||||||
|
|
||||||
//[Category("数据保存配置")]
|
|
||||||
//[Description("检测图片 保存文件夹")]
|
|
||||||
//[DisplayName("检测图片保存文件夹")]
|
|
||||||
//[Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
|
|
||||||
//public string ImageSaveDirectory { get; set; } = "D:\\PROJECTS\\X017\\Images";
|
|
||||||
|
|
||||||
//[Category("数据保存配置")]
|
|
||||||
//[Description("检测明细CSV文件夹")]
|
|
||||||
//[DisplayName("检测明细CSV文件夹")]
|
|
||||||
//[Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
|
|
||||||
//public string CSVDataPath { get; set; } = "D:\\PROJECTS\\X017\\Images";
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
|||||||
<PackageReference Include="OpenCvSharp4" Version="4.10.0.20241108" />
|
<PackageReference Include="OpenCvSharp4" Version="4.10.0.20241108" />
|
||||||
<PackageReference Include="OpenCvSharp4.Extensions" Version="4.10.0.20241108" />
|
<PackageReference Include="OpenCvSharp4.Extensions" Version="4.10.0.20241108" />
|
||||||
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.10.0.20241108" />
|
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.10.0.20241108" />
|
||||||
|
<PackageReference Include="System.IO.Ports" Version="9.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -2,36 +2,92 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
using AntdUI;
|
using AntdUI;
|
||||||
|
using DH.Commons.Enums;
|
||||||
|
using DVPCameraType;
|
||||||
|
using HalconDotNet;
|
||||||
using OpenCvSharp;
|
using OpenCvSharp;
|
||||||
|
|
||||||
namespace DH.Devices.Devices
|
namespace DH.Commons.Base
|
||||||
{
|
{
|
||||||
|
public class MatSet
|
||||||
|
{
|
||||||
|
public DateTime ImageTime { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
private string id = "";
|
||||||
|
public string Id
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(id))
|
||||||
|
{
|
||||||
|
id = ImageTime.ToString("HHmmssfff");
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
id = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public string CameraId { get; set; }
|
||||||
|
public Mat _mat { get; set; } = null;
|
||||||
|
|
||||||
|
public ImageFormat _imageFormat { get; set; } = ImageFormat.Jpeg;
|
||||||
|
public virtual void Dispose()
|
||||||
|
{
|
||||||
|
_mat?.Dispose();
|
||||||
|
_mat = null;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
public class CameraBase : NotifyProperty
|
public class CameraBase : NotifyProperty
|
||||||
{
|
{
|
||||||
|
|
||||||
|
// public LoggerHelper LoggerHelper { get; set; } = new LoggerHelper();
|
||||||
|
|
||||||
// 私有字段 + 带通知的属性(与DetectionLabel风格一致)
|
// 私有字段 + 带通知的属性(与DetectionLabel风格一致)
|
||||||
private bool _isEnabled = false;
|
private bool _isEnabled = false;
|
||||||
|
private bool _isallPicEnabled = true;//默认全画幅
|
||||||
|
private bool _isRGBEnabled = true;//默认彩色
|
||||||
private bool _isContinueMode = false;
|
private bool _isContinueMode = false;
|
||||||
private bool _isSavePicEnabled = false;
|
private bool _isSavePicEnabled = false;
|
||||||
|
private bool _isZoomCamera = false;
|
||||||
private string _imageSaveDirectory;
|
private string _imageSaveDirectory;
|
||||||
|
private EnumCamType _CamType;
|
||||||
|
private dvpStreamFormat _dvpstreamFormat = dvpStreamFormat.S_RGB24;
|
||||||
private ImageFormat _imageFormat = ImageFormat.Jpeg;
|
private ImageFormat _imageFormat = ImageFormat.Jpeg;
|
||||||
private bool _isHardwareTrigger = false;
|
private bool _isHardwareTrigger = true;
|
||||||
private string _serialNumber = string.Empty;
|
private string _serialNumber = string.Empty;
|
||||||
private string _cameraName = string.Empty;
|
private string _cameraName = string.Empty;
|
||||||
private string _cameraIP = string.Empty;
|
private string _cameraIP = string.Empty;
|
||||||
private string _computerIP = string.Empty;
|
private string _computerIP = string.Empty;
|
||||||
private bool _isDirectHardwareTrigger = false;
|
private bool _isDirectHardwareTrigger = false;
|
||||||
private float _gain = -1;
|
private float _gain =6;
|
||||||
private float _rotateImage = 0;
|
private int _rotateImage = 0;
|
||||||
private float _exposure = 200;
|
private float _exposure = 200;
|
||||||
private float _triggerDelay = 0;
|
private float _triggerDelay = 0;
|
||||||
private decimal _roiX = 0;
|
private decimal _roiX = 0;
|
||||||
private decimal _roiY = 0;
|
private decimal _roiY = 0;
|
||||||
private decimal _roiW = 0;
|
private decimal _roiW = 2448;
|
||||||
private decimal _roiH = 0;
|
private decimal _roiH = 2048;
|
||||||
private int _lineDebouncerTime = 0;
|
private int _lineDebouncerTime = 0;
|
||||||
|
|
||||||
public volatile int SnapshotCount = 0;
|
public volatile int SnapshotCount = 0;
|
||||||
|
|
||||||
|
[Category("相机设置")]
|
||||||
|
[DisplayName("图像格式")]
|
||||||
|
[Description("相机采集图像格式")]
|
||||||
|
public dvpStreamFormat DvpImageFormat
|
||||||
|
{
|
||||||
|
get => _dvpstreamFormat;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_dvpstreamFormat == value) return;
|
||||||
|
_dvpstreamFormat = value;
|
||||||
|
OnPropertyChanged(nameof(DvpImageFormat));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Category("采图模式")]
|
[Category("采图模式")]
|
||||||
[DisplayName("连续模式")]
|
[DisplayName("连续模式")]
|
||||||
[Description("是否连续模式。true:连续模式采图;false:触发模式采图")]
|
[Description("是否连续模式。true:连续模式采图;false:触发模式采图")]
|
||||||
@ -45,6 +101,16 @@ namespace DH.Devices.Devices
|
|||||||
OnPropertyChanged(nameof(IsContinueMode));
|
OnPropertyChanged(nameof(IsContinueMode));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public bool IsZoomCamera
|
||||||
|
{
|
||||||
|
get => _isZoomCamera;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_isZoomCamera == value) return;
|
||||||
|
_isZoomCamera = value;
|
||||||
|
OnPropertyChanged(nameof(IsZoomCamera));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public virtual bool IsEnabled
|
public virtual bool IsEnabled
|
||||||
{
|
{
|
||||||
@ -56,7 +122,16 @@ namespace DH.Devices.Devices
|
|||||||
OnPropertyChanged(nameof(IsEnabled));
|
OnPropertyChanged(nameof(IsEnabled));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public virtual bool IsAllPicEnabled
|
||||||
|
{
|
||||||
|
get => _isallPicEnabled;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_isallPicEnabled == value) return;
|
||||||
|
_isallPicEnabled = value;
|
||||||
|
OnPropertyChanged(nameof(IsAllPicEnabled));
|
||||||
|
}
|
||||||
|
}
|
||||||
public virtual bool IsSavePicEnabled
|
public virtual bool IsSavePicEnabled
|
||||||
{
|
{
|
||||||
get => _isSavePicEnabled;
|
get => _isSavePicEnabled;
|
||||||
@ -95,6 +170,19 @@ namespace DH.Devices.Devices
|
|||||||
OnPropertyChanged(nameof(ImageFormat));
|
OnPropertyChanged(nameof(ImageFormat));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
[Category("设备配置")]
|
||||||
|
[DisplayName("相机类型")]
|
||||||
|
[Description("相机类型")]
|
||||||
|
public EnumCamType CamType
|
||||||
|
{
|
||||||
|
get => _CamType;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_CamType == value) return;
|
||||||
|
_CamType = value;
|
||||||
|
OnPropertyChanged(nameof(CamType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Category("采图模式")]
|
[Category("采图模式")]
|
||||||
[DisplayName("硬触发")]
|
[DisplayName("硬触发")]
|
||||||
@ -185,7 +273,7 @@ namespace DH.Devices.Devices
|
|||||||
[Category("图像旋转")]
|
[Category("图像旋转")]
|
||||||
[DisplayName("默认旋转")]
|
[DisplayName("默认旋转")]
|
||||||
[Description("默认旋转,相机开启后默认不旋转")]
|
[Description("默认旋转,相机开启后默认不旋转")]
|
||||||
public virtual float RotateImage
|
public virtual int RotateImage
|
||||||
{
|
{
|
||||||
get => _rotateImage;
|
get => _rotateImage;
|
||||||
set
|
set
|
||||||
@ -283,7 +371,18 @@ namespace DH.Devices.Devices
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 其他方法保持原有逻辑
|
// 其他方法保持原有逻辑
|
||||||
public Action<DateTime, CameraBase, Mat> OnHImageOutput { get; set; }
|
public MatSet CopyImageSet(MatSet srcSet)
|
||||||
|
{
|
||||||
|
MatSet imageSet = new MatSet
|
||||||
|
{
|
||||||
|
Id = srcSet.Id,
|
||||||
|
_mat = srcSet._mat.Clone(),
|
||||||
|
// ImageSaveOption = srcSet.ImageSaveOption.Copy(),
|
||||||
|
ImageTime = srcSet.ImageTime
|
||||||
|
};
|
||||||
|
return imageSet;
|
||||||
|
}
|
||||||
|
public Action<DateTime, CameraBase, MatSet> OnHImageOutput { get; set; }
|
||||||
|
|
||||||
public virtual bool CameraConnect() { return false; }
|
public virtual bool CameraConnect() { return false; }
|
||||||
|
|
@ -9,27 +9,14 @@ using AntdUI;
|
|||||||
|
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using static DH.Commons.Enums.EnumHelper;
|
using static DH.Commons.Enums.EnumHelper;
|
||||||
using System.Collections.ObjectModel;
|
using System.Text.Json.Serialization;
|
||||||
|
using DH.Commons.Enums;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
|
||||||
|
namespace DH.Commons.Base
|
||||||
namespace DH.Commons.Enums
|
|
||||||
{
|
{
|
||||||
public enum MLModelType
|
|
||||||
{
|
public class ModelLabel
|
||||||
[Description("图像分类")]
|
|
||||||
ImageClassification = 1,
|
|
||||||
[Description("目标检测")]
|
|
||||||
ObjectDetection = 2,
|
|
||||||
//[Description("图像分割")]
|
|
||||||
//ImageSegmentation = 3
|
|
||||||
[Description("语义分割")]
|
|
||||||
SemanticSegmentation = 3,
|
|
||||||
[Description("实例分割")]
|
|
||||||
InstanceSegmentation = 4,
|
|
||||||
[Description("目标检测GPU")]
|
|
||||||
ObjectGPUDetection = 5
|
|
||||||
}
|
|
||||||
public class ModelLabel
|
|
||||||
{
|
{
|
||||||
public string LabelId { get; set; }
|
public string LabelId { get; set; }
|
||||||
|
|
||||||
@ -45,7 +32,7 @@ namespace DH.Commons.Enums
|
|||||||
[Description("模型识别的标签名称")]
|
[Description("模型识别的标签名称")]
|
||||||
public string LabelName { get; set; }
|
public string LabelName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//[Category("模型配置")]
|
//[Category("模型配置")]
|
||||||
@ -74,28 +61,28 @@ namespace DH.Commons.Enums
|
|||||||
//public int ImageResizeCount;
|
//public int ImageResizeCount;
|
||||||
public bool IsCLDetection;
|
public bool IsCLDetection;
|
||||||
public int ProCount;
|
public int ProCount;
|
||||||
public string in_node_name;
|
public string in_node_name;
|
||||||
|
|
||||||
public string out_node_name;
|
public string out_node_name;
|
||||||
|
|
||||||
public string in_lable_path;
|
public string in_lable_path;
|
||||||
|
|
||||||
public int ResizeImageSize;
|
public int ResizeImageSize;
|
||||||
public int segmentWidth;
|
public int segmentWidth;
|
||||||
public int ImageWidth;
|
public int ImageWidth;
|
||||||
|
|
||||||
// public List<labelStringBase> OkClassTxtList;
|
// public List<labelStringBase> OkClassTxtList;
|
||||||
|
|
||||||
|
|
||||||
public List<ModelLabel> LabelNames;
|
public List<ModelLabel> LabelNames;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public enum ResultState
|
public enum ResultState
|
||||||
{
|
{
|
||||||
|
|
||||||
[Description("检测NG")]
|
[Description("检测NG")]
|
||||||
DetectNG = -3,
|
DetectNG = -3,
|
||||||
|
|
||||||
@ -120,20 +107,20 @@ namespace DH.Commons.Enums
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class DetectionResultDetail
|
public class DetectionResultDetail
|
||||||
{
|
{
|
||||||
|
|
||||||
public string LabelBGR { get; set; }//识别到对象的标签BGR
|
public string LabelBGR { get; set; }//识别到对象的标签BGR
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public int LabelNo { get; set; } // 识别到对象的标签索引
|
public int LabelNo { get; set; } // 识别到对象的标签索引
|
||||||
|
|
||||||
|
|
||||||
public string LabelName { get; set; }//识别到对象的标签名称
|
public string LabelName { get; set; }//识别到对象的标签名称
|
||||||
|
|
||||||
|
|
||||||
public double Score { get; set; }//识别目标结果的可能性、得分
|
public double Score { get; set; }//识别目标结果的可能性、得分
|
||||||
|
|
||||||
|
|
||||||
public string LabelDisplay { get; set; }//识别到对象的 显示信息
|
public string LabelDisplay { get; set; }//识别到对象的 显示信息
|
||||||
|
|
||||||
|
|
||||||
@ -154,10 +141,10 @@ namespace DH.Commons.Enums
|
|||||||
public class MLResult
|
public class MLResult
|
||||||
{
|
{
|
||||||
public bool IsSuccess = false;
|
public bool IsSuccess = false;
|
||||||
|
|
||||||
public string ResultMessage;
|
public string ResultMessage;
|
||||||
|
|
||||||
|
|
||||||
public Bitmap ResultMap;
|
public Bitmap ResultMap;
|
||||||
|
|
||||||
public List<DetectionResultDetail> ResultDetails = new List<DetectionResultDetail>();
|
public List<DetectionResultDetail> ResultDetails = new List<DetectionResultDetail>();
|
||||||
@ -181,8 +168,7 @@ namespace DH.Commons.Enums
|
|||||||
public bool IsGPU;
|
public bool IsGPU;
|
||||||
public int GPUId;
|
public int GPUId;
|
||||||
public float Score_thre;
|
public float Score_thre;
|
||||||
|
|
||||||
|
|
||||||
public MLInit(string modelFile, bool isGPU, int gpuId, float score_thre)
|
public MLInit(string modelFile, bool isGPU, int gpuId, float score_thre)
|
||||||
|
|
||||||
|
|
||||||
@ -205,31 +191,48 @@ namespace DH.Commons.Enums
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public class DetectStationResult
|
public class DetectStationResult
|
||||||
{
|
{
|
||||||
|
public DateTime ImageTime { get; set; } = DateTime.Now;
|
||||||
|
|
||||||
|
private string id = "";
|
||||||
|
public string Id
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(id))
|
||||||
|
{
|
||||||
|
id = ImageTime.ToString("HHmmssfff");
|
||||||
|
}
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
id = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
public string Pid { get; set; }
|
public string Pid { get; set; }
|
||||||
|
|
||||||
|
public string TempPid { get; set; }
|
||||||
|
|
||||||
public string TempPid { get; set; }
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检测工位名称
|
/// 检测工位名称
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
public string DetectName { get; set; }
|
public string DetectName { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 深度学习 检测结果
|
/// 深度学习 检测结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public List<DetectionResultDetail> DetectDetails = new List<DetectionResultDetail>();
|
public List<DetectionResultDetail> DetectDetails = new List<DetectionResultDetail>();
|
||||||
public List<IShapeElement> DetectionResultShapes = new List<IShapeElement>();
|
public List<IShapeElement> DetectionResultShapes = new List<IShapeElement>();
|
||||||
|
/// <summary>
|
||||||
|
/// 视觉测量结果集合
|
||||||
|
/// </summary>
|
||||||
|
|
||||||
|
public List<IndexedSpec> realSpecs { get; set; } = new List<IndexedSpec>();
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 工位检测结果
|
/// 工位检测结果
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -254,36 +257,25 @@ namespace DH.Commons.Enums
|
|||||||
/// 预处理阶段已经NG
|
/// 预处理阶段已经NG
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsPreTreatNG { get; set; } = false;
|
public bool IsPreTreatNG { get; set; } = false;
|
||||||
|
/// <summary>
|
||||||
|
/// 检测原图
|
||||||
|
/// </summary>
|
||||||
|
public Bitmap DetectionOriginImage { get; set; }
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 目标检测NG
|
/// 目标检测NG
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool IsObjectDetectNG { get; set; } = false;
|
public bool IsObjectDetectNG { get; set; } = false;
|
||||||
|
public ImageFormat ImageFormat { get; set; } = ImageFormat.Jpeg;
|
||||||
public DateTime EndTime { get; set; }
|
public DateTime EndTime { get; set; }
|
||||||
|
|
||||||
|
public string ImageSaveDirectory { get; set; }
|
||||||
public int StationDetectElapsed { get; set; }
|
public int StationDetectElapsed { get; set; }
|
||||||
public static string NormalizeAndClean(string input)
|
public bool SaveOKOriginal = false;
|
||||||
{
|
public bool SaveNGOriginal = false;
|
||||||
#pragma warning disable CS8603 // 可能返回 null 引用
|
public bool SaveOKDetect = false;
|
||||||
if (input == null) return null;
|
public bool SaveNGDetect = false;
|
||||||
#pragma warning restore CS8603 // 可能返回 null 引用
|
|
||||||
|
|
||||||
// Step 1: 标准化字符编码为 Form C (规范组合)
|
|
||||||
string normalizedString = input.Normalize(NormalizationForm.FormC);
|
|
||||||
|
|
||||||
// Step 2: 移除所有空白字符,包括制表符和换行符
|
|
||||||
string withoutWhitespace = Regex.Replace(normalizedString, @"\s+", "");
|
|
||||||
|
|
||||||
// Step 3: 移除控制字符 (Unicode 控制字符,范围 \u0000 - \u001F 和 \u007F)
|
|
||||||
string withoutControlChars = Regex.Replace(withoutWhitespace, @"[\u0000-\u001F\u007F]+", "");
|
|
||||||
|
|
||||||
// Step 4: 移除特殊的不可见字符(如零宽度空格等)
|
|
||||||
string cleanedString = Regex.Replace(withoutControlChars, @"[\u200B\u200C\u200D\uFEFF]+", "");
|
|
||||||
|
|
||||||
return cleanedString;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
public class RelatedCamera : NotifyProperty
|
public class RelatedCamera : NotifyProperty
|
||||||
{
|
{
|
||||||
@ -406,7 +398,7 @@ namespace DH.Commons.Enums
|
|||||||
|
|
||||||
public static double GetDistance(CustomizedPoint p1, CustomizedPoint p2)
|
public static double GetDistance(CustomizedPoint p1, CustomizedPoint p2)
|
||||||
{
|
{
|
||||||
return Math.Sqrt(Math.Pow((p1.X - p2.X), 2) + Math.Pow((p1.Y - p2.Y), 2));
|
return Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
@ -447,13 +439,13 @@ namespace DH.Commons.Enums
|
|||||||
|
|
||||||
public int CompareTo(CustomizedPoint other)
|
public int CompareTo(CustomizedPoint other)
|
||||||
{
|
{
|
||||||
return (X == other.X && Y == other.Y) ? 0 : 1;
|
return X == other.X && Y == other.Y ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
//return (int)(X * 10 + Y);
|
//return (int)(X * 10 + Y);
|
||||||
return (new Tuple<double, double>(X, Y)).GetHashCode();
|
return new Tuple<double, double>(X, Y).GetHashCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CustomizedPoint operator -(CustomizedPoint p1, CustomizedPoint p2)
|
public static CustomizedPoint operator -(CustomizedPoint p1, CustomizedPoint p2)
|
||||||
@ -476,7 +468,7 @@ namespace DH.Commons.Enums
|
|||||||
// [Category("预处理参数")]
|
// [Category("预处理参数")]
|
||||||
// [DisplayName("参数名称")]
|
// [DisplayName("参数名称")]
|
||||||
// [Description("参数名称")]
|
// [Description("参数名称")]
|
||||||
//
|
//#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||||
// public string Name { get; set; }
|
// public string Name { get; set; }
|
||||||
|
|
||||||
|
|
||||||
@ -488,7 +480,7 @@ namespace DH.Commons.Enums
|
|||||||
// [Category("预处理参数")]
|
// [Category("预处理参数")]
|
||||||
// [DisplayName("参数值")]
|
// [DisplayName("参数值")]
|
||||||
// [Description("参数值")]
|
// [Description("参数值")]
|
||||||
//
|
//#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||||
// public string Value { get; set; }
|
// public string Value { get; set; }
|
||||||
|
|
||||||
|
|
||||||
@ -496,48 +488,135 @@ namespace DH.Commons.Enums
|
|||||||
// }
|
// }
|
||||||
public class DetectionConfig : NotifyProperty
|
public class DetectionConfig : NotifyProperty
|
||||||
{
|
{
|
||||||
#region 基本信息
|
#region 属性字段
|
||||||
[JsonPropertyName("id")]
|
private string _id = Guid.NewGuid().ToString();
|
||||||
|
private string _name;
|
||||||
|
private EnumDetectionType _detectionType= EnumDetectionType.深度学习;
|
||||||
|
private string _cameraSourceId = "";
|
||||||
|
private List<RelatedCamera> _cameraCollects = new List<RelatedCamera>();
|
||||||
|
private bool _isEnableGPU;
|
||||||
|
private bool _isMixModel;
|
||||||
|
private bool _isPreEnabled;
|
||||||
|
private bool _isEnabled;
|
||||||
|
private bool _isAddStation = true;
|
||||||
|
private string _halconAlgorithemPath_Pre;
|
||||||
|
private AntList<PreTreatParam> _preTreatParams = new AntList<PreTreatParam>();
|
||||||
|
private AntList<PreTreatParam> _outPreTreatParams = new AntList<PreTreatParam>();
|
||||||
|
private ModelType _modelType = ModelType.目标检测;
|
||||||
|
private string _modelPath;
|
||||||
|
private int _modelWidth = 640;
|
||||||
|
private int _modelHeight = 640;
|
||||||
|
private string _modeloutNodeName = "output0";
|
||||||
|
private float _modelconfThreshold = 0.5f;
|
||||||
|
private string _in_lable_path;
|
||||||
|
private AntList<DetectionLable> _detectionLableList = new AntList<DetectionLable>();
|
||||||
|
private AntList<SizeTreatParam> _sizeTreatParamList = new AntList<SizeTreatParam>();
|
||||||
|
|
||||||
|
private CustomizedPoint _showLocation = new CustomizedPoint();
|
||||||
|
private string _imageSaveDirectory= "D://PROJECTS//Images//";
|
||||||
|
private bool _saveOKOriginal = false;
|
||||||
|
private bool _saveNGOriginal = false;
|
||||||
|
private bool _saveOKDetect = false;
|
||||||
|
private bool _saveNGDetect = false;
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 属性声明
|
||||||
[ReadOnly(true)]
|
[ReadOnly(true)]
|
||||||
public string Id { get; private set; } = Guid.NewGuid().ToString();
|
public string Id
|
||||||
|
{
|
||||||
|
get => _id;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_id == value) return;
|
||||||
|
_id = value;
|
||||||
|
OnPropertyChanged(nameof(Id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Category("检测配置")]
|
[Category("检测配置")]
|
||||||
[DisplayName("检测配置名称")]
|
[DisplayName("检测配置名称")]
|
||||||
[Description("检测配置名称")]
|
[Description("检测配置名称")]
|
||||||
[JsonPropertyName("name")]
|
public string Name
|
||||||
public string Name { get; set; }
|
{
|
||||||
|
get => _name;
|
||||||
#endregion
|
set
|
||||||
|
{
|
||||||
#region 相机配置
|
if (_name == value) return;
|
||||||
[Category("关联相机")]
|
_name = value;
|
||||||
[DisplayName("关联相机")]
|
OnPropertyChanged(nameof(Name));
|
||||||
[Description("关联相机描述")]
|
}
|
||||||
[JsonPropertyName("camera_source_id")]
|
}
|
||||||
public string CameraSourceId { get; set; } = "";
|
|
||||||
|
|
||||||
[Category("关联相机集合")]
|
[Category("关联相机集合")]
|
||||||
[DisplayName("关联相机集合")]
|
[DisplayName("关联相机集合")]
|
||||||
[Description("关联相机描述")]
|
[Description("关联相机描述")]
|
||||||
[JsonPropertyName("camera_Collects")]
|
public List<RelatedCamera> CameraCollects
|
||||||
public List<RelatedCamera> CameraCollects { get; set; } = new();
|
{
|
||||||
#endregion
|
get => _cameraCollects;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_cameraCollects == value) return;
|
||||||
|
_cameraCollects = value;
|
||||||
|
OnPropertyChanged(nameof(CameraCollects));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region 启用选项
|
|
||||||
[Category("启用配置")]
|
[Category("启用配置")]
|
||||||
[DisplayName("是否启用GPU检测")]
|
[DisplayName("是否启用GPU检测")]
|
||||||
[JsonPropertyName("is_enable_gpu")]
|
[Description("是否启用GPU检测")]
|
||||||
public bool IsEnableGPU { get; set; }
|
public bool IsEnableGPU
|
||||||
|
{
|
||||||
|
get => _isEnableGPU;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_isEnableGPU == value) return;
|
||||||
|
_isEnableGPU = value;
|
||||||
|
OnPropertyChanged(nameof(IsEnableGPU));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Category("启用配置")]
|
[Category("启用配置")]
|
||||||
[DisplayName("是否混料模型")]
|
[DisplayName("是否混料模型")]
|
||||||
[JsonPropertyName("is_mixModel")]
|
[Description("是否混料模型")]
|
||||||
public bool IsMixModel { get; set; }
|
public bool IsMixModel
|
||||||
|
{
|
||||||
|
get => _isMixModel;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_isMixModel == value) return;
|
||||||
|
_isMixModel = value;
|
||||||
|
OnPropertyChanged(nameof(IsMixModel));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("启用配置")]
|
||||||
|
[DisplayName("是否启用预处理")]
|
||||||
|
[Description("是否启用预处理")]
|
||||||
|
public bool IsPreEnabled
|
||||||
|
{
|
||||||
|
get => _isPreEnabled;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_isPreEnabled == value) return;
|
||||||
|
_isPreEnabled = value;
|
||||||
|
OnPropertyChanged(nameof(IsPreEnabled));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Category("启用配置")]
|
[Category("启用配置")]
|
||||||
[DisplayName("是否启用该检测")]
|
[DisplayName("是否启用该检测")]
|
||||||
[JsonPropertyName("is_enabled")]
|
[Description("是否启用该检测")]
|
||||||
public bool IsEnabled { get; set; }
|
public bool IsEnabled
|
||||||
|
{
|
||||||
|
get => _isEnabled;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_isEnabled == value) return;
|
||||||
|
_isEnabled = value;
|
||||||
|
OnPropertyChanged(nameof(IsEnabled));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Category("启用配置")]
|
[Category("启用配置")]
|
||||||
[DisplayName("是否启用预处理")]
|
[DisplayName("是否启用预处理")]
|
||||||
@ -548,133 +627,293 @@ namespace DH.Commons.Enums
|
|||||||
private bool _isAddStation;
|
private bool _isAddStation;
|
||||||
[Category("启用配置")]
|
[Category("启用配置")]
|
||||||
[DisplayName("是否加入检测工位")]
|
[DisplayName("是否加入检测工位")]
|
||||||
[JsonPropertyName("is_addstation")]
|
[Description("是否加入检测工位")]
|
||||||
public bool IsAddStation
|
public bool IsAddStation
|
||||||
{
|
{
|
||||||
get => _isAddStation;
|
get => _isAddStation;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_isAddStation != value)
|
if (_isAddStation == value) return;
|
||||||
{
|
_isAddStation = value;
|
||||||
_isAddStation = value;
|
OnPropertyChanged(nameof(IsAddStation));
|
||||||
OnPropertyChanged(nameof(IsAddStation));
|
}
|
||||||
}
|
}
|
||||||
|
[Category("图片保存")]
|
||||||
|
[DisplayName("图片保存文件夹")]
|
||||||
|
[Description("图片保存文件夹")]
|
||||||
|
public virtual string ImageSaveDirectory
|
||||||
|
{
|
||||||
|
get => _imageSaveDirectory;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_imageSaveDirectory == value) return;
|
||||||
|
_imageSaveDirectory = value;
|
||||||
|
OnPropertyChanged(nameof(ImageSaveDirectory));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 预处理(视觉算子)
|
|
||||||
[Category("1.预处理(视觉算子)")]
|
[Category("1.预处理(视觉算子)")]
|
||||||
[DisplayName("预处理-算法文件路径")]
|
[DisplayName("预处理-算法文件路径")]
|
||||||
[JsonPropertyName("halcon_algorithemPath_pre")]
|
public string HalconAlgorithemPath_Pre
|
||||||
public string HalconAlgorithemPath_Pre { get; set; }
|
{
|
||||||
|
get => _halconAlgorithemPath_Pre;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_halconAlgorithemPath_Pre == value) return;
|
||||||
|
_halconAlgorithemPath_Pre = value;
|
||||||
|
OnPropertyChanged(nameof(HalconAlgorithemPath_Pre));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Category("1.预处理(视觉算子)")]
|
[Category("1.预处理(视觉算子)")]
|
||||||
[DisplayName("预处理-参数列表")]
|
[DisplayName("预处理-参数列表")]
|
||||||
[JsonPropertyName("pre_treatParams")]
|
[Description("预处理-参数列表")]
|
||||||
public List<PreTreatParam> PreTreatParams { get; set; } = new();
|
public AntList<PreTreatParam> PreTreatParams
|
||||||
|
|
||||||
[Category("1.预处理(视觉算子)")]
|
|
||||||
[DisplayName("预处理-输出参数列表")]
|
|
||||||
[JsonPropertyName("out_preTreatParams")]
|
|
||||||
public List<PreTreatParam> OUTPreTreatParams { get; set; } = new();
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 深度学习检测
|
|
||||||
[Category("2.中检测(深度学习)")]
|
|
||||||
[DisplayName("模型类型")]
|
|
||||||
[JsonPropertyName("model_Type")]
|
|
||||||
public MLModelType ModelType { get; set; } = MLModelType.ObjectDetection;
|
|
||||||
|
|
||||||
[Category("2.中检测(深度学习)")]
|
|
||||||
[DisplayName("模型文件路径")]
|
|
||||||
[JsonPropertyName("model_Path")]
|
|
||||||
public string ModelPath { get; set; }
|
|
||||||
|
|
||||||
[Category("2.中检测(深度学习)")]
|
|
||||||
[DisplayName("模型宽度")]
|
|
||||||
[JsonPropertyName("model_Width")]
|
|
||||||
public int ModelWidth { get; set; } = 640;
|
|
||||||
|
|
||||||
[Category("2.中检测(深度学习)")]
|
|
||||||
[DisplayName("模型高度")]
|
|
||||||
[JsonPropertyName("model_Height")]
|
|
||||||
public int ModelHeight { get; set; } = 640;
|
|
||||||
|
|
||||||
[Category("2.中检测(深度学习)")]
|
|
||||||
[DisplayName("模型节点名称")]
|
|
||||||
[JsonPropertyName("model_outNodeName")]
|
|
||||||
public string ModeloutNodeName { get; set; } = "output0";
|
|
||||||
|
|
||||||
[Category("2.中检测(深度学习)")]
|
|
||||||
[DisplayName("模型置信度")]
|
|
||||||
[JsonPropertyName("model_confThreshold")]
|
|
||||||
public float ModelconfThreshold { get; set; } = 0.5f;
|
|
||||||
|
|
||||||
[Category("2.中检测(深度学习)")]
|
|
||||||
[DisplayName("模型标签路径")]
|
|
||||||
[JsonPropertyName("in_lablepath")]
|
|
||||||
public string in_lable_path { get; set; }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region 尺寸测量
|
|
||||||
|
|
||||||
// public List<SizeTreatParam> PreTreatCollects { get; set; } = new();
|
|
||||||
private List<SizeTreatParam> _preTreatParams = new();
|
|
||||||
|
|
||||||
[Category("1.尺寸测量集合")]
|
|
||||||
[DisplayName("尺寸测量集合")]
|
|
||||||
[JsonPropertyName("Pre_TreatCollects")]
|
|
||||||
public List<SizeTreatParam> PreTreatCollects
|
|
||||||
{
|
{
|
||||||
get => _preTreatParams;
|
get => _preTreatParams;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_preTreatParams != value)
|
if (_preTreatParams == value) return;
|
||||||
{
|
_preTreatParams = value;
|
||||||
_preTreatParams = value;
|
OnPropertyChanged(nameof(PreTreatParams));
|
||||||
OnPropertyChanged(nameof(PreTreatCollects));
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
[Category("1.预处理(视觉算子)")]
|
||||||
|
[DisplayName("预处理-输出参数列表")]
|
||||||
|
[Description("预处理-输出参数列表")]
|
||||||
|
public AntList<PreTreatParam> OUTPreTreatParams
|
||||||
|
{
|
||||||
|
get => _outPreTreatParams;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_outPreTreatParams == value) return;
|
||||||
|
_outPreTreatParams = value;
|
||||||
|
OnPropertyChanged(nameof(OUTPreTreatParams));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region 过滤器
|
[Category("2.中检测(深度学习)")]
|
||||||
[Category("4.最终过滤(逻辑过滤)")]
|
[DisplayName("中检测-模型类型")]
|
||||||
[DisplayName("过滤器集合")]
|
[Description("模型类型:ImageClassification-图片分类;ObjectDetection:目标检测;Segmentation-图像分割")]
|
||||||
[JsonPropertyName("detection_filterList")]
|
public ModelType ModelType
|
||||||
public List<DetectionFilter> DetectionFilterList { get; set; } = new();
|
{
|
||||||
#endregion
|
get => _modelType;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_modelType == value) return;
|
||||||
|
_modelType = value;
|
||||||
|
OnPropertyChanged(nameof(ModelType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#region 其他信息
|
[Category("2.中检测(深度学习)")]
|
||||||
[JsonPropertyName("Detection_LableList")]
|
[DisplayName("中检测-模型文件路径")]
|
||||||
public List<DetectionLable> DetectionLableList { get; set; } = new();
|
[Description("中处理 深度学习模型文件路径")]
|
||||||
|
public string ModelPath
|
||||||
|
{
|
||||||
|
get => _modelPath;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_modelPath == value) return;
|
||||||
|
_modelPath = value;
|
||||||
|
OnPropertyChanged(nameof(ModelPath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("2.中检测(深度学习)")]
|
||||||
|
[DisplayName("中检测-模型宽度")]
|
||||||
|
[Description("中处理-模型宽度")]
|
||||||
|
public int ModelWidth
|
||||||
|
{
|
||||||
|
get => _modelWidth;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_modelWidth == value) return;
|
||||||
|
_modelWidth = value;
|
||||||
|
OnPropertyChanged(nameof(ModelWidth));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("2.中检测(深度学习)")]
|
||||||
|
[DisplayName("中检测-模型高度")]
|
||||||
|
[Description("中处理-模型高度")]
|
||||||
|
public int ModelHeight
|
||||||
|
{
|
||||||
|
get => _modelHeight;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_modelHeight == value) return;
|
||||||
|
_modelHeight = value;
|
||||||
|
OnPropertyChanged(nameof(ModelHeight));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("2.中检测(深度学习)")]
|
||||||
|
[DisplayName("中检测-模型节点名称")]
|
||||||
|
[Description("中处理-模型节点名称")]
|
||||||
|
public string ModeloutNodeName
|
||||||
|
{
|
||||||
|
get => _modeloutNodeName;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_modeloutNodeName == value) return;
|
||||||
|
_modeloutNodeName = value;
|
||||||
|
OnPropertyChanged(nameof(ModeloutNodeName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("2.中检测(深度学习)")]
|
||||||
|
[DisplayName("中检测-模型置信度")]
|
||||||
|
[Description("中处理-模型置信度")]
|
||||||
|
public float ModelconfThreshold
|
||||||
|
{
|
||||||
|
get => _modelconfThreshold;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_modelconfThreshold == value) return;
|
||||||
|
_modelconfThreshold = value;
|
||||||
|
OnPropertyChanged(nameof(ModelconfThreshold));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("2.中检测(深度学习)")]
|
||||||
|
[DisplayName("中检测-模型标签路径")]
|
||||||
|
[Description("中处理-模型标签路径")]
|
||||||
|
public string In_lable_path
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(ModelPath) || string.IsNullOrWhiteSpace(ModelPath))
|
||||||
|
{
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
string dir = Path.GetDirectoryName(ModelPath);
|
||||||
|
string file = $"{Path.GetFileNameWithoutExtension(ModelPath)}.txt";
|
||||||
|
return Path.Combine(dir, file);
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_in_lable_path == value) return;
|
||||||
|
_in_lable_path = value;
|
||||||
|
OnPropertyChanged(nameof(In_lable_path));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("检测配置")]
|
||||||
|
[DisplayName("检测类型")]
|
||||||
|
[Description("检测类型")]
|
||||||
|
public EnumDetectionType DetectionType
|
||||||
|
{
|
||||||
|
get => _detectionType;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_detectionType == value) return;
|
||||||
|
_detectionType = value;
|
||||||
|
OnPropertyChanged(nameof(DetectionType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[Category("显示配置")]
|
[Category("显示配置")]
|
||||||
[DisplayName("显示位置")]
|
[DisplayName("显示位置")]
|
||||||
[JsonPropertyName("Show_Location")]
|
[Description("检测信息显示位置")]
|
||||||
public CustomizedPoint ShowLocation { get; set; } = new();
|
public CustomizedPoint ShowLocation
|
||||||
#endregion
|
{
|
||||||
//public event PropertyChangedEventHandler PropertyChanged;
|
get => _showLocation;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_showLocation == value) return;
|
||||||
|
_showLocation = value;
|
||||||
|
OnPropertyChanged(nameof(ShowLocation));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//protected virtual void OnPropertyChanged(string propertyName)
|
/// <summary>
|
||||||
//{
|
/// 标签集合(需确保DetectionLable也实现INotifyPropertyChanged)
|
||||||
// PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
/// </summary>
|
||||||
//}
|
public AntList<DetectionLable> DetectionLableList
|
||||||
|
{
|
||||||
|
get => _detectionLableList;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_detectionLableList == value) return;
|
||||||
|
_detectionLableList = value;
|
||||||
|
OnPropertyChanged(nameof(DetectionLableList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public AntList<SizeTreatParam> SizeTreatParamList
|
||||||
|
{
|
||||||
|
get => _sizeTreatParamList;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_sizeTreatParamList == value) return;
|
||||||
|
_sizeTreatParamList = value;
|
||||||
|
OnPropertyChanged(nameof(SizeTreatParamList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public bool SaveOKOriginal
|
||||||
|
{
|
||||||
|
get => _saveOKOriginal;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_saveOKOriginal == value) return;
|
||||||
|
_saveOKOriginal = value;
|
||||||
|
OnPropertyChanged(nameof(SaveOKOriginal));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool SaveNGOriginal
|
||||||
|
{
|
||||||
|
get => _saveNGOriginal;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_saveNGOriginal == value) return;
|
||||||
|
_saveNGOriginal = value;
|
||||||
|
OnPropertyChanged(nameof(SaveNGOriginal));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool SaveOKDetect
|
||||||
|
{
|
||||||
|
get => _saveOKDetect;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_saveOKDetect == value) return;
|
||||||
|
_saveOKDetect = value;
|
||||||
|
OnPropertyChanged(nameof(SaveOKDetect));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool SaveNGDetect
|
||||||
|
{
|
||||||
|
get => _saveNGDetect;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_saveNGDetect == value) return;
|
||||||
|
_saveNGDetect = value;
|
||||||
|
OnPropertyChanged(nameof(SaveNGDetect));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
#region 构造函数
|
#region 构造函数
|
||||||
public DetectionConfig() { }
|
public DetectionConfig() { }
|
||||||
|
|
||||||
public DetectionConfig(string name, MLModelType modelType, string modelPath, bool isEnableGPU, string sCameraSourceId)
|
public DetectionConfig(
|
||||||
|
string name,
|
||||||
|
ModelType modelType,
|
||||||
|
string modelPath,
|
||||||
|
bool isEnableGPU,
|
||||||
|
string sCameraSourceId)
|
||||||
{
|
{
|
||||||
|
// 通过属性赋值触发通知
|
||||||
|
ModelPath = modelPath ?? string.Empty;
|
||||||
Name = name;
|
Name = name;
|
||||||
ModelType = modelType;
|
ModelType = modelType;
|
||||||
ModelPath = modelPath ?? string.Empty;
|
ModelPath = modelPath ?? string.Empty;
|
||||||
IsEnableGPU = isEnableGPU;
|
IsEnableGPU = isEnableGPU;
|
||||||
CameraSourceId = sCameraSourceId;
|
|
||||||
Id = Guid.NewGuid().ToString();
|
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
@ -727,6 +966,7 @@ namespace DH.Commons.Enums
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CellLink[] cellLinks;
|
private CellLink[] cellLinks;
|
||||||
|
[JsonIgnore]
|
||||||
public CellLink[] CellLinks
|
public CellLink[] CellLinks
|
||||||
{
|
{
|
||||||
get {
|
get {
|
||||||
@ -747,17 +987,18 @@ namespace DH.Commons.Enums
|
|||||||
public class DetectionLable : NotifyProperty
|
public class DetectionLable : NotifyProperty
|
||||||
{
|
{
|
||||||
private bool _selected = false;
|
private bool _selected = false;
|
||||||
|
|
||||||
private string _labelId;
|
private string _labelId;
|
||||||
private string _labelName;
|
private string _labelName;
|
||||||
private double _maxSource;
|
private double _maxScore;
|
||||||
private double _minSource;
|
private double _minScore;
|
||||||
private double _maxArea;
|
private double _maxArea;
|
||||||
private double _minArea;
|
private double _minArea;
|
||||||
private ResultState _resultState = ResultState.ResultTBD;
|
private ResultState _resultState = ResultState.ResultTBD;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public bool Selected
|
public bool Selected
|
||||||
{
|
{
|
||||||
get { return _selected; }
|
get { return _selected; }
|
||||||
@ -792,27 +1033,26 @@ namespace DH.Commons.Enums
|
|||||||
OnPropertyChanged(nameof(LabelName));
|
OnPropertyChanged(nameof(LabelName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[JsonPropertyName("maxSource")]
|
|
||||||
public double MaxSource
|
public double MaxScore
|
||||||
{
|
{
|
||||||
get { return _maxSource; }
|
get { return _maxScore; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_maxSource.Equals(value)) return;
|
if (_maxScore.Equals(value)) return;
|
||||||
_maxSource = value;
|
_maxScore = value;
|
||||||
OnPropertyChanged(nameof(MaxSource));
|
OnPropertyChanged(nameof(MaxScore));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[JsonPropertyName("minSource")]
|
public double MinScore
|
||||||
public double MinSource
|
|
||||||
{
|
{
|
||||||
get { return _minSource; }
|
get { return _minScore; }
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
if (_minSource.Equals(value)) return;
|
if (_minScore.Equals(value)) return;
|
||||||
_minSource = value;
|
_minScore = value;
|
||||||
OnPropertyChanged(nameof(MinSource));
|
OnPropertyChanged(nameof(MinScore));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
[JsonPropertyName("maxArea")]
|
[JsonPropertyName("maxArea")]
|
||||||
@ -850,6 +1090,7 @@ namespace DH.Commons.Enums
|
|||||||
}
|
}
|
||||||
|
|
||||||
private CellLink[] cellLinks;
|
private CellLink[] cellLinks;
|
||||||
|
[JsonIgnore]
|
||||||
public CellLink[] CellLinks
|
public CellLink[] CellLinks
|
||||||
{
|
{
|
||||||
get {
|
get {
|
||||||
@ -862,6 +1103,15 @@ namespace DH.Commons.Enums
|
|||||||
OnPropertyChanged(nameof(CellLinks));
|
OnPropertyChanged(nameof(CellLinks));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool FilterOperation(DetectionResultDetail recongnitionResult)
|
||||||
|
{
|
||||||
|
|
||||||
|
double compareValue = recongnitionResult.Area;
|
||||||
|
double compareScoreValue = recongnitionResult.Score;
|
||||||
|
return (compareValue >= MinArea && compareValue <= MaxArea)&& (compareScoreValue >= MinScore && compareScoreValue <= MaxScore);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
public class PreTreatCollect
|
public class PreTreatCollect
|
||||||
{
|
{
|
||||||
@ -999,7 +1249,7 @@ namespace DH.Commons.Enums
|
|||||||
_resultShow = value;
|
_resultShow = value;
|
||||||
OnPropertyChanged(nameof(ResultShow));
|
OnPropertyChanged(nameof(ResultShow));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string OutResultShow
|
public string OutResultShow
|
||||||
@ -1013,19 +1263,20 @@ namespace DH.Commons.Enums
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//public string PrePath
|
public string PrePath
|
||||||
//{
|
{
|
||||||
// get { return _prePath; }
|
get { return _prePath; }
|
||||||
// set
|
set
|
||||||
// {
|
{
|
||||||
// if (_prePath.Equals(value)) return;
|
if (_prePath.Equals(value)) return;
|
||||||
// _prePath = value;
|
_prePath = value;
|
||||||
// OnPropertyChanged(nameof(PrePath));
|
OnPropertyChanged(nameof(PrePath));
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CellLink[] cellLinks;
|
private CellLink[] cellLinks;
|
||||||
|
[JsonIgnore]
|
||||||
public CellLink[] CellLinks
|
public CellLink[] CellLinks
|
||||||
{
|
{
|
||||||
get { return cellLinks; }
|
get { return cellLinks; }
|
||||||
@ -1063,9 +1314,9 @@ namespace DH.Commons.Enums
|
|||||||
//[TypeConverter(typeof(LabelCategoryConverter))]
|
//[TypeConverter(typeof(LabelCategoryConverter))]
|
||||||
public string LabelCategory { get; set; } = "";
|
public string LabelCategory { get; set; } = "";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -1126,8 +1377,8 @@ namespace DH.Commons.Enums
|
|||||||
//public string GetLabelName()
|
//public string GetLabelName()
|
||||||
//{
|
//{
|
||||||
// var name = "";
|
// var name = "";
|
||||||
|
|
||||||
|
|
||||||
// var mlBase = iConfig.DeviceConfigs.FirstOrDefault(c => c is VisionEngineInitialConfigBase) as VisionEngineInitialConfigBase;
|
// var mlBase = iConfig.DeviceConfigs.FirstOrDefault(c => c is VisionEngineInitialConfigBase) as VisionEngineInitialConfigBase;
|
||||||
// if (mlBase != null)
|
// if (mlBase != null)
|
||||||
// {
|
// {
|
||||||
@ -1138,7 +1389,7 @@ namespace DH.Commons.Enums
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// return name;
|
// return name;
|
||||||
//}
|
//}
|
||||||
}
|
}
|
||||||
@ -1199,11 +1450,11 @@ namespace DH.Commons.Enums
|
|||||||
[DisplayName("过滤条件集合")]
|
[DisplayName("过滤条件集合")]
|
||||||
[Description("过滤条件集合,集合之间为“且”关系")]
|
[Description("过滤条件集合,集合之间为“且”关系")]
|
||||||
//[TypeConverter(typeof(CollectionCountConvert))]
|
//[TypeConverter(typeof(CollectionCountConvert))]
|
||||||
// [Editor(typeof(ComplexCollectionEditor<FilterConditions>), typeof(UITypeEditor))]
|
// [Editor(typeof(ComplexCollectionEditor<FilterConditions>), typeof(UITypeEditor))]
|
||||||
public List<FilterConditions> FilterConditionsCollection { get; set; } = new List<FilterConditions>();
|
public List<FilterConditions> FilterConditionsCollection { get; set; } = new List<FilterConditions>();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public bool FilterOperation(DetectionResultDetail recongnitionResult)
|
public bool FilterOperation(DetectionResultDetail recongnitionResult)
|
||||||
{
|
{
|
||||||
return FilterConditionsCollection.All(u =>
|
return FilterConditionsCollection.All(u =>
|
389
DH.Commons/Base/DeviceBase.cs
Normal file
389
DH.Commons/Base/DeviceBase.cs
Normal file
@ -0,0 +1,389 @@
|
|||||||
|
|
||||||
|
using DH.Commons.Enums;
|
||||||
|
using OpenCvSharp.Internal;
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using static DH.Commons.Enums.EnumHelper;
|
||||||
|
using Timer = System.Threading.Timer;
|
||||||
|
|
||||||
|
namespace DH.Commons.Base
|
||||||
|
{
|
||||||
|
public abstract class DeviceBase : IDisposable
|
||||||
|
{
|
||||||
|
#region Event
|
||||||
|
[JsonIgnore]
|
||||||
|
[Browsable(false)]
|
||||||
|
public Action<DateTime, Exception> OnExceptionOccured { get; set; }
|
||||||
|
//public event Action<DateTime, LogLevel, string> OnLog;
|
||||||
|
public event Action<LogMsg> OnLog;
|
||||||
|
// public event Action<IDevice, DeviceState> OnDeviceStateChanged;
|
||||||
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region field
|
||||||
|
int RetryTime = 3;
|
||||||
|
/// <summary>
|
||||||
|
/// 和设备暂停状态关联的信号量
|
||||||
|
/// </summary>
|
||||||
|
private readonly ManualResetEvent pauseHandle = new ManualResetEvent(true);
|
||||||
|
readonly Timer stateChangedTimer;
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Property
|
||||||
|
#region State
|
||||||
|
private EnumHelper.DeviceState _currentStateToBe = EnumHelper.DeviceState.DSUninit;
|
||||||
|
/// <summary>
|
||||||
|
/// 当前设备状态
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
internal EnumHelper.DeviceState CurrentStateToBe
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _currentStateToBe;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (value != _currentStateToBe)
|
||||||
|
{
|
||||||
|
var initialState = _currentStateToBe;
|
||||||
|
_currentStateToBe = value;
|
||||||
|
|
||||||
|
if (_currentStateToBe != EnumHelper.DeviceState.DSExcept)
|
||||||
|
{
|
||||||
|
// OnStateChanged(initialState);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
stateChangedTimer.Change(Timeout.Infinite, Timeout.Infinite);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//private EnumHelper.DeviceState initialState = EnumHelper.DeviceState.DSUninit;
|
||||||
|
private EnumHelper.DeviceState _currentState = EnumHelper.DeviceState.DSUninit;
|
||||||
|
public EnumHelper.DeviceState CurrentState
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _currentState;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_currentState = value;
|
||||||
|
|
||||||
|
if (value != EnumHelper.DeviceState.TBD)
|
||||||
|
{
|
||||||
|
// OnDeviceStateChanged?.Invoke(this, _currentState);
|
||||||
|
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("CurrentState"));
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// initialState = _currentState;
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备标识符 从数据库获取
|
||||||
|
/// </summary>
|
||||||
|
public string Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设备名称 从数据库获取
|
||||||
|
/// </summary>
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
//private IInitialConfig initialConfig = null;
|
||||||
|
///// <summary>
|
||||||
|
///// 设备初始化配置 从数据库获取
|
||||||
|
///// </summary>
|
||||||
|
//public virtual IInitialConfig InitialConfig
|
||||||
|
//{
|
||||||
|
// get => initialConfig;
|
||||||
|
// set
|
||||||
|
// {
|
||||||
|
// initialConfig = value;
|
||||||
|
// Id = initialConfig.Id;
|
||||||
|
// Name = initialConfig.Name;
|
||||||
|
|
||||||
|
// LoggerHelper.LogPath = initialConfig.LogPath;
|
||||||
|
// LoggerHelper.LogPrefix = initialConfig.Name;
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 构造函数
|
||||||
|
public DeviceBase()
|
||||||
|
{
|
||||||
|
RegisterFileWriterException();
|
||||||
|
// stateChangedTimer = new Timer(new TimerCallback(CheckDeviceOpTimeOut), null, Timeout.Infinite, Timeout.Infinite);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 设备抽象方法
|
||||||
|
protected virtual void Init()
|
||||||
|
{
|
||||||
|
LogAsync(DateTime.Now, LogLevel.Information, $"{Name}初始化完成");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
protected virtual void Start()
|
||||||
|
{
|
||||||
|
LogAsync(DateTime.Now, LogLevel.Information, $"{Name}启动");
|
||||||
|
}
|
||||||
|
|
||||||
|
protected virtual void Stop()
|
||||||
|
{
|
||||||
|
LogAsync(DateTime.Now, LogLevel.Information, $"{Name}停止");
|
||||||
|
}
|
||||||
|
|
||||||
|
//public abstract void AttachToProcess(IProcess process);
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 常用操作封装方法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="opConfig"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//public virtual ResponseMessage RunWrap(IOperationConfig opConfig)
|
||||||
|
//{
|
||||||
|
// ResponseMessage msg = new ResponseMessage();
|
||||||
|
// msg.Message = "设备基类默认操作";
|
||||||
|
// return msg;
|
||||||
|
//}
|
||||||
|
|
||||||
|
#region 状态切换
|
||||||
|
//[DeviceExceptionAspect]
|
||||||
|
//public void StateChange(EnumHelper.DeviceState stateToBe)
|
||||||
|
//{
|
||||||
|
// if (CurrentState == stateToBe)
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (!stateToBe.CheckPreStateValid((int)CurrentStateToBe))
|
||||||
|
// {
|
||||||
|
// string currentStateStr = CurrentStateToBe.GetEnumDescription();
|
||||||
|
// string stateToBeStr = stateToBe.GetEnumDescription();
|
||||||
|
// throw new ProcessException($"{InitialConfig.Name}设备的当前状态为{currentStateStr},无法切换至{stateToBeStr}");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// CurrentState = EnumHelper.DeviceState.TBD;
|
||||||
|
// CurrentStateToBe = stateToBe;
|
||||||
|
//}
|
||||||
|
|
||||||
|
//[DeviceExceptionAspect]
|
||||||
|
//private void OnStateChanged(EnumHelper.DeviceState initialState)
|
||||||
|
//{
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// if (CurrentStateToBe != EnumHelper.DeviceState.DSExcept)
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// if (CurrentState == EnumHelper.DeviceState.DSExcept)
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// throw new ProcessException($"{InitialConfig.Name}设备操作超时");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (RetryTime >= 0)
|
||||||
|
// {
|
||||||
|
// if (initialState == CurrentStateToBe)
|
||||||
|
// {
|
||||||
|
// CurrentState = CurrentStateToBe;
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// #region 状态切换操作
|
||||||
|
// switch (CurrentStateToBe)
|
||||||
|
// {
|
||||||
|
// case EnumHelper.DeviceState.DSInit:
|
||||||
|
// if (initialState == EnumHelper.DeviceState.DSOpen)
|
||||||
|
// {
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// Init();
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
// case EnumHelper.DeviceState.DSOpen:
|
||||||
|
// if (initialState == EnumHelper.DeviceState.DSInit)
|
||||||
|
// {
|
||||||
|
// Start();
|
||||||
|
// }
|
||||||
|
// else if (initialState == EnumHelper.DeviceState.DSPause)
|
||||||
|
// {
|
||||||
|
// Resume();
|
||||||
|
// pauseHandle.Set();
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
// case EnumHelper.DeviceState.DSPause:
|
||||||
|
// pauseHandle.Reset();
|
||||||
|
// Pause();
|
||||||
|
// break;
|
||||||
|
// case EnumHelper.DeviceState.DSClose:
|
||||||
|
// if (initialState != DeviceState.DSUninit)
|
||||||
|
// {
|
||||||
|
// Stop();
|
||||||
|
// }
|
||||||
|
// break;
|
||||||
|
// default:
|
||||||
|
// break;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// RetryTime = 3;
|
||||||
|
// CurrentState = CurrentStateToBe;
|
||||||
|
// #endregion
|
||||||
|
// }
|
||||||
|
|
||||||
|
// stateChangedTimer.Change(Timeout.Infinite, Timeout.Infinite);
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// RetryTime--;
|
||||||
|
// if (RetryTime > 0)
|
||||||
|
// {
|
||||||
|
// OnStateChanged(initialState);
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// if (CurrentState != EnumHelper.DeviceState.DSExcept)
|
||||||
|
// {
|
||||||
|
// RetryTime = 3;
|
||||||
|
// throw new ProcessException($"设备{InitialConfig.Name}的{CurrentStateToBe.GetEnumDescription()}操作重复3次失败", ex, ExceptionLevel.Warning);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//private void CheckDeviceOpTimeOut(object state)
|
||||||
|
//{
|
||||||
|
// stateChangedTimer?.Change(Timeout.Infinite, Timeout.Infinite);
|
||||||
|
|
||||||
|
// if (CurrentState != EnumHelper.DeviceState.DSExcept)
|
||||||
|
// {
|
||||||
|
// StateChange(EnumHelper.DeviceState.DSExcept);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 日志处理
|
||||||
|
private void RegisterFileWriterException()
|
||||||
|
{
|
||||||
|
LoggerHelper.OnLogExceptionRaised -= LoggerHelper_OnLogExceptionRaised;
|
||||||
|
// CSVHelper.OnCSVExceptionRaised -= LoggerHelper_OnLogExceptionRaised;
|
||||||
|
|
||||||
|
LoggerHelper.OnLogExceptionRaised += LoggerHelper_OnLogExceptionRaised;
|
||||||
|
// CSVHelper.OnCSVExceptionRaised += LoggerHelper_OnLogExceptionRaised;
|
||||||
|
}
|
||||||
|
// public CSVHelper CSVHelper { get; set; } = new CSVHelper();
|
||||||
|
|
||||||
|
public LoggerHelper LoggerHelper { get; set; } = new LoggerHelper();
|
||||||
|
|
||||||
|
public virtual void LogAsync(LogMsg msg)
|
||||||
|
{
|
||||||
|
msg.MsgSource = Name;
|
||||||
|
msg.ThreadId = Thread.CurrentThread.ManagedThreadId;
|
||||||
|
|
||||||
|
//OnLog?.BeginInvoke(msg, null, null);
|
||||||
|
OnLog?.Invoke(msg);
|
||||||
|
|
||||||
|
//if (InitialConfig.IsEnableLog)
|
||||||
|
//{
|
||||||
|
LoggerHelper.LogAsync(msg);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void LogAsync(DateTime dt, LogLevel logLevel, string msg)
|
||||||
|
{
|
||||||
|
LogAsync(new LogMsg(dt, logLevel, msg));
|
||||||
|
}
|
||||||
|
private void LoggerHelper_OnLogExceptionRaised(DateTime dt, string msg)
|
||||||
|
{
|
||||||
|
OnLog?.Invoke(new LogMsg(dt, LogLevel.Error, msg));
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// CSV异步数据输出
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="csvFile">CSV输出文件的文件全路径</param>
|
||||||
|
/// <param name="csvData">CSV输出数据</param>
|
||||||
|
/// <param name="csvHead">CSV文件表头</param>
|
||||||
|
public virtual void CSVRecordAsync(string csvFile, string csvData, string csvHead = "")
|
||||||
|
{
|
||||||
|
// CSVHelper.CSVOutputAsync(csvFile, csvData, csvHead);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region 报警记录
|
||||||
|
//object _alarmLock = new object();
|
||||||
|
//protected virtual async void SaveAlarmCSVAsync(DateTime now, string deviceName, IWarningSet ws)
|
||||||
|
//{
|
||||||
|
// await Task.Run(() =>
|
||||||
|
// {
|
||||||
|
// LogAsync(now, LogLevel.Warning, $"{ws.WarningCode}-{ws.WarningDescription} {(ws.CurrentStatus ? "发生" : "取消")}");
|
||||||
|
|
||||||
|
// if (string.IsNullOrWhiteSpace(this.InitialConfig.LogPath) || !InitialConfig.IsEnableCSV)
|
||||||
|
// return;
|
||||||
|
|
||||||
|
// string path = Path.Combine(InitialConfig.LogPath, $"Alarm_{Name}_{now.ToString("yyyyMMdd")}.csv");
|
||||||
|
// string head = "Time,Source,AlarmCode,AlarmDescription,AlarmStatus";
|
||||||
|
// string data = $"{now.ToString("HH:mm:ss.fff")},{deviceName},{ws.WarningCode},{ws.WarningDescription},{(ws.CurrentStatus ? "报警发生" : "报警取消")}";
|
||||||
|
// CSVRecordAsync(path, data, head);
|
||||||
|
// });
|
||||||
|
//}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region IDisposable Support
|
||||||
|
private bool disposedValue = false; // 要检测冗余调用
|
||||||
|
|
||||||
|
protected virtual void Dispose(bool disposing)
|
||||||
|
{
|
||||||
|
if (!disposedValue)
|
||||||
|
{
|
||||||
|
if (disposing)
|
||||||
|
{
|
||||||
|
//释放托管状态(托管对象)。
|
||||||
|
stateChangedTimer?.Dispose();
|
||||||
|
pauseHandle?.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: 释放未托管的资源(未托管的对象)并在以下内容中替代终结器。
|
||||||
|
// TODO: 将大型字段设置为 null。
|
||||||
|
|
||||||
|
disposedValue = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: 仅当以上 Dispose(bool disposing) 拥有用于释放未托管资源的代码时才替代终结器。
|
||||||
|
// ~DeviceBase()
|
||||||
|
// {
|
||||||
|
// // 请勿更改此代码。将清理代码放入以上 Dispose(bool disposing) 中。
|
||||||
|
// Dispose(false);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// 添加此代码以正确实现可处置模式。
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
// 请勿更改此代码。将清理代码放入以上 Dispose(bool disposing) 中。
|
||||||
|
Dispose(true);
|
||||||
|
// TODO: 如果在以上内容中替代了终结器,则取消注释以下行。
|
||||||
|
// GC.SuppressFinalize(this);
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
169
DH.Commons/Base/GlobalConfig.cs
Normal file
169
DH.Commons/Base/GlobalConfig.cs
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Xml.Linq;
|
||||||
|
using AntdUI;
|
||||||
|
|
||||||
|
namespace DH.Commons.Base
|
||||||
|
{
|
||||||
|
public class GlobalConfig : NotifyProperty
|
||||||
|
{
|
||||||
|
bool _EnableVibrator=false;
|
||||||
|
bool _EnableBelt = false;
|
||||||
|
int _ClearTime=0;
|
||||||
|
string _name;
|
||||||
|
private BindingList<PLCItem> _InitProcessList = new BindingList<PLCItem>();
|
||||||
|
private BindingList<PLCItem> _StartProcessList = new BindingList<PLCItem>();
|
||||||
|
private BindingList<PLCItem> _StopProcessList = new BindingList<PLCItem>();
|
||||||
|
private BindingList<PLCItem> _StartResetList = new BindingList<PLCItem>();
|
||||||
|
private BindingList<PLCItem> _StopResetList = new BindingList<PLCItem>();
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get => _name;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_name != value)
|
||||||
|
{
|
||||||
|
_name = value;
|
||||||
|
OnPropertyChanged(nameof(Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool EnableBelt
|
||||||
|
{
|
||||||
|
get => _EnableBelt;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_EnableBelt != value)
|
||||||
|
{
|
||||||
|
_EnableBelt = value;
|
||||||
|
OnPropertyChanged(nameof(EnableBelt));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public bool EnableVibrator
|
||||||
|
{
|
||||||
|
get => _EnableVibrator;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_EnableVibrator != value)
|
||||||
|
{
|
||||||
|
_EnableVibrator = value;
|
||||||
|
OnPropertyChanged(nameof(EnableVibrator));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int ClearTime
|
||||||
|
{
|
||||||
|
get => _ClearTime;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_ClearTime != value)
|
||||||
|
{
|
||||||
|
_ClearTime = value;
|
||||||
|
OnPropertyChanged(nameof(ClearTime));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public BindingList<PLCItem> InitProcessList
|
||||||
|
{
|
||||||
|
get => _InitProcessList;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_InitProcessList == value) return;
|
||||||
|
_InitProcessList = value;
|
||||||
|
OnPropertyChanged(nameof(InitProcessList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public BindingList<PLCItem> StartProcessList
|
||||||
|
{
|
||||||
|
get => _StartProcessList;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_StartProcessList == value) return;
|
||||||
|
_StartProcessList = value;
|
||||||
|
OnPropertyChanged(nameof(StartProcessList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public BindingList<PLCItem> StopProcessList
|
||||||
|
{
|
||||||
|
get => _StopProcessList;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_StopProcessList == value) return;
|
||||||
|
_StopProcessList = value;
|
||||||
|
OnPropertyChanged(nameof(StopProcessList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public BindingList<PLCItem> StartResetList
|
||||||
|
{
|
||||||
|
get => _StartResetList;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_StartResetList == value) return;
|
||||||
|
_StartResetList = value;
|
||||||
|
OnPropertyChanged(nameof(StartResetList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public BindingList<PLCItem> StopResetList
|
||||||
|
{
|
||||||
|
get => _StopResetList;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_StopResetList == value) return;
|
||||||
|
_StopResetList = value;
|
||||||
|
OnPropertyChanged(nameof(StopResetList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string _imgSavePath;
|
||||||
|
string _dbSavePath;
|
||||||
|
string _configSavePath;
|
||||||
|
|
||||||
|
public string ImgSavePath
|
||||||
|
{
|
||||||
|
get => _imgSavePath;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_imgSavePath != value)
|
||||||
|
{
|
||||||
|
_imgSavePath = value;
|
||||||
|
OnPropertyChanged(nameof(ImgSavePath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DbSavePath
|
||||||
|
{
|
||||||
|
get => _dbSavePath;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_dbSavePath != value)
|
||||||
|
{
|
||||||
|
_dbSavePath = value;
|
||||||
|
OnPropertyChanged(nameof(DbSavePath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string ConfigSavePath
|
||||||
|
{
|
||||||
|
get => _configSavePath;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_configSavePath != value)
|
||||||
|
{
|
||||||
|
_configSavePath = value;
|
||||||
|
OnPropertyChanged(nameof(ConfigSavePath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
378
DH.Commons/Base/PLCBase.cs
Normal file
378
DH.Commons/Base/PLCBase.cs
Normal file
@ -0,0 +1,378 @@
|
|||||||
|
using System.ComponentModel;
|
||||||
|
using System.IO.Ports;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using AntdUI;
|
||||||
|
using DH.Commons.Enums; // 请确保此命名空间包含EnumPLCType
|
||||||
|
|
||||||
|
namespace DH.Commons.Base
|
||||||
|
{
|
||||||
|
public class PLCBase : NotifyProperty
|
||||||
|
{
|
||||||
|
|
||||||
|
// 私有字段
|
||||||
|
private bool _enable;
|
||||||
|
private bool _connected;
|
||||||
|
private string _plcName;
|
||||||
|
private EnumPLCType _plcType;
|
||||||
|
private string _com = "COM1";
|
||||||
|
private int _baudRate = 9600;
|
||||||
|
private int _dataBit = 8;
|
||||||
|
private StopBits _stopBit = StopBits.One;
|
||||||
|
private Parity _parity = Parity.None;
|
||||||
|
private string _ip = "192.168.6.61";
|
||||||
|
private int _port = 502;
|
||||||
|
private BindingList<PLCItem> _PLCItemList = new BindingList<PLCItem>();
|
||||||
|
|
||||||
|
[Category("设备配置")]
|
||||||
|
[DisplayName("是否启用")]
|
||||||
|
[Description("是否启用")]
|
||||||
|
public bool Enable
|
||||||
|
{
|
||||||
|
get => _enable;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_enable == value) return;
|
||||||
|
_enable = value;
|
||||||
|
OnPropertyChanged(nameof(Enable));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[Category("状态监控")]
|
||||||
|
[DisplayName("连接状态")]
|
||||||
|
[Description("PLC连接状态")]
|
||||||
|
public bool Connected
|
||||||
|
{
|
||||||
|
get => _connected;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_connected == value) return;
|
||||||
|
_connected = value;
|
||||||
|
OnPropertyChanged(nameof(Connected));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("设备配置")]
|
||||||
|
[DisplayName("PLC名称")]
|
||||||
|
[Description("PLC设备名称")]
|
||||||
|
public string PLCName
|
||||||
|
{
|
||||||
|
get => _plcName;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_plcName == value) return;
|
||||||
|
_plcName = value;
|
||||||
|
OnPropertyChanged(nameof(PLCName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("设备配置")]
|
||||||
|
[DisplayName("PLC类型")]
|
||||||
|
[Description("PLC通信协议类型")]
|
||||||
|
public EnumPLCType PLCType
|
||||||
|
{
|
||||||
|
get => _plcType;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_plcType == value) return;
|
||||||
|
_plcType = value;
|
||||||
|
OnPropertyChanged(nameof(PLCType));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("串口配置")]
|
||||||
|
[DisplayName("COM端口")]
|
||||||
|
[Description("串口号,如COM1")]
|
||||||
|
public string COM
|
||||||
|
{
|
||||||
|
get => _com;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_com == value) return;
|
||||||
|
_com = value;
|
||||||
|
OnPropertyChanged(nameof(COM));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("串口配置")]
|
||||||
|
[DisplayName("波特率")]
|
||||||
|
[Description("串口通信波特率")]
|
||||||
|
public int BaudRate
|
||||||
|
{
|
||||||
|
get => _baudRate;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_baudRate == value) return;
|
||||||
|
_baudRate = value;
|
||||||
|
OnPropertyChanged(nameof(BaudRate));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("串口配置")]
|
||||||
|
[DisplayName("数据位")]
|
||||||
|
[Description("数据位长度(5/6/7/8)")]
|
||||||
|
public int DataBit
|
||||||
|
{
|
||||||
|
get => _dataBit;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_dataBit == value) return;
|
||||||
|
_dataBit = value;
|
||||||
|
OnPropertyChanged(nameof(DataBit));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("串口配置")]
|
||||||
|
[DisplayName("停止位")]
|
||||||
|
[Description("停止位设置")]
|
||||||
|
public StopBits StopBit
|
||||||
|
{
|
||||||
|
get => _stopBit;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_stopBit == value) return;
|
||||||
|
_stopBit = value;
|
||||||
|
OnPropertyChanged(nameof(StopBit));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("串口配置")]
|
||||||
|
[DisplayName("校验位")]
|
||||||
|
[Description("奇偶校验方式")]
|
||||||
|
public Parity Parity
|
||||||
|
{
|
||||||
|
get => _parity;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_parity == value) return;
|
||||||
|
_parity = value;
|
||||||
|
OnPropertyChanged(nameof(Parity));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("网络配置")]
|
||||||
|
[DisplayName("IP地址")]
|
||||||
|
[Description("PLC网络地址")]
|
||||||
|
public string IP
|
||||||
|
{
|
||||||
|
get => _ip;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_ip == value) return;
|
||||||
|
_ip = value;
|
||||||
|
OnPropertyChanged(nameof(IP));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("网络配置")]
|
||||||
|
[DisplayName("端口号")]
|
||||||
|
[Description("网络通信端口")]
|
||||||
|
public int Port
|
||||||
|
{
|
||||||
|
get => _port;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_port == value) return;
|
||||||
|
_port = value;
|
||||||
|
OnPropertyChanged(nameof(Port));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Category("点位配置")]
|
||||||
|
[DisplayName("点位配置")]
|
||||||
|
[Description("点位配置")]
|
||||||
|
public BindingList<PLCItem> PLCItemList
|
||||||
|
{
|
||||||
|
get => _PLCItemList;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_PLCItemList == value) return;
|
||||||
|
_PLCItemList = value;
|
||||||
|
OnPropertyChanged(nameof(PLCItemList));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public virtual bool PLCConnect()
|
||||||
|
{
|
||||||
|
Connected = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual bool PLCDisConnect()
|
||||||
|
{
|
||||||
|
Connected = false;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual Int16 ReadInt16(string address) { return 0; }
|
||||||
|
|
||||||
|
public virtual Int32 ReadInt32(string address) { return 0; }
|
||||||
|
|
||||||
|
public virtual UInt16 ReadUInt16(string address) { return 0; }
|
||||||
|
|
||||||
|
public virtual UInt32 ReadUInt32(string address) { return 0; }
|
||||||
|
public virtual float ReadFloat(string address) { return 0; }
|
||||||
|
public virtual bool ReadBool(string address) { return false; }
|
||||||
|
|
||||||
|
public virtual bool WriteInt16(string address, Int16 value, bool waitForReply = true) { return false; }
|
||||||
|
public virtual bool WriteInt32(string address, Int32 value, bool waitForReply = true) { return false; }
|
||||||
|
|
||||||
|
|
||||||
|
public virtual bool WriteUInt16(string address, UInt16 value, bool waitForReply = true) { return false; }
|
||||||
|
public virtual bool WriteUInt32(string address, UInt32 value, bool waitForReply = true) { return false; }
|
||||||
|
|
||||||
|
public virtual bool WriteFloat(string address, float value, bool waitForReply = true) { return false; }
|
||||||
|
public virtual bool WriteBool(string address, bool value, bool waitForReply = true) { return false; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class PLCItem : NotifyProperty
|
||||||
|
{
|
||||||
|
private bool _selected;
|
||||||
|
private string _name = string.Empty;
|
||||||
|
private EnumPLCDataType _type;
|
||||||
|
private string _value = string.Empty;
|
||||||
|
private bool _startexecute;
|
||||||
|
private int _startindex;
|
||||||
|
private string _address;
|
||||||
|
/// <summary>
|
||||||
|
/// 是否选中
|
||||||
|
/// </summary>
|
||||||
|
public bool Selected
|
||||||
|
{
|
||||||
|
get => _selected;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_selected != value)
|
||||||
|
{
|
||||||
|
_selected = value;
|
||||||
|
OnPropertyChanged(nameof(Selected));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 参数名称
|
||||||
|
/// </summary>
|
||||||
|
public string Name
|
||||||
|
{
|
||||||
|
get => _name;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_name != value)
|
||||||
|
{
|
||||||
|
_name = value;
|
||||||
|
OnPropertyChanged(nameof(Name));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public EnumPLCDataType Type
|
||||||
|
{
|
||||||
|
get => _type;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_type != value)
|
||||||
|
{
|
||||||
|
_type = value;
|
||||||
|
OnPropertyChanged(nameof(Type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 参数类型
|
||||||
|
/// </summary>
|
||||||
|
public string Address
|
||||||
|
{
|
||||||
|
get => _address;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_address != value)
|
||||||
|
{
|
||||||
|
_address = value;
|
||||||
|
OnPropertyChanged(nameof(Address));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 参数值
|
||||||
|
/// </summary>
|
||||||
|
public string Value
|
||||||
|
{
|
||||||
|
get => _value;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_value != value)
|
||||||
|
{
|
||||||
|
_value = value;
|
||||||
|
OnPropertyChanged(nameof(Value));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 启用状态
|
||||||
|
/// </summary>
|
||||||
|
public bool StartExecute
|
||||||
|
{
|
||||||
|
get => _startexecute;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_startexecute != value)
|
||||||
|
{
|
||||||
|
_startexecute = value;
|
||||||
|
OnPropertyChanged(nameof(StartExecute));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 顺序
|
||||||
|
/// </summary>
|
||||||
|
public int StartIndex
|
||||||
|
{
|
||||||
|
get => _startindex;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (_startindex != value)
|
||||||
|
{
|
||||||
|
_startindex = value;
|
||||||
|
OnPropertyChanged(nameof(StartIndex));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private CellLink[] cellLinks;
|
||||||
|
[JsonIgnore]
|
||||||
|
public CellLink[] CellLinks
|
||||||
|
{
|
||||||
|
get { return cellLinks; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (cellLinks == value) return;
|
||||||
|
cellLinks = value;
|
||||||
|
OnPropertyChanged(nameof(CellLinks));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//private CellTag[] cellTags;
|
||||||
|
//[JsonIgnore]
|
||||||
|
//public CellTag[] CellTags
|
||||||
|
//{
|
||||||
|
// get { return cellTags; }
|
||||||
|
// set
|
||||||
|
// {
|
||||||
|
// if (cellTags == value) return;
|
||||||
|
// cellTags = value;
|
||||||
|
// OnPropertyChanged(nameof(CellTags));
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
78
DH.Commons/Base/VisionEngineBase.cs
Normal file
78
DH.Commons/Base/VisionEngineBase.cs
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using DH.Commons.Enums;
|
||||||
|
using DH.Commons.Helper;
|
||||||
|
using HalconDotNet;
|
||||||
|
using OpenCvSharp;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace DH.Commons.Base
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 视觉处理引擎:1.传统视觉 2.深度学习
|
||||||
|
/// CV深度学习 四大领域
|
||||||
|
/// Image Classification 图像分类:判别图中物体是什么,比如是猫还是狗;
|
||||||
|
/// Semantic Segmentation 语义分割:对图像进行像素级分类,预测每个像素属于的类别,不区分个体;
|
||||||
|
/// Object Detection 目标检测:寻找图像中的物体并进行定位;
|
||||||
|
/// Instance Segmentation 实例分割:定位图中每个物体,并进行像素级标注,区分不同个体;
|
||||||
|
/// </summary>
|
||||||
|
public abstract class VisionEngineBase : DeviceBase
|
||||||
|
{
|
||||||
|
public List<DetectionConfig> DetectionConfigs = new List<DetectionConfig>();
|
||||||
|
#region event
|
||||||
|
public event Action<string, List<double>> OnCropParamsOutput;
|
||||||
|
public event Action<string, Bitmap, List<IShapeElement>> OnDetectionDone;
|
||||||
|
public event Action<string> OnDetectionWarningStop;//有无检测 需要报警停机
|
||||||
|
#endregion
|
||||||
|
//public VisionEngineInitialConfigBase IConfig
|
||||||
|
//{
|
||||||
|
// get => InitialConfig as VisionEngineInitialConfigBase;
|
||||||
|
//}
|
||||||
|
// public ImageSaveHelper ImageSaveHelper { get; set; } = new ImageSaveHelper();
|
||||||
|
public string BatchNO { get; set; }
|
||||||
|
|
||||||
|
public HTuple hv_ModelID;
|
||||||
|
|
||||||
|
public abstract DetectStationResult RunInference(MatSet originImgSet, string detectionId = null);
|
||||||
|
|
||||||
|
//public abstract void SaveDetectResultAsync(DetectStationResult detectResult);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public virtual void DetectionDone(string detectionId, Bitmap image, List<IShapeElement> detectionResults)
|
||||||
|
{
|
||||||
|
OnDetectionDone?.Invoke(detectionId, image, detectionResults);
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual void DetectionWarningStop(string detectionDes)
|
||||||
|
{
|
||||||
|
OnDetectionWarningStop?.Invoke(detectionDes);
|
||||||
|
}
|
||||||
|
public ImageSaveHelper ImageSaveHelper { get; set; } = new ImageSaveHelper();
|
||||||
|
public virtual void SaveImageAsync(string fullname, Bitmap saveMap, ImageFormat imageFormat)
|
||||||
|
{
|
||||||
|
if (saveMap != null)
|
||||||
|
{
|
||||||
|
ImageSaveSet imageSaveSet = new ImageSaveSet()
|
||||||
|
{
|
||||||
|
FullName = fullname,
|
||||||
|
SaveImage = saveMap.CopyBitmap(),
|
||||||
|
ImageFormat = imageFormat.DeepSerializeClone()
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
ImageSaveHelper.ImageSaveAsync(imageSaveSet);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
80
DH.Commons/Base/VisualLocalization.cs
Normal file
80
DH.Commons/Base/VisualLocalization.cs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace DH.Commons.Base
|
||||||
|
{
|
||||||
|
public class VisualLocalization
|
||||||
|
{
|
||||||
|
// 配置属性
|
||||||
|
public string CameraName { get; set; }
|
||||||
|
public string ModelPath { get; set; }
|
||||||
|
public string ImgPath { get; set; }
|
||||||
|
public string Threshold { get; set; }
|
||||||
|
public string Direction { get; set; }
|
||||||
|
public string Speed { get; set; }
|
||||||
|
|
||||||
|
public string MSpeed { get; set; }
|
||||||
|
|
||||||
|
// 配置文件路径
|
||||||
|
private const string ConfigFile = "VisualConfigs.json";
|
||||||
|
private static readonly object _fileLock = new object();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存当前配置(存在则更新,不存在则新增)
|
||||||
|
/// </summary>
|
||||||
|
public void Save()
|
||||||
|
{
|
||||||
|
lock (_fileLock)
|
||||||
|
{
|
||||||
|
var list = LoadAll();
|
||||||
|
var existing = list.FirstOrDefault(c => c.CameraName == CameraName);
|
||||||
|
|
||||||
|
if (existing != null)
|
||||||
|
{
|
||||||
|
// 更新现有配置
|
||||||
|
existing.ModelPath = ModelPath;
|
||||||
|
existing.ImgPath = ImgPath;
|
||||||
|
existing.Threshold = Threshold;
|
||||||
|
existing.Direction = Direction;
|
||||||
|
existing.Speed = Speed;
|
||||||
|
existing.MSpeed = MSpeed;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
list.Add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveAll(list);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取全部配置列表
|
||||||
|
/// </summary>
|
||||||
|
public static List<VisualLocalization> LoadAll()
|
||||||
|
{
|
||||||
|
lock (_fileLock)
|
||||||
|
{
|
||||||
|
if (!File.Exists(ConfigFile)) return new List<VisualLocalization>();
|
||||||
|
|
||||||
|
var json = File.ReadAllText(ConfigFile);
|
||||||
|
return JsonSerializer.Deserialize<List<VisualLocalization>>(json)
|
||||||
|
?? new List<VisualLocalization>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void SaveAll(List<VisualLocalization> list)
|
||||||
|
{
|
||||||
|
var options = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
IgnoreNullValues = true
|
||||||
|
};
|
||||||
|
|
||||||
|
File.WriteAllText(ConfigFile, JsonSerializer.Serialize(list, options));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,15 +13,23 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="AntdUI" Version="1.8.9" />
|
<PackageReference Include="AntdUI" Version="1.8.9" />
|
||||||
|
<PackageReference Include="hyjiacan.pinyin4net" Version="4.1.1" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="OpenCvSharp4" Version="4.10.0.20241108" />
|
<PackageReference Include="OpenCvSharp4" Version="4.10.0.20241108" />
|
||||||
<PackageReference Include="OpenCvSharp4.Extensions" Version="4.10.0.20241108" />
|
<PackageReference Include="OpenCvSharp4.Extensions" Version="4.10.0.20241108" />
|
||||||
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.10.0.20241108" />
|
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.10.0.20241108" />
|
||||||
|
<PackageReference Include="System.IO.Ports" Version="9.0.3" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
<Reference Include="DVPCameraCS64">
|
||||||
|
<HintPath>..\X64\Debug\DVPCameraCS64.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="halcondotnet">
|
<Reference Include="halcondotnet">
|
||||||
<HintPath>..\x64\Debug\halcondotnet.dll</HintPath>
|
<HintPath>..\x64\Debug\halcondotnet.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace DH.Commons.Enums
|
|
||||||
{
|
|
||||||
public class CameraInfo
|
|
||||||
{
|
|
||||||
public string CamName { get; set; }
|
|
||||||
public string Serinum { get; set; }
|
|
||||||
public string IP { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -7,12 +7,62 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace DH.Commons.Enums
|
namespace DH.Commons.Enums
|
||||||
{
|
{
|
||||||
|
public enum EnumStatus
|
||||||
|
{
|
||||||
|
待机中,
|
||||||
|
运行中,
|
||||||
|
清料中,
|
||||||
|
警告,
|
||||||
|
异常
|
||||||
|
}
|
||||||
|
public enum ModelType
|
||||||
|
{
|
||||||
|
图像分类 = 1,
|
||||||
|
目标检测 = 2,
|
||||||
|
语义分割 = 3,
|
||||||
|
实例分割 = 4,
|
||||||
|
目标检测GPU = 5
|
||||||
|
}
|
||||||
|
public enum SelectPicType
|
||||||
|
{
|
||||||
|
[Description("训练图片")]
|
||||||
|
train = 0,
|
||||||
|
[Description("测试图片")]
|
||||||
|
test
|
||||||
|
|
||||||
|
}
|
||||||
|
public enum NetModel
|
||||||
|
{
|
||||||
|
[Description("目标检测")]
|
||||||
|
training = 0,
|
||||||
|
[Description("语义分割")]
|
||||||
|
train_seg,
|
||||||
|
[Description("模型导出")]
|
||||||
|
emport,
|
||||||
|
[Description("推理预测")]
|
||||||
|
infernce
|
||||||
|
|
||||||
|
}
|
||||||
|
public enum EnumCamType
|
||||||
|
{
|
||||||
|
[Description("度申相机")]
|
||||||
|
度申Do3think = 0,
|
||||||
|
[Description("海康相机")]
|
||||||
|
海康hik ,
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public enum EnumPLCType
|
public enum EnumPLCType
|
||||||
{
|
{
|
||||||
信捷XC_串口,
|
[Description("信捷XC串口")]
|
||||||
信捷XC_网口,
|
信捷XC串口 = 0,
|
||||||
信捷XD_串口,
|
[Description("信捷XC网口")]
|
||||||
信捷XD_网口
|
信捷XC网口 = 1,
|
||||||
|
[Description("信捷XD串口")]
|
||||||
|
信捷XD串口 = 2,
|
||||||
|
[Description("信捷XD网口")]
|
||||||
|
信捷XD网口 = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -28,32 +78,84 @@ namespace DH.Commons.Enums
|
|||||||
public enum EnumPLCOutputIO
|
public enum EnumPLCOutputIO
|
||||||
{
|
{
|
||||||
转盘方向=0,
|
转盘方向=0,
|
||||||
转盘速度=1,
|
转盘速度,
|
||||||
转盘使能=2,
|
转盘使能,
|
||||||
转盘启动=3,
|
转盘启动,
|
||||||
转盘清料=4,
|
转盘清料,
|
||||||
指示灯绿=5,
|
指示灯绿,
|
||||||
指示灯黄=6,
|
指示灯黄,
|
||||||
指示灯红=7,
|
指示灯红,
|
||||||
蜂鸣器=8,
|
蜂鸣器,
|
||||||
振动盘=9,
|
振动盘,
|
||||||
皮带=10,
|
皮带,
|
||||||
工位1=11,
|
工位1,
|
||||||
工位2=12,
|
工位2,
|
||||||
工位3=13,
|
工位3,
|
||||||
工位4=14,
|
工位4,
|
||||||
工位5=15,
|
工位5,
|
||||||
OK料盒=16,
|
工位6 ,
|
||||||
NG料盒=17,
|
工位7 ,
|
||||||
OK吹气时间=18,
|
工位8 ,
|
||||||
NG吹气时间=19,
|
工位9 ,
|
||||||
产品计数=20,
|
工位10 ,
|
||||||
计数清零=21,
|
相机触发时间,
|
||||||
工件最小值=22,
|
吹气时间,
|
||||||
工具最大值=23,
|
产品计数,
|
||||||
启用心跳=24,
|
计数清零,
|
||||||
心跳=25
|
工件最小值,
|
||||||
|
工件最大值,
|
||||||
|
启用心跳,
|
||||||
|
心跳地址,
|
||||||
|
挡料电机回原点,
|
||||||
|
挡料电机回原点速度,
|
||||||
|
挡料电机速度,
|
||||||
|
挡料电机顺时针,
|
||||||
|
挡料电机逆时针,
|
||||||
|
挡料电机位置,
|
||||||
|
OK脉冲,
|
||||||
|
NG脉冲,
|
||||||
|
状态复位,
|
||||||
|
启用定位,
|
||||||
|
定位完成脉冲值,
|
||||||
|
相机步进原点,
|
||||||
|
相机步进位置,
|
||||||
|
相机步进速度,
|
||||||
|
相机步进顺时针,
|
||||||
|
相机步进逆时针,
|
||||||
|
点动相机步进,
|
||||||
|
点动挡杆步进,
|
||||||
|
相机步进实时位置,
|
||||||
|
挡料电机实时位置
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public enum EnumPLCDataType
|
||||||
|
{
|
||||||
|
单字整型,
|
||||||
|
双字整型,
|
||||||
|
浮点型,
|
||||||
|
布尔型
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum EnumBool
|
||||||
|
{
|
||||||
|
关闭,
|
||||||
|
启用
|
||||||
|
}
|
||||||
|
public enum EnumBool1
|
||||||
|
{
|
||||||
|
False,
|
||||||
|
True
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum EnumDetectionType
|
||||||
|
{
|
||||||
|
深度学习,
|
||||||
|
尺寸测量
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
64
DH.Commons/Exception/ExceptionHelper.cs
Normal file
64
DH.Commons/Exception/ExceptionHelper.cs
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
using System;
|
||||||
|
using static DH.Commons.Enums.EnumHelper;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DH.Commons.Helper
|
||||||
|
{
|
||||||
|
public enum ExceptionLevel
|
||||||
|
{
|
||||||
|
Info = 0,
|
||||||
|
Warning = 1,
|
||||||
|
Fatal = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
//public delegate void OnProcessExceptionRaisedDelegate(DateTime dt, ProcessException ex);
|
||||||
|
//[Serializable]
|
||||||
|
public class ProcessException : Exception
|
||||||
|
{
|
||||||
|
public ExceptionLevel Level { get; set; } = ExceptionLevel.Warning;
|
||||||
|
|
||||||
|
public ProcessException()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProcessException(Exception ex, ExceptionLevel lvl = ExceptionLevel.Warning) : base(ex.Message, ex)
|
||||||
|
{
|
||||||
|
Level = lvl;
|
||||||
|
ExceptionNotice();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ProcessException(string error, Exception ex = null, ExceptionLevel lvl = ExceptionLevel.Warning) : base(error, ex)
|
||||||
|
{
|
||||||
|
Level = lvl;
|
||||||
|
ExceptionNotice();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ExceptionNotice()
|
||||||
|
{
|
||||||
|
//OnProcessExceptionRaised?.Invoke(DateTime.Now, this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ExceptionHelper
|
||||||
|
{
|
||||||
|
public static LogLevel LogLevel = LogLevel.Information;
|
||||||
|
public static string GetExceptionMessage(this Exception ex)
|
||||||
|
{
|
||||||
|
string msg = "异常信息:" + ex.Message;
|
||||||
|
if (ex.InnerException != null)
|
||||||
|
{
|
||||||
|
msg += ";\t内部异常信息:" + ex.InnerException.GetExceptionMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LogLevel <= LogLevel.Assist)
|
||||||
|
{
|
||||||
|
msg += (";\r\n\t\tStackTrace:" + ex.StackTrace);
|
||||||
|
}
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AuthorityException : ProcessException
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
162
DH.Commons/Helper/AttributeHelper.cs
Normal file
162
DH.Commons/Helper/AttributeHelper.cs
Normal file
@ -0,0 +1,162 @@
|
|||||||
|
using DH.Commons.Enums;
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using static DH.Commons.Enums.EnumHelper;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DH.Commons.Enums
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设备特性,指示该信息的设备类型,适用于设备信息和配置信息
|
||||||
|
/// </summary>
|
||||||
|
public class DeviceAttribute : Attribute
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 设备类型
|
||||||
|
/// </summary>
|
||||||
|
public string TypeCode { get; set; }
|
||||||
|
|
||||||
|
public string TypeDescription { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 特性修饰类别
|
||||||
|
/// </summary>
|
||||||
|
public DeviceAttributeType AttrType { get; set; }
|
||||||
|
|
||||||
|
public DeviceAttribute(string typeCode, string typeDesc, EnumHelper.DeviceAttributeType attrType)
|
||||||
|
{
|
||||||
|
TypeCode = typeCode;
|
||||||
|
TypeDescription = typeDesc;
|
||||||
|
AttrType = attrType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 预置状态特性 指定该修饰信息的前置状态允许范围
|
||||||
|
/// </summary>
|
||||||
|
public class PreStateAttribute : Attribute
|
||||||
|
{
|
||||||
|
public int PreState { get; set; }
|
||||||
|
public PreStateAttribute(int _preState)
|
||||||
|
{
|
||||||
|
PreState = _preState;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检查当前待执行操作的前置状态要求是否合法
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="currentState"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public bool CheckPreStateValid(int currentState)
|
||||||
|
{
|
||||||
|
return (currentState & PreState) == currentState;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ColorSelectAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string SelectedColor { get; set; }
|
||||||
|
public ColorSelectAttribute(string selectedColor)
|
||||||
|
{
|
||||||
|
SelectedColor = selectedColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FontColorSelectAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string SelectedColor { get; set; }
|
||||||
|
public FontColorSelectAttribute(string selectedColor)
|
||||||
|
{
|
||||||
|
SelectedColor = selectedColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum InvokeType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 不公开调用
|
||||||
|
/// </summary>
|
||||||
|
[Description("不公开调用")]
|
||||||
|
NoneInvoke = 0,
|
||||||
|
/// <summary>
|
||||||
|
/// 测试调用
|
||||||
|
/// </summary>
|
||||||
|
[Description("测试调用")]
|
||||||
|
TestInvoke = 1,
|
||||||
|
/// <summary>
|
||||||
|
/// 标定调用
|
||||||
|
/// </summary>
|
||||||
|
[Description("标定调用")]
|
||||||
|
CalibInvoke = 2,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 用来修饰对外开放的调用方法的特性
|
||||||
|
/// 调用方法参数顺序:IOperationConfig,InvokeDevice,SourceDevice
|
||||||
|
/// </summary>
|
||||||
|
public class ProcessMethodAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string MethodCode { get; set; }
|
||||||
|
public string MethodDesc { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 是否提供人工调用测试
|
||||||
|
/// </summary>
|
||||||
|
public InvokeType InvokeType { get; set; }
|
||||||
|
|
||||||
|
public string DeviceType { get; set; }
|
||||||
|
|
||||||
|
public ProcessMethodAttribute(string deviceType, string code, string description, InvokeType invokeType)
|
||||||
|
{
|
||||||
|
DeviceType = deviceType;
|
||||||
|
MethodCode = code;
|
||||||
|
MethodDesc = description;
|
||||||
|
InvokeType = invokeType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class SwitchDisplayAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string SwitchName { get; set; }
|
||||||
|
|
||||||
|
public bool SwithOnStatus { get; set; } = true;
|
||||||
|
|
||||||
|
public SwitchDisplayAttribute(string name, bool status)
|
||||||
|
{
|
||||||
|
SwitchName = name;
|
||||||
|
SwithOnStatus = status;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ElementAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
public string Desc { get; set; }
|
||||||
|
|
||||||
|
public string IconPath { get; set; }
|
||||||
|
|
||||||
|
public bool IsShowInToolBar { get; set; }
|
||||||
|
|
||||||
|
public ElementAttribute(string desc, string iconPath, bool isShowInToolBar = true, [CallerMemberName] string name = "")
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
Desc = desc;
|
||||||
|
IconPath = iconPath;
|
||||||
|
IsShowInToolBar = isShowInToolBar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ProcessAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string ProcessCode { get; set; }
|
||||||
|
public DeviceAttributeType AttrType { get; set; }
|
||||||
|
|
||||||
|
public ProcessAttribute(string stationCode, DeviceAttributeType attrType)
|
||||||
|
{
|
||||||
|
ProcessCode = stationCode;
|
||||||
|
AttrType = attrType;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
280
DH.Commons/Helper/ConfigHelper.cs
Normal file
280
DH.Commons/Helper/ConfigHelper.cs
Normal file
@ -0,0 +1,280 @@
|
|||||||
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using AntdUI;
|
||||||
|
using DH.Commons.Base;
|
||||||
|
using DH.Commons.Enums;
|
||||||
|
using DH.Commons.Models;
|
||||||
|
|
||||||
|
namespace DH.Commons.Helper
|
||||||
|
{
|
||||||
|
public static class ConfigHelper
|
||||||
|
{
|
||||||
|
private static readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions
|
||||||
|
{
|
||||||
|
WriteIndented = true,
|
||||||
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||||
|
IgnoreNullValues = true
|
||||||
|
};
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置存储根目录
|
||||||
|
/// </summary>
|
||||||
|
private static string ConfigsRoot => Path.Combine(
|
||||||
|
AppDomain.CurrentDomain.BaseDirectory,
|
||||||
|
"configs");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取当前方案的主配置文件路径
|
||||||
|
/// </summary>
|
||||||
|
private static string CurrentConfigPath
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
ValidateCurrentScheme();
|
||||||
|
return Path.Combine(
|
||||||
|
ConfigsRoot,
|
||||||
|
$"config_{SystemModel.CurrentScheme}.json");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取当前方案的备份目录路径
|
||||||
|
/// </summary>
|
||||||
|
private static string CurrentBackupDir
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
ValidateCurrentScheme();
|
||||||
|
return Path.Combine(
|
||||||
|
ConfigsRoot,
|
||||||
|
$"bak_{SystemModel.CurrentScheme}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化新方案(创建空文件)
|
||||||
|
/// </summary>
|
||||||
|
public static void InitializeScheme(string scheme)
|
||||||
|
{
|
||||||
|
SystemModel.CurrentScheme = scheme;
|
||||||
|
|
||||||
|
// 创建空配置文件
|
||||||
|
if (!File.Exists(CurrentConfigPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(ConfigsRoot);
|
||||||
|
File.WriteAllText(CurrentConfigPath, "{}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建备份目录
|
||||||
|
Directory.CreateDirectory(CurrentBackupDir);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存当前配置(自动备份)
|
||||||
|
/// </summary>
|
||||||
|
public static void SaveConfig()
|
||||||
|
{
|
||||||
|
ValidateCurrentScheme();
|
||||||
|
|
||||||
|
// 确保配置目录存在
|
||||||
|
Directory.CreateDirectory(ConfigsRoot);
|
||||||
|
|
||||||
|
// 备份现有配置
|
||||||
|
if (File.Exists(CurrentConfigPath))
|
||||||
|
{
|
||||||
|
var backupName = $"config_{SystemModel.CurrentScheme}_{DateTime.Now:yyyyMMddHHmmss}.json";
|
||||||
|
var backupPath = Path.Combine(CurrentBackupDir, backupName);
|
||||||
|
|
||||||
|
Directory.CreateDirectory(CurrentBackupDir);
|
||||||
|
File.Copy(CurrentConfigPath, backupPath);
|
||||||
|
}
|
||||||
|
//重置标签文件路径和内容
|
||||||
|
ConfigModel.DetectionList.ForEach(config =>
|
||||||
|
{
|
||||||
|
GenerateLabelFile(config);
|
||||||
|
});
|
||||||
|
|
||||||
|
// 序列化当前配置
|
||||||
|
var json = JsonSerializer.Serialize(new
|
||||||
|
{
|
||||||
|
ConfigModel.CameraBaseList,
|
||||||
|
ConfigModel.PLCBaseList,
|
||||||
|
ConfigModel.DetectionList,
|
||||||
|
ConfigModel.GlobalList,
|
||||||
|
}, _jsonOptions);
|
||||||
|
|
||||||
|
// 写入新配置
|
||||||
|
File.WriteAllText(CurrentConfigPath, json);
|
||||||
|
}
|
||||||
|
private static void GenerateLabelFile(DetectionConfig config)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (config.DetectionLableList == null || string.IsNullOrEmpty(config.In_lable_path))
|
||||||
|
return;
|
||||||
|
|
||||||
|
// 确保目录存在
|
||||||
|
var directory = Path.GetDirectoryName(config.In_lable_path);
|
||||||
|
if (!string.IsNullOrEmpty(directory) && !Directory.Exists(directory))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(directory);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 写入文件内容
|
||||||
|
using (var writer = new StreamWriter(config.In_lable_path, false))
|
||||||
|
{
|
||||||
|
foreach (var label in config.DetectionLableList)
|
||||||
|
{
|
||||||
|
//是否假如判断标签为中文转为为英文
|
||||||
|
//string pinyinlabel = FileHelper.ConvertHanzitoPinyinWithNumbers(label.LabelName.ToString());
|
||||||
|
//if (FileHelper.IsAlphaNumericOnly(pinyinlabel))
|
||||||
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
// 根据实际需求格式化输出
|
||||||
|
writer.WriteLine(label.LabelName.ToString()); // 假设DetectionLable重写了ToString()
|
||||||
|
|
||||||
|
// 或者明确指定格式:
|
||||||
|
// writer.WriteLine($"{label.Id},{label.Name},{label.Confidence}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine($"生成标签文件失败: {ex.Message}");
|
||||||
|
// 可以考虑记录更详细的日志
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 加载当前方案配置
|
||||||
|
/// </summary>
|
||||||
|
public static void LoadConfig()
|
||||||
|
{
|
||||||
|
ValidateCurrentScheme();
|
||||||
|
|
||||||
|
if (!File.Exists(CurrentConfigPath))
|
||||||
|
{
|
||||||
|
InitializeScheme(SystemModel.CurrentScheme);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var json = File.ReadAllText(CurrentConfigPath);
|
||||||
|
var data = JsonSerializer.Deserialize<ConfigData>(json, _jsonOptions);
|
||||||
|
|
||||||
|
ConfigModel.CameraBaseList = data?.Cameras ?? new List<CameraBase>();
|
||||||
|
ConfigModel.DetectionList = data?.Detections ?? new List<DetectionConfig>();
|
||||||
|
ConfigModel.PLCBaseList = data?.PLCs ?? new List<PLCBase>();
|
||||||
|
ConfigModel.GlobalList = data?.GlobalConfigs ?? new List<GlobalConfig>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 验证当前方案有效性
|
||||||
|
/// </summary>
|
||||||
|
private static void ValidateCurrentScheme()
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(SystemModel.CurrentScheme))
|
||||||
|
throw new InvalidOperationException("当前方案未设置");
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 派生新方案(基于当前方案创建副本)
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="newSchemeName">新方案名称</param>
|
||||||
|
public static void DeriveScheme(string newSchemeName)
|
||||||
|
{
|
||||||
|
// 验证输入
|
||||||
|
if (string.IsNullOrWhiteSpace(newSchemeName))
|
||||||
|
{
|
||||||
|
throw new ArgumentException("新方案名称不能为空");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 验证当前方案是否有效
|
||||||
|
ValidateCurrentScheme();
|
||||||
|
|
||||||
|
// 检查新方案是否已存在
|
||||||
|
var newConfigPath = Path.Combine(ConfigsRoot, $"config_{newSchemeName}.json");
|
||||||
|
if (File.Exists(newConfigPath))
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"方案 {newSchemeName} 已存在");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保存当前配置确保最新
|
||||||
|
SaveConfig();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 复制配置文件
|
||||||
|
File.Copy(CurrentConfigPath, newConfigPath);
|
||||||
|
|
||||||
|
// 创建备份目录
|
||||||
|
var newBackupDir = Path.Combine(ConfigsRoot, $"bak_{newSchemeName}");
|
||||||
|
Directory.CreateDirectory(newBackupDir);
|
||||||
|
|
||||||
|
// 可选:自动切换新方案
|
||||||
|
// SystemModel.CurrentScheme = newSchemeName;
|
||||||
|
}
|
||||||
|
catch (IOException ex)
|
||||||
|
{
|
||||||
|
throw new InvalidOperationException($"方案派生失败: {ex.Message}", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除指定方案的配置文件及备份目录
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="schemeName">要删除的方案名称</param>
|
||||||
|
/// <exception cref="ArgumentException">当方案名称为空时抛出</exception>
|
||||||
|
/// <exception cref="IOException">文件操作失败时抛出</exception>
|
||||||
|
public static void DeleteSchemeConfig(string schemeName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(schemeName))
|
||||||
|
throw new ArgumentException("方案名称无效");
|
||||||
|
|
||||||
|
// 构造路径
|
||||||
|
var configPath = Path.Combine(ConfigsRoot, $"config_{schemeName}.json");
|
||||||
|
var backupDir = Path.Combine(ConfigsRoot, $"bak_{schemeName}");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 删除配置文件
|
||||||
|
if (File.Exists(configPath))
|
||||||
|
{
|
||||||
|
File.Delete(configPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除备份目录(递归删除)
|
||||||
|
if (Directory.Exists(backupDir))
|
||||||
|
{
|
||||||
|
Directory.Delete(backupDir, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex) when (ex is IOException || ex is UnauthorizedAccessException)
|
||||||
|
{
|
||||||
|
throw new IOException($"删除方案 {schemeName} 的配置文件失败: {ex.Message}", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置数据模型(内部类)
|
||||||
|
/// </summary>
|
||||||
|
private class ConfigData
|
||||||
|
{
|
||||||
|
[JsonPropertyName("cameraBaseList")]
|
||||||
|
public List<CameraBase> Cameras { get; set; } = new List<CameraBase>();
|
||||||
|
|
||||||
|
[JsonPropertyName("plcBaseList")]
|
||||||
|
public List<PLCBase> PLCs { get; set; } = new List<PLCBase>();
|
||||||
|
|
||||||
|
[JsonPropertyName("detectionList")]
|
||||||
|
public List<DetectionConfig> Detections { get; set; } = new List<DetectionConfig>();
|
||||||
|
[JsonPropertyName("globalList")]
|
||||||
|
public List<GlobalConfig> GlobalConfigs { get; set; } = new List<GlobalConfig>();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -76,159 +76,83 @@ namespace DH.Commons.Enums
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//public static System.Windows.Media.Color GetEnumSelectedMediaColor(this Enum enumObj)
|
// 根据描述获取枚举值(泛型方法)
|
||||||
//{
|
public static T GetEnumFromDescription<T>(string description) where T : Enum
|
||||||
// Type t = enumObj.GetType();
|
{
|
||||||
// FieldInfo f = t.GetField(enumObj.ToString());
|
Type enumType = typeof(T);
|
||||||
|
foreach (T value in Enum.GetValues(enumType))
|
||||||
// ColorSelectAttribute attr = f.GetCustomAttribute<ColorSelectAttribute>();
|
{
|
||||||
// if (attr != null)
|
string desc = GetEnumDescription(value);
|
||||||
// {
|
if (desc == description)
|
||||||
// var prop = typeof(System.Windows.Media.Colors).GetProperties().FirstOrDefault(p => p.Name == attr.SelectedColor);
|
{
|
||||||
// if (prop != null)
|
return value;
|
||||||
// {
|
}
|
||||||
// return (System.Windows.Media.Color)prop.GetValue(null);
|
}
|
||||||
// }
|
throw new ArgumentException($"在枚举 {enumType.Name} 中未找到描述为 '{description}' 的值");
|
||||||
// }
|
}
|
||||||
// return System.Windows.Media.Colors.Transparent;
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public static System.Drawing.Color GetEnumSelectedColor(this Enum enumObj)
|
|
||||||
//{
|
|
||||||
// Type t = enumObj.GetType();
|
|
||||||
// FieldInfo f = t.GetField(enumObj.ToString());
|
|
||||||
|
|
||||||
// ColorSelectAttribute attr = f.GetCustomAttribute<ColorSelectAttribute>();
|
|
||||||
// if (attr != null)
|
|
||||||
// {
|
|
||||||
// return System.Drawing.Color.FromName(attr.SelectedColor);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return System.Drawing.Color.Transparent;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public static System.Drawing.Color GetEnumSelectedFontColor(this Enum enumObj)
|
|
||||||
//{
|
|
||||||
// Type t = enumObj.GetType();
|
|
||||||
// FieldInfo f = t.GetField(enumObj.ToString());
|
|
||||||
|
|
||||||
// var attr = f.GetCustomAttribute<FontColorSelectAttribute>();
|
|
||||||
// if (attr != null)
|
|
||||||
// {
|
|
||||||
// return System.Drawing.Color.FromName(attr.SelectedColor);
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return System.Drawing.Color.Transparent;
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
//public static string GetEnumSelectedColorString(this Enum enumObj)
|
|
||||||
//{
|
|
||||||
// Type t = enumObj.GetType();
|
|
||||||
// FieldInfo f = t.GetField(enumObj.ToString());
|
|
||||||
|
|
||||||
// ColorSelectAttribute attr = f.GetCustomAttribute<ColorSelectAttribute>();
|
|
||||||
// if (attr != null)
|
|
||||||
// {
|
|
||||||
// return attr.SelectedColor;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return "Transparent";
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 当枚举牵涉到状态变换,检查现状态是否满足待转换的状态的前置状态要求
|
/// 获取枚举类型的所有描述文本
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="stateToBe"></param>
|
/// <param name="enumType">枚举类型</param>
|
||||||
/// <param name="currentState"></param>
|
/// <returns>描述文本列表</returns>
|
||||||
/// <returns></returns>
|
public static List<string> GetEnumDescriptions(Type enumType)
|
||||||
//public static bool CheckPreStateValid(this Enum stateToBe, int currentState)
|
{
|
||||||
//{
|
// 验证类型是否为枚举
|
||||||
// Type t = stateToBe.GetType();
|
if (!enumType.IsEnum)
|
||||||
// FieldInfo f = t.GetField(stateToBe.ToString());
|
throw new ArgumentException("传入的类型必须是枚举类型", nameof(enumType));
|
||||||
|
|
||||||
// PreStateAttribute attr = f.GetCustomAttribute<PreStateAttribute>();
|
var descriptions = new List<string>();
|
||||||
// if (attr == null)
|
|
||||||
// {
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return attr.CheckPreStateValid(currentState);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
|
|
||||||
/// <summary>
|
foreach (var value in Enum.GetValues(enumType))
|
||||||
/// 设备状态定义
|
{
|
||||||
/// 未初始化和异常状态无前置状态要求
|
var fieldInfo = enumType.GetField(value.ToString());
|
||||||
/// 初始化操作前置状态必须是未初始化、关闭状态和异常状态
|
var attribute = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
|
||||||
/// 打开前置必须是初始化和暂停
|
descriptions.Add(attribute?.Description ?? value.ToString());
|
||||||
/// 关闭前置必须是打开和暂停和异常
|
}
|
||||||
/// 暂停前置必须是打开
|
|
||||||
/// </summary>
|
|
||||||
//public enum DeviceState
|
|
||||||
//{
|
|
||||||
// TBD = -1,
|
|
||||||
|
|
||||||
// [ColorSelect("Gray")]
|
return descriptions;
|
||||||
// [FontColorSelect("Black")]
|
}
|
||||||
// [Description("未初始化")]
|
public static string GetEnumDescription1(Enum value)
|
||||||
// DSUninit = 1,
|
{
|
||||||
|
var field = value.GetType().GetField(value.ToString());
|
||||||
|
var attribute = field.GetCustomAttributes(typeof(DescriptionAttribute), false)
|
||||||
|
.FirstOrDefault() as DescriptionAttribute;
|
||||||
|
return attribute?.Description ?? value.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
// [ColorSelect("Gold")]
|
public static System.Drawing.Color GetEnumSelectedColor(this Enum enumObj)
|
||||||
// [FontColorSelect("White")]
|
{
|
||||||
// [PreState(1 + 2 + 4 + 8 + 32)]
|
Type t = enumObj.GetType();
|
||||||
// [Description("初始化")]
|
FieldInfo f = t.GetField(enumObj.ToString());
|
||||||
// DSInit = 2,
|
|
||||||
|
|
||||||
// [ColorSelect("Lime")]
|
ColorSelectAttribute attr = f.GetCustomAttribute<ColorSelectAttribute>();
|
||||||
// [FontColorSelect("Black")]
|
if (attr != null)
|
||||||
// [PreState(2 + 4 + 16)]
|
{
|
||||||
// [Description("运行中")]
|
return System.Drawing.Color.FromName(attr.SelectedColor);
|
||||||
// DSOpen = 4,
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return System.Drawing.Color.Transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// [ColorSelect("Gray")]
|
public static System.Drawing.Color GetEnumSelectedFontColor(this Enum enumObj)
|
||||||
// [FontColorSelect("White")]
|
{
|
||||||
// [PreState(1 + 4 + 8 + 16 + 32)]
|
Type t = enumObj.GetType();
|
||||||
// [Description("关闭")]
|
FieldInfo f = t.GetField(enumObj.ToString());
|
||||||
// DSClose = 8,
|
|
||||||
|
|
||||||
// [ColorSelect("Gold")]
|
var attr = f.GetCustomAttribute<FontColorSelectAttribute>();
|
||||||
// [FontColorSelect("White")]
|
if (attr != null)
|
||||||
// [PreState(4 + 16)]
|
{
|
||||||
// [Description("暂停")]
|
return System.Drawing.Color.FromName(attr.SelectedColor);
|
||||||
// DSPause = 16,
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return System.Drawing.Color.Transparent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// [ColorSelect("Red")]
|
|
||||||
// [FontColorSelect("White")]
|
|
||||||
// [Description("异常")]
|
|
||||||
// DSExcept = 32
|
|
||||||
//}
|
|
||||||
|
|
||||||
///// <summary>
|
|
||||||
///// 工序状态
|
|
||||||
///// </summary>
|
|
||||||
//public enum RunState
|
|
||||||
//{
|
|
||||||
// [ColorSelect("Gold")]
|
|
||||||
// [Description("空闲")]
|
|
||||||
// Idle = 1,
|
|
||||||
// [ColorSelect("Lime")]
|
|
||||||
// [Description("运行中")]
|
|
||||||
// Running = 2,
|
|
||||||
// [ColorSelect("Gray")]
|
|
||||||
// [Description("停止")]
|
|
||||||
// Stop = 3,
|
|
||||||
// [ColorSelect("Red")]
|
|
||||||
// [Description("宕机")]
|
|
||||||
// Down = 99,
|
|
||||||
//}
|
|
||||||
|
|
||||||
[Flags]
|
[Flags]
|
||||||
public enum DeviceAttributeType
|
public enum DeviceAttributeType
|
||||||
@ -361,7 +285,38 @@ namespace DH.Commons.Enums
|
|||||||
[Description("测量结果")]
|
[Description("测量结果")]
|
||||||
MeasureResult = 31,
|
MeasureResult = 31,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum LogLevel
|
||||||
|
{
|
||||||
|
[Description("详细")]
|
||||||
|
[ColorSelect("White")]
|
||||||
|
[FontColorSelect("Green")]
|
||||||
|
Detail = 2,
|
||||||
|
[Description("信息")]
|
||||||
|
[ColorSelect("White")]
|
||||||
|
[FontColorSelect("Dark")]
|
||||||
|
Information = 3,
|
||||||
|
[Description("辅助")]
|
||||||
|
[ColorSelect("White")]
|
||||||
|
[FontColorSelect("Blue")]
|
||||||
|
Assist = 4,
|
||||||
|
[Description("动作")]
|
||||||
|
[ColorSelect("DarkGreen")]
|
||||||
|
[FontColorSelect("Yellow")]
|
||||||
|
Action = 5,
|
||||||
|
[Description("错误")]
|
||||||
|
[ColorSelect("Orange")]
|
||||||
|
[FontColorSelect("White")]
|
||||||
|
Error = 6,
|
||||||
|
[Description("警报")]
|
||||||
|
[ColorSelect("Brown")]
|
||||||
|
[FontColorSelect("White")]
|
||||||
|
Warning = 7,
|
||||||
|
[Description("异常")]
|
||||||
|
[ColorSelect("Red")]
|
||||||
|
[FontColorSelect("White")]
|
||||||
|
Exception = 8,
|
||||||
|
}
|
||||||
//public enum CameraDriverType
|
//public enum CameraDriverType
|
||||||
//{
|
//{
|
||||||
// Halcon,
|
// Halcon,
|
||||||
@ -382,6 +337,59 @@ namespace DH.Commons.Enums
|
|||||||
// NG = -1,
|
// NG = -1,
|
||||||
// IGNORE = -999,
|
// IGNORE = -999,
|
||||||
//}
|
//}
|
||||||
|
public enum DeviceState
|
||||||
|
{
|
||||||
|
TBD = -1,
|
||||||
|
|
||||||
|
[ColorSelect("Gray")]
|
||||||
|
[FontColorSelect("Black")]
|
||||||
|
[Description("未初始化")]
|
||||||
|
DSUninit = 1,
|
||||||
|
|
||||||
|
[ColorSelect("Gold")]
|
||||||
|
[FontColorSelect("White")]
|
||||||
|
[PreState(1 + 2 + 4 + 8 + 32)]
|
||||||
|
[Description("初始化")]
|
||||||
|
DSInit = 2,
|
||||||
|
|
||||||
|
[ColorSelect("Lime")]
|
||||||
|
[FontColorSelect("Black")]
|
||||||
|
[PreState(2 + 4 + 16)]
|
||||||
|
[Description("运行中")]
|
||||||
|
DSOpen = 4,
|
||||||
|
|
||||||
|
[ColorSelect("Gray")]
|
||||||
|
[FontColorSelect("White")]
|
||||||
|
[PreState(1 + 4 + 8 + 16 + 32)]
|
||||||
|
[Description("关闭")]
|
||||||
|
DSClose = 8,
|
||||||
|
|
||||||
|
[ColorSelect("Gold")]
|
||||||
|
[FontColorSelect("White")]
|
||||||
|
[PreState(4 + 16)]
|
||||||
|
[Description("暂停")]
|
||||||
|
DSPause = 16,
|
||||||
|
|
||||||
|
[ColorSelect("Red")]
|
||||||
|
[FontColorSelect("White")]
|
||||||
|
[Description("异常")]
|
||||||
|
DSExcept = 32
|
||||||
|
}
|
||||||
|
public enum RunState
|
||||||
|
{
|
||||||
|
[ColorSelect("Gold")]
|
||||||
|
[Description("空闲")]
|
||||||
|
Idle = 1,
|
||||||
|
[ColorSelect("Lime")]
|
||||||
|
[Description("运行中")]
|
||||||
|
Running = 2,
|
||||||
|
[ColorSelect("Gray")]
|
||||||
|
[Description("停止")]
|
||||||
|
Stop = 3,
|
||||||
|
[ColorSelect("Red")]
|
||||||
|
[Description("宕机")]
|
||||||
|
Down = 99,
|
||||||
|
}
|
||||||
|
|
||||||
public enum PriorityDirection
|
public enum PriorityDirection
|
||||||
{
|
{
|
||||||
|
507
DH.Commons/Helper/FileHelper.cs
Normal file
507
DH.Commons/Helper/FileHelper.cs
Normal file
@ -0,0 +1,507 @@
|
|||||||
|
using hyjiacan.py4n;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.Commons.Enums
|
||||||
|
{
|
||||||
|
|
||||||
|
public static class FileHelper
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 清理两个文件夹中的文件,保留文件名交集部分,其余文件删除。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="imagesFolder">图片文件夹路径</param>
|
||||||
|
/// <param name="labelsFolder">标签文件夹路径</param>
|
||||||
|
public static void CleanupFolders(string imagesFolder, string labelsFolder)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(imagesFolder))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Images folder does not exist: {imagesFolder}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Directory.Exists(labelsFolder))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Labels folder does not exist: {labelsFolder}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取文件名(不包含扩展名)
|
||||||
|
var imageFiles = Directory.GetFiles(imagesFolder)
|
||||||
|
.Select(Path.GetFileNameWithoutExtension)
|
||||||
|
.ToHashSet();
|
||||||
|
|
||||||
|
var labelFiles = Directory.GetFiles(labelsFolder)
|
||||||
|
.Select(Path.GetFileNameWithoutExtension)
|
||||||
|
.ToHashSet();
|
||||||
|
|
||||||
|
// 计算交集
|
||||||
|
var commonFiles = imageFiles.Intersect(labelFiles);
|
||||||
|
|
||||||
|
// 删除 images 文件夹中不在交集中的文件
|
||||||
|
foreach (var imagePath in Directory.GetFiles(imagesFolder))
|
||||||
|
{
|
||||||
|
string fileNameWithoutExt = Path.GetFileNameWithoutExtension(imagePath);
|
||||||
|
if (!commonFiles.Contains(fileNameWithoutExt))
|
||||||
|
{
|
||||||
|
File.Delete(imagePath);
|
||||||
|
Console.WriteLine($"Deleted image file: {imagePath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除 labels 文件夹中不在交集中的文件
|
||||||
|
foreach (var labelPath in Directory.GetFiles(labelsFolder))
|
||||||
|
{
|
||||||
|
string fileNameWithoutExt = Path.GetFileNameWithoutExtension(labelPath);
|
||||||
|
if (!commonFiles.Contains(fileNameWithoutExt))
|
||||||
|
{
|
||||||
|
File.Delete(labelPath);
|
||||||
|
Console.WriteLine($"Deleted label file: {labelPath}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("Folders cleaned successfully!");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取文件夹中所有图片文件的个数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folderPath">目标文件夹路径</param>
|
||||||
|
/// <param name="includeSubdirectories">是否包含子文件夹,默认不包含</param>
|
||||||
|
/// <returns>图片文件总数</returns>
|
||||||
|
public static int CountImageFiles(string folderPath, bool includeSubdirectories = false)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(folderPath))
|
||||||
|
{
|
||||||
|
throw new DirectoryNotFoundException($"The folder '{folderPath}' does not exist.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 支持的图片格式
|
||||||
|
string[] imageExtensions = { "*.jpg", "*.jpeg", "*.png", "*.bmp", "*.gif" };
|
||||||
|
|
||||||
|
// 搜索选项
|
||||||
|
SearchOption searchOption = includeSubdirectories ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly;
|
||||||
|
|
||||||
|
int fileCount = 0;
|
||||||
|
|
||||||
|
foreach (var ext in imageExtensions)
|
||||||
|
{
|
||||||
|
fileCount += Directory.GetFiles(folderPath, ext, searchOption).Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
return fileCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除一个目录所有子目录和文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="path"></param>
|
||||||
|
public static void DeleteDirectoryAndContents(string path)
|
||||||
|
{
|
||||||
|
// 确保目录存在
|
||||||
|
if (Directory.Exists(path))
|
||||||
|
{
|
||||||
|
// 删除目录中的文件
|
||||||
|
string[] files = Directory.GetFiles(path);
|
||||||
|
foreach (var file in files)
|
||||||
|
{
|
||||||
|
File.Delete(file);
|
||||||
|
Console.WriteLine($"文件已删除: {file}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除目录中的子目录
|
||||||
|
string[] directories = Directory.GetDirectories(path);
|
||||||
|
foreach (var directory in directories)
|
||||||
|
{
|
||||||
|
DeleteDirectoryAndContents(directory); // 递归删除子目录
|
||||||
|
}
|
||||||
|
|
||||||
|
// 删除空目录
|
||||||
|
Directory.Delete(path);
|
||||||
|
Console.WriteLine($"目录已删除: {path}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("目录不存在!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 将一个文件夹中的所有图片文件和 JSON 文件复制到另一个文件夹中
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourceDirectory"></param>
|
||||||
|
/// <param name="destinationDirectory"></param>
|
||||||
|
public static void CopyImageAndJsonFiles(string sourceDirectory, string destinationDirectory)
|
||||||
|
{
|
||||||
|
// 确保目标文件夹存在,如果不存在则创建它
|
||||||
|
if (!Directory.Exists(destinationDirectory))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(destinationDirectory);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取源文件夹中的所有图片文件和 JSON 文件
|
||||||
|
string[] imageFiles = Directory.GetFiles(sourceDirectory, "*.*")
|
||||||
|
.Where(file => file.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
file.EndsWith(".jpeg", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
file.EndsWith(".png", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
file.EndsWith(".gif", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
file.EndsWith(".bmp", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
file.EndsWith(".tiff", StringComparison.OrdinalIgnoreCase) ||
|
||||||
|
file.EndsWith(".webp", StringComparison.OrdinalIgnoreCase))
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
string[] jsonFiles = Directory.GetFiles(sourceDirectory, "*.json");
|
||||||
|
|
||||||
|
// 合并图片文件和 JSON 文件
|
||||||
|
string[] filesToCopy = imageFiles.Concat(jsonFiles).ToArray();
|
||||||
|
|
||||||
|
foreach (string file in filesToCopy)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 获取文件名
|
||||||
|
string fileName = Path.GetFileName(file);
|
||||||
|
|
||||||
|
// 拼接目标文件的完整路径
|
||||||
|
string destinationFile = Path.Combine(destinationDirectory, fileName);
|
||||||
|
|
||||||
|
// 如果目标文件已存在,可以选择覆盖或跳过(这里我们选择跳过)
|
||||||
|
if (File.Exists(destinationFile))
|
||||||
|
{
|
||||||
|
Console.WriteLine($"文件 {fileName} 已存在,跳过复制.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 复制文件
|
||||||
|
File.Copy(file, destinationFile);
|
||||||
|
Console.WriteLine($"文件 {fileName} 已成功复制到 {destinationDirectory}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"复制文件 {file} 时出错: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 遍历图片文件夹,检查对应的标签文件夹中是否有同名的 .txt 文件。
|
||||||
|
/// 如果没有,则创建一个空的 .txt 文件。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="imagesDirectory">图片文件夹路径</param>
|
||||||
|
/// <param name="labelsDirectory">标签文件夹路径</param>
|
||||||
|
public static void ProcessImageFiles(string imagesDirectory, string labelsDirectory)
|
||||||
|
{
|
||||||
|
// 检查 images 目录是否存在
|
||||||
|
if (!Directory.Exists(imagesDirectory))
|
||||||
|
{
|
||||||
|
throw new DirectoryNotFoundException($"目录 {imagesDirectory} 不存在.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查 labels 目录是否存在,如果不存在则创建
|
||||||
|
if (!Directory.Exists(labelsDirectory))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(labelsDirectory);
|
||||||
|
Console.WriteLine($"目录 {labelsDirectory} 已创建.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取 images 目录中的所有文件(包括图片文件)
|
||||||
|
string[] imageFiles = Directory.GetFiles(imagesDirectory, "*.*", SearchOption.TopDirectoryOnly);
|
||||||
|
string[] validExtensions = { ".jpg", ".jpeg", ".png", ".bmp", ".gif" }; // 支持的图片格式
|
||||||
|
|
||||||
|
foreach (var imageFile in imageFiles)
|
||||||
|
{
|
||||||
|
// 检查文件扩展名是否为支持的图片格式
|
||||||
|
string extension = Path.GetExtension(imageFile).ToLower();
|
||||||
|
if (Array.Exists(validExtensions, ext => ext == extension))
|
||||||
|
{
|
||||||
|
// 获取图片文件的文件名(不包括扩展名)
|
||||||
|
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(imageFile);
|
||||||
|
|
||||||
|
// 生成对应的 txt 文件路径
|
||||||
|
string labelFilePath = Path.Combine(labelsDirectory, fileNameWithoutExtension + ".txt");
|
||||||
|
|
||||||
|
// 如果该 txt 文件不存在,则创建一个空白 txt 文件
|
||||||
|
if (!File.Exists(labelFilePath))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.WriteAllText(labelFilePath, string.Empty); // 创建空白 txt 文件
|
||||||
|
Console.WriteLine($"创建空白文件: {labelFilePath}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"无法创建文件 {labelFilePath}: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 封装的函数:删除没有对应 JSON 文件的图片
|
||||||
|
public static void DeleteUnmatchedImages(string labelsFolderPath, string imagesFolderPath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 获取 labels 文件夹中的所有 JSON 文件名(去除扩展名)
|
||||||
|
string[] jsonFiles = Directory.GetFiles(labelsFolderPath, "*.txt");
|
||||||
|
HashSet<string> jsonFileNames = new HashSet<string>();
|
||||||
|
|
||||||
|
foreach (string jsonFile in jsonFiles)
|
||||||
|
{
|
||||||
|
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(jsonFile);
|
||||||
|
jsonFileNames.Add(fileNameWithoutExtension);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获取 images 文件夹中的所有图片文件
|
||||||
|
string[] imageFiles = Directory.GetFiles(imagesFolderPath);
|
||||||
|
|
||||||
|
// 遍历图片文件,检查是否有对应的 JSON 文件
|
||||||
|
foreach (string imageFile in imageFiles)
|
||||||
|
{
|
||||||
|
string imageFileNameWithoutExtension = Path.GetFileNameWithoutExtension(imageFile);
|
||||||
|
|
||||||
|
// 如果图片文件名不在 labels 文件夹的 JSON 文件名集合中,则删除该图片
|
||||||
|
if (!jsonFileNames.Contains(imageFileNameWithoutExtension))
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
File.Delete(imageFile); // 删除图片
|
||||||
|
Console.WriteLine($"已删除图片: {Path.GetFileName(imageFile)}");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"删除文件 {Path.GetFileName(imageFile)} 时出错: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"图片 {Path.GetFileName(imageFile)} 有对应的 JSON 文件,不删除。");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"操作失败: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将 List<string> 保存到指定文件中,格式为 "项,标签"。
|
||||||
|
/// 标签是根据项的索引生成的。
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="items">要保存的字符串列表</param>
|
||||||
|
/// <param name="filePath">保存文件的路径</param>
|
||||||
|
public static void SaveItemsToFile(List<string> items, string filePath)
|
||||||
|
{
|
||||||
|
// 使用 StreamWriter 写入文件
|
||||||
|
using (StreamWriter writer = new StreamWriter(filePath))
|
||||||
|
{
|
||||||
|
// 遍历 items 列表
|
||||||
|
for (int i = 0; i < items.Count; i++)
|
||||||
|
{
|
||||||
|
// 写入每一行,格式为 "项, 标签"
|
||||||
|
writer.WriteLine($"{items[i]},{i}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public static void SaveItemsToFile(HashSet<string> items, string filePath)
|
||||||
|
{
|
||||||
|
// 使用 StreamWriter 写入文件
|
||||||
|
using (StreamWriter writer = new StreamWriter(filePath))
|
||||||
|
{
|
||||||
|
// 遍历 HashSet
|
||||||
|
int i = 0;
|
||||||
|
foreach (string item in items)
|
||||||
|
{
|
||||||
|
// 写入每一行,格式为 "项, 标签"
|
||||||
|
writer.WriteLine($"{item},{i}"); // 假设使用 item 的长度作为标签
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static List<FileInformation> FileList = new List<FileInformation>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 递归获取指定文件夹下所有文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dir"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<FileInformation> GetAllFiles(DirectoryInfo dir)
|
||||||
|
{
|
||||||
|
FileInfo[] allFile = dir.GetFiles();
|
||||||
|
foreach (FileInfo fi in allFile)
|
||||||
|
{
|
||||||
|
FileList.Add(new FileInformation { FileName = fi.Name, FilePath = fi.FullName });
|
||||||
|
}
|
||||||
|
DirectoryInfo[] allDir = dir.GetDirectories();
|
||||||
|
foreach (DirectoryInfo d in allDir)
|
||||||
|
{
|
||||||
|
GetAllFiles(d);
|
||||||
|
}
|
||||||
|
return FileList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 判断字符串是否纯字母
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static bool IsAlphabetOnly(string input)
|
||||||
|
{
|
||||||
|
return Regex.IsMatch(input, "^[a-zA-Z]+$");
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 判断字符串是否仅包含大小写字母和数字
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="input">待判断的字符串</param>
|
||||||
|
/// <returns>如果字符串仅包含字母和数字,返回 true;否则返回 false</returns>
|
||||||
|
public static bool IsAlphaNumericOnly(string input)
|
||||||
|
{
|
||||||
|
return Regex.IsMatch(input, "^[a-zA-Z0-9]+$");
|
||||||
|
}
|
||||||
|
public static string ConvertHanzitoPinyinWithNumbers(string input)
|
||||||
|
{
|
||||||
|
// 正则表达式匹配汉字
|
||||||
|
string pattern = @"[\u4e00-\u9fa5]";
|
||||||
|
Regex regex = new Regex(pattern);
|
||||||
|
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
int lastIndex = 0;
|
||||||
|
|
||||||
|
foreach (Match match in regex.Matches(input))
|
||||||
|
{
|
||||||
|
// 将非汉字部分保留为原样
|
||||||
|
result.Append(input.Substring(lastIndex, match.Index - lastIndex));
|
||||||
|
|
||||||
|
// 获取汉字并转换为拼音
|
||||||
|
string hanzi = match.Value;
|
||||||
|
string pinyin = ConvertHanziToPinyin(hanzi);
|
||||||
|
|
||||||
|
// 将拼音追加到结果中
|
||||||
|
result.Append(pinyin);
|
||||||
|
|
||||||
|
lastIndex = match.Index + match.Length;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加最后的非汉字部分
|
||||||
|
result.Append(input.Substring(lastIndex));
|
||||||
|
|
||||||
|
return result.ToString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string ConvertHanziToPinyin(string hanzi)
|
||||||
|
{
|
||||||
|
// 设置拼音格式:去掉音调,拼音小写,ü保持为u:
|
||||||
|
PinyinFormat format = PinyinFormat.WITHOUT_TONE | PinyinFormat.LOWERCASE | PinyinFormat.WITH_U_AND_COLON;
|
||||||
|
|
||||||
|
// 获取拼音数组
|
||||||
|
List<PinyinItem> pinyinItems = Pinyin4Net.GetPinyinArray(hanzi, format);
|
||||||
|
|
||||||
|
StringBuilder pinyinBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
foreach (var item in pinyinItems)
|
||||||
|
{
|
||||||
|
// 处理多音字:默认取第一个拼音
|
||||||
|
if (item.Count > 0)
|
||||||
|
{
|
||||||
|
string pinyin = item[0];
|
||||||
|
|
||||||
|
// 特殊处理ü的情况
|
||||||
|
pinyin = pinyin.Replace("u:", "v"); // 将u:转为v,这是常见的拼音表示法
|
||||||
|
|
||||||
|
pinyinBuilder.Append(pinyin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return pinyinBuilder.ToString();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 汉字拼音转化
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="hanzi"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//public static string ConvertHanzitoPinyin(string hanzi)
|
||||||
|
//{
|
||||||
|
// PinyinFormat format = PinyinFormat.WITHOUT_TONE | PinyinFormat.LOWERCASE | PinyinFormat.WITH_U_UNICODE;
|
||||||
|
|
||||||
|
// // string hanzi = defectRow.LabelDescription;
|
||||||
|
// List<PinyinItem> pylist = Pinyin4Net.GetPinyinArray(hanzi, format);
|
||||||
|
// // 提取所有拼音并合并为一个字符串
|
||||||
|
// List<string> pinyinStrings = new List<string>();
|
||||||
|
// foreach (var item in pylist)
|
||||||
|
// {
|
||||||
|
// // 将PinyinItem中的每个拼音(List<string>)合并为一个字符串
|
||||||
|
// string joinedPinyin = string.Join("", item); // 这里的item就是一个List<string>,其中存储了拼音
|
||||||
|
// pinyinStrings.Add(joinedPinyin); // 添加合并后的拼音
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // 合并所有拼音为一个字符串
|
||||||
|
// string allPinyin = string.Join("", pinyinStrings);
|
||||||
|
// return allPinyin;
|
||||||
|
//}
|
||||||
|
/// <summary>
|
||||||
|
/// 递归获取指定文件夹下所有文件
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="dir"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<FileInformation> GetAllFiles(string dir)
|
||||||
|
{
|
||||||
|
DirectoryInfo directoryInfo = new(dir);
|
||||||
|
return GetAllFiles(directoryInfo);
|
||||||
|
}
|
||||||
|
public static string OpenSlectDirDialog(string dirpath = "")
|
||||||
|
{
|
||||||
|
FolderBrowserDialog fbd = new FolderBrowserDialog();
|
||||||
|
fbd.InitialDirectory = dirpath;
|
||||||
|
if (fbd.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
string targetDirPath = fbd.SelectedPath;
|
||||||
|
if (Directory.Exists(targetDirPath))
|
||||||
|
{
|
||||||
|
return targetDirPath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return string.Empty;
|
||||||
|
//ImportDirImages(targetDirPath);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return string.Empty;
|
||||||
|
}
|
||||||
|
public static string OpenSlectfileDialog(string dirpath = "")
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// 创建并配置 OpenFileDialog 实例
|
||||||
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||||
|
openFileDialog.Title = "选择文件"; // 对话框标题
|
||||||
|
openFileDialog.Filter = "所有文件 (*.pt)|*.*"; // 允许选择任何类型的文件
|
||||||
|
openFileDialog.InitialDirectory = @"C:\"; // 初始显示目录,可以根据需要修改
|
||||||
|
|
||||||
|
// 显示对话框
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
// 获取选中的文件路径
|
||||||
|
string selectedFilePath = openFileDialog.FileName;
|
||||||
|
Console.WriteLine("您选择的文件路径是: " + selectedFilePath);
|
||||||
|
return selectedFilePath;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine("没有选择任何文件。");
|
||||||
|
return string.Empty;
|
||||||
|
MessageBox.Show("没有选择任何文件。");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class FileInformation
|
||||||
|
{
|
||||||
|
public string FileName { get; set; }
|
||||||
|
public string FilePath { get; set; }
|
||||||
|
}
|
||||||
|
}
|
107
DH.Commons/Helper/ImageSaveHelper.cs
Normal file
107
DH.Commons/Helper/ImageSaveHelper.cs
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DH.Commons.Helper;
|
||||||
|
|
||||||
|
namespace DH.Commons.Enums
|
||||||
|
{
|
||||||
|
public class ImageSaveHelper
|
||||||
|
{
|
||||||
|
public event Action<DateTime, string> OnImageSaveExceptionRaised;
|
||||||
|
|
||||||
|
//private string baseDirectory = "";
|
||||||
|
//public string BaseDirectory
|
||||||
|
//{
|
||||||
|
// get => baseDirectory;
|
||||||
|
// set
|
||||||
|
// {
|
||||||
|
// baseDirectory = value;
|
||||||
|
// if (string.IsNullOrWhiteSpace(baseDirectory) || !Path.IsPathRooted(baseDirectory))
|
||||||
|
// {
|
||||||
|
// baseDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Images");
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
public bool EnableImageSave { get; set; } = true;
|
||||||
|
|
||||||
|
public ImageSaveHelper() { }
|
||||||
|
public ImageSaveHelper(bool enableImageSave = true)
|
||||||
|
{
|
||||||
|
EnableImageSave = enableImageSave;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
object lockObj = new object();
|
||||||
|
////耗时操作从 _taskFactory分配线程
|
||||||
|
//public TaskFactory _taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.LongRunning);
|
||||||
|
readonly ConcurrentQueue<ImageSaveSet> _imageQueue = new ConcurrentQueue<ImageSaveSet>();
|
||||||
|
Task _saveTask = null;
|
||||||
|
readonly object _saveLock = new object();
|
||||||
|
|
||||||
|
public async void ImageSaveAsync(ImageSaveSet set)
|
||||||
|
{
|
||||||
|
if (!EnableImageSave)
|
||||||
|
return;
|
||||||
|
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
_imageQueue.Enqueue(set);
|
||||||
|
|
||||||
|
lock (_saveLock)
|
||||||
|
{
|
||||||
|
if (_saveTask == null)
|
||||||
|
{
|
||||||
|
_saveTask = Task.Run(async () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
while (_imageQueue.Count > 0)
|
||||||
|
{
|
||||||
|
if (_imageQueue.TryDequeue(out ImageSaveSet saveSet))
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(Path.GetDirectoryName(saveSet.FullName)))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(Path.GetDirectoryName(saveSet.FullName));
|
||||||
|
}
|
||||||
|
if (saveSet.SaveImage != null)
|
||||||
|
{
|
||||||
|
saveSet.SaveImage.Save(saveSet.FullName, saveSet.ImageFormat);
|
||||||
|
saveSet.SaveImage.Dispose();
|
||||||
|
}
|
||||||
|
saveSet = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
await Task.Delay(2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
OnImageSaveExceptionRaised?.Invoke(DateTime.Now, $"图片保存异常:{ex.GetExceptionMessage()}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ImageSaveSet
|
||||||
|
{
|
||||||
|
public string FullName { get; set; }//带后缀 全路径
|
||||||
|
|
||||||
|
public Bitmap SaveImage { get; set; }
|
||||||
|
|
||||||
|
public ImageFormat ImageFormat { get; set; } = ImageFormat.Jpeg;
|
||||||
|
}
|
||||||
|
}
|
138
DH.Commons/Helper/LoggerHelper.cs
Normal file
138
DH.Commons/Helper/LoggerHelper.cs
Normal file
@ -0,0 +1,138 @@
|
|||||||
|
using DH.Commons.Helper;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using static DH.Commons.Enums.EnumHelper;
|
||||||
|
|
||||||
|
namespace DH.Commons.Enums
|
||||||
|
{
|
||||||
|
public interface ILogOutput
|
||||||
|
{
|
||||||
|
event Action<LogMsg> OnLogMsgOutput;
|
||||||
|
void LogDisplay(LogMsg msg);
|
||||||
|
}
|
||||||
|
public interface ILogger
|
||||||
|
{
|
||||||
|
event Action<LogMsg> OnLog;
|
||||||
|
LoggerHelper LoggerHelper { get; set; }
|
||||||
|
//void LogAsync(DateTime dt, LogLevel loglevel, string msg);
|
||||||
|
void LogAsync(LogMsg msg);
|
||||||
|
}
|
||||||
|
public class LoggerHelper
|
||||||
|
{
|
||||||
|
public event Action<DateTime, string> OnLogExceptionRaised;
|
||||||
|
|
||||||
|
public string LogPath { get; set; }
|
||||||
|
public string LogPrefix { get; set; }
|
||||||
|
|
||||||
|
LogLevel LogLevel = LogLevel.Information;
|
||||||
|
|
||||||
|
public LoggerHelper() { }
|
||||||
|
public LoggerHelper(string logPath, string logPrefix, LogLevel logLevel = LogLevel.Information)
|
||||||
|
{
|
||||||
|
LogPath = logPath;
|
||||||
|
LogPrefix = logPrefix;
|
||||||
|
|
||||||
|
LogLevel = logLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetLogLevel(LogLevel logLevel)
|
||||||
|
{
|
||||||
|
if (LogLevel != logLevel)
|
||||||
|
LogLevel = logLevel;
|
||||||
|
}
|
||||||
|
////耗时操作从 _taskFactory分配线程
|
||||||
|
//public TaskFactory _taskFactory = new TaskFactory(TaskCreationOptions.LongRunning, TaskContinuationOptions.LongRunning);
|
||||||
|
readonly ConcurrentQueue<LogMsg> _logQueue = new ConcurrentQueue<LogMsg>();
|
||||||
|
Task _logTask = null;
|
||||||
|
readonly object _logLock = new object();
|
||||||
|
|
||||||
|
public async void LogAsync(LogMsg msg)
|
||||||
|
{
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
_logQueue.Enqueue(msg);
|
||||||
|
|
||||||
|
lock (_logLock)
|
||||||
|
{
|
||||||
|
if (_logTask == null)
|
||||||
|
{
|
||||||
|
_logTask = Task.Run(async () =>
|
||||||
|
{
|
||||||
|
string filePath = Path.Combine(LogPath, $"{(string.IsNullOrWhiteSpace(LogPrefix) ? "Log_" : ("Log_" + LogPrefix + "_"))}{DateTime.Now.ToString("yyyyMMdd")}.txt");
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!StaticHelper.CheckFilesCanUse(filePath))
|
||||||
|
{
|
||||||
|
OnLogExceptionRaised?.Invoke(DateTime.Now, $"日志文件{filePath}被占用,无法写入");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
using (StreamWriter writer = new StreamWriter(filePath, true, System.Text.Encoding.UTF8))
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(LogPath))
|
||||||
|
{
|
||||||
|
Directory.CreateDirectory(LogPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
while (_logQueue.Count > 0)
|
||||||
|
{
|
||||||
|
if (_logQueue.TryDequeue(out LogMsg log))
|
||||||
|
{
|
||||||
|
if (log.LogLevel >= LogLevel)
|
||||||
|
{
|
||||||
|
writer.WriteLine($"{log.LogTime.ToString("yyyy-MM-dd HH:mm:ss.fff")}[{log.ThreadId}]\t{log.LogLevel.GetEnumDescription()}\t{log.Msg}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.Flush();
|
||||||
|
|
||||||
|
await Task.Delay(2000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
//OnLogExceptionRaised?.Invoke(DateTime.Now, $"日志文件{filePath}写入异常:/*{ex.GetExceptionMessage()*/}");
|
||||||
|
OnLogExceptionRaised?.Invoke(DateTime.Now, $"日志文件{filePath}写入异常");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogAsync(DateTime dt, LogLevel logLevel, string msg)
|
||||||
|
{
|
||||||
|
LogAsync(new LogMsg(dt, logLevel, msg));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LogMsg
|
||||||
|
{
|
||||||
|
public DateTime LogTime { get; set; }
|
||||||
|
public LogLevel LogLevel { get; set; }
|
||||||
|
//public string Prefix { get; set; }
|
||||||
|
public string Msg { get; set; }
|
||||||
|
|
||||||
|
public string MsgSource { get; set; }
|
||||||
|
|
||||||
|
public int ThreadId { get; set; }
|
||||||
|
|
||||||
|
public LogMsg() { }
|
||||||
|
public LogMsg(DateTime dt, LogLevel logLevel, string msg)
|
||||||
|
{
|
||||||
|
LogTime = dt;
|
||||||
|
LogLevel = logLevel;
|
||||||
|
Msg = msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override string ToString()
|
||||||
|
{
|
||||||
|
return $"{LogTime.ToString("HH:mm:ss.fff")}\t{MsgSource}\t{Msg}";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
169
DH.Commons/Helper/SchemeHelper.cs
Normal file
169
DH.Commons/Helper/SchemeHelper.cs
Normal file
@ -0,0 +1,169 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace DH.Commons.Helper
|
||||||
|
{
|
||||||
|
public static class SchemeHelper
|
||||||
|
{
|
||||||
|
private const string DefaultSchemeName = "默认方案";
|
||||||
|
private static readonly string ConfigFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "schemes.json");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 方案配置数据结构
|
||||||
|
/// </summary>
|
||||||
|
private class SchemeConfig
|
||||||
|
{
|
||||||
|
public List<string> Schemes { get; set; } = new List<string>();
|
||||||
|
public string CurrentScheme { get; set; } = DefaultSchemeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化配置(首次运行时调用)
|
||||||
|
/// </summary>
|
||||||
|
public static void Initialize()
|
||||||
|
{
|
||||||
|
if (!File.Exists(ConfigFilePath))
|
||||||
|
{
|
||||||
|
var defaultConfig = new SchemeConfig
|
||||||
|
{
|
||||||
|
Schemes = new List<string> { DefaultSchemeName },
|
||||||
|
CurrentScheme = DefaultSchemeName
|
||||||
|
};
|
||||||
|
SaveConfig(defaultConfig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取所有方案
|
||||||
|
/// </summary>
|
||||||
|
public static List<string> GetAllSchemes()
|
||||||
|
{
|
||||||
|
var config = LoadConfig();
|
||||||
|
return config.Schemes ?? new List<string>();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 添加新方案
|
||||||
|
/// </summary>
|
||||||
|
public static void AddScheme(string schemeName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(schemeName))
|
||||||
|
throw new ArgumentException("方案名称无效");
|
||||||
|
|
||||||
|
var config = LoadConfig();
|
||||||
|
|
||||||
|
if (config.Schemes.Contains(schemeName))
|
||||||
|
throw new InvalidOperationException($"方案 {schemeName} 已存在");
|
||||||
|
|
||||||
|
config.Schemes.Add(schemeName);
|
||||||
|
SaveConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 设置当前方案
|
||||||
|
/// </summary>
|
||||||
|
public static void SetCurrentScheme(string schemeName)
|
||||||
|
{
|
||||||
|
var config = LoadConfig();
|
||||||
|
|
||||||
|
if (!config.Schemes.Contains(schemeName))
|
||||||
|
throw new KeyNotFoundException($"方案 {schemeName} 不存在");
|
||||||
|
|
||||||
|
config.CurrentScheme = schemeName;
|
||||||
|
SaveConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取当前方案
|
||||||
|
/// </summary>
|
||||||
|
public static string GetCurrentScheme()
|
||||||
|
{
|
||||||
|
var config = LoadConfig();
|
||||||
|
return !string.IsNullOrEmpty(config.CurrentScheme)
|
||||||
|
? config.CurrentScheme
|
||||||
|
: DefaultSchemeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除指定方案
|
||||||
|
/// </summary>
|
||||||
|
public static void DeleteScheme(string schemeName)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(schemeName))
|
||||||
|
throw new ArgumentException("方案名称无效");
|
||||||
|
|
||||||
|
var config = LoadConfig();
|
||||||
|
|
||||||
|
if (!config.Schemes.Contains(schemeName))
|
||||||
|
throw new KeyNotFoundException($"方案 {schemeName} 不存在");
|
||||||
|
|
||||||
|
// 如果是当前方案,需要先切换
|
||||||
|
if (config.CurrentScheme == schemeName)
|
||||||
|
{
|
||||||
|
var otherScheme = config.Schemes.FirstOrDefault(s => s != schemeName);
|
||||||
|
if (otherScheme != null)
|
||||||
|
{
|
||||||
|
config.CurrentScheme = otherScheme;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
config.CurrentScheme = DefaultSchemeName;
|
||||||
|
if (!config.Schemes.Contains(DefaultSchemeName))
|
||||||
|
{
|
||||||
|
config.Schemes.Add(DefaultSchemeName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config.Schemes.Remove(schemeName);
|
||||||
|
SaveConfig(config);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 加载配置文件
|
||||||
|
/// </summary>
|
||||||
|
private static SchemeConfig LoadConfig()
|
||||||
|
{
|
||||||
|
if (!File.Exists(ConfigFilePath))
|
||||||
|
{
|
||||||
|
Initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string json = File.ReadAllText(ConfigFilePath);
|
||||||
|
return JsonConvert.DeserializeObject<SchemeConfig>(json) ?? new SchemeConfig();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
// 如果读取失败,返回默认配置
|
||||||
|
return new SchemeConfig
|
||||||
|
{
|
||||||
|
Schemes = new List<string> { DefaultSchemeName },
|
||||||
|
CurrentScheme = DefaultSchemeName
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存配置文件
|
||||||
|
/// </summary>
|
||||||
|
private static void SaveConfig(SchemeConfig config)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
string json = JsonConvert.SerializeObject(config, Formatting.Indented);
|
||||||
|
File.WriteAllText(ConfigFilePath, json);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
// 处理保存失败的情况
|
||||||
|
throw new InvalidOperationException("保存方案配置失败", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
680
DH.Commons/Helper/StaticHelper.cs
Normal file
680
DH.Commons/Helper/StaticHelper.cs
Normal file
@ -0,0 +1,680 @@
|
|||||||
|
using Microsoft.CSharp.RuntimeBinder;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Drawing.Imaging;
|
||||||
|
using System.Dynamic;
|
||||||
|
using System.Linq.Expressions;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
using System.Runtime.ExceptionServices;
|
||||||
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Runtime.Serialization.Formatters.Binary;
|
||||||
|
|
||||||
|
namespace DH.Commons.Helper
|
||||||
|
{
|
||||||
|
public static class StaticHelper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 数值转换为byte数组 高位在前,低位在后
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="number"></param>
|
||||||
|
/// <param name="size"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static byte[] IntToBytes(this int number, int size = 2)
|
||||||
|
{
|
||||||
|
byte[] result = new byte[size];
|
||||||
|
|
||||||
|
int temp = size;
|
||||||
|
while (temp > 0)
|
||||||
|
{
|
||||||
|
result[size - temp] = (byte)(number >> ((temp - 1) * 8) & 0xff);
|
||||||
|
|
||||||
|
temp--;
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
public static T DeepSerializeClone<T>(this T t)
|
||||||
|
{
|
||||||
|
return JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(t));
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 字节数组转换为整数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">字节数组</param>
|
||||||
|
/// <param name="HtL">true:数组序号低的在高位 false:数组序号低的在低位</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static int BytesToInt(this byte[] data, bool HtL = true)
|
||||||
|
{
|
||||||
|
int res = 0;
|
||||||
|
|
||||||
|
for (int i = 0; i < data.Length; i++)
|
||||||
|
{
|
||||||
|
int index = i;
|
||||||
|
|
||||||
|
if (HtL)
|
||||||
|
{
|
||||||
|
index = data.Length - 1 - i;
|
||||||
|
}
|
||||||
|
|
||||||
|
res += data[index] << (8 * i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取一个类指定的属性值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="info">object对象</param>
|
||||||
|
/// <param name="field">属性名称</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static object GetPropertyValue(object info, string field)
|
||||||
|
{
|
||||||
|
if (info == null) return null;
|
||||||
|
Type t = info.GetType();
|
||||||
|
IEnumerable<System.Reflection.PropertyInfo> property = from pi in t.GetProperties() where pi.Name.ToLower() == field.ToLower() select pi;
|
||||||
|
return property.First().GetValue(info, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将32位整形拆分为无符号16位整形
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="num">需要拆分的32位整形</param>
|
||||||
|
/// <param name="bitNum">拆分为16位整形的位数 1或者2</param>
|
||||||
|
/// <param name="HtL">true:高位在前,低位在后;false:高位在后,低位在前</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<ushort> ParseIntToUnsignShortList(this int num, int bitNum = 2, bool HtL = false)
|
||||||
|
{
|
||||||
|
if (bitNum == 2)
|
||||||
|
{
|
||||||
|
ushort high = (ushort)(num >> 16);
|
||||||
|
ushort low = (ushort)num;
|
||||||
|
|
||||||
|
if (HtL)
|
||||||
|
{
|
||||||
|
return new List<ushort>() { high, low };
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return new List<ushort>() { low, high };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (num < 0)
|
||||||
|
{
|
||||||
|
num = ushort.MaxValue + 1 + num;
|
||||||
|
}
|
||||||
|
|
||||||
|
return new List<ushort>() { (ushort)num };
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将32位整形数组拆分为无符号16位整形数组
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="list">需要拆分的32位整形</param>
|
||||||
|
/// <param name="bitNum">拆分为16位整形的位数 1或者2</param>
|
||||||
|
/// <param name="HtL">true:高位在前,低位在后;false:高位在后,低位在前</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<ushort> ParseIntToUnsignShortList(this List<int> list, int bitNum = 2, bool HtL = false)
|
||||||
|
{
|
||||||
|
return list.SelectMany(u => u.ParseIntToUnsignShortList(bitNum, HtL)).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 将ushort的集合转换为16位带符号整形
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="numList"></param>
|
||||||
|
/// <param name="bitNum">合并的位数 1或者2</param>
|
||||||
|
/// <param name="HtL">true:高位在前,低位在后;false:高位在后,低位在前</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<int> ParseUnsignShortListToInt(this List<int> numList, int bitNum = 2, bool HtL = false)
|
||||||
|
{
|
||||||
|
if (bitNum == 1)
|
||||||
|
{
|
||||||
|
return numList.ConvertAll(n =>
|
||||||
|
{
|
||||||
|
int num = n;
|
||||||
|
if (num > short.MaxValue)
|
||||||
|
{
|
||||||
|
num = num - ushort.MaxValue - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return num;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
List<int> list = new List<int>();
|
||||||
|
for (int i = 0; i < numList.Count; i += 2)
|
||||||
|
{
|
||||||
|
int high = HtL ? numList[i] : numList[i + 1];
|
||||||
|
int low = HtL ? numList[i + 1] : numList[i];
|
||||||
|
list.Add((high << 16) | low);
|
||||||
|
}
|
||||||
|
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//public static T DeepSerializeClone<T>(this T t)
|
||||||
|
//{
|
||||||
|
// return JsonConvert.DeserializeObject<T>(JsonConvert.SerializeObject(t));
|
||||||
|
//}
|
||||||
|
|
||||||
|
public static void DataFrom<T1, T2>(this T1 destT, T2 sourceT, List<string> exceptionProps = null) where T1 : class where T2 : class
|
||||||
|
{
|
||||||
|
if (sourceT == null)
|
||||||
|
{
|
||||||
|
destT = null;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
PropertyInfo[] propDest = destT.GetType().GetProperties();//.Where(p => !(p.GetMethod.IsVirtual && !p.GetMethod.IsFinal)).ToArray();
|
||||||
|
PropertyInfo[] propSource = sourceT.GetType().GetProperties();
|
||||||
|
|
||||||
|
Array.ForEach(propDest, prop =>
|
||||||
|
{
|
||||||
|
if (exceptionProps == null || !exceptionProps.Contains(prop.Name))
|
||||||
|
{
|
||||||
|
if (prop.CanWrite)
|
||||||
|
{
|
||||||
|
PropertyInfo propS = propSource.FirstOrDefault(p => p.Name == prop.Name);
|
||||||
|
if (propS != null && propS.CanRead)
|
||||||
|
{
|
||||||
|
prop.SetValue(destT, propS.GetValue(sourceT));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//RtlMoveMemory
|
||||||
|
[DllImport("kernel32.dll", EntryPoint = "RtlMoveMemory", SetLastError = false)]
|
||||||
|
public static extern void CopyMemory(IntPtr dest, IntPtr src, uint count);
|
||||||
|
[HandleProcessCorruptedStateExceptions]
|
||||||
|
//public static Bitmap CopyBitmap(this Bitmap source)
|
||||||
|
//{
|
||||||
|
// Bitmap clone = new Bitmap(source.Width, source.Height, source.PixelFormat);
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// int PixelSize = Bitmap.GetPixelFormatSize(source.PixelFormat) / 8;
|
||||||
|
// if (PixelSize == 1)
|
||||||
|
// {
|
||||||
|
// ColorPalette cp = clone.Palette;
|
||||||
|
// for (int i = 0; i < 256; i++)
|
||||||
|
// {
|
||||||
|
// cp.Entries[i] = Color.FromArgb(255, i, i, i);
|
||||||
|
// }
|
||||||
|
// clone.Palette = cp;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// Rectangle rect = new Rectangle(0, 0, source.Width, source.Height);
|
||||||
|
// BitmapData sourceData = source.LockBits(rect, ImageLockMode.ReadWrite, source.PixelFormat);
|
||||||
|
// BitmapData cloneData = clone.LockBits(rect, ImageLockMode.ReadWrite, source.PixelFormat);
|
||||||
|
// if (source.Width % 4 == 0)
|
||||||
|
// {
|
||||||
|
// unsafe
|
||||||
|
// {
|
||||||
|
// CopyMemory(cloneData.Scan0, sourceData.Scan0, (uint)(sourceData.Stride * sourceData.Height));
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// Parallel.For(0, source.Height, h =>
|
||||||
|
// {
|
||||||
|
// unsafe
|
||||||
|
// {
|
||||||
|
// CopyMemory(cloneData.Scan0 + h * sourceData.Stride, sourceData.Scan0 + h * sourceData.Stride, (uint)sourceData.Width);
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
|
||||||
|
// clone.UnlockBits(cloneData);
|
||||||
|
// source.UnlockBits(sourceData);
|
||||||
|
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// return clone;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// return clone;
|
||||||
|
//}
|
||||||
|
public static Bitmap CopyBitmap(this Bitmap source)
|
||||||
|
{
|
||||||
|
Bitmap clone = new Bitmap(source.Width, source.Height, source.PixelFormat);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int pixelSize = Bitmap.GetPixelFormatSize(source.PixelFormat) / 8;
|
||||||
|
if (pixelSize == 1)
|
||||||
|
{
|
||||||
|
ColorPalette cp = clone.Palette;
|
||||||
|
for (int i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
cp.Entries[i] = Color.FromArgb(255, i, i, i);
|
||||||
|
}
|
||||||
|
clone.Palette = cp;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rectangle rect = new Rectangle(0, 0, source.Width, source.Height);
|
||||||
|
BitmapData sourceData = source.LockBits(rect, ImageLockMode.ReadOnly, source.PixelFormat);
|
||||||
|
BitmapData cloneData = clone.LockBits(rect, ImageLockMode.WriteOnly, source.PixelFormat);
|
||||||
|
|
||||||
|
int stride = sourceData.Stride;
|
||||||
|
int height = sourceData.Height;
|
||||||
|
|
||||||
|
if (stride % 4 == 0)
|
||||||
|
{
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
CopyMemory(cloneData.Scan0, sourceData.Scan0, (uint)(stride * height));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Parallel.For(0, height, h =>
|
||||||
|
{
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
CopyMemory(cloneData.Scan0 + h * stride, sourceData.Scan0 + h * stride, (uint)stride);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
source.UnlockBits(sourceData); clone.UnlockBits(cloneData);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{ // Handle or log exception if needed
|
||||||
|
} return clone; }
|
||||||
|
|
||||||
|
|
||||||
|
public static Bitmap BitmapDeepClone(Bitmap source)
|
||||||
|
{
|
||||||
|
Bitmap clone = new Bitmap(source.Width, source.Height, source.PixelFormat);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int PixelSize = Bitmap.GetPixelFormatSize(source.PixelFormat) / 8;
|
||||||
|
if (PixelSize == 1)
|
||||||
|
{
|
||||||
|
ColorPalette cp = clone.Palette;
|
||||||
|
for (int i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
cp.Entries[i] = Color.FromArgb(255, i, i, i);
|
||||||
|
}
|
||||||
|
clone.Palette = cp;
|
||||||
|
}
|
||||||
|
Rectangle rect = new Rectangle(0, 0, source.Width, source.Height);
|
||||||
|
BitmapData source_bitmap = source.LockBits(rect, ImageLockMode.ReadWrite, source.PixelFormat);
|
||||||
|
BitmapData destination_bitmap = clone.LockBits(rect, ImageLockMode.ReadWrite, clone.PixelFormat);
|
||||||
|
|
||||||
|
int depth_width = source_bitmap.Width * PixelSize;
|
||||||
|
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
byte* source_ptr = (byte*)source_bitmap.Scan0;
|
||||||
|
byte* destination_ptr = (byte*)destination_bitmap.Scan0;
|
||||||
|
|
||||||
|
int offset = source_bitmap.Stride - depth_width;
|
||||||
|
|
||||||
|
for (int i = 0; i < source_bitmap.Height; i++)
|
||||||
|
{
|
||||||
|
for (int j = 0; j < depth_width; j++, source_ptr++, destination_ptr++)
|
||||||
|
{
|
||||||
|
*destination_ptr = *source_ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
source_ptr += offset;
|
||||||
|
destination_ptr += offset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
source.UnlockBits(source_bitmap);
|
||||||
|
clone.UnlockBits(destination_bitmap);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
return clone;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static Bitmap HConnectBitmap(this Bitmap map1, Bitmap map2)
|
||||||
|
{
|
||||||
|
Bitmap connectImage = null;
|
||||||
|
if (map1 == null || map2 == null)
|
||||||
|
return null;
|
||||||
|
//横向拼接
|
||||||
|
int width = map1.Width + map2.Width;
|
||||||
|
//高度不变
|
||||||
|
int height = Math.Max(map1.Height, map2.Height);
|
||||||
|
connectImage = new Bitmap(width, height);
|
||||||
|
using (Graphics graph = Graphics.FromImage(connectImage))
|
||||||
|
{
|
||||||
|
graph.DrawImage(connectImage, width, height);
|
||||||
|
graph.Clear(System.Drawing.Color.White);
|
||||||
|
graph.DrawImage(map1, 0, 0);
|
||||||
|
graph.DrawImage(map2, map1.Width, 0);
|
||||||
|
}
|
||||||
|
return connectImage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IntPtr FloatToIntptr(float[] bytes)
|
||||||
|
{
|
||||||
|
GCHandle hObject = GCHandle.Alloc(bytes, GCHandleType.Pinned);
|
||||||
|
return hObject.AddrOfPinnedObject();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 将Btimap类转换为byte[]类函数
|
||||||
|
public static byte[] GetBGRValues(Bitmap bmp, out int stride)
|
||||||
|
{
|
||||||
|
var rect = new Rectangle(0, 0, bmp.Width, bmp.Height);
|
||||||
|
var bmpData = bmp.LockBits(rect, ImageLockMode.ReadOnly, bmp.PixelFormat);
|
||||||
|
stride = bmpData.Stride;
|
||||||
|
var rowBytes = bmpData.Width * Image.GetPixelFormatSize(bmp.PixelFormat) / 8;
|
||||||
|
var imgBytes = bmp.Height * rowBytes;
|
||||||
|
byte[] rgbValues = new byte[imgBytes];
|
||||||
|
IntPtr ptr = bmpData.Scan0;
|
||||||
|
for (var i = 0; i < bmp.Height; i++)
|
||||||
|
{
|
||||||
|
Marshal.Copy(ptr, rgbValues, i * rowBytes, rowBytes);
|
||||||
|
ptr += bmpData.Stride;
|
||||||
|
}
|
||||||
|
bmp.UnlockBits(bmpData);
|
||||||
|
return rgbValues;
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 缺陷灰度图转彩色图像函数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="src">灰度图</param>
|
||||||
|
/// <returns>返回构造的伪彩色图像</returns>
|
||||||
|
public static Bitmap GrayMapToColorMap(this Bitmap src, Dictionary<int, Color> indexColorDict = null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
//Stopwatch sw = new Stopwatch();
|
||||||
|
//sw.Start();
|
||||||
|
|
||||||
|
Bitmap dest = new Bitmap(src.Width, src.Height, PixelFormat.Format32bppArgb);
|
||||||
|
|
||||||
|
int destHeight = dest.Height;
|
||||||
|
int destWidth = dest.Width;
|
||||||
|
|
||||||
|
Rectangle rect = new Rectangle(0, 0, destWidth, destHeight);
|
||||||
|
BitmapData bmpDataDest = dest.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format32bppArgb);
|
||||||
|
BitmapData bmpDataSrc = src.LockBits(rect, ImageLockMode.ReadWrite, PixelFormat.Format8bppIndexed);
|
||||||
|
int strideDest = bmpDataDest.Stride;
|
||||||
|
|
||||||
|
int strideSrc = bmpDataSrc.Stride;
|
||||||
|
unsafe
|
||||||
|
{
|
||||||
|
byte* pDest = (byte*)bmpDataDest.Scan0.ToPointer();
|
||||||
|
byte* pSrc = (byte*)bmpDataSrc.Scan0.ToPointer();
|
||||||
|
|
||||||
|
Parallel.For(0, destHeight, y =>
|
||||||
|
{
|
||||||
|
Parallel.For(0, destWidth, x =>
|
||||||
|
{
|
||||||
|
int pixel = pSrc[y * strideSrc + x];
|
||||||
|
int startIndex = y * strideDest + x * 4;
|
||||||
|
if (pixel >= 0 && pixel <= 63)
|
||||||
|
{
|
||||||
|
Color color = Color.Red;
|
||||||
|
if (indexColorDict != null && indexColorDict.ContainsKey(pixel))
|
||||||
|
{
|
||||||
|
color = indexColorDict[pixel];
|
||||||
|
}
|
||||||
|
|
||||||
|
byte R = color.R;
|
||||||
|
byte G = color.G;
|
||||||
|
byte B = color.B;
|
||||||
|
|
||||||
|
pDest[startIndex] = B;
|
||||||
|
pDest[startIndex + 1] = G;
|
||||||
|
pDest[startIndex + 2] = R;
|
||||||
|
pDest[startIndex + 3] = 100;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pDest[startIndex] = 255;
|
||||||
|
pDest[startIndex + 1] = 255;
|
||||||
|
pDest[startIndex + 2] = 255;
|
||||||
|
pDest[startIndex + 3] = 0;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
dest.UnlockBits(bmpDataDest);
|
||||||
|
src.UnlockBits(bmpDataSrc);
|
||||||
|
|
||||||
|
//sw.Stop();
|
||||||
|
//Console.WriteLine($"转换耗时:{sw.ElapsedMilliseconds}");
|
||||||
|
|
||||||
|
return dest;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Sort<T>(this ObservableCollection<T> collection) where T : IComparable<T>
|
||||||
|
{
|
||||||
|
List<T> sortedList = collection.OrderByDescending(x => x).ToList();//这里用降序
|
||||||
|
for (int i = 0; i < sortedList.Count(); i++)
|
||||||
|
{
|
||||||
|
collection.Move(collection.IndexOf(sortedList[i]), i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得字符串中开始和结束字符串中间的值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sourse"></param>
|
||||||
|
/// <param name="startstr"></param>
|
||||||
|
/// <param name="endstr"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string GetMidString(string sourse, string startstr, string endstr)
|
||||||
|
{
|
||||||
|
string result = string.Empty;
|
||||||
|
int startindex, endindex;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
startindex = sourse.IndexOf(startstr);
|
||||||
|
if (startindex == -1)
|
||||||
|
return result;
|
||||||
|
string tmpstr = sourse.Substring(startindex + startstr.Length);
|
||||||
|
endindex = tmpstr.IndexOf(endstr);
|
||||||
|
if (endindex == -1)
|
||||||
|
return result;
|
||||||
|
result = tmpstr.Remove(endindex);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得字符串中开始和结束字符串中间的值
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="t">字符串</param>
|
||||||
|
/// <param name="k">开始</param>
|
||||||
|
/// <param name="j">结束</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static string GetMidString2(string sourse, string startstr, string endstr) //截取指定文本,和易语言的取文本中间差不多
|
||||||
|
{
|
||||||
|
try //异常捕捉
|
||||||
|
{
|
||||||
|
var kn = sourse.IndexOf(startstr, StringComparison.Ordinal) + startstr.Length;
|
||||||
|
var jn = sourse.IndexOf(endstr, kn, StringComparison.Ordinal);
|
||||||
|
return sourse.Substring(kn, jn - kn);
|
||||||
|
}
|
||||||
|
catch //如果发现未知的错误,比如上面的代码出错了,就执行下面这句代码
|
||||||
|
{
|
||||||
|
return ""; //返回空
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// 布尔类型转换为整型
|
||||||
|
public static int ToInt(this object obj)
|
||||||
|
{
|
||||||
|
if (Convert.ToBoolean(obj) == true)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 整型转换为布尔类型
|
||||||
|
public static bool ToBool(this object obj)
|
||||||
|
{
|
||||||
|
if (Convert.ToInt32(obj) == 1)
|
||||||
|
return true;
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static object GetProperty(this object o, string member)
|
||||||
|
{
|
||||||
|
if (o == null) throw new ArgumentNullException("o");
|
||||||
|
if (member == null) throw new ArgumentNullException("member");
|
||||||
|
Type scope = o.GetType();
|
||||||
|
IDynamicMetaObjectProvider provider = o as IDynamicMetaObjectProvider;
|
||||||
|
if (provider != null)
|
||||||
|
{
|
||||||
|
ParameterExpression param = Expression.Parameter(typeof(object));
|
||||||
|
DynamicMetaObject mobj = provider.GetMetaObject(param);
|
||||||
|
GetMemberBinder binder = (GetMemberBinder)Microsoft.CSharp.RuntimeBinder.Binder.GetMember(0, member, scope, new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(0, null) });
|
||||||
|
DynamicMetaObject ret = mobj.BindGetMember(binder);
|
||||||
|
BlockExpression final = Expression.Block(
|
||||||
|
Expression.Label(CallSiteBinder.UpdateLabel),
|
||||||
|
ret.Expression
|
||||||
|
);
|
||||||
|
LambdaExpression lambda = Expression.Lambda(final, param);
|
||||||
|
Delegate del = lambda.Compile();
|
||||||
|
return del.DynamicInvoke(o);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return o.GetType().GetProperty(member, BindingFlags.Public | BindingFlags.Instance).GetValue(o, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 检测文件状态及操作方式选择
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
private static extern IntPtr _lopen(string lpPathName, int iReadWrite);
|
||||||
|
[DllImport("kernel32.dll")]
|
||||||
|
private static extern bool CloseHandle(IntPtr hObject);
|
||||||
|
private const int OF_READWRITE = 2;
|
||||||
|
private const int OF_SHARE_DENY_NONE = 0x40;
|
||||||
|
private static readonly IntPtr HFILE_ERROR = new IntPtr(-1);
|
||||||
|
/// <summary>
|
||||||
|
/// 检测文件是否只读或被使用
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="FileNames">要检测的文件</param>
|
||||||
|
/// <returns>true可用,false在用或只读</returns>
|
||||||
|
public static bool CheckFilesCanUse(string fileName)
|
||||||
|
{
|
||||||
|
if (!File.Exists(fileName))
|
||||||
|
return true;//文件不存在
|
||||||
|
if ((File.GetAttributes(fileName) & FileAttributes.ReadOnly) == FileAttributes.ReadOnly)
|
||||||
|
return false; //文件只读
|
||||||
|
IntPtr vHandle = _lopen(fileName, OF_READWRITE | OF_SHARE_DENY_NONE);
|
||||||
|
if (vHandle == HFILE_ERROR)
|
||||||
|
{
|
||||||
|
CloseHandle(vHandle);
|
||||||
|
return false; //文件被占用
|
||||||
|
}
|
||||||
|
|
||||||
|
CloseHandle(vHandle); //文件没被占用
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取指定文件夹下所有的文件名称
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folderName">指定文件夹名称,绝对路径</param>
|
||||||
|
/// <param name="fileFilter">文件类型过滤,根据文件后缀名,如:*,*.txt,*.xls</param>
|
||||||
|
/// <param name="isContainSubFolder">是否包含子文件夹</param>
|
||||||
|
/// <returns>ArrayList数组,为所有需要的文件路径名称</returns>
|
||||||
|
public static List<FileInfo> GetAllFilesByFolder(string folderName, string fileFilter, bool isContainSubFolder = false)
|
||||||
|
{
|
||||||
|
List<FileInfo> resList = new List<FileInfo>();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DirectoryInfo currDir = new DirectoryInfo(folderName);//当前目录
|
||||||
|
FileInfo[] currFiles = currDir.GetFiles(fileFilter);//当前目录文件
|
||||||
|
foreach (FileInfo file in currFiles)
|
||||||
|
{
|
||||||
|
if (fileFilter.ToLower().IndexOf(file.Extension.ToLower()) >= 0)
|
||||||
|
{
|
||||||
|
resList.Add(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (isContainSubFolder)
|
||||||
|
{
|
||||||
|
string[] subFolders = Directory.GetDirectories(folderName);
|
||||||
|
foreach (string subFolder in subFolders)
|
||||||
|
{
|
||||||
|
resList.AddRange(GetAllFilesByFolder(subFolder, fileFilter));//递归
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
throw ex;
|
||||||
|
}
|
||||||
|
return resList;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取指定文件夹下所有的文件名称,不过滤文件类型
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="folderName">指定文件夹名称,绝对路径</param>
|
||||||
|
/// <param name="isContainSubFolder">是否包含子文件夹</param>
|
||||||
|
/// <returns>ArrayList数组,为所有需要的文件路径名称</returns>
|
||||||
|
public static List<FileInfo> GetAllFilesByFolder(string folderName, bool isContainSubFolder)
|
||||||
|
{
|
||||||
|
return GetAllFilesByFolder(folderName, "*", isContainSubFolder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Compare<T, C> : IEqualityComparer<T>
|
||||||
|
{
|
||||||
|
private Func<T, C> _getField;
|
||||||
|
public Compare(Func<T, C> getfield)
|
||||||
|
{
|
||||||
|
_getField = getfield;
|
||||||
|
}
|
||||||
|
public bool Equals(T x, T y)
|
||||||
|
{
|
||||||
|
return EqualityComparer<C>.Default.Equals(_getField(x), _getField(y));
|
||||||
|
}
|
||||||
|
public int GetHashCode(T obj)
|
||||||
|
{
|
||||||
|
return EqualityComparer<C>.Default.GetHashCode(_getField(obj));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class ObjectExtensions
|
||||||
|
{
|
||||||
|
public static IEnumerable<T> DistinctBy<T, C>(this IEnumerable<T> source, Func<T, C> getfield)
|
||||||
|
{
|
||||||
|
return source.Distinct(new Compare<T, C>(getfield));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IQueryable<T> DistinctBy<T, C>(this IQueryable<T> source, Func<T, C> getfield)
|
||||||
|
{
|
||||||
|
return source.Distinct(new Compare<T, C>(getfield));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
120
DH.Commons/Helper/SystemConfigHelper.cs
Normal file
120
DH.Commons/Helper/SystemConfigHelper.cs
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Configuration;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.Commons.Helper
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 配置文件操作工具类(自动定位主程序配置)
|
||||||
|
/// </summary>
|
||||||
|
public static class SystemConfigHelper
|
||||||
|
{
|
||||||
|
private static Configuration _mainConfig;
|
||||||
|
private static readonly object _lock = new object();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取主程序配置对象
|
||||||
|
/// </summary>
|
||||||
|
private static Configuration MainConfiguration
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_mainConfig == null)
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
if (_mainConfig == null)
|
||||||
|
{
|
||||||
|
// 获取主程序路径
|
||||||
|
string exePath = Assembly.GetEntryAssembly().Location;
|
||||||
|
var configFile = exePath + ".config";
|
||||||
|
|
||||||
|
// 加载主程序配置
|
||||||
|
var fileMap = new ExeConfigurationFileMap
|
||||||
|
{
|
||||||
|
ExeConfigFilename = configFile
|
||||||
|
};
|
||||||
|
_mainConfig = ConfigurationManager.OpenMappedExeConfiguration(
|
||||||
|
fileMap,
|
||||||
|
ConfigurationUserLevel.None
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return _mainConfig;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 检查配置项是否存在
|
||||||
|
/// </summary>
|
||||||
|
public static bool KeyExists(string key)
|
||||||
|
{
|
||||||
|
return MainConfiguration.AppSettings.Settings[key] != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 读取配置项(带类型自动转换)
|
||||||
|
/// </summary>
|
||||||
|
public static T GetValue<T>(string key, T defaultValue = default)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var setting = MainConfiguration.AppSettings.Settings[key];
|
||||||
|
if (setting == null) return defaultValue;
|
||||||
|
|
||||||
|
return (T)Convert.ChangeType(setting.Value, typeof(T));
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 写入配置项(自动保存)
|
||||||
|
/// </summary>
|
||||||
|
public static void SetValue(string key, object value)
|
||||||
|
{
|
||||||
|
var settings = MainConfiguration.AppSettings.Settings;
|
||||||
|
var stringValue = value?.ToString() ?? string.Empty;
|
||||||
|
|
||||||
|
if (settings[key] == null)
|
||||||
|
{
|
||||||
|
settings.Add(key, stringValue);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
settings[key].Value = stringValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveChanges();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除指定配置项
|
||||||
|
/// </summary>
|
||||||
|
public static void RemoveKey(string key)
|
||||||
|
{
|
||||||
|
if (KeyExists(key))
|
||||||
|
{
|
||||||
|
MainConfiguration.AppSettings.Settings.Remove(key);
|
||||||
|
SaveChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存配置修改
|
||||||
|
/// </summary>
|
||||||
|
private static void SaveChanges()
|
||||||
|
{
|
||||||
|
MainConfiguration.Save(ConfigurationSaveMode.Modified);
|
||||||
|
ConfigurationManager.RefreshSection("appSettings");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
109
DH.Commons/Interface/Spec.cs
Normal file
109
DH.Commons/Interface/Spec.cs
Normal file
@ -0,0 +1,109 @@
|
|||||||
|
|
||||||
|
using System;
|
||||||
|
using System.ComponentModel;
|
||||||
|
using System.Drawing.Design;
|
||||||
|
|
||||||
|
namespace DH.Commons.Enums
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 标准配置
|
||||||
|
/// </summary>
|
||||||
|
public class Spec
|
||||||
|
{
|
||||||
|
[Category("通用配置")]
|
||||||
|
[Description("标准代码")]
|
||||||
|
public virtual string Code { get; set; }
|
||||||
|
|
||||||
|
[Category("通用配置")]
|
||||||
|
[Description("启用状态,true:启用;false:禁用")]
|
||||||
|
[DisplayName("启用状态")]
|
||||||
|
public bool IsEnabled { get; set; }
|
||||||
|
|
||||||
|
[Category("标准配置")]
|
||||||
|
[Description("标准值")]
|
||||||
|
[DisplayName("标准值")]
|
||||||
|
public double StandardValue { get; set; }
|
||||||
|
|
||||||
|
[Category("标准配置")]
|
||||||
|
[Description("正公差")]
|
||||||
|
[DisplayName("正公差")]
|
||||||
|
public double Tolrenance_Positive { get; set; }
|
||||||
|
|
||||||
|
[Category("标准配置")]
|
||||||
|
[Description("负公差")]
|
||||||
|
[DisplayName("负公差")]
|
||||||
|
public double Tolrenance_Negative { get; set; }
|
||||||
|
|
||||||
|
protected double? actualValue = null;
|
||||||
|
[Browsable(false)]
|
||||||
|
|
||||||
|
public virtual double? ActualValue
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return actualValue;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
//if (actualValue != value && value != null)
|
||||||
|
if (value != null)
|
||||||
|
{
|
||||||
|
if (value.Value >= (StandardValue - Tolrenance_Negative) && value.Value <= (StandardValue + Tolrenance_Positive))
|
||||||
|
{
|
||||||
|
MeasureResult = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MeasureResult = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
actualValue = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
|
|
||||||
|
public bool? MeasureResult { get; set; } = null;
|
||||||
|
|
||||||
|
|
||||||
|
public Spec Copy()
|
||||||
|
{
|
||||||
|
Spec spec = new Spec();
|
||||||
|
|
||||||
|
spec.Code = this.Code;
|
||||||
|
spec.IsEnabled = this.IsEnabled;
|
||||||
|
spec.StandardValue = this.StandardValue;
|
||||||
|
spec.Tolrenance_Positive = this.Tolrenance_Positive;
|
||||||
|
spec.Tolrenance_Negative = this.Tolrenance_Negative;
|
||||||
|
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class IndexedSpec : Spec
|
||||||
|
{
|
||||||
|
[Category("数据源配置")]
|
||||||
|
[Description("数据源输出索引")]
|
||||||
|
[DisplayName("数据源输出索引")]
|
||||||
|
public int OutputIndex { get; set; }
|
||||||
|
|
||||||
|
public new IndexedSpec Copy()
|
||||||
|
{
|
||||||
|
IndexedSpec spec = new IndexedSpec();
|
||||||
|
|
||||||
|
spec.Code = this.Code;
|
||||||
|
spec.IsEnabled = this.IsEnabled;
|
||||||
|
spec.StandardValue = this.StandardValue;
|
||||||
|
spec.Tolrenance_Positive = this.Tolrenance_Positive;
|
||||||
|
spec.Tolrenance_Negative = this.Tolrenance_Negative;
|
||||||
|
|
||||||
|
spec.OutputIndex = this.OutputIndex;
|
||||||
|
|
||||||
|
return spec;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
26
DH.Commons/Models/ProductSummary.cs
Normal file
26
DH.Commons/Models/ProductSummary.cs
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.Commons.Models
|
||||||
|
{
|
||||||
|
public class CameraSummary
|
||||||
|
{
|
||||||
|
public string CameraName { get; set; } // 相机名称
|
||||||
|
public int TiggerCount { get; set; } //触发数
|
||||||
|
public int OKCount { get; set; } // OK 数
|
||||||
|
public int NGCount { get; set; } // NG 数
|
||||||
|
public int TotalCount => OKCount + NGCount; // 总检测数量
|
||||||
|
public string YieldStr => $"{Yield:f2} %"; // 良率(字符串形式)
|
||||||
|
public double Yield => OKCount + NGCount > 0 ? (double)OKCount / (OKCount + NGCount) * 100 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class ProductSummary
|
||||||
|
{
|
||||||
|
public int ProductAmount { get; set; }
|
||||||
|
public string ResultDesc { get; set; }
|
||||||
|
public string PercentStr { get; set; }
|
||||||
|
}
|
||||||
|
}
|
34
DH.Commons/Models/SystemModel.cs
Normal file
34
DH.Commons/Models/SystemModel.cs
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DH.Commons.Base;
|
||||||
|
using DH.Commons.Enums;
|
||||||
|
|
||||||
|
namespace DH.Commons.Models
|
||||||
|
{
|
||||||
|
public static class SystemModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 当前方案
|
||||||
|
/// </summary>
|
||||||
|
public static string CurrentScheme=string.Empty;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前状态
|
||||||
|
/// </summary>
|
||||||
|
public static EnumStatus CurrentStatus =EnumStatus.待机中;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 配置集合
|
||||||
|
/// </summary>
|
||||||
|
public static class ConfigModel
|
||||||
|
{
|
||||||
|
public static List<CameraBase> CameraBaseList = new List<CameraBase>();
|
||||||
|
public static List<PLCBase> PLCBaseList = new List<PLCBase>();
|
||||||
|
public static List<DetectionConfig> DetectionList = new List<DetectionConfig>();
|
||||||
|
public static List<GlobalConfig> GlobalList = new List<GlobalConfig>();
|
||||||
|
}
|
||||||
|
}
|
@ -24,7 +24,6 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DH.Commons.Devies\DH.Commons.Devies.csproj" />
|
|
||||||
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
|
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
@ -1,31 +1,45 @@
|
|||||||
using System.Diagnostics;
|
using System.Collections.Concurrent;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Reflection.Metadata;
|
using System.Reflection.Metadata;
|
||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using DH.Devices.Devices;
|
using DH.Commons.Base;
|
||||||
|
using DH.Commons.Enums;
|
||||||
|
using DH.Commons.Helper;
|
||||||
using DVPCameraType;
|
using DVPCameraType;
|
||||||
using OpenCvSharp;
|
using OpenCvSharp;
|
||||||
|
using OpenCvSharp.Extensions;
|
||||||
using static System.Net.Mime.MediaTypeNames;
|
using static System.Net.Mime.MediaTypeNames;
|
||||||
|
using static MvCamCtrl.NET.MyCamera;
|
||||||
|
using LogLevel = DH.Commons.Enums.EnumHelper.LogLevel;
|
||||||
|
|
||||||
|
|
||||||
namespace DH.Devices.Camera
|
namespace DH.Devices.Camera
|
||||||
{
|
{
|
||||||
|
|
||||||
public class Do3ThinkCamera : CameraBase
|
public class Do3ThinkCamera : CameraBase, ILogger
|
||||||
{
|
{
|
||||||
|
|
||||||
private dvpCameraInfo stDevInfo = new dvpCameraInfo();
|
private dvpCameraInfo stDevInfo = new dvpCameraInfo();
|
||||||
private dvpStatus nRet = dvpStatus.DVP_STATUS_OK;
|
private dvpStatus nRet = dvpStatus.DVP_STATUS_OK;
|
||||||
private DVPCamera.dvpEventCallback pCallBackFunc;
|
private DVPCamera.dvpEventCallback pCallBackFunc;
|
||||||
private uint m_handle;
|
private uint m_handle;
|
||||||
|
public bool Connected=false;
|
||||||
public int m_n_dev_count = 0;
|
public int m_n_dev_count = 0;
|
||||||
private DVPCamera.dvpStreamCallback ImageCallback;
|
private DVPCamera.dvpStreamCallback ImageCallback;
|
||||||
public dvpStreamFormat dvpStreamFormat = dvpStreamFormat.S_RGB24;
|
// public dvpStreamFormat dvpStreamFormat = dvpStreamFormat.S_RGB24;
|
||||||
public int m_CamCount = 0;
|
public int m_CamCount = 0;
|
||||||
public Double m_dfDisplayCount = 0;
|
public Double m_dfDisplayCount = 0;
|
||||||
|
|
||||||
|
public LoggerHelper LoggerHelper { get; set; } = new LoggerHelper();
|
||||||
|
public event Action<LogMsg> OnLog;
|
||||||
|
public ConcurrentDictionary<string, MatSet> _imageSetList = new ConcurrentDictionary<string, MatSet>();
|
||||||
|
|
||||||
|
|
||||||
public Do3ThinkCamera()
|
public Do3ThinkCamera()
|
||||||
{
|
{
|
||||||
|
LoggerHelper.LogPath = "D://";
|
||||||
|
LoggerHelper.LogPrefix = CameraName;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,6 +63,9 @@ namespace DH.Devices.Camera
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (CameraName == "Cam1")
|
||||||
|
Console.WriteLine("");
|
||||||
|
pCallBackFunc = new DVPCamera.dvpEventCallback(cbExceptiondelegate);
|
||||||
nRet = DVPCamera.dvpOpenByUserId(CameraName,
|
nRet = DVPCamera.dvpOpenByUserId(CameraName,
|
||||||
dvpOpenMode.OPEN_NORMAL,
|
dvpOpenMode.OPEN_NORMAL,
|
||||||
ref m_handle);
|
ref m_handle);
|
||||||
@ -59,7 +76,7 @@ namespace DH.Devices.Camera
|
|||||||
throw new Exception($"Create device failed:{nRet:x8}");
|
throw new Exception($"Create device failed:{nRet:x8}");
|
||||||
}
|
}
|
||||||
|
|
||||||
nRet = DVPCamera.dvpSetTargetFormat(m_handle, (dvpStreamFormat)dvpStreamFormat);
|
nRet = DVPCamera.dvpSetTargetFormat(m_handle, (dvpStreamFormat)DvpImageFormat);
|
||||||
if (dvpStatus.DVP_STATUS_OK != nRet)
|
if (dvpStatus.DVP_STATUS_OK != nRet)
|
||||||
{
|
{
|
||||||
throw new Exception($"Set image format failed:{nRet:x8}");
|
throw new Exception($"Set image format failed:{nRet:x8}");
|
||||||
@ -69,13 +86,13 @@ namespace DH.Devices.Camera
|
|||||||
nRet = DVPCamera.dvpGetCameraInfo(m_handle, ref camerainfo);
|
nRet = DVPCamera.dvpGetCameraInfo(m_handle, ref camerainfo);
|
||||||
|
|
||||||
SerialNumber = camerainfo.SerialNumber;
|
SerialNumber = camerainfo.SerialNumber;
|
||||||
// ch:注册异常回调函数 | en:Register Exception Callback
|
//ch: 注册异常回调函数 | en:Register Exception Callback
|
||||||
//nRet = DVPCamera.dvpRegisterEventCallback(m_handle, pCallBackFunc, dvpEvent.EVENT_DISCONNECTED, IntPtr.Zero);
|
nRet = DVPCamera.dvpRegisterEventCallback(m_handle, pCallBackFunc, dvpEvent.EVENT_DISCONNECTED, IntPtr.Zero);
|
||||||
//if (nRet != dvpStatus.DVP_STATUS_OK)
|
if (nRet != dvpStatus.DVP_STATUS_OK)
|
||||||
//{
|
{
|
||||||
// throw new Exception($"Register expection callback failed:{nRet}");
|
throw new Exception($"Register expection callback failed:{nRet}");
|
||||||
//}
|
}
|
||||||
//GC.KeepAlive(pCallBackFunc);
|
GC.KeepAlive(pCallBackFunc);
|
||||||
|
|
||||||
//// ch:设置采集连续模式 | en:Set Continues Aquisition Mode
|
//// ch:设置采集连续模式 | en:Set Continues Aquisition Mode
|
||||||
if (IsContinueMode)
|
if (IsContinueMode)
|
||||||
@ -130,53 +147,78 @@ namespace DH.Devices.Camera
|
|||||||
throw new Exception($"Start grabbing failed:{nRet:x8}");
|
throw new Exception($"Start grabbing failed:{nRet:x8}");
|
||||||
}
|
}
|
||||||
//// 曝光
|
//// 曝光
|
||||||
//if (IIConfig.DefaultExposure != 0)
|
if (Exposure != 0)
|
||||||
//{
|
{
|
||||||
// SetExposure(IIConfig.DefaultExposure);
|
SetExposure(Exposure);
|
||||||
//}
|
}
|
||||||
//// 增益
|
//// 增益
|
||||||
//if (IIConfig.Gain >= 0)
|
if (Gain >= 0)
|
||||||
//{
|
{
|
||||||
// SetGain(IIConfig.Gain);
|
SetGain(Gain);
|
||||||
//}
|
}
|
||||||
//SetPictureRoi(IIConfig.VelocityPara.A_Pic_X, IIConfig.VelocityPara.A_Pic_Y, IIConfig.VelocityPara.Width, IIConfig.VelocityPara.Hight);
|
//全画幅
|
||||||
|
if (!IsAllPicEnabled)
|
||||||
|
{
|
||||||
|
SetPictureRoi((int)ROIX, (int)ROIY, (int)ROIW, (int)ROIH);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//// 设置 触发延迟
|
//// 设置 触发延迟
|
||||||
//if (IIConfig.TriggerDelay > 0)
|
if (TriggerDelay > 0)
|
||||||
//{
|
{
|
||||||
// nRet = DVPCamera.dvpSetTriggerDelay(m_handle, IIConfig.TriggerDelay);
|
nRet = DVPCamera.dvpSetTriggerDelay(m_handle, TriggerDelay);
|
||||||
// if (nRet != dvpStatus.DVP_STATUS_OK)
|
if (nRet != dvpStatus.DVP_STATUS_OK)
|
||||||
// {
|
{
|
||||||
// throw new Exception("Set TriggerDelay failed!");
|
throw new Exception("Set TriggerDelay failed!");
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
//// 信号消抖
|
//// 信号消抖
|
||||||
//if (IIConfig.LineDebouncerTime > 0)
|
if (LineDebouncerTime > 0)
|
||||||
//{
|
{
|
||||||
// nRet = DVPCamera.dvpSetTriggerJitterFilter(m_handle, IIConfig.LineDebouncerTime);
|
nRet = DVPCamera.dvpSetTriggerJitterFilter(m_handle, LineDebouncerTime);
|
||||||
// if (nRet != dvpStatus.DVP_STATUS_OK)
|
if (nRet != dvpStatus.DVP_STATUS_OK)
|
||||||
// {
|
{
|
||||||
// throw new Exception($"LineDebouncerTime set failed:{nRet}");
|
throw new Exception($"LineDebouncerTime set failed:{nRet}");
|
||||||
// }
|
}
|
||||||
//}
|
}
|
||||||
|
|
||||||
//IIConfig.PropertyChanged -= IIConfig_PropertyChanged;
|
//IIConfig.PropertyChanged -= IIConfig_PropertyChanged;
|
||||||
//IIConfig.PropertyChanged += IIConfig_PropertyChanged;
|
//IIConfig.PropertyChanged += IIConfig_PropertyChanged;
|
||||||
|
Connected = true;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
|
Connected = false;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 回调函数
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="handle"></param>
|
||||||
|
/// <param name="_event"></param>
|
||||||
|
/// <param name="pContext"></param>
|
||||||
|
/// <param name="param"></param>
|
||||||
|
/// <param name="refVariant"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int cbExceptiondelegate(uint handle, dvpEvent _event, IntPtr pContext, int param, ref dvpVariant refVariant)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (_event == dvpEvent.EVENT_DISCONNECTED)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return dvpStatus.DVP_STATUS_OK.ToInt();
|
||||||
|
}
|
||||||
|
|
||||||
private void IIConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
private void IIConfig_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
|
||||||
{
|
{
|
||||||
@ -313,14 +355,7 @@ namespace DH.Devices.Camera
|
|||||||
public int ImageCallbackFunc(uint handle, dvpStreamEvent _event, IntPtr pContext, ref dvpFrame refFrame, IntPtr pBuffer)
|
public int ImageCallbackFunc(uint handle, dvpStreamEvent _event, IntPtr pContext, ref dvpFrame refFrame, IntPtr pBuffer)
|
||||||
{
|
{
|
||||||
Mat cvImage = new Mat();
|
Mat cvImage = new Mat();
|
||||||
if (this.CameraName.Equals("Cam1"))
|
|
||||||
{
|
|
||||||
Console.WriteLine( );
|
|
||||||
}
|
|
||||||
if (this.CameraName.Equals("Cam2"))
|
|
||||||
{
|
|
||||||
Console.WriteLine();
|
|
||||||
}
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -350,10 +385,39 @@ namespace DH.Devices.Camera
|
|||||||
cvImage = Mat.FromPixelData(nHeight, nWidth, MatType.CV_8UC1, pBuffer);
|
cvImage = Mat.FromPixelData(nHeight, nWidth, MatType.CV_8UC1, pBuffer);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
Mat smat = cvImage.Clone();
|
Mat smat = cvImage.Clone();
|
||||||
OnHImageOutput?.Invoke(DateTime.Now, this, smat);
|
Mat rotated = new Mat(); // 显式创建输出对象
|
||||||
|
|
||||||
|
switch (RotateImage)
|
||||||
|
{
|
||||||
|
case 90:
|
||||||
|
Cv2.Rotate(smat, rotated, RotateFlags.Rotate90Clockwise);
|
||||||
|
break;
|
||||||
|
case 180:
|
||||||
|
Cv2.Rotate(smat, rotated, RotateFlags.Rotate180);
|
||||||
|
break;
|
||||||
|
case 270:
|
||||||
|
Cv2.Rotate(smat, rotated, RotateFlags.Rotate90Counterclockwise);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
rotated = smat.Clone(); // 无旋转时保持原图
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var imageSet = new MatSet
|
||||||
|
{
|
||||||
|
|
||||||
|
_mat = rotated,
|
||||||
|
|
||||||
|
};
|
||||||
|
InitialImageSet(imageSet);
|
||||||
|
|
||||||
|
var outImgSet = CopyImageSet(imageSet);
|
||||||
|
OnHImageOutput?.Invoke(DateTime.Now, this, outImgSet);
|
||||||
|
|
||||||
|
//存图
|
||||||
|
DisplayAndSaveOriginImage(imageSet.Id, SnapshotCount);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -369,36 +433,135 @@ namespace DH.Devices.Camera
|
|||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
public void InitialImageSet(MatSet set)
|
||||||
|
{
|
||||||
|
//if (saveOption != null)
|
||||||
|
//{
|
||||||
|
// set.ImageSaveOption = saveOption.Copy();
|
||||||
|
//}
|
||||||
|
|
||||||
|
//set.IsOriginSaved = !set.ImageSaveOption.IsSaveOriginImage;
|
||||||
|
//set.IsFitSaved = !set.ImageSaveOption.IsSaveFitImage;
|
||||||
|
//set.IsAddtionalSaved = string.IsNullOrWhiteSpace(set.ImageSaveOption.AddtionalSaveType);
|
||||||
|
set.CameraId = this.CameraName;
|
||||||
|
|
||||||
|
set.ImageTime = DateTime.Now;
|
||||||
|
_imageSetList[set.Id] = set;
|
||||||
|
}
|
||||||
|
|
||||||
|
public virtual async void DisplayAndSaveOriginImage(string imgSetId, int _counter)
|
||||||
|
{
|
||||||
|
MatSet set = _imageSetList.Values.FirstOrDefault(u => u.Id == imgSetId);
|
||||||
|
|
||||||
|
if (set != null && set._mat != null)
|
||||||
|
{
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
Bitmap? showImage = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
showImage = set._mat.ToBitmap();
|
||||||
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
//释放 himage
|
||||||
|
ClearImageSet(set);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// showImage.Save("D:/test333.bmp");
|
||||||
|
// Marshal.Copy(pbyteImageBuffer, 0, (IntPtr)lAddrImage, (int)dwBufferSize);
|
||||||
|
// Bitmap saveImage = showImage?.CopyBitmap();
|
||||||
|
// saveImage.Save("d://TEST444.BMP");
|
||||||
|
// OnShowImageUpdated?.Invoke(this, showImage, imgSetId);
|
||||||
|
if (IsSavePicEnabled && showImage != null)
|
||||||
|
{
|
||||||
|
string fullname = Path.Combine(ImageSaveDirectory, $"{CameraName}_{_counter:D7}_{set.Id}.{set._imageFormat.ToString().ToLower()}");
|
||||||
|
ImageSaveAsync(fullname, showImage);
|
||||||
|
}
|
||||||
|
|
||||||
|
//释放 himage
|
||||||
|
ClearImageSet(set);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
static object _imageSetLock = new object();
|
||||||
|
public void ClearImageSet(MatSet set)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
bool flag = false;
|
||||||
|
lock (_imageSetLock)
|
||||||
|
{
|
||||||
|
flag = _imageSetList.TryRemove(set.Id, out set);
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
set.Dispose();
|
||||||
|
}
|
||||||
|
//LogAsync(DateTime.Now, $"{Name}移除图片信息{(flag ? "成功" : "失败")},当前缓存数量:{_imageSetList.Count}", "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
LogAsync(DateTime.Now, LogLevel.Exception, $"清理图片缓存异常,当前缓存数量{_imageSetList.Count},{ex.GetExceptionMessage()}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ImageSaveHelper ImageSaveHelper { get; set; } = new ImageSaveHelper();
|
||||||
|
public virtual void ImageSaveAsync(string fullName, Bitmap map)
|
||||||
|
{
|
||||||
|
if (!IsSavePicEnabled)
|
||||||
|
{
|
||||||
|
map?.Dispose();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ImageSaveSet imageSaveSet = new ImageSaveSet()
|
||||||
|
{
|
||||||
|
FullName = fullName,
|
||||||
|
SaveImage = map,
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
ImageSaveHelper.ImageSaveAsync(imageSaveSet);
|
||||||
|
}
|
||||||
public override bool CameraDisConnect()
|
public override bool CameraDisConnect()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
dvpStreamState StreamState = new dvpStreamState();
|
|
||||||
nRet = DVPCamera.dvpGetStreamState(m_handle, ref StreamState);
|
// 1. 停止采集(如果正在运行)
|
||||||
Debug.Assert(nRet == dvpStatus.DVP_STATUS_OK);
|
dvpStreamState streamState = new dvpStreamState();
|
||||||
if (StreamState == dvpStreamState.STATE_STARTED)
|
nRet = DVPCamera.dvpGetStreamState(m_handle, ref streamState);
|
||||||
|
if (streamState == dvpStreamState.STATE_STARTED)
|
||||||
{
|
{
|
||||||
// stop camera
|
// 先停止采集流
|
||||||
nRet = DVPCamera.dvpStop(m_handle);
|
nRet = DVPCamera.dvpStop(m_handle);
|
||||||
Debug.Assert(nRet == dvpStatus.DVP_STATUS_OK);
|
|
||||||
if (nRet != dvpStatus.DVP_STATUS_OK)
|
if (nRet != dvpStatus.DVP_STATUS_OK)
|
||||||
{
|
{
|
||||||
throw new Exception($"Stop grabbing failed{nRet:x8}");
|
throw new Exception($"停止采集失败,错误码:0x{nRet:X8}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 2. 设置触发源为软件触发(此时设备已停止)
|
||||||
|
nRet = DVPCamera.dvpSetTriggerState(m_handle, false);
|
||||||
|
if (nRet != dvpStatus.DVP_STATUS_OK)
|
||||||
|
{
|
||||||
|
throw new Exception($"设置软件触发失败,错误码:0x{nRet:X8}");
|
||||||
|
}
|
||||||
|
|
||||||
|
// 3. 注销事件回调
|
||||||
nRet = DVPCamera.dvpUnregisterEventCallback(m_handle, pCallBackFunc, dvpEvent.EVENT_DISCONNECTED, IntPtr.Zero);
|
nRet = DVPCamera.dvpUnregisterEventCallback(m_handle, pCallBackFunc, dvpEvent.EVENT_DISCONNECTED, IntPtr.Zero);
|
||||||
if (nRet != dvpStatus.DVP_STATUS_OK)
|
if (nRet != dvpStatus.DVP_STATUS_OK)
|
||||||
{
|
{
|
||||||
throw new Exception($"Unregister expection callback failed:{nRet}");
|
throw new Exception($"注销事件回调失败,错误码:0x{nRet:X8}");
|
||||||
}
|
}
|
||||||
|
|
||||||
// ch:关闭设备 | en:Close device
|
// 4. 关闭设备
|
||||||
nRet = DVPCamera.dvpClose(m_handle);
|
nRet = DVPCamera.dvpClose(m_handle);
|
||||||
if (nRet != dvpStatus.DVP_STATUS_OK)
|
if (nRet != dvpStatus.DVP_STATUS_OK)
|
||||||
{
|
{
|
||||||
throw new Exception($"Close device failed{nRet:x8}");
|
throw new Exception($"关闭设备失败,错误码:0x{nRet:X8}");
|
||||||
}
|
}
|
||||||
|
|
||||||
m_handle = 0;
|
m_handle = 0;
|
||||||
@ -411,6 +574,28 @@ namespace DH.Devices.Camera
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Snapshot()
|
||||||
|
{
|
||||||
|
DVPCamera.dvpTriggerFire(m_handle);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void LogAsync(LogMsg msg)
|
||||||
|
{
|
||||||
|
msg.MsgSource = CameraName;
|
||||||
|
msg.ThreadId = Thread.CurrentThread.ManagedThreadId;
|
||||||
|
|
||||||
|
//OnLog?.BeginInvoke(msg, null, null);
|
||||||
|
OnLog?.Invoke(msg);
|
||||||
|
|
||||||
|
//if (InitialConfig.IsEnableLog)
|
||||||
|
{
|
||||||
|
LoggerHelper.LogAsync(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void LogAsync(DateTime dt, LogLevel logLevel, string msg)
|
||||||
|
{
|
||||||
|
LogAsync(new LogMsg(dt, logLevel, msg));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
|
|||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using DH.Commons.Enums;
|
using DH.Commons.Enums;
|
||||||
using static MvCamCtrl.NET.MyCamera;
|
using static MvCamCtrl.NET.MyCamera;
|
||||||
using DH.Devices.Devices;
|
using DH.Commons.Base;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -368,7 +368,7 @@ namespace DH.Devices.Camera
|
|||||||
throw new NotSupportedException($"Unsupported pixel type: {pFrameInfo.enPixelType}");
|
throw new NotSupportedException($"Unsupported pixel type: {pFrameInfo.enPixelType}");
|
||||||
}
|
}
|
||||||
|
|
||||||
OnHImageOutput?.Invoke(DateTime.Now, this, cvImage);
|
//OnHImageOutput?.Invoke(DateTime.Now, this, cvImage);
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
@ -85,11 +85,15 @@ namespace DH.Devices.Motion
|
|||||||
|
|
||||||
public void NewPieces(int diskIndex, uint pieceNumber)
|
public void NewPieces(int diskIndex, uint pieceNumber)
|
||||||
{
|
{
|
||||||
_taskFactory.StartNew(() =>
|
Task.Run(() =>
|
||||||
{
|
{
|
||||||
Thread.CurrentThread.Priority = ThreadPriority.Highest;
|
try {
|
||||||
|
Thread.CurrentThread.Priority = ThreadPriority.Highest;
|
||||||
|
|
||||||
OnNewPieces?.Invoke(diskIndex, pieceNumber);
|
OnNewPieces?.Invoke(diskIndex, pieceNumber);
|
||||||
|
}
|
||||||
|
catch (Exception ex) { /* 记录异常 */ }
|
||||||
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
public void SetResetFlag(bool isReset)
|
public void SetResetFlag(bool isReset)
|
||||||
|
@ -12,10 +12,6 @@
|
|||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
|
||||||
<PackageReference Include="System.IO.Ports" Version="9.0.2" />
|
|
||||||
</ItemGroup>
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
|
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -1,82 +0,0 @@
|
|||||||
using System.IO.Ports;
|
|
||||||
using DH.Commons.Enums;
|
|
||||||
using HslCommunication;
|
|
||||||
|
|
||||||
namespace DH.Devices.PLC
|
|
||||||
{
|
|
||||||
public class PLCBase
|
|
||||||
{
|
|
||||||
/// <summary>
|
|
||||||
/// 连接状态
|
|
||||||
/// </summary>
|
|
||||||
public bool connected = false;
|
|
||||||
|
|
||||||
public string PLCName;
|
|
||||||
/// <summary>
|
|
||||||
/// 类型
|
|
||||||
/// </summary>
|
|
||||||
public EnumPLCType PLCType=EnumPLCType.信捷XD_网口;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 串口号
|
|
||||||
/// </summary>
|
|
||||||
public string portName="COM1";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 波特率
|
|
||||||
/// </summary>
|
|
||||||
public int baudRate = 9600;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 数据位
|
|
||||||
/// </summary>
|
|
||||||
public int dataBit = 8;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 停止位
|
|
||||||
/// </summary>
|
|
||||||
public StopBits stopBit = (StopBits)Enum.Parse(typeof(StopBits), "One");
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 奇偶效验位
|
|
||||||
/// </summary>
|
|
||||||
public Parity parity = (Parity)Enum.Parse(typeof(Parity), "None");
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// IP地址
|
|
||||||
/// </summary>
|
|
||||||
public string IP = "192.168.6.6";
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 端口号
|
|
||||||
/// </summary>
|
|
||||||
public int Port = 502;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 初始化
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
public virtual bool PLCConnect() { return false; }
|
|
||||||
|
|
||||||
public virtual bool PLCDisConnect() { return false; }
|
|
||||||
|
|
||||||
public virtual ushort ReadShort(string address) { return 0; }
|
|
||||||
|
|
||||||
public virtual int ReadInt(string address) { return 0; }
|
|
||||||
|
|
||||||
|
|
||||||
public virtual float ReadFloat(string address) { return 0; }
|
|
||||||
|
|
||||||
public virtual bool ReadBool(string address) { return false; }
|
|
||||||
|
|
||||||
public virtual bool WriteShort(string address, short value, bool waitForReply = true) { return false; }
|
|
||||||
|
|
||||||
public virtual bool WriteInt(string address, int value, bool waitForReply = true) { return false; }
|
|
||||||
|
|
||||||
public virtual bool WriteDInt(string address, int value, bool waitForReply = true) { return false; }
|
|
||||||
|
|
||||||
public virtual bool WriteFloat(string address, float value, bool waitForReply = true) { return false; }
|
|
||||||
|
|
||||||
public virtual bool WriteBool(string address, bool value, bool waitForReply = true) { return false; }
|
|
||||||
}
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load Diff
@ -11,6 +11,14 @@
|
|||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
|
||||||
|
<Optimize>False</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||||
|
<Optimize>False</Optimize>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -28,7 +36,6 @@
|
|||||||
|
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\DH.Commons.Devies\DH.Commons.Devies.csproj" />
|
|
||||||
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
|
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
|
||||||
<ProjectReference Include="..\DH.UI.Model.Winform\DH.UI.Model.Winform.csproj" />
|
<ProjectReference Include="..\DH.UI.Model.Winform\DH.UI.Model.Winform.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
@ -13,13 +13,13 @@ using System.Threading.Tasks;
|
|||||||
using System.Security.Cryptography.Xml;
|
using System.Security.Cryptography.Xml;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using DH.Commons.Enums;
|
using DH.Commons.Base;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
namespace DH.Devices.Vision
|
namespace DH.Devices.Vision
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 目标检测 GPU
|
/// 目标检测 GPU
|
||||||
@ -32,6 +32,10 @@ namespace DH.Devices.Vision
|
|||||||
bool res = false;
|
bool res = false;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
if (!Path.GetExtension(mLInit.ModelFile).Equals(".trt", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
throw new Exception("选择的模型不是trt格式");
|
||||||
|
}
|
||||||
Model = MLGPUEngine.InitModel(mLInit.ModelFile, 1, mLInit.Score_thre, mLInit.GPUId, 3, 8);
|
Model = MLGPUEngine.InitModel(mLInit.ModelFile, 1, mLInit.Score_thre, mLInit.GPUId, 3, 8);
|
||||||
|
|
||||||
//Model = MLEngine.InitModel(mLInit.ModelFile, 1, 0.45f, 0, 3);
|
//Model = MLEngine.InitModel(mLInit.ModelFile, 1, 0.45f, 0, 3);
|
||||||
@ -104,18 +108,18 @@ namespace DH.Devices.Vision
|
|||||||
// json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}";
|
// json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}";
|
||||||
//
|
//
|
||||||
Console.WriteLine("检测结果JSON:" + json);
|
Console.WriteLine("检测结果JSON:" + json);
|
||||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
|
|
||||||
HYoloResult detResult = JsonConvert.DeserializeObject<HYoloResult>(json);
|
HYoloResult detResult = JsonConvert.DeserializeObject<HYoloResult>(json);
|
||||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
|
|
||||||
if (detResult == null)
|
if (detResult == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int iNum = detResult.HYolo.Count;
|
int iNum = detResult.HYolo.Count;
|
||||||
#pragma warning disable CS0219 // 变量已被赋值,但从未使用过它的值
|
|
||||||
int IokNum = 0;
|
int IokNum = 0;
|
||||||
#pragma warning restore CS0219 // 变量已被赋值,但从未使用过它的值
|
|
||||||
for (int ix = 0; ix < iNum; ix++)
|
for (int ix = 0; ix < iNum; ix++)
|
||||||
{
|
{
|
||||||
var det = detResult.HYolo[ix];
|
var det = detResult.HYolo[ix];
|
||||||
@ -145,7 +149,6 @@ namespace DH.Devices.Vision
|
|||||||
Mat originMat = new Mat();
|
Mat originMat = new Mat();
|
||||||
Mat detectMat = new Mat();
|
Mat detectMat = new Mat();
|
||||||
|
|
||||||
#pragma warning disable CS0168 // 声明了变量,但从未使用过
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (req.mImage == null)
|
if (req.mImage == null)
|
||||||
|
@ -12,7 +12,7 @@ using System.Threading;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using DH.Commons.Enums;
|
using DH.Commons.Base;
|
||||||
|
|
||||||
|
|
||||||
namespace DH.Devices.Vision
|
namespace DH.Devices.Vision
|
||||||
|
@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
|||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using System.Xml;
|
using System.Xml;
|
||||||
using DH.Commons.Enums;
|
using DH.Commons.Base;
|
||||||
|
|
||||||
|
|
||||||
namespace DH.Devices.Vision
|
namespace DH.Devices.Vision
|
||||||
@ -136,9 +136,8 @@ namespace DH.Devices.Vision
|
|||||||
// json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}";
|
// json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}";
|
||||||
//
|
//
|
||||||
Console.WriteLine("检测结果JSON:" + json);
|
Console.WriteLine("检测结果JSON:" + json);
|
||||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
|
|
||||||
SegResult detResult = JsonConvert.DeserializeObject<SegResult>(json);
|
SegResult detResult = JsonConvert.DeserializeObject<SegResult>(json);
|
||||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
|
|
||||||
if (detResult == null)
|
if (detResult == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -176,7 +175,6 @@ namespace DH.Devices.Vision
|
|||||||
MLResult mlResult = new MLResult();
|
MLResult mlResult = new MLResult();
|
||||||
Mat originMat=new Mat() ;
|
Mat originMat=new Mat() ;
|
||||||
Mat detectMat= new Mat();
|
Mat detectMat= new Mat();
|
||||||
#pragma warning disable CS0168 // 声明了变量,但从未使用过
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (req.mImage == null)
|
if (req.mImage == null)
|
||||||
@ -266,25 +264,24 @@ namespace DH.Devices.Vision
|
|||||||
// 释放 Mat 资源
|
// 释放 Mat 资源
|
||||||
if (detectMat != null)
|
if (detectMat != null)
|
||||||
{
|
{
|
||||||
detectMat.Dispose();
|
|
||||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
|
|
||||||
detectMat = null;
|
detectMat = null;
|
||||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (originMat != null)
|
if (originMat != null)
|
||||||
{
|
{
|
||||||
originMat.Dispose();
|
originMat.Dispose();
|
||||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
|
|
||||||
originMat = null;
|
originMat = null;
|
||||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// GC.Collect();
|
// GC.Collect();
|
||||||
}
|
}
|
||||||
#pragma warning restore CS0168 // 声明了变量,但从未使用过
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
|||||||
using AntdUI;
|
using AntdUI;
|
||||||
|
using DH.Commons.Base;
|
||||||
using DH.Commons.Enums;
|
using DH.Commons.Enums;
|
||||||
using OpenCvSharp;
|
using OpenCvSharp;
|
||||||
using System;
|
using System;
|
||||||
@ -17,7 +17,7 @@ namespace DH.Devices.Vision
|
|||||||
public Mat ColorLut { get; set; }
|
public Mat ColorLut { get; set; }
|
||||||
public byte[] ColorMap { get; set; }
|
public byte[] ColorMap { get; set; }
|
||||||
|
|
||||||
public MLModelType ModelType { get; set; }
|
public ModelType ModelType { get; set; }
|
||||||
|
|
||||||
public IntPtr Model { get; set; }
|
public IntPtr Model { get; set; }
|
||||||
|
|
||||||
|
879
DH.RBAC/AccountForm.Designer.cs
generated
Normal file
879
DH.RBAC/AccountForm.Designer.cs
generated
Normal file
@ -0,0 +1,879 @@
|
|||||||
|
namespace DH.RBAC
|
||||||
|
{
|
||||||
|
partial class AccountForm
|
||||||
|
{
|
||||||
|
/// <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(AccountForm));
|
||||||
|
this.uiPanel1 = new Sunny.UI.UIPanel();
|
||||||
|
this.titlePanel = new System.Windows.Forms.Panel();
|
||||||
|
this.uiLabel15 = new Sunny.UI.UILabel();
|
||||||
|
this.btnClose = new Sunny.UI.UISymbolLabel();
|
||||||
|
this.panel1 = new System.Windows.Forms.Panel();
|
||||||
|
this.lblCurrentUser = new System.Windows.Forms.Label();
|
||||||
|
this.imageAvator = new System.Windows.Forms.PictureBox();
|
||||||
|
this.uiTabControl1 = new Sunny.UI.UITabControl();
|
||||||
|
this.tabPage1 = new System.Windows.Forms.TabPage();
|
||||||
|
this.txtBirthday = new Sunny.UI.UIDatePicker();
|
||||||
|
this.btnSave = new Sunny.UI.UIButton();
|
||||||
|
this.txtSignature = new Sunny.UI.UITextBox();
|
||||||
|
this.lblSignature = new Sunny.UI.UILabel();
|
||||||
|
this.txtAddress = new Sunny.UI.UITextBox();
|
||||||
|
this.lblAddress = new Sunny.UI.UILabel();
|
||||||
|
this.txtTel = new Sunny.UI.UITextBox();
|
||||||
|
this.lblTel = new Sunny.UI.UILabel();
|
||||||
|
this.txtEmail = new Sunny.UI.UITextBox();
|
||||||
|
this.lblEmail = new Sunny.UI.UILabel();
|
||||||
|
this.lblBirthday = new Sunny.UI.UILabel();
|
||||||
|
this.rdFemale = new Sunny.UI.UIRadioButton();
|
||||||
|
this.rdMale = new Sunny.UI.UIRadioButton();
|
||||||
|
this.txtNickName = new Sunny.UI.UITextBox();
|
||||||
|
this.lblGender = new Sunny.UI.UILabel();
|
||||||
|
this.lblNickName = new Sunny.UI.UILabel();
|
||||||
|
this.txtName = new Sunny.UI.UITextBox();
|
||||||
|
this.lblName = new Sunny.UI.UILabel();
|
||||||
|
this.txtAccount = new Sunny.UI.UITextBox();
|
||||||
|
this.lblAccount = new Sunny.UI.UILabel();
|
||||||
|
this.tabPage2 = new System.Windows.Forms.TabPage();
|
||||||
|
this.btnSelectAvator = new Sunny.UI.UIButton();
|
||||||
|
this.uiLabel10 = new Sunny.UI.UILabel();
|
||||||
|
this.tabPage3 = new System.Windows.Forms.TabPage();
|
||||||
|
this.btnReset = new Sunny.UI.UIButton();
|
||||||
|
this.btnChangePassword = new Sunny.UI.UIButton();
|
||||||
|
this.txtComfirmPassword = new Sunny.UI.UITextBox();
|
||||||
|
this.txtNewPassword = new Sunny.UI.UITextBox();
|
||||||
|
this.lblComfirmPassword = new Sunny.UI.UILabel();
|
||||||
|
this.lblNewPassword = new Sunny.UI.UILabel();
|
||||||
|
this.txtOldPassword = new Sunny.UI.UITextBox();
|
||||||
|
this.lblOldPassword = new Sunny.UI.UILabel();
|
||||||
|
this.uiLabel11 = new Sunny.UI.UILabel();
|
||||||
|
this.uiPanel1.SuspendLayout();
|
||||||
|
this.titlePanel.SuspendLayout();
|
||||||
|
this.panel1.SuspendLayout();
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.imageAvator)).BeginInit();
|
||||||
|
this.uiTabControl1.SuspendLayout();
|
||||||
|
this.tabPage1.SuspendLayout();
|
||||||
|
this.tabPage2.SuspendLayout();
|
||||||
|
this.tabPage3.SuspendLayout();
|
||||||
|
this.SuspendLayout();
|
||||||
|
//
|
||||||
|
// uiPanel1
|
||||||
|
//
|
||||||
|
this.uiPanel1.Controls.Add(this.titlePanel);
|
||||||
|
this.uiPanel1.Controls.Add(this.panel1);
|
||||||
|
this.uiPanel1.Controls.Add(this.uiTabControl1);
|
||||||
|
this.uiPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.uiPanel1.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(241)))), ((int)(((byte)(243)))));
|
||||||
|
this.uiPanel1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.uiPanel1.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.uiPanel1.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||||
|
this.uiPanel1.MinimumSize = new System.Drawing.Size(1, 1);
|
||||||
|
this.uiPanel1.Name = "uiPanel1";
|
||||||
|
this.uiPanel1.RectColor = System.Drawing.Color.Silver;
|
||||||
|
this.uiPanel1.Size = new System.Drawing.Size(1031, 558);
|
||||||
|
this.uiPanel1.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.uiPanel1.StyleCustomMode = true;
|
||||||
|
this.uiPanel1.TabIndex = 6;
|
||||||
|
this.uiPanel1.Text = null;
|
||||||
|
this.uiPanel1.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
//
|
||||||
|
// titlePanel
|
||||||
|
//
|
||||||
|
this.titlePanel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.titlePanel.Controls.Add(this.uiLabel15);
|
||||||
|
this.titlePanel.Controls.Add(this.btnClose);
|
||||||
|
this.titlePanel.Location = new System.Drawing.Point(0, -1);
|
||||||
|
this.titlePanel.Name = "titlePanel";
|
||||||
|
this.titlePanel.Size = new System.Drawing.Size(1031, 43);
|
||||||
|
this.titlePanel.TabIndex = 7;
|
||||||
|
this.titlePanel.MouseDown += new System.Windows.Forms.MouseEventHandler(this.titlePanel_MouseDown);
|
||||||
|
this.titlePanel.MouseMove += new System.Windows.Forms.MouseEventHandler(this.titlePanel_MouseMove);
|
||||||
|
//
|
||||||
|
// uiLabel15
|
||||||
|
//
|
||||||
|
this.uiLabel15.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.uiLabel15.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.uiLabel15.Location = new System.Drawing.Point(0, 0);
|
||||||
|
this.uiLabel15.Name = "uiLabel15";
|
||||||
|
this.uiLabel15.Size = new System.Drawing.Size(986, 43);
|
||||||
|
this.uiLabel15.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.uiLabel15.TabIndex = 1;
|
||||||
|
this.uiLabel15.Text = "用户账号管理";
|
||||||
|
this.uiLabel15.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
this.uiLabel15.MouseDown += new System.Windows.Forms.MouseEventHandler(this.titlePanel_MouseDown);
|
||||||
|
this.uiLabel15.MouseMove += new System.Windows.Forms.MouseEventHandler(this.titlePanel_MouseMove);
|
||||||
|
//
|
||||||
|
// btnClose
|
||||||
|
//
|
||||||
|
this.btnClose.Dock = System.Windows.Forms.DockStyle.Right;
|
||||||
|
this.btnClose.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.btnClose.Location = new System.Drawing.Point(986, 0);
|
||||||
|
this.btnClose.MinimumSize = new System.Drawing.Size(1, 1);
|
||||||
|
this.btnClose.Name = "btnClose";
|
||||||
|
this.btnClose.Padding = new System.Windows.Forms.Padding(64, 0, 0, 0);
|
||||||
|
this.btnClose.Size = new System.Drawing.Size(45, 43);
|
||||||
|
this.btnClose.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.btnClose.Symbol = 77;
|
||||||
|
this.btnClose.SymbolSize = 60;
|
||||||
|
this.btnClose.TabIndex = 0;
|
||||||
|
this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
|
||||||
|
this.btnClose.MouseEnter += new System.EventHandler(this.btnClose_MouseEnter);
|
||||||
|
this.btnClose.MouseLeave += new System.EventHandler(this.btnClose_MouseLeave);
|
||||||
|
//
|
||||||
|
// panel1
|
||||||
|
//
|
||||||
|
this.panel1.BackColor = System.Drawing.Color.White;
|
||||||
|
this.panel1.Controls.Add(this.lblCurrentUser);
|
||||||
|
this.panel1.Controls.Add(this.imageAvator);
|
||||||
|
this.panel1.Location = new System.Drawing.Point(12, 56);
|
||||||
|
this.panel1.Name = "panel1";
|
||||||
|
this.panel1.Size = new System.Drawing.Size(241, 218);
|
||||||
|
this.panel1.TabIndex = 6;
|
||||||
|
//
|
||||||
|
// lblCurrentUser
|
||||||
|
//
|
||||||
|
this.lblCurrentUser.Location = new System.Drawing.Point(3, 176);
|
||||||
|
this.lblCurrentUser.Name = "lblCurrentUser";
|
||||||
|
this.lblCurrentUser.Size = new System.Drawing.Size(235, 27);
|
||||||
|
this.lblCurrentUser.TabIndex = 4;
|
||||||
|
this.lblCurrentUser.Text = "admin@管理员";
|
||||||
|
this.lblCurrentUser.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||||
|
//
|
||||||
|
// imageAvator
|
||||||
|
//
|
||||||
|
this.imageAvator.Image = global:: DH.RBAC.Properties.Resources.avatar;
|
||||||
|
this.imageAvator.Location = new System.Drawing.Point(49, 27);
|
||||||
|
this.imageAvator.Name = "imageAvator";
|
||||||
|
this.imageAvator.Size = new System.Drawing.Size(139, 136);
|
||||||
|
this.imageAvator.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage;
|
||||||
|
this.imageAvator.TabIndex = 3;
|
||||||
|
this.imageAvator.TabStop = false;
|
||||||
|
//
|
||||||
|
// uiTabControl1
|
||||||
|
//
|
||||||
|
this.uiTabControl1.Controls.Add(this.tabPage1);
|
||||||
|
this.uiTabControl1.Controls.Add(this.tabPage2);
|
||||||
|
this.uiTabControl1.Controls.Add(this.tabPage3);
|
||||||
|
this.uiTabControl1.DrawMode = System.Windows.Forms.TabDrawMode.OwnerDrawFixed;
|
||||||
|
this.uiTabControl1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.uiTabControl1.ItemSize = new System.Drawing.Size(150, 40);
|
||||||
|
this.uiTabControl1.Location = new System.Drawing.Point(275, 56);
|
||||||
|
this.uiTabControl1.MainPage = "";
|
||||||
|
this.uiTabControl1.MenuStyle = Sunny.UI.UIMenuStyle.Custom;
|
||||||
|
this.uiTabControl1.Name = "uiTabControl1";
|
||||||
|
this.uiTabControl1.SelectedIndex = 0;
|
||||||
|
this.uiTabControl1.Size = new System.Drawing.Size(734, 490);
|
||||||
|
this.uiTabControl1.SizeMode = System.Windows.Forms.TabSizeMode.Fixed;
|
||||||
|
this.uiTabControl1.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.uiTabControl1.TabBackColor = System.Drawing.Color.White;
|
||||||
|
this.uiTabControl1.TabIndex = 5;
|
||||||
|
this.uiTabControl1.TabSelectedColor = System.Drawing.Color.White;
|
||||||
|
this.uiTabControl1.TabUnSelectedForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(73)))), ((int)(((byte)(82)))), ((int)(((byte)(91)))));
|
||||||
|
//
|
||||||
|
// tabPage1
|
||||||
|
//
|
||||||
|
this.tabPage1.BackColor = System.Drawing.Color.White;
|
||||||
|
this.tabPage1.Controls.Add(this.txtBirthday);
|
||||||
|
this.tabPage1.Controls.Add(this.btnSave);
|
||||||
|
this.tabPage1.Controls.Add(this.txtSignature);
|
||||||
|
this.tabPage1.Controls.Add(this.lblSignature);
|
||||||
|
this.tabPage1.Controls.Add(this.txtAddress);
|
||||||
|
this.tabPage1.Controls.Add(this.lblAddress);
|
||||||
|
this.tabPage1.Controls.Add(this.txtTel);
|
||||||
|
this.tabPage1.Controls.Add(this.lblTel);
|
||||||
|
this.tabPage1.Controls.Add(this.txtEmail);
|
||||||
|
this.tabPage1.Controls.Add(this.lblEmail);
|
||||||
|
this.tabPage1.Controls.Add(this.lblBirthday);
|
||||||
|
this.tabPage1.Controls.Add(this.rdFemale);
|
||||||
|
this.tabPage1.Controls.Add(this.rdMale);
|
||||||
|
this.tabPage1.Controls.Add(this.txtNickName);
|
||||||
|
this.tabPage1.Controls.Add(this.lblGender);
|
||||||
|
this.tabPage1.Controls.Add(this.lblNickName);
|
||||||
|
this.tabPage1.Controls.Add(this.txtName);
|
||||||
|
this.tabPage1.Controls.Add(this.lblName);
|
||||||
|
this.tabPage1.Controls.Add(this.txtAccount);
|
||||||
|
this.tabPage1.Controls.Add(this.lblAccount);
|
||||||
|
this.tabPage1.Location = new System.Drawing.Point(0, 40);
|
||||||
|
this.tabPage1.Name = "tabPage1";
|
||||||
|
this.tabPage1.Size = new System.Drawing.Size(734, 450);
|
||||||
|
this.tabPage1.TabIndex = 0;
|
||||||
|
this.tabPage1.Text = "资料";
|
||||||
|
//
|
||||||
|
// txtBirthday
|
||||||
|
//
|
||||||
|
this.txtBirthday.FillColor = System.Drawing.Color.White;
|
||||||
|
this.txtBirthday.FillColor2 = System.Drawing.Color.White;
|
||||||
|
this.txtBirthday.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.txtBirthday.Location = new System.Drawing.Point(117, 139);
|
||||||
|
this.txtBirthday.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||||
|
this.txtBirthday.MaxLength = 10;
|
||||||
|
this.txtBirthday.MinimumSize = new System.Drawing.Size(63, 0);
|
||||||
|
this.txtBirthday.Name = "txtBirthday";
|
||||||
|
this.txtBirthday.Padding = new System.Windows.Forms.Padding(0, 0, 30, 2);
|
||||||
|
this.txtBirthday.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtBirthday.Size = new System.Drawing.Size(188, 36);
|
||||||
|
|
||||||
|
this.txtBirthday.StyleCustomMode = true;
|
||||||
|
this.txtBirthday.SymbolDropDown = 61555;
|
||||||
|
this.txtBirthday.SymbolNormal = 61555;
|
||||||
|
this.txtBirthday.TabIndex = 20;
|
||||||
|
this.txtBirthday.Text = "2021-12-29";
|
||||||
|
this.txtBirthday.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
this.txtBirthday.Value = new System.DateTime(2021, 12, 29, 0, 0, 0, 0);
|
||||||
|
//
|
||||||
|
// btnSave
|
||||||
|
//
|
||||||
|
this.btnSave.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.btnSave.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.btnSave.Location = new System.Drawing.Point(117, 379);
|
||||||
|
this.btnSave.MinimumSize = new System.Drawing.Size(1, 1);
|
||||||
|
this.btnSave.Name = "btnSave";
|
||||||
|
this.btnSave.Size = new System.Drawing.Size(125, 44);
|
||||||
|
this.btnSave.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.btnSave.TabIndex = 19;
|
||||||
|
this.btnSave.Text = "保存";
|
||||||
|
this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
|
||||||
|
//
|
||||||
|
// txtSignature
|
||||||
|
//
|
||||||
|
this.txtSignature.ButtonFillColor = System.Drawing.Color.White;
|
||||||
|
this.txtSignature.ButtonFillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtSignature.ButtonFillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtSignature.ButtonForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(96)))), ((int)(((byte)(98)))), ((int)(((byte)(102)))));
|
||||||
|
this.txtSignature.ButtonForeHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtSignature.ButtonForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(131)))), ((int)(((byte)(229)))));
|
||||||
|
this.txtSignature.ButtonRectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtSignature.ButtonRectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(222)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtSignature.ButtonSymbol = 61761;
|
||||||
|
this.txtSignature.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||||
|
this.txtSignature.FillColor2 = System.Drawing.Color.White;
|
||||||
|
this.txtSignature.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.txtSignature.Location = new System.Drawing.Point(117, 252);
|
||||||
|
this.txtSignature.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||||
|
this.txtSignature.Maximum = 2147483647D;
|
||||||
|
this.txtSignature.MaxLength = 128;
|
||||||
|
this.txtSignature.Minimum = -2147483648D;
|
||||||
|
this.txtSignature.MinimumSize = new System.Drawing.Size(1, 16);
|
||||||
|
this.txtSignature.Multiline = true;
|
||||||
|
this.txtSignature.Name = "txtSignature";
|
||||||
|
this.txtSignature.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtSignature.Size = new System.Drawing.Size(581, 103);
|
||||||
|
|
||||||
|
this.txtSignature.StyleCustomMode = true;
|
||||||
|
this.txtSignature.TabIndex = 18;
|
||||||
|
this.txtSignature.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// lblSignature
|
||||||
|
//
|
||||||
|
this.lblSignature.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.lblSignature.Location = new System.Drawing.Point(3, 252);
|
||||||
|
this.lblSignature.Name = "lblSignature";
|
||||||
|
this.lblSignature.Size = new System.Drawing.Size(107, 29);
|
||||||
|
this.lblSignature.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.lblSignature.TabIndex = 17;
|
||||||
|
this.lblSignature.Text = "个性签名";
|
||||||
|
this.lblSignature.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||||
|
//
|
||||||
|
// txtAddress
|
||||||
|
//
|
||||||
|
this.txtAddress.ButtonFillColor = System.Drawing.Color.White;
|
||||||
|
this.txtAddress.ButtonFillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtAddress.ButtonFillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtAddress.ButtonForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(96)))), ((int)(((byte)(98)))), ((int)(((byte)(102)))));
|
||||||
|
this.txtAddress.ButtonForeHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtAddress.ButtonForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(131)))), ((int)(((byte)(229)))));
|
||||||
|
this.txtAddress.ButtonRectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtAddress.ButtonRectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(222)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtAddress.ButtonSymbol = 61761;
|
||||||
|
this.txtAddress.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||||
|
this.txtAddress.FillColor2 = System.Drawing.Color.White;
|
||||||
|
this.txtAddress.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.txtAddress.Location = new System.Drawing.Point(429, 191);
|
||||||
|
this.txtAddress.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||||
|
this.txtAddress.Maximum = 2147483647D;
|
||||||
|
this.txtAddress.MaxLength = 128;
|
||||||
|
this.txtAddress.Minimum = -2147483648D;
|
||||||
|
this.txtAddress.MinimumSize = new System.Drawing.Size(1, 16);
|
||||||
|
this.txtAddress.Name = "txtAddress";
|
||||||
|
this.txtAddress.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtAddress.Size = new System.Drawing.Size(269, 42);
|
||||||
|
|
||||||
|
this.txtAddress.StyleCustomMode = true;
|
||||||
|
this.txtAddress.TabIndex = 16;
|
||||||
|
this.txtAddress.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// lblAddress
|
||||||
|
//
|
||||||
|
this.lblAddress.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.lblAddress.Location = new System.Drawing.Point(312, 198);
|
||||||
|
this.lblAddress.Name = "lblAddress";
|
||||||
|
this.lblAddress.Size = new System.Drawing.Size(110, 29);
|
||||||
|
this.lblAddress.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.lblAddress.TabIndex = 15;
|
||||||
|
this.lblAddress.Text = "联系地址";
|
||||||
|
this.lblAddress.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||||
|
//
|
||||||
|
// txtTel
|
||||||
|
//
|
||||||
|
this.txtTel.ButtonFillColor = System.Drawing.Color.White;
|
||||||
|
this.txtTel.ButtonFillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtTel.ButtonFillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtTel.ButtonForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(96)))), ((int)(((byte)(98)))), ((int)(((byte)(102)))));
|
||||||
|
this.txtTel.ButtonForeHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtTel.ButtonForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(131)))), ((int)(((byte)(229)))));
|
||||||
|
this.txtTel.ButtonRectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtTel.ButtonRectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(222)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtTel.ButtonSymbol = 61761;
|
||||||
|
this.txtTel.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||||
|
this.txtTel.FillColor2 = System.Drawing.Color.White;
|
||||||
|
this.txtTel.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.txtTel.Location = new System.Drawing.Point(117, 191);
|
||||||
|
this.txtTel.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||||
|
this.txtTel.Maximum = 2147483647D;
|
||||||
|
this.txtTel.MaxLength = 20;
|
||||||
|
this.txtTel.Minimum = -2147483648D;
|
||||||
|
this.txtTel.MinimumSize = new System.Drawing.Size(1, 16);
|
||||||
|
this.txtTel.Name = "txtTel";
|
||||||
|
this.txtTel.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtTel.Size = new System.Drawing.Size(188, 42);
|
||||||
|
|
||||||
|
this.txtTel.StyleCustomMode = true;
|
||||||
|
this.txtTel.TabIndex = 14;
|
||||||
|
this.txtTel.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// lblTel
|
||||||
|
//
|
||||||
|
this.lblTel.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.lblTel.Location = new System.Drawing.Point(3, 198);
|
||||||
|
this.lblTel.Name = "lblTel";
|
||||||
|
this.lblTel.Size = new System.Drawing.Size(107, 29);
|
||||||
|
this.lblTel.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.lblTel.TabIndex = 13;
|
||||||
|
this.lblTel.Text = "移动电话";
|
||||||
|
this.lblTel.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||||
|
//
|
||||||
|
// txtEmail
|
||||||
|
//
|
||||||
|
this.txtEmail.ButtonFillColor = System.Drawing.Color.White;
|
||||||
|
this.txtEmail.ButtonFillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtEmail.ButtonFillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtEmail.ButtonForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(96)))), ((int)(((byte)(98)))), ((int)(((byte)(102)))));
|
||||||
|
this.txtEmail.ButtonForeHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtEmail.ButtonForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(131)))), ((int)(((byte)(229)))));
|
||||||
|
this.txtEmail.ButtonRectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtEmail.ButtonRectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(222)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtEmail.ButtonSymbol = 61761;
|
||||||
|
this.txtEmail.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||||
|
this.txtEmail.FillColor2 = System.Drawing.Color.White;
|
||||||
|
this.txtEmail.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.txtEmail.Location = new System.Drawing.Point(429, 136);
|
||||||
|
this.txtEmail.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||||
|
this.txtEmail.Maximum = 2147483647D;
|
||||||
|
this.txtEmail.MaxLength = 60;
|
||||||
|
this.txtEmail.Minimum = -2147483648D;
|
||||||
|
this.txtEmail.MinimumSize = new System.Drawing.Size(1, 16);
|
||||||
|
this.txtEmail.Name = "txtEmail";
|
||||||
|
this.txtEmail.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtEmail.Size = new System.Drawing.Size(269, 42);
|
||||||
|
|
||||||
|
this.txtEmail.StyleCustomMode = true;
|
||||||
|
this.txtEmail.TabIndex = 12;
|
||||||
|
this.txtEmail.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// lblEmail
|
||||||
|
//
|
||||||
|
this.lblEmail.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.lblEmail.Location = new System.Drawing.Point(357, 143);
|
||||||
|
this.lblEmail.Name = "lblEmail";
|
||||||
|
this.lblEmail.Size = new System.Drawing.Size(65, 29);
|
||||||
|
this.lblEmail.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.lblEmail.TabIndex = 11;
|
||||||
|
this.lblEmail.Text = "邮箱";
|
||||||
|
this.lblEmail.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||||
|
//
|
||||||
|
// lblBirthday
|
||||||
|
//
|
||||||
|
this.lblBirthday.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.lblBirthday.Location = new System.Drawing.Point(3, 143);
|
||||||
|
this.lblBirthday.Name = "lblBirthday";
|
||||||
|
this.lblBirthday.Size = new System.Drawing.Size(107, 29);
|
||||||
|
this.lblBirthday.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.lblBirthday.TabIndex = 9;
|
||||||
|
this.lblBirthday.Text = "出生日期";
|
||||||
|
this.lblBirthday.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||||
|
//
|
||||||
|
// rdFemale
|
||||||
|
//
|
||||||
|
this.rdFemale.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.rdFemale.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.rdFemale.Location = new System.Drawing.Point(501, 88);
|
||||||
|
this.rdFemale.MinimumSize = new System.Drawing.Size(1, 1);
|
||||||
|
this.rdFemale.Name = "rdFemale";
|
||||||
|
this.rdFemale.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0);
|
||||||
|
this.rdFemale.Size = new System.Drawing.Size(57, 36);
|
||||||
|
this.rdFemale.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.rdFemale.TabIndex = 8;
|
||||||
|
this.rdFemale.Text = "女";
|
||||||
|
//
|
||||||
|
// rdMale
|
||||||
|
//
|
||||||
|
this.rdMale.Checked = true;
|
||||||
|
this.rdMale.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.rdMale.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.rdMale.Location = new System.Drawing.Point(433, 88);
|
||||||
|
this.rdMale.MinimumSize = new System.Drawing.Size(1, 1);
|
||||||
|
this.rdMale.Name = "rdMale";
|
||||||
|
this.rdMale.Padding = new System.Windows.Forms.Padding(22, 0, 0, 0);
|
||||||
|
this.rdMale.Size = new System.Drawing.Size(57, 36);
|
||||||
|
this.rdMale.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.rdMale.TabIndex = 7;
|
||||||
|
this.rdMale.Text = "男";
|
||||||
|
//
|
||||||
|
// txtNickName
|
||||||
|
//
|
||||||
|
this.txtNickName.ButtonFillColor = System.Drawing.Color.White;
|
||||||
|
this.txtNickName.ButtonFillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtNickName.ButtonFillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtNickName.ButtonForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(96)))), ((int)(((byte)(98)))), ((int)(((byte)(102)))));
|
||||||
|
this.txtNickName.ButtonForeHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtNickName.ButtonForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(131)))), ((int)(((byte)(229)))));
|
||||||
|
this.txtNickName.ButtonRectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtNickName.ButtonRectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(222)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtNickName.ButtonSymbol = 61761;
|
||||||
|
this.txtNickName.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||||
|
this.txtNickName.FillColor2 = System.Drawing.Color.White;
|
||||||
|
this.txtNickName.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.txtNickName.Location = new System.Drawing.Point(429, 32);
|
||||||
|
this.txtNickName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||||
|
this.txtNickName.Maximum = 2147483647D;
|
||||||
|
this.txtNickName.MaxLength = 20;
|
||||||
|
this.txtNickName.Minimum = -2147483648D;
|
||||||
|
this.txtNickName.MinimumSize = new System.Drawing.Size(1, 16);
|
||||||
|
this.txtNickName.Name = "txtNickName";
|
||||||
|
this.txtNickName.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtNickName.Size = new System.Drawing.Size(269, 42);
|
||||||
|
|
||||||
|
this.txtNickName.StyleCustomMode = true;
|
||||||
|
this.txtNickName.TabIndex = 3;
|
||||||
|
this.txtNickName.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// lblGender
|
||||||
|
//
|
||||||
|
this.lblGender.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.lblGender.Location = new System.Drawing.Point(357, 91);
|
||||||
|
this.lblGender.Name = "lblGender";
|
||||||
|
this.lblGender.Size = new System.Drawing.Size(65, 29);
|
||||||
|
this.lblGender.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.lblGender.TabIndex = 6;
|
||||||
|
this.lblGender.Text = "性别";
|
||||||
|
this.lblGender.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||||
|
//
|
||||||
|
// lblNickName
|
||||||
|
//
|
||||||
|
this.lblNickName.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.lblNickName.Location = new System.Drawing.Point(357, 39);
|
||||||
|
this.lblNickName.Name = "lblNickName";
|
||||||
|
this.lblNickName.Size = new System.Drawing.Size(65, 29);
|
||||||
|
this.lblNickName.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.lblNickName.TabIndex = 2;
|
||||||
|
this.lblNickName.Text = "昵称";
|
||||||
|
this.lblNickName.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||||
|
//
|
||||||
|
// txtName
|
||||||
|
//
|
||||||
|
this.txtName.ButtonFillColor = System.Drawing.Color.White;
|
||||||
|
this.txtName.ButtonFillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtName.ButtonFillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtName.ButtonForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(96)))), ((int)(((byte)(98)))), ((int)(((byte)(102)))));
|
||||||
|
this.txtName.ButtonForeHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtName.ButtonForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(131)))), ((int)(((byte)(229)))));
|
||||||
|
this.txtName.ButtonRectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtName.ButtonRectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(222)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtName.ButtonSymbol = 61761;
|
||||||
|
this.txtName.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||||
|
this.txtName.FillColor2 = System.Drawing.Color.White;
|
||||||
|
this.txtName.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.txtName.Location = new System.Drawing.Point(117, 84);
|
||||||
|
this.txtName.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||||
|
this.txtName.Maximum = 2147483647D;
|
||||||
|
this.txtName.MaxLength = 20;
|
||||||
|
this.txtName.Minimum = -2147483648D;
|
||||||
|
this.txtName.MinimumSize = new System.Drawing.Size(1, 16);
|
||||||
|
this.txtName.Name = "txtName";
|
||||||
|
this.txtName.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtName.Size = new System.Drawing.Size(188, 42);
|
||||||
|
|
||||||
|
this.txtName.StyleCustomMode = true;
|
||||||
|
this.txtName.TabIndex = 5;
|
||||||
|
this.txtName.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// lblName
|
||||||
|
//
|
||||||
|
this.lblName.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.lblName.Location = new System.Drawing.Point(45, 91);
|
||||||
|
this.lblName.Name = "lblName";
|
||||||
|
this.lblName.Size = new System.Drawing.Size(65, 29);
|
||||||
|
this.lblName.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.lblName.TabIndex = 4;
|
||||||
|
this.lblName.Text = "姓名";
|
||||||
|
this.lblName.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||||
|
//
|
||||||
|
// txtAccount
|
||||||
|
//
|
||||||
|
this.txtAccount.ButtonFillColor = System.Drawing.Color.White;
|
||||||
|
this.txtAccount.ButtonFillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtAccount.ButtonFillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtAccount.ButtonForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(96)))), ((int)(((byte)(98)))), ((int)(((byte)(102)))));
|
||||||
|
this.txtAccount.ButtonForeHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtAccount.ButtonForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(131)))), ((int)(((byte)(229)))));
|
||||||
|
this.txtAccount.ButtonRectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtAccount.ButtonRectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(222)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtAccount.ButtonSymbol = 61761;
|
||||||
|
this.txtAccount.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||||
|
this.txtAccount.Enabled = false;
|
||||||
|
this.txtAccount.FillColor2 = System.Drawing.Color.White;
|
||||||
|
this.txtAccount.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.txtAccount.Location = new System.Drawing.Point(117, 32);
|
||||||
|
this.txtAccount.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||||
|
this.txtAccount.Maximum = 2147483647D;
|
||||||
|
this.txtAccount.MaxLength = 20;
|
||||||
|
this.txtAccount.Minimum = -2147483648D;
|
||||||
|
this.txtAccount.MinimumSize = new System.Drawing.Size(1, 16);
|
||||||
|
this.txtAccount.Name = "txtAccount";
|
||||||
|
this.txtAccount.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtAccount.Size = new System.Drawing.Size(188, 42);
|
||||||
|
|
||||||
|
this.txtAccount.StyleCustomMode = true;
|
||||||
|
this.txtAccount.TabIndex = 1;
|
||||||
|
this.txtAccount.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// lblAccount
|
||||||
|
//
|
||||||
|
this.lblAccount.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.lblAccount.Location = new System.Drawing.Point(45, 39);
|
||||||
|
this.lblAccount.Name = "lblAccount";
|
||||||
|
this.lblAccount.Size = new System.Drawing.Size(65, 29);
|
||||||
|
this.lblAccount.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.lblAccount.TabIndex = 0;
|
||||||
|
this.lblAccount.Text = "账号";
|
||||||
|
this.lblAccount.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||||
|
//
|
||||||
|
// tabPage2
|
||||||
|
//
|
||||||
|
this.tabPage2.BackColor = System.Drawing.Color.White;
|
||||||
|
this.tabPage2.Controls.Add(this.btnSelectAvator);
|
||||||
|
this.tabPage2.Controls.Add(this.uiLabel10);
|
||||||
|
this.tabPage2.Location = new System.Drawing.Point(0, 40);
|
||||||
|
this.tabPage2.Name = "tabPage2";
|
||||||
|
this.tabPage2.Size = new System.Drawing.Size(200, 60);
|
||||||
|
this.tabPage2.TabIndex = 1;
|
||||||
|
this.tabPage2.Text = "头像";
|
||||||
|
//
|
||||||
|
// btnSelectAvator
|
||||||
|
//
|
||||||
|
this.btnSelectAvator.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.btnSelectAvator.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.btnSelectAvator.Location = new System.Drawing.Point(258, 127);
|
||||||
|
this.btnSelectAvator.MinimumSize = new System.Drawing.Size(1, 1);
|
||||||
|
this.btnSelectAvator.Name = "btnSelectAvator";
|
||||||
|
this.btnSelectAvator.Size = new System.Drawing.Size(137, 48);
|
||||||
|
this.btnSelectAvator.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.btnSelectAvator.TabIndex = 1;
|
||||||
|
this.btnSelectAvator.Text = "上传头像";
|
||||||
|
this.btnSelectAvator.Click += new System.EventHandler(this.btnSelectAvator_Click);
|
||||||
|
//
|
||||||
|
// uiLabel10
|
||||||
|
//
|
||||||
|
this.uiLabel10.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.uiLabel10.Location = new System.Drawing.Point(111, 47);
|
||||||
|
this.uiLabel10.Name = "uiLabel10";
|
||||||
|
this.uiLabel10.Size = new System.Drawing.Size(538, 29);
|
||||||
|
this.uiLabel10.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.uiLabel10.TabIndex = 0;
|
||||||
|
this.uiLabel10.Text = "建议尺寸168*168,支持jpg,bmp,png,不能超过200kb";
|
||||||
|
this.uiLabel10.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// tabPage3
|
||||||
|
//
|
||||||
|
this.tabPage3.BackColor = System.Drawing.Color.White;
|
||||||
|
this.tabPage3.Controls.Add(this.btnReset);
|
||||||
|
this.tabPage3.Controls.Add(this.btnChangePassword);
|
||||||
|
this.tabPage3.Controls.Add(this.txtComfirmPassword);
|
||||||
|
this.tabPage3.Controls.Add(this.txtNewPassword);
|
||||||
|
this.tabPage3.Controls.Add(this.lblComfirmPassword);
|
||||||
|
this.tabPage3.Controls.Add(this.lblNewPassword);
|
||||||
|
this.tabPage3.Controls.Add(this.txtOldPassword);
|
||||||
|
this.tabPage3.Controls.Add(this.lblOldPassword);
|
||||||
|
this.tabPage3.Controls.Add(this.uiLabel11);
|
||||||
|
this.tabPage3.Location = new System.Drawing.Point(0, 40);
|
||||||
|
this.tabPage3.Name = "tabPage3";
|
||||||
|
this.tabPage3.Size = new System.Drawing.Size(200, 60);
|
||||||
|
this.tabPage3.TabIndex = 2;
|
||||||
|
this.tabPage3.Text = "账号";
|
||||||
|
//
|
||||||
|
// btnReset
|
||||||
|
//
|
||||||
|
this.btnReset.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.btnReset.FillColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(155)))), ((int)(((byte)(40)))));
|
||||||
|
this.btnReset.FillColor2 = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(155)))), ((int)(((byte)(40)))));
|
||||||
|
this.btnReset.FillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(174)))), ((int)(((byte)(86)))));
|
||||||
|
this.btnReset.FillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(137)))), ((int)(((byte)(43)))));
|
||||||
|
this.btnReset.FillSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(137)))), ((int)(((byte)(43)))));
|
||||||
|
this.btnReset.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.btnReset.Location = new System.Drawing.Point(268, 261);
|
||||||
|
this.btnReset.MinimumSize = new System.Drawing.Size(1, 1);
|
||||||
|
this.btnReset.Name = "btnReset";
|
||||||
|
this.btnReset.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(220)))), ((int)(((byte)(155)))), ((int)(((byte)(40)))));
|
||||||
|
this.btnReset.RectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(223)))), ((int)(((byte)(174)))), ((int)(((byte)(86)))));
|
||||||
|
this.btnReset.RectPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(137)))), ((int)(((byte)(43)))));
|
||||||
|
this.btnReset.RectSelectedColor = System.Drawing.Color.FromArgb(((int)(((byte)(192)))), ((int)(((byte)(137)))), ((int)(((byte)(43)))));
|
||||||
|
this.btnReset.Size = new System.Drawing.Size(125, 44);
|
||||||
|
this.btnReset.Style = Sunny.UI.UIStyle.Orange;
|
||||||
|
this.btnReset.StyleCustomMode = true;
|
||||||
|
this.btnReset.TabIndex = 21;
|
||||||
|
this.btnReset.Text = "重置";
|
||||||
|
this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
|
||||||
|
//
|
||||||
|
// btnChangePassword
|
||||||
|
//
|
||||||
|
this.btnChangePassword.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||||
|
this.btnChangePassword.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.btnChangePassword.Location = new System.Drawing.Point(114, 261);
|
||||||
|
this.btnChangePassword.MinimumSize = new System.Drawing.Size(1, 1);
|
||||||
|
this.btnChangePassword.Name = "btnChangePassword";
|
||||||
|
this.btnChangePassword.Size = new System.Drawing.Size(125, 44);
|
||||||
|
this.btnChangePassword.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.btnChangePassword.TabIndex = 20;
|
||||||
|
this.btnChangePassword.Text = "保存";
|
||||||
|
this.btnChangePassword.Click += new System.EventHandler(this.btnChangePassword_Click);
|
||||||
|
//
|
||||||
|
// txtComfirmPassword
|
||||||
|
//
|
||||||
|
this.txtComfirmPassword.ButtonFillColor = System.Drawing.Color.White;
|
||||||
|
this.txtComfirmPassword.ButtonFillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtComfirmPassword.ButtonFillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtComfirmPassword.ButtonForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(96)))), ((int)(((byte)(98)))), ((int)(((byte)(102)))));
|
||||||
|
this.txtComfirmPassword.ButtonForeHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtComfirmPassword.ButtonForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(131)))), ((int)(((byte)(229)))));
|
||||||
|
this.txtComfirmPassword.ButtonRectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtComfirmPassword.ButtonRectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(222)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtComfirmPassword.ButtonSymbol = 61761;
|
||||||
|
this.txtComfirmPassword.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||||
|
this.txtComfirmPassword.FillColor2 = System.Drawing.Color.White;
|
||||||
|
this.txtComfirmPassword.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.txtComfirmPassword.Location = new System.Drawing.Point(205, 178);
|
||||||
|
this.txtComfirmPassword.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||||
|
this.txtComfirmPassword.Maximum = 2147483647D;
|
||||||
|
this.txtComfirmPassword.Minimum = -2147483648D;
|
||||||
|
this.txtComfirmPassword.MinimumSize = new System.Drawing.Size(1, 16);
|
||||||
|
this.txtComfirmPassword.Name = "txtComfirmPassword";
|
||||||
|
this.txtComfirmPassword.PasswordChar = '*';
|
||||||
|
this.txtComfirmPassword.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtComfirmPassword.Size = new System.Drawing.Size(188, 42);
|
||||||
|
|
||||||
|
this.txtComfirmPassword.StyleCustomMode = true;
|
||||||
|
this.txtComfirmPassword.TabIndex = 11;
|
||||||
|
this.txtComfirmPassword.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// txtNewPassword
|
||||||
|
//
|
||||||
|
this.txtNewPassword.ButtonFillColor = System.Drawing.Color.White;
|
||||||
|
this.txtNewPassword.ButtonFillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtNewPassword.ButtonFillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtNewPassword.ButtonForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(96)))), ((int)(((byte)(98)))), ((int)(((byte)(102)))));
|
||||||
|
this.txtNewPassword.ButtonForeHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtNewPassword.ButtonForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(131)))), ((int)(((byte)(229)))));
|
||||||
|
this.txtNewPassword.ButtonRectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtNewPassword.ButtonRectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(222)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtNewPassword.ButtonSymbol = 61761;
|
||||||
|
this.txtNewPassword.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||||
|
this.txtNewPassword.FillColor2 = System.Drawing.Color.White;
|
||||||
|
this.txtNewPassword.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.txtNewPassword.Location = new System.Drawing.Point(205, 123);
|
||||||
|
this.txtNewPassword.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||||
|
this.txtNewPassword.Maximum = 2147483647D;
|
||||||
|
this.txtNewPassword.Minimum = -2147483648D;
|
||||||
|
this.txtNewPassword.MinimumSize = new System.Drawing.Size(1, 16);
|
||||||
|
this.txtNewPassword.Name = "txtNewPassword";
|
||||||
|
this.txtNewPassword.PasswordChar = '*';
|
||||||
|
this.txtNewPassword.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtNewPassword.Size = new System.Drawing.Size(188, 42);
|
||||||
|
|
||||||
|
this.txtNewPassword.StyleCustomMode = true;
|
||||||
|
this.txtNewPassword.TabIndex = 9;
|
||||||
|
this.txtNewPassword.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// lblComfirmPassword
|
||||||
|
//
|
||||||
|
this.lblComfirmPassword.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.lblComfirmPassword.Location = new System.Drawing.Point(88, 185);
|
||||||
|
this.lblComfirmPassword.Name = "lblComfirmPassword";
|
||||||
|
this.lblComfirmPassword.Size = new System.Drawing.Size(110, 29);
|
||||||
|
this.lblComfirmPassword.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.lblComfirmPassword.TabIndex = 10;
|
||||||
|
this.lblComfirmPassword.Text = "确认密码";
|
||||||
|
this.lblComfirmPassword.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||||
|
//
|
||||||
|
// lblNewPassword
|
||||||
|
//
|
||||||
|
this.lblNewPassword.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.lblNewPassword.Location = new System.Drawing.Point(114, 130);
|
||||||
|
this.lblNewPassword.Name = "lblNewPassword";
|
||||||
|
this.lblNewPassword.Size = new System.Drawing.Size(84, 29);
|
||||||
|
this.lblNewPassword.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.lblNewPassword.TabIndex = 8;
|
||||||
|
this.lblNewPassword.Text = "新密码";
|
||||||
|
this.lblNewPassword.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||||
|
//
|
||||||
|
// txtOldPassword
|
||||||
|
//
|
||||||
|
this.txtOldPassword.ButtonFillColor = System.Drawing.Color.White;
|
||||||
|
this.txtOldPassword.ButtonFillHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtOldPassword.ButtonFillPressColor = System.Drawing.Color.FromArgb(((int)(((byte)(235)))), ((int)(((byte)(243)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtOldPassword.ButtonForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(96)))), ((int)(((byte)(98)))), ((int)(((byte)(102)))));
|
||||||
|
this.txtOldPassword.ButtonForeHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(80)))), ((int)(((byte)(160)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtOldPassword.ButtonForePressColor = System.Drawing.Color.FromArgb(((int)(((byte)(74)))), ((int)(((byte)(131)))), ((int)(((byte)(229)))));
|
||||||
|
this.txtOldPassword.ButtonRectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtOldPassword.ButtonRectHoverColor = System.Drawing.Color.FromArgb(((int)(((byte)(197)))), ((int)(((byte)(222)))), ((int)(((byte)(255)))));
|
||||||
|
this.txtOldPassword.ButtonSymbol = 61761;
|
||||||
|
this.txtOldPassword.Cursor = System.Windows.Forms.Cursors.IBeam;
|
||||||
|
this.txtOldPassword.FillColor2 = System.Drawing.Color.White;
|
||||||
|
this.txtOldPassword.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.txtOldPassword.Location = new System.Drawing.Point(205, 71);
|
||||||
|
this.txtOldPassword.Margin = new System.Windows.Forms.Padding(4, 5, 4, 5);
|
||||||
|
this.txtOldPassword.Maximum = 2147483647D;
|
||||||
|
this.txtOldPassword.Minimum = -2147483648D;
|
||||||
|
this.txtOldPassword.MinimumSize = new System.Drawing.Size(1, 16);
|
||||||
|
this.txtOldPassword.Name = "txtOldPassword";
|
||||||
|
this.txtOldPassword.PasswordChar = '*';
|
||||||
|
this.txtOldPassword.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(216)))), ((int)(((byte)(219)))), ((int)(((byte)(227)))));
|
||||||
|
this.txtOldPassword.Size = new System.Drawing.Size(188, 42);
|
||||||
|
|
||||||
|
this.txtOldPassword.StyleCustomMode = true;
|
||||||
|
this.txtOldPassword.TabIndex = 7;
|
||||||
|
this.txtOldPassword.TextAlignment = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// lblOldPassword
|
||||||
|
//
|
||||||
|
this.lblOldPassword.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.lblOldPassword.Location = new System.Drawing.Point(114, 78);
|
||||||
|
this.lblOldPassword.Name = "lblOldPassword";
|
||||||
|
this.lblOldPassword.Size = new System.Drawing.Size(84, 29);
|
||||||
|
this.lblOldPassword.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.lblOldPassword.TabIndex = 6;
|
||||||
|
this.lblOldPassword.Text = "旧密码";
|
||||||
|
this.lblOldPassword.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||||
|
//
|
||||||
|
// uiLabel11
|
||||||
|
//
|
||||||
|
this.uiLabel11.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point);
|
||||||
|
this.uiLabel11.Location = new System.Drawing.Point(45, 23);
|
||||||
|
this.uiLabel11.Name = "uiLabel11";
|
||||||
|
this.uiLabel11.Size = new System.Drawing.Size(125, 29);
|
||||||
|
this.uiLabel11.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.uiLabel11.TabIndex = 0;
|
||||||
|
this.uiLabel11.Text = "修改密码";
|
||||||
|
this.uiLabel11.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||||
|
//
|
||||||
|
// AccountForm
|
||||||
|
//
|
||||||
|
this.AllowShowTitle = false;
|
||||||
|
this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 27F);
|
||||||
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
|
this.ClientSize = new System.Drawing.Size(1031, 558);
|
||||||
|
this.Controls.Add(this.uiPanel1);
|
||||||
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
|
this.MaximizeBox = false;
|
||||||
|
this.MinimizeBox = false;
|
||||||
|
this.Name = "AccountForm";
|
||||||
|
this.Padding = new System.Windows.Forms.Padding(0);
|
||||||
|
this.RectColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(248)))));
|
||||||
|
this.ShowTitle = false;
|
||||||
|
this.ShowTitleIcon = true;
|
||||||
|
this.Style = Sunny.UI.UIStyle.Custom;
|
||||||
|
this.Text = "账户管理";
|
||||||
|
this.TitleColor = System.Drawing.Color.FromArgb(((int)(((byte)(248)))), ((int)(((byte)(248)))), ((int)(((byte)(248)))));
|
||||||
|
this.TitleForeColor = System.Drawing.Color.DimGray;
|
||||||
|
this.TopMost = true;
|
||||||
|
this.Load += new System.EventHandler(this.AccountForm_Load);
|
||||||
|
this.uiPanel1.ResumeLayout(false);
|
||||||
|
this.titlePanel.ResumeLayout(false);
|
||||||
|
this.panel1.ResumeLayout(false);
|
||||||
|
((System.ComponentModel.ISupportInitialize)(this.imageAvator)).EndInit();
|
||||||
|
this.uiTabControl1.ResumeLayout(false);
|
||||||
|
this.tabPage1.ResumeLayout(false);
|
||||||
|
this.tabPage2.ResumeLayout(false);
|
||||||
|
this.tabPage3.ResumeLayout(false);
|
||||||
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
private Sunny.UI.UIPanel uiPanel1;
|
||||||
|
private System.Windows.Forms.Panel panel1;
|
||||||
|
private System.Windows.Forms.Label lblCurrentUser;
|
||||||
|
private System.Windows.Forms.PictureBox imageAvator;
|
||||||
|
private Sunny.UI.UITabControl uiTabControl1;
|
||||||
|
private System.Windows.Forms.TabPage tabPage1;
|
||||||
|
private Sunny.UI.UIButton btnSave;
|
||||||
|
private Sunny.UI.UITextBox txtSignature;
|
||||||
|
private Sunny.UI.UILabel lblSignature;
|
||||||
|
private Sunny.UI.UITextBox txtAddress;
|
||||||
|
private Sunny.UI.UILabel lblAddress;
|
||||||
|
private Sunny.UI.UITextBox txtTel;
|
||||||
|
private Sunny.UI.UILabel lblTel;
|
||||||
|
private Sunny.UI.UITextBox txtEmail;
|
||||||
|
private Sunny.UI.UILabel lblEmail;
|
||||||
|
private Sunny.UI.UILabel lblBirthday;
|
||||||
|
private Sunny.UI.UIRadioButton rdFemale;
|
||||||
|
private Sunny.UI.UIRadioButton rdMale;
|
||||||
|
private Sunny.UI.UILabel lblGender;
|
||||||
|
private Sunny.UI.UILabel lblNickName;
|
||||||
|
private Sunny.UI.UITextBox txtName;
|
||||||
|
private Sunny.UI.UILabel lblName;
|
||||||
|
private Sunny.UI.UITextBox txtAccount;
|
||||||
|
private Sunny.UI.UILabel lblAccount;
|
||||||
|
private System.Windows.Forms.TabPage tabPage2;
|
||||||
|
private Sunny.UI.UIButton btnSelectAvator;
|
||||||
|
private Sunny.UI.UILabel uiLabel10;
|
||||||
|
private System.Windows.Forms.TabPage tabPage3;
|
||||||
|
private Sunny.UI.UIButton btnReset;
|
||||||
|
private Sunny.UI.UIButton btnChangePassword;
|
||||||
|
private Sunny.UI.UITextBox txtComfirmPassword;
|
||||||
|
private Sunny.UI.UITextBox txtNewPassword;
|
||||||
|
private Sunny.UI.UILabel lblComfirmPassword;
|
||||||
|
private Sunny.UI.UILabel lblNewPassword;
|
||||||
|
private Sunny.UI.UITextBox txtOldPassword;
|
||||||
|
private Sunny.UI.UILabel lblOldPassword;
|
||||||
|
private Sunny.UI.UILabel uiLabel11;
|
||||||
|
private System.Windows.Forms.Panel titlePanel;
|
||||||
|
private Sunny.UI.UILabel uiLabel15;
|
||||||
|
private Sunny.UI.UISymbolLabel btnClose;
|
||||||
|
private Sunny.UI.UITextBox txtNickName;
|
||||||
|
private Sunny.UI.UIDatePicker txtBirthday;
|
||||||
|
}
|
||||||
|
}
|
304
DH.RBAC/AccountForm.cs
Normal file
304
DH.RBAC/AccountForm.cs
Normal file
@ -0,0 +1,304 @@
|
|||||||
|
using Sunny.UI;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using System.IO;
|
||||||
|
using System.Windows.Forms;
|
||||||
|
using DH.RBAC.Model.Sys;
|
||||||
|
using DH.RBAC.Common;
|
||||||
|
using DH.RBAC.Properties;
|
||||||
|
using DH.RBAC.Logic.Sys;
|
||||||
|
using DH.RBAC.Utility.Other;
|
||||||
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||||
|
|
||||||
|
namespace DH.RBAC
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 用户账户界面
|
||||||
|
/// </summary>
|
||||||
|
public partial class AccountForm : UIForm
|
||||||
|
{
|
||||||
|
private SysUserLogic userlogic;
|
||||||
|
private SysUserLogOnLogic userLogOnLogic;
|
||||||
|
/// <summary>
|
||||||
|
/// 构造方法
|
||||||
|
/// </summary>
|
||||||
|
public AccountForm()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
userlogic = new SysUserLogic();
|
||||||
|
userLogOnLogic = new SysUserLogOnLogic();
|
||||||
|
}
|
||||||
|
|
||||||
|
#region 标题栏 处理
|
||||||
|
private void btnClose_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
FormHelper.subForm = null;
|
||||||
|
this.Close();
|
||||||
|
}
|
||||||
|
private Point mPoint;
|
||||||
|
private void titlePanel_MouseDown(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
mPoint = new Point(e.X, e.Y);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void titlePanel_MouseMove(object sender, MouseEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.Button == MouseButtons.Left)
|
||||||
|
{
|
||||||
|
this.Location = new Point(this.Location.X + e.X - mPoint.X, this.Location.Y + e.Y - mPoint.Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnClose_MouseEnter(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
btnClose.BackColor = Color.FromArgb(231, 231, 231);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnClose_MouseLeave(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
btnClose.BackColor = Color.Transparent;
|
||||||
|
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private string Avatar;
|
||||||
|
/// <summary>
|
||||||
|
/// 画面加载,读取用户信息,显示在界面上
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void AccountForm_Load(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SysUser user = userlogic.Get(GlobalConfig.CurrentUser.Id);
|
||||||
|
if (user == null)
|
||||||
|
{
|
||||||
|
AntdUI.Message.warn(this, "网络或服务器异常,请稍后重试!", autoClose: 3);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Avatar = user.Avatar;
|
||||||
|
txtAccount.Text = user.Account;
|
||||||
|
txtNickName.Text = user.NickName;
|
||||||
|
txtName.Text = user.RealName;
|
||||||
|
if (user.Gender == "1")
|
||||||
|
rdMale.Checked = true;
|
||||||
|
else
|
||||||
|
rdFemale.Checked = true;
|
||||||
|
txtBirthday.Value = user.Birthday.Value;
|
||||||
|
txtEmail.Text = user.Email;
|
||||||
|
txtTel.Text = user.MobilePhone;
|
||||||
|
txtAddress.Text = user.Address;
|
||||||
|
txtSignature.Text = user.Signature;
|
||||||
|
|
||||||
|
//头像显示
|
||||||
|
if (StringHelper.IsNullOrEmpty(user.AvatarBase64))
|
||||||
|
{
|
||||||
|
imageAvator.Image = Resources.avatar;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
MemoryStream ms = new MemoryStream(Convert.FromBase64String(user.AvatarBase64));
|
||||||
|
imageAvator.Image = Image.FromStream(ms);
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
imageAvator.Image = Resources.avatar;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lblCurrentUser.Text = $"{user.Account}@{user.NickName}";
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 保存修改
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void btnSave_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//非空检测
|
||||||
|
if (StringHelper.IsNullOrEmpty(txtNickName.Text))
|
||||||
|
{
|
||||||
|
AntdUI.Message.warn(this, "昵称不能为空!", autoClose: 3);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (StringHelper.IsNullOrEmpty(txtName.Text))
|
||||||
|
{
|
||||||
|
AntdUI.Message.warn(this, "姓名不能为空!", autoClose: 3);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (StringHelper.IsNullOrEmpty(txtBirthday.Text))
|
||||||
|
{
|
||||||
|
AntdUI.Message.warn(this, "请选择生日!", autoClose: 3);
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (StringHelper.IsNullOrEmpty(txtEmail.Text))
|
||||||
|
{
|
||||||
|
AntdUI.Message.warn(this, "邮箱不能为空!", autoClose: 3);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (StringHelper.IsNullOrEmpty(txtTel.Text))
|
||||||
|
{
|
||||||
|
AntdUI.Message.warn(this, "手机不能为空!", autoClose: 3);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//获得目前信息,提交给服务端处理,返回结果
|
||||||
|
SysUser model = new SysUser();
|
||||||
|
model.Id = GlobalConfig.CurrentUser.Id;
|
||||||
|
model.Account = txtAccount.Text;
|
||||||
|
model.NickName = txtNickName.Text;
|
||||||
|
model.RealName = txtName.Text;
|
||||||
|
model.Avatar = Avatar;
|
||||||
|
model.Gender = rdMale.Checked ? "1" : "0";
|
||||||
|
model.StrBirthday = txtBirthday.Text;
|
||||||
|
model.Email = txtEmail.Text;
|
||||||
|
model.MobilePhone = txtTel.Text;
|
||||||
|
model.Address = txtAddress.Text;
|
||||||
|
model.Signature = txtSignature.Text;
|
||||||
|
|
||||||
|
DateTime defaultDt = DateTime.Today;
|
||||||
|
DateTime.TryParse(model.StrBirthday, out defaultDt);
|
||||||
|
model.Birthday = defaultDt;
|
||||||
|
int row = userlogic.AppUpdateBasicInfo(model);
|
||||||
|
|
||||||
|
if (row == 0)
|
||||||
|
{
|
||||||
|
AntdUI.Message.warn(this, "对不起,操作失败!", autoClose: 3);
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AntdUI.Message.success(this, "恭喜你,操作成功!", autoClose: 3);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 选择图片上传
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
private void btnSelectAvator_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//OpenFileDialog dialog = new OpenFileDialog();
|
||||||
|
//dialog.Filter = "Image Files(*.BMP;*.JPG;*.png)|*.BMP;*.JPG;*.png";
|
||||||
|
//if (dialog.ShowDialog() == DialogResult.OK)
|
||||||
|
//{
|
||||||
|
// string fileName = dialog.FileName;
|
||||||
|
// Image image = Image.FromFile(fileName);
|
||||||
|
// //上传到服务器
|
||||||
|
// AjaxResult result = null;
|
||||||
|
|
||||||
|
// string url = GlobalConfig.Config.Url + "account/uploadImage";
|
||||||
|
// string str = HttpUtils.PostFile(url, fileName, 2000);
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// result = str.ToObject<AjaxResult>();
|
||||||
|
// }
|
||||||
|
// catch
|
||||||
|
// {
|
||||||
|
// result = null;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
// if (result == null)
|
||||||
|
// {
|
||||||
|
// this.ShowWarningDialog("网络或服务器异常,请稍后重试", UIStyle.White);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// if (result.state != ResultType.Success)
|
||||||
|
// {
|
||||||
|
// this.ShowWarningDialog(result.message, UIStyle.White);
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// //上传成功,修改界面头像,以及服务器头像地址
|
||||||
|
// Avatar = result.data.ToString();
|
||||||
|
// imageAvator.Image = image;
|
||||||
|
// this.ShowSuccessDialog("上传成功,点击保存后生效", UIStyle.White);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnReset_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
txtOldPassword.Text = string.Empty;
|
||||||
|
txtNewPassword.Text = string.Empty;
|
||||||
|
txtComfirmPassword.Text = string.Empty;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnChangePassword_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
//非空检测
|
||||||
|
if (StringHelper.IsNullOrEmpty(txtOldPassword.Text))
|
||||||
|
{
|
||||||
|
AntdUI.Message.warn(this, "旧密码不能为空!", autoClose: 3);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (StringHelper.IsNullOrEmpty(txtNewPassword.Text))
|
||||||
|
{
|
||||||
|
AntdUI.Message.warn(this, "新密码不能为空!", autoClose: 3);
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (StringHelper.IsNullOrEmpty(txtComfirmPassword.Text))
|
||||||
|
{
|
||||||
|
AntdUI.Message.warn(this, "确认密码不能为空!", autoClose: 3);
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (txtNewPassword.Text != txtComfirmPassword.Text)
|
||||||
|
{
|
||||||
|
AntdUI.Message.warn(this, "两次密码不一致!", autoClose: 3);
|
||||||
|
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Dictionary<string, string> parm = new Dictionary<string, string>();
|
||||||
|
string userId = GlobalConfig.CurrentUser.Id;
|
||||||
|
string oldPassword = txtOldPassword.Text;
|
||||||
|
string newPassword = txtNewPassword.Text;
|
||||||
|
string confirmPassword = txtComfirmPassword.Text;
|
||||||
|
|
||||||
|
|
||||||
|
if (!newPassword.Equals(confirmPassword))
|
||||||
|
{
|
||||||
|
AntdUI.Message.warn(this, "两次密码输入不一致,请重新确认!", autoClose: 3);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
oldPassword = oldPassword.MD5Encrypt();
|
||||||
|
newPassword = newPassword.MD5Encrypt();
|
||||||
|
confirmPassword = confirmPassword.MD5Encrypt();
|
||||||
|
|
||||||
|
var userLoginEntity = userLogOnLogic.GetByAccount(userId);
|
||||||
|
if (oldPassword.DESEncrypt(userLoginEntity.SecretKey).MD5Encrypt() != userLoginEntity.Password)
|
||||||
|
{
|
||||||
|
AntdUI.Message.warn(this, "旧密码验证失败!", autoClose: 3);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
userLoginEntity.Password = newPassword.DESEncrypt(userLoginEntity.SecretKey).MD5Encrypt();
|
||||||
|
int isSuccess = userLogOnLogic.ModifyPwd(userLoginEntity);
|
||||||
|
if (isSuccess == 0)
|
||||||
|
{
|
||||||
|
AntdUI.Message.warn(this, "对不起,操作失败!", autoClose: 3);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
AntdUI.Message.success(this, "修改成功!", autoClose: 3);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1161
DH.RBAC/AccountForm.resx
Normal file
1161
DH.RBAC/AccountForm.resx
Normal file
File diff suppressed because it is too large
Load Diff
35
DH.RBAC/Common/GlobalConfig.cs
Normal file
35
DH.RBAC/Common/GlobalConfig.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Drawing;
|
||||||
|
using DH.RBAC.Model.Sys;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Common
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 全局数据存放
|
||||||
|
/// </summary>
|
||||||
|
public class GlobalConfig
|
||||||
|
{
|
||||||
|
public static MyConfig Config { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 当前登录的用户
|
||||||
|
/// </summary>
|
||||||
|
public static SysUser CurrentUser;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前用户头像
|
||||||
|
/// </summary>
|
||||||
|
public static Image Avatar;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前选的哪个菜单
|
||||||
|
/// </summary>
|
||||||
|
public static string CurrentMenuText;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 当前用户权限
|
||||||
|
/// </summary>
|
||||||
|
public static List<SysPermission> PermissionList;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
719
DH.RBAC/Common/IconDict.cs
Normal file
719
DH.RBAC/Common/IconDict.cs
Normal file
@ -0,0 +1,719 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Common
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 图标字典
|
||||||
|
/// </summary>
|
||||||
|
public class IconDict
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 全局存放图标字典
|
||||||
|
/// </summary>
|
||||||
|
public static Dictionary<string, int> MyIconDict = Init();
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 初始化字典
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private static Dictionary<string, int> Init()
|
||||||
|
{
|
||||||
|
Dictionary<string, int> dict = new Dictionary<string, int>();
|
||||||
|
dict.Add("fa fa-bluetooth", 62099);
|
||||||
|
dict.Add("fa fa-bluetooth-b", 62100);
|
||||||
|
dict.Add("fa fa-codiepie", 62084);
|
||||||
|
dict.Add("fa fa-credit-card-alt", 62083);
|
||||||
|
dict.Add("fa fa-edge", 62082);
|
||||||
|
dict.Add("fa fa-fort-awesome", 62086);
|
||||||
|
dict.Add("fa fa-hashtag", 62098);
|
||||||
|
dict.Add("fa fa-mixcloud", 62089);
|
||||||
|
dict.Add("fa fa-modx", 62085);
|
||||||
|
dict.Add("fa fa-pause-circle", 62091);
|
||||||
|
dict.Add("fa fa-pause-circle-o", 62092);
|
||||||
|
dict.Add("fa fa-percent", 62101);
|
||||||
|
dict.Add("fa fa-product-hunt", 62088);
|
||||||
|
dict.Add("fa fa-reddit-alien", 62081);
|
||||||
|
dict.Add("fa fa-scribd", 62090);
|
||||||
|
dict.Add("fa fa-shopping-bag", 62096);
|
||||||
|
dict.Add("fa fa-shopping-basket", 62097);
|
||||||
|
dict.Add("fa fa-stop-circle", 62093);
|
||||||
|
dict.Add("fa fa-stop-circle-o", 62094);
|
||||||
|
dict.Add("fa fa-usb", 62087);
|
||||||
|
dict.Add("fa fa-adjust", 61506);
|
||||||
|
dict.Add("fa fa-anchor", 61757);
|
||||||
|
dict.Add("fa fa-archive", 61831);
|
||||||
|
dict.Add("fa fa-area-chart", 61950);
|
||||||
|
dict.Add("fa fa-arrows", 61511);
|
||||||
|
dict.Add("fa fa-arrows-h", 61566);
|
||||||
|
dict.Add("fa fa-arrows-v", 61565);
|
||||||
|
dict.Add("fa fa-asterisk", 61545);
|
||||||
|
dict.Add("fa fa-at", 61946);
|
||||||
|
dict.Add("fa fa-automobile", 61881);
|
||||||
|
dict.Add("fa fa-balance-scale", 62030);
|
||||||
|
dict.Add("fa fa-ban", 61534);
|
||||||
|
dict.Add("fa fa-bank", 61852);
|
||||||
|
dict.Add("fa fa-bar-chart", 61568);
|
||||||
|
dict.Add("fa fa-bar-chart-o", 61568);
|
||||||
|
dict.Add("fa fa-barcode", 61482);
|
||||||
|
dict.Add("fa fa-bars", 61641);
|
||||||
|
dict.Add("fa fa-battery-0", 62020);
|
||||||
|
dict.Add("fa fa-battery-1", 62019);
|
||||||
|
dict.Add("fa fa-battery-2", 62018);
|
||||||
|
dict.Add("fa fa-battery-3", 62017);
|
||||||
|
dict.Add("fa fa-battery-4", 62016);
|
||||||
|
dict.Add("fa fa-battery-empty", 62020);
|
||||||
|
dict.Add("fa fa-battery-full", 62016);
|
||||||
|
dict.Add("fa fa-battery-half", 62018);
|
||||||
|
dict.Add("fa fa-battery-quarter", 62019);
|
||||||
|
dict.Add("fa fa-battery-three-quarters", 62017);
|
||||||
|
dict.Add("fa fa-bed", 62006);
|
||||||
|
dict.Add("fa fa-beer", 61692);
|
||||||
|
dict.Add("fa fa-bell", 61683);
|
||||||
|
dict.Add("fa fa-bell-o", 61602);
|
||||||
|
dict.Add("fa fa-bell-slash", 61942);
|
||||||
|
dict.Add("fa fa-bell-slash-o", 61943);
|
||||||
|
dict.Add("fa fa-bicycle", 61958);
|
||||||
|
dict.Add("fa fa-binoculars", 61925);
|
||||||
|
dict.Add("fa fa-birthday-cake", 61949);
|
||||||
|
dict.Add("fa fa-bolt", 61671);
|
||||||
|
dict.Add("fa fa-bomb", 61922);
|
||||||
|
dict.Add("fa fa-book", 61485);
|
||||||
|
dict.Add("fa fa-bookmark", 61486);
|
||||||
|
dict.Add("fa fa-bookmark-o", 61591);
|
||||||
|
dict.Add("fa fa-briefcase", 61617);
|
||||||
|
dict.Add("fa fa-bug", 61832);
|
||||||
|
dict.Add("fa fa-building", 61869);
|
||||||
|
dict.Add("fa fa-building-o", 61687);
|
||||||
|
dict.Add("fa fa-bullhorn", 61601);
|
||||||
|
dict.Add("fa fa-bullseye", 61760);
|
||||||
|
dict.Add("fa fa-bus", 61959);
|
||||||
|
dict.Add("fa fa-cab", 61882);
|
||||||
|
dict.Add("fa fa-calculator", 61932);
|
||||||
|
dict.Add("fa fa-calendar", 61555);
|
||||||
|
dict.Add("fa fa-calendar-check-o", 62068);
|
||||||
|
dict.Add("fa fa-calendar-minus-o", 62066);
|
||||||
|
dict.Add("fa fa-calendar-o", 61747);
|
||||||
|
dict.Add("fa fa-calendar-plus-o", 62065);
|
||||||
|
dict.Add("fa fa-calendar-times-o", 62067);
|
||||||
|
dict.Add("fa fa-camera", 61488);
|
||||||
|
dict.Add("fa fa-camera-retro", 61571);
|
||||||
|
dict.Add("fa fa-car", 61881);
|
||||||
|
dict.Add("fa fa-caret-square-o-down", 61776);
|
||||||
|
dict.Add("fa fa-caret-square-o-left", 61841);
|
||||||
|
dict.Add("fa fa-caret-square-o-right", 61778);
|
||||||
|
dict.Add("fa fa-caret-square-o-up", 61777);
|
||||||
|
dict.Add("fa fa-cart-arrow-down", 61976);
|
||||||
|
dict.Add("fa fa-cart-plus", 61975);
|
||||||
|
dict.Add("fa fa-cc", 61962);
|
||||||
|
dict.Add("fa fa-certificate", 61603);
|
||||||
|
dict.Add("fa fa-check", 61452);
|
||||||
|
dict.Add("fa fa-check-circle", 61528);
|
||||||
|
dict.Add("fa fa-check-circle-o", 61533);
|
||||||
|
dict.Add("fa fa-check-square", 61770);
|
||||||
|
dict.Add("fa fa-check-square-o", 61510);
|
||||||
|
dict.Add("fa fa-child", 61870);
|
||||||
|
dict.Add("fa fa-circle", 61713);
|
||||||
|
dict.Add("fa fa-circle-o", 61708);
|
||||||
|
dict.Add("fa fa-circle-o-notch", 61902);
|
||||||
|
dict.Add("fa fa-circle-thin", 61915);
|
||||||
|
dict.Add("fa fa-clock-o", 61463);
|
||||||
|
dict.Add("fa fa-clone", 62029);
|
||||||
|
dict.Add("fa fa-close", 61453);
|
||||||
|
dict.Add("fa fa-cloud", 61634);
|
||||||
|
dict.Add("fa fa-cloud-download", 61677);
|
||||||
|
dict.Add("fa fa-cloud-upload", 61678);
|
||||||
|
dict.Add("fa fa-code", 61729);
|
||||||
|
dict.Add("fa fa-code-fork", 61734);
|
||||||
|
dict.Add("fa fa-coffee", 61684);
|
||||||
|
dict.Add("fa fa-cog", 61459);
|
||||||
|
dict.Add("fa fa-cogs", 61573);
|
||||||
|
dict.Add("fa fa-comment", 61557);
|
||||||
|
dict.Add("fa fa-comment-o", 61669);
|
||||||
|
dict.Add("fa fa-commenting", 62074);
|
||||||
|
dict.Add("fa fa-commenting-o", 62075);
|
||||||
|
dict.Add("fa fa-comments", 61574);
|
||||||
|
dict.Add("fa fa-comments-o", 61670);
|
||||||
|
dict.Add("fa fa-compass", 61774);
|
||||||
|
dict.Add("fa fa-copyright", 61945);
|
||||||
|
dict.Add("fa fa-creative-commons", 62046);
|
||||||
|
dict.Add("fa fa-credit-card", 61597);
|
||||||
|
dict.Add("fa fa-crop", 61733);
|
||||||
|
dict.Add("fa fa-crosshairs", 61531);
|
||||||
|
dict.Add("fa fa-cube", 61874);
|
||||||
|
dict.Add("fa fa-cubes", 61875);
|
||||||
|
dict.Add("fa fa-cutlery", 61685);
|
||||||
|
dict.Add("fa fa-dashboard", 61668);
|
||||||
|
dict.Add("fa fa-database", 61888);
|
||||||
|
dict.Add("fa fa-desktop", 61704);
|
||||||
|
dict.Add("fa fa-diamond", 61977);
|
||||||
|
dict.Add("fa fa-dot-circle-o", 61842);
|
||||||
|
dict.Add("fa fa-download", 61465);
|
||||||
|
dict.Add("fa fa-edit", 61508);
|
||||||
|
dict.Add("fa fa-ellipsis-h", 61761);
|
||||||
|
dict.Add("fa fa-ellipsis-v", 61762);
|
||||||
|
dict.Add("fa fa-envelope", 61664);
|
||||||
|
dict.Add("fa fa-envelope-o", 61443);
|
||||||
|
dict.Add("fa fa-envelope-square", 61849);
|
||||||
|
dict.Add("fa fa-eraser", 61741);
|
||||||
|
dict.Add("fa fa-exchange", 61676);
|
||||||
|
dict.Add("fa fa-exclamation", 61738);
|
||||||
|
dict.Add("fa fa-exclamation-circle", 61546);
|
||||||
|
dict.Add("fa fa-exclamation-triangle", 61553);
|
||||||
|
dict.Add("fa fa-external-link", 61582);
|
||||||
|
dict.Add("fa fa-external-link-square", 61772);
|
||||||
|
dict.Add("fa fa-eye", 61550);
|
||||||
|
dict.Add("fa fa-eye-slash", 61552);
|
||||||
|
dict.Add("fa fa-eyedropper", 61947);
|
||||||
|
dict.Add("fa fa-fax", 61868);
|
||||||
|
dict.Add("fa fa-feed", 61598);
|
||||||
|
dict.Add("fa fa-female", 61826);
|
||||||
|
dict.Add("fa fa-fighter-jet", 61691);
|
||||||
|
dict.Add("fa fa-file-archive-o", 61894);
|
||||||
|
dict.Add("fa fa-file-audio-o", 61895);
|
||||||
|
dict.Add("fa fa-file-code-o", 61897);
|
||||||
|
dict.Add("fa fa-file-excel-o", 61891);
|
||||||
|
dict.Add("fa fa-file-image-o", 61893);
|
||||||
|
dict.Add("fa fa-file-movie-o", 61896);
|
||||||
|
dict.Add("fa fa-file-pdf-o", 61889);
|
||||||
|
dict.Add("fa fa-file-photo-o", 61893);
|
||||||
|
dict.Add("fa fa-file-picture-o", 61893);
|
||||||
|
dict.Add("fa fa-file-powerpoint-o", 61892);
|
||||||
|
dict.Add("fa fa-file-sound-o", 61895);
|
||||||
|
dict.Add("fa fa-file-video-o", 61896);
|
||||||
|
dict.Add("fa fa-file-word-o", 61890);
|
||||||
|
dict.Add("fa fa-file-zip-o", 61894);
|
||||||
|
dict.Add("fa fa-film", 61448);
|
||||||
|
dict.Add("fa fa-filter", 61616);
|
||||||
|
dict.Add("fa fa-fire", 61549);
|
||||||
|
dict.Add("fa fa-fire-extinguisher", 61748);
|
||||||
|
dict.Add("fa fa-flag", 61476);
|
||||||
|
dict.Add("fa fa-flag-checkered", 61726);
|
||||||
|
dict.Add("fa fa-flag-o", 61725);
|
||||||
|
dict.Add("fa fa-flash", 61671);
|
||||||
|
dict.Add("fa fa-flask", 61635);
|
||||||
|
dict.Add("fa fa-folder", 61563);
|
||||||
|
dict.Add("fa fa-folder-o", 61716);
|
||||||
|
dict.Add("fa fa-folder-open", 61564);
|
||||||
|
dict.Add("fa fa-folder-open-o", 61717);
|
||||||
|
dict.Add("fa fa-frown-o", 61721);
|
||||||
|
dict.Add("fa fa-futbol-o", 61923);
|
||||||
|
dict.Add("fa fa-gamepad", 61723);
|
||||||
|
dict.Add("fa fa-gavel", 61667);
|
||||||
|
dict.Add("fa fa-gear", 61459);
|
||||||
|
dict.Add("fa fa-gears", 61573);
|
||||||
|
dict.Add("fa fa-gift", 61547);
|
||||||
|
dict.Add("fa fa-glass", 61440);
|
||||||
|
dict.Add("fa fa-globe", 61612);
|
||||||
|
dict.Add("fa fa-graduation-cap", 61853);
|
||||||
|
dict.Add("fa fa-group", 61632);
|
||||||
|
dict.Add("fa fa-hand-grab-o", 62037);
|
||||||
|
dict.Add("fa fa-hand-lizard-o", 62040);
|
||||||
|
dict.Add("fa fa-hand-paper-o", 62038);
|
||||||
|
dict.Add("fa fa-hand-peace-o", 62043);
|
||||||
|
dict.Add("fa fa-hand-pointer-o", 62042);
|
||||||
|
dict.Add("fa fa-hand-rock-o", 62037);
|
||||||
|
dict.Add("fa fa-hand-scissors-o", 62039);
|
||||||
|
dict.Add("fa fa-hand-spock-o", 62041);
|
||||||
|
dict.Add("fa fa-hand-stop-o", 62038);
|
||||||
|
dict.Add("fa fa-hdd-o", 61600);
|
||||||
|
dict.Add("fa fa-headphones", 61477);
|
||||||
|
dict.Add("fa fa-heart", 61444);
|
||||||
|
dict.Add("fa fa-heart-o", 61578);
|
||||||
|
dict.Add("fa fa-heartbeat", 61982);
|
||||||
|
dict.Add("fa fa-history", 61914);
|
||||||
|
dict.Add("fa fa-home", 61461);
|
||||||
|
dict.Add("fa fa-hotel", 62006);
|
||||||
|
dict.Add("fa fa-hourglass", 62036);
|
||||||
|
dict.Add("fa fa-hourglass-1", 62033);
|
||||||
|
dict.Add("fa fa-hourglass-2", 62034);
|
||||||
|
dict.Add("fa fa-hourglass-3", 62035);
|
||||||
|
dict.Add("fa fa-hourglass-end", 62035);
|
||||||
|
dict.Add("fa fa-hourglass-half", 62034);
|
||||||
|
dict.Add("fa fa-hourglass-o", 62032);
|
||||||
|
dict.Add("fa fa-hourglass-start", 62033);
|
||||||
|
dict.Add("fa fa-i-cursor", 62022);
|
||||||
|
dict.Add("fa fa-image", 61502);
|
||||||
|
dict.Add("fa fa-inbox", 61468);
|
||||||
|
dict.Add("fa fa-industry", 62069);
|
||||||
|
dict.Add("fa fa-info", 61737);
|
||||||
|
dict.Add("fa fa-info-circle", 61530);
|
||||||
|
dict.Add("fa fa-institution", 61852);
|
||||||
|
dict.Add("fa fa-key", 61572);
|
||||||
|
dict.Add("fa fa-keyboard-o", 61724);
|
||||||
|
dict.Add("fa fa-language", 61867);
|
||||||
|
dict.Add("fa fa-laptop", 61705);
|
||||||
|
dict.Add("fa fa-leaf", 61548);
|
||||||
|
dict.Add("fa fa-legal", 61667);
|
||||||
|
dict.Add("fa fa-lemon-o", 61588);
|
||||||
|
dict.Add("fa fa-level-down", 61769);
|
||||||
|
dict.Add("fa fa-level-up", 61768);
|
||||||
|
dict.Add("fa fa-life-bouy", 61901);
|
||||||
|
dict.Add("fa fa-life-buoy", 61901);
|
||||||
|
dict.Add("fa fa-life-ring", 61901);
|
||||||
|
dict.Add("fa fa-life-saver", 61901);
|
||||||
|
dict.Add("fa fa-lightbulb-o", 61675);
|
||||||
|
dict.Add("fa fa-line-chart", 61953);
|
||||||
|
dict.Add("fa fa-location-arrow", 61732);
|
||||||
|
dict.Add("fa fa-lock", 61475);
|
||||||
|
dict.Add("fa fa-magic", 61648);
|
||||||
|
dict.Add("fa fa-magnet", 61558);
|
||||||
|
dict.Add("fa fa-mail-forward", 61540);
|
||||||
|
dict.Add("fa fa-mail-reply", 61714);
|
||||||
|
dict.Add("fa fa-mail-reply-all", 61730);
|
||||||
|
dict.Add("fa fa-male", 61827);
|
||||||
|
dict.Add("fa fa-map", 62073);
|
||||||
|
dict.Add("fa fa-map-marker", 61505);
|
||||||
|
dict.Add("fa fa-map-o", 62072);
|
||||||
|
dict.Add("fa fa-map-pin", 62070);
|
||||||
|
dict.Add("fa fa-map-signs", 62071);
|
||||||
|
dict.Add("fa fa-meh-o", 61722);
|
||||||
|
dict.Add("fa fa-microphone", 61744);
|
||||||
|
dict.Add("fa fa-microphone-slash", 61745);
|
||||||
|
dict.Add("fa fa-minus", 61544);
|
||||||
|
dict.Add("fa fa-minus-circle", 61526);
|
||||||
|
dict.Add("fa fa-minus-square", 61766);
|
||||||
|
dict.Add("fa fa-minus-square-o", 61767);
|
||||||
|
dict.Add("fa fa-mobile", 61707);
|
||||||
|
dict.Add("fa fa-mobile-phone", 61707);
|
||||||
|
dict.Add("fa fa-money", 61654);
|
||||||
|
dict.Add("fa fa-moon-o", 61830);
|
||||||
|
dict.Add("fa fa-mortar-board", 61853);
|
||||||
|
dict.Add("fa fa-motorcycle", 61980);
|
||||||
|
dict.Add("fa fa-mouse-pointer", 62021);
|
||||||
|
dict.Add("fa fa-music", 61441);
|
||||||
|
dict.Add("fa fa-navicon", 61641);
|
||||||
|
dict.Add("fa fa-newspaper-o", 61930);
|
||||||
|
dict.Add("fa fa-object-group", 62023);
|
||||||
|
dict.Add("fa fa-object-ungroup", 62024);
|
||||||
|
dict.Add("fa fa-paint-brush", 61948);
|
||||||
|
dict.Add("fa fa-paper-plane", 61912);
|
||||||
|
dict.Add("fa fa-paper-plane-o", 61913);
|
||||||
|
dict.Add("fa fa-paw", 61872);
|
||||||
|
dict.Add("fa fa-pencil", 61504);
|
||||||
|
dict.Add("fa fa-pencil-square", 61771);
|
||||||
|
dict.Add("fa fa-pencil-square-o", 61508);
|
||||||
|
dict.Add("fa fa-phone", 61589);
|
||||||
|
dict.Add("fa fa-phone-square", 61592);
|
||||||
|
dict.Add("fa fa-photo", 61502);
|
||||||
|
dict.Add("fa fa-picture-o", 61502);
|
||||||
|
dict.Add("fa fa-pie-chart", 61952);
|
||||||
|
dict.Add("fa fa-plane", 61554);
|
||||||
|
dict.Add("fa fa-plug", 61926);
|
||||||
|
dict.Add("fa fa-plus", 61543);
|
||||||
|
dict.Add("fa fa-plus-circle", 61525);
|
||||||
|
dict.Add("fa fa-plus-square", 61694);
|
||||||
|
dict.Add("fa fa-plus-square-o", 61846);
|
||||||
|
dict.Add("fa fa-power-off", 61457);
|
||||||
|
dict.Add("fa fa-print", 61487);
|
||||||
|
dict.Add("fa fa-puzzle-piece", 61742);
|
||||||
|
dict.Add("fa fa-qrcode", 61481);
|
||||||
|
dict.Add("fa fa-question", 61736);
|
||||||
|
dict.Add("fa fa-question-circle", 61529);
|
||||||
|
dict.Add("fa fa-quote-left", 61709);
|
||||||
|
dict.Add("fa fa-quote-right", 61710);
|
||||||
|
dict.Add("fa fa-random", 61556);
|
||||||
|
dict.Add("fa fa-recycle", 61880);
|
||||||
|
dict.Add("fa fa-refresh", 61473);
|
||||||
|
dict.Add("fa fa-registered", 62045);
|
||||||
|
dict.Add("fa fa-remove", 61453);
|
||||||
|
dict.Add("fa fa-reorder", 61641);
|
||||||
|
dict.Add("fa fa-reply", 61714);
|
||||||
|
dict.Add("fa fa-reply-all", 61730);
|
||||||
|
dict.Add("fa fa-retweet", 61561);
|
||||||
|
dict.Add("fa fa-road", 61464);
|
||||||
|
dict.Add("fa fa-rocket", 61749);
|
||||||
|
dict.Add("fa fa-rss", 61598);
|
||||||
|
dict.Add("fa fa-rss-square", 61763);
|
||||||
|
dict.Add("fa fa-search", 61442);
|
||||||
|
dict.Add("fa fa-search-minus", 61456);
|
||||||
|
dict.Add("fa fa-search-plus", 61454);
|
||||||
|
dict.Add("fa fa-send", 61912);
|
||||||
|
dict.Add("fa fa-send-o", 61913);
|
||||||
|
dict.Add("fa fa-server", 62003);
|
||||||
|
dict.Add("fa fa-share", 61540);
|
||||||
|
dict.Add("fa fa-share-alt", 61920);
|
||||||
|
dict.Add("fa fa-share-alt-square", 61921);
|
||||||
|
dict.Add("fa fa-share-square", 61773);
|
||||||
|
dict.Add("fa fa-share-square-o", 61509);
|
||||||
|
dict.Add("fa fa-shield", 61746);
|
||||||
|
dict.Add("fa fa-ship", 61978);
|
||||||
|
dict.Add("fa fa-shopping-cart", 61562);
|
||||||
|
dict.Add("fa fa-sign-in", 61584);
|
||||||
|
dict.Add("fa fa-sign-out", 61579);
|
||||||
|
dict.Add("fa fa-signal", 61458);
|
||||||
|
dict.Add("fa fa-sitemap", 61672);
|
||||||
|
dict.Add("fa fa-sliders", 61918);
|
||||||
|
dict.Add("fa fa-smile-o", 61720);
|
||||||
|
dict.Add("fa fa-soccer-ball-o", 61923);
|
||||||
|
dict.Add("fa fa-sort", 61660);
|
||||||
|
dict.Add("fa fa-sort-alpha-asc", 61789);
|
||||||
|
dict.Add("fa fa-sort-alpha-desc", 61790);
|
||||||
|
dict.Add("fa fa-sort-amount-asc", 61792);
|
||||||
|
dict.Add("fa fa-sort-amount-desc", 61793);
|
||||||
|
dict.Add("fa fa-sort-asc", 61662);
|
||||||
|
dict.Add("fa fa-sort-desc", 61661);
|
||||||
|
dict.Add("fa fa-sort-down", 61661);
|
||||||
|
dict.Add("fa fa-sort-numeric-asc", 61794);
|
||||||
|
dict.Add("fa fa-sort-numeric-desc", 61795);
|
||||||
|
dict.Add("fa fa-sort-up", 61662);
|
||||||
|
dict.Add("fa fa-space-shuttle", 61847);
|
||||||
|
dict.Add("fa fa-spoon", 61873);
|
||||||
|
dict.Add("fa fa-square", 61640);
|
||||||
|
dict.Add("fa fa-square-o", 61590);
|
||||||
|
dict.Add("fa fa-star", 61445);
|
||||||
|
dict.Add("fa fa-star-half", 61577);
|
||||||
|
dict.Add("fa fa-star-half-empty", 61731);
|
||||||
|
dict.Add("fa fa-star-half-full", 61731);
|
||||||
|
dict.Add("fa fa-star-half-o", 61731);
|
||||||
|
dict.Add("fa fa-star-o", 61446);
|
||||||
|
dict.Add("fa fa-sticky-note", 62025);
|
||||||
|
dict.Add("fa fa-sticky-note-o", 62026);
|
||||||
|
dict.Add("fa fa-street-view", 61981);
|
||||||
|
dict.Add("fa fa-suitcase", 61682);
|
||||||
|
dict.Add("fa fa-sun-o", 61829);
|
||||||
|
dict.Add("fa fa-support", 61901);
|
||||||
|
dict.Add("fa fa-tablet", 61706);
|
||||||
|
dict.Add("fa fa-tachometer", 61668);
|
||||||
|
dict.Add("fa fa-tag", 61483);
|
||||||
|
dict.Add("fa fa-tags", 61484);
|
||||||
|
dict.Add("fa fa-tasks", 61614);
|
||||||
|
dict.Add("fa fa-taxi", 61882);
|
||||||
|
dict.Add("fa fa-television", 62060);
|
||||||
|
dict.Add("fa fa-terminal", 61728);
|
||||||
|
dict.Add("fa fa-thumb-tack", 61581);
|
||||||
|
dict.Add("fa fa-thumbs-down", 61797);
|
||||||
|
dict.Add("fa fa-thumbs-o-down", 61576);
|
||||||
|
dict.Add("fa fa-thumbs-o-up", 61575);
|
||||||
|
dict.Add("fa fa-thumbs-up", 61796);
|
||||||
|
dict.Add("fa fa-ticket", 61765);
|
||||||
|
dict.Add("fa fa-times", 61453);
|
||||||
|
dict.Add("fa fa-times-circle", 61527);
|
||||||
|
dict.Add("fa fa-times-circle-o", 61532);
|
||||||
|
dict.Add("fa fa-tint", 61507);
|
||||||
|
dict.Add("fa fa-toggle-down", 61776);
|
||||||
|
dict.Add("fa fa-toggle-left", 61841);
|
||||||
|
dict.Add("fa fa-toggle-off", 61956);
|
||||||
|
dict.Add("fa fa-toggle-on", 61957);
|
||||||
|
dict.Add("fa fa-toggle-right", 61778);
|
||||||
|
dict.Add("fa fa-toggle-up", 61777);
|
||||||
|
dict.Add("fa fa-trademark", 62044);
|
||||||
|
dict.Add("fa fa-trash", 61944);
|
||||||
|
dict.Add("fa fa-trash-o", 61460);
|
||||||
|
dict.Add("fa fa-tree", 61883);
|
||||||
|
dict.Add("fa fa-trophy", 61585);
|
||||||
|
dict.Add("fa fa-truck", 61649);
|
||||||
|
dict.Add("fa fa-tty", 61924);
|
||||||
|
dict.Add("fa fa-tv", 62060);
|
||||||
|
dict.Add("fa fa-umbrella", 61673);
|
||||||
|
dict.Add("fa fa-university", 61852);
|
||||||
|
dict.Add("fa fa-unlock", 61596);
|
||||||
|
dict.Add("fa fa-unlock-alt", 61758);
|
||||||
|
dict.Add("fa fa-unsorted", 61660);
|
||||||
|
dict.Add("fa fa-upload", 61587);
|
||||||
|
dict.Add("fa fa-user", 61447);
|
||||||
|
dict.Add("fa fa-user-plus", 62004);
|
||||||
|
dict.Add("fa fa-user-secret", 61979);
|
||||||
|
dict.Add("fa fa-user-times", 62005);
|
||||||
|
dict.Add("fa fa-users", 61632);
|
||||||
|
dict.Add("fa fa-video-camera", 61501);
|
||||||
|
dict.Add("fa fa-volume-down", 61479);
|
||||||
|
dict.Add("fa fa-volume-off", 61478);
|
||||||
|
dict.Add("fa fa-volume-up", 61480);
|
||||||
|
dict.Add("fa fa-warning", 61553);
|
||||||
|
dict.Add("fa fa-wheelchair", 61843);
|
||||||
|
dict.Add("fa fa-wifi", 61931);
|
||||||
|
dict.Add("fa fa-wrench", 61613);
|
||||||
|
dict.Add("fa fa-hand-o-down", 61607);
|
||||||
|
dict.Add("fa fa-hand-o-left", 61605);
|
||||||
|
dict.Add("fa fa-hand-o-right", 61604);
|
||||||
|
dict.Add("fa fa-hand-o-up", 61606);
|
||||||
|
dict.Add("fa fa-ambulance", 61689);
|
||||||
|
dict.Add("fa fa-subway", 62009);
|
||||||
|
dict.Add("fa fa-train", 62008);
|
||||||
|
dict.Add("fa fa-genderless", 61997);
|
||||||
|
dict.Add("fa fa-intersex", 61988);
|
||||||
|
dict.Add("fa fa-mars", 61986);
|
||||||
|
dict.Add("fa fa-mars-double", 61991);
|
||||||
|
dict.Add("fa fa-mars-stroke", 61993);
|
||||||
|
dict.Add("fa fa-mars-stroke-h", 61995);
|
||||||
|
dict.Add("fa fa-mars-stroke-v", 61994);
|
||||||
|
dict.Add("fa fa-mercury", 61987);
|
||||||
|
dict.Add("fa fa-neuter", 61996);
|
||||||
|
dict.Add("fa fa-transgender", 61988);
|
||||||
|
dict.Add("fa fa-transgender-alt", 61989);
|
||||||
|
dict.Add("fa fa-venus", 61985);
|
||||||
|
dict.Add("fa fa-venus-double", 61990);
|
||||||
|
dict.Add("fa fa-venus-mars", 61992);
|
||||||
|
dict.Add("fa fa-file", 61787);
|
||||||
|
dict.Add("fa fa-file-o", 61462);
|
||||||
|
dict.Add("fa fa-file-text", 61788);
|
||||||
|
dict.Add("fa fa-file-text-o", 61686);
|
||||||
|
dict.Add("fa fa-cc-amex", 61939);
|
||||||
|
dict.Add("fa fa-cc-diners-club", 62028);
|
||||||
|
dict.Add("fa fa-cc-discover", 61938);
|
||||||
|
dict.Add("fa fa-cc-jcb", 62027);
|
||||||
|
dict.Add("fa fa-cc-mastercard", 61937);
|
||||||
|
dict.Add("fa fa-cc-paypal", 61940);
|
||||||
|
dict.Add("fa fa-cc-stripe", 61941);
|
||||||
|
dict.Add("fa fa-cc-visa", 61936);
|
||||||
|
dict.Add("fa fa-google-wallet", 61934);
|
||||||
|
dict.Add("fa fa-paypal", 61933);
|
||||||
|
dict.Add("fa fa-bitcoin", 61786);
|
||||||
|
dict.Add("fa fa-btc", 61786);
|
||||||
|
dict.Add("fa fa-cny", 61783);
|
||||||
|
dict.Add("fa fa-dollar", 61781);
|
||||||
|
dict.Add("fa fa-eur", 61779);
|
||||||
|
dict.Add("fa fa-euro", 61779);
|
||||||
|
dict.Add("fa fa-gbp", 61780);
|
||||||
|
dict.Add("fa fa-gg", 62048);
|
||||||
|
dict.Add("fa fa-gg-circle", 62049);
|
||||||
|
dict.Add("fa fa-ils", 61963);
|
||||||
|
dict.Add("fa fa-inr", 61782);
|
||||||
|
dict.Add("fa fa-jpy", 61783);
|
||||||
|
dict.Add("fa fa-krw", 61785);
|
||||||
|
dict.Add("fa fa-rmb", 61783);
|
||||||
|
dict.Add("fa fa-rouble", 61784);
|
||||||
|
dict.Add("fa fa-rub", 61784);
|
||||||
|
dict.Add("fa fa-ruble", 61784);
|
||||||
|
dict.Add("fa fa-rupee", 61782);
|
||||||
|
dict.Add("fa fa-shekel", 61963);
|
||||||
|
dict.Add("fa fa-sheqel", 61963);
|
||||||
|
dict.Add("fa fa-try", 61845);
|
||||||
|
dict.Add("fa fa-turkish-lira", 61845);
|
||||||
|
dict.Add("fa fa-usd", 61781);
|
||||||
|
dict.Add("fa fa-won", 61785);
|
||||||
|
dict.Add("fa fa-yen", 61783);
|
||||||
|
dict.Add("fa fa-align-center", 61495);
|
||||||
|
dict.Add("fa fa-align-justify", 61497);
|
||||||
|
dict.Add("fa fa-align-left", 61494);
|
||||||
|
dict.Add("fa fa-align-right", 61496);
|
||||||
|
dict.Add("fa fa-bold", 61490);
|
||||||
|
dict.Add("fa fa-chain", 61633);
|
||||||
|
dict.Add("fa fa-chain-broken", 61735);
|
||||||
|
dict.Add("fa fa-clipboard", 61674);
|
||||||
|
dict.Add("fa fa-columns", 61659);
|
||||||
|
dict.Add("fa fa-copy", 61637);
|
||||||
|
dict.Add("fa fa-cut", 61636);
|
||||||
|
dict.Add("fa fa-dedent", 61499);
|
||||||
|
dict.Add("fa fa-files-o", 61637);
|
||||||
|
dict.Add("fa fa-floppy-o", 61639);
|
||||||
|
dict.Add("fa fa-font", 61489);
|
||||||
|
dict.Add("fa fa-header", 61916);
|
||||||
|
dict.Add("fa fa-indent", 61500);
|
||||||
|
dict.Add("fa fa-italic", 61491);
|
||||||
|
dict.Add("fa fa-link", 61633);
|
||||||
|
dict.Add("fa fa-list", 61498);
|
||||||
|
dict.Add("fa fa-list-alt", 61474);
|
||||||
|
dict.Add("fa fa-list-ol", 61643);
|
||||||
|
dict.Add("fa fa-list-ul", 61642);
|
||||||
|
dict.Add("fa fa-outdent", 61499);
|
||||||
|
dict.Add("fa fa-paperclip", 61638);
|
||||||
|
dict.Add("fa fa-paragraph", 61917);
|
||||||
|
dict.Add("fa fa-paste", 61674);
|
||||||
|
dict.Add("fa fa-repeat", 61470);
|
||||||
|
dict.Add("fa fa-rotate-left", 61666);
|
||||||
|
dict.Add("fa fa-rotate-right", 61470);
|
||||||
|
dict.Add("fa fa-save", 61639);
|
||||||
|
dict.Add("fa fa-scissors", 61636);
|
||||||
|
dict.Add("fa fa-strikethrough", 61644);
|
||||||
|
dict.Add("fa fa-subscript", 61740);
|
||||||
|
dict.Add("fa fa-superscript", 61739);
|
||||||
|
dict.Add("fa fa-table", 61646);
|
||||||
|
dict.Add("fa fa-text-height", 61492);
|
||||||
|
dict.Add("fa fa-text-width", 61493);
|
||||||
|
dict.Add("fa fa-th", 61450);
|
||||||
|
dict.Add("fa fa-th-large", 61449);
|
||||||
|
dict.Add("fa fa-th-list", 61451);
|
||||||
|
dict.Add("fa fa-underline", 61645);
|
||||||
|
dict.Add("fa fa-undo", 61666);
|
||||||
|
dict.Add("fa fa-unlink", 61735);
|
||||||
|
dict.Add("fa fa-angle-double-down", 61699);
|
||||||
|
dict.Add("fa fa-angle-double-left", 61696);
|
||||||
|
dict.Add("fa fa-angle-double-right", 61697);
|
||||||
|
dict.Add("fa fa-angle-double-up", 61698);
|
||||||
|
dict.Add("fa fa-angle-down", 61703);
|
||||||
|
dict.Add("fa fa-angle-left", 61700);
|
||||||
|
dict.Add("fa fa-angle-right", 61701);
|
||||||
|
dict.Add("fa fa-angle-up", 61702);
|
||||||
|
dict.Add("fa fa-arrow-circle-down", 61611);
|
||||||
|
dict.Add("fa fa-arrow-circle-left", 61608);
|
||||||
|
dict.Add("fa fa-arrow-circle-o-down", 61466);
|
||||||
|
dict.Add("fa fa-arrow-circle-o-left", 61840);
|
||||||
|
dict.Add("fa fa-arrow-circle-o-right", 61838);
|
||||||
|
dict.Add("fa fa-arrow-circle-o-up", 61467);
|
||||||
|
dict.Add("fa fa-arrow-circle-right", 61609);
|
||||||
|
dict.Add("fa fa-arrow-circle-up", 61610);
|
||||||
|
dict.Add("fa fa-arrow-down", 61539);
|
||||||
|
dict.Add("fa fa-arrow-left", 61536);
|
||||||
|
dict.Add("fa fa-arrow-right", 61537);
|
||||||
|
dict.Add("fa fa-arrow-up", 61538);
|
||||||
|
dict.Add("fa fa-arrows-alt", 61618);
|
||||||
|
dict.Add("fa fa-caret-down", 61655);
|
||||||
|
dict.Add("fa fa-caret-left", 61657);
|
||||||
|
dict.Add("fa fa-caret-right", 61658);
|
||||||
|
dict.Add("fa fa-caret-up", 61656);
|
||||||
|
dict.Add("fa fa-chevron-circle-down", 61754);
|
||||||
|
dict.Add("fa fa-chevron-circle-left", 61751);
|
||||||
|
dict.Add("fa fa-chevron-circle-right", 61752);
|
||||||
|
dict.Add("fa fa-chevron-circle-up", 61753);
|
||||||
|
dict.Add("fa fa-chevron-down", 61560);
|
||||||
|
dict.Add("fa fa-chevron-left", 61523);
|
||||||
|
dict.Add("fa fa-chevron-right", 61524);
|
||||||
|
dict.Add("fa fa-chevron-up", 61559);
|
||||||
|
dict.Add("fa fa-long-arrow-down", 61813);
|
||||||
|
dict.Add("fa fa-long-arrow-left", 61815);
|
||||||
|
dict.Add("fa fa-long-arrow-right", 61816);
|
||||||
|
dict.Add("fa fa-long-arrow-up", 61814);
|
||||||
|
dict.Add("fa fa-backward", 61514);
|
||||||
|
dict.Add("fa fa-compress", 61542);
|
||||||
|
dict.Add("fa fa-eject", 61522);
|
||||||
|
dict.Add("fa fa-expand", 61541);
|
||||||
|
dict.Add("fa fa-fast-backward", 61513);
|
||||||
|
dict.Add("fa fa-fast-forward", 61520);
|
||||||
|
dict.Add("fa fa-forward", 61518);
|
||||||
|
dict.Add("fa fa-pause", 61516);
|
||||||
|
dict.Add("fa fa-play", 61515);
|
||||||
|
dict.Add("fa fa-play-circle", 61764);
|
||||||
|
dict.Add("fa fa-play-circle-o", 61469);
|
||||||
|
dict.Add("fa fa-step-backward", 61512);
|
||||||
|
dict.Add("fa fa-step-forward", 61521);
|
||||||
|
dict.Add("fa fa-stop", 61517);
|
||||||
|
dict.Add("fa fa-youtube-play", 61802);
|
||||||
|
dict.Add("fa fa-500px", 62062);
|
||||||
|
dict.Add("fa fa-adn", 61808);
|
||||||
|
dict.Add("fa fa-amazon", 62064);
|
||||||
|
dict.Add("fa fa-android", 61819);
|
||||||
|
dict.Add("fa fa-angellist", 61961);
|
||||||
|
dict.Add("fa fa-apple", 61817);
|
||||||
|
dict.Add("fa fa-behance", 61876);
|
||||||
|
dict.Add("fa fa-behance-square", 61877);
|
||||||
|
dict.Add("fa fa-bitbucket", 61809);
|
||||||
|
dict.Add("fa fa-bitbucket-square", 61810);
|
||||||
|
dict.Add("fa fa-black-tie", 62078);
|
||||||
|
dict.Add("fa fa-buysellads", 61965);
|
||||||
|
dict.Add("fa fa-chrome", 62056);
|
||||||
|
dict.Add("fa fa-codepen", 61899);
|
||||||
|
dict.Add("fa fa-connectdevelop", 61966);
|
||||||
|
dict.Add("fa fa-contao", 62061);
|
||||||
|
dict.Add("fa fa-css3", 61756);
|
||||||
|
dict.Add("fa fa-dashcube", 61968);
|
||||||
|
dict.Add("fa fa-delicious", 61861);
|
||||||
|
dict.Add("fa fa-deviantart", 61885);
|
||||||
|
dict.Add("fa fa-digg", 61862);
|
||||||
|
dict.Add("fa fa-dribbble", 61821);
|
||||||
|
dict.Add("fa fa-dropbox", 61803);
|
||||||
|
dict.Add("fa fa-drupal", 61865);
|
||||||
|
dict.Add("fa fa-empire", 61905);
|
||||||
|
dict.Add("fa fa-expeditedssl", 62014);
|
||||||
|
dict.Add("fa fa-facebook", 61594);
|
||||||
|
dict.Add("fa fa-facebook-f", 61594);
|
||||||
|
dict.Add("fa fa-facebook-official", 62000);
|
||||||
|
dict.Add("fa fa-facebook-square", 61570);
|
||||||
|
dict.Add("fa fa-firefox", 62057);
|
||||||
|
dict.Add("fa fa-flickr", 61806);
|
||||||
|
dict.Add("fa fa-fonticons", 62080);
|
||||||
|
dict.Add("fa fa-forumbee", 61969);
|
||||||
|
dict.Add("fa fa-foursquare", 61824);
|
||||||
|
dict.Add("fa fa-ge", 61905);
|
||||||
|
dict.Add("fa fa-get-pocket", 62053);
|
||||||
|
dict.Add("fa fa-git", 61907);
|
||||||
|
dict.Add("fa fa-git-square", 61906);
|
||||||
|
dict.Add("fa fa-github", 61595);
|
||||||
|
dict.Add("fa fa-github-alt", 61715);
|
||||||
|
dict.Add("fa fa-github-square", 61586);
|
||||||
|
dict.Add("fa fa-gittip", 61828);
|
||||||
|
dict.Add("fa fa-google", 61856);
|
||||||
|
dict.Add("fa fa-google-plus", 61653);
|
||||||
|
dict.Add("fa fa-google-plus-square", 61652);
|
||||||
|
dict.Add("fa fa-gratipay", 61828);
|
||||||
|
dict.Add("fa fa-hacker-news", 61908);
|
||||||
|
dict.Add("fa fa-houzz", 62076);
|
||||||
|
dict.Add("fa fa-html5", 61755);
|
||||||
|
dict.Add("fa fa-instagram", 61805);
|
||||||
|
dict.Add("fa fa-internet-explorer", 62059);
|
||||||
|
dict.Add("fa fa-ioxhost", 61960);
|
||||||
|
dict.Add("fa fa-joomla", 61866);
|
||||||
|
dict.Add("fa fa-jsfiddle", 61900);
|
||||||
|
dict.Add("fa fa-lastfm", 61954);
|
||||||
|
dict.Add("fa fa-lastfm-square", 61955);
|
||||||
|
dict.Add("fa fa-leanpub", 61970);
|
||||||
|
dict.Add("fa fa-linkedin", 61665);
|
||||||
|
dict.Add("fa fa-linkedin-square", 61580);
|
||||||
|
dict.Add("fa fa-linux", 61820);
|
||||||
|
dict.Add("fa fa-maxcdn", 61750);
|
||||||
|
dict.Add("fa fa-meanpath", 61964);
|
||||||
|
dict.Add("fa fa-medium", 62010);
|
||||||
|
dict.Add("fa fa-odnoklassniki", 62051);
|
||||||
|
dict.Add("fa fa-odnoklassniki-square", 62052);
|
||||||
|
dict.Add("fa fa-opencart", 62013);
|
||||||
|
dict.Add("fa fa-openid", 61851);
|
||||||
|
dict.Add("fa fa-opera", 62058);
|
||||||
|
dict.Add("fa fa-optin-monster", 62012);
|
||||||
|
dict.Add("fa fa-pagelines", 61836);
|
||||||
|
dict.Add("fa fa-pied-piper", 62126);
|
||||||
|
dict.Add("fa fa-pied-piper-alt", 61864);
|
||||||
|
dict.Add("fa fa-pinterest", 61650);
|
||||||
|
dict.Add("fa fa-pinterest-p", 62001);
|
||||||
|
dict.Add("fa fa-pinterest-square", 61651);
|
||||||
|
dict.Add("fa fa-qq", 61910);
|
||||||
|
dict.Add("fa fa-ra", 61904);
|
||||||
|
dict.Add("fa fa-rebel", 61904);
|
||||||
|
dict.Add("fa fa-reddit", 61857);
|
||||||
|
dict.Add("fa fa-reddit-square", 61858);
|
||||||
|
dict.Add("fa fa-renren", 61835);
|
||||||
|
dict.Add("fa fa-safari", 62055);
|
||||||
|
dict.Add("fa fa-sellsy", 61971);
|
||||||
|
dict.Add("fa fa-shirtsinbulk", 61972);
|
||||||
|
dict.Add("fa fa-simplybuilt", 61973);
|
||||||
|
dict.Add("fa fa-skyatlas", 61974);
|
||||||
|
dict.Add("fa fa-skype", 61822);
|
||||||
|
dict.Add("fa fa-slack", 61848);
|
||||||
|
dict.Add("fa fa-slideshare", 61927);
|
||||||
|
dict.Add("fa fa-soundcloud", 61886);
|
||||||
|
dict.Add("fa fa-spotify", 61884);
|
||||||
|
dict.Add("fa fa-stack-exchange", 61837);
|
||||||
|
dict.Add("fa fa-stack-overflow", 61804);
|
||||||
|
dict.Add("fa fa-steam", 61878);
|
||||||
|
dict.Add("fa fa-steam-square", 61879);
|
||||||
|
dict.Add("fa fa-stumbleupon", 61860);
|
||||||
|
dict.Add("fa fa-stumbleupon-circle", 61859);
|
||||||
|
dict.Add("fa fa-tencent-weibo", 61909);
|
||||||
|
dict.Add("fa fa-trello", 61825);
|
||||||
|
dict.Add("fa fa-tripadvisor", 62050);
|
||||||
|
dict.Add("fa fa-tumblr", 61811);
|
||||||
|
dict.Add("fa fa-tumblr-square", 61812);
|
||||||
|
dict.Add("fa fa-twitch", 61928);
|
||||||
|
dict.Add("fa fa-twitter", 61593);
|
||||||
|
dict.Add("fa fa-twitter-square", 61569);
|
||||||
|
dict.Add("fa fa-viacoin", 62007);
|
||||||
|
dict.Add("fa fa-vimeo", 62077);
|
||||||
|
dict.Add("fa fa-vimeo-square", 61844);
|
||||||
|
dict.Add("fa fa-vine", 61898);
|
||||||
|
dict.Add("fa fa-vk", 61833);
|
||||||
|
dict.Add("fa fa-wechat", 61911);
|
||||||
|
dict.Add("fa fa-weibo", 61834);
|
||||||
|
dict.Add("fa fa-weixin", 61911);
|
||||||
|
dict.Add("fa fa-whatsapp", 62002);
|
||||||
|
dict.Add("fa fa-wikipedia-w", 62054);
|
||||||
|
dict.Add("fa fa-windows", 61818);
|
||||||
|
dict.Add("fa fa-wordpress", 61850);
|
||||||
|
dict.Add("fa fa-xing", 61800);
|
||||||
|
dict.Add("fa fa-xing-square", 61801);
|
||||||
|
dict.Add("fa fa-y-combinator", 62011);
|
||||||
|
dict.Add("fa fa-y-combinator-square", 61908);
|
||||||
|
dict.Add("fa fa-yahoo", 61854);
|
||||||
|
dict.Add("fa fa-yc", 62011);
|
||||||
|
dict.Add("fa fa-yc-square", 61908);
|
||||||
|
dict.Add("fa fa-yelp", 61929);
|
||||||
|
dict.Add("fa fa-youtube", 61799);
|
||||||
|
dict.Add("fa fa-youtube-square", 61798);
|
||||||
|
dict.Add("fa fa-h-square", 61693);
|
||||||
|
dict.Add("fa fa-hospital-o", 61688);
|
||||||
|
dict.Add("fa fa-medkit", 61690);
|
||||||
|
dict.Add("fa fa-stethoscope", 61681);
|
||||||
|
dict.Add("fa fa-user-md", 61680);
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
45
DH.RBAC/Common/MyConfig.cs
Normal file
45
DH.RBAC/Common/MyConfig.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Common
|
||||||
|
{
|
||||||
|
public class MyConfig
|
||||||
|
{
|
||||||
|
public int EveryPageDataCount { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 数据库类型
|
||||||
|
/// </summary>
|
||||||
|
public string DbType { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 数据库主机IP
|
||||||
|
/// </summary>
|
||||||
|
public string DbHost { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据库名
|
||||||
|
/// </summary>
|
||||||
|
public string DbName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据库用户名
|
||||||
|
/// </summary>
|
||||||
|
public string DbUserName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据库密码
|
||||||
|
/// </summary>
|
||||||
|
public string DbPassword { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
private bool _debug = false;
|
||||||
|
/// <summary>
|
||||||
|
/// 是否调试模式,调试模式将会输出日志
|
||||||
|
/// </summary>
|
||||||
|
public bool Debug { get { return _debug; } set { _debug = value; } }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
145
DH.RBAC/DH.RBAC.csproj
Normal file
145
DH.RBAC/DH.RBAC.csproj
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
|
<EnableDefaultCompileItems>false</EnableDefaultCompileItems>
|
||||||
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
|
<Nullable>enable</Nullable>
|
||||||
|
<BaseOutputPath>..\</BaseOutputPath>
|
||||||
|
<AppendTargetFrameworkToOutputPath>output</AppendTargetFrameworkToOutputPath>
|
||||||
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Include="AccountForm.cs" />
|
||||||
|
<Compile Include="AccountForm.Designer.cs" />
|
||||||
|
<Compile Include="Common\GlobalConfig.cs" />
|
||||||
|
<Compile Include="Common\IconDict.cs" />
|
||||||
|
<Compile Include="Common\MyConfig.cs" />
|
||||||
|
<Compile Include="Logic\BaseLogic.cs" />
|
||||||
|
<Compile Include="Logic\Logger.cs" />
|
||||||
|
<Compile Include="Logic\Sys\SysItemLogic.cs" />
|
||||||
|
<Compile Include="Logic\Sys\SysItemsDetailLogic.cs" />
|
||||||
|
<Compile Include="Logic\Sys\SysLogLogic.cs" />
|
||||||
|
<Compile Include="Logic\Sys\SysOrganizeLogic.cs" />
|
||||||
|
<Compile Include="Logic\Sys\SysPermissionLogic.cs" />
|
||||||
|
<Compile Include="Logic\Sys\SysRoleAuthorizeLogic.cs" />
|
||||||
|
<Compile Include="Logic\Sys\SysRoleLogic.cs" />
|
||||||
|
<Compile Include="Logic\Sys\SysUserLogic.cs" />
|
||||||
|
<Compile Include="Logic\Sys\SysUserLogOnLogic.cs" />
|
||||||
|
<Compile Include="Logic\Sys\SysUserRoleRelationLogic.cs" />
|
||||||
|
<Compile Include="Models\Base\BaseModelEntity.cs" />
|
||||||
|
<Compile Include="Models\Base\CodeGenerator.cs" />
|
||||||
|
<Compile Include="Models\Base\MenuControlAttribute.cs" />
|
||||||
|
<Compile Include="Models\DTO\Parms\AuthorParms.cs" />
|
||||||
|
<Compile Include="Models\DTO\Parms\FileUploadParms.cs" />
|
||||||
|
<Compile Include="Models\DTO\Parms\ItemDetailIndexParms.cs" />
|
||||||
|
<Compile Include="Models\DTO\Parms\KeyValue.cs" />
|
||||||
|
<Compile Include="Models\DTO\Parms\LogDeleteParms.cs" />
|
||||||
|
<Compile Include="Models\DTO\Parms\LogIndexParms.cs" />
|
||||||
|
<Compile Include="Models\DTO\Parms\LongPrimaryKeyParms.cs" />
|
||||||
|
<Compile Include="Models\DTO\Parms\ModifyPasswordParms.cs" />
|
||||||
|
<Compile Include="Models\DTO\Parms\RoleDeleteParms.cs" />
|
||||||
|
<Compile Include="Models\DTO\Parms\SearchParms.cs" />
|
||||||
|
<Compile Include="Models\DTO\Parms\StrPrimaryKeyParms.cs" />
|
||||||
|
<Compile Include="Models\DTO\Parms\UserDeleteParms.cs" />
|
||||||
|
<Compile Include="Models\DTO\Parms\UserLoginParms.cs" />
|
||||||
|
<Compile Include="Models\Enum\ModuleType.cs" />
|
||||||
|
<Compile Include="Models\Sys\SysItem.cs" />
|
||||||
|
<Compile Include="Models\Sys\SysItemDetail.cs" />
|
||||||
|
<Compile Include="Models\Sys\SysLog.cs" />
|
||||||
|
<Compile Include="Models\Sys\SysOrganize.cs" />
|
||||||
|
<Compile Include="Models\Sys\SysPermission.cs" />
|
||||||
|
<Compile Include="Models\Sys\SysRole.cs" />
|
||||||
|
<Compile Include="Models\Sys\SysRoleAuthorize.cs" />
|
||||||
|
<Compile Include="Models\Sys\SysUser.cs" />
|
||||||
|
<Compile Include="Models\Sys\SysUserLogOn.cs" />
|
||||||
|
<Compile Include="Models\Sys\SysUserRoleRelation.cs" />
|
||||||
|
<Compile Include="Properties\Resources.Designer.cs" />
|
||||||
|
<Compile Include="RBACWindow.cs" />
|
||||||
|
<Compile Include="RBACWindow.Designer.cs" />
|
||||||
|
<Compile Include="UserControls\AccountControl.cs" />
|
||||||
|
<Compile Include="UserControls\AccountControl.Designer.cs" />
|
||||||
|
<Compile Include="UserControls\Menus\UserMenuPanel.cs" />
|
||||||
|
<Compile Include="UserControls\ProgressForm.cs" />
|
||||||
|
<Compile Include="UserControls\ProgressForm.Designer.cs" />
|
||||||
|
<Compile Include="Utility\Extension\ExtMethods.cs" />
|
||||||
|
<Compile Include="Utility\Extension\MyEnvironment.cs" />
|
||||||
|
<Compile Include="Utility\Other\DESHelper.cs" />
|
||||||
|
<Compile Include="Utility\Other\FormHelper.cs" />
|
||||||
|
<Compile Include="Utility\Other\JsonHelper.cs" />
|
||||||
|
<Compile Include="Utility\Other\MD5Helper.cs" />
|
||||||
|
<Compile Include="Utility\Other\PanelScrollHelper.cs" />
|
||||||
|
<Compile Include="Utility\Other\ScreenUtils.cs" />
|
||||||
|
<Compile Include="Utility\Other\SnowFlakeHelper.cs" />
|
||||||
|
<Compile Include="Utility\Other\StringHelper.cs" />
|
||||||
|
<Compile Include="Utility\Other\TreeSelect.cs" />
|
||||||
|
<Compile Include="Utility\Other\UIUtils.cs" />
|
||||||
|
<Compile Include="Utility\Other\UUID.cs" />
|
||||||
|
<Compile Include="Utility\Other\ZTreeNode.cs" />
|
||||||
|
<Compile Include="Utility\PopupTool\GripBounds.cs" />
|
||||||
|
<Compile Include="Utility\PopupTool\Popup.cs" />
|
||||||
|
<Compile Include="Utility\PopupTool\UnsafeMethods.cs" />
|
||||||
|
<Compile Include="Views\DefaultPage.cs" />
|
||||||
|
<Compile Include="Views\DefaultPage.Designer.cs" />
|
||||||
|
<Compile Include="Views\EmptyPage.cs" />
|
||||||
|
<Compile Include="Views\EmptyPage.Designer.cs" />
|
||||||
|
<Compile Include="Views\MyPage.cs" />
|
||||||
|
<Compile Include="Views\Sys\BaseSubForm.cs" />
|
||||||
|
<Compile Include="Views\Sys\BaseSubForm.Designer.cs" />
|
||||||
|
<Compile Include="Views\Sys\Organize\AddOrganizeForm.cs" />
|
||||||
|
<Compile Include="Views\Sys\Organize\AddOrganizeForm.Designer.cs" />
|
||||||
|
<Compile Include="Views\Sys\Organize\OrganizePage.cs" />
|
||||||
|
<Compile Include="Views\Sys\Organize\OrganizePage.Designer.cs" />
|
||||||
|
<Compile Include="Views\Sys\Permission\AddPermissionForm.cs" />
|
||||||
|
<Compile Include="Views\Sys\Permission\AddPermissionForm.Designer.cs" />
|
||||||
|
<Compile Include="Views\Sys\Permission\IconForm.cs" />
|
||||||
|
<Compile Include="Views\Sys\Permission\IconForm.Designer.cs" />
|
||||||
|
<Compile Include="Views\Sys\Permission\PermissionPage.cs" />
|
||||||
|
<Compile Include="Views\Sys\Permission\PermissionPage.Designer.cs" />
|
||||||
|
<Compile Include="Views\Sys\Role\AddRoleForm.cs" />
|
||||||
|
<Compile Include="Views\Sys\Role\AddRoleForm.Designer.cs" />
|
||||||
|
<Compile Include="Views\Sys\Role\RoleAuthorizeForm.cs" />
|
||||||
|
<Compile Include="Views\Sys\Role\RoleAuthorizeForm.Designer.cs" />
|
||||||
|
<Compile Include="Views\Sys\Role\RolePage.cs" />
|
||||||
|
<Compile Include="Views\Sys\Role\RolePage.Designer.cs" />
|
||||||
|
<Compile Include="Views\Sys\User\AddUserForm.cs" />
|
||||||
|
<Compile Include="Views\Sys\User\AddUserForm.Designer.cs" />
|
||||||
|
<Compile Include="Views\Sys\User\UserPage.cs" />
|
||||||
|
<Compile Include="Views\Sys\User\UserPage.Designer.cs" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="AntdUI" Version="1.8.9" />
|
||||||
|
<PackageReference Include="JinianNet.JNTemplate" Version="2.4.2" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
<PackageReference Include="SqlSugarCore" Version="5.1.4.185" />
|
||||||
|
<PackageReference Include="SunnyUI" Version="3.8.2" />
|
||||||
|
<PackageReference Include="System.Data.SqlClient" Version="4.9.0" />
|
||||||
|
<PackageReference Include="System.Data.SQLite" Version="1.0.119" />
|
||||||
|
<PackageReference Include="System.Drawing.Common" Version="9.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 自动生成 -->
|
||||||
|
<ItemGroup>
|
||||||
|
<Compile Update="Page\DefaultPage.cs" />
|
||||||
|
<Compile Update="Properties\Resources.Designer.cs">
|
||||||
|
<DesignTime>True</DesignTime>
|
||||||
|
<AutoGen>True</AutoGen>
|
||||||
|
<DependentUpon>Resources.resx</DependentUpon>
|
||||||
|
</Compile>
|
||||||
|
</ItemGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<EmbeddedResource Update="Properties\Resources.resx">
|
||||||
|
<Generator>ResXFileCodeGenerator</Generator>
|
||||||
|
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||||
|
</EmbeddedResource>
|
||||||
|
</ItemGroup>
|
||||||
|
<ProjectExtensions>
|
||||||
|
<VisualStudio>
|
||||||
|
<UserProperties configs_4config_1json__JsonSchema="" />
|
||||||
|
</VisualStudio>
|
||||||
|
</ProjectExtensions>
|
||||||
|
</Project>
|
303
DH.RBAC/Logic/BaseLogic.cs
Normal file
303
DH.RBAC/Logic/BaseLogic.cs
Normal file
@ -0,0 +1,303 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
using System.Data;
|
||||||
|
|
||||||
|
using DH.RBAC.Model.Base;
|
||||||
|
using JinianNet.JNTemplate;
|
||||||
|
using DH.RBAC.Utility.Other;
|
||||||
|
using DH.RBAC.Utility.Extension;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
namespace DH.RBAC.Logic.Base
|
||||||
|
{
|
||||||
|
public class BaseLogic
|
||||||
|
{
|
||||||
|
private static string ConnectionString;
|
||||||
|
private static SqlSugar.DbType DbType;
|
||||||
|
private static string DbName;
|
||||||
|
private static bool DebugMode;
|
||||||
|
|
||||||
|
public static bool InitDB(string dbType, string host, string dbName, string userName, string pasword, ref string message, bool debug = false)
|
||||||
|
{
|
||||||
|
DebugMode = debug;
|
||||||
|
DbName = dbName;
|
||||||
|
if (dbType.ToLower() == "SqlServer".ToLower())
|
||||||
|
{
|
||||||
|
DbType = SqlSugar.DbType.SqlServer;
|
||||||
|
ConnectionString = $"Data Source={host};Initial Catalog={dbName};User ID={userName};Password={pasword};";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (dbType.ToLower() == "MySql".ToLower())
|
||||||
|
{
|
||||||
|
DbType = SqlSugar.DbType.MySql;
|
||||||
|
ConnectionString = $"server={host};Database={dbName};Uid={userName};Pwd={pasword};";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (dbType.ToLower() == "Oracle".ToLower())
|
||||||
|
{
|
||||||
|
DbType = SqlSugar.DbType.Oracle;
|
||||||
|
ConnectionString = $"Data Source={host}/{dbName};User ID={userName};Password={pasword};";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (dbType.ToLower() == "PostgreSql".ToLower())
|
||||||
|
{
|
||||||
|
DbType = SqlSugar.DbType.PostgreSQL;
|
||||||
|
ConnectionString = $"Server={host};Port=5432;Database={dbName};User Id={userName};Password={pasword};";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (dbType.ToLower() == "Sqlite".ToLower())
|
||||||
|
{
|
||||||
|
DbType = SqlSugar.DbType.Sqlite;
|
||||||
|
|
||||||
|
var template = Engine.CreateTemplate(dbName);
|
||||||
|
template.Set("BaseDirectory", MyEnvironment.RootPath(""));
|
||||||
|
var result = template.Render();
|
||||||
|
|
||||||
|
ConnectionString = $"DataSource={result};";
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message = "不支持的数据库";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SqlSugarClient GetInstance()
|
||||||
|
{
|
||||||
|
#if !NETFRAMEWORK && !WINDOWS
|
||||||
|
SqlSugarScope client = (SqlSugar.SqlSugarScope)Utility.MiddleWare.AutofacContainerModule.GetService<ISqlSugarClient>();
|
||||||
|
if (client != null)
|
||||||
|
return client.ScopedContext;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
SqlSugarClient db = new SqlSugarClient(new ConnectionConfig()
|
||||||
|
{
|
||||||
|
ConnectionString = ConnectionString,
|
||||||
|
DbType = DbType,
|
||||||
|
IsAutoCloseConnection = true,
|
||||||
|
ConfigureExternalServices = new ConfigureExternalServices()
|
||||||
|
{
|
||||||
|
SqlFuncServices = ExtMethods.GetExpMethods
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//用来打印Sql方便你调式
|
||||||
|
db.Aop.OnLogExecuting = (sql, pars) =>
|
||||||
|
{
|
||||||
|
if (DebugMode)
|
||||||
|
{
|
||||||
|
Console.WriteLine(sql + "\r\n" +
|
||||||
|
db.Utilities.SerializeObject(pars.ToDictionary(it => it.ParameterName, it => it.Value)));
|
||||||
|
Console.WriteLine();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
return db;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTable GetTableColumnInfo(string tableName)
|
||||||
|
{
|
||||||
|
if (DbType == SqlSugar.DbType.SqlServer)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
StringBuilder strSql = new StringBuilder();
|
||||||
|
strSql.Append(" SELECT ").AppendLine();
|
||||||
|
strSql.Append(" A.Name AS TableName, ").AppendLine();
|
||||||
|
strSql.Append(" B.Name AS ColumnName, ").AppendLine();
|
||||||
|
strSql.Append(" D.Name AS TypeName, ").AppendLine();
|
||||||
|
strSql.Append(" B.Max_Length AS TypeLength, ").AppendLine();
|
||||||
|
strSql.Append(" CASE WHEN ").AppendLine();
|
||||||
|
strSql.Append(" ( ").AppendLine();
|
||||||
|
strSql.Append(" SELECT ").AppendLine();
|
||||||
|
strSql.Append(" F.Name ").AppendLine();
|
||||||
|
strSql.Append(" FROM ").AppendLine();
|
||||||
|
strSql.Append(" information_schema.key_column_usage E,sys.indexes F ").AppendLine();
|
||||||
|
strSql.Append(" WHERE ").AppendLine();
|
||||||
|
strSql.Append(" F.object_id=B.object_id ").AppendLine();
|
||||||
|
strSql.Append(" AND F.name=E.constraint_name ").AppendLine();
|
||||||
|
strSql.Append(" AND F.is_primary_key=1 ").AppendLine();
|
||||||
|
strSql.Append(" AND E.table_name=A.Name ").AppendLine();
|
||||||
|
strSql.Append(" AND E.column_name =B.Name ").AppendLine();
|
||||||
|
strSql.Append(" ) IS NULL THEN 0 ELSE 1 END AS IsPrimaryKey, ").AppendLine();
|
||||||
|
strSql.Append(" '' AS ClassName, ").AppendLine();
|
||||||
|
strSql.Append(" '' AS PropertyName, ").AppendLine();
|
||||||
|
strSql.Append(" '' AS CSType, ").AppendLine();
|
||||||
|
strSql.Append(" C.VALUE AS Other ").AppendLine();
|
||||||
|
strSql.Append(" FROM sys.tables A ").AppendLine();
|
||||||
|
strSql.Append(" LEFT JOIN sys.columns B ").AppendLine();
|
||||||
|
strSql.Append(" ON B.object_id = A.object_id ").AppendLine();
|
||||||
|
strSql.Append(" LEFT JOIN sys.extended_properties C ").AppendLine();
|
||||||
|
strSql.Append(" ON C.major_id = B.object_id AND C.minor_id = B.column_id ").AppendLine();
|
||||||
|
strSql.Append(" LEFT JOIN sys.types D ON D.system_type_id=B.system_type_id ").AppendLine();
|
||||||
|
strSql.Append(" WHERE A.Name = '" + tableName + "' ").AppendLine();
|
||||||
|
DataTable dt = db.Ado.GetDataTable(strSql.ToString());
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (DbType == SqlSugar.DbType.MySql)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
StringBuilder strSql = new StringBuilder();
|
||||||
|
strSql.Append(" SELECT ").AppendLine();
|
||||||
|
strSql.Append(" '" + tableName + "' AS TableName, ").AppendLine();
|
||||||
|
strSql.Append(" COLUMN_NAME AS ColumnName, ").AppendLine();
|
||||||
|
strSql.Append(" DATA_TYPE AS TypeName, ").AppendLine();
|
||||||
|
strSql.Append(" CHARACTER_MAXIMUM_LENGTH AS TypeLength, ").AppendLine();
|
||||||
|
strSql.Append(" case when COLUMN_KEY = 'PRI' THEN 1 ELSE 0 END AS IsPrimaryKey, ").AppendLine();
|
||||||
|
strSql.Append(" '' AS ClassName, ").AppendLine();
|
||||||
|
strSql.Append(" '' PropertyName, ").AppendLine();
|
||||||
|
strSql.Append(" '' CSType , ").AppendLine();
|
||||||
|
strSql.Append(" COLUMN_COMMENT AS Other ").AppendLine();
|
||||||
|
strSql.Append(" FROM ").AppendLine();
|
||||||
|
strSql.Append(" INFORMATION_SCHEMA.COLUMNS ").AppendLine();
|
||||||
|
strSql.Append(" WHERE ").AppendLine();
|
||||||
|
strSql.Append(" table_schema ='" + DbName + "' AND table_name = '" + tableName + "' ").AppendLine();
|
||||||
|
strSql.Append(" ORDER BY ORDINAL_POSITION ").AppendLine();
|
||||||
|
DataTable dt = db.Ado.GetDataTable(strSql.ToString());
|
||||||
|
return dt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (DbType == SqlSugar.DbType.Sqlite)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
|
||||||
|
string sql = "SELECT * from sqlite_master where type = 'table' AND tbl_name='" + tableName + "'";
|
||||||
|
DataTable dt = db.Ado.GetDataTable(sql);
|
||||||
|
//创建个新的DataTable,把dt中的数据放进去
|
||||||
|
DataTable newDt = new DataTable();
|
||||||
|
newDt.Columns.Add("TableName");
|
||||||
|
newDt.Columns.Add("ColumnName");
|
||||||
|
newDt.Columns.Add("TypeName");
|
||||||
|
newDt.Columns.Add("TypeLength");
|
||||||
|
newDt.Columns.Add("IsPrimaryKey");
|
||||||
|
newDt.Columns.Add("ClassName");
|
||||||
|
newDt.Columns.Add("PropertyName");
|
||||||
|
newDt.Columns.Add("CSType");
|
||||||
|
newDt.Columns.Add("Other");
|
||||||
|
if (dt == null || dt.Rows.Count == 0)
|
||||||
|
return newDt;
|
||||||
|
string sql1 = dt.Rows[0]["sql"].ToString().Replace("\"", "");
|
||||||
|
|
||||||
|
List<CodeGenerator> list = new List<CodeGenerator>();
|
||||||
|
//第一个(
|
||||||
|
int index1 = sql1.IndexOf("(");
|
||||||
|
int index2 = sql1.LastIndexOf(")");
|
||||||
|
string content = sql1.Substring(index1 + 1, index2 - index1 - 1);
|
||||||
|
List<string> array = content.Split('\n').Select(it => it.Trim()).ToList();
|
||||||
|
List<string> primaryKey = new List<string>();
|
||||||
|
foreach (string item in array)
|
||||||
|
{
|
||||||
|
if (item.Trim() == "")
|
||||||
|
continue;
|
||||||
|
if (item.ToUpper().StartsWith("PRIMARY KEY"))
|
||||||
|
{
|
||||||
|
int index3 = item.IndexOf("(");
|
||||||
|
int index4 = item.IndexOf(")");
|
||||||
|
string[] keyArray = item.Substring(index3 + 1, index4 - index3 - 1).Split(',');
|
||||||
|
foreach (string key in keyArray)
|
||||||
|
primaryKey.Add(key.Trim());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
string[] itemText = item.Trim().Split(' ');
|
||||||
|
CodeGenerator codeGenerator = new CodeGenerator();
|
||||||
|
codeGenerator.TableName = tableName;
|
||||||
|
codeGenerator.ColumnName = itemText[0];
|
||||||
|
string type = itemText[1];
|
||||||
|
int index5 = type.IndexOf("(");
|
||||||
|
int index6 = type.IndexOf(")");
|
||||||
|
codeGenerator.TypeName = index5 == -1 ? type : type.Substring(0, index5);
|
||||||
|
codeGenerator.TypeLength = index5 == -1 ? "0" : type.Substring(index5 + 1, index6 - index5 - 1);
|
||||||
|
codeGenerator.IsPrimaryKey = "0";
|
||||||
|
codeGenerator.ClassName = "";
|
||||||
|
codeGenerator.PropertyName = "";
|
||||||
|
codeGenerator.CSType = "";
|
||||||
|
codeGenerator.Other = "";
|
||||||
|
list.Add(codeGenerator);
|
||||||
|
}
|
||||||
|
foreach (CodeGenerator code in list)
|
||||||
|
{
|
||||||
|
if (primaryKey.Contains(code.ColumnName))
|
||||||
|
code.IsPrimaryKey = "1";
|
||||||
|
}
|
||||||
|
return list.ToJson().ToDataTable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<string> GetTableList()
|
||||||
|
{
|
||||||
|
if (DbType == SqlSugar.DbType.SqlServer)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
StringBuilder strSql = new StringBuilder();
|
||||||
|
strSql.Append(" SELECT ").AppendLine();
|
||||||
|
strSql.Append(" A.Name ").AppendLine();
|
||||||
|
strSql.Append(" FROM ").AppendLine();
|
||||||
|
strSql.Append(" sysobjects A ").AppendLine();
|
||||||
|
strSql.Append(" WHERE ").AppendLine();
|
||||||
|
strSql.Append(" A.xtype = 'U' ").AppendLine();
|
||||||
|
DataTable dt = db.Ado.GetDataTable(strSql.ToString());
|
||||||
|
if (dt == null)
|
||||||
|
return new List<string>();
|
||||||
|
List<string> list = new List<string>();
|
||||||
|
foreach (DataRow row in dt.Rows)
|
||||||
|
{
|
||||||
|
list.Add(row["Name"].ToString());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (DbType == SqlSugar.DbType.MySql)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
StringBuilder strSql = new StringBuilder();
|
||||||
|
strSql.Append(" SELECT ").AppendLine();
|
||||||
|
strSql.Append(" TABLE_NAME AS Name ").AppendLine();
|
||||||
|
strSql.Append(" FROM ").AppendLine();
|
||||||
|
strSql.Append(" information_schema.TABLES ").AppendLine();
|
||||||
|
strSql.Append(" WHERE ").AppendLine();
|
||||||
|
strSql.Append(" TABLE_SCHEMA = '" + DbName + "' ").AppendLine();
|
||||||
|
DataTable dt = db.Ado.GetDataTable(strSql.ToString());
|
||||||
|
if (dt == null)
|
||||||
|
return new List<string>();
|
||||||
|
List<string> list = new List<string>();
|
||||||
|
foreach (DataRow row in dt.Rows)
|
||||||
|
{
|
||||||
|
list.Add(row["Name"].ToString());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (DbType == SqlSugar.DbType.Sqlite)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
string sql = "SELECT name from sqlite_master where type='table'";
|
||||||
|
DataTable dt = db.Ado.GetDataTable(sql);
|
||||||
|
if (dt == null)
|
||||||
|
return new List<string>();
|
||||||
|
List<string> list = new List<string>();
|
||||||
|
foreach (DataRow row in dt.Rows)
|
||||||
|
{
|
||||||
|
list.Add(row["name"].ToString());
|
||||||
|
}
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new List<string>();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
80
DH.RBAC/Logic/Logger.cs
Normal file
80
DH.RBAC/Logic/Logger.cs
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
using DH.RBAC.Model.Sys;
|
||||||
|
using DH.RBAC.Logic.Base;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DH.RBAC.Utility.Other;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Logic
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 日志
|
||||||
|
/// </summary>
|
||||||
|
public class Logger
|
||||||
|
{
|
||||||
|
private static object _lock = new object();
|
||||||
|
private static void Log(string type, string message)
|
||||||
|
{
|
||||||
|
lock (_lock)
|
||||||
|
{
|
||||||
|
SimpleClient<SysLog> client = new SimpleClient<SysLog>(BaseLogic.GetInstance());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
SysLog log = new SysLog();
|
||||||
|
log.Id = UUID.SnowId;
|
||||||
|
log.Type = type;
|
||||||
|
#if !NETFRAMEWORK
|
||||||
|
log.ThreadId = Thread.GetCurrentProcessorId();
|
||||||
|
#else
|
||||||
|
log.ThreadId = Thread.CurrentThread.ManagedThreadId;
|
||||||
|
#endif
|
||||||
|
log.Message = message;
|
||||||
|
log.EnableFlag = "Y";
|
||||||
|
log.DeleteFlag = "N";
|
||||||
|
log.CreateTime = DateTime.Now;
|
||||||
|
log.CreateUserId = "1";
|
||||||
|
log.ModifyUserId = "1";
|
||||||
|
log.ModifyTime = log.CreateTime;
|
||||||
|
client.Insert(log);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 操作日志写入
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
public static void OperateInfo(string message)
|
||||||
|
{
|
||||||
|
Log("Operate", message);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 运行日志写入
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
public static void RunningInfo(string message)
|
||||||
|
{
|
||||||
|
Log("Running", message);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 错误日志写入
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="message"></param>
|
||||||
|
public static void ErrorInfo(string message)
|
||||||
|
{
|
||||||
|
Log("Error", message);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
167
DH.RBAC/Logic/Sys/SysItemLogic.cs
Normal file
167
DH.RBAC/Logic/Sys/SysItemLogic.cs
Normal file
@ -0,0 +1,167 @@
|
|||||||
|
using DH.RBAC.Model.Sys;
|
||||||
|
using DH.RBAC.Logic.Base;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using SqlSugar;
|
||||||
|
using DH.RBAC.Utility.Other;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DH.RBAC.Logic.Sys
|
||||||
|
{
|
||||||
|
public class SysItemLogic : BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
public List<SysItem> GetList()
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysItem>().Where(it => it.DeleteFlag == "N")
|
||||||
|
.Includes(it => it.CreateUser)
|
||||||
|
.Includes(it => it.ModifyUser)
|
||||||
|
.OrderBy(it => it.SortCode)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SysItem> GetAppList(int pageIndex, int pageSize, ref int totalCount)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysItem>().Where(it => it.ParentId != "0" && it.DeleteFlag == "N")
|
||||||
|
.Includes(it => it.CreateUser)
|
||||||
|
.Includes(it => it.ModifyUser)
|
||||||
|
.OrderBy(it => it.SortCode)
|
||||||
|
.ToPageList(pageIndex, pageSize, ref totalCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public List<SysItem> GetList(int pageIndex, int pageSize, string keyWord, ref int totalCount)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
ISugarQueryable<SysItem> queryable = db.Queryable<SysItem>().Where(it => it.DeleteFlag == "N");
|
||||||
|
|
||||||
|
if (!string.IsNullOrWhiteSpace(keyWord))
|
||||||
|
{
|
||||||
|
queryable = queryable.Where(it => (it.Name.Contains(keyWord) || it.EnCode.Contains(keyWord)));
|
||||||
|
}
|
||||||
|
return queryable
|
||||||
|
.Includes(it => it.CreateUser)
|
||||||
|
.Includes(it => it.ModifyUser)
|
||||||
|
.OrderBy(it => it.SortCode)
|
||||||
|
.ToPageList(pageIndex, pageSize, ref totalCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int GetChildCount(string parentId)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysItem>()
|
||||||
|
.Where(it => it.ParentId == parentId && it.DeleteFlag == "N")
|
||||||
|
.ToList().Count();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public SysItem Get(string primaryKey)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysItem>().Where(it => it.DeleteFlag == "N")
|
||||||
|
.Where(it => it.Id == primaryKey)
|
||||||
|
.Includes(it => it.CreateUser)
|
||||||
|
.Includes(it => it.ModifyUser)
|
||||||
|
.First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int AppInsert(SysItem model, string operateUser)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
SysItem s = db.Queryable<SysItem>().Where(it => it.ParentId == "0").First();
|
||||||
|
model.Id = UUID.StrSnowId;
|
||||||
|
model.Layer = s.Layer + 1;
|
||||||
|
model.ParentId = s.Id;
|
||||||
|
model.DeleteFlag = "N";
|
||||||
|
model.CreateUserId = operateUser;
|
||||||
|
model.CreateTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.CreateUser.Id;
|
||||||
|
model.ModifyTime = model.CreateTime;
|
||||||
|
return db.Insertable<SysItem>(model).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(SysItem model, string account)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.Id = UUID.StrSnowId;
|
||||||
|
model.Layer = Get(model.ParentId).Layer += 1;
|
||||||
|
model.DeleteFlag = "N";
|
||||||
|
model.CreateUserId = account;
|
||||||
|
model.CreateTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.CreateUserId;
|
||||||
|
model.ModifyTime = model.CreateTime;
|
||||||
|
return db.Insertable<SysItem>(model).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Delete(string primaryKey)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
SysItem item = db.Queryable<SysItem>().Where(it => it.Id == primaryKey).First();
|
||||||
|
if (item == null)
|
||||||
|
return 0;
|
||||||
|
item.DeleteFlag = "Y";
|
||||||
|
return db.Updateable<SysItem>(item).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int Update(SysItem model, string account)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.Layer = Get(model.ParentId).Layer += 1;
|
||||||
|
model.ModifyUserId = account;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
return db.Updateable<SysItem>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.ParentId,
|
||||||
|
it.Layer,
|
||||||
|
it.EnCode,
|
||||||
|
it.Name,
|
||||||
|
it.SortCode,
|
||||||
|
it.EnableFlag,
|
||||||
|
it.Remark,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int AppUpdate(SysItem model, string operateUser)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.ModifyUserId = operateUser;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
return db.Updateable<SysItem>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.EnCode,
|
||||||
|
it.Name,
|
||||||
|
it.SortCode,
|
||||||
|
it.Remark,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
182
DH.RBAC/Logic/Sys/SysItemsDetailLogic.cs
Normal file
182
DH.RBAC/Logic/Sys/SysItemsDetailLogic.cs
Normal file
@ -0,0 +1,182 @@
|
|||||||
|
using DH.RBAC.Model.Sys;
|
||||||
|
using DH.RBAC.Logic.Base;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DH.RBAC.Utility.Other;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DH.RBAC.Logic.Sys
|
||||||
|
{
|
||||||
|
public class SysItemsDetailLogic : BaseLogic
|
||||||
|
{
|
||||||
|
public List<SysItemDetail> GetItemDetailList(string strItemCode)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
|
||||||
|
SysItem item = db.Queryable<SysItem>().Where(it => it.EnCode == strItemCode && it.DeleteFlag == "N").First();
|
||||||
|
if (null == item)
|
||||||
|
return null;
|
||||||
|
return db.Queryable<SysItemDetail>().Where(it => it.ItemId == item.Id && it.DeleteFlag == "N")
|
||||||
|
.Includes(it => it.CreateUser)
|
||||||
|
.Includes(it => it.ModifyUser)
|
||||||
|
.OrderBy(it => it.SortCode)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SysItemDetail> GetList(int pageIndex, int pageSize, string itemId, string keyWord, ref int totalCount)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
ISugarQueryable<SysItemDetail> queryable = db.Queryable<SysItemDetail>().Where(it => it.DeleteFlag == "N" && it.ItemId == itemId);
|
||||||
|
if (!keyWord.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
queryable = queryable.Where(it => (it.Name.Contains(keyWord) || it.EnCode.Contains(keyWord)));
|
||||||
|
}
|
||||||
|
return queryable
|
||||||
|
.Includes(it => it.CreateUser)
|
||||||
|
.Includes(it => it.ModifyUser)
|
||||||
|
.OrderBy(it => it.SortCode)
|
||||||
|
.ToPageList(pageIndex, pageSize, ref totalCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SysItemDetail> GetListByItemId(string itemId)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysItemDetail>()
|
||||||
|
.Where(it => it.ItemId == itemId && it.DeleteFlag == "N")
|
||||||
|
.Includes(it => it.CreateUser)
|
||||||
|
.Includes(it => it.ModifyUser)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void InsertItemDetail(string itemId, List<SysItemDetail> list)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
db.BeginTran();
|
||||||
|
List<SysItemDetail> list2 = db.Queryable<SysItemDetail>().Where(it => it.ItemId == itemId && it.DeleteFlag == "N").ToList();
|
||||||
|
list2.ForEach(it => { it.DeleteFlag = "Y"; });
|
||||||
|
db.Updateable<SysItemDetail>(list2).ExecuteCommand();
|
||||||
|
db.Insertable<SysItemDetail>(list).ExecuteCommand();
|
||||||
|
db.CommitTran();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SysItemDetail Get(string primaryKey)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysItemDetail>()
|
||||||
|
.Where(it => it.DeleteFlag == "N" && it.Id == primaryKey)
|
||||||
|
.Includes(it => it.CreateUser)
|
||||||
|
.Includes(it => it.ModifyUser)
|
||||||
|
.First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(SysItemDetail model, string account)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.Id = UUID.StrSnowId;
|
||||||
|
model.IsDefault = model.IsDefault == null ? "0" : "1";
|
||||||
|
model.DeleteFlag = "N";
|
||||||
|
model.CreateUserId = account;
|
||||||
|
model.CreateTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.CreateUserId;
|
||||||
|
model.ModifyTime = model.CreateTime;
|
||||||
|
return db.Insertable<SysItemDetail>(model).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AppInsert(SysItemDetail model, string operateUser)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.Id = UUID.StrSnowId;
|
||||||
|
model.IsDefault = "0";
|
||||||
|
model.DeleteFlag = "N";
|
||||||
|
model.CreateUserId = operateUser;
|
||||||
|
model.CreateTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.CreateUserId;
|
||||||
|
model.ModifyTime = model.CreateTime;
|
||||||
|
return db.Insertable<SysItemDetail>(model).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int AppUpdate(SysItemDetail model, string operateUser)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.ModifyUserId = operateUser;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
return db.Updateable<SysItemDetail>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.EnCode,
|
||||||
|
it.Name,
|
||||||
|
it.SortCode,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Delete(string itemId)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
SysItemDetail itemDetail = db.Queryable<SysItemDetail>().Where(it => it.Id == itemId).First();
|
||||||
|
if (itemDetail == null)
|
||||||
|
return 0;
|
||||||
|
itemDetail.DeleteFlag = "Y";
|
||||||
|
return db.Updateable<SysItemDetail>(itemDetail).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Update(SysItemDetail model, string account)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.IsDefault = model.IsDefault == null ? "0" : "1";
|
||||||
|
model.ModifyUserId = account;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
return db.Updateable<SysItemDetail>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.ItemId,
|
||||||
|
it.EnCode,
|
||||||
|
it.Name,
|
||||||
|
it.IsDefault,
|
||||||
|
it.SortCode,
|
||||||
|
it.EnableFlag,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SysItemDetail GetSoftwareName()
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysItemDetail>().Where(it => it.EnCode == "SoftwareName").First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
123
DH.RBAC/Logic/Sys/SysLogLogic.cs
Normal file
123
DH.RBAC/Logic/Sys/SysLogLogic.cs
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
using DH.RBAC.Model.Sys;
|
||||||
|
using DH.RBAC.Logic.Base;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using DH.RBAC.Utility.Other;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DH.RBAC.Logic.Sys
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 系统日志表数据访问
|
||||||
|
/// </summary>
|
||||||
|
public class SysLogLogic : BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据日志类型获得日志
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pageIndex"></param>
|
||||||
|
/// <param name="pageSize"></param>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <param name="keyWord"></param>
|
||||||
|
/// <param name="totalCount"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<SysLog> GetList(int pageIndex, int pageSize, string type, string index, string keyWord, ref int totalCount)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
ISugarQueryable<SysLog> query = db.Queryable<SysLog>().Where(it => it.Type == type);
|
||||||
|
if (!keyWord.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
query = query.Where(it => it.Message.Contains(keyWord));
|
||||||
|
}
|
||||||
|
//查询当日
|
||||||
|
if (index == "1")
|
||||||
|
{
|
||||||
|
DateTime today = DateTime.Today;
|
||||||
|
DateTime startTime = today;
|
||||||
|
DateTime endTime = today.AddDays(1);
|
||||||
|
query = query.Where(it => it.CreateTime >= startTime && it.CreateTime < endTime);
|
||||||
|
}
|
||||||
|
//近7天
|
||||||
|
else if (index == "2")
|
||||||
|
{
|
||||||
|
DateTime today = DateTime.Today;
|
||||||
|
DateTime startTime = today.AddDays(-6);
|
||||||
|
DateTime endTime = today.AddDays(1);
|
||||||
|
query = query.Where(it => it.CreateTime >= startTime && it.CreateTime < endTime);
|
||||||
|
}
|
||||||
|
//近1月
|
||||||
|
else if (index == "3")
|
||||||
|
{
|
||||||
|
DateTime today = DateTime.Today;
|
||||||
|
DateTime startTime = today.AddDays(-29);
|
||||||
|
DateTime endTime = today.AddDays(1);
|
||||||
|
query = query.Where(it => it.CreateTime >= startTime && it.CreateTime < endTime);
|
||||||
|
}
|
||||||
|
//近3月
|
||||||
|
else if (index == "4")
|
||||||
|
{
|
||||||
|
DateTime today = DateTime.Today;
|
||||||
|
DateTime startTime = today.AddDays(-91);
|
||||||
|
DateTime endTime = today.AddDays(1);
|
||||||
|
query = query.Where(it => it.CreateTime >= startTime && it.CreateTime < endTime);
|
||||||
|
}
|
||||||
|
return query.OrderBy(it => it.Id, OrderByType.Desc).ToPageList(pageIndex, pageSize, ref totalCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除日志
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="type"></param>
|
||||||
|
/// <param name="index"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Delete(string type, string index)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
IDeleteable<SysLog> query = db.Deleteable<SysLog>().Where(it => it.Type == type);
|
||||||
|
//保留一个月
|
||||||
|
if (index == "1")
|
||||||
|
{
|
||||||
|
DateTime today = DateTime.Today;
|
||||||
|
DateTime startTime = today;
|
||||||
|
DateTime endTime = today.AddDays(-29);
|
||||||
|
query = query.Where(it => it.CreateTime < endTime);
|
||||||
|
return query.ExecuteCommand();
|
||||||
|
}
|
||||||
|
//保留7天
|
||||||
|
else if (index == "2")
|
||||||
|
{
|
||||||
|
DateTime today = DateTime.Today;
|
||||||
|
DateTime startTime = today.AddDays(-6);
|
||||||
|
query = query.Where(it => it.CreateTime < startTime);
|
||||||
|
return query.ExecuteCommand();
|
||||||
|
}
|
||||||
|
//保留近3个月
|
||||||
|
else if (index == "3")
|
||||||
|
{
|
||||||
|
DateTime today = DateTime.Today;
|
||||||
|
DateTime startTime = today.AddDays(-92);
|
||||||
|
query = query.Where(it => it.CreateTime < startTime);
|
||||||
|
return query.ExecuteCommand();
|
||||||
|
}
|
||||||
|
//全部
|
||||||
|
else if (index == "4")
|
||||||
|
{
|
||||||
|
return query.ExecuteCommand();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
157
DH.RBAC/Logic/Sys/SysOrganizeLogic.cs
Normal file
157
DH.RBAC/Logic/Sys/SysOrganizeLogic.cs
Normal file
@ -0,0 +1,157 @@
|
|||||||
|
using DH.RBAC.Model.Sys;
|
||||||
|
using DH.RBAC.Logic.Base;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DH.RBAC.Utility.Other;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DH.RBAC.Logic.Sys
|
||||||
|
{
|
||||||
|
public class SysOrganizeLogic : BaseLogic
|
||||||
|
{
|
||||||
|
public List<SysOrganize> GetList()
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysOrganize>().Where(it => it.DeleteFlag == "N").ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SysOrganize> GetList(int pageIndex, int pageSize, string keyWord, ref int totalCount)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
ISugarQueryable<SysOrganize> queryable = db.Queryable<SysOrganize>().Where(it => it.ParentId != "0" && it.DeleteFlag == "N");
|
||||||
|
|
||||||
|
if (!keyWord.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
queryable = queryable.Where(it => (it.FullName.Contains(keyWord) || it.EnCode.Contains(keyWord)));
|
||||||
|
}
|
||||||
|
return queryable
|
||||||
|
.OrderBy(it => it.SortCode)
|
||||||
|
.ToPageList(pageIndex, pageSize, ref totalCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public int GetChildCount(string parentId)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysOrganize>().Where(it => it.ParentId == parentId && it.DeleteFlag == "N").Count();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int AppUpdate(SysOrganize model, string opreaterUser)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.ModifyUserId = opreaterUser;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
return db.Updateable<SysOrganize>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.EnCode,
|
||||||
|
it.FullName,
|
||||||
|
it.Type,
|
||||||
|
it.ManagerId,
|
||||||
|
it.TelePhone,
|
||||||
|
it.WeChat,
|
||||||
|
it.Fax,
|
||||||
|
it.Email,
|
||||||
|
it.Address,
|
||||||
|
it.SortCode,
|
||||||
|
it.Remark,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AppInsert(SysOrganize model, string opreaterUser)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
SysOrganize s = db.Queryable<SysOrganize>().Where(it => it.ParentId == "0").First();
|
||||||
|
model.Id = UUID.StrSnowId;
|
||||||
|
model.Layer = s.Layer + 1;
|
||||||
|
model.ParentId = s.Id;
|
||||||
|
|
||||||
|
model.EnableFlag = "Y";
|
||||||
|
model.DeleteFlag = "N";
|
||||||
|
model.CreateUserId = opreaterUser;
|
||||||
|
model.CreateTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.CreateUserId;
|
||||||
|
model.ModifyTime = model.CreateTime;
|
||||||
|
return db.Insertable<SysOrganize>(model).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int Insert(SysOrganize model, string account)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.Id = UUID.StrSnowId;
|
||||||
|
model.Layer = Get(model.ParentId).Layer += 1;
|
||||||
|
model.EnableFlag = "Y";
|
||||||
|
model.DeleteFlag = "N";
|
||||||
|
model.CreateUserId = account;
|
||||||
|
model.CreateTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.CreateUserId;
|
||||||
|
model.ModifyTime = model.CreateTime;
|
||||||
|
return db.Insertable<SysOrganize>(model).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Delete(string primaryKey)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
SysOrganize organize = db.Queryable<SysOrganize>().Where(it => it.Id == primaryKey).First();
|
||||||
|
if (organize == null)
|
||||||
|
return 0;
|
||||||
|
organize.DeleteFlag = "Y";
|
||||||
|
return db.Updateable<SysOrganize>(organize).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public SysOrganize Get(string primaryKey)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysOrganize>().Where(it => it.Id == primaryKey).Includes(it => it.CreateUser).Includes(it => it.ModifyUser).First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int Update(SysOrganize model, string account)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.ModifyUserId = account;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
return db.Updateable<SysOrganize>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.ParentId,
|
||||||
|
it.Layer,
|
||||||
|
it.EnCode,
|
||||||
|
it.FullName,
|
||||||
|
it.Type,
|
||||||
|
it.ManagerId,
|
||||||
|
it.TelePhone,
|
||||||
|
it.WeChat,
|
||||||
|
it.Fax,
|
||||||
|
it.Email,
|
||||||
|
it.Address,
|
||||||
|
it.SortCode,
|
||||||
|
it.EnableFlag,
|
||||||
|
it.Remark,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
238
DH.RBAC/Logic/Sys/SysPermissionLogic.cs
Normal file
238
DH.RBAC/Logic/Sys/SysPermissionLogic.cs
Normal file
@ -0,0 +1,238 @@
|
|||||||
|
using DH.RBAC.Model.Sys;
|
||||||
|
using DH.RBAC.Logic.Base;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DH.RBAC.Utility.Other;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DH.RBAC.Logic.Sys
|
||||||
|
{
|
||||||
|
public class SysPermissionLogic : BaseLogic
|
||||||
|
{
|
||||||
|
public bool ActionValidate(string userId, string action)
|
||||||
|
{
|
||||||
|
List<SysPermission> authorizeModules;
|
||||||
|
if (new SysUserLogic().ContainsUser("admin", userId))
|
||||||
|
{
|
||||||
|
authorizeModules = GetList();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
authorizeModules = GetList(userId);
|
||||||
|
}
|
||||||
|
foreach (var item in authorizeModules)
|
||||||
|
{
|
||||||
|
if (!string.IsNullOrEmpty(item.Url))
|
||||||
|
{
|
||||||
|
string[] url = item.Url.Split('?');
|
||||||
|
if (url[0].ToLower() == action.ToLower())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<SysPermission> GetList(string userId)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
List<string> permissionIdList = db.Queryable<SysUserRoleRelation, SysRoleAuthorize, SysPermission>((A, B, C) => new object[] {
|
||||||
|
JoinType.Left,A.RoleId == B.RoleId,
|
||||||
|
JoinType.Left,C.Id == B.ModuleId,
|
||||||
|
})
|
||||||
|
.Where((A, B, C) => A.UserId == userId && C.EnableFlag == "Y" && B.DeleteFlag == "N")
|
||||||
|
.Select((A, B, C) => C.Id).ToList();
|
||||||
|
return db.Queryable<SysPermission>().Where(it => permissionIdList.Contains(it.Id)).OrderBy(it => it.SortCode).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<SysPermission> GetList(int pageIndex, int pageSize, string keyWord, ref int totalCount)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
if (keyWord.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysPermission>().Where(it => it.DeleteFlag == "N").OrderBy(it => it.SortCode).ToPageList(pageIndex, pageSize, ref totalCount);
|
||||||
|
}
|
||||||
|
return db.Queryable<SysPermission>().Where(it => it.DeleteFlag == "N" && (it.Name.Contains(keyWord) || it.EnCode.Contains(keyWord))).OrderBy(it => it.SortCode).ToPageList(pageIndex, pageSize, ref totalCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Delete(params string[] primaryKeys)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
db.BeginTran();
|
||||||
|
//删除权限与角色的对应关系。
|
||||||
|
List<SysPermission> list = db.Queryable<SysPermission>().Where(it => primaryKeys.Contains(it.Id) && it.DeleteFlag == "N").ToList();
|
||||||
|
List<string> ids = list.Select(it => it.Id).ToList();
|
||||||
|
list.ForEach(it => { it.DeleteFlag = "Y"; });
|
||||||
|
db.Updateable<SysPermission>(list).ExecuteCommand();
|
||||||
|
List<SysRoleAuthorize> list2 = db.Queryable<SysRoleAuthorize>().Where(it => ids.Contains(it.ModuleId) && it.DeleteFlag == "N").ToList();
|
||||||
|
list2.ForEach(it => { it.DeleteFlag = "Y"; });
|
||||||
|
db.Updateable<SysRoleAuthorize>(list2).ExecuteCommand();
|
||||||
|
db.CommitTran();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
public int GetMaxChildMenuOrderCode(string parentId)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
//得到当前节点
|
||||||
|
SysPermission permission = db.Queryable<SysPermission>().Where(it => it.Id == parentId && it.DeleteFlag == "N").First();
|
||||||
|
if (permission == null)
|
||||||
|
return 0;
|
||||||
|
//得到子的
|
||||||
|
SysPermission child = db.Queryable<SysPermission>().Where(it => it.ParentId == parentId && it.DeleteFlag == "N").OrderBy(it => it.SortCode, OrderByType.Desc).First();
|
||||||
|
if (child == null)
|
||||||
|
return permission.SortCode.Value + 100;
|
||||||
|
else
|
||||||
|
return child.SortCode.Value + 100;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int GetChildCount(string parentId)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysPermission>().Where(it => it.ParentId == parentId && it.DeleteFlag == "N").ToList().Count();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<SysPermission> GetList()
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysPermission>().Where(it => it.DeleteFlag == "N").OrderBy(it => it.SortCode).ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public SysPermission Get(string primaryKey)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysPermission>().Where(it => it.Id == primaryKey).Includes(it => it.CreateUser).Includes(it => it.ModifyUser).First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int Insert(SysPermission model, string account)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.Id = UUID.StrSnowId;
|
||||||
|
model.Layer = model.Type == 2 ? 0 : model.Type == 0 ? 1 : 2;
|
||||||
|
model.IsEdit = model.IsEdit == null ? "0" : "1";
|
||||||
|
model.IsPublic = model.IsPublic == null ? "0" : "1";
|
||||||
|
|
||||||
|
model.DeleteFlag = "N";
|
||||||
|
model.EnableFlag = "Y";
|
||||||
|
model.CreateUserId = account;
|
||||||
|
model.CreateTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.CreateUserId;
|
||||||
|
model.ModifyTime = model.CreateTime;
|
||||||
|
return db.Insertable<SysPermission>(model).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int AppInsert(SysPermission model, string operateUser)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.Id = UUID.StrSnowId;
|
||||||
|
model.Layer = model.Type == 2 ? 0 : model.Type == 0 ? 1 : 2;
|
||||||
|
model.IsEdit = "1";
|
||||||
|
model.IsPublic = "0";
|
||||||
|
|
||||||
|
model.DeleteFlag = "N";
|
||||||
|
model.EnableFlag = "Y";
|
||||||
|
model.CreateUserId = operateUser;
|
||||||
|
model.CreateTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.CreateUserId;
|
||||||
|
model.ModifyTime = model.CreateTime;
|
||||||
|
return db.Insertable<SysPermission>(model).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AppUpdate(SysPermission model, string operateUser)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.Layer = model.Type == 2 ? 0 : model.Type == 0 ? 1 : 2;
|
||||||
|
model.ModifyUserId = operateUser;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
return db.Updateable<SysPermission>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.ParentId,
|
||||||
|
it.Layer,
|
||||||
|
it.EnCode,
|
||||||
|
it.Name,
|
||||||
|
it.JsEvent,
|
||||||
|
it.Icon,
|
||||||
|
it.SymbolIndex,
|
||||||
|
it.Url,
|
||||||
|
it.Remark,
|
||||||
|
it.Type,
|
||||||
|
it.SortCode,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime,
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int Update(SysPermission model, string account)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.Layer = model.Type == 2 ? 0 : model.Type == 0 ? 1 : 2;
|
||||||
|
model.IsEdit = model.IsEdit == null ? "0" : "1";
|
||||||
|
model.IsPublic = model.IsPublic == null ? "0" : "1";
|
||||||
|
model.ModifyUserId = account;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
return db.Updateable<SysPermission>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.ParentId,
|
||||||
|
it.Layer,
|
||||||
|
it.EnCode,
|
||||||
|
it.Name,
|
||||||
|
it.JsEvent,
|
||||||
|
it.Icon,
|
||||||
|
it.SymbolIndex,
|
||||||
|
it.Url,
|
||||||
|
it.Remark,
|
||||||
|
it.Type,
|
||||||
|
it.SortCode,
|
||||||
|
it.IsPublic,
|
||||||
|
it.EnableFlag,
|
||||||
|
it.IsEdit,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime,
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int InsertList(List<SysPermission> permissionList)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Insertable<SysPermission>(permissionList).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
170
DH.RBAC/Logic/Sys/SysRoleAuthorizeLogic.cs
Normal file
170
DH.RBAC/Logic/Sys/SysRoleAuthorizeLogic.cs
Normal file
@ -0,0 +1,170 @@
|
|||||||
|
using DH.RBAC.Model.Sys;
|
||||||
|
using DH.RBAC.Logic.Base;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DH.RBAC.Utility.Other;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DH.RBAC.Logic.Sys
|
||||||
|
{
|
||||||
|
public class SysRoleAuthorizeLogic : BaseLogic
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 获得角色权限关系
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<SysRoleAuthorize> GetList()
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysRoleAuthorize>().ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据角色ID获得角色权限关系
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="roleId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<SysRoleAuthorize> GetList(string roleId)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysRoleAuthorize>().Where(it => it.RoleId == roleId && it.DeleteFlag == "N").ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 给某个角色授权
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="roleId"></param>
|
||||||
|
/// <param name="perIds"></param>
|
||||||
|
public void AppAuthorize(string operate, string roleId, params string[] perIds)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
db.BeginTran();
|
||||||
|
//获得所有权限
|
||||||
|
List<SysPermission> permissionList = db.Queryable<SysPermission>().Where(it => it.DeleteFlag == "N").ToList();
|
||||||
|
List<string> perList = new List<string>();
|
||||||
|
foreach (string perId in perIds)
|
||||||
|
{
|
||||||
|
string id = perId;
|
||||||
|
while (!id.IsNullOrEmpty() && id != "0")
|
||||||
|
{
|
||||||
|
if (!perList.Contains(id))
|
||||||
|
{
|
||||||
|
perList.Add(id);
|
||||||
|
}
|
||||||
|
id = permissionList.Where(it => it.Id == id).Select(it => it.ParentId).FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//删除旧的
|
||||||
|
List<SysRoleAuthorize> list2 = db.Queryable<SysRoleAuthorize>().Where(it => it.RoleId == roleId && it.DeleteFlag == "N").ToList();
|
||||||
|
list2.ForEach(it => { it.DeleteFlag = "Y"; });
|
||||||
|
db.Updateable<SysRoleAuthorize>(list2).ExecuteCommand();
|
||||||
|
|
||||||
|
|
||||||
|
List<SysRoleAuthorize> newRoleAuthorizeList = perList.Select(it => new SysRoleAuthorize
|
||||||
|
{
|
||||||
|
Id = UUID.StrSnowId,
|
||||||
|
RoleId = roleId,
|
||||||
|
ModuleId = it,
|
||||||
|
DeleteFlag = "N",
|
||||||
|
EnableFlag = "Y",
|
||||||
|
CreateUserId = operate,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
ModifyUserId = operate,
|
||||||
|
ModifyTime = DateTime.Now
|
||||||
|
|
||||||
|
}).ToList();
|
||||||
|
db.Insertable<SysRoleAuthorize>(newRoleAuthorizeList).ExecuteCommand();
|
||||||
|
db.CommitTran();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 给某个角色授权
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="roleId"></param>
|
||||||
|
/// <param name="perIds"></param>
|
||||||
|
public void Authorize(string roleId, string account, params string[] perIds)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
db.BeginTran();
|
||||||
|
//获得所有权限
|
||||||
|
List<SysPermission> permissionList = db.Queryable<SysPermission>().ToList();
|
||||||
|
List<string> perList = new List<string>();
|
||||||
|
foreach (string perId in perIds)
|
||||||
|
{
|
||||||
|
string id = perId;
|
||||||
|
while (!id.IsNullOrEmpty() && id != "0")
|
||||||
|
{
|
||||||
|
if (!perList.Contains(id))
|
||||||
|
{
|
||||||
|
perList.Add(id);
|
||||||
|
}
|
||||||
|
id = permissionList.Where(it => it.Id == id).Select(it => it.ParentId).FirstOrDefault();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//删除旧的
|
||||||
|
List<SysRoleAuthorize> list2 = db.Queryable<SysRoleAuthorize>().Where(it => it.RoleId == roleId && it.DeleteFlag == "N").ToList();
|
||||||
|
list2.ForEach(it => { it.DeleteFlag = "Y"; });
|
||||||
|
db.Updateable<SysRoleAuthorize>(list2).ExecuteCommand();
|
||||||
|
|
||||||
|
|
||||||
|
List<SysRoleAuthorize> newRoleAuthorizeList = perList.Select(it => new SysRoleAuthorize
|
||||||
|
{
|
||||||
|
Id = UUID.StrSnowId,
|
||||||
|
RoleId = roleId,
|
||||||
|
ModuleId = it,
|
||||||
|
DeleteFlag = "N",
|
||||||
|
EnableFlag = "Y",
|
||||||
|
CreateUserId = account,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
ModifyUserId = account,
|
||||||
|
ModifyTime = DateTime.Now
|
||||||
|
}).ToList();
|
||||||
|
db.Insertable<SysRoleAuthorize>(newRoleAuthorizeList).ExecuteCommand();
|
||||||
|
db.CommitTran();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从角色权限关系中删除某个模块
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="moduleIds"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Delete(params string[] moduleIds)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
List<SysRoleAuthorize> list = db.Queryable<SysRoleAuthorize>().Where(it => moduleIds.Contains(it.ModuleId)).ToList();
|
||||||
|
list.ForEach(it => { it.DeleteFlag = "Y"; });
|
||||||
|
return db.Updateable<SysRoleAuthorize>(list).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
176
DH.RBAC/Logic/Sys/SysRoleLogic.cs
Normal file
176
DH.RBAC/Logic/Sys/SysRoleLogic.cs
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DH.RBAC.Model.Sys;
|
||||||
|
using DH.RBAC.Logic.Base;
|
||||||
|
using SqlSugar;
|
||||||
|
using DH.RBAC.Utility.Other;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DH.RBAC.Logic.Sys
|
||||||
|
{
|
||||||
|
public class SysRoleLogic : BaseLogic
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 得到角色列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<SysRole> GetList()
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysRole>().Where(it => it.DeleteFlag == "N")
|
||||||
|
.Includes(it => it.Organize)
|
||||||
|
.Includes(it => it.CreateUser)
|
||||||
|
.Includes(it => it.ModifyUser)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得角色列表分页
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pageIndex"></param>
|
||||||
|
/// <param name="pageSize"></param>
|
||||||
|
/// <param name="keyWord"></param>
|
||||||
|
/// <param name="totalCount"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<SysRole> GetList(int pageIndex, int pageSize, string keyWord, ref int totalCount)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
|
||||||
|
ISugarQueryable<SysRole> queryable = db.Queryable<SysRole>().Where(it => it.DeleteFlag == "N");
|
||||||
|
|
||||||
|
if (!keyWord.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
queryable = queryable.Where(it => (it.Name.Contains(keyWord) || it.EnCode.Contains(keyWord)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return queryable.Includes(it => it.Organize)
|
||||||
|
.Includes(it => it.CreateUser)
|
||||||
|
.Includes(it => it.ModifyUser)
|
||||||
|
.OrderBy(it => it.SortCode)
|
||||||
|
.ToPageList(pageIndex, pageSize, ref totalCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增角色
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Insert(SysRole model, string account)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.Id = UUID.StrSnowId;
|
||||||
|
model.AllowEdit = model.AllowEdit == null ? "0" : "1";
|
||||||
|
model.DeleteFlag = "N";
|
||||||
|
model.CreateUserId = account;
|
||||||
|
model.CreateTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.CreateUserId;
|
||||||
|
model.ModifyTime = model.CreateTime;
|
||||||
|
return db.Insertable<SysRole>(model).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AppInsert(SysRole model, string operateUser)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.Id = UUID.StrSnowId;
|
||||||
|
model.AllowEdit = "1";
|
||||||
|
model.DeleteFlag = "N";
|
||||||
|
model.CreateUserId = operateUser;
|
||||||
|
model.CreateTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.CreateUserId;
|
||||||
|
model.ModifyTime = model.CreateTime;
|
||||||
|
return db.Insertable<SysRole>(model).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AppUpdate(SysRole model, string operateUser)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.AllowEdit = model.AllowEdit == null ? "0" : "1";
|
||||||
|
model.ModifyUserId = operateUser;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
return db.Updateable<SysRole>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.OrganizeId,
|
||||||
|
it.EnCode,
|
||||||
|
it.Type,
|
||||||
|
it.Name,
|
||||||
|
it.Remark,
|
||||||
|
it.SortCode,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新角色信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Update(SysRole model, string account)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.AllowEdit = model.AllowEdit == null ? "0" : "1";
|
||||||
|
model.ModifyUserId = account;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
return db.Updateable<SysRole>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.OrganizeId,
|
||||||
|
it.EnCode,
|
||||||
|
it.Type,
|
||||||
|
it.Name,
|
||||||
|
it.AllowEdit,
|
||||||
|
it.EnableFlag,
|
||||||
|
it.Remark,
|
||||||
|
it.SortCode,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据主键得到角色信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="primaryKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public SysRole Get(string primaryKey)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysRole>().Where(it => it.Id == primaryKey)
|
||||||
|
.Includes(it => it.Organize)
|
||||||
|
.Includes(it => it.CreateUser)
|
||||||
|
.Includes(it => it.ModifyUser)
|
||||||
|
.First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 删除角色信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="primaryKeys"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Delete(List<string> primaryKeys)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
List<SysRole> list = db.Queryable<SysRole>().Where(it => primaryKeys.Contains(it.Id)).ToList();
|
||||||
|
list.ForEach(it => { it.DeleteFlag = "Y"; });
|
||||||
|
return db.Updateable<SysRole>(list).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
175
DH.RBAC/Logic/Sys/SysUserLogOnLogic.cs
Normal file
175
DH.RBAC/Logic/Sys/SysUserLogOnLogic.cs
Normal file
@ -0,0 +1,175 @@
|
|||||||
|
using DH.RBAC.Model.Sys;
|
||||||
|
using DH.RBAC.Logic.Base;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using DH.RBAC.Utility.Other;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DH.RBAC.Logic.Sys
|
||||||
|
{
|
||||||
|
public class SysUserLogOnLogic : BaseLogic
|
||||||
|
{
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据用户Id得到登录账号信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userId"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public SysUserLogOn GetByAccount(string userId)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysUserLogOn>().Where(it => it.UserId == userId).First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新用户登录账号信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int UpdateLogin(SysUserLogOn model)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.IsOnLine = "1";
|
||||||
|
model.LastVisitTime = DateTime.Now;
|
||||||
|
model.PrevVisitTime = model.LastVisitTime;
|
||||||
|
model.LoginCount += 1;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.UserId;
|
||||||
|
return db.Updateable<SysUserLogOn>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.IsOnLine,
|
||||||
|
it.PrevVisitTime,
|
||||||
|
it.LastVisitTime,
|
||||||
|
it.LoginCount,
|
||||||
|
it.ModifyTime,
|
||||||
|
it.ModifyUserId
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改密码
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userLoginEntity"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int ModifyPwd(SysUserLogOn userLoginEntity)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
userLoginEntity.ChangePwdTime = DateTime.Now;
|
||||||
|
userLoginEntity.ModifyUserId = userLoginEntity.UserId;
|
||||||
|
userLoginEntity.ModifyTime = DateTime.Now;
|
||||||
|
|
||||||
|
return db.Updateable<SysUserLogOn>(userLoginEntity).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.Password,
|
||||||
|
it.ChangePwdTime,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除用户登录信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userIds"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Delete(List<string> userIds)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
List<SysUserLogOn> list = db.Queryable<SysUserLogOn>().Where(it => userIds.Contains(it.UserId)).ToList();
|
||||||
|
list.ForEach(it => { it.DeleteFlag = "Y"; });
|
||||||
|
return db.Updateable<SysUserLogOn>(list).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增用户登录账号
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Insert(SysUserLogOn model)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.Id = UUID.StrSnowId;
|
||||||
|
model.SecretKey = model.Id.DESEncrypt().Substring(0, 8);
|
||||||
|
model.Password = model.Password.MD5Encrypt().DESEncrypt(model.SecretKey).MD5Encrypt();
|
||||||
|
model.LoginCount = 0;
|
||||||
|
model.IsOnLine = "0";
|
||||||
|
model.EnableFlag = "Y";
|
||||||
|
model.DeleteFlag = "N";
|
||||||
|
model.CreateTime = DateTime.Now;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.UserId;
|
||||||
|
model.CreateUserId = model.UserId;
|
||||||
|
return db.Insertable<SysUserLogOn>(model).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 更新用户登录账号信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int UpdateInfo(SysUserLogOn model)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.UserId;
|
||||||
|
|
||||||
|
return db.Updateable<SysUserLogOn>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.AllowMultiUserOnline,
|
||||||
|
it.Question,
|
||||||
|
it.AnswerQuestion,
|
||||||
|
it.CheckIPAddress,
|
||||||
|
it.Language,
|
||||||
|
it.Theme,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int UpdateTheme(SysUserLogOn model)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.UserId;
|
||||||
|
return db.Updateable<SysUserLogOn>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.Theme,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int UpdatePassword(SysUserLogOn model)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.UserId;
|
||||||
|
return db.Updateable<SysUserLogOn>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.Password,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
509
DH.RBAC/Logic/Sys/SysUserLogic.cs
Normal file
509
DH.RBAC/Logic/Sys/SysUserLogic.cs
Normal file
@ -0,0 +1,509 @@
|
|||||||
|
|
||||||
|
using DH.RBAC.Logic.Base;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Security.Principal;
|
||||||
|
using DH.RBAC.Model.Sys;
|
||||||
|
|
||||||
|
using DH.RBAC.Utility.Other;
|
||||||
|
using SqlSugar;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Logic.Sys
|
||||||
|
{
|
||||||
|
public class SysUserLogic : BaseLogic
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 根据账号得到用户信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="account"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public SysUser GetByUserName(string account)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysUser>().Where(it => it.Account == account && it.DeleteFlag == "N")
|
||||||
|
.Includes(it => it.Organize)
|
||||||
|
.Includes(it => it.CreateUser)
|
||||||
|
.Includes(it => it.ModifyUser)
|
||||||
|
.First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 修改用户基础信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int UpdateBasicInfo(SysUser model, string account)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.ModifyUserId = account;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
return db.Updateable<SysUser>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.RealName,
|
||||||
|
it.NickName,
|
||||||
|
it.Gender,
|
||||||
|
it.Birthday,
|
||||||
|
it.MobilePhone,
|
||||||
|
it.Avatar,
|
||||||
|
it.Email,
|
||||||
|
it.Signature,
|
||||||
|
it.Address,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int AppUpdateBasicInfo(SysUser model)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.ModifyUserId = model.Id;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
return db.Updateable<SysUser>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.RealName,
|
||||||
|
it.NickName,
|
||||||
|
it.Gender,
|
||||||
|
it.Birthday,
|
||||||
|
it.MobilePhone,
|
||||||
|
it.Avatar,
|
||||||
|
it.Email,
|
||||||
|
it.Signature,
|
||||||
|
it.Address,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Insert(SysUser model, string password, string account, string[] roleIds)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
db.BeginTran();
|
||||||
|
////新增用户基本信息。
|
||||||
|
model.Id = UUID.StrSnowId;
|
||||||
|
model.EnableFlag = "Y";
|
||||||
|
model.DeleteFlag = "N";
|
||||||
|
model.CreateUserId = account;
|
||||||
|
model.CreateTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.CreateUserId;
|
||||||
|
model.ModifyTime = model.CreateTime;
|
||||||
|
model.Avatar = "/Content/framework/images/avatar.png";
|
||||||
|
int row = db.Insertable<SysUser>(model).ExecuteCommand();
|
||||||
|
if (row == 0)
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
//新增新的角色
|
||||||
|
List<SysUserRoleRelation> list = new List<SysUserRoleRelation>();
|
||||||
|
foreach (string roleId in roleIds)
|
||||||
|
{
|
||||||
|
SysUserRoleRelation roleRelation = new SysUserRoleRelation
|
||||||
|
{
|
||||||
|
Id = UUID.StrSnowId,
|
||||||
|
UserId = model.Id,
|
||||||
|
RoleId = roleId,
|
||||||
|
EnableFlag = "Y",
|
||||||
|
DeleteFlag = "N",
|
||||||
|
CreateUserId = account,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
ModifyUserId = account,
|
||||||
|
ModifyTime = DateTime.Now
|
||||||
|
};
|
||||||
|
list.Add(roleRelation);
|
||||||
|
}
|
||||||
|
row = db.Insertable<SysUserRoleRelation>(list).ExecuteCommand();
|
||||||
|
if (row == 0)
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
//新增用户登陆信息。
|
||||||
|
SysUserLogOn userLogOnEntity = new SysUserLogOn();
|
||||||
|
userLogOnEntity.Id = UUID.StrSnowId;
|
||||||
|
userLogOnEntity.UserId = model.Id;
|
||||||
|
userLogOnEntity.SecretKey = userLogOnEntity.Id.DESEncrypt().Substring(0, 8);
|
||||||
|
userLogOnEntity.Password = password.MD5Encrypt().DESEncrypt(userLogOnEntity.SecretKey).MD5Encrypt();
|
||||||
|
userLogOnEntity.LoginCount = 0;
|
||||||
|
userLogOnEntity.IsOnLine = "0";
|
||||||
|
userLogOnEntity.EnableFlag = "Y";
|
||||||
|
userLogOnEntity.DeleteFlag = "N";
|
||||||
|
userLogOnEntity.CreateUserId = account;
|
||||||
|
userLogOnEntity.CreateTime = DateTime.Now;
|
||||||
|
userLogOnEntity.ModifyUserId = account;
|
||||||
|
userLogOnEntity.ModifyTime = DateTime.Now;
|
||||||
|
row = db.Insertable<SysUserLogOn>(userLogOnEntity).ExecuteCommand();
|
||||||
|
if (row == 0)
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
db.CommitTran();
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool ContainsUser(string userAccount, params string[] userIdList)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
List<string> accountList = db.Queryable<SysUser>().Where(it => userIdList.Contains(it.Id)).Select(it => it.Account).ToList();
|
||||||
|
if (accountList.IsNullOrEmpty())
|
||||||
|
return false;
|
||||||
|
if (accountList.Contains(userAccount))
|
||||||
|
return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public int AppInsert(SysUser model, string password, string[] roleIds, string opearateUser)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
db.BeginTran();
|
||||||
|
////新增用户基本信息。
|
||||||
|
model.Id = UUID.StrSnowId;
|
||||||
|
model.EnableFlag = "Y";
|
||||||
|
model.DeleteFlag = "N";
|
||||||
|
model.CreateUserId = opearateUser;
|
||||||
|
model.CreateTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.CreateUserId;
|
||||||
|
model.ModifyTime = model.CreateTime;
|
||||||
|
model.Avatar = "/Content/framework/images/avatar.png";
|
||||||
|
int row = db.Insertable<SysUser>(model).ExecuteCommand();
|
||||||
|
if (row == 0)
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
|
||||||
|
//新增新的角色
|
||||||
|
List<SysUserRoleRelation> list = new List<SysUserRoleRelation>();
|
||||||
|
foreach (string roleId in roleIds)
|
||||||
|
{
|
||||||
|
SysUserRoleRelation roleRelation = new SysUserRoleRelation
|
||||||
|
{
|
||||||
|
Id = UUID.StrSnowId,
|
||||||
|
UserId = model.Id,
|
||||||
|
RoleId = roleId,
|
||||||
|
EnableFlag = "Y",
|
||||||
|
DeleteFlag = "N",
|
||||||
|
CreateUserId = opearateUser,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
ModifyUserId = opearateUser,
|
||||||
|
ModifyTime = DateTime.Now
|
||||||
|
};
|
||||||
|
list.Add(roleRelation);
|
||||||
|
}
|
||||||
|
row = db.Insertable<SysUserRoleRelation>(list).ExecuteCommand();
|
||||||
|
if (row == 0)
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
//新增用户登陆信息。
|
||||||
|
SysUserLogOn userLogOnEntity = new SysUserLogOn();
|
||||||
|
userLogOnEntity.Id = UUID.StrSnowId;
|
||||||
|
userLogOnEntity.UserId = model.Id;
|
||||||
|
userLogOnEntity.SecretKey = userLogOnEntity.Id.DESEncrypt().Substring(0, 8);
|
||||||
|
userLogOnEntity.Password = password.DESEncrypt(userLogOnEntity.SecretKey).MD5Encrypt();
|
||||||
|
userLogOnEntity.LoginCount = 0;
|
||||||
|
userLogOnEntity.IsOnLine = "0";
|
||||||
|
userLogOnEntity.EnableFlag = "Y";
|
||||||
|
userLogOnEntity.DeleteFlag = "N";
|
||||||
|
userLogOnEntity.CreateUserId = opearateUser;
|
||||||
|
userLogOnEntity.CreateTime = DateTime.Now;
|
||||||
|
userLogOnEntity.ModifyUserId = userLogOnEntity.CreateUserId;
|
||||||
|
userLogOnEntity.ModifyTime = userLogOnEntity.CreateTime;
|
||||||
|
row = db.Insertable<SysUserLogOn>(userLogOnEntity).ExecuteCommand();
|
||||||
|
if (row == 0)
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
db.CommitTran();
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据主键得到用户信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="primaryKey"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public SysUser Get(string primaryKey)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysUser>().Where(it => it.Id == primaryKey)
|
||||||
|
.Includes(it => it.Organize)
|
||||||
|
.Includes(it => it.CreateUser)
|
||||||
|
.Includes(it => it.ModifyUser).First();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获得用户列表分页
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="pageIndex"></param>
|
||||||
|
/// <param name="pageSize"></param>
|
||||||
|
/// <param name="keyWord"></param>
|
||||||
|
/// <param name="totalCount"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<SysUser> GetList(int pageIndex, int pageSize, string keyWord, ref int totalCount)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
ISugarQueryable<SysUser> queryable = db.Queryable<SysUser>().Where(it => it.DeleteFlag == "N");
|
||||||
|
if (!keyWord.IsNullOrEmpty())
|
||||||
|
{
|
||||||
|
queryable = queryable.Where(it => it.Account.Contains(keyWord) || it.RealName.Contains(keyWord));
|
||||||
|
}
|
||||||
|
return queryable.OrderBy(it => it.SortCode)
|
||||||
|
.Includes(it => it.Organize)
|
||||||
|
.Includes(it => it.CreateUser)
|
||||||
|
.Includes(it => it.ModifyUser).ToPageList(pageIndex, pageSize, ref totalCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 删除用户信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="primaryKeys"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Delete(List<string> primaryKeys)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
List<SysUser> list = db.Queryable<SysUser>().Where(it => primaryKeys.Contains(it.Id)).ToList();
|
||||||
|
list.ForEach(it => { it.DeleteFlag = "Y"; });
|
||||||
|
return db.Updateable<SysUser>(list).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 新增用户基础信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Insert(SysUser model, string account)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.Id = UUID.StrSnowId;
|
||||||
|
model.DeleteFlag = "N";
|
||||||
|
model.EnableFlag = "Y";
|
||||||
|
|
||||||
|
|
||||||
|
model.CreateUserId = account;
|
||||||
|
model.CreateTime = DateTime.Now;
|
||||||
|
model.ModifyUserId = model.CreateUserId;
|
||||||
|
model.ModifyTime = model.CreateTime;
|
||||||
|
model.Avatar = "/Content/framework/images/avatar.png";
|
||||||
|
return db.Insertable<SysUser>(model).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// 更新用户基础信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Update(SysUser model, string account)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
model.ModifyUserId = account;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
|
||||||
|
return db.Updateable<SysUser>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.NickName,
|
||||||
|
it.RealName,
|
||||||
|
it.Birthday,
|
||||||
|
it.Gender,
|
||||||
|
it.Email,
|
||||||
|
it.DepartmentId,
|
||||||
|
it.RoleId,
|
||||||
|
it.MobilePhone,
|
||||||
|
it.Address,
|
||||||
|
it.Signature,
|
||||||
|
it.SortCode,
|
||||||
|
it.IsEnabled,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public int AppUpdateAndSetRole(SysUser model, string[] roleIds, string opereateUser)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
db.BeginTran();
|
||||||
|
model.ModifyUserId = opereateUser;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
int row = db.Updateable<SysUser>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.NickName,
|
||||||
|
it.RealName,
|
||||||
|
it.Birthday,
|
||||||
|
it.Gender,
|
||||||
|
it.Email,
|
||||||
|
it.DepartmentId,
|
||||||
|
it.RoleId,
|
||||||
|
it.MobilePhone,
|
||||||
|
it.Address,
|
||||||
|
it.Signature,
|
||||||
|
it.SortCode,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (row == 0)
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
//删除原来的角色
|
||||||
|
List<SysUserRoleRelation> list2 = db.Queryable<SysUserRoleRelation>().Where(it => it.UserId == model.Id && it.DeleteFlag == "N").ToList();
|
||||||
|
list2.ForEach(it => { it.DeleteFlag = "Y"; });
|
||||||
|
db.Updateable<SysUserRoleRelation>(list2).ExecuteCommand();
|
||||||
|
//新增新的角色
|
||||||
|
List<SysUserRoleRelation> list = new List<SysUserRoleRelation>();
|
||||||
|
foreach (string roleId in roleIds)
|
||||||
|
{
|
||||||
|
SysUserRoleRelation roleRelation = new SysUserRoleRelation
|
||||||
|
{
|
||||||
|
Id = UUID.StrSnowId,
|
||||||
|
UserId = model.Id,
|
||||||
|
RoleId = roleId,
|
||||||
|
DeleteFlag = "N",
|
||||||
|
EnableFlag = "Y",
|
||||||
|
CreateUserId = opereateUser,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
ModifyUserId = opereateUser,
|
||||||
|
ModifyTime = DateTime.Now
|
||||||
|
};
|
||||||
|
list.Add(roleRelation);
|
||||||
|
}
|
||||||
|
row = db.Insertable<SysUserRoleRelation>(list).ExecuteCommand();
|
||||||
|
if (row == 0)
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
db.CommitTran();
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int UpdateAndSetRole(SysUser model, string account, string[] roleIds)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
db.BeginTran();
|
||||||
|
model.ModifyUserId = account;
|
||||||
|
model.ModifyTime = DateTime.Now;
|
||||||
|
int row = db.Updateable<SysUser>(model).UpdateColumns(it => new
|
||||||
|
{
|
||||||
|
it.NickName,
|
||||||
|
it.RealName,
|
||||||
|
it.Birthday,
|
||||||
|
it.Gender,
|
||||||
|
it.Email,
|
||||||
|
it.DepartmentId,
|
||||||
|
it.RoleId,
|
||||||
|
it.MobilePhone,
|
||||||
|
it.Address,
|
||||||
|
it.Signature,
|
||||||
|
it.SortCode,
|
||||||
|
it.EnableFlag,
|
||||||
|
it.ModifyUserId,
|
||||||
|
it.ModifyTime
|
||||||
|
}).ExecuteCommand();
|
||||||
|
if (row == 0)
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
//删除原来的角色
|
||||||
|
List<SysUserRoleRelation> list2 = db.Queryable<SysUserRoleRelation>().Where(it => it.UserId == model.Id && it.DeleteFlag == "N").ToList();
|
||||||
|
list2.ForEach(it => { it.DeleteFlag = "Y"; });
|
||||||
|
db.Updateable<SysUserRoleRelation>(list2).ExecuteCommand();
|
||||||
|
//新增新的角色
|
||||||
|
List<SysUserRoleRelation> list = new List<SysUserRoleRelation>();
|
||||||
|
foreach (string roleId in roleIds)
|
||||||
|
{
|
||||||
|
SysUserRoleRelation roleRelation = new SysUserRoleRelation
|
||||||
|
{
|
||||||
|
Id = UUID.StrSnowId,
|
||||||
|
UserId = model.Id,
|
||||||
|
RoleId = roleId,
|
||||||
|
EnableFlag = "Y",
|
||||||
|
DeleteFlag = "N",
|
||||||
|
CreateUserId = account,
|
||||||
|
CreateTime = DateTime.Now,
|
||||||
|
ModifyTime = DateTime.Now,
|
||||||
|
ModifyUserId = account
|
||||||
|
};
|
||||||
|
list.Add(roleRelation);
|
||||||
|
}
|
||||||
|
row = db.Insertable<SysUserRoleRelation>(list).ExecuteCommand();
|
||||||
|
if (row == 0)
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
db.CommitTran();
|
||||||
|
return row;
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
db.RollbackTran();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
57
DH.RBAC/Logic/Sys/SysUserRoleRelationLogic.cs
Normal file
57
DH.RBAC/Logic/Sys/SysUserRoleRelationLogic.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using DH.RBAC.Model.Sys;
|
||||||
|
using DH.RBAC.Logic.Base;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
|
||||||
|
namespace DH.RBAC.Logic.Sys
|
||||||
|
{
|
||||||
|
public class SysUserRoleRelationLogic : BaseLogic
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 删除用户角色关系
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userIds"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public int Delete(List<string> userIds)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
List<SysUserRoleRelation> list = db.Queryable<SysUserRoleRelation>().Where(it => userIds.Contains(it.UserId)).ToList();
|
||||||
|
list.ForEach(it => { it.DeleteFlag = "Y"; });
|
||||||
|
return db.Updateable<SysUserRoleRelation>(list).ExecuteCommand();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据ID得到用户角色关系
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="userIds"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<SysUserRoleRelation> GetList(string userId)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysUserRoleRelation>().Where(it => it.UserId == userId && it.DeleteFlag=="N").ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 从用户角色关系表中得到所有角色绑定信息
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="ids"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public List<SysUserRoleRelation> GetByRoles(List<string> ids)
|
||||||
|
{
|
||||||
|
using (var db = GetInstance())
|
||||||
|
{
|
||||||
|
return db.Queryable<SysUserRoleRelation>().Where(it => ids.Contains(it.RoleId) && it.DeleteFlag == "N").ToList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
91
DH.RBAC/Models/Base/BaseModelEntity.cs
Normal file
91
DH.RBAC/Models/Base/BaseModelEntity.cs
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
using AntdUI;
|
||||||
|
using DH.RBAC.Model.Sys;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model
|
||||||
|
{
|
||||||
|
public class BaseModelEntity: NotifyProperty
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 是否启用
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "EnableFlag", ColumnDescription = "是否启用", IsNullable = true, Length = 1)]
|
||||||
|
public virtual string EnableFlag { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 是否删除
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "DeleteFlag", ColumnDescription = "是否删除", IsNullable = true, Length = 1)]
|
||||||
|
public virtual string DeleteFlag { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 创建人
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "CreateUserId", ColumnDescription = "创建人", IsNullable = true, Length = 255)]
|
||||||
|
public virtual string CreateUserId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 创建时间
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "CreateTime", ColumnDescription = "创建时间", IsNullable = true, Length = 3)]
|
||||||
|
public virtual DateTime? CreateTime { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 更新人
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "ModifyUserId", ColumnDescription = "更新人", IsNullable = true, Length = 255)]
|
||||||
|
public virtual string ModifyUserId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// 更新时间
|
||||||
|
/// </summary>
|
||||||
|
[SugarColumn(ColumnName = "ModifyTime", ColumnDescription = "更新时间", IsNullable = true, Length = 3)]
|
||||||
|
public virtual DateTime? ModifyTime { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 创建人
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
[Navigate(NavigateType.OneToOne, nameof(CreateUserId), nameof(SysUser.Id))]//一对一 SchoolId是StudentA类里面的
|
||||||
|
public SysUser CreateUser { get; set; } //不能赋值只能是null
|
||||||
|
/// <summary>
|
||||||
|
/// 更新人
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
[Navigate(NavigateType.OneToOne, nameof(ModifyUserId), nameof(SysUser.Id))]//一对一 SchoolId是StudentA类里面的
|
||||||
|
public SysUser ModifyUser { get; set; } //不能赋值只能是null
|
||||||
|
|
||||||
|
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public string CreateUserName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return CreateUser == null ? "" : CreateUser.RealName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public string ModifyUserName
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return ModifyUser == null ? "" : ModifyUser.RealName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public bool IsDeleted
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return DeleteFlag == "Y" ? true : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[SugarColumn(IsIgnore = true)]
|
||||||
|
public bool IsEnabled
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return EnableFlag == "Y" ? true : false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
22
DH.RBAC/Models/Base/CodeGenerator.cs
Normal file
22
DH.RBAC/Models/Base/CodeGenerator.cs
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.Base
|
||||||
|
{
|
||||||
|
public class CodeGenerator
|
||||||
|
{
|
||||||
|
public string TableName { get; set; }
|
||||||
|
public string ColumnName { get; set; }
|
||||||
|
public string TypeName { get; set; }
|
||||||
|
public string TypeLength { get; set; }
|
||||||
|
public string IsPrimaryKey { get; set; }
|
||||||
|
public string ClassName { get; set; }
|
||||||
|
public string PropertyName { get; set; }
|
||||||
|
public string CSType { get; set; }
|
||||||
|
|
||||||
|
public string Other { get; set; }
|
||||||
|
}
|
||||||
|
}
|
20
DH.RBAC/Models/Base/MenuControlAttribute.cs
Normal file
20
DH.RBAC/Models/Base/MenuControlAttribute.cs
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Models.Base
|
||||||
|
{
|
||||||
|
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false)]
|
||||||
|
public class MenuControlAttribute : Attribute
|
||||||
|
{
|
||||||
|
public string ParentMenu { get; } // 父菜单名称(如 "相机设置")
|
||||||
|
public Type ConfigType { get; } // 配置类型(如 CameraBase)
|
||||||
|
|
||||||
|
public MenuControlAttribute(string parentMenu)
|
||||||
|
{
|
||||||
|
ParentMenu = parentMenu;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
16
DH.RBAC/Models/DTO/Parms/AuthorParms.cs
Normal file
16
DH.RBAC/Models/DTO/Parms/AuthorParms.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.DTO.Parms
|
||||||
|
{
|
||||||
|
public class AuthorParms
|
||||||
|
{
|
||||||
|
public string roleId { get; set; }
|
||||||
|
public List<string> perIds { get; set; }
|
||||||
|
|
||||||
|
public string operater { get; set; }
|
||||||
|
}
|
||||||
|
}
|
14
DH.RBAC/Models/DTO/Parms/FileUploadParms.cs
Normal file
14
DH.RBAC/Models/DTO/Parms/FileUploadParms.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.DTO.Parms
|
||||||
|
{
|
||||||
|
public class FileUploadParms
|
||||||
|
{
|
||||||
|
public byte[] file { get; set; }
|
||||||
|
public string fileName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
17
DH.RBAC/Models/DTO/Parms/ItemDetailIndexParms.cs
Normal file
17
DH.RBAC/Models/DTO/Parms/ItemDetailIndexParms.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.DTO.Parms
|
||||||
|
{
|
||||||
|
public class ItemDetailIndexParms
|
||||||
|
{
|
||||||
|
public int pageIndex { get; set; }
|
||||||
|
public int pageSize { get; set; }
|
||||||
|
|
||||||
|
public string keyWord { get; set; }
|
||||||
|
public string itemId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
14
DH.RBAC/Models/DTO/Parms/KeyValue.cs
Normal file
14
DH.RBAC/Models/DTO/Parms/KeyValue.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.DTO.Parms
|
||||||
|
{
|
||||||
|
public class KeyValue
|
||||||
|
{
|
||||||
|
public string Name { get; set; }
|
||||||
|
public string Value { get; set; }
|
||||||
|
}
|
||||||
|
}
|
15
DH.RBAC/Models/DTO/Parms/LogDeleteParms.cs
Normal file
15
DH.RBAC/Models/DTO/Parms/LogDeleteParms.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.DTO.Parms
|
||||||
|
{
|
||||||
|
public class LogDeleteParms
|
||||||
|
{
|
||||||
|
public string type { get; set; }
|
||||||
|
public string index { get; set; }
|
||||||
|
public string operateUser { get; set; }
|
||||||
|
}
|
||||||
|
}
|
17
DH.RBAC/Models/DTO/Parms/LogIndexParms.cs
Normal file
17
DH.RBAC/Models/DTO/Parms/LogIndexParms.cs
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.DTO.Parms
|
||||||
|
{
|
||||||
|
public class LogIndexParms
|
||||||
|
{
|
||||||
|
public int pageIndex { get; set; }
|
||||||
|
public int pageSize { get; set; }
|
||||||
|
public string type { get; set; }
|
||||||
|
public string index { get; set; }
|
||||||
|
public string keyWord { get; set; }
|
||||||
|
}
|
||||||
|
}
|
18
DH.RBAC/Models/DTO/Parms/LongPrimaryKeyParms.cs
Normal file
18
DH.RBAC/Models/DTO/Parms/LongPrimaryKeyParms.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.DTO.Parms
|
||||||
|
{
|
||||||
|
public class LongPrimaryKeyParms
|
||||||
|
{
|
||||||
|
public string operaterId { get; set; }
|
||||||
|
public long primaryKey { get; set; }
|
||||||
|
|
||||||
|
public string operateUser { get; set; }
|
||||||
|
public string userIds { get; set; }
|
||||||
|
public string roleId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
16
DH.RBAC/Models/DTO/Parms/ModifyPasswordParms.cs
Normal file
16
DH.RBAC/Models/DTO/Parms/ModifyPasswordParms.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.DTO.Parms
|
||||||
|
{
|
||||||
|
public class ModifyPasswordParms
|
||||||
|
{
|
||||||
|
public string userId { get; set; }
|
||||||
|
public string oldPassword { get; set; }
|
||||||
|
public string newPassword { get; set; }
|
||||||
|
public string confirmPassword { get; set; }
|
||||||
|
}
|
||||||
|
}
|
14
DH.RBAC/Models/DTO/Parms/RoleDeleteParms.cs
Normal file
14
DH.RBAC/Models/DTO/Parms/RoleDeleteParms.cs
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.DTO.Parms
|
||||||
|
{
|
||||||
|
public class RoleDeleteParms
|
||||||
|
{
|
||||||
|
public List<string> roleIdList { get; set; }
|
||||||
|
public string operateUser { get; set; }
|
||||||
|
}
|
||||||
|
}
|
15
DH.RBAC/Models/DTO/Parms/SearchParms.cs
Normal file
15
DH.RBAC/Models/DTO/Parms/SearchParms.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.DTO.Parms
|
||||||
|
{
|
||||||
|
public class SearchParms
|
||||||
|
{
|
||||||
|
public int pageIndex { get; set; }
|
||||||
|
public int pageSize { get; set; }
|
||||||
|
public string keyWord { get; set; }
|
||||||
|
}
|
||||||
|
}
|
18
DH.RBAC/Models/DTO/Parms/StrPrimaryKeyParms.cs
Normal file
18
DH.RBAC/Models/DTO/Parms/StrPrimaryKeyParms.cs
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.DTO.Parms
|
||||||
|
{
|
||||||
|
public class StrPrimaryKeyParms
|
||||||
|
{
|
||||||
|
public string operaterId { get; set; }
|
||||||
|
public string primaryKey { get; set; }
|
||||||
|
|
||||||
|
public string operateUser { get; set; }
|
||||||
|
public string userIds { get; set; }
|
||||||
|
public string roleId { get; set; }
|
||||||
|
}
|
||||||
|
}
|
16
DH.RBAC/Models/DTO/Parms/UserDeleteParms.cs
Normal file
16
DH.RBAC/Models/DTO/Parms/UserDeleteParms.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.DTO.Parms
|
||||||
|
{
|
||||||
|
public class UserDeleteParms
|
||||||
|
{
|
||||||
|
public List<string> userIdList { get; set; }
|
||||||
|
|
||||||
|
public string currentUserId { get; set; }
|
||||||
|
public string operateUser { get; set; }
|
||||||
|
}
|
||||||
|
}
|
15
DH.RBAC/Models/DTO/Parms/UserLoginParms.cs
Normal file
15
DH.RBAC/Models/DTO/Parms/UserLoginParms.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.DTO.Parms
|
||||||
|
{
|
||||||
|
public class UserLoginParms
|
||||||
|
{
|
||||||
|
public string verifyCode { get; set; }
|
||||||
|
public string userName { get; set; }
|
||||||
|
public string password { get; set; }
|
||||||
|
}
|
||||||
|
}
|
27
DH.RBAC/Models/Enum/ModuleType.cs
Normal file
27
DH.RBAC/Models/Enum/ModuleType.cs
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
namespace DH.RBAC.Model.Enum
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 权限类型。
|
||||||
|
/// </summary>
|
||||||
|
public class ModuleType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 主菜单。
|
||||||
|
/// </summary>
|
||||||
|
public const int Menu = 2;
|
||||||
|
/// <summary>
|
||||||
|
/// 子菜单
|
||||||
|
/// </summary>
|
||||||
|
public const int SubMenu = 0;
|
||||||
|
/// <summary>
|
||||||
|
/// 按钮。
|
||||||
|
/// </summary>
|
||||||
|
public const int Button = 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
37
DH.RBAC/Models/Sys/SysItem.cs
Normal file
37
DH.RBAC/Models/Sys/SysItem.cs
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace DH.RBAC.Model.Sys
|
||||||
|
{
|
||||||
|
[SugarTable("Sys_Item")]
|
||||||
|
public partial class SysItem : BaseModelEntity
|
||||||
|
{
|
||||||
|
[SugarColumn(ColumnName = "Id", IsPrimaryKey = true)]
|
||||||
|
public string Id { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(ColumnName = "EnCode")]
|
||||||
|
public string EnCode { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(ColumnName = "ParentId")]
|
||||||
|
public string ParentId { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(ColumnName = "Name")]
|
||||||
|
public string Name { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(ColumnName = "Layer")]
|
||||||
|
public int? Layer { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(ColumnName = "SortCode")]
|
||||||
|
public int? SortCode { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(ColumnName = "IsTree")]
|
||||||
|
public string IsTree { get; set; }
|
||||||
|
|
||||||
|
[SugarColumn(ColumnName = "Remark")]
|
||||||
|
public string Remark { get; set; }
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user