2 Commits

Author SHA1 Message Date
7011e4f353 1 2025-03-18 14:25:41 +08:00
6696c4e106 修改config 2025-03-18 14:20:11 +08:00
161 changed files with 4681 additions and 21657 deletions

View File

@ -110,7 +110,7 @@ namespace CanFly.Canvas.Shape
/// <summary>
/// 是否填充多边形使用select_fill_color 或 fill_color 填充
/// 是否填充多边形 使用select_fill_color 或 fill_color 填充
/// </summary>
public bool fill = false;

View File

@ -3,14 +3,14 @@
partial class FlyCanvas
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
///// <summary>
///// 清理所有正在使用的资源
///// 清理所有正在使用的资源
///// </summary>
///// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
///// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
//protected override void Dispose(bool disposing)
//{
// if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -1704,9 +1704,9 @@ namespace CanFly.Canvas.UI
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))

View File

@ -1,10 +1,10 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成
// 此代码由工具生成
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失
// 重新生成代码,这些更改将会丢失
// </auto-generated>
//------------------------------------------------------------------------------
@ -13,12 +13,12 @@ namespace XKRS.CanFly.Properties {
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等
/// 一个强类型的资源类,用于查找本地化的字符串等
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目
// (以 /str 作为命令选项),或重新生成 VS 项目
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
@ -33,7 +33,7 @@ namespace XKRS.CanFly.Properties {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例
/// 返回此类使用的缓存的 ResourceManager 实例
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
@ -48,7 +48,7 @@ namespace XKRS.CanFly.Properties {
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写
/// 使用此强类型资源类的所有资源查找执行重写
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
@ -61,7 +61,7 @@ namespace XKRS.CanFly.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap Close {
get {

View File

@ -3,14 +3,14 @@
partial class CtrlTitleBar
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class GuideCircleCtrl
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class GuideHeightCtrl
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class GuideLineCircleCtrl
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class GuideLineCtrl
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -11,6 +11,12 @@
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Halcon\**" />
<EmbeddedResource Remove="Halcon\**" />
<None Remove="Halcon\**" />
</ItemGroup>
@ -24,10 +30,6 @@
<ProjectReference Include="..\CanFly.Canvas\CanFly.Canvas.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Halcon\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="OpenCvSharp4" Version="4.10.0.20241108" />
<PackageReference Include="OpenCvSharp4.Extensions" Version="4.10.0.20241108" />

View File

@ -2,70 +2,32 @@
using System.ComponentModel;
using System.Drawing.Imaging;
using AntdUI;
using DH.Commons.Enums;
using HalconDotNet;
using OpenCvSharp;
namespace DH.Commons.Base
namespace DH.Devices.Devices
{
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 LoggerHelper LoggerHelper { get; set; } = new LoggerHelper();
// 私有字段 + 带通知的属性与DetectionLabel风格一致
private bool _isEnabled = false;
private bool _isallPicEnabled = true;//默认全画幅
private bool _isContinueMode = false;
private bool _isSavePicEnabled = false;
private string _imageSaveDirectory;
private EnumCamType _CamType;
private ImageFormat _imageFormat = ImageFormat.Jpeg;
private bool _isHardwareTrigger = true;
private bool _isHardwareTrigger = false;
private string _serialNumber = string.Empty;
private string _cameraName = string.Empty;
private string _cameraIP = string.Empty;
private string _computerIP = string.Empty;
private bool _isDirectHardwareTrigger = false;
private float _gain =6;
private float _gain = -1;
private float _rotateImage = 0;
private float _exposure = 200;
private float _triggerDelay = 0;
private decimal _roiX = 0;
private decimal _roiY = 0;
private decimal _roiW = 2448;
private decimal _roiH = 2048;
private decimal _roiW = 0;
private decimal _roiH = 0;
private int _lineDebouncerTime = 0;
public volatile int SnapshotCount = 0;
@ -94,16 +56,7 @@ namespace DH.Commons.Base
OnPropertyChanged(nameof(IsEnabled));
}
}
public virtual bool IsAllPicEnabled
{
get => _isallPicEnabled;
set
{
if (_isallPicEnabled == value) return;
_isallPicEnabled = value;
OnPropertyChanged(nameof(IsAllPicEnabled));
}
}
public virtual bool IsSavePicEnabled
{
get => _isSavePicEnabled;
@ -142,19 +95,6 @@ namespace DH.Commons.Base
OnPropertyChanged(nameof(ImageFormat));
}
}
[Category("设备配置")]
[DisplayName("相机类型")]
[Description("相机类型")]
public EnumCamType CamType
{
get => _CamType;
set
{
if (_CamType == value) return;
_CamType = value;
OnPropertyChanged(nameof(CamType));
}
}
[Category("采图模式")]
[DisplayName("硬触发")]

View File

@ -0,0 +1,186 @@
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";
}
}

View File

@ -21,7 +21,6 @@
<PackageReference Include="OpenCvSharp4" 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="System.IO.Ports" Version="9.0.3" />
</ItemGroup>
<ItemGroup>

View File

@ -1,389 +0,0 @@

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
}
}

View File

@ -1,131 +0,0 @@
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
{
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 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));
}
}
}
}
}

View File

@ -1,378 +0,0 @@
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));
// }
//}
}
}

View File

@ -1,78 +0,0 @@
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(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 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);
}
}
}
}

View File

@ -16,11 +16,9 @@
<ItemGroup>
<PackageReference Include="AntdUI" Version="1.8.9" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="OpenCvSharp4" 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="System.IO.Ports" Version="9.0.3" />
</ItemGroup>
<ItemGroup>

View File

@ -0,0 +1,16 @@
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; }
}
}

View File

@ -7,61 +7,12 @@ using System.Threading.Tasks;
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
{
[Description("信捷XC串口")]
XC串口 = 0,
[Description("信捷XC网口")]
XC网口 = 1,
[Description("信捷XD串口")]
XD串口 = 2,
[Description("信捷XD网口")]
XD网口 = 3
XC_串口,
XC_网口,
XD_串口,
XD_网口
}
@ -77,70 +28,35 @@ namespace DH.Commons.Enums
public enum EnumPLCOutputIO
{
=0,
,
使,
,
,
绿,
,
,
,
,
,
1,
2,
3,
4,
5,
6 ,
7 ,
8 ,
9 ,
10 ,
,
,
,
,
,
,
,
,
,
,
,
,
,
,
OK脉冲,
NG脉冲,
,
,
=1,
使=2,
=3,
=4,
绿=5,
=6,
=7,
=8,
=9,
=10,
1=11,
2=12,
3=13,
4=14,
5=15,
OK料盒=16,
NG料盒=17,
OK吹气时间=18,
NG吹气时间=19,
=20,
=21,
=22,
=23,
=24,
=25
}
public enum EnumPLCDataType
{
,
,
,
}
public enum EnumBool
{
,
}
public enum EnumBool1
{
False,
True
}
public enum StreamFormat
{
[Description("8位图像")]

View File

@ -1,64 +0,0 @@
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
{
}
}

View File

@ -1,162 +0,0 @@
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>
/// 用来修饰对外开放的调用方法的特性
/// 调用方法参数顺序IOperationConfigInvokeDeviceSourceDevice
/// </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;
}
}
}

View File

@ -1,272 +0,0 @@
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.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)
{
// 根据实际需求格式化输出
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>();
}
}
}

View File

@ -76,83 +76,159 @@ namespace DH.Commons.Enums
}
}
// 根据描述获取枚举值(泛型方法)
public static T GetEnumFromDescription<T>(string description) where T : Enum
{
Type enumType = typeof(T);
foreach (T value in Enum.GetValues(enumType))
{
string desc = GetEnumDescription(value);
if (desc == description)
{
return value;
}
}
throw new ArgumentException($"在枚举 {enumType.Name} 中未找到描述为 '{description}' 的值");
}
//public static System.Windows.Media.Color GetEnumSelectedMediaColor(this Enum enumObj)
//{
// Type t = enumObj.GetType();
// FieldInfo f = t.GetField(enumObj.ToString());
// ColorSelectAttribute attr = f.GetCustomAttribute<ColorSelectAttribute>();
// if (attr != null)
// {
// var prop = typeof(System.Windows.Media.Colors).GetProperties().FirstOrDefault(p => p.Name == attr.SelectedColor);
// if (prop != null)
// {
// return (System.Windows.Media.Color)prop.GetValue(null);
// }
// }
// 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>
/// <param name="enumType">枚举类型</param>
/// <returns>描述文本列表</returns>
public static List<string> GetEnumDescriptions(Type enumType)
{
// 验证类型是否为枚举
if (!enumType.IsEnum)
throw new ArgumentException("传入的类型必须是枚举类型", nameof(enumType));
/// <param name="stateToBe"></param>
/// <param name="currentState"></param>
/// <returns></returns>
//public static bool CheckPreStateValid(this Enum stateToBe, int currentState)
//{
// Type t = stateToBe.GetType();
// FieldInfo f = t.GetField(stateToBe.ToString());
var descriptions = new List<string>();
// PreStateAttribute attr = f.GetCustomAttribute<PreStateAttribute>();
// if (attr == null)
// {
// return true;
// }
// else
// {
// return attr.CheckPreStateValid(currentState);
// }
//}
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>
/// 设备状态定义
/// 未初始化和异常状态无前置状态要求
/// 初始化操作前置状态必须是未初始化、关闭状态和异常状态
/// 打开前置必须是初始化和暂停
/// 关闭前置必须是打开和暂停和异常
/// 暂停前置必须是打开
/// </summary>
//public enum DeviceState
//{
// TBD = -1,
return descriptions;
}
public static string GetEnumDescription1(Enum value)
{
var field = value.GetType().GetField(value.ToString());
var attribute = field.GetCustomAttributes(typeof(DescriptionAttribute), false)
.FirstOrDefault() as DescriptionAttribute;
return attribute?.Description ?? value.ToString();
}
// [ColorSelect("Gray")]
// [FontColorSelect("Black")]
// [Description("未初始化")]
// DSUninit = 1,
public static System.Drawing.Color GetEnumSelectedColor(this Enum enumObj)
{
Type t = enumObj.GetType();
FieldInfo f = t.GetField(enumObj.ToString());
// [ColorSelect("Gold")]
// [FontColorSelect("White")]
// [PreState(1 + 2 + 4 + 8 + 32)]
// [Description("初始化")]
// DSInit = 2,
ColorSelectAttribute attr = f.GetCustomAttribute<ColorSelectAttribute>();
if (attr != null)
{
return System.Drawing.Color.FromName(attr.SelectedColor);
}
else
{
return System.Drawing.Color.Transparent;
}
}
// [ColorSelect("Lime")]
// [FontColorSelect("Black")]
// [PreState(2 + 4 + 16)]
// [Description("运行中")]
// DSOpen = 4,
public static System.Drawing.Color GetEnumSelectedFontColor(this Enum enumObj)
{
Type t = enumObj.GetType();
FieldInfo f = t.GetField(enumObj.ToString());
// [ColorSelect("Gray")]
// [FontColorSelect("White")]
// [PreState(1 + 4 + 8 + 16 + 32)]
// [Description("关闭")]
// DSClose = 8,
var attr = f.GetCustomAttribute<FontColorSelectAttribute>();
if (attr != null)
{
return System.Drawing.Color.FromName(attr.SelectedColor);
}
else
{
return System.Drawing.Color.Transparent;
}
}
// [ColorSelect("Gold")]
// [FontColorSelect("White")]
// [PreState(4 + 16)]
// [Description("暂停")]
// DSPause = 16,
// [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]
public enum DeviceAttributeType
@ -285,38 +361,7 @@ namespace DH.Commons.Enums
[Description("测量结果")]
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
//{
// Halcon,
@ -337,59 +382,6 @@ namespace DH.Commons.Enums
// NG = -1,
// 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
{
@ -682,31 +674,31 @@ namespace DH.Commons.Enums
Warning = 8,
}
public enum ResultState
{
[Description("NA")]
NA = -5,
[Description("尺寸NG")]
SizeNG = -4,
[Description("检测NG")]
DetectNG = -3,
//public enum ResultState
//{
// [Description("NA")]
// NA = -5,
// [Description("尺寸NG")]
// SizeNG = -4,
// [Description("检测NG")]
// DetectNG = -3,
//[Description("检测不足TBD")]
// ShortageTBD = -2,
[Description("检测结果TBD")]
ResultTBD = -1,
[Description("OK")]
OK = 1,
// [Description("NG")]
// NG = 2,
//统计结果
[Description("A类NG")]
A_NG = 25,
[Description("B类NG")]
B_NG = 26,
[Description("C类NG")]
C_NG = 27,
}
// //[Description("检测不足TBD")]
// // ShortageTBD = -2,
// [Description("检测结果TBD")]
// ResultTBD = -1,
// [Description("OK")]
// OK = 1,
// // [Description("NG")]
// // NG = 2,
// //统计结果
// [Description("A类NG")]
// A_NG = 25,
// [Description("B类NG")]
// B_NG = 26,
// [Description("C类NG")]
// C_NG = 27,
//}
public enum HikCameraType
{
[Description("HikCamera-Gige")]

View File

@ -1,107 +0,0 @@

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;
}
}

View File

@ -1,138 +0,0 @@
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}";
}
}
}

View File

@ -571,8 +571,8 @@ namespace DH.Commons.Enums
}
//分别基于像素GetPixel和SetPixel、基于内存、基于指针这三种方法增强图片对比度
// 第一种方法:像素提取法速度慢 基于像素400-600ms
//分别基于像素GetPixel和SetPixel、基于内存、基于指针这三种方法增强图片对比度
// 第一种方法:像素提取法 速度慢 基于像素400-600ms
public static Bitmap MethodBaseOnPixel(Bitmap bitmap, int degree)
{
Color curColor;

View File

@ -1,117 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DH.Commons.Helper
{
public static class SchemeHelper
{
private const string SchemesKey = "Schemes";
private const string CurrentSchemeKey = "CurrentScheme";
private const char Separator = '|';
/// <summary>
/// 初始化配置(首次运行时调用)
/// </summary>
public static void Initialize()
{
// 如果Schemes不存在创建空键
if (!SystemConfigHelper.KeyExists(SchemesKey))
{
SystemConfigHelper.SetValue(SchemesKey, "");
}
// 如果CurrentScheme不存在创建空键
if (!SystemConfigHelper.KeyExists(CurrentSchemeKey))
{
SystemConfigHelper.SetValue(CurrentSchemeKey, "");
}
}
/// <summary>
/// 获取所有方案(自动处理空值)
/// </summary>
public static List<string> GetAllSchemes()
{
var schemeString = SystemConfigHelper.GetValue(SchemesKey, "");
return string.IsNullOrEmpty(schemeString)
? new List<string>()
: new List<string>(schemeString.Split(Separator));
}
/// <summary>
/// 添加新方案(自动初始化处理)
/// </summary>
public static void AddScheme(string schemeName)
{
if (string.IsNullOrWhiteSpace(schemeName))
throw new ArgumentException("方案名称无效");
var schemes = GetAllSchemes();
if (schemes.Contains(schemeName))
throw new InvalidOperationException($"方案 {schemeName} 已存在");
schemes.Add(schemeName);
SaveSchemes(schemes);
}
/// <summary>
/// 设置当前方案(空值安全处理)
/// </summary>
public static void SetCurrentScheme(string schemeName)
{
var schemes = GetAllSchemes();
if (!schemes.Contains(schemeName))
throw new KeyNotFoundException($"方案 {schemeName} 不存在");
SystemConfigHelper.SetValue(CurrentSchemeKey, schemeName);
}
/// <summary>
/// 获取当前方案(默认值处理)
/// </summary>
public static string GetCurrentScheme()
{
var current = SystemConfigHelper.GetValue(CurrentSchemeKey, "");
return !string.IsNullOrEmpty(current) ? current : "默认方案";
}
private static void SaveSchemes(List<string> schemes)
{
var schemeString = schemes.Count > 0
? string.Join(Separator.ToString(), schemes)
: "";
SystemConfigHelper.SetValue(SchemesKey, schemeString);
}
/// <summary>
/// 删除指定方案(自动同步当前方案状态)
/// </summary>
/// <param name="schemeName">要删除的方案名称</param>
/// <exception cref="ArgumentException">当方案名称为空时抛出</exception>
/// <exception cref="KeyNotFoundException">当方案不存在时抛出</exception>
public static void DeleteScheme(string schemeName)
{
if (string.IsNullOrWhiteSpace(schemeName))
throw new ArgumentException("方案名称无效");
var schemes = GetAllSchemes();
if (!schemes.Contains(schemeName))
throw new KeyNotFoundException($"方案 {schemeName} 不存在");
// 删除前检查是否是当前方案
bool isCurrent = GetCurrentScheme() == schemeName;
// 执行删除操作
schemes.Remove(schemeName);
SaveSchemes(schemes);
}
}
}

View File

@ -1,680 +0,0 @@
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));
}
}
}

View File

@ -1,120 +0,0 @@
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");
}
}
}

View File

@ -108,7 +108,7 @@ namespace DH.Commons.Enums
                DataGridViewCheckboxHeaderEventArgs ex = new DataGridViewCheckboxHeaderEventArgs();
ex.CheckedState = _checked;
object sender = new object();//此处不代表选择的列头checkbox只是作为参数传递因为列头checkbox是绘制出来的无法获得它的实例
object sender = new object();//此处不代表选择的列头checkbox只是作为参数传递 因为列头checkbox是绘制出来的无法获得它的实例
                if (OnCheckBoxClicked != null)
{

View File

@ -1,109 +0,0 @@

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;
}
}
}

View File

@ -1,26 +0,0 @@
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; }
}
}

View File

@ -1,34 +0,0 @@
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>();
}
}

View File

@ -24,6 +24,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DH.Commons.Devies\DH.Commons.Devies.csproj" />
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
</ItemGroup>

View File

@ -1,21 +1,17 @@
using System.Collections.Concurrent;
using System.Diagnostics;
using System.Diagnostics;
using System.Reflection.Metadata;
using System.Xml.Linq;
using DH.Commons.Base;
using DH.Commons.Enums;
using DH.Commons.Helper;
using DH.Devices.Devices;
using DVPCameraType;
using OpenCvSharp;
using OpenCvSharp.Extensions;
using static System.Net.Mime.MediaTypeNames;
using LogLevel = DH.Commons.Enums.EnumHelper.LogLevel;
namespace DH.Devices.Camera
{
public class Do3ThinkCamera : CameraBase, ILogger
public class Do3ThinkCamera : CameraBase
{
private dvpCameraInfo stDevInfo = new dvpCameraInfo();
@ -28,17 +24,9 @@ namespace DH.Devices.Camera
public dvpStreamFormat dvpStreamFormat = dvpStreamFormat.S_RGB24;
public int m_CamCount = 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()
{
LoggerHelper.LogPath = "D://";
LoggerHelper.LogPrefix = CameraName;
}
@ -142,43 +130,41 @@ namespace DH.Devices.Camera
throw new Exception($"Start grabbing failed:{nRet:x8}");
}
//// 曝光
if (Exposure != 0)
{
SetExposure(Exposure);
}
//if (IIConfig.DefaultExposure != 0)
//{
// SetExposure(IIConfig.DefaultExposure);
//}
//// 增益
if (Gain >= 0)
{
SetGain(Gain);
}
//全画幅
if(!IsAllPicEnabled)
SetPictureRoi((int)ROIX, (int)ROIY, (int)ROIW, (int)ROIH);
//if (IIConfig.Gain >= 0)
//{
// SetGain(IIConfig.Gain);
//}
//SetPictureRoi(IIConfig.VelocityPara.A_Pic_X, IIConfig.VelocityPara.A_Pic_Y, IIConfig.VelocityPara.Width, IIConfig.VelocityPara.Hight);
//// 设置 触发延迟
if (TriggerDelay > 0)
{
nRet = DVPCamera.dvpSetTriggerDelay(m_handle, TriggerDelay);
if (nRet != dvpStatus.DVP_STATUS_OK)
{
throw new Exception("Set TriggerDelay failed!");
}
}
//if (IIConfig.TriggerDelay > 0)
//{
// nRet = DVPCamera.dvpSetTriggerDelay(m_handle, IIConfig.TriggerDelay);
// if (nRet != dvpStatus.DVP_STATUS_OK)
// {
// throw new Exception("Set TriggerDelay failed!");
// }
//}
//// 信号消抖
if (LineDebouncerTime > 0)
{
nRet = DVPCamera.dvpSetTriggerJitterFilter(m_handle, LineDebouncerTime);
if (nRet != dvpStatus.DVP_STATUS_OK)
{
throw new Exception($"LineDebouncerTime set failed:{nRet}");
}
}
//if (IIConfig.LineDebouncerTime > 0)
//{
// nRet = DVPCamera.dvpSetTriggerJitterFilter(m_handle, IIConfig.LineDebouncerTime);
// if (nRet != dvpStatus.DVP_STATUS_OK)
// {
// throw new Exception($"LineDebouncerTime set failed:{nRet}");
// }
//}
//IIConfig.PropertyChanged -= IIConfig_PropertyChanged;
//IIConfig.PropertyChanged += IIConfig_PropertyChanged;
}
return true;
}
@ -365,17 +351,9 @@ namespace DH.Devices.Camera
break;
}
Mat smat = cvImage.Clone();
var imageSet = new MatSet
{
_mat = smat,
};
InitialImageSet(imageSet);
OnHImageOutput?.Invoke(DateTime.Now, this, smat);
//存图
DisplayAndSaveOriginImage(imageSet.Id,SnapshotCount);
@ -391,93 +369,14 @@ namespace DH.Devices.Camera
}
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 = set._mat.ToBitmap();
// 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)
{
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()
{
try
{
dvpStreamState StreamState = new dvpStreamState();
nRet = DVPCamera.dvpGetStreamState(m_handle, ref StreamState);
//Debug.Assert(nRet == dvpStatus.DVP_STATUS_OK);
Debug.Assert(nRet == dvpStatus.DVP_STATUS_OK);
if (StreamState == dvpStreamState.STATE_STARTED)
{
// stop camera
@ -512,22 +411,6 @@ namespace DH.Devices.Camera
}
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));
}
}
}

View File

@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
using System.Xml.Linq;
using DH.Commons.Enums;
using static MvCamCtrl.NET.MyCamera;
using DH.Commons.Base;
using DH.Devices.Devices;

View File

@ -409,7 +409,7 @@ namespace MCDLL_NET
/********************************************************************************************************************************************************************
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD>ж<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD>ݡ<EFBFBD>
<20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD>Ѿ<EFBFBD><D1BE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD>ж<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>
********************************************************************************************************************************************************************/
@ -1005,8 +1005,8 @@ namespace MCDLL_NET
/// </summary>
/// <param name="Axis"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
/// <param name="Stop_Time"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͣʱ<CDA3><20><>Χ 0 -1000ms<6D><73><EFBFBD><EFBFBD>Ĭ<EFBFBD>ϣ<EFBFBD><CFA3><EFBFBD>ͣ<EFBFBD><CDA3>
/// ע<><EFBFBD><E2A3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײԭ<D7B2>㻺ͣʱ<CDA3><EFBFBD><E4A3AC>Ҫ<EFBFBD><D2AA><EFBFBD>ϻ<EFBFBD><CFBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õĸ<C3B5><C4B8>ٶ<EFBFBD><D9B6>ٶȣ<D9B6><C8A3>͵<EFBFBD><CDB5>ٶ<EFBFBD><D9B6>ٶȵĴ<C8B5><C4B4>
/// <20><><EFBFBD>ô<EFBFBD><C3B4>˻<EFBFBD><CBBB><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>ֹͣ<CDA3><D6B9>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD>ԭ<EFBFBD><D4AD>ʱ<EFBFBD><CAB1><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD><EFBFBD>м</param>
/// ע<><EFBFBD><E2A3BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײԭ<D7B2>㻺ͣʱ<CDA3><EFBFBD><E4A3AC>Ҫ<EFBFBD><D2AA><EFBFBD>ϻ<EFBFBD><CFBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD>õĸ<C3B5><C4B8>ٶ<EFBFBD><D9B6>ٶȣ<D9B6><C8A3>͵<EFBFBD><CDB5>ٶ<EFBFBD><D9B6>ٶȵĴ<C8B5><C4B4><EFBFBD>
/// <20><><EFBFBD>ô<EFBFBD><C3B4>˻<EFBFBD><CBBB><EFBFBD><EFBFBD>ֹ<EFBFBD><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD><D0A1>ֹͣ<CDA3><D6B9>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD><D0B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD><E4A3AC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ҵ<EFBFBD>ԭ<EFBFBD><D4AD>ʱ<EFBFBD><CAB1><EFBFBD>ڿ<EFBFBD><DABF><EFBFBD><EFBFBD>м<EFBFBD> </param>
/// <param name="StationNumber">վ<><D5BE><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>Ĭ<EFBFBD>ϲ<EFBFBD><CFB2><EFBFBD>Ϊ 0</param>
/// <returns></returns>
[DllImport("MCDLL_NET.DLL", EntryPoint = "MCF_Search_Home_Stop_Time_Net")]

View File

@ -444,17 +444,17 @@ namespace DH.Devices.Motion
//[Category("回原点设置")]
//[DisplayName("回原点模式")]
//[Description("HomeMode回原点模式0一般模式 1极限限位模式 2外部触发模式")]
//[Description("HomeMode回原点模式 0一般模式 1极限限位模式 2外部触发模式")]
//public int HomeMode { get; set; } = 0;
//[Category("回原点设置")]
//[DisplayName("回原点方向")]
//[Description("IsHomePositive回原点方向 true正方向开始 false负方向开始")]
//[Description("IsHomePositive回原点方向 true正方向开始 false负方向开始")]
//public bool IsHomePositive { get; set; } = true;
//[Category("回原点设置")]
//[DisplayName("是否自动回原点")]
//[Description("IsAutoGoHome是否自动回原点 true是 false否")]
//[Description("IsAutoGoHome是否自动回原点 true是 false否")]
//public bool IsAutoGoHome { get; set; } = false;
//[Category("超时设置")]
@ -601,7 +601,7 @@ namespace DH.Devices.Motion
[Category("回原点参数")]
[DisplayName("碰撞原点缓停时间")]
[Description("SearchHomeStopTime触发缓停时间范围 0-1000ms默认急停注意:设置碰撞原点缓停时间,需要配合回零设置的高速段速度,和低速度速度的搭配设置大了会出现过冲的现象,设置小了停止的时候会有抖动,需要调节时间,尽量设置找到原点时候在开关中间")]
[Description("SearchHomeStopTime触发缓停时间范围 0-1000ms默认急停 注意:设置碰撞原点缓停时间,需要配合回零设置的高速段速度,和低速度速度的搭配 设置大了会出现过冲的现象,设置小了停止的时候会有抖动,需要调节时间,尽量设置找到原点时候在开关中间 ")]
public ushort SearchHomeStopTime { get; set; } = 0;

View File

@ -314,9 +314,9 @@ namespace DH.Devices.Motion
// //设置物件检测有效电平 0是低电平 1是高电平
// rtn = CMCDLL_NET_Sorting.MCF_Sorting_Set_Input_Logic_Net((ushort)SortingInputSetting.BitInputNumber, 0);
// //设置来料检测编码器 双转盘要设置两个轴
// /*Bit_Input_Number设置位号
// 取值: Bit_Input_0, Bit_Input_1
// Axis: 轴号
// /*Bit_Input_Number设置位号
// 取值: Bit_Input_0, Bit_Input_1
// Axis: 轴号
// Source跟随方式
// 取值0命令
// 1编码器(默认)
@ -1655,7 +1655,7 @@ namespace DH.Devices.Motion
#region IMonitor
/// <summary>
/// 位置捕获监听,入料检测
/// 位置捕获监听,入料检测
/// 入料检测对射开关接到了HOME口每当有新料到达入料检测传感器时程序把当前位置当作原点并调用<see cref="SolidMotionCardBase.CapturePositionChanged(int, int)"/>函数
/// </summary>
private void MonitorPieces()
@ -1796,7 +1796,7 @@ namespace DH.Devices.Motion
// Picese_sizeStr += i.ToString()+":"+Piece_Size[i]+"\t";
// Picese_DistanceizeStr += i.ToString()+":"+ Piece_Distance_To_next[i]+"\t";
//}
// LogAsync(DateTime.Now, LogLevel.Information, $"转盘{station}产品入列 , {piecesCountDic[station]} size:{Piece_Size[Piece_Size.Length - 1]}");
// LogAsync(DateTime.Now, LogLevel.Information, $"转盘{station}产品入列 , {piecesCountDic[station]} size:{Piece_Size[Piece_Size.Length - 1]} ");
// LogAsync(DateTime.Now, LogLevel.Information, $"转盘{station}产品入列 ,监听piece_find{tmpPieceNumber} 监听物件大小" + Picese_sizeStr+",物件间距"+ Picese_DistanceizeStr+"相机经过个数"+Piece_Cross_Camera);
if (tmpPieceNumber != piecesCountDic[station] + 1)
{

View File

@ -12,6 +12,10 @@
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="System.IO.Ports" Version="9.0.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
</ItemGroup>

82
DH.Devices.PLC/PLCBase.cs Normal file
View File

@ -0,0 +1,82 @@
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

View File

@ -11,14 +11,6 @@
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Optimize>False</Optimize>
</PropertyGroup>
@ -36,6 +28,7 @@
<ItemGroup>
<ProjectReference Include="..\DH.Commons.Devies\DH.Commons.Devies.csproj" />
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
<ProjectReference Include="..\DH.UI.Model.Winform\DH.UI.Model.Winform.csproj" />
</ItemGroup>

View File

@ -13,13 +13,13 @@ using System.Threading.Tasks;
using System.Security.Cryptography.Xml;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using DH.Commons.Base;
using DH.Commons.Enums;
namespace DH.Devices.Vision
{
/// <summary>
/// 目标检测 GPU
@ -104,18 +104,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]}]}";
//
Console.WriteLine("检测结果JSON" + json);
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
HYoloResult detResult = JsonConvert.DeserializeObject<HYoloResult>(json);
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
if (detResult == null)
{
return;
}
int iNum = detResult.HYolo.Count;
#pragma warning disable CS0219 // 变量已被赋值,但从未使用过它的值
int IokNum = 0;
#pragma warning restore CS0219 // 变量已被赋值,但从未使用过它的值
for (int ix = 0; ix < iNum; ix++)
{
var det = detResult.HYolo[ix];
@ -145,6 +145,7 @@ namespace DH.Devices.Vision
Mat originMat = new Mat();
Mat detectMat = new Mat();
#pragma warning disable CS0168 // 声明了变量,但从未使用过
try
{
if (req.mImage == null)
@ -233,15 +234,15 @@ namespace DH.Devices.Vision
{
originMat?.Dispose();
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
originMat = null;
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
//maskMat?.Dispose();
// maskMat = null;
detectMat?.Dispose();
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
detectMat = null;
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
// maskWeighted?.Dispose();
// maskWeighted = null;
// GC.Collect();

View File

@ -12,7 +12,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using DH.Commons.Base;
using DH.Commons.Enums;
namespace DH.Devices.Vision
@ -127,9 +127,9 @@ 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]}]}";
//
Console.WriteLine("检测结果JSON" + json);
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
SegResult detResult = JsonConvert.DeserializeObject<SegResult>(json);
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
if (detResult == null)
{
return;
@ -259,9 +259,9 @@ namespace DH.Devices.Vision
{
originMat?.Dispose();
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
originMat = null;
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
// GC.Collect();

View File

@ -13,7 +13,7 @@ using System.Threading.Tasks;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using System.Xml;
using DH.Commons.Base;
using DH.Commons.Enums;
namespace DH.Devices.Vision
@ -136,8 +136,9 @@ 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]}]}";
//
Console.WriteLine("检测结果JSON" + json);
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
SegResult detResult = JsonConvert.DeserializeObject<SegResult>(json);
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
if (detResult == null)
{
return;
@ -175,6 +176,7 @@ namespace DH.Devices.Vision
MLResult mlResult = new MLResult();
Mat originMat=new Mat() ;
Mat detectMat= new Mat();
#pragma warning disable CS0168 // 声明了变量,但从未使用过
try
{
if (req.mImage == null)
@ -264,24 +266,25 @@ namespace DH.Devices.Vision
// 释放 Mat 资源
if (detectMat != null)
{
detectMat.Dispose();
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
detectMat = null;
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
}
if (originMat != null)
{
originMat.Dispose();
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
originMat = null;
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型
}
// GC.Collect();
}
#pragma warning restore CS0168 // 声明了变量,但从未使用过
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
using AntdUI;
using DH.Commons.Base;
using DH.Commons.Enums;
using OpenCvSharp;
using System;
@ -17,7 +17,7 @@ namespace DH.Devices.Vision
public Mat ColorLut { get; set; }
public byte[] ColorMap { get; set; }
public ModelType ModelType { get; set; }
public MLModelType ModelType { get; set; }
public IntPtr Model { get; set; }
@ -59,7 +59,7 @@ namespace DH.Devices.Vision
// "rect": [421, 823, 6, 8]
// }]
//}
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
public List<Result> HYolo;
public class Result
@ -67,12 +67,12 @@ namespace DH.Devices.Vision
public double fScore;
public int classId;
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
public string classname;
//public double area;
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
public List<int> rect;
@ -82,7 +82,7 @@ namespace DH.Devices.Vision
}
public class SegResult
{
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
public List<Result> SegmentResult;
public class Result
@ -90,12 +90,12 @@ namespace DH.Devices.Vision
public double fScore;
public int classId;
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
public string classname;
public double area;
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
public List<int> rect;

View File

@ -22,18 +22,18 @@ namespace DH.Devices.Vision
/// <summary>
/// 检测配置ID
/// </summary>
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
public string DetectionId { get; set; }
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
public string DetectionName { get; set; }
/// <summary>
/// 深度学习模型
/// </summary>
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
public SimboVisionMLBase StationMLEngine { get; set; }

View File

@ -0,0 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<TargetFramework>net8.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<BaseOutputPath>..\</BaseOutputPath>
<AppendTargetFrameworkToOutputPath>output</AppendTargetFrameworkToOutputPath>
<UseWindowsForms>true</UseWindowsForms>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DH.Commons.Devies\DH.Commons.Devies.csproj" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,49 @@
using DH.Commons.Enums;
using DH.Devices.Devices;
using System.ComponentModel;
using System.Drawing.Design;
using System.Text.Json.Serialization;
namespace DH.Process
{
public class ProcessConfigBase
{
[JsonPropertyName("station_code")]
public string StationCode { get; set; }
#region
[Category("设备配置")]
[Description("相机配置")]
[DisplayName("相机配置")]
[JsonPropertyName("camera_config_collection")]
//[TypeConverter(typeof(CollectionCountConvert))]
//[Editor(typeof(InitialConfigCollectionEditor<CameraInitialConfigBase>), typeof(UITypeEditor))]
public List<CameraBase> CameraConfigCollection { get; set; } = new List<CameraBase>();
[Category("设备配置")]
[Description("模型配置")]
[DisplayName("模型配置")]
[JsonPropertyName("detection_config_collection")]
//[TypeConverter(typeof(CollectionCountConvert))]
//[Editor(typeof(InitialConfigCollectionEditor<CameraInitialConfigBase>), typeof(UITypeEditor))]
public List<DetectionConfig> DetectionConfigCollection { get; set; } = new List<DetectionConfig>();
// [Category("设备配置")]
// [Description("PLC配置")]
// [DisplayName("PLC配置")]
// [TypeConverter(typeof(CollectionCountConvert))]
// [Editor(typeof(InitialConfigCollectionEditor<PLCInitialConfigBase>), typeof(UITypeEditor))]
// public List<IInitialConfig> PLCConfigCollection { get; set; } = new List<IInitialConfig>();
// [Category("设备配置")]
// [Description("其他设备配置")]
// [DisplayName("其他设备配置")]
// [TypeConverter(typeof(CollectionCountConvert))]
// [Editor(typeof(InitialConfigCollectionEditor<InitialConfigBase>), typeof(UITypeEditor))]
// public List<IInitialConfig> DeviceConfigs { get; set; } = new List<IInitialConfig>();
#endregion
}
}

View File

@ -3,14 +3,14 @@
partial class Canvas
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,7 +3,7 @@
partial class CanvasImage
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
@ -11,7 +11,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -923,9 +923,9 @@ namespace DH.UI.Model.Winform
#region Dispose
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
MAP?.Dispose();

View File

@ -3,14 +3,14 @@
partial class GridCtrl
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class IOIndicatorCtrl
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -10,14 +10,6 @@
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Optimize>False</Optimize>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
</ItemGroup>

View File

@ -580,7 +580,7 @@ namespace DH.UI.Model.Winform
/// </summary>
[Browsable(false)]
public Rectangle BaseRectangle { get; set; }
EnumHelper.ElementState IShapeElement.State { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public abstract bool IsMouseHover(PointF p);
@ -864,30 +864,30 @@ namespace DH.UI.Model.Winform
{
if (disposing)
{
// 释放托管状态(托管对象)
// 释放托管状态(托管对象)
Pen?.Dispose();
}
// TODO: 释放未托管的资源(未托管的对象)并在以下内容中替代终结器
// TODO: 将大型字段设置为 null
// TODO: 释放未托管的资源(未托管的对象)并在以下内容中替代终结器
// TODO: 将大型字段设置为 null
disposedValue = true;
}
}
// TODO: 仅当以上 Dispose(bool disposing) 拥有用于释放未托管资源的代码时才替代终结器
// TODO: 仅当以上 Dispose(bool disposing) 拥有用于释放未托管资源的代码时才替代终结器
// ~ElementBase()
// {
// // 请勿更改此代码将清理代码放入以上 Dispose(bool disposing) 中
// // 请勿更改此代码 将清理代码放入以上 Dispose(bool disposing) 中
// Dispose(false);
// }
// 添加此代码以正确实现可处置模式
// 添加此代码以正确实现可处置模式
public void Dispose()
{
// 请勿更改此代码将清理代码放入以上 Dispose(bool disposing) 中
// 请勿更改此代码 将清理代码放入以上 Dispose(bool disposing) 中
Dispose(true);
// TODO: 如果在以上内容中替代了终结器,则取消注释以下行
// TODO: 如果在以上内容中替代了终结器,则取消注释以下行
// GC.SuppressFinalize(this);
}
#endregion

View File

@ -1,5 +1,5 @@

using DH.Commons.Base;
using DH.Commons.Enums;
using System;
using System.Collections.Generic;
using System.Drawing;

View File

@ -3,14 +3,14 @@
partial class GridCtrl
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -3,14 +3,14 @@
partial class IOIndicatorCtrl
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -24,7 +24,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

View File

@ -25,6 +25,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Motion", "Motion", "{5C8472
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DH.Devices.Motion", "DH.Devices.Motion\DH.Devices.Motion.csproj", "{144E3775-0BD7-4528-9FB0-A0F4ADC74313}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DH.Commons.Devies", "DH.Commons.Devies\DH.Commons.Devies.csproj", "{A33108B6-2740-4D28-AD22-B280372980BE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "UI", "UI", "{3EAF3D9C-D3F9-4B6E-89DE-58F129CD1F4C}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DH.UI.Model.Winform", "DH.UI.Model.Winform\DH.UI.Model.Winform.csproj", "{12CB9041-B1B1-41AE-B308-AABDACAA580E}"
@ -37,6 +39,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "XKRS.CanFly", "CanFly\XKRS.
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CanFly.Canvas", "CanFly.Canvas\CanFly.Canvas.csproj", "{EA7E228B-DB5C-4BF1-832B-D51B7F7D5F35}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Process", "Process", "{FE1AEA36-9909-4E4F-8A88-37338ECCCE62}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DH.Process", "DH.Process\DH.Process.csproj", "{9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -85,6 +91,14 @@ Global
{144E3775-0BD7-4528-9FB0-A0F4ADC74313}.Release|Any CPU.Build.0 = Release|Any CPU
{144E3775-0BD7-4528-9FB0-A0F4ADC74313}.Release|x64.ActiveCfg = Release|x64
{144E3775-0BD7-4528-9FB0-A0F4ADC74313}.Release|x64.Build.0 = Release|x64
{A33108B6-2740-4D28-AD22-B280372980BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A33108B6-2740-4D28-AD22-B280372980BE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A33108B6-2740-4D28-AD22-B280372980BE}.Debug|x64.ActiveCfg = Debug|X64
{A33108B6-2740-4D28-AD22-B280372980BE}.Debug|x64.Build.0 = Debug|X64
{A33108B6-2740-4D28-AD22-B280372980BE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A33108B6-2740-4D28-AD22-B280372980BE}.Release|Any CPU.Build.0 = Release|Any CPU
{A33108B6-2740-4D28-AD22-B280372980BE}.Release|x64.ActiveCfg = Release|X64
{A33108B6-2740-4D28-AD22-B280372980BE}.Release|x64.Build.0 = Release|X64
{12CB9041-B1B1-41AE-B308-AABDACAA580E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{12CB9041-B1B1-41AE-B308-AABDACAA580E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{12CB9041-B1B1-41AE-B308-AABDACAA580E}.Debug|x64.ActiveCfg = Debug|Any CPU
@ -117,6 +131,14 @@ Global
{EA7E228B-DB5C-4BF1-832B-D51B7F7D5F35}.Release|Any CPU.Build.0 = Release|Any CPU
{EA7E228B-DB5C-4BF1-832B-D51B7F7D5F35}.Release|x64.ActiveCfg = Release|x64
{EA7E228B-DB5C-4BF1-832B-D51B7F7D5F35}.Release|x64.Build.0 = Release|x64
{9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Debug|x64.ActiveCfg = Debug|Any CPU
{9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Debug|x64.Build.0 = Debug|Any CPU
{9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Release|Any CPU.Build.0 = Release|Any CPU
{9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Release|x64.ActiveCfg = Release|Any CPU
{9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@ -130,10 +152,12 @@ Global
{458B2CF6-6F1B-4B8B-BB85-C6FD7F453A5D} = {2560C5A5-0CA2-48AD-B606-6C55BEFD8109}
{5C8472C6-EB6A-4D89-B519-7073BBF6A5D2} = {8EC33C16-65CE-4C12-9C8D-DB2425F9F7C0}
{144E3775-0BD7-4528-9FB0-A0F4ADC74313} = {5C8472C6-EB6A-4D89-B519-7073BBF6A5D2}
{A33108B6-2740-4D28-AD22-B280372980BE} = {0AB4BB9A-A861-4F80-B549-CD331490942B}
{12CB9041-B1B1-41AE-B308-AABDACAA580E} = {3EAF3D9C-D3F9-4B6E-89DE-58F129CD1F4C}
{5AD3A29E-149A-4C37-9548-7638A36C8175} = {F77AF94C-280D-44C5-B7C0-FC86AA9EC504}
{1FB768DB-843E-4C67-96B9-7684CF890D89} = {048B30B5-D075-4CE0-BF9F-CB6152E6D376}
{EA7E228B-DB5C-4BF1-832B-D51B7F7D5F35} = {048B30B5-D075-4CE0-BF9F-CB6152E6D376}
{9C6D1290-26D9-4C5B-8BF5-A1F1E35368C5} = {FE1AEA36-9909-4E4F-8A88-37338ECCCE62}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {6FC1A8DF-636E-434C-981E-10F20FAD723B}

View File

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<!-- 方案存储键(初始值为空) -->
<add key="Schemes" value=""/>
<!-- 当前方案键(初始值为空) -->
<add key="CurrentScheme" value=""/>
</appSettings>
</configuration>

View File

@ -12,11 +12,35 @@
<OutputType>WinExe</OutputType>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="AntdUI" Version="1.8.9" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.185" />
<PackageReference Include="System.Data.SQLite.Core" Version="1.0.119" />
<PackageReference Include="System.IO.Ports" Version="9.0.2" />
</ItemGroup>
<ItemGroup>
@ -25,6 +49,7 @@
<ProjectReference Include="..\DH.Devices.Motion\DH.Devices.Motion.csproj" />
<ProjectReference Include="..\DH.Devices.PLC\DH.Devices.PLC.csproj" />
<ProjectReference Include="..\DH.Devices.Vision\DH.Devices.Vision.csproj" />
<ProjectReference Include="..\DH.Process\DH.Process.csproj" />
<ProjectReference Include="..\DH.UI.Model.Winform\DH.UI.Model.Winform.csproj" />
</ItemGroup>

68
DHSoftware/EnumHelper.cs Normal file
View File

@ -0,0 +1,68 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
namespace DHSoftware
{
public static class EnumHelper
{
public enum SelectPicType
{
[Description("训练图片")]
train =0,
[Description("测试图片")]
test
}
public enum NetModel
{
[Description("目标检测")]
training = 0,
[Description("语义分割")]
train_seg,
[Description("模型导出")]
emport,
[Description("推理预测")]
infernce
}
public static string GetEnumDescription(this Enum enumObj)
{
Type t = enumObj.GetType();
FieldInfo f = t.GetField(enumObj.ToString());
if (f == null)
{
return enumObj.ToString();
}
DescriptionAttribute attr = f.GetCustomAttribute<DescriptionAttribute>();
if (attr != null)
{
return attr.Description;
}
else
{
return enumObj.ToString();
}
}
// 根据描述获取枚举值(泛型方法)
public static T GetEnumFromDescription<T>(string description) where T : Enum
{
Type enumType = typeof(T);
foreach (T value in Enum.GetValues(enumType))
{
string desc = GetEnumDescription(value);
if (desc == description)
{
return value;
}
}
throw new ArgumentException($"在枚举 {enumType.Name} 中未找到描述为 '{description}' 的值");
}
}
}

View File

@ -1,4 +1,10 @@
namespace DHSoftware.Languages
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DHSoftware.Languages
{
public class Localizer_enus : AntdUI.ILocalization
{
@ -8,183 +14,126 @@
{
case "search":
return "Search";
case "welcome":
return "Welcome to the AntdUI Demo";
case "home":
return "Home";
case "closeall":
return "Close all tabs";
#region systemset
case "systemset":
return "System Settings";
case "baseset":
return "Basic Settings";
case "messageconfig":
return "Message configuration";
case "animationon":
return "Turn on animation";
case "shadowon":
return "Enable shadow";
case "scrollbarhide":
return "Hide scrollbar";
case "showinwindow":
return "Show in window";
case "windowOffsetXY":
return "WindowOffsetXY";
case "tip":
return "Tip";
case "switchsuccess":
return "Switch successful.";
#endregion systemset
#endregion
#region Button
case "Button.Text":
return "Button";
case "Button.Description":
return "To trigger an operation.";
case "type":
return "Type";
case "wave":
return "Wave";
case "loading":
return "Loading";
case "ghost":
return "Ghost";
case "border":
return "Border";
case "icon":
return "Icon";
case "arrow":
return "Arrow";
case "join":
return "Join";
case "gradient":
return "Gradient";
case "toggle":
return "Toggle";
#endregion Button
#endregion
#region FloatButton
case "FloatButton.Text":
return "FloatButton";
case "FloatButton.Description":
return "A button that floats at the top of the page.";
case "FloatButton.Tip":
return "FloatButton does not have a toolbox control and is called code.";
case "control_option":
return "Control Options";
case "button_option":
return "Button Options";
case "open":
return "Open";
case "close":
return "Close";
case "reset":
return "Reset";
#endregion FloatButton
#endregion
#region Icon
case "Icon.Text":
return "Icon";
case "Icon.Description":
return "Semantic vector graphics.";
case "Icon.Tip":
return "Icon does not have a toolbox control and is used for Svg property assignments.";
case "outlined":
return "Outlined";
case "filled":
return "Filled";
case "directionalicon":
return "Directional icons";
case "suggestionicon":
return "Suggestion Icon";
case "editingicon":
return "Editing Icons";
case "dataicon":
return "Data icons";
case "brand":
return "Brand and logo";
case "universal":
return "Universal Icons for Websites";
case "copysuccess":
return "Copy successful!";
case "copyfail":
return "Copy failed!";
#endregion Icon
#endregion
#region Divider
case "Divider.Text":
return "Divider";
case "Divider.Description":
return "A divider line separates different content.";
case "basicusage":
return "Basic Usage";
case "vertical":
return "Vertical";
case "horizontal":
return "Horizontal";
#endregion Divider
#endregion
default:
return null;
}
}
}
}
}

View File

@ -1,117 +0,0 @@
namespace DHSoftware
{
partial class LoginWindow
{
/// <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(LoginWindow));
label1 = new AntdUI.Label();
iptName = new AntdUI.Input();
iptPwd = new AntdUI.Input();
button_cancel = new AntdUI.Button();
button_ok = new AntdUI.Button();
SuspendLayout();
//
// label1
//
label1.BackColor = SystemColors.Window;
label1.Font = new Font("Microsoft YaHei UI", 14.25F, FontStyle.Bold, GraphicsUnit.Point, 134);
label1.Location = new Point(351, 44);
label1.Name = "label1";
label1.Size = new Size(212, 23);
label1.TabIndex = 0;
label1.Text = "登录CCD光学筛选系统";
//
// iptName
//
iptName.Location = new Point(351, 95);
iptName.Name = "iptName";
iptName.PlaceholderText = "请输入用户名";
iptName.Size = new Size(227, 37);
iptName.TabIndex = 1;
//
// iptPwd
//
iptPwd.Location = new Point(351, 156);
iptPwd.Name = "iptPwd";
iptPwd.PasswordPaste = false;
iptPwd.PlaceholderText = "请输入密码";
iptPwd.Size = new Size(227, 37);
iptPwd.TabIndex = 2;
iptPwd.UseSystemPasswordChar = true;
//
// button_cancel
//
button_cancel.BorderWidth = 1F;
button_cancel.Font = new Font("Microsoft YaHei UI", 9F);
button_cancel.Ghost = true;
button_cancel.Location = new Point(468, 231);
button_cancel.Name = "button_cancel";
button_cancel.Size = new Size(95, 38);
button_cancel.TabIndex = 4;
button_cancel.Text = "取消";
//
// button_ok
//
button_ok.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
button_ok.Location = new Point(364, 231);
button_ok.Name = "button_ok";
button_ok.Size = new Size(95, 38);
button_ok.TabIndex = 3;
button_ok.Text = "登录";
button_ok.Type = AntdUI.TTypeMini.Primary;
//
// LoginWindow
//
BackgroundImage = (Image)resources.GetObject("$this.BackgroundImage");
BackgroundImageLayout = ImageLayout.Stretch;
ClientSize = new Size(590, 340);
ControlBox = false;
Controls.Add(button_cancel);
Controls.Add(button_ok);
Controls.Add(iptPwd);
Controls.Add(iptName);
Controls.Add(label1);
Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
Icon = (Icon)resources.GetObject("$this.Icon");
Name = "LoginWindow";
StartPosition = FormStartPosition.CenterScreen;
Text = "登录界面";
Load += LoginWindow_Load;
ResumeLayout(false);
}
#endregion
private AntdUI.Label label1;
private AntdUI.Input iptName;
private AntdUI.Input iptPwd;
private AntdUI.Button button_cancel;
private AntdUI.Button button_ok;
}
}

View File

@ -1,123 +0,0 @@
using AntdUI;
using DHSoftware.Models;
using DHSoftware.Services;
namespace DHSoftware
{
public partial class LoginWindow : AntdUI.Window
{
public LoginWindow()
{
InitializeComponent();
// 关键设置:允许窗体优先接收按键事件
this.KeyPreview = true;
// 绑定按键事件
this.KeyDown += Login_KeyDown;
button_ok.Click += Button_ok_Click;
button_cancel.Click += Button_cancel_Click;
}
private void Login_KeyDown(object? sender, KeyEventArgs e)
{
// 监听回车键
if (e.KeyCode == Keys.Enter)
{
button_ok.PerformClick(); // 触发确定按钮的点击事件
e.Handled = true; // 阻止其他控件处理该按键
}
// 监听 ESC 键
if (e.KeyCode == Keys.Escape)
{
button_cancel.PerformClick(); // 触发取消按钮的点击事件
e.Handled = true;
}
}
/// <summary>
/// 窗体对象实例
/// </summary>
private static LoginWindow _instance;
internal static LoginWindow Instance
{
get
{
if (_instance == null || _instance.IsDisposed)
_instance = new LoginWindow();
return _instance;
}
}
private void Button_cancel_Click(object? sender, EventArgs e)
{
this.Dispose();
}
private void Button_ok_Click(object? sender, EventArgs e)
{
if (string.IsNullOrWhiteSpace(iptName.Text))
{
AntdUI.Message.warn(this, "用户名不能为空!", autoClose: 3);
return;
}
if (string.IsNullOrWhiteSpace(iptPwd.Text))
{
AntdUI.Message.warn(this, "密码不能为空!", autoClose: 3);
return;
}
if (AuthService.Login(iptName.Text, iptPwd.Text))
{
if (this.Owner is MainWindow parent)
{
List<string> UserPermissions = AuthService.GetUserPermissions();
// 检查当前用户是否有权限
if (AuthService.HasPermission("system:config"))
{
parent.ShowConfig = true;
}
else
{
parent.ShowConfig = false;
}
if (AuthService.HasPermission("system:loadscheme"))
{
parent.Loadscheme = true;
}
else
{
parent.Loadscheme = false;
}
if (AuthService.HasPermission("system:addscheme"))
{
parent.Addscheme = true;
}
else
{
parent.Addscheme = false;
}
if (AuthService.HasPermission("system:deletescheme"))
{
parent.Deleteschememe = true;
}
else
{
parent.Deleteschememe = false;
}
parent.LoginName = iptName.Text;
}
this.Dispose();
}
else
{
AntdUI.Message.warn(this, "用户名或密码错误,登录失败!", autoClose: 3);
}
}
private void LoginWindow_Load(object sender, EventArgs e)
{
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -28,75 +28,62 @@
/// </summary>
private void InitializeComponent()
{
AntdUI.Tabs.StyleLine styleLine2 = new AntdUI.Tabs.StyleLine();
AntdUI.Tabs.StyleCard styleCard2 = new AntdUI.Tabs.StyleCard();
AntdUI.SegmentedItem segmentedItem6 = new AntdUI.SegmentedItem();
AntdUI.SegmentedItem segmentedItem7 = new AntdUI.SegmentedItem();
AntdUI.SegmentedItem segmentedItem8 = new AntdUI.SegmentedItem();
AntdUI.SegmentedItem segmentedItem9 = new AntdUI.SegmentedItem();
AntdUI.SegmentedItem segmentedItem10 = new AntdUI.SegmentedItem();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainWindow));
AntdUI.Tabs.StyleCard styleCard1 = new AntdUI.Tabs.StyleCard();
AntdUI.Tabs.StyleCard styleCard2 = new AntdUI.Tabs.StyleCard();
AntdUI.Tabs.StyleCard styleCard3 = new AntdUI.Tabs.StyleCard();
AntdUI.SegmentedItem segmentedItem1 = new AntdUI.SegmentedItem();
AntdUI.SegmentedItem segmentedItem2 = new AntdUI.SegmentedItem();
AntdUI.SegmentedItem segmentedItem3 = new AntdUI.SegmentedItem();
AntdUI.SegmentedItem segmentedItem4 = new AntdUI.SegmentedItem();
AntdUI.SegmentedItem segmentedItem5 = new AntdUI.SegmentedItem();
titlebar = new AntdUI.PageHeader();
lbName = new AntdUI.Label();
button_color = new AntdUI.Button();
buttonSZ = new AntdUI.Button();
pageHeader1 = new AntdUI.PageHeader();
label1 = new Label();
divider2 = new AntdUI.Divider();
panelmain = new AntdUI.Panel();
panel2 = new AntdUI.Panel();
panel4 = new AntdUI.Panel();
panel6 = new AntdUI.Panel();
splitContainer1 = new SplitContainer();
splitContainer2 = new SplitContainer();
tabImgDisplay = new AntdUI.Tabs();
tabMain = new AntdUI.TabPage();
tabsStas = new AntdUI.Tabs();
tabPage3 = new AntdUI.TabPage();
panel7 = new Panel();
tabMain = new AntdUI.TabPage();
panelmain = new AntdUI.Panel();
splitter2 = new AntdUI.Splitter();
tabImgDisplay = new AntdUI.Tabs();
splitter1 = new AntdUI.Splitter();
pnlLog = new AntdUI.Panel();
panel6 = new AntdUI.Panel();
tableLayoutstatistics = new TableLayoutPanel();
dgvCamreaNums = new DataGridView();
panelNums = new AntdUI.Panel();
tableLayoutNums = new TableLayoutPanel();
dgvProductNums = new DataGridView();
tableLayoutPanel3 = new TableLayoutPanel();
lblTotalTime = new Label();
label1 = new Label();
label12 = new Label();
lblUPH = new Label();
lblStartTime = new Label();
lblOEE_Total = new Label();
label10 = new Label();
label7 = new Label();
panel2 = new AntdUI.Panel();
richTextBox1 = new RichTextBox();
tabsConfig = new AntdUI.Tabs();
tabPage2 = new AntdUI.TabPage();
panel1 = new AntdUI.Panel();
panel3 = new AntdUI.Panel();
btnDeleteProject = new AntdUI.Button();
btnAddProject = new AntdUI.Button();
btnLoadProject = new AntdUI.Button();
sltProjects = new AntdUI.Select();
segmented1 = new AntdUI.Segmented();
titlebar.SuspendLayout();
pageHeader1.SuspendLayout();
panelmain.SuspendLayout();
panel2.SuspendLayout();
panel4.SuspendLayout();
panel6.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
splitContainer1.Panel1.SuspendLayout();
splitContainer1.Panel2.SuspendLayout();
splitContainer1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitContainer2).BeginInit();
splitContainer2.Panel1.SuspendLayout();
splitContainer2.Panel2.SuspendLayout();
splitContainer2.SuspendLayout();
tabImgDisplay.SuspendLayout();
tabsStas.SuspendLayout();
tabPage3.SuspendLayout();
panelmain.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitter2).BeginInit();
splitter2.Panel1.SuspendLayout();
splitter2.Panel2.SuspendLayout();
splitter2.SuspendLayout();
((System.ComponentModel.ISupportInitialize)splitter1).BeginInit();
splitter1.Panel1.SuspendLayout();
splitter1.Panel2.SuspendLayout();
splitter1.SuspendLayout();
panel6.SuspendLayout();
tableLayoutstatistics.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dgvCamreaNums).BeginInit();
panelNums.SuspendLayout();
tableLayoutNums.SuspendLayout();
((System.ComponentModel.ISupportInitialize)dgvProductNums).BeginInit();
tableLayoutPanel3.SuspendLayout();
tabsConfig.SuspendLayout();
panel1.SuspendLayout();
panel3.SuspendLayout();
SuspendLayout();
//
// titlebar
//
titlebar.BackColor = Color.FromArgb(46, 108, 227);
titlebar.Controls.Add(lbName);
titlebar.BackColor = SystemColors.MenuHighlight;
titlebar.Controls.Add(button_color);
titlebar.Controls.Add(buttonSZ);
titlebar.DividerShow = true;
titlebar.DividerThickness = 0F;
titlebar.Dock = DockStyle.Top;
@ -112,44 +99,157 @@
titlebar.TabIndex = 0;
titlebar.Text = "山东迭慧智能科技有限公司";
//
// lbName
// button_color
//
lbName.Dock = DockStyle.Right;
lbName.ForeColor = SystemColors.Window;
lbName.Location = new Point(746, 0);
lbName.Name = "lbName";
lbName.Size = new Size(134, 40);
lbName.TabIndex = 0;
lbName.Text = "";
lbName.TextAlign = ContentAlignment.MiddleRight;
button_color.Dock = DockStyle.Right;
button_color.Ghost = true;
button_color.IconRatio = 0.6F;
button_color.IconSvg = "SunOutlined";
button_color.Location = new Point(780, 0);
button_color.Name = "button_color";
button_color.Radius = 0;
button_color.Size = new Size(50, 40);
button_color.TabIndex = 1;
button_color.ToggleIconSvg = "MoonOutlined";
button_color.Visible = false;
button_color.WaveSize = 0;
//
// tabsStas
// buttonSZ
//
tabsStas.Dock = DockStyle.Fill;
tabsStas.Location = new Point(0, 0);
tabsStas.Name = "tabsStas";
tabsStas.Pages.Add(tabPage3);
tabsStas.Size = new Size(580, 176);
tabsStas.Style = styleLine2;
tabsStas.TabIndex = 3;
tabsStas.Text = "tabs3";
buttonSZ.Dock = DockStyle.Right;
buttonSZ.Ghost = true;
buttonSZ.IconSvg = resources.GetString("buttonSZ.IconSvg");
buttonSZ.Location = new Point(830, 0);
buttonSZ.Name = "buttonSZ";
buttonSZ.Radius = 0;
buttonSZ.Size = new Size(50, 40);
buttonSZ.TabIndex = 0;
buttonSZ.Visible = false;
buttonSZ.WaveSize = 0;
//
// tabPage3
// pageHeader1
//
tabPage3.Controls.Add(panel7);
tabPage3.Location = new Point(3, 3);
tabPage3.Name = "tabPage3";
tabPage3.Size = new Size(574, 170);
tabPage3.TabIndex = 0;
tabPage3.Text = "日志";
pageHeader1.Controls.Add(label1);
pageHeader1.Controls.Add(divider2);
pageHeader1.DividerShow = true;
pageHeader1.Dock = DockStyle.Bottom;
pageHeader1.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
pageHeader1.Location = new Point(0, 608);
pageHeader1.Name = "pageHeader1";
pageHeader1.Size = new Size(1024, 40);
pageHeader1.TabIndex = 7;
pageHeader1.Text = "UPH";
//
// panel7
// label1
//
panel7.Dock = DockStyle.Fill;
panel7.Location = new Point(0, 0);
panel7.Name = "panel7";
panel7.Size = new Size(574, 170);
panel7.TabIndex = 2;
label1.AutoSize = true;
label1.Location = new Point(979, 10);
label1.Name = "label1";
label1.Size = new Size(64, 21);
label1.TabIndex = 1;
label1.Text = "100000";
//
// divider2
//
divider2.Dock = DockStyle.Top;
divider2.Location = new Point(54, 0);
divider2.Name = "divider2";
divider2.OrientationMargin = 0F;
divider2.Size = new Size(970, 10);
divider2.TabIndex = 0;
divider2.Text = "";
//
// panelmain
//
panelmain.Controls.Add(panel2);
panelmain.Controls.Add(panel1);
panelmain.Dock = DockStyle.Fill;
panelmain.Location = new Point(0, 40);
panelmain.Margin = new Padding(0);
panelmain.Name = "panelmain";
panelmain.Size = new Size(1024, 568);
panelmain.TabIndex = 8;
//
// panel2
//
panel2.Controls.Add(panel4);
panel2.Dock = DockStyle.Fill;
panel2.Location = new Point(0, 68);
panel2.Name = "panel2";
panel2.Size = new Size(1024, 500);
panel2.TabIndex = 1;
panel2.Text = "panel2";
//
// panel4
//
panel4.Controls.Add(panel6);
panel4.Dock = DockStyle.Fill;
panel4.Location = new Point(0, 0);
panel4.Name = "panel4";
panel4.Size = new Size(1024, 500);
panel4.TabIndex = 1;
panel4.Text = "panel4";
//
// panel6
//
panel6.Controls.Add(splitContainer1);
panel6.Dock = DockStyle.Fill;
panel6.Location = new Point(0, 0);
panel6.Name = "panel6";
panel6.Size = new Size(1024, 500);
panel6.TabIndex = 1;
panel6.Text = "panel6";
//
// splitContainer1
//
splitContainer1.BackColor = SystemColors.Control;
splitContainer1.Dock = DockStyle.Fill;
splitContainer1.Location = new Point(0, 0);
splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
splitContainer1.Panel1.Controls.Add(splitContainer2);
//
// splitContainer1.Panel2
//
splitContainer1.Panel2.BackColor = SystemColors.ButtonFace;
splitContainer1.Panel2.Controls.Add(tabsConfig);
splitContainer1.Size = new Size(1024, 500);
splitContainer1.SplitterDistance = 580;
splitContainer1.SplitterIncrement = 2;
splitContainer1.SplitterWidth = 10;
splitContainer1.TabIndex = 0;
//
// splitContainer2
//
splitContainer2.Dock = DockStyle.Fill;
splitContainer2.Location = new Point(0, 0);
splitContainer2.Name = "splitContainer2";
splitContainer2.Orientation = Orientation.Horizontal;
//
// splitContainer2.Panel1
//
splitContainer2.Panel1.Controls.Add(tabImgDisplay);
//
// splitContainer2.Panel2
//
splitContainer2.Panel2.Controls.Add(tabsStas);
splitContainer2.Size = new Size(580, 500);
splitContainer2.SplitterDistance = 320;
splitContainer2.TabIndex = 0;
//
// tabImgDisplay
//
tabImgDisplay.Controls.Add(tabMain);
tabImgDisplay.Dock = DockStyle.Fill;
tabImgDisplay.Location = new Point(0, 0);
tabImgDisplay.Name = "tabImgDisplay";
tabImgDisplay.Pages.Add(tabMain);
tabImgDisplay.Size = new Size(580, 320);
tabImgDisplay.Style = styleCard1;
tabImgDisplay.TabIndex = 1;
tabImgDisplay.Text = "tabs1";
//
// tabMain
//
@ -159,294 +259,59 @@
tabMain.TabIndex = 0;
tabMain.Text = "检测";
//
// panelmain
// tabsStas
//
panelmain.Controls.Add(splitter2);
panelmain.Controls.Add(panel2);
panelmain.Controls.Add(panel1);
panelmain.Dock = DockStyle.Fill;
panelmain.Location = new Point(0, 40);
panelmain.Margin = new Padding(0);
panelmain.Name = "panelmain";
panelmain.Size = new Size(1024, 631);
panelmain.TabIndex = 8;
tabsStas.Controls.Add(tabPage3);
tabsStas.Dock = DockStyle.Fill;
tabsStas.Location = new Point(0, 0);
tabsStas.Name = "tabsStas";
tabsStas.Pages.Add(tabPage3);
tabsStas.Size = new Size(580, 176);
tabsStas.Style = styleCard2;
tabsStas.TabIndex = 3;
tabsStas.Text = "tabs3";
//
// splitter2
// tabPage3
//
splitter2.Dock = DockStyle.Fill;
splitter2.Location = new Point(0, 68);
splitter2.Name = "splitter2";
splitter2.Orientation = Orientation.Horizontal;
tabPage3.Controls.Add(richTextBox1);
tabPage3.Location = new Point(3, 28);
tabPage3.Name = "tabPage3";
tabPage3.Size = new Size(574, 145);
tabPage3.TabIndex = 0;
tabPage3.Text = "日志";
//
// splitter2.Panel1
// richTextBox1
//
splitter2.Panel1.Controls.Add(tabImgDisplay);
richTextBox1.Dock = DockStyle.Fill;
richTextBox1.Location = new Point(0, 0);
richTextBox1.Name = "richTextBox1";
richTextBox1.Size = new Size(574, 145);
richTextBox1.TabIndex = 0;
richTextBox1.Text = "";
//
// splitter2.Panel2
// tabsConfig
//
splitter2.Panel2.Controls.Add(splitter1);
splitter2.Size = new Size(1024, 563);
splitter2.SplitterDistance = 442;
splitter2.TabIndex = 4;
tabsConfig.Controls.Add(tabPage2);
tabsConfig.Dock = DockStyle.Fill;
tabsConfig.Location = new Point(0, 0);
tabsConfig.Name = "tabsConfig";
tabsConfig.Pages.Add(tabPage2);
tabsConfig.Size = new Size(434, 500);
tabsConfig.Style = styleCard3;
tabsConfig.TabIndex = 2;
tabsConfig.Text = "tabs2";
//
// tabImgDisplay
// tabPage2
//
tabImgDisplay.Dock = DockStyle.Fill;
tabImgDisplay.Location = new Point(0, 0);
tabImgDisplay.Name = "tabImgDisplay";
tabImgDisplay.Size = new Size(1024, 442);
tabImgDisplay.Style = styleCard2;
tabImgDisplay.TabIndex = 3;
tabImgDisplay.Text = "tabs1";
//
// splitter1
//
splitter1.Dock = DockStyle.Fill;
splitter1.Location = new Point(0, 0);
splitter1.Name = "splitter1";
//
// splitter1.Panel1
//
splitter1.Panel1.Controls.Add(pnlLog);
//
// splitter1.Panel2
//
splitter1.Panel2.Controls.Add(panel6);
splitter1.Size = new Size(1024, 117);
splitter1.SplitterDistance = 332;
splitter1.TabIndex = 3;
//
// pnlLog
//
pnlLog.Dock = DockStyle.Fill;
pnlLog.Location = new Point(0, 0);
pnlLog.Name = "pnlLog";
pnlLog.Size = new Size(332, 117);
pnlLog.TabIndex = 2;
pnlLog.Text = "panel8";
//
// panel6
//
panel6.Controls.Add(tableLayoutstatistics);
panel6.Dock = DockStyle.Fill;
panel6.Location = new Point(0, 0);
panel6.Name = "panel6";
panel6.Size = new Size(688, 117);
panel6.TabIndex = 0;
panel6.Text = "panel6";
//
// tableLayoutstatistics
//
tableLayoutstatistics.ColumnCount = 2;
tableLayoutstatistics.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutstatistics.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutstatistics.Controls.Add(dgvCamreaNums, 0, 0);
tableLayoutstatistics.Controls.Add(panelNums, 1, 0);
tableLayoutstatistics.Dock = DockStyle.Fill;
tableLayoutstatistics.Location = new Point(0, 0);
tableLayoutstatistics.Name = "tableLayoutstatistics";
tableLayoutstatistics.RowCount = 1;
tableLayoutstatistics.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutstatistics.Size = new Size(688, 117);
tableLayoutstatistics.TabIndex = 9;
//
// dgvCamreaNums
//
dgvCamreaNums.AllowUserToAddRows = false;
dgvCamreaNums.AllowUserToDeleteRows = false;
dgvCamreaNums.AllowUserToResizeColumns = false;
dgvCamreaNums.AllowUserToResizeRows = false;
dgvCamreaNums.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dgvCamreaNums.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
dgvCamreaNums.BackgroundColor = SystemColors.Control;
dgvCamreaNums.BorderStyle = BorderStyle.None;
dgvCamreaNums.CellBorderStyle = DataGridViewCellBorderStyle.SunkenHorizontal;
dgvCamreaNums.ColumnHeadersHeight = 4;
dgvCamreaNums.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
dgvCamreaNums.ColumnHeadersVisible = false;
dgvCamreaNums.Dock = DockStyle.Fill;
dgvCamreaNums.Location = new Point(3, 3);
dgvCamreaNums.MultiSelect = false;
dgvCamreaNums.Name = "dgvCamreaNums";
dgvCamreaNums.ReadOnly = true;
dgvCamreaNums.RowHeadersVisible = false;
dgvCamreaNums.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvCamreaNums.Size = new Size(338, 111);
dgvCamreaNums.TabIndex = 9;
//
// panelNums
//
panelNums.Controls.Add(tableLayoutNums);
panelNums.Dock = DockStyle.Fill;
panelNums.Location = new Point(347, 3);
panelNums.Name = "panelNums";
panelNums.Size = new Size(338, 111);
panelNums.TabIndex = 8;
panelNums.Text = "panel4";
//
// tableLayoutNums
//
tableLayoutNums.ColumnCount = 1;
tableLayoutNums.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100F));
tableLayoutNums.Controls.Add(dgvProductNums, 0, 0);
tableLayoutNums.Controls.Add(tableLayoutPanel3, 0, 1);
tableLayoutNums.Dock = DockStyle.Fill;
tableLayoutNums.Location = new Point(0, 0);
tableLayoutNums.Name = "tableLayoutNums";
tableLayoutNums.RowCount = 2;
tableLayoutNums.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutNums.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutNums.Size = new Size(338, 111);
tableLayoutNums.TabIndex = 8;
//
// dgvProductNums
//
dgvProductNums.AllowUserToAddRows = false;
dgvProductNums.AllowUserToDeleteRows = false;
dgvProductNums.AllowUserToResizeColumns = false;
dgvProductNums.AllowUserToResizeRows = false;
dgvProductNums.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
dgvProductNums.AutoSizeRowsMode = DataGridViewAutoSizeRowsMode.AllCells;
dgvProductNums.BackgroundColor = SystemColors.Control;
dgvProductNums.BorderStyle = BorderStyle.None;
dgvProductNums.CellBorderStyle = DataGridViewCellBorderStyle.SunkenHorizontal;
dgvProductNums.ColumnHeadersHeight = 4;
dgvProductNums.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.DisableResizing;
dgvProductNums.ColumnHeadersVisible = false;
dgvProductNums.Dock = DockStyle.Fill;
dgvProductNums.Location = new Point(3, 3);
dgvProductNums.MultiSelect = false;
dgvProductNums.Name = "dgvProductNums";
dgvProductNums.ReadOnly = true;
dgvProductNums.RowHeadersVisible = false;
dgvProductNums.SelectionMode = DataGridViewSelectionMode.FullRowSelect;
dgvProductNums.Size = new Size(332, 49);
dgvProductNums.TabIndex = 10;
//
// tableLayoutPanel3
//
tableLayoutPanel3.ColumnCount = 4;
tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 81F));
tableLayoutPanel3.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, 75F));
tableLayoutPanel3.Controls.Add(lblTotalTime, 1, 1);
tableLayoutPanel3.Controls.Add(label1, 2, 1);
tableLayoutPanel3.Controls.Add(label12, 0, 1);
tableLayoutPanel3.Controls.Add(lblUPH, 3, 1);
tableLayoutPanel3.Controls.Add(lblStartTime, 1, 0);
tableLayoutPanel3.Controls.Add(lblOEE_Total, 3, 0);
tableLayoutPanel3.Controls.Add(label10, 0, 0);
tableLayoutPanel3.Controls.Add(label7, 2, 0);
tableLayoutPanel3.Dock = DockStyle.Fill;
tableLayoutPanel3.Location = new Point(3, 58);
tableLayoutPanel3.Name = "tableLayoutPanel3";
tableLayoutPanel3.RowCount = 2;
tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutPanel3.RowStyles.Add(new RowStyle(SizeType.Percent, 50F));
tableLayoutPanel3.Size = new Size(332, 50);
tableLayoutPanel3.TabIndex = 11;
//
// lblTotalTime
//
lblTotalTime.AutoSize = true;
lblTotalTime.Dock = DockStyle.Fill;
lblTotalTime.Location = new Point(91, 25);
lblTotalTime.Name = "lblTotalTime";
lblTotalTime.Size = new Size(82, 25);
lblTotalTime.TabIndex = 15;
lblTotalTime.Text = "0";
lblTotalTime.TextAlign = ContentAlignment.MiddleCenter;
//
// label1
//
label1.AutoSize = true;
label1.Dock = DockStyle.Fill;
label1.Location = new Point(179, 25);
label1.Name = "label1";
label1.Size = new Size(75, 25);
label1.TabIndex = 8;
label1.Text = "UPH";
label1.TextAlign = ContentAlignment.MiddleCenter;
//
// label12
//
label12.AutoSize = true;
label12.Dock = DockStyle.Fill;
label12.Location = new Point(3, 25);
label12.Name = "label12";
label12.Size = new Size(82, 25);
label12.TabIndex = 14;
label12.Text = "运行时间";
label12.TextAlign = ContentAlignment.MiddleCenter;
//
// lblUPH
//
lblUPH.AutoSize = true;
lblUPH.Dock = DockStyle.Fill;
lblUPH.Location = new Point(260, 25);
lblUPH.Name = "lblUPH";
lblUPH.Size = new Size(69, 25);
lblUPH.TabIndex = 9;
lblUPH.Text = "0";
lblUPH.TextAlign = ContentAlignment.MiddleCenter;
//
// lblStartTime
//
lblStartTime.AutoSize = true;
lblStartTime.Dock = DockStyle.Fill;
lblStartTime.Location = new Point(91, 0);
lblStartTime.Name = "lblStartTime";
lblStartTime.Size = new Size(82, 25);
lblStartTime.TabIndex = 11;
lblStartTime.Text = "0";
lblStartTime.TextAlign = ContentAlignment.MiddleCenter;
//
// lblOEE_Total
//
lblOEE_Total.AutoSize = true;
lblOEE_Total.Dock = DockStyle.Fill;
lblOEE_Total.Location = new Point(260, 0);
lblOEE_Total.Name = "lblOEE_Total";
lblOEE_Total.Size = new Size(69, 25);
lblOEE_Total.TabIndex = 13;
lblOEE_Total.Text = "0";
lblOEE_Total.TextAlign = ContentAlignment.MiddleCenter;
//
// label10
//
label10.AutoSize = true;
label10.Dock = DockStyle.Fill;
label10.Location = new Point(3, 0);
label10.Name = "label10";
label10.Size = new Size(82, 25);
label10.TabIndex = 12;
label10.Text = "开始时间";
label10.TextAlign = ContentAlignment.MiddleCenter;
//
// label7
//
label7.AutoSize = true;
label7.Dock = DockStyle.Fill;
label7.Location = new Point(179, 0);
label7.Name = "label7";
label7.Size = new Size(75, 25);
label7.TabIndex = 10;
label7.Text = "总计数";
label7.TextAlign = ContentAlignment.MiddleCenter;
//
// panel2
//
panel2.Location = new Point(511, 86);
panel2.Name = "panel2";
panel2.Size = new Size(814, 364);
panel2.TabIndex = 3;
panel2.Text = "panel2";
tabPage2.Location = new Point(3, 28);
tabPage2.Name = "tabPage2";
tabPage2.Size = new Size(428, 469);
tabPage2.TabIndex = 0;
tabPage2.Text = "配置";
//
// panel1
//
panel1.Back = Color.FromArgb(46, 108, 227);
panel1.Controls.Add(panel3);
panel1.Back = SystemColors.MenuHighlight;
panel1.Controls.Add(segmented1);
panel1.Dock = DockStyle.Top;
panel1.Location = new Point(0, 0);
@ -457,61 +322,6 @@
panel1.TabIndex = 0;
panel1.Text = "panel1";
//
// panel3
//
panel3.Back = Color.FromArgb(46, 108, 227);
panel3.Controls.Add(btnDeleteProject);
panel3.Controls.Add(btnAddProject);
panel3.Controls.Add(btnLoadProject);
panel3.Controls.Add(sltProjects);
panel3.Dock = DockStyle.Right;
panel3.Location = new Point(553, 0);
panel3.Name = "panel3";
panel3.Padding = new Padding(30);
panel3.Radius = 0;
panel3.ShadowOpacity = 0F;
panel3.ShadowOpacityHover = 0F;
panel3.Size = new Size(471, 68);
panel3.TabIndex = 16;
panel3.Text = "panel3";
//
// btnDeleteProject
//
btnDeleteProject.Location = new Point(400, 18);
btnDeleteProject.Name = "btnDeleteProject";
btnDeleteProject.Size = new Size(68, 40);
btnDeleteProject.TabIndex = 19;
btnDeleteProject.Text = "删除";
btnDeleteProject.Visible = false;
//
// btnAddProject
//
btnAddProject.Location = new Point(326, 18);
btnAddProject.Name = "btnAddProject";
btnAddProject.Size = new Size(68, 40);
btnAddProject.TabIndex = 18;
btnAddProject.Text = "新增";
btnAddProject.Visible = false;
//
// btnLoadProject
//
btnLoadProject.Location = new Point(252, 18);
btnLoadProject.Name = "btnLoadProject";
btnLoadProject.Size = new Size(68, 40);
btnLoadProject.TabIndex = 17;
btnLoadProject.Text = "载入";
btnLoadProject.Visible = false;
//
// sltProjects
//
sltProjects.List = true;
sltProjects.Location = new Point(25, 18);
sltProjects.Margin = new Padding(10);
sltProjects.MaxCount = 10;
sltProjects.Name = "sltProjects";
sltProjects.Size = new Size(214, 40);
sltProjects.TabIndex = 16;
//
// segmented1
//
segmented1.BackActive = Color.FromArgb(100, 255, 87, 34);
@ -520,56 +330,66 @@
segmented1.Font = new Font("Microsoft YaHei UI", 9F);
segmented1.ForeColor = Color.White;
segmented1.Full = true;
segmentedItem6.Badge = null;
segmentedItem6.BadgeAlign = AntdUI.TAlignFrom.TR;
segmentedItem6.BadgeBack = null;
segmentedItem6.BadgeMode = false;
segmentedItem6.BadgeOffsetX = 0;
segmentedItem6.BadgeOffsetY = 0;
segmentedItem6.BadgeSize = 0.6F;
segmentedItem6.BadgeSvg = null;
segmentedItem6.Text = "启动";
segmentedItem7.Badge = null;
segmentedItem7.BadgeAlign = AntdUI.TAlignFrom.TR;
segmentedItem7.BadgeBack = null;
segmentedItem7.BadgeMode = false;
segmentedItem7.BadgeOffsetX = 0;
segmentedItem7.BadgeOffsetY = 0;
segmentedItem7.BadgeSize = 0.6F;
segmentedItem7.BadgeSvg = null;
segmentedItem7.Text = "停止";
segmentedItem8.Badge = null;
segmentedItem8.BadgeAlign = AntdUI.TAlignFrom.TR;
segmentedItem8.BadgeBack = null;
segmentedItem8.BadgeMode = false;
segmentedItem8.BadgeOffsetX = 0;
segmentedItem8.BadgeOffsetY = 0;
segmentedItem8.BadgeSize = 0.6F;
segmentedItem8.BadgeSvg = null;
segmentedItem8.Text = "复位";
segmentedItem9.Badge = null;
segmentedItem9.BadgeAlign = AntdUI.TAlignFrom.TR;
segmentedItem9.BadgeBack = null;
segmentedItem9.BadgeMode = false;
segmentedItem9.BadgeOffsetX = 0;
segmentedItem9.BadgeOffsetY = 0;
segmentedItem9.BadgeSize = 0.6F;
segmentedItem9.BadgeSvg = null;
segmentedItem9.Text = "登录";
segmentedItem10.Badge = null;
segmentedItem10.BadgeAlign = AntdUI.TAlignFrom.TR;
segmentedItem10.BadgeBack = null;
segmentedItem10.BadgeMode = false;
segmentedItem10.BadgeOffsetX = 0;
segmentedItem10.BadgeOffsetY = 0;
segmentedItem10.BadgeSize = 0.6F;
segmentedItem10.BadgeSvg = null;
segmentedItem10.Text = "设置";
segmented1.Items.Add(segmentedItem6);
segmented1.Items.Add(segmentedItem7);
segmented1.Items.Add(segmentedItem8);
segmented1.Items.Add(segmentedItem9);
segmented1.Items.Add(segmentedItem10);
segmentedItem1.Badge = null;
segmentedItem1.BadgeAlign = AntdUI.TAlignFrom.TR;
segmentedItem1.BadgeBack = null;
segmentedItem1.BadgeMode = false;
segmentedItem1.BadgeOffsetX = 0;
segmentedItem1.BadgeOffsetY = 0;
segmentedItem1.BadgeSize = 0.6F;
segmentedItem1.BadgeSvg = null;
segmentedItem1.IconActiveSvg = resources.GetString("segmentedItem1.IconActiveSvg");
segmentedItem1.IconSvg = resources.GetString("segmentedItem1.IconSvg");
segmentedItem1.Text = "启动";
segmentedItem2.Badge = null;
segmentedItem2.BadgeAlign = AntdUI.TAlignFrom.TR;
segmentedItem2.BadgeBack = null;
segmentedItem2.BadgeMode = false;
segmentedItem2.BadgeOffsetX = 0;
segmentedItem2.BadgeOffsetY = 0;
segmentedItem2.BadgeSize = 0.6F;
segmentedItem2.BadgeSvg = null;
segmentedItem2.IconActiveSvg = resources.GetString("segmentedItem2.IconActiveSvg");
segmentedItem2.IconSvg = resources.GetString("segmentedItem2.IconSvg");
segmentedItem2.Text = "停止";
segmentedItem3.Badge = null;
segmentedItem3.BadgeAlign = AntdUI.TAlignFrom.TR;
segmentedItem3.BadgeBack = null;
segmentedItem3.BadgeMode = false;
segmentedItem3.BadgeOffsetX = 0;
segmentedItem3.BadgeOffsetY = 0;
segmentedItem3.BadgeSize = 0.6F;
segmentedItem3.BadgeSvg = null;
segmentedItem3.IconActiveSvg = resources.GetString("segmentedItem3.IconActiveSvg");
segmentedItem3.IconSvg = resources.GetString("segmentedItem3.IconSvg");
segmentedItem3.Text = "复位";
segmentedItem4.Badge = null;
segmentedItem4.BadgeAlign = AntdUI.TAlignFrom.TR;
segmentedItem4.BadgeBack = null;
segmentedItem4.BadgeMode = false;
segmentedItem4.BadgeOffsetX = 0;
segmentedItem4.BadgeOffsetY = 0;
segmentedItem4.BadgeSize = 0.6F;
segmentedItem4.BadgeSvg = null;
segmentedItem4.IconActiveSvg = resources.GetString("segmentedItem4.IconActiveSvg");
segmentedItem4.IconSvg = resources.GetString("segmentedItem4.IconSvg");
segmentedItem4.Text = "设置";
segmentedItem5.Badge = null;
segmentedItem5.BadgeAlign = AntdUI.TAlignFrom.TR;
segmentedItem5.BadgeBack = null;
segmentedItem5.BadgeMode = false;
segmentedItem5.BadgeOffsetX = 0;
segmentedItem5.BadgeOffsetY = 0;
segmentedItem5.BadgeSize = 0.6F;
segmentedItem5.BadgeSvg = null;
segmentedItem5.IconActiveSvg = resources.GetString("segmentedItem5.IconActiveSvg");
segmentedItem5.IconSvg = resources.GetString("segmentedItem5.IconSvg");
segmentedItem5.Text = "登录";
segmented1.Items.Add(segmentedItem1);
segmented1.Items.Add(segmentedItem2);
segmented1.Items.Add(segmentedItem3);
segmented1.Items.Add(segmentedItem4);
segmented1.Items.Add(segmentedItem5);
segmented1.Location = new Point(0, 0);
segmented1.Name = "segmented1";
segmented1.Size = new Size(491, 68);
@ -579,88 +399,65 @@
//
// MainWindow
//
ClientSize = new Size(1024, 671);
ClientSize = new Size(1024, 648);
ControlBox = false;
Controls.Add(panelmain);
Controls.Add(pageHeader1);
Controls.Add(titlebar);
Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
Icon = (Icon)resources.GetObject("$this.Icon");
Name = "MainWindow";
StartPosition = FormStartPosition.CenterScreen;
Text = "CCD光学筛选系统";
Text = "AntdUI Demo";
WindowState = FormWindowState.Maximized;
FormClosing += MainWindow_FormClosing;
FormClosed += MainWindow_FormClosed;
Load += MainWindow_Load;
titlebar.ResumeLayout(false);
pageHeader1.ResumeLayout(false);
pageHeader1.PerformLayout();
panelmain.ResumeLayout(false);
panel2.ResumeLayout(false);
panel4.ResumeLayout(false);
panel6.ResumeLayout(false);
splitContainer1.Panel1.ResumeLayout(false);
splitContainer1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit();
splitContainer1.ResumeLayout(false);
splitContainer2.Panel1.ResumeLayout(false);
splitContainer2.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitContainer2).EndInit();
splitContainer2.ResumeLayout(false);
tabImgDisplay.ResumeLayout(false);
tabsStas.ResumeLayout(false);
tabPage3.ResumeLayout(false);
panelmain.ResumeLayout(false);
splitter2.Panel1.ResumeLayout(false);
splitter2.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitter2).EndInit();
splitter2.ResumeLayout(false);
splitter1.Panel1.ResumeLayout(false);
splitter1.Panel2.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)splitter1).EndInit();
splitter1.ResumeLayout(false);
panel6.ResumeLayout(false);
tableLayoutstatistics.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dgvCamreaNums).EndInit();
panelNums.ResumeLayout(false);
tableLayoutNums.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)dgvProductNums).EndInit();
tableLayoutPanel3.ResumeLayout(false);
tableLayoutPanel3.PerformLayout();
tabsConfig.ResumeLayout(false);
panel1.ResumeLayout(false);
panel3.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private AntdUI.PageHeader titlebar;
private AntdUI.Button buttonSZ;
private AntdUI.Button button_color;
private AntdUI.PageHeader pageHeader1;
private AntdUI.Divider divider2;
private AntdUI.Panel panelmain;
private AntdUI.Panel panel1;
private AntdUI.Segmented segmented1;
private AntdUI.Panel panel2;
private AntdUI.Panel panel4;
private AntdUI.Panel panel6;
private Label label1;
private AntdUI.Splitter splitter1;
private AntdUI.Label lbName;
private AntdUI.Panel panel3;
private AntdUI.Button btnDeleteProject;
private AntdUI.Button btnAddProject;
private AntdUI.Button btnLoadProject;
public AntdUI.Select sltProjects;
private Panel panel7;
// private Panel panel5;
// private Label lblNum;
// private Label label2;
// private Label lblNowtime;
// private Label label8;
// private Label lblstarttime;
// private Label label6;
// private Label lblUPH;
private Label label4;
private AntdUI.TabPage tabPage3;
private SplitContainer splitContainer1;
private SplitContainer splitContainer2;
private AntdUI.Tabs tabImgDisplay;
private AntdUI.TabPage tabMain;
private AntdUI.Tabs tabsStas;
private AntdUI.Panel panel2;
private AntdUI.Tabs tabImgDisplay;
private AntdUI.Panel panel6;
private AntdUI.Panel pnlLog;
private AntdUI.Splitter splitter2;
private TableLayoutPanel tableLayoutstatistics;
private AntdUI.Panel panelNums;
private DataGridView dgvCamreaNums;
private TableLayoutPanel tableLayoutNums;
private Label label1;
private Label lblTotalTime;
private Label lblUPH;
private Label label12;
private Label label7;
private Label lblOEE_Total;
private Label lblStartTime;
private Label label10;
private DataGridView dgvProductNums;
private TableLayoutPanel tableLayoutPanel3;
private AntdUI.TabPage tabPage3;
private RichTextBox richTextBox1;
private AntdUI.Tabs tabsConfig;
private AntdUI.TabPage tabPage2;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -117,6 +117,39 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="buttonSZ.IconSvg" xml:space="preserve">
<value>&lt;svg t="1724122928419" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="2893" width="200" height="200"&gt;&lt;path d="M920.5 435.9c-7.6-40.3-36.1-66.8-69.8-66.2h-3.4c-36.6 0-66.3-29.7-66.3-66.3 0-7.8 3.6-19.1 6-24.9 15.4-35.1 3.3-78.1-28.9-100.6l-102-56.9-4.2-2c-31.7-13.7-72.7-5.4-96.4 19.2-15.1 15.6-42.2 33.7-54.6 33.7-12.5 0-39.8-18.5-54.9-34.3-23.6-24.9-62.2-34.4-97.4-19.5l-105.4 57.7-4.2 2.7c-31.7 22-43.8 65.3-28.3 100.1 1.9 4.6 6 16.7 6 24.9 0 36.6-29.7 66.3-66.3 66.3h-2.6c-34.9-0.6-63.1 25.8-70.7 66.2-0.9 4.8-8.9 48.2-8.9 84s8 79.2 8.9 84c7.5 39.6 35.3 66.2 69.2 66.2h4.1c36.6 0 66.3 29.7 66.3 66.3 0 8.2-4 20.3-5.8 24.5-15.6 35.2-3.6 78.4 28.9 101.2l99.8 56 4.1 2c10.5 4.6 21.8 6.9 33.6 6.9 24.5 0 47.8-9.9 63.7-27.3 14.8-16.1 43.5-35.8 55.8-35.8 12.8 0 40.8 19.7 56.1 36.5 15.8 17.4 39.8 27.8 64.2 27.8 11.6 0 22.6-2.2 34.3-7.3l103.2-56.9 4.2-2.7c31.6-22 43.7-65.2 28.1-100.4-1.9-4.6-5.9-16.5-5.9-24.6 0-36.6 29.7-66.3 66.3-66.3h4c34 0 61.7-26.4 69.2-65.9 0.1-0.5 9-46.3 9-84.4-0.1-35.9-8.1-79.1-9-83.9z m-71.3 154.6c-0.6 3.3-1.5 5.6-2.2 7.1-76.4 0.1-138.6 62.4-138.6 138.8 0 23 8.4 45.7 12.1 53.9 1.6 3.5 0.4 8.4-3.3 11.5l-96.4 53.3c-4.7 1.6-11.9-0.9-14.3-3.5-5.6-6.2-56.5-60.3-109.8-60.3-54 0-106.9 56.8-109.1 59.2-2.2 2.4-7.4 5.7-14.6 3.1l-93.1-52.1c-3.1-2.5-4.5-7.7-2.8-11.6 1.2-2.8 12-28.1 12-53.7 0-76.5-62.1-138.7-138.6-138.8-0.7-1.5-1.6-3.8-2.3-7.1-0.3-1.6-7.6-40.9-7.6-70.6 0-29.7 7.3-69 7.6-70.6 0.6-3.3 1.5-5.7 2.3-7.1 76.4-0.1 138.6-62.3 138.6-138.8 0-25-9.9-49.1-12.1-54-1.5-3.5-0.4-8.3 3.2-11.4l98.2-53.9c4.8-1.7 12.5 0.8 15 3.4 5.5 5.8 55.7 56.8 107.4 56.8 51.2 0 101.2-50 106.7-55.8 2.4-2.4 8.3-5.6 15.1-3.1l94.9 52.7c3.2 2.5 4.5 7.7 2.9 11.3l-0.7 1.8c-3.1 7.6-11.3 29.8-11.3 52.2 0 76.5 62.1 138.7 138.6 138.8 0.7 1.5 1.6 3.8 2.3 7.1 0.1 0.4 7.6 40.6 7.6 70.6-0.1 25.6-5.7 60.4-7.7 70.8z" p-id="2894"&gt;&lt;/path&gt;&lt;path d="M498.7 355.9c-90.3 0-163.8 73.5-163.8 163.8 0 90.3 73.5 163.8 163.8 163.8 90.3 0 163.8-73.5 163.8-163.8 0-90.4-73.5-163.8-163.8-163.8z m0 273.1c-60.3 0-109.4-49.1-109.4-109.4 0-60.3 49.1-109.4 109.4-109.4 60.3 0 109.4 49.1 109.4 109.4 0 60.3-49.1 109.4-109.4 109.4z" p-id="2895"&gt;&lt;/path&gt;&lt;/svg&gt;</value>
</data>
<data name="segmentedItem1.IconActiveSvg" xml:space="preserve">
<value>&lt;svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"&gt;&lt;path d="M731.818667 500.280889L386.844444 239.729778a14.677333 14.677333 0 0 0-23.495111 11.719111v521.159111a14.677333 14.677333 0 0 0 23.495111 11.662222l344.860445-260.608a14.677333 14.677333 0 0 0 0.113778-23.381333z" fill="#FFFFFF"/&gt;&lt;path d="M512 1024a512 512 0 1 1 512-512 512.568889 512.568889 0 0 1-512 512z m0-946.915556A434.915556 434.915556 0 1 0 946.915556 512 435.427556 435.427556 0 0 0 512 77.084444z" fill="#FFFFFF"/&gt;&lt;/svg&gt;</value>
</data>
<data name="segmentedItem1.IconSvg" xml:space="preserve">
<value>&lt;svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"&gt;&lt;path d="M731.818667 500.280889L386.844444 239.729778a14.677333 14.677333 0 0 0-23.495111 11.719111v521.159111a14.677333 14.677333 0 0 0 23.495111 11.662222l344.860445-260.608a14.677333 14.677333 0 0 0 0.113778-23.381333z" fill="#FFFFFF"/&gt;&lt;path d="M512 1024a512 512 0 1 1 512-512 512.568889 512.568889 0 0 1-512 512z m0-946.915556A434.915556 434.915556 0 1 0 946.915556 512 435.427556 435.427556 0 0 0 512 77.084444z" fill="#FFFFFF"/&gt;&lt;/svg&gt;</value>
</data>
<data name="segmentedItem2.IconActiveSvg" xml:space="preserve">
<value>&lt;svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"&gt;&lt;path d="M365.014704 657.815846H657.084939V365.74561H365.014704V657.815846zm584.140471-146.035118c0-240.906781-197.125482-438.105353-438.105353-438.105353-240.979872 0-438.105353 197.198572-438.105354 438.105353 0 240.979872 197.125482 438.178444 438.105354 438.178444 240.979872 0 438.105353-197.198572 438.105353-438.178444zM511.634547 0.730906c281.399001 0 511.634547 230.235546 511.634547 511.634547s-230.235546 511.634547-511.634547 511.634547-511.634547-230.235546-511.634547-511.634547 230.235546-511.634547 511.634547-511.634547z" fill="#FFFFFF"/&gt;&lt;/svg&gt;</value>
</data>
<data name="segmentedItem2.IconSvg" xml:space="preserve">
<value>&lt;svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"&gt;&lt;path d="M365.014704 657.815846H657.084939V365.74561H365.014704V657.815846zm584.140471-146.035118c0-240.906781-197.125482-438.105353-438.105353-438.105353-240.979872 0-438.105353 197.198572-438.105354 438.105353 0 240.979872 197.125482 438.178444 438.105354 438.178444 240.979872 0 438.105353-197.198572 438.105353-438.178444zM511.634547 0.730906c281.399001 0 511.634547 230.235546 511.634547 511.634547s-230.235546 511.634547-511.634547 511.634547-511.634547-230.235546-511.634547-511.634547 230.235546-511.634547 511.634547-511.634547z" fill="#FFFFFF"/&gt;&lt;/svg&gt;</value>
</data>
<data name="segmentedItem3.IconActiveSvg" xml:space="preserve">
<value>&lt;svg viewBox="0 0 1027 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"&gt;&lt;path d="M512 0C229.376 0 0 229.376 0 512s229.376 512 512 512 512-229.376 512-512S794.624 0 512 0zm0 963.584c-249.344 0-451.584-202.24-451.584-451.584S262.656 60.416 512 60.416s451.584 202.24 451.584 451.584-202.24 451.584-451.584 451.584z" fill="#FFFFFF"/&gt;&lt;path d="M527.36 351.744V292.864L410.624 380.416 527.36 468.48V410.624c72.192 8.192 124.416 73.216 116.224 145.408-8.192 72.192-73.216 124.416-145.408 116.224-66.56-7.168-117.248-64-117.248-131.072-0.512-5.12-0.512-9.728 0-14.848H323.584c-0.512 5.12-0.512 9.728 0 14.848 0 104.96 85.504 189.952 190.464 189.952s189.952-85.504 189.952-190.464c-0.512-99.328-77.312-181.76-176.64-188.928z" fill="#FFFFFF"/&gt;&lt;/svg&gt;</value>
</data>
<data name="segmentedItem3.IconSvg" xml:space="preserve">
<value>&lt;svg viewBox="0 0 1027 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"&gt;&lt;path d="M512 0C229.376 0 0 229.376 0 512s229.376 512 512 512 512-229.376 512-512S794.624 0 512 0zm0 963.584c-249.344 0-451.584-202.24-451.584-451.584S262.656 60.416 512 60.416s451.584 202.24 451.584 451.584-202.24 451.584-451.584 451.584z" fill="#FFFFFF"/&gt;&lt;path d="M527.36 351.744V292.864L410.624 380.416 527.36 468.48V410.624c72.192 8.192 124.416 73.216 116.224 145.408-8.192 72.192-73.216 124.416-145.408 116.224-66.56-7.168-117.248-64-117.248-131.072-0.512-5.12-0.512-9.728 0-14.848H323.584c-0.512 5.12-0.512 9.728 0 14.848 0 104.96 85.504 189.952 190.464 189.952s189.952-85.504 189.952-190.464c-0.512-99.328-77.312-181.76-176.64-188.928z" fill="#FFFFFF"/&gt;&lt;/svg&gt;</value>
</data>
<data name="segmentedItem4.IconActiveSvg" xml:space="preserve">
<value>&lt;svg viewBox="0 0 1027 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"&gt;&lt;path d="M512 0C229.376 0 0 229.376 0 512s229.376 512 512 512 512-229.376 512-512S794.624 0 512 0zm0 963.584c-249.344 0-451.584-202.24-451.584-451.584S262.656 60.416 512 60.416s451.584 202.24 451.584 451.584-202.24 451.584-451.584 451.584z" fill="#FFFFFF"/&gt;&lt;path d="M437.314 840.84l-18.967-5.795c-43.935-13.425-84.182-35.551-119.623-65.767l-15.203-12.962 11.199-16.544c17.376-25.668 17.938-59.158 1.433-85.319-14.356-22.787-39.028-36.385-66.006-36.385-4.102 0-8.229 0.328-12.267 0.974l-19.752 3.158-5.301-19.288c-8.196-29.823-12.353-59.896-12.353-89.381 0-19.675 1.863-39.491 5.694-60.582l3.652-20.105 20.349 1.862c2.343 0.214 4.726 0.323 7.081 0.323 29.007 0 55.436-15.908 68.974-41.516 14.941-28.2 11.264-62.223-9.356-86.694l-13.166-15.625L278.1 276.7c38.694-38.954 86.677-68.095 138.76-84.273l19.741-6.132 7.631 19.211c11.88 29.908 40.312 49.234 72.432 49.234 32.097 0 60.521-19.328 72.413-49.241l7.632-19.197 19.73 6.122c43.968 13.642 84.295 36.164 119.862 66.938l15.414 13.337-11.883 16.561c-18.636 25.975-19.684 60.166-2.671 87.105 14.369 22.78 39.055 36.373 66.04 36.372 4.344 0 8.71-0.366 12.978-1.087l20.143-3.403 5.176 19.762c7.539 28.792 11.362 57.566 11.362 85.522 0 21.328-2.143 43.048-6.365 64.554l-3.859 19.65-19.952-1.709a77.999 77.999 0 0 0-6.612-0.281c-28.998 0-55.44 15.917-69.009 41.542-14.47 27.405-11.311 60.816 8.063 85.095l12.496 15.661-14.222 14.111c-38.674 38.378-86.551 67.041-138.455 82.892l-18.968 5.792-7.988-18.152c-12.462-28.318-40.459-46.617-71.325-46.617-30.883 0-58.893 18.299-71.36 46.619l-7.99 18.152zm-95.455-94.18c22.324 16.82 46.59 30.174 72.469 39.881 22.445-34.023 60.731-55.125 102.336-55.125 41.59 0 79.862 21.1 102.303 55.12 32.745-12.298 63.249-30.557 89.663-53.667-19.709-35.774-20.525-79.555-1.04-116.455 19.699-37.203 56.634-61.386 98.053-64.883 1.705-12.731 2.565-25.453 2.565-38 0-18.339-1.923-37.155-5.729-56.144-42.123-0.241-80.616-21.581-103.077-57.189-22.944-36.331-25.024-81.029-6.697-118.768-22.165-16.932-46.203-30.4-71.788-40.221-8.847 14.328-20.577 26.719-34.618 36.447-20.522 14.219-44.602 21.735-69.635 21.735-25.044 0-49.131-7.516-69.657-21.734-14.042-9.727-25.773-22.116-34.618-36.441-32.551 12.503-62.856 30.935-89.106 54.196 21.198 36.233 22.547 80.974 2.407 118.987-19.71 37.285-56.808 61.499-98.402 64.875-1.45 11.713-2.161 23.035-2.161 34.255 0 19.715 2.166 39.792 6.449 59.894 41.851 0.474 80.029 21.785 102.35 57.214 22.218 35.217 24.782 78.871 7.933 116.023z" fill="#FFFFFF"/&gt;&lt;path d="M516.664 633.864c-66.246 0-120.141-53.897-120.141-120.147 0-66.249 53.895-120.146 120.141-120.146 66.237 0 120.127 53.897 120.127 120.146 0 66.25-53.89 120.147-120.127 120.147zm0-195.641c-41.625 0-75.488 33.866-75.488 75.494s33.863 75.495 75.488 75.495c41.617 0 75.475-33.867 75.475-75.495s-33.858-75.494-75.475-75.494z" fill="#FFFFFF"/&gt;&lt;/svg&gt;</value>
</data>
<data name="segmentedItem4.IconSvg" xml:space="preserve">
<value>&lt;svg viewBox="0 0 1027 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"&gt;&lt;path d="M512 0C229.376 0 0 229.376 0 512s229.376 512 512 512 512-229.376 512-512S794.624 0 512 0zm0 963.584c-249.344 0-451.584-202.24-451.584-451.584S262.656 60.416 512 60.416s451.584 202.24 451.584 451.584-202.24 451.584-451.584 451.584z" fill="#FFFFFF"/&gt;&lt;path d="M437.314 840.84l-18.967-5.795c-43.935-13.425-84.182-35.551-119.623-65.767l-15.203-12.962 11.199-16.544c17.376-25.668 17.938-59.158 1.433-85.319-14.356-22.787-39.028-36.385-66.006-36.385-4.102 0-8.229 0.328-12.267 0.974l-19.752 3.158-5.301-19.288c-8.196-29.823-12.353-59.896-12.353-89.381 0-19.675 1.863-39.491 5.694-60.582l3.652-20.105 20.349 1.862c2.343 0.214 4.726 0.323 7.081 0.323 29.007 0 55.436-15.908 68.974-41.516 14.941-28.2 11.264-62.223-9.356-86.694l-13.166-15.625L278.1 276.7c38.694-38.954 86.677-68.095 138.76-84.273l19.741-6.132 7.631 19.211c11.88 29.908 40.312 49.234 72.432 49.234 32.097 0 60.521-19.328 72.413-49.241l7.632-19.197 19.73 6.122c43.968 13.642 84.295 36.164 119.862 66.938l15.414 13.337-11.883 16.561c-18.636 25.975-19.684 60.166-2.671 87.105 14.369 22.78 39.055 36.373 66.04 36.372 4.344 0 8.71-0.366 12.978-1.087l20.143-3.403 5.176 19.762c7.539 28.792 11.362 57.566 11.362 85.522 0 21.328-2.143 43.048-6.365 64.554l-3.859 19.65-19.952-1.709a77.999 77.999 0 0 0-6.612-0.281c-28.998 0-55.44 15.917-69.009 41.542-14.47 27.405-11.311 60.816 8.063 85.095l12.496 15.661-14.222 14.111c-38.674 38.378-86.551 67.041-138.455 82.892l-18.968 5.792-7.988-18.152c-12.462-28.318-40.459-46.617-71.325-46.617-30.883 0-58.893 18.299-71.36 46.619l-7.99 18.152zm-95.455-94.18c22.324 16.82 46.59 30.174 72.469 39.881 22.445-34.023 60.731-55.125 102.336-55.125 41.59 0 79.862 21.1 102.303 55.12 32.745-12.298 63.249-30.557 89.663-53.667-19.709-35.774-20.525-79.555-1.04-116.455 19.699-37.203 56.634-61.386 98.053-64.883 1.705-12.731 2.565-25.453 2.565-38 0-18.339-1.923-37.155-5.729-56.144-42.123-0.241-80.616-21.581-103.077-57.189-22.944-36.331-25.024-81.029-6.697-118.768-22.165-16.932-46.203-30.4-71.788-40.221-8.847 14.328-20.577 26.719-34.618 36.447-20.522 14.219-44.602 21.735-69.635 21.735-25.044 0-49.131-7.516-69.657-21.734-14.042-9.727-25.773-22.116-34.618-36.441-32.551 12.503-62.856 30.935-89.106 54.196 21.198 36.233 22.547 80.974 2.407 118.987-19.71 37.285-56.808 61.499-98.402 64.875-1.45 11.713-2.161 23.035-2.161 34.255 0 19.715 2.166 39.792 6.449 59.894 41.851 0.474 80.029 21.785 102.35 57.214 22.218 35.217 24.782 78.871 7.933 116.023z" fill="#FFFFFF"/&gt;&lt;path d="M516.664 633.864c-66.246 0-120.141-53.897-120.141-120.147 0-66.249 53.895-120.146 120.141-120.146 66.237 0 120.127 53.897 120.127 120.146 0 66.25-53.89 120.147-120.127 120.147zm0-195.641c-41.625 0-75.488 33.866-75.488 75.494s33.863 75.495 75.488 75.495c41.617 0 75.475-33.867 75.475-75.495s-33.858-75.494-75.475-75.494z" fill="#FFFFFF"/&gt;&lt;/svg&gt;</value>
</data>
<data name="segmentedItem5.IconActiveSvg" xml:space="preserve">
<value>&lt;svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"&gt;&lt;path d="M512 0C229.376 0 0 229.376 0 512s229.376 512 512 512 512-229.376 512-512S794.624 0 512 0zm0 963.584c-249.344 0-451.584-202.24-451.584-451.584S262.656 60.416 512 60.416s451.584 202.24 451.584 451.584-202.24 451.584-451.584 451.584z" fill="#FFFFFF"/&gt;&lt;path transform="scale(0.8) translate(128,128)" d="M960.853333 903.816533a463.633067 463.633067 0 0 0-11.264-39.185066c-1.536-4.539733-3.413333-8.942933-5.051733-13.448534a484.078933 484.078933 0 0 0-9.557333-24.4736c-2.2528-5.188267-4.881067-10.274133-7.338667-15.394133-3.413333-7.099733-6.8608-14.165333-10.6496-21.0944-2.901333-5.3248-6.075733-10.513067-9.181867-15.701333-2.423467-4.061867-4.573867-8.226133-7.133866-12.219734-1.604267-2.4576-3.413333-4.778667-5.0176-7.202133-1.501867-2.218667-2.730667-4.608-4.266667-6.792533-0.4096-0.6144-1.058133-0.887467-1.501867-1.4336a461.482667 461.482667 0 0 0-90.385066-96.768c-13.5168-10.786133-27.7504-20.48-42.257067-29.5936-0.477867-0.341333-0.7168-0.8192-1.194667-1.1264-3.6864-2.286933-7.509333-4.3008-11.264-6.485334-4.266667-2.491733-8.4992-5.051733-12.868266-7.441066-6.826667-3.6864-13.789867-7.099733-20.753067-10.478934-3.618133-1.7408-7.202133-3.618133-10.8544-5.290666a449.194667 449.194667 0 0 0-31.607467-12.731734c-0.7168-0.273067-1.365333-0.6144-2.082133-0.8192-3.140267-1.1264-6.417067-1.911467-9.557333-2.935466-4.164267-1.399467-8.328533-2.833067-12.561067-4.096a259.9936 259.9936 0 0 0 129.194667-225.450667 260.061867 260.061867 0 0 0-76.629334-185.002667 259.9936 259.9936 0 0 0-185.002666-76.629333H512h-0.034133a259.857067 259.857067 0 0 0-185.002667 76.629333 259.925333 259.925333 0 0 0-76.629333 185.002667 259.584 259.584 0 0 0 76.629333 185.002667c15.906133 15.940267 33.655467 29.2864 52.565333 40.448-4.266667 1.262933-8.430933 2.730667-12.663466 4.096-3.140267 1.058133-6.3488 1.8432-9.489067 2.935466-0.7168 0.238933-1.365333 0.580267-2.048 0.8192-10.683733 3.822933-21.265067 8.0896-31.675733 12.765867-3.584 1.604267-7.0656 3.4816-10.615467 5.154133-7.099733 3.413333-14.165333 6.826667-21.0944 10.615467-4.266667 2.321067-8.3968 4.8128-12.561067 7.2704-3.822933 2.218667-7.748267 4.266667-11.502933 6.621867-0.512 0.3072-0.750933 0.8192-1.2288 1.160533-14.506667 9.147733-28.706133 18.807467-42.222933 29.559467a459.6736 459.6736 0 0 0-90.385067 96.768c-0.443733 0.546133-1.092267 0.8192-1.501867 1.4336-1.536 2.184533-2.7648 4.573867-4.266666 6.792533-1.604267 2.423467-3.447467 4.744533-5.0176 7.202133-2.56 3.9936-4.7104 8.157867-7.133867 12.219734-3.106133 5.188267-6.280533 10.376533-9.181867 15.701333-3.7888 6.929067-7.202133 13.994667-10.6496 21.0944-2.4576 5.12-5.051733 10.205867-7.338666 15.394133-3.515733 8.021333-6.519467 16.247467-9.557334 24.4736-1.672533 4.5056-3.549867 8.9088-5.051733 13.448534-4.3008 12.868267-8.0896 25.941333-11.264 39.185066-3.072 12.970667 2.594133 25.770667 13.073067 32.802134a31.3344 31.3344 0 0 0 9.966933 4.608 30.9248 30.9248 0 0 0 34.030933-15.2576 30.446933 30.446933 0 0 0 3.345067-7.7824c2.833067-11.844267 6.178133-23.483733 10.0352-34.9184 0.6144-1.8432 1.399467-3.549867 2.013867-5.358934 3.447467-9.762133 7.133867-19.456 11.332266-28.945066 0.512-1.160533 1.1264-2.2528 1.6384-3.447467 4.7104-10.308267 9.728-20.48 15.291734-30.344533l0.068266-0.1024a402.773333 402.773333 0 0 1 19.694934-31.4368l0.136533-0.375467a397.4144 397.4144 0 0 1 116.599467-111.2064c0.136533-0.1024 0.3072-0.068267 0.443733-0.170667a397.824 397.824 0 0 1 94.993067-42.973866c2.7648-0.8192 5.495467-1.7408 8.2944-2.491734 5.7344-1.604267 11.5712-3.003733 17.373866-4.334933a367.8208 367.8208 0 0 1 47.342934-7.953067c3.8912-0.443733 7.7824-0.9216 11.6736-1.2288 10.410667-0.785067 20.8896-1.3312 31.505066-1.3312s21.060267 0.546133 31.505067 1.3312c3.8912 0.3072 7.816533 0.785067 11.707733 1.2288a361.3696 361.3696 0 0 1 47.240534 7.953067c5.870933 1.3312 11.707733 2.730667 17.5104 4.334933 2.696533 0.750933 5.358933 1.6384 8.021333 2.4576 33.348267 10.103467 65.365333 24.405333 95.197867 43.008 0.136533 0.1024 0.3072 0.068267 0.443733 0.170667a396.151467 396.151467 0 0 1 116.599467 111.2064c0.1024 0.136533 0.1024 0.273067 0.170666 0.375467 13.687467 19.7632 25.3952 40.5504 35.191467 62.1568l1.467733 3.037866c4.3008 9.659733 8.055467 19.592533 11.605334 29.5936 0.546133 1.604267 1.2288 3.106133 1.774933 4.7104 3.822933 11.4688 7.236267 23.176533 10.0352 35.0208a31.061333 31.061333 0 0 0 60.450133-14.336zm-249.275733-560.2304A199.850667 199.850667 0 0 1 512 543.197867a199.850667 199.850667 0 0 1-199.5776-199.611734A199.816533 199.816533 0 0 1 512 144.008533a199.816533 199.816533 0 0 1 199.5776 199.5776z" fill="#FFFFFF"/&gt;&lt;/svg&gt;</value>
</data>
<data name="segmentedItem5.IconSvg" xml:space="preserve">
<value>&lt;svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"&gt;&lt;path d="M512 0C229.376 0 0 229.376 0 512s229.376 512 512 512 512-229.376 512-512S794.624 0 512 0zm0 963.584c-249.344 0-451.584-202.24-451.584-451.584S262.656 60.416 512 60.416s451.584 202.24 451.584 451.584-202.24 451.584-451.584 451.584z" fill="#FFFFFF"/&gt;&lt;path transform="scale(0.8) translate(128,128)" d="M960.853333 903.816533a463.633067 463.633067 0 0 0-11.264-39.185066c-1.536-4.539733-3.413333-8.942933-5.051733-13.448534a484.078933 484.078933 0 0 0-9.557333-24.4736c-2.2528-5.188267-4.881067-10.274133-7.338667-15.394133-3.413333-7.099733-6.8608-14.165333-10.6496-21.0944-2.901333-5.3248-6.075733-10.513067-9.181867-15.701333-2.423467-4.061867-4.573867-8.226133-7.133866-12.219734-1.604267-2.4576-3.413333-4.778667-5.0176-7.202133-1.501867-2.218667-2.730667-4.608-4.266667-6.792533-0.4096-0.6144-1.058133-0.887467-1.501867-1.4336a461.482667 461.482667 0 0 0-90.385066-96.768c-13.5168-10.786133-27.7504-20.48-42.257067-29.5936-0.477867-0.341333-0.7168-0.8192-1.194667-1.1264-3.6864-2.286933-7.509333-4.3008-11.264-6.485334-4.266667-2.491733-8.4992-5.051733-12.868266-7.441066-6.826667-3.6864-13.789867-7.099733-20.753067-10.478934-3.618133-1.7408-7.202133-3.618133-10.8544-5.290666a449.194667 449.194667 0 0 0-31.607467-12.731734c-0.7168-0.273067-1.365333-0.6144-2.082133-0.8192-3.140267-1.1264-6.417067-1.911467-9.557333-2.935466-4.164267-1.399467-8.328533-2.833067-12.561067-4.096a259.9936 259.9936 0 0 0 129.194667-225.450667 260.061867 260.061867 0 0 0-76.629334-185.002667 259.9936 259.9936 0 0 0-185.002666-76.629333H512h-0.034133a259.857067 259.857067 0 0 0-185.002667 76.629333 259.925333 259.925333 0 0 0-76.629333 185.002667 259.584 259.584 0 0 0 76.629333 185.002667c15.906133 15.940267 33.655467 29.2864 52.565333 40.448-4.266667 1.262933-8.430933 2.730667-12.663466 4.096-3.140267 1.058133-6.3488 1.8432-9.489067 2.935466-0.7168 0.238933-1.365333 0.580267-2.048 0.8192-10.683733 3.822933-21.265067 8.0896-31.675733 12.765867-3.584 1.604267-7.0656 3.4816-10.615467 5.154133-7.099733 3.413333-14.165333 6.826667-21.0944 10.615467-4.266667 2.321067-8.3968 4.8128-12.561067 7.2704-3.822933 2.218667-7.748267 4.266667-11.502933 6.621867-0.512 0.3072-0.750933 0.8192-1.2288 1.160533-14.506667 9.147733-28.706133 18.807467-42.222933 29.559467a459.6736 459.6736 0 0 0-90.385067 96.768c-0.443733 0.546133-1.092267 0.8192-1.501867 1.4336-1.536 2.184533-2.7648 4.573867-4.266666 6.792533-1.604267 2.423467-3.447467 4.744533-5.0176 7.202133-2.56 3.9936-4.7104 8.157867-7.133867 12.219734-3.106133 5.188267-6.280533 10.376533-9.181867 15.701333-3.7888 6.929067-7.202133 13.994667-10.6496 21.0944-2.4576 5.12-5.051733 10.205867-7.338666 15.394133-3.515733 8.021333-6.519467 16.247467-9.557334 24.4736-1.672533 4.5056-3.549867 8.9088-5.051733 13.448534-4.3008 12.868267-8.0896 25.941333-11.264 39.185066-3.072 12.970667 2.594133 25.770667 13.073067 32.802134a31.3344 31.3344 0 0 0 9.966933 4.608 30.9248 30.9248 0 0 0 34.030933-15.2576 30.446933 30.446933 0 0 0 3.345067-7.7824c2.833067-11.844267 6.178133-23.483733 10.0352-34.9184 0.6144-1.8432 1.399467-3.549867 2.013867-5.358934 3.447467-9.762133 7.133867-19.456 11.332266-28.945066 0.512-1.160533 1.1264-2.2528 1.6384-3.447467 4.7104-10.308267 9.728-20.48 15.291734-30.344533l0.068266-0.1024a402.773333 402.773333 0 0 1 19.694934-31.4368l0.136533-0.375467a397.4144 397.4144 0 0 1 116.599467-111.2064c0.136533-0.1024 0.3072-0.068267 0.443733-0.170667a397.824 397.824 0 0 1 94.993067-42.973866c2.7648-0.8192 5.495467-1.7408 8.2944-2.491734 5.7344-1.604267 11.5712-3.003733 17.373866-4.334933a367.8208 367.8208 0 0 1 47.342934-7.953067c3.8912-0.443733 7.7824-0.9216 11.6736-1.2288 10.410667-0.785067 20.8896-1.3312 31.505066-1.3312s21.060267 0.546133 31.505067 1.3312c3.8912 0.3072 7.816533 0.785067 11.707733 1.2288a361.3696 361.3696 0 0 1 47.240534 7.953067c5.870933 1.3312 11.707733 2.730667 17.5104 4.334933 2.696533 0.750933 5.358933 1.6384 8.021333 2.4576 33.348267 10.103467 65.365333 24.405333 95.197867 43.008 0.136533 0.1024 0.3072 0.068267 0.443733 0.170667a396.151467 396.151467 0 0 1 116.599467 111.2064c0.1024 0.136533 0.1024 0.273067 0.170666 0.375467 13.687467 19.7632 25.3952 40.5504 35.191467 62.1568l1.467733 3.037866c4.3008 9.659733 8.055467 19.592533 11.605334 29.5936 0.546133 1.604267 1.2288 3.106133 1.774933 4.7104 3.822933 11.4688 7.236267 23.176533 10.0352 35.0208a31.061333 31.061333 0 0 0 60.450133-14.336zm-249.275733-560.2304A199.850667 199.850667 0 0 1 512 543.197867a199.850667 199.850667 0 0 1-199.5776-199.611734A199.816533 199.816533 0 0 1 512 144.008533a199.816533 199.816533 0 0 1 199.5776 199.5776z" fill="#FFFFFF"/&gt;&lt;/svg&gt;</value>
</data>
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<data name="$this.Icon" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>

View File

@ -1,12 +1,16 @@
using AntdUI;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DHSoftware.Models
{
public class DataModel
{
}
public class DefectRow : NotifyProperty
public class DefectRow:NotifyProperty
{
private bool selected = false;
public string LabelId { get; set; }
@ -31,4 +35,4 @@ namespace DHSoftware.Models
}
}
}
}
}

View File

@ -1,4 +1,6 @@
namespace AntdUIDemo.Models
using System.Collections.Generic;
namespace AntdUIDemo.Models
{
public class DataUtil
{
@ -218,5 +220,9 @@
{ "Chat", "MessageOutlined" },
{ "Other", "SettingOutlined" }
};
}
}
}

View File

@ -1,63 +0,0 @@
using SqlSugar;
namespace DHSoftware.Models
{
[SugarTable("User")]
public class User
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
[SugarColumn(Length = 50, IsNullable = false)]
public string UserName { get; set; }
[SugarColumn(Length = 100, IsNullable = false)]
public string Password { get; set; }
[SugarColumn(IsNullable = true)]
public DateTime? LastLoginTime { get; set; }
}
[SugarTable("Role")]
public class Role
{
[SugarColumn(IsPrimaryKey = true, IsIdentity = true)]
public int Id { get; set; }
[SugarColumn(Length = 50, IsNullable = false)]
public string RoleName { get; set; }
[SugarColumn(Length = 200)]
public string Description { get; set; }
}
[SugarTable("Permission")]
public class Permission
{
[SugarColumn(IsPrimaryKey = true, Length = 50)]
public string Code { get; set; }
[SugarColumn(Length = 100, IsNullable = false)]
public string Name { get; set; }
}
[SugarTable("UserRole")]
public class UserRole
{
[SugarColumn(IsPrimaryKey = true)]
public int UserId { get; set; }
[SugarColumn(IsPrimaryKey = true)]
public int RoleId { get; set; }
}
[SugarTable("RolePermission")]
public class RolePermission
{
[SugarColumn(IsPrimaryKey = true)]
public int RoleId { get; set; }
[SugarColumn(IsPrimaryKey = true)]
public string PermissionCode { get; set; }
}
}

View File

@ -1,9 +1,20 @@
namespace DHSoftware.Models
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DHSoftware.Models
{
public class Camera
{
public string DeviceName { get; set; }
public string Alias { get; set; }
public string ImagePath { get; set; }
}
}
}

View File

@ -6,4 +6,4 @@
public string Text { get; set; } = string.Empty;
public string Tag { get; set; } = null;
}
}
}

166
DHSoftware/Models/User.cs Normal file
View File

@ -0,0 +1,166 @@
using AntdUI;
namespace AntdUIDemo.Models
{
public class User : NotifyProperty
{
private bool selected = false;
private string name;
private int age = 0;
private string address;
private bool enabled = false;
private CellImage[] cellImages;
private CellTag[] cellTags;
private CellBadge cellBadge;
private CellText cellText;
private CellLink[] cellLinks;
private CellProgress cellProgress;
private CellDivider cellDivider;
//用于设置树形表格,加入自身数组
private User[] users;
public bool Selected
{
get { return selected; }
set
{
if (selected == value) return;
selected = value;
OnPropertyChanged(nameof(Selected));
}
}
public string Name
{
get { return name; }
set
{
if (name == value) return;
name = value;
OnPropertyChanged(nameof(Name));
}
}
public int Age
{
get { return age; }
set
{
if (age == value) return;
age = value;
OnPropertyChanged(nameof(Age));
}
}
public string Address
{
get { return address; }
set
{
if (address == value) return;
address = value;
OnPropertyChanged(nameof(Address));
}
}
public bool Enabled
{
get { return enabled; }
set
{
if (enabled == value) return;
enabled = value;
OnPropertyChanged(nameof(Enabled));
}
}
public CellImage[] CellImages
{
get { return cellImages; }
set
{
if (cellImages == value) return;
cellImages = value;
OnPropertyChanged(nameof(CellImages));
}
}
public CellTag[] CellTags
{
get { return cellTags; }
set
{
if (cellTags == value) return;
cellTags = value;
OnPropertyChanged(nameof(CellTags));
}
}
public CellBadge CellBadge
{
get { return cellBadge; }
set
{
if (cellBadge == value) return;
cellBadge = value;
OnPropertyChanged(nameof(CellBadge));
}
}
public CellText CellText
{
get { return cellText; }
set
{
if (cellText == value) return;
cellText = value;
OnPropertyChanged(nameof(CellText));
}
}
public CellLink[] CellLinks
{
get { return cellLinks; }
set
{
if (cellLinks == value) return;
cellLinks = value;
OnPropertyChanged(nameof(CellLinks));
}
}
public CellProgress CellProgress
{
get { return cellProgress; }
set
{
if (cellProgress == value) return;
cellProgress = value;
OnPropertyChanged(nameof(CellProgress));
}
}
public CellDivider CellDivider
{
get { return cellDivider; }
set
{
if (cellDivider == value) return;
cellDivider = value;
OnPropertyChanged(nameof(CellDivider));
}
}
public User[] Users
{
get { return users; }
set
{
if (users == value) return;
users = value;
OnPropertyChanged(nameof(Users));
}
}
}
}

View File

@ -1,13 +1,7 @@
using System;
using System.Drawing;
using System.Windows.Forms;
using AntdUI;
using DH.Commons.Enums;
using DH.Commons.Helper;
using DH.Commons.Models;
using DHSoftware.Utils;
using DHSoftware.Views;
using Microsoft.VisualBasic.Logging;
namespace DHSoftware
{
@ -15,84 +9,23 @@ namespace DHSoftware
{
private static MainWindow mainWindow;
/// <summary>
/// 应用程序的主入口点
/// 应用程序的主入口点
/// </summary>
[STAThread]
static void Main()
{
// 必须在第一个窗口创建前调用以下两行
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
// 注册全局异常处理
Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
// 初始化AntdUI配置
AntdUI.Localization.DefaultLanguage = "zh-CN";
//若文字不清晰,切换其他渲染方式
AntdUI.Config.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAliasGridFit;
AntdUI.Config.SetCorrectionTextRendering("Microsoft YaHei UI");
AntdUI.Style.Set(AntdUI.Colour.Primary, Color.FromArgb(46, 108, 227));
// 现在再创建窗口
WelcomeWindow.Instance.Show();
UpdateStep(0, "正在初始化", true);
UpdateStep(10, "正在加载数据库", true);
try
{
DatabaseUtil.InitializeDatabase();
}
catch (Exception ex)
{
SystemModel.CurrentStatus = EnumStatus.;
Modal.open(WelcomeWindow.Instance, "错误!", ex.ToString(), TType.Error);
}
UpdateStep(30, "正在加载解决方案", true);
try
{
MainWindow.Instance.LoadScheme();
}
catch (Exception ex)
{
SystemModel.CurrentStatus = EnumStatus.;
Modal.open(WelcomeWindow.Instance, "错误!", ex.ToString(), TType.Error);
}
UpdateStep(50, "正在连接相机", true);
try
{
MainWindow.Instance.ConnectCamera();
}
catch(Exception ex)
{
SystemModel.CurrentStatus = EnumStatus.;
Modal.open(WelcomeWindow.Instance, "错误!", ex.ToString(), TType.Error);
}
UpdateStep(70, "正在连接PLC", true);
try
{
MainWindow.Instance.ConnectPLC();
}
catch (Exception ex)
{
SystemModel.CurrentStatus = EnumStatus.;
Modal.open(WelcomeWindow.Instance, "错误!", ex.ToString(), TType.Error);
}
UpdateStep(80, "正在加载算法模型", true);
try
{
MainWindow.Instance.InitModel();
}
catch (Exception ex)
{
SystemModel.CurrentStatus = EnumStatus.;
Modal.open(WelcomeWindow.Instance, "错误!", ex.ToString(), TType.Error);
}
UpdateStep(100, "程序初始化完成", true);
Thread.Sleep(100);
WelcomeWindow.Instance.Close();
// 启动主窗口
Application.Run(MainWindow.Instance);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
mainWindow = new MainWindow();
Application.Run(mainWindow);
}
// 捕获UI线程中的未处理异常
@ -106,22 +39,5 @@ namespace DHSoftware
{
AntdUI.Notification.error(mainWindow, "未处理的非UI线程异常", e.ToString(), autoClose: 3, align: AntdUI.TAlignFrom.TR);
}
//更新进度
internal static void UpdateStep(int percentValue, string stepMsg, bool succeed)
{
try
{
WelcomeWindow.Instance.bar_step.Value = percentValue;
WelcomeWindow.Instance.lbl_step.Text = stepMsg + "......";
Thread.Sleep(200);
Application.DoEvents();
}
catch (Exception ex)
{
}
}
}
}

View File

@ -1,10 +1,10 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成
// 此代码由工具生成
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失
// 重新生成代码,这些更改将会丢失
// </auto-generated>
//------------------------------------------------------------------------------
@ -13,12 +13,12 @@ namespace DHSoftware.Properties {
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等
/// 一个强类型的资源类,用于查找本地化的字符串等
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目
// (以 /str 作为命令选项),或重新生成 VS 项目
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
@ -33,7 +33,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例
/// 返回此类使用的缓存的 ResourceManager 实例
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
@ -48,7 +48,7 @@ namespace DHSoftware.Properties {
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写
/// 使用此强类型资源类的所有资源查找执行重写
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
@ -61,7 +61,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap bg1 {
get {
@ -71,7 +71,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap bg2 {
get {
@ -81,7 +81,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap bg3 {
get {
@ -91,7 +91,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap head {
get {
@ -101,7 +101,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap head2 {
get {
@ -111,7 +111,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap logo {
get {
@ -121,7 +121,7 @@ namespace DHSoftware.Properties {
}
/// <summary>
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// 查找 System.Drawing.Bitmap 类型的本地化资源
/// </summary>
internal static System.Drawing.Bitmap {
get {

View File

@ -117,4 +117,26 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<assembly alias="System.Windows.Forms" name="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<data name="bg1" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bg1.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="bg2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bg2.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="bg3" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\bg3.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="head" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\head.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="head2" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\head2.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="logo" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\assets\logo.jpg;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="关闭" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\关闭.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -1,64 +0,0 @@
using DHSoftware.Models;
using DHSoftware.Utils;
using SqlSugar;
namespace DHSoftware.Services
{
public static class AuthService
{
public static User CurrentUser { get; private set; }
public static bool Login(string username, string password)
{
using (var db = DatabaseUtil.GetDatabase())
{
var user = db.Queryable<User>()
.First(u => u.UserName == username);
if (user != null && HashHelper.MD5Encrypt(password).Equals(user.Password))
{
CurrentUser = user;
UpdateLastLoginTime(db, user.Id);
return true;
}
return false;
}
}
public static bool HasPermission(string permissionCode)
{
if (CurrentUser == null) return false;
using (var db = DatabaseUtil.GetDatabase())
{
return db.Queryable<UserRole>()
.InnerJoin<RolePermission>((ur, rp) => ur.RoleId == rp.RoleId)
.Where((ur, rp) => ur.UserId == CurrentUser.Id)
.Where((ur, rp) => rp.PermissionCode == permissionCode)
.Any();
}
}
public static List<string> GetUserPermissions()
{
if (CurrentUser == null) return new List<string>();
using (var db = DatabaseUtil.GetDatabase())
{
return db.Queryable<UserRole>()
.InnerJoin<RolePermission>((ur, rp) => ur.RoleId == rp.RoleId)
.Where((ur, rp) => ur.UserId == CurrentUser.Id)
.Select((ur, rp) => rp.PermissionCode)
.ToList();
}
}
private static void UpdateLastLoginTime(SqlSugarClient db, int userId)
{
db.Updateable<User>()
.SetColumns(u => u.LastLoginTime == DateTime.Now)
.Where(u => u.Id == userId)
.ExecuteCommand();
}
}
}

View File

@ -1,9 +1,18 @@
namespace DHSoftware.Utils
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AntdUI;
namespace DHSoftware.Utils
{
public static class AdaptiveHelper
{
#region
public static void setTag(Control cons)
{
foreach (Control con in cons.Controls)
@ -26,13 +35,15 @@
con.Height = Convert.ToInt32(Convert.ToSingle(mytag[1]) * newy); //高度
con.Left = Convert.ToInt32(Convert.ToSingle(mytag[2]) * newx); //左边距
con.Top = Convert.ToInt32(Convert.ToSingle(mytag[3]) * newy); //顶边距
var currentSize = Convert.ToSingle(mytag[4]) * newy; //字体大小
var currentSize = Convert.ToSingle(mytag[4]) * newy; //字体大小
if (currentSize > 0) con.Font = new Font(con.Font.Name, currentSize, con.Font.Style, con.Font.Unit);
con.Focus();
if (con.Controls.Count > 0) setControls(newx, newy, con);
}
}
#endregion
#endregion
}
}
}

View File

@ -0,0 +1,155 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.Json;
using System.Windows.Forms;
using DH.Commons.Enums;
using DH.Devices.Devices;
using DH.Devices.PLC;
namespace DH.Commons.Helper
{
// 配置数据模型
public class AppConfig
{
public List<CameraBase> Cameras { get; set; } = new List<CameraBase>();
public List<PLCBase> PLCs { get; set; } = new List<PLCBase>();
public List<DetectionConfig> Detections { get; set; } = new List<DetectionConfig>();
}
// 配置管理工具类
public static class ConfigManager
{
private static readonly JsonSerializerOptions _jsonOptions = new JsonSerializerOptions
{
WriteIndented = true,
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
IgnoreNullValues = true
};
// 默认路径配置
private static readonly string DefaultConfigDir = Path.Combine(
Application.StartupPath,
"configs"
);
public static readonly string DefaultConfigPath = Path.Combine(
DefaultConfigDir,
"appsettings.json"
);
/// <summary>
/// 保存配置文件(自动处理目录和备份)
/// </summary>
/// <param name="config">配置对象</param>
/// <param name="filePath">可选文件路径</param>
public static void SaveConfig(AppConfig config, string filePath = null)
{
try
{
// 使用默认路径如果未指定
filePath ??= DefaultConfigPath;
// 确保配置目录存在
var configDir = Path.GetDirectoryName(filePath);
if (!Directory.Exists(configDir))
{
Directory.CreateDirectory(configDir);
}
// 备份已有配置
if (File.Exists(filePath))
{
BackupConfig(filePath);
}
// 序列化并保存
string json = JsonSerializer.Serialize(config, _jsonOptions);
File.WriteAllText(filePath, json);
}
catch (Exception ex)
{
throw new InvalidOperationException("配置保存失败", ex);
}
}
/// <summary>
/// 加载配置文件
/// </summary>
/// <param name="filePath">可选文件路径</param>
/// <returns>配置对象</returns>
public static AppConfig LoadConfig(string filePath = null)
{
try
{
filePath ??= DefaultConfigPath;
if (!File.Exists(filePath))
{
return new AppConfig(); // 返回空配置而不是null
}
string json = File.ReadAllText(filePath);
return JsonSerializer.Deserialize<AppConfig>(json, _jsonOptions);
}
catch (Exception ex)
{
throw new InvalidOperationException("配置加载失败", ex);
}
}
/// <summary>
/// 创建带时间戳的备份文件
/// </summary>
private static void BackupConfig(string originalPath)
{
try
{
// 创建备份目录
var backupDir = Path.Combine(
Path.GetDirectoryName(originalPath),
"backups"
);
if (!Directory.Exists(backupDir))
{
Directory.CreateDirectory(backupDir);
}
// 生成带时间戳的文件名
string timestamp = DateTime.Now.ToString("yyyyMMdd_HHmmss");
string fileName = $"{Path.GetFileNameWithoutExtension(originalPath)}_" +
$"{timestamp}" +
$"{Path.GetExtension(originalPath)}";
// 执行备份
File.Copy(
originalPath,
Path.Combine(backupDir, fileName),
overwrite: true
);
}
catch (Exception ex)
{
throw new InvalidOperationException("配置备份失败", ex);
}
}
/// <summary>
/// 创建新的配置对象
/// </summary>
public static AppConfig CreateConfig(
List<CameraBase> cameras = null,
List<PLCBase> plcs = null,
List<DetectionConfig> detections = null)
{
return new AppConfig
{
Cameras = cameras ?? new List<CameraBase>(),
PLCs = plcs ?? new List<PLCBase>(),
Detections = detections ?? new List<DetectionConfig>()
};
}
}
}

View File

@ -1,151 +0,0 @@
using DHSoftware.Models;
using SqlSugar;
namespace DHSoftware.Utils
{
public static class DatabaseUtil
{
private static readonly string DatabasePath = Path.Combine(
Application.StartupPath,
"db",
"RBACSystem.sqlite"
);
public static void InitializeDatabase()
{
EnsureDirectoryExists();
using (var db = GetDatabase())
{
// 检查初始化状态(通过检查是否存在系统表)
bool isInitialized = db.DbMaintenance.IsAnyTable("RolePermission");
if (!isInitialized)
{
// 创建所有表
db.CodeFirst.InitTables(
typeof(User),
typeof(Role),
typeof(Permission),
typeof(UserRole),
typeof(RolePermission)
);
// 初始化基础数据
InitializeSeedData(db);
}
}
}
public static SqlSugarClient GetDatabase()
{
return new SqlSugarClient(new ConnectionConfig()
{
ConnectionString = $"Data Source={DatabasePath};",
DbType = DbType.Sqlite,
IsAutoCloseConnection = true,
InitKeyType = InitKeyType.Attribute
});
}
private static void EnsureDirectoryExists()
{
var directory = Path.GetDirectoryName(DatabasePath);
if (!Directory.Exists(directory))
{
Directory.CreateDirectory(directory);
}
}
private static void InitializeSeedData(SqlSugarClient db)
{
// 初始化角色
var adminRole = GetOrCreateRole(db, "admin", "系统管理员");
var userRole = GetOrCreateRole(db, "user", "普通用户");
// 初始化权限
var permissions = new List<Permission>
{
new Permission { Code = "system:access", Name = "访问系统" },
new Permission { Code = "user:view", Name = "查看用户" },
new Permission { Code = "user:edit", Name = "管理用户" },
new Permission { Code = "role:manage", Name = "角色管理" },
new Permission { Code = "system:config", Name = "配置权限" },
new Permission { Code = "system:loadscheme", Name = "加载方案" },
new Permission { Code = "system:addscheme", Name = "新增方案" },
new Permission { Code = "system:deletescheme", Name = "删除方案" }
};
InitializePermissions(db, permissions);
// 分配权限给管理员角色
AssignPermissionsToRole(db, adminRole.Id, permissions.Select(p => p.Code).ToList());
// 创建默认管理员
CreateAdminUser(db);
}
private static Role GetOrCreateRole(SqlSugarClient db, string roleName, string description)
{
var role = db.Queryable<Role>()
.First(r => r.RoleName == roleName);
if (role == null)
{
role = new Role
{
RoleName = roleName,
Description = description
};
role.Id = db.Insertable(role).ExecuteReturnIdentity();
}
return role;
}
private static void InitializePermissions(SqlSugarClient db, List<Permission> permissions)
{
foreach (var p in permissions)
{
if (!db.Queryable<Permission>().Any(x => x.Code == p.Code))
{
db.Insertable(p).ExecuteCommand();
}
}
}
private static void AssignPermissionsToRole(SqlSugarClient db, int roleId, List<string> permissionCodes)
{
var existing = db.Queryable<RolePermission>()
.Where(rp => rp.RoleId == roleId)
.Select(rp => rp.PermissionCode)
.ToList();
foreach (var code in permissionCodes.Except(existing))
{
db.Insertable(new RolePermission
{
RoleId = roleId,
PermissionCode = code
}).ExecuteCommand();
}
}
private static void CreateAdminUser(SqlSugarClient db)
{
if (!db.Queryable<User>().Any(u => u.UserName == "admin"))
{
var admin = new User
{
UserName = "admin",
Password = HashHelper.MD5Encrypt("admin123"),
LastLoginTime = null
};
admin.Id = db.Insertable(admin).ExecuteReturnIdentity();
db.Insertable(new UserRole
{
UserId = admin.Id,
RoleId = db.Queryable<Role>().First(r => r.RoleName == "admin").Id
}).ExecuteCommand();
}
}
}
}

View File

@ -1,19 +0,0 @@
using System.Security.Cryptography;
using System.Text;
namespace DHSoftware.Utils
{
// 密码加密辅助类
public static class HashHelper
{
public static string MD5Encrypt(string input)
{
using (var md5 = MD5.Create())
{
byte[] inputBytes = Encoding.UTF8.GetBytes(input);
byte[] hashBytes = md5.ComputeHash(inputBytes);
return BitConverter.ToString(hashBytes).Replace("-", "");
}
}
}
}

View File

@ -1,4 +1,5 @@
using Microsoft.Win32;
using System.Drawing;
namespace DHSoftware.Utils
{
@ -44,4 +45,4 @@ namespace DHSoftware.Utils
}
}
}
}
}

View File

@ -29,7 +29,6 @@
private void InitializeComponent()
{
panel1 = new AntdUI.Panel();
lbTitleName = new AntdUI.Label();
input_name = new AntdUI.Input();
label3 = new AntdUI.Label();
divider1 = new AntdUI.Divider();
@ -37,6 +36,7 @@
button_cancel = new AntdUI.Button();
button_ok = new AntdUI.Button();
divider2 = new AntdUI.Divider();
label1 = new AntdUI.Label();
panel1.SuspendLayout();
stackPanel1.SuspendLayout();
SuspendLayout();
@ -48,7 +48,7 @@
panel1.Controls.Add(divider1);
panel1.Controls.Add(stackPanel1);
panel1.Controls.Add(divider2);
panel1.Controls.Add(lbTitleName);
panel1.Controls.Add(label1);
panel1.Dock = DockStyle.Fill;
panel1.Location = new Point(0, 0);
panel1.Name = "panel1";
@ -58,16 +58,6 @@
panel1.TabIndex = 0;
panel1.Text = "panel1";
//
// lbTitleName
//
lbTitleName.Dock = DockStyle.Top;
lbTitleName.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
lbTitleName.Location = new Point(18, 18);
lbTitleName.Name = "lbTitleName";
lbTitleName.Size = new Size(464, 24);
lbTitleName.TabIndex = 23;
lbTitleName.Text = "新增相机操作";
//
// input_name
//
input_name.Dock = DockStyle.Top;
@ -76,7 +66,7 @@
input_name.Name = "input_name";
input_name.Radius = 3;
input_name.Size = new Size(464, 38);
input_name.TabIndex = 28;
input_name.TabIndex = 22;
//
// label3
//
@ -85,7 +75,7 @@
label3.Location = new Point(18, 110);
label3.Name = "label3";
label3.Size = new Size(464, 24);
label3.TabIndex = 27;
label3.TabIndex = 21;
label3.Text = "相机名称";
//
// divider1
@ -94,7 +84,7 @@
divider1.Location = new Point(18, 98);
divider1.Name = "divider1";
divider1.Size = new Size(464, 12);
divider1.TabIndex = 26;
divider1.TabIndex = 20;
//
// stackPanel1
//
@ -105,7 +95,7 @@
stackPanel1.Name = "stackPanel1";
stackPanel1.RightToLeft = RightToLeft.No;
stackPanel1.Size = new Size(464, 44);
stackPanel1.TabIndex = 25;
stackPanel1.TabIndex = 19;
stackPanel1.Text = "stackPanel1";
//
// button_cancel
@ -128,7 +118,6 @@
button_ok.TabIndex = 0;
button_ok.Text = "确定";
button_ok.Type = AntdUI.TTypeMini.Primary;
//
// divider2
//
@ -136,7 +125,17 @@
divider2.Location = new Point(18, 42);
divider2.Name = "divider2";
divider2.Size = new Size(464, 12);
divider2.TabIndex = 24;
divider2.TabIndex = 18;
//
// label1
//
label1.Dock = DockStyle.Top;
label1.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label1.Location = new Point(18, 18);
label1.Name = "label1";
label1.Size = new Size(464, 24);
label1.TabIndex = 17;
label1.Text = "新增相机操作";
//
// AddCameraControl
//
@ -151,6 +150,7 @@
#endregion
private AntdUI.Panel panel1;
private AntdUI.Label label1;
private AntdUI.Input input_name;
private AntdUI.Label label3;
private AntdUI.Divider divider1;
@ -158,6 +158,5 @@
private AntdUI.Button button_cancel;
private AntdUI.Button button_ok;
private AntdUI.Divider divider2;
private AntdUI.Label lbTitleName;
}
}

View File

@ -7,12 +7,10 @@ namespace DHSoftware.Views
private AntdUI.Window window;
public bool submit;
public string CubicleName;
public AddCameraControl(AntdUI.Window _window, string TitleName)
public AddCameraControl(AntdUI.Window _window)
{
this.window = _window;
InitializeComponent();
lbTitleName.Text = TitleName;
// 绑定事件
BindEventHandler();
}

View File

@ -36,7 +36,7 @@
button_cancel = new AntdUI.Button();
button_ok = new AntdUI.Button();
divider2 = new AntdUI.Divider();
lbTitleName = new AntdUI.Label();
label1 = new AntdUI.Label();
panel1.SuspendLayout();
stackPanel1.SuspendLayout();
SuspendLayout();
@ -48,7 +48,7 @@
panel1.Controls.Add(divider1);
panel1.Controls.Add(stackPanel1);
panel1.Controls.Add(divider2);
panel1.Controls.Add(lbTitleName);
panel1.Controls.Add(label1);
panel1.Dock = DockStyle.Fill;
panel1.Location = new Point(0, 0);
panel1.Name = "panel1";
@ -127,15 +127,15 @@
divider2.Size = new Size(464, 12);
divider2.TabIndex = 18;
//
// lbTitleName
// label1
//
lbTitleName.Dock = DockStyle.Top;
lbTitleName.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
lbTitleName.Location = new Point(18, 18);
lbTitleName.Name = "lbTitleName";
lbTitleName.Size = new Size(464, 24);
lbTitleName.TabIndex = 17;
lbTitleName.Text = "新增工位操作";
label1.Dock = DockStyle.Top;
label1.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label1.Location = new Point(18, 18);
label1.Name = "label1";
label1.Size = new Size(464, 24);
label1.TabIndex = 17;
label1.Text = "新增工位操作";
//
// AddCubicleControl
//
@ -150,7 +150,7 @@
#endregion
private AntdUI.Panel panel1;
private AntdUI.Label lbTitleName;
private AntdUI.Label label1;
private AntdUI.Input input_name;
private AntdUI.Label label3;
private AntdUI.Divider divider1;

View File

@ -7,11 +7,10 @@ namespace DHSoftware.Views
private AntdUI.Window window;
public bool submit;
public string CubicleName;
public AddCubicleControl(AntdUI.Window _window,string TitleName)
public AddCubicleControl(AntdUI.Window _window)
{
this.window = _window;
InitializeComponent();
lbTitleName.Text = TitleName;
// 绑定事件
BindEventHandler();
}

View File

@ -1,162 +0,0 @@
namespace DHSoftware.Views
{
partial class AddGlobalControl
{
/// <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()
{
panel1 = new AntdUI.Panel();
input_name = new AntdUI.Input();
label3 = new AntdUI.Label();
divider1 = new AntdUI.Divider();
stackPanel1 = new AntdUI.StackPanel();
button_cancel = new AntdUI.Button();
button_ok = new AntdUI.Button();
divider2 = new AntdUI.Divider();
lbTitleName = new AntdUI.Label();
panel1.SuspendLayout();
stackPanel1.SuspendLayout();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(input_name);
panel1.Controls.Add(label3);
panel1.Controls.Add(divider1);
panel1.Controls.Add(stackPanel1);
panel1.Controls.Add(divider2);
panel1.Controls.Add(lbTitleName);
panel1.Dock = DockStyle.Fill;
panel1.Location = new Point(0, 0);
panel1.Name = "panel1";
panel1.Padding = new Padding(12);
panel1.Shadow = 6;
panel1.Size = new Size(500, 192);
panel1.TabIndex = 0;
panel1.Text = "panel1";
//
// input_name
//
input_name.Dock = DockStyle.Top;
input_name.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
input_name.Location = new Point(18, 134);
input_name.Name = "input_name";
input_name.Radius = 3;
input_name.Size = new Size(464, 38);
input_name.TabIndex = 22;
//
// label3
//
label3.Dock = DockStyle.Top;
label3.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label3.Location = new Point(18, 110);
label3.Name = "label3";
label3.Size = new Size(464, 24);
label3.TabIndex = 21;
label3.Text = "全局配置名称";
//
// divider1
//
divider1.Dock = DockStyle.Top;
divider1.Location = new Point(18, 98);
divider1.Name = "divider1";
divider1.Size = new Size(464, 12);
divider1.TabIndex = 20;
//
// stackPanel1
//
stackPanel1.Controls.Add(button_cancel);
stackPanel1.Controls.Add(button_ok);
stackPanel1.Dock = DockStyle.Top;
stackPanel1.Location = new Point(18, 54);
stackPanel1.Name = "stackPanel1";
stackPanel1.RightToLeft = RightToLeft.No;
stackPanel1.Size = new Size(464, 44);
stackPanel1.TabIndex = 19;
stackPanel1.Text = "stackPanel1";
//
// button_cancel
//
button_cancel.BorderWidth = 1F;
button_cancel.Font = new Font("Microsoft YaHei UI", 9F);
button_cancel.Ghost = true;
button_cancel.Location = new Point(84, 3);
button_cancel.Name = "button_cancel";
button_cancel.Size = new Size(75, 38);
button_cancel.TabIndex = 1;
button_cancel.Text = "取消";
//
// button_ok
//
button_ok.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
button_ok.Location = new Point(3, 3);
button_ok.Name = "button_ok";
button_ok.Size = new Size(75, 38);
button_ok.TabIndex = 0;
button_ok.Text = "确定";
button_ok.Type = AntdUI.TTypeMini.Primary;
//
// divider2
//
divider2.Dock = DockStyle.Top;
divider2.Location = new Point(18, 42);
divider2.Name = "divider2";
divider2.Size = new Size(464, 12);
divider2.TabIndex = 18;
//
// lbTitleName
//
lbTitleName.Dock = DockStyle.Top;
lbTitleName.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
lbTitleName.Location = new Point(18, 18);
lbTitleName.Name = "lbTitleName";
lbTitleName.Size = new Size(464, 24);
lbTitleName.TabIndex = 17;
lbTitleName.Text = "新增全局配置操作";
//
// AddGlobalControl
//
Controls.Add(panel1);
Name = "AddGlobalControl";
Size = new Size(500, 192);
panel1.ResumeLayout(false);
stackPanel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private AntdUI.Panel panel1;
private AntdUI.Label lbTitleName;
private AntdUI.Input input_name;
private AntdUI.Label label3;
private AntdUI.Divider divider1;
private AntdUI.StackPanel stackPanel1;
private AntdUI.Button button_cancel;
private AntdUI.Button button_ok;
private AntdUI.Divider divider2;
}
}

View File

@ -1,48 +0,0 @@

namespace DHSoftware.Views
{
public partial class AddGlobalControl : UserControl
{
private AntdUI.Window window;
public bool submit;
public string GlobalName;
public AddGlobalControl(AntdUI.Window _window,string TitleName)
{
this.window = _window;
InitializeComponent();
lbTitleName.Text = TitleName;
// 绑定事件
BindEventHandler();
}
private void BindEventHandler()
{
button_ok.Click += Button_ok_Click;
button_cancel.Click += Button_cancel_Click;
}
private void Button_cancel_Click(object sender, EventArgs e)
{
submit = false;
this.Dispose();
}
private void Button_ok_Click(object sender, EventArgs e)
{
input_name.Status = AntdUI.TType.None;
//检查输入内容
if (String.IsNullOrEmpty(input_name.Text))
{
input_name.Status = AntdUI.TType.Error;
AntdUI.Message.warn(window, "全局配置名称名称不能为空!", autoClose: 3);
return;
}
GlobalName = input_name.Text;
submit = true;
this.Dispose();
}
}
}

View File

@ -36,25 +36,31 @@
button_cancel = new AntdUI.Button();
button_ok = new AntdUI.Button();
divider2 = new AntdUI.Divider();
lbTitleName = new AntdUI.Label();
label1 = new AntdUI.Label();
label2 = new AntdUI.Label();
divider3 = new AntdUI.Divider();
select_type = new AntdUI.Select();
panel1.SuspendLayout();
stackPanel1.SuspendLayout();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(select_type);
panel1.Controls.Add(label2);
panel1.Controls.Add(divider3);
panel1.Controls.Add(input_name);
panel1.Controls.Add(label3);
panel1.Controls.Add(divider1);
panel1.Controls.Add(stackPanel1);
panel1.Controls.Add(divider2);
panel1.Controls.Add(lbTitleName);
panel1.Controls.Add(label1);
panel1.Dock = DockStyle.Fill;
panel1.Location = new Point(0, 0);
panel1.Name = "panel1";
panel1.Padding = new Padding(12);
panel1.Shadow = 6;
panel1.Size = new Size(500, 192);
panel1.Size = new Size(500, 260);
panel1.TabIndex = 0;
panel1.Text = "panel1";
//
@ -118,7 +124,6 @@
button_ok.TabIndex = 0;
button_ok.Text = "确定";
button_ok.Type = AntdUI.TTypeMini.Primary;
//
// divider2
//
@ -128,21 +133,47 @@
divider2.Size = new Size(464, 12);
divider2.TabIndex = 18;
//
// lbTitleName
// label1
//
lbTitleName.Dock = DockStyle.Top;
lbTitleName.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
lbTitleName.Location = new Point(18, 18);
lbTitleName.Name = "lbTitleName";
lbTitleName.Size = new Size(464, 24);
lbTitleName.TabIndex = 17;
lbTitleName.Text = "新增运动控制操作";
label1.Dock = DockStyle.Top;
label1.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label1.Location = new Point(18, 18);
label1.Name = "label1";
label1.Size = new Size(464, 24);
label1.TabIndex = 17;
label1.Text = "新增运动控制操作";
//
// label2
//
label2.Dock = DockStyle.Top;
label2.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label2.Location = new Point(18, 184);
label2.Name = "label2";
label2.Size = new Size(464, 24);
label2.TabIndex = 24;
label2.Text = "运动控制类型";
//
// divider3
//
divider3.Dock = DockStyle.Top;
divider3.Location = new Point(18, 172);
divider3.Name = "divider3";
divider3.Size = new Size(464, 12);
divider3.TabIndex = 23;
//
// select_type
//
select_type.Dock = DockStyle.Top;
select_type.Location = new Point(18, 208);
select_type.Name = "select_type";
select_type.Size = new Size(464, 37);
select_type.TabIndex = 25;
//
// AddMotionControl
//
Controls.Add(panel1);
Name = "AddMotionControl";
Size = new Size(500, 192);
Size = new Size(500, 260);
panel1.ResumeLayout(false);
stackPanel1.ResumeLayout(false);
ResumeLayout(false);
@ -151,7 +182,7 @@
#endregion
private AntdUI.Panel panel1;
private AntdUI.Label lbTitleName;
private AntdUI.Label label1;
private AntdUI.Input input_name;
private AntdUI.Label label3;
private AntdUI.Divider divider1;
@ -159,5 +190,8 @@
private AntdUI.Button button_cancel;
private AntdUI.Button button_ok;
private AntdUI.Divider divider2;
private AntdUI.Select select_type;
private AntdUI.Label label2;
private AntdUI.Divider divider3;
}
}

View File

@ -8,11 +8,10 @@ namespace DHSoftware.Views
public bool submit;
public string MotionName;
public string MotionType;
public AddMotionControl(AntdUI.Window _window,string TitleName)
public AddMotionControl(AntdUI.Window _window)
{
this.window = _window;
InitializeComponent();
lbTitleName.Text = TitleName;
// 绑定事件
BindEventHandler();
}
@ -40,6 +39,7 @@ namespace DHSoftware.Views
return;
}
MotionName = input_name.Text;
MotionType = select_type.Text;
submit = true;
this.Dispose();
}

View File

@ -1,201 +0,0 @@
namespace DHSoftware.Views
{
partial class AddSchemeControl
{
/// <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()
{
panel1 = new AntdUI.Panel();
input_name = new AntdUI.Input();
label3 = new AntdUI.Label();
stackPanel2 = new AntdUI.StackPanel();
label1 = new AntdUI.Label();
ckNullScheme = new AntdUI.Checkbox();
divider1 = new AntdUI.Divider();
stackPanel1 = new AntdUI.StackPanel();
button_cancel = new AntdUI.Button();
button_ok = new AntdUI.Button();
divider2 = new AntdUI.Divider();
lbTitleName = new AntdUI.Label();
panel1.SuspendLayout();
stackPanel2.SuspendLayout();
stackPanel1.SuspendLayout();
SuspendLayout();
//
// panel1
//
panel1.Controls.Add(input_name);
panel1.Controls.Add(label3);
panel1.Controls.Add(stackPanel2);
panel1.Controls.Add(divider1);
panel1.Controls.Add(stackPanel1);
panel1.Controls.Add(divider2);
panel1.Controls.Add(lbTitleName);
panel1.Dock = DockStyle.Fill;
panel1.Location = new Point(0, 0);
panel1.Name = "panel1";
panel1.Padding = new Padding(12);
panel1.Shadow = 6;
panel1.Size = new Size(500, 234);
panel1.TabIndex = 0;
panel1.Text = "panel1";
//
// input_name
//
input_name.Dock = DockStyle.Top;
input_name.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
input_name.Location = new Point(18, 164);
input_name.Name = "input_name";
input_name.Radius = 3;
input_name.Size = new Size(464, 38);
input_name.TabIndex = 25;
//
// label3
//
label3.Dock = DockStyle.Top;
label3.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
label3.Location = new Point(18, 140);
label3.Name = "label3";
label3.Size = new Size(464, 24);
label3.TabIndex = 24;
label3.Text = "方案名称";
//
// stackPanel2
//
stackPanel2.Controls.Add(label1);
stackPanel2.Controls.Add(ckNullScheme);
stackPanel2.Dock = DockStyle.Top;
stackPanel2.Location = new Point(18, 110);
stackPanel2.Name = "stackPanel2";
stackPanel2.RightToLeft = RightToLeft.No;
stackPanel2.Size = new Size(464, 30);
stackPanel2.TabIndex = 23;
stackPanel2.Text = "stackPanel2";
//
// label1
//
label1.Dock = DockStyle.Fill;
label1.Location = new Point(84, 3);
label1.Name = "label1";
label1.Size = new Size(333, 24);
label1.TabIndex = 1;
label1.Text = "默认从当前方案派生,若想创建新方案选中此项";
//
// ckNullScheme
//
ckNullScheme.Dock = DockStyle.Left;
ckNullScheme.Location = new Point(3, 3);
ckNullScheme.Name = "ckNullScheme";
ckNullScheme.Size = new Size(75, 24);
ckNullScheme.TabIndex = 0;
ckNullScheme.Text = "新方案";
//
// divider1
//
divider1.Dock = DockStyle.Top;
divider1.Location = new Point(18, 98);
divider1.Name = "divider1";
divider1.Size = new Size(464, 12);
divider1.TabIndex = 20;
//
// stackPanel1
//
stackPanel1.Controls.Add(button_cancel);
stackPanel1.Controls.Add(button_ok);
stackPanel1.Dock = DockStyle.Top;
stackPanel1.Location = new Point(18, 54);
stackPanel1.Name = "stackPanel1";
stackPanel1.RightToLeft = RightToLeft.No;
stackPanel1.Size = new Size(464, 44);
stackPanel1.TabIndex = 19;
stackPanel1.Text = "stackPanel1";
//
// button_cancel
//
button_cancel.BorderWidth = 1F;
button_cancel.Font = new Font("Microsoft YaHei UI", 9F);
button_cancel.Ghost = true;
button_cancel.Location = new Point(84, 3);
button_cancel.Name = "button_cancel";
button_cancel.Size = new Size(75, 38);
button_cancel.TabIndex = 1;
button_cancel.Text = "取消";
//
// button_ok
//
button_ok.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
button_ok.Location = new Point(3, 3);
button_ok.Name = "button_ok";
button_ok.Size = new Size(75, 38);
button_ok.TabIndex = 0;
button_ok.Text = "确定";
button_ok.Type = AntdUI.TTypeMini.Primary;
//
// divider2
//
divider2.Dock = DockStyle.Top;
divider2.Location = new Point(18, 42);
divider2.Name = "divider2";
divider2.Size = new Size(464, 12);
divider2.TabIndex = 18;
//
// lbTitleName
//
lbTitleName.Dock = DockStyle.Top;
lbTitleName.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
lbTitleName.Location = new Point(18, 18);
lbTitleName.Name = "lbTitleName";
lbTitleName.Size = new Size(464, 24);
lbTitleName.TabIndex = 17;
lbTitleName.Text = "新增方案操作";
//
// AddSchemeControl
//
Controls.Add(panel1);
Name = "AddSchemeControl";
Size = new Size(500, 234);
panel1.ResumeLayout(false);
stackPanel2.ResumeLayout(false);
stackPanel1.ResumeLayout(false);
ResumeLayout(false);
}
#endregion
private AntdUI.Panel panel1;
private AntdUI.Label lbTitleName;
private AntdUI.Divider divider1;
private AntdUI.StackPanel stackPanel1;
private AntdUI.Button button_cancel;
private AntdUI.Button button_ok;
private AntdUI.Divider divider2;
private AntdUI.Input input_name;
private AntdUI.Label label3;
private AntdUI.StackPanel stackPanel2;
private AntdUI.Checkbox ckNullScheme;
private AntdUI.Label label1;
}
}

View File

@ -1,52 +0,0 @@

namespace DHSoftware.Views
{
public partial class AddSchemeControl : UserControl
{
private AntdUI.Window window;
public bool submit;
public string SchemeName;
public bool NullScheme;
public AddSchemeControl(AntdUI.Window _window,string TitleName)
{
this.window = _window;
InitializeComponent();
lbTitleName.Text = TitleName;
// 绑定事件
BindEventHandler();
}
private void BindEventHandler()
{
button_ok.Click += Button_ok_Click;
button_cancel.Click += Button_cancel_Click;
}
private void Button_cancel_Click(object sender, EventArgs e)
{
submit = false;
this.Dispose();
}
private void Button_ok_Click(object sender, EventArgs e)
{
input_name.Status = AntdUI.TType.None;
//检查输入内容
if (String.IsNullOrEmpty(input_name.Text))
{
input_name.Status = AntdUI.TType.Error;
AntdUI.Message.warn(window, "方案名称不能为空!", autoClose: 3);
return;
}
SchemeName = input_name.Text;
NullScheme = ckNullScheme.Checked;
submit = true;
this.Dispose();
}
}
}

View File

@ -4,14 +4,14 @@
{
/// <summary>
/// 必需的设计器变量
/// 必需的设计器变量
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// 清理所有正在使用的资源
/// 清理所有正在使用的资源
/// </summary>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false</param>
/// <param name="disposing">如果应释放托管资源,为 true否则为 false </param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
@ -25,7 +25,7 @@
/// <summary>
/// 设计器支持所需的方法 - 不要修改
/// 使用代码编辑器修改此方法的内容
/// 使用代码编辑器修改此方法的内容
/// </summary>
private void InitializeComponent()
{

Some files were not shown because too many files have changed in this diff Show More