提交
This commit is contained in:
parent
0dedff36fd
commit
9a5d3be528
@ -21,6 +21,7 @@
|
||||
<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>
|
||||
|
@ -4,7 +4,7 @@ using System.Drawing.Imaging;
|
||||
using AntdUI;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace DH.Devices.Devices
|
||||
namespace DH.Commons.Base
|
||||
{
|
||||
public class CameraBase : NotifyProperty
|
||||
{
|
@ -7,26 +7,13 @@ using System.Text;
|
||||
using System.Drawing.Design;
|
||||
using AntdUI;
|
||||
using static DH.Commons.Enums.EnumHelper;
|
||||
using System.Text.Json.Serialization;
|
||||
using DH.Commons.Enums;
|
||||
|
||||
|
||||
namespace DH.Commons.Enums
|
||||
namespace DH.Commons.Base
|
||||
{
|
||||
public enum MLModelType
|
||||
{
|
||||
[Description("图像分类")]
|
||||
ImageClassification = 1,
|
||||
[Description("目标检测")]
|
||||
ObjectDetection = 2,
|
||||
//[Description("图像分割")]
|
||||
//ImageSegmentation = 3
|
||||
[Description("语义分割")]
|
||||
SemanticSegmentation = 3,
|
||||
[Description("实例分割")]
|
||||
InstanceSegmentation = 4,
|
||||
[Description("目标检测GPU")]
|
||||
ObjectGPUDetection = 5
|
||||
}
|
||||
public class ModelLabel
|
||||
|
||||
public class ModelLabel
|
||||
{
|
||||
public string LabelId { get; set; }
|
||||
|
||||
@ -42,7 +29,7 @@ namespace DH.Commons.Enums
|
||||
[Description("模型识别的标签名称")]
|
||||
public string LabelName { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//[Category("模型配置")]
|
||||
@ -71,28 +58,28 @@ namespace DH.Commons.Enums
|
||||
//public int ImageResizeCount;
|
||||
public bool IsCLDetection;
|
||||
public int ProCount;
|
||||
public string in_node_name;
|
||||
public string in_node_name;
|
||||
|
||||
public string out_node_name;
|
||||
public string out_node_name;
|
||||
|
||||
public string in_lable_path;
|
||||
public string in_lable_path;
|
||||
|
||||
public int ResizeImageSize;
|
||||
public int segmentWidth;
|
||||
public int ImageWidth;
|
||||
|
||||
// public List<labelStringBase> OkClassTxtList;
|
||||
// public List<labelStringBase> OkClassTxtList;
|
||||
|
||||
|
||||
public List<ModelLabel> LabelNames;
|
||||
public List<ModelLabel> LabelNames;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
public enum ResultState
|
||||
{
|
||||
|
||||
|
||||
[Description("检测NG")]
|
||||
DetectNG = -3,
|
||||
|
||||
@ -202,7 +189,7 @@ namespace DH.Commons.Enums
|
||||
|
||||
}
|
||||
}
|
||||
public class DetectStationResult
|
||||
public class DetectStationResult
|
||||
{
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string Pid { get; set; }
|
||||
@ -219,7 +206,7 @@ namespace DH.Commons.Enums
|
||||
public string DetectName { get; set; }
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 深度学习 检测结果
|
||||
/// </summary>
|
||||
@ -280,7 +267,7 @@ namespace DH.Commons.Enums
|
||||
|
||||
return cleanedString;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
public class RelatedCamera : NotifyProperty
|
||||
{
|
||||
@ -402,7 +389,7 @@ namespace DH.Commons.Enums
|
||||
|
||||
public static double GetDistance(CustomizedPoint p1, CustomizedPoint p2)
|
||||
{
|
||||
return Math.Sqrt(Math.Pow((p1.X - p2.X), 2) + Math.Pow((p1.Y - p2.Y), 2));
|
||||
return Math.Sqrt(Math.Pow(p1.X - p2.X, 2) + Math.Pow(p1.Y - p2.Y, 2));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
@ -443,13 +430,13 @@ namespace DH.Commons.Enums
|
||||
|
||||
public int CompareTo(CustomizedPoint other)
|
||||
{
|
||||
return (X == other.X && Y == other.Y) ? 0 : 1;
|
||||
return X == other.X && Y == other.Y ? 0 : 1;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
//return (int)(X * 10 + Y);
|
||||
return (new Tuple<double, double>(X, Y)).GetHashCode();
|
||||
return new Tuple<double, double>(X, Y).GetHashCode();
|
||||
}
|
||||
|
||||
public static CustomizedPoint operator -(CustomizedPoint p1, CustomizedPoint p2)
|
||||
@ -462,193 +449,421 @@ namespace DH.Commons.Enums
|
||||
return new CustomizedPoint(p1.X + p2.X, p1.Y + p2.Y);
|
||||
}
|
||||
}
|
||||
// public class PreTreatParam
|
||||
// {
|
||||
// public class PreTreatParam
|
||||
// {
|
||||
|
||||
// /// <summary>
|
||||
// /// 参数名称
|
||||
// /// </summary>
|
||||
// ///
|
||||
// [Category("预处理参数")]
|
||||
// [DisplayName("参数名称")]
|
||||
// [Description("参数名称")]
|
||||
//#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
// public string Name { get; set; }
|
||||
// /// <summary>
|
||||
// /// 参数名称
|
||||
// /// </summary>
|
||||
// ///
|
||||
// [Category("预处理参数")]
|
||||
// [DisplayName("参数名称")]
|
||||
// [Description("参数名称")]
|
||||
//#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
// public string Name { get; set; }
|
||||
|
||||
|
||||
|
||||
// /// <summary>
|
||||
// /// 参数值
|
||||
// /// </summary>
|
||||
// ///
|
||||
// [Category("预处理参数")]
|
||||
// [DisplayName("参数值")]
|
||||
// [Description("参数值")]
|
||||
//#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
// public string Value { get; set; }
|
||||
// /// <summary>
|
||||
// /// 参数值
|
||||
// /// </summary>
|
||||
// ///
|
||||
// [Category("预处理参数")]
|
||||
// [DisplayName("参数值")]
|
||||
// [Description("参数值")]
|
||||
//#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
// public string Value { get; set; }
|
||||
|
||||
|
||||
|
||||
// }
|
||||
public class DetectionConfig
|
||||
// }
|
||||
public class DetectionConfig : NotifyProperty
|
||||
{
|
||||
[ReadOnly(true)]
|
||||
public string Id { get; set; } = Guid.NewGuid().ToString();
|
||||
#region 属性字段
|
||||
private string _id = Guid.NewGuid().ToString();
|
||||
private string _name;
|
||||
private string _cameraSourceId = "";
|
||||
private List<RelatedCamera> _cameraCollects = new List<RelatedCamera>();
|
||||
private bool _isEnableGPU;
|
||||
private bool _isMixModel;
|
||||
private bool _isPreEnabled;
|
||||
private bool _isEnabled;
|
||||
private bool _isAddStation = true;
|
||||
private string _halconAlgorithemPath_Pre;
|
||||
private AntList<PreTreatParam> _preTreatParams = new AntList<PreTreatParam>();
|
||||
private AntList<PreTreatParam> _outPreTreatParams = new AntList<PreTreatParam>();
|
||||
private ModelType _modelType = ModelType.目标检测;
|
||||
private string _modelPath;
|
||||
private int _modelWidth = 640;
|
||||
private int _modelHeight = 640;
|
||||
private string _modeloutNodeName = "output0";
|
||||
private float _modelconfThreshold = 0.5f;
|
||||
private string _in_lable_path;
|
||||
private AntList<DetectionLable> _detectionLableList = new AntList<DetectionLable>();
|
||||
private AntList<SizeTreatParam> _sizeTreatParamList = new AntList<SizeTreatParam>();
|
||||
|
||||
private CustomizedPoint _showLocation = new CustomizedPoint();
|
||||
|
||||
private bool _saveOKOriginal = false;
|
||||
private bool _saveNGOriginal = false;
|
||||
private bool _saveOKDetect = false;
|
||||
private bool _saveNGDetect = false;
|
||||
|
||||
#endregion
|
||||
|
||||
#region 属性声明
|
||||
[ReadOnly(true)]
|
||||
public string Id
|
||||
{
|
||||
get => _id;
|
||||
set
|
||||
{
|
||||
if (_id == value) return;
|
||||
_id = value;
|
||||
OnPropertyChanged(nameof(Id));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("检测配置")]
|
||||
[DisplayName("检测配置名称")]
|
||||
[Description("检测配置名称")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Category("关联相机")]
|
||||
[DisplayName("关联相机")]
|
||||
[Description("关联相机描述")]
|
||||
|
||||
|
||||
public string CameraSourceId { get; set; } = "";
|
||||
|
||||
public string Name
|
||||
{
|
||||
get => _name;
|
||||
set
|
||||
{
|
||||
if (_name == value) return;
|
||||
_name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("关联相机集合")]
|
||||
[DisplayName("关联相机集合")]
|
||||
[Description("关联相机描述")]
|
||||
//[TypeConverter(typeof(DeviceIdSelectorConverter<CameraBase>))]
|
||||
|
||||
|
||||
|
||||
public List<RelatedCamera> CameraCollects { get; set; } = new List<RelatedCamera>();
|
||||
|
||||
public List<RelatedCamera> CameraCollects
|
||||
{
|
||||
get => _cameraCollects;
|
||||
set
|
||||
{
|
||||
if (_cameraCollects == value) return;
|
||||
_cameraCollects = value;
|
||||
OnPropertyChanged(nameof(CameraCollects));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("启用配置")]
|
||||
[DisplayName("是否启用GPU检测")]
|
||||
[Description("是否启用GPU检测")]
|
||||
public bool IsEnableGPU { get; set; } = false;
|
||||
public bool IsEnableGPU
|
||||
{
|
||||
get => _isEnableGPU;
|
||||
set
|
||||
{
|
||||
if (_isEnableGPU == value) return;
|
||||
_isEnableGPU = value;
|
||||
OnPropertyChanged(nameof(IsEnableGPU));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("启用配置")]
|
||||
[DisplayName("是否混料模型")]
|
||||
[Description("是否混料模型")]
|
||||
public bool IsMixModel { get; set; } = false;
|
||||
public bool IsMixModel
|
||||
{
|
||||
get => _isMixModel;
|
||||
set
|
||||
{
|
||||
if (_isMixModel == value) return;
|
||||
_isMixModel = value;
|
||||
OnPropertyChanged(nameof(IsMixModel));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[Category("启用配置")]
|
||||
[DisplayName("是否启用预处理")]
|
||||
[Description("是否启用预处理")]
|
||||
public bool IsPreEnabled
|
||||
{
|
||||
get => _isPreEnabled;
|
||||
set
|
||||
{
|
||||
if (_isPreEnabled == value) return;
|
||||
_isPreEnabled = value;
|
||||
OnPropertyChanged(nameof(IsPreEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("启用配置")]
|
||||
[DisplayName("是否启用该检测")]
|
||||
[Description("是否启用该检测")]
|
||||
public bool IsEnabled { get; set; }
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => _isEnabled;
|
||||
set
|
||||
{
|
||||
if (_isEnabled == value) return;
|
||||
_isEnabled = value;
|
||||
OnPropertyChanged(nameof(IsEnabled));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("启用配置")]
|
||||
[DisplayName("是否加入检测工位")]
|
||||
[Description("是否加入检测工位")]
|
||||
public bool IsAddStation { get; set; } = true;
|
||||
public bool IsAddStation
|
||||
{
|
||||
get => _isAddStation;
|
||||
set
|
||||
{
|
||||
if (_isAddStation == value) return;
|
||||
_isAddStation = value;
|
||||
OnPropertyChanged(nameof(IsAddStation));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("1.预处理(视觉算子)")]
|
||||
[DisplayName("预处理-算法文件路径")]
|
||||
// [Description("预处理算法文件路径配置")][Editor(typeof(FileDialogEditor), typeof(UITypeEditor))]
|
||||
public string HalconAlgorithemPath_Pre { get; set; }
|
||||
|
||||
// [Category("1.预处理(视觉算子)")]
|
||||
//[DisplayName("预处理-输出结果的SPEC标准")]
|
||||
//[Description("预处理输出结果的SPEC标准配置")]
|
||||
|
||||
// public List<IndexedSpec> OutputSpec_Pre { get; set; } = new List<IndexedSpec>();
|
||||
public string HalconAlgorithemPath_Pre
|
||||
{
|
||||
get => _halconAlgorithemPath_Pre;
|
||||
set
|
||||
{
|
||||
if (_halconAlgorithemPath_Pre == value) return;
|
||||
_halconAlgorithemPath_Pre = value;
|
||||
OnPropertyChanged(nameof(HalconAlgorithemPath_Pre));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("1.预处理(视觉算子)")]
|
||||
[DisplayName("预处理-参数列表")]
|
||||
[Description("预处理-参数列表")]
|
||||
|
||||
public List<PreTreatParam> PreTreatParams { get; set; } = new List<PreTreatParam>();
|
||||
public AntList<PreTreatParam> PreTreatParams
|
||||
{
|
||||
get => _preTreatParams;
|
||||
set
|
||||
{
|
||||
if (_preTreatParams == value) return;
|
||||
_preTreatParams = value;
|
||||
OnPropertyChanged(nameof(PreTreatParams));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("1.预处理(视觉算子)")]
|
||||
[DisplayName("预处理-输出参数列表")]
|
||||
[Description("预处理-输出参数列表")]
|
||||
|
||||
public List<PreTreatParam> OUTPreTreatParams { get; set; } = new List<PreTreatParam>();
|
||||
public AntList<PreTreatParam> OUTPreTreatParams
|
||||
{
|
||||
get => _outPreTreatParams;
|
||||
set
|
||||
{
|
||||
if (_outPreTreatParams == value) return;
|
||||
_outPreTreatParams = value;
|
||||
OnPropertyChanged(nameof(OUTPreTreatParams));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("2.中检测(深度学习)")]
|
||||
[DisplayName("中检测-模型类型")]
|
||||
[Description("模型类型:ImageClassification-图片分类;ObjectDetection:目标检测;Segmentation-图像分割")]
|
||||
//[TypeConverter(typeof(EnumDescriptionConverter<MLModelType>))]
|
||||
public MLModelType ModelType { get; set; } = MLModelType.ObjectDetection;
|
||||
|
||||
//[Category("2.中检测(深度学习)")]
|
||||
//[DisplayName("中检测-GPU索引")]
|
||||
//[Description("GPU索引")]
|
||||
//public int GPUIndex { get; set; } = 0;
|
||||
public ModelType ModelType
|
||||
{
|
||||
get => _modelType;
|
||||
set
|
||||
{
|
||||
if (_modelType == value) return;
|
||||
_modelType = value;
|
||||
OnPropertyChanged(nameof(ModelType));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("2.中检测(深度学习)")]
|
||||
[DisplayName("中检测-模型文件路径")]
|
||||
[Description("中处理 深度学习模型文件路径,路径中不可含有中文字符,一般情况可以只配置中检测模型,当需要先用预检测过滤一次时,请先配置好与预检测相关配置")]
|
||||
|
||||
public string ModelPath { get; set; }
|
||||
[Description("中处理 深度学习模型文件路径")]
|
||||
public string ModelPath
|
||||
{
|
||||
get => _modelPath;
|
||||
set
|
||||
{
|
||||
if (_modelPath == value) return;
|
||||
_modelPath = value;
|
||||
OnPropertyChanged(nameof(ModelPath));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("2.中检测(深度学习)")]
|
||||
[DisplayName("中检测-模型宽度")]
|
||||
[Description("中处理-模型宽度")]
|
||||
|
||||
public int ModelWidth { get; set; } = 640;
|
||||
public int ModelWidth
|
||||
{
|
||||
get => _modelWidth;
|
||||
set
|
||||
{
|
||||
if (_modelWidth == value) return;
|
||||
_modelWidth = value;
|
||||
OnPropertyChanged(nameof(ModelWidth));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("2.中检测(深度学习)")]
|
||||
[DisplayName("中检测-模型高度")]
|
||||
[Description("中处理-模型高度")]
|
||||
|
||||
public int ModelHeight { get; set; } = 640;
|
||||
public int ModelHeight
|
||||
{
|
||||
get => _modelHeight;
|
||||
set
|
||||
{
|
||||
if (_modelHeight == value) return;
|
||||
_modelHeight = value;
|
||||
OnPropertyChanged(nameof(ModelHeight));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("2.中检测(深度学习)")]
|
||||
[DisplayName("中检测-模型节点名称")]
|
||||
[Description("中处理-模型节点名称")]
|
||||
|
||||
public string ModeloutNodeName { get; set; } = "output0";
|
||||
public string ModeloutNodeName
|
||||
{
|
||||
get => _modeloutNodeName;
|
||||
set
|
||||
{
|
||||
if (_modeloutNodeName == value) return;
|
||||
_modeloutNodeName = value;
|
||||
OnPropertyChanged(nameof(ModeloutNodeName));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("2.中检测(深度学习)")]
|
||||
[DisplayName("中检测-模型置信度")]
|
||||
[Description("中处理-模型置信度")]
|
||||
|
||||
public float ModelconfThreshold { get; set; } = 0.5f;
|
||||
public float ModelconfThreshold
|
||||
{
|
||||
get => _modelconfThreshold;
|
||||
set
|
||||
{
|
||||
if (_modelconfThreshold == value) return;
|
||||
_modelconfThreshold = value;
|
||||
OnPropertyChanged(nameof(ModelconfThreshold));
|
||||
}
|
||||
}
|
||||
|
||||
[Category("2.中检测(深度学习)")]
|
||||
[DisplayName("中检测-模型标签路径")]
|
||||
[Description("中处理-模型标签路径")]
|
||||
|
||||
public string in_lable_path { get; set; }
|
||||
|
||||
[Category("4.最终过滤(逻辑过滤)")]
|
||||
[DisplayName("过滤器集合")]
|
||||
[Description("最后的逻辑过滤:可根据 识别出对象的 宽度、高度、面积、得分来设置最终检测结果,同一识别目标同一判定,多项过滤器之间为“或”关系")]
|
||||
|
||||
public List<DetectionFilter> DetectionFilterList { get; set; } = new List<DetectionFilter>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 标签集合
|
||||
/// </summary>
|
||||
public List<DetectionLable> DetectionLableList { get; set; } = new List<DetectionLable>();
|
||||
//[Category("深度学习配置")]
|
||||
//[DisplayName("检测配置标签")]
|
||||
//[Description("检测配置标签关联")]
|
||||
|
||||
//public List<DetectConfigLabel> DetectConfigLabelList { get; set; } = new List<DetectConfigLabel>();
|
||||
[Category("显示配置")]
|
||||
[DisplayName("显示位置")]
|
||||
[Description("检测信息显示位置。左上角为(1,1),向右向下为正方向")]
|
||||
// [TypeConverter(typeof(ComplexObjectConvert))]
|
||||
// [Editor(typeof(PropertyObjectEditor), typeof(UITypeEditor))]
|
||||
public CustomizedPoint ShowLocation { get; set; } = new CustomizedPoint();
|
||||
|
||||
public DetectionConfig()
|
||||
public string In_lable_path
|
||||
{
|
||||
|
||||
get => _in_lable_path;
|
||||
set
|
||||
{
|
||||
if (_in_lable_path == value) return;
|
||||
_in_lable_path = value;
|
||||
OnPropertyChanged(nameof(In_lable_path));
|
||||
}
|
||||
}
|
||||
|
||||
public DetectionConfig(string name, MLModelType modelType, string modelPath, bool isEnableGPU,string sCameraSourceId)
|
||||
{
|
||||
|
||||
|
||||
[Category("显示配置")]
|
||||
[DisplayName("显示位置")]
|
||||
[Description("检测信息显示位置")]
|
||||
public CustomizedPoint ShowLocation
|
||||
{
|
||||
get => _showLocation;
|
||||
set
|
||||
{
|
||||
if (_showLocation == value) return;
|
||||
_showLocation = value;
|
||||
OnPropertyChanged(nameof(ShowLocation));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 标签集合(需确保DetectionLable也实现INotifyPropertyChanged)
|
||||
/// </summary>
|
||||
public AntList<DetectionLable> DetectionLableList
|
||||
{
|
||||
get => _detectionLableList;
|
||||
set
|
||||
{
|
||||
if (_detectionLableList == value) return;
|
||||
_detectionLableList = value;
|
||||
OnPropertyChanged(nameof(DetectionLableList));
|
||||
}
|
||||
}
|
||||
|
||||
public AntList<SizeTreatParam> SizeTreatParamList
|
||||
{
|
||||
get => _sizeTreatParamList;
|
||||
set
|
||||
{
|
||||
if (_sizeTreatParamList == value) return;
|
||||
_sizeTreatParamList = value;
|
||||
OnPropertyChanged(nameof(SizeTreatParamList));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool SaveOKOriginal
|
||||
{
|
||||
get => _saveOKOriginal;
|
||||
set
|
||||
{
|
||||
if (_saveOKOriginal == value) return;
|
||||
_saveOKOriginal = value;
|
||||
OnPropertyChanged(nameof(SaveOKOriginal));
|
||||
}
|
||||
}
|
||||
|
||||
public bool SaveNGOriginal
|
||||
{
|
||||
get => _saveNGOriginal;
|
||||
set
|
||||
{
|
||||
if (_saveNGOriginal == value) return;
|
||||
_saveNGOriginal = value;
|
||||
OnPropertyChanged(nameof(SaveNGOriginal));
|
||||
}
|
||||
}
|
||||
public bool SaveOKDetect
|
||||
{
|
||||
get => _saveOKDetect;
|
||||
set
|
||||
{
|
||||
if (_saveOKDetect == value) return;
|
||||
_saveOKDetect = value;
|
||||
OnPropertyChanged(nameof(SaveOKDetect));
|
||||
}
|
||||
}
|
||||
public bool SaveNGDetect
|
||||
{
|
||||
get => _saveNGDetect;
|
||||
set
|
||||
{
|
||||
if (_saveNGDetect == value) return;
|
||||
_saveNGDetect = value;
|
||||
OnPropertyChanged(nameof(SaveNGDetect));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 构造函数
|
||||
public DetectionConfig() { }
|
||||
|
||||
public DetectionConfig(
|
||||
string name,
|
||||
ModelType modelType,
|
||||
string modelPath,
|
||||
bool isEnableGPU,
|
||||
string sCameraSourceId)
|
||||
{
|
||||
// 通过属性赋值触发通知
|
||||
ModelPath = modelPath ?? string.Empty;
|
||||
Name = name;
|
||||
ModelType = modelType;
|
||||
IsEnableGPU = isEnableGPU;
|
||||
Id = Guid.NewGuid().ToString();
|
||||
CameraSourceId = sCameraSourceId;
|
||||
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
//大改预处理类
|
||||
@ -696,6 +911,7 @@ namespace DH.Commons.Enums
|
||||
}
|
||||
|
||||
private CellLink[] cellLinks;
|
||||
[JsonIgnore]
|
||||
public CellLink[] CellLinks
|
||||
{
|
||||
get { return cellLinks; }
|
||||
@ -724,7 +940,7 @@ namespace DH.Commons.Enums
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public bool Selected
|
||||
{
|
||||
get { return _selected; }
|
||||
@ -816,6 +1032,7 @@ namespace DH.Commons.Enums
|
||||
}
|
||||
|
||||
private CellLink[] cellLinks;
|
||||
[JsonIgnore]
|
||||
public CellLink[] CellLinks
|
||||
{
|
||||
get { return cellLinks; }
|
||||
@ -909,7 +1126,7 @@ namespace DH.Commons.Enums
|
||||
_resultShow = value;
|
||||
OnPropertyChanged(nameof(ResultShow));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public string OutResultShow
|
||||
@ -933,9 +1150,10 @@ namespace DH.Commons.Enums
|
||||
OnPropertyChanged(nameof(PrePath));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private CellLink[] cellLinks;
|
||||
[JsonIgnore]
|
||||
public CellLink[] CellLinks
|
||||
{
|
||||
get { return cellLinks; }
|
||||
@ -973,9 +1191,9 @@ namespace DH.Commons.Enums
|
||||
//[TypeConverter(typeof(LabelCategoryConverter))]
|
||||
public string LabelCategory { get; set; } = "";
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -1036,8 +1254,8 @@ namespace DH.Commons.Enums
|
||||
//public string GetLabelName()
|
||||
//{
|
||||
// var name = "";
|
||||
|
||||
|
||||
|
||||
|
||||
// var mlBase = iConfig.DeviceConfigs.FirstOrDefault(c => c is VisionEngineInitialConfigBase) as VisionEngineInitialConfigBase;
|
||||
// if (mlBase != null)
|
||||
// {
|
||||
@ -1048,7 +1266,7 @@ namespace DH.Commons.Enums
|
||||
// }
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// return name;
|
||||
//}
|
||||
}
|
||||
@ -1109,11 +1327,11 @@ namespace DH.Commons.Enums
|
||||
[DisplayName("过滤条件集合")]
|
||||
[Description("过滤条件集合,集合之间为“且”关系")]
|
||||
//[TypeConverter(typeof(CollectionCountConvert))]
|
||||
// [Editor(typeof(ComplexCollectionEditor<FilterConditions>), typeof(UITypeEditor))]
|
||||
// [Editor(typeof(ComplexCollectionEditor<FilterConditions>), typeof(UITypeEditor))]
|
||||
public List<FilterConditions> FilterConditionsCollection { get; set; } = new List<FilterConditions>();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public bool FilterOperation(DetectionResultDetail recongnitionResult)
|
||||
{
|
||||
return FilterConditionsCollection.All(u =>
|
408
DH.Commons/Base/PLCBase.cs
Normal file
408
DH.Commons/Base/PLCBase.cs
Normal file
@ -0,0 +1,408 @@
|
||||
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.6";
|
||||
private int _port = 502;
|
||||
private AntList<PLCItem> _PLCItemList = new AntList<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 AntList<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 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; }
|
||||
}
|
||||
|
||||
|
||||
public class PLCItem : NotifyProperty
|
||||
{
|
||||
private bool _selected;
|
||||
private string _name = string.Empty;
|
||||
private string _type = string.Empty;
|
||||
private string _value = string.Empty;
|
||||
private bool _startexecute;
|
||||
private bool _endexecute;
|
||||
private int _startindex;
|
||||
private int _endindex;
|
||||
private string _numtype;
|
||||
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 string 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
public string NumTpye
|
||||
{
|
||||
get => _numtype;
|
||||
set
|
||||
{
|
||||
if (_numtype != value)
|
||||
{
|
||||
_numtype = value;
|
||||
OnPropertyChanged(nameof(NumTpye));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <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 bool EndExecute
|
||||
{
|
||||
get => _endexecute;
|
||||
set
|
||||
{
|
||||
if (_endexecute != value)
|
||||
{
|
||||
_endexecute = value;
|
||||
OnPropertyChanged(nameof(EndExecute));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 流程开启顺序
|
||||
/// </summary>
|
||||
public int StartIndex
|
||||
{
|
||||
get => _startindex;
|
||||
set
|
||||
{
|
||||
if (_startindex != value)
|
||||
{
|
||||
_startindex = value;
|
||||
OnPropertyChanged(nameof(StartIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 流程结束顺序
|
||||
/// </summary>
|
||||
public int EndIndex
|
||||
{
|
||||
get => _endindex;
|
||||
set
|
||||
{
|
||||
if (_endindex != value)
|
||||
{
|
||||
_endindex = value;
|
||||
OnPropertyChanged(nameof(EndIndex));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -8,7 +8,7 @@ using OpenCvSharp;
|
||||
|
||||
|
||||
|
||||
namespace DH.Devices.Devices
|
||||
namespace DH.Commons.Base
|
||||
{
|
||||
/// <summary>
|
||||
/// 视觉处理引擎:1.传统视觉 2.深度学习
|
@ -13,12 +13,19 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AntdUI" Version="1.8.9" />
|
||||
<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>
|
||||
|
@ -1,16 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DH.Commons.Enums
|
||||
{
|
||||
public class CameraInfo
|
||||
{
|
||||
public string CamName { get; set; }
|
||||
public string Serinum { get; set; }
|
||||
public string IP { get; set; }
|
||||
}
|
||||
|
||||
}
|
@ -7,12 +7,48 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace DH.Commons.Enums
|
||||
{
|
||||
|
||||
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 EnumPLCType
|
||||
{
|
||||
信捷XC_串口,
|
||||
信捷XC_网口,
|
||||
信捷XD_串口,
|
||||
信捷XD_网口
|
||||
[Description("信捷XC串口")]
|
||||
信捷XC串口 = 0,
|
||||
[Description("信捷XC网口")]
|
||||
信捷XC网口 = 1,
|
||||
[Description("信捷XD串口")]
|
||||
信捷XD串口 = 2,
|
||||
[Description("信捷XD网口")]
|
||||
信捷XD网口 = 3
|
||||
}
|
||||
|
||||
|
||||
@ -43,20 +79,39 @@ namespace DH.Commons.Enums
|
||||
工位3=13,
|
||||
工位4=14,
|
||||
工位5=15,
|
||||
OK料盒=16,
|
||||
NG料盒=17,
|
||||
OK吹气时间=18,
|
||||
NG吹气时间=19,
|
||||
产品计数=20,
|
||||
计数清零=21,
|
||||
工件最小值=22,
|
||||
工具最大值=23,
|
||||
启用心跳=24,
|
||||
心跳=25
|
||||
工位6 = 16,
|
||||
工位7 = 17,
|
||||
工位8 = 18,
|
||||
工位9 = 19,
|
||||
工位10 = 20,
|
||||
OK料盒 =21,
|
||||
NG料盒=22,
|
||||
OK吹气时间=23,
|
||||
NG吹气时间=24,
|
||||
产品计数=25,
|
||||
计数清零=26,
|
||||
工件最小值=27,
|
||||
工具最大值=28,
|
||||
启用心跳=29,
|
||||
心跳地址=30
|
||||
|
||||
}
|
||||
|
||||
|
||||
public enum EnumPLCDataType
|
||||
{
|
||||
HD,
|
||||
D,
|
||||
M
|
||||
}
|
||||
public enum EnumPLCINTType
|
||||
{
|
||||
单字16位,
|
||||
单字32位,
|
||||
双字16位,
|
||||
双字32位
|
||||
}
|
||||
|
||||
public enum StreamFormat
|
||||
{
|
||||
[Description("8位图像")]
|
||||
|
227
DH.Commons/Helper/ConfigHelper.cs
Normal file
227
DH.Commons/Helper/ConfigHelper.cs
Normal file
@ -0,0 +1,227 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
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);
|
||||
}
|
||||
|
||||
// 序列化当前配置
|
||||
var json = JsonSerializer.Serialize(new
|
||||
{
|
||||
ConfigModel.CameraBaseList,
|
||||
ConfigModel.PLCBaseList,
|
||||
ConfigModel.DetectionList
|
||||
}, _jsonOptions);
|
||||
|
||||
// 写入新配置
|
||||
File.WriteAllText(CurrentConfigPath, json);
|
||||
}
|
||||
|
||||
/// <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.PLCBaseList = data?.PLCs ?? new List<PLCBase>();
|
||||
ConfigModel.DetectionList = data?.Detections ?? new List<DetectionConfig>();
|
||||
}
|
||||
|
||||
/// <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>();
|
||||
}
|
||||
}
|
||||
}
|
@ -76,160 +76,50 @@ namespace DH.Commons.Enums
|
||||
}
|
||||
}
|
||||
|
||||
//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";
|
||||
// }
|
||||
//}
|
||||
|
||||
// 根据描述获取枚举值(泛型方法)
|
||||
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}' 的值");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 当枚举牵涉到状态变换,检查现状态是否满足待转换的状态的前置状态要求
|
||||
/// 获取枚举类型的所有描述文本
|
||||
/// </summary>
|
||||
/// <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());
|
||||
/// <param name="enumType">枚举类型</param>
|
||||
/// <returns>描述文本列表</returns>
|
||||
public static List<string> GetEnumDescriptions(Type enumType)
|
||||
{
|
||||
// 验证类型是否为枚举
|
||||
if (!enumType.IsEnum)
|
||||
throw new ArgumentException("传入的类型必须是枚举类型", nameof(enumType));
|
||||
|
||||
// PreStateAttribute attr = f.GetCustomAttribute<PreStateAttribute>();
|
||||
// if (attr == null)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return attr.CheckPreStateValid(currentState);
|
||||
// }
|
||||
//}
|
||||
var descriptions = new List<string>();
|
||||
|
||||
/// <summary>
|
||||
/// 设备状态定义
|
||||
/// 未初始化和异常状态无前置状态要求
|
||||
/// 初始化操作前置状态必须是未初始化、关闭状态和异常状态
|
||||
/// 打开前置必须是初始化和暂停
|
||||
/// 关闭前置必须是打开和暂停和异常
|
||||
/// 暂停前置必须是打开
|
||||
/// </summary>
|
||||
//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
|
||||
//}
|
||||
|
||||
///// <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,
|
||||
//}
|
||||
foreach (var value in Enum.GetValues(enumType))
|
||||
{
|
||||
var fieldInfo = enumType.GetField(value.ToString());
|
||||
var attribute = fieldInfo.GetCustomAttribute<DescriptionAttribute>();
|
||||
descriptions.Add(attribute?.Description ?? value.ToString());
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
[Flags]
|
||||
public enum DeviceAttributeType
|
||||
{
|
||||
|
117
DH.Commons/Helper/SchemeHelper.cs
Normal file
117
DH.Commons/Helper/SchemeHelper.cs
Normal file
@ -0,0 +1,117 @@
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
120
DH.Commons/Helper/SystemConfigHelper.cs
Normal file
120
DH.Commons/Helper/SystemConfigHelper.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Configuration;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DH.Commons.Helper
|
||||
{
|
||||
/// <summary>
|
||||
/// 配置文件操作工具类(自动定位主程序配置)
|
||||
/// </summary>
|
||||
public static class SystemConfigHelper
|
||||
{
|
||||
private static Configuration _mainConfig;
|
||||
private static readonly object _lock = new object();
|
||||
|
||||
/// <summary>
|
||||
/// 获取主程序配置对象
|
||||
/// </summary>
|
||||
private static Configuration MainConfiguration
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_mainConfig == null)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
if (_mainConfig == null)
|
||||
{
|
||||
// 获取主程序路径
|
||||
string exePath = Assembly.GetEntryAssembly().Location;
|
||||
var configFile = exePath + ".config";
|
||||
|
||||
// 加载主程序配置
|
||||
var fileMap = new ExeConfigurationFileMap
|
||||
{
|
||||
ExeConfigFilename = configFile
|
||||
};
|
||||
_mainConfig = ConfigurationManager.OpenMappedExeConfiguration(
|
||||
fileMap,
|
||||
ConfigurationUserLevel.None
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
return _mainConfig;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查配置项是否存在
|
||||
/// </summary>
|
||||
public static bool KeyExists(string key)
|
||||
{
|
||||
return MainConfiguration.AppSettings.Settings[key] != null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 读取配置项(带类型自动转换)
|
||||
/// </summary>
|
||||
public static T GetValue<T>(string key, T defaultValue = default)
|
||||
{
|
||||
try
|
||||
{
|
||||
var setting = MainConfiguration.AppSettings.Settings[key];
|
||||
if (setting == null) return defaultValue;
|
||||
|
||||
return (T)Convert.ChangeType(setting.Value, typeof(T));
|
||||
}
|
||||
catch
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 写入配置项(自动保存)
|
||||
/// </summary>
|
||||
public static void SetValue(string key, object value)
|
||||
{
|
||||
var settings = MainConfiguration.AppSettings.Settings;
|
||||
var stringValue = value?.ToString() ?? string.Empty;
|
||||
|
||||
if (settings[key] == null)
|
||||
{
|
||||
settings.Add(key, stringValue);
|
||||
}
|
||||
else
|
||||
{
|
||||
settings[key].Value = stringValue;
|
||||
}
|
||||
|
||||
SaveChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除指定配置项
|
||||
/// </summary>
|
||||
public static void RemoveKey(string key)
|
||||
{
|
||||
if (KeyExists(key))
|
||||
{
|
||||
MainConfiguration.AppSettings.Settings.Remove(key);
|
||||
SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存配置修改
|
||||
/// </summary>
|
||||
private static void SaveChanges()
|
||||
{
|
||||
MainConfiguration.Save(ConfigurationSaveMode.Modified);
|
||||
ConfigurationManager.RefreshSection("appSettings");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
29
DH.Commons/Models/SystemModel.cs
Normal file
29
DH.Commons/Models/SystemModel.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using DH.Commons.Base;
|
||||
|
||||
namespace DH.Commons.Models
|
||||
{
|
||||
public static class SystemModel
|
||||
{
|
||||
/// <summary>
|
||||
/// 当前方案
|
||||
/// </summary>
|
||||
public static string CurrentScheme=string.Empty;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/// <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>();
|
||||
}
|
||||
}
|
@ -24,7 +24,6 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DH.Commons.Devies\DH.Commons.Devies.csproj" />
|
||||
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Xml.Linq;
|
||||
using DH.Devices.Devices;
|
||||
using DH.Commons.Base;
|
||||
using DVPCameraType;
|
||||
using OpenCvSharp;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
|
@ -5,7 +5,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Xml.Linq;
|
||||
using DH.Commons.Enums;
|
||||
using static MvCamCtrl.NET.MyCamera;
|
||||
using DH.Devices.Devices;
|
||||
using DH.Commons.Base;
|
||||
|
||||
|
||||
|
||||
|
@ -12,10 +12,6 @@
|
||||
<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>
|
||||
|
@ -1,82 +0,0 @@
|
||||
using System.IO.Ports;
|
||||
using DH.Commons.Enums;
|
||||
using HslCommunication;
|
||||
|
||||
namespace DH.Devices.PLC
|
||||
{
|
||||
public class PLCBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 连接状态
|
||||
/// </summary>
|
||||
public bool connected = false;
|
||||
|
||||
public string PLCName;
|
||||
/// <summary>
|
||||
/// 类型
|
||||
/// </summary>
|
||||
public EnumPLCType PLCType=EnumPLCType.信捷XD_网口;
|
||||
|
||||
/// <summary>
|
||||
/// 串口号
|
||||
/// </summary>
|
||||
public string portName="COM1";
|
||||
|
||||
/// <summary>
|
||||
/// 波特率
|
||||
/// </summary>
|
||||
public int baudRate = 9600;
|
||||
|
||||
/// <summary>
|
||||
/// 数据位
|
||||
/// </summary>
|
||||
public int dataBit = 8;
|
||||
|
||||
/// <summary>
|
||||
/// 停止位
|
||||
/// </summary>
|
||||
public StopBits stopBit = (StopBits)Enum.Parse(typeof(StopBits), "One");
|
||||
|
||||
/// <summary>
|
||||
/// 奇偶效验位
|
||||
/// </summary>
|
||||
public Parity parity = (Parity)Enum.Parse(typeof(Parity), "None");
|
||||
|
||||
/// <summary>
|
||||
/// IP地址
|
||||
/// </summary>
|
||||
public string IP = "192.168.6.6";
|
||||
|
||||
/// <summary>
|
||||
/// 端口号
|
||||
/// </summary>
|
||||
public int Port = 502;
|
||||
|
||||
/// <summary>
|
||||
/// 初始化
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual bool PLCConnect() { return false; }
|
||||
|
||||
public virtual bool PLCDisConnect() { return false; }
|
||||
|
||||
public virtual ushort ReadShort(string address) { return 0; }
|
||||
|
||||
public virtual int ReadInt(string address) { return 0; }
|
||||
|
||||
|
||||
public virtual float ReadFloat(string address) { return 0; }
|
||||
|
||||
public virtual bool ReadBool(string address) { return false; }
|
||||
|
||||
public virtual bool WriteShort(string address, short value, bool waitForReply = true) { return false; }
|
||||
|
||||
public virtual bool WriteInt(string address, int value, bool waitForReply = true) { return false; }
|
||||
|
||||
public virtual bool WriteDInt(string address, int value, bool waitForReply = true) { return false; }
|
||||
|
||||
public virtual bool WriteFloat(string address, float value, bool waitForReply = true) { return false; }
|
||||
|
||||
public virtual bool WriteBool(string address, bool value, bool waitForReply = true) { return false; }
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@ using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading.Tasks;
|
||||
using System.Xml.Linq;
|
||||
using DH.Commons.Base;
|
||||
using DH.Commons.Enums;
|
||||
using HslCommunication;
|
||||
using HslCommunication.Enthernet;
|
||||
@ -47,7 +48,7 @@ namespace DH.Devices.PLC
|
||||
OperateResult ret = TcpNet.ConnectServer();
|
||||
if (ret.IsSuccess)
|
||||
{
|
||||
connected = true;
|
||||
Connected = true;
|
||||
MonitorPieces();
|
||||
TurntableOpen(12000,true);
|
||||
|
||||
@ -382,13 +383,13 @@ namespace DH.Devices.PLC
|
||||
|
||||
public override bool PLCDisConnect()
|
||||
{
|
||||
if (connected)
|
||||
if (Connected)
|
||||
{
|
||||
TurntableStop();
|
||||
var res = TcpNet.ConnectClose();
|
||||
if (res.IsSuccess)
|
||||
{
|
||||
connected = false;
|
||||
Connected = false;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -442,7 +443,7 @@ namespace DH.Devices.PLC
|
||||
TimeSpan timeSpan = endTime - startTime;
|
||||
Thread.CurrentThread.Priority = ThreadPriority.AboveNormal;
|
||||
//while (CurrentState != DeviceState.DSClose && CurrentState != DeviceState.DSExcept && CurrentState != DeviceState.DSUninit)
|
||||
while (connected)
|
||||
while (Connected)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
uint tmpPieceNumber = 0;
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
|
||||
<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>
|
||||
|
@ -13,13 +13,13 @@ using System.Threading.Tasks;
|
||||
using System.Security.Cryptography.Xml;
|
||||
using System.Runtime.InteropServices;
|
||||
using Newtonsoft.Json;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Commons.Base;
|
||||
|
||||
|
||||
|
||||
namespace DH.Devices.Vision
|
||||
{
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 目标检测 GPU
|
||||
|
@ -12,7 +12,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
using Newtonsoft.Json;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Commons.Base;
|
||||
|
||||
|
||||
namespace DH.Devices.Vision
|
||||
|
@ -13,7 +13,7 @@ using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
using Newtonsoft.Json;
|
||||
using System.Xml;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Commons.Base;
|
||||
|
||||
|
||||
namespace DH.Devices.Vision
|
||||
|
@ -1,5 +1,5 @@
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Devices;
|
||||
using DH.Commons.Base;
|
||||
using DH.Commons.Enums;
|
||||
using DH.UI.Model.Winform;
|
||||
using HalconDotNet;
|
||||
using OpenCvSharp;
|
||||
@ -15,7 +15,7 @@ using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using XKRS.UI.Model.Winform;
|
||||
using static DH.Commons.Enums.EnumHelper;
|
||||
using ResultState = DH.Commons.Enums.ResultState;
|
||||
using ResultState = DH.Commons.Base.ResultState;
|
||||
|
||||
|
||||
namespace DH.Devices.Vision
|
||||
@ -113,7 +113,7 @@ namespace DH.Devices.Vision
|
||||
// req.Score = IIConfig.Score;
|
||||
req.mImage = originImgSet.Clone();
|
||||
|
||||
req.in_lable_path = detectConfig.in_lable_path;
|
||||
req.in_lable_path = detectConfig.In_lable_path;
|
||||
|
||||
req.confThreshold = detectConfig.ModelconfThreshold;
|
||||
req.iouThreshold = 0.3f;
|
||||
@ -121,16 +121,16 @@ namespace DH.Devices.Vision
|
||||
req.out_node_name = "output0";
|
||||
switch (detectConfig.ModelType)
|
||||
{
|
||||
case MLModelType.ImageClassification:
|
||||
case ModelType.图像分类:
|
||||
break;
|
||||
case MLModelType.ObjectDetection:
|
||||
case ModelType.目标检测:
|
||||
|
||||
break;
|
||||
case MLModelType.SemanticSegmentation:
|
||||
case ModelType.语义分割:
|
||||
break;
|
||||
case MLModelType.InstanceSegmentation:
|
||||
case ModelType.实例分割:
|
||||
break;
|
||||
case MLModelType.ObjectGPUDetection:
|
||||
case ModelType.目标检测GPU:
|
||||
|
||||
break;
|
||||
default:
|
||||
@ -213,53 +213,53 @@ namespace DH.Devices.Vision
|
||||
// .OrderBy(u => u.Key)
|
||||
// .ToList();
|
||||
//当前检测项的 过滤条件
|
||||
var conditionList = detectConfig.DetectionFilterList
|
||||
.Where(u => u.IsEnabled && u.LabelName == d.LabelName)
|
||||
.GroupBy(u => u.ResultState)
|
||||
.OrderBy(u => u.Key)
|
||||
.ToList();
|
||||
//var conditionList = detectConfig.DetectionFilterList
|
||||
// .Where(u => u.IsEnabled && u.LabelName == d.LabelName)
|
||||
// .GroupBy(u => u.ResultState)
|
||||
// .OrderBy(u => u.Key)
|
||||
// .ToList();
|
||||
|
||||
if (conditionList.Count == 0)
|
||||
{
|
||||
//if (conditionList.Count == 0)
|
||||
//{
|
||||
|
||||
d.FinalResult = d.LabelName.ToLower() == "ok"
|
||||
? ResultState.OK
|
||||
: ResultState.DetectNG;
|
||||
}
|
||||
else
|
||||
{
|
||||
d.FinalResult = detectConfig.IsMixModel
|
||||
? ResultState.A_NG
|
||||
: ResultState.OK;
|
||||
// d.FinalResult = d.LabelName.ToLower() == "ok"
|
||||
// ? ResultState.OK
|
||||
// : ResultState.DetectNG;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// d.FinalResult = detectConfig.IsMixModel
|
||||
// ? ResultState.A_NG
|
||||
// : ResultState.OK;
|
||||
|
||||
|
||||
}
|
||||
//}
|
||||
|
||||
|
||||
foreach (IGrouping<ResultState, DetectionFilter> group in conditionList)
|
||||
{
|
||||
//bool b = group.ToList().Any(f =>
|
||||
//{
|
||||
// return f.FilterOperation(d);
|
||||
//});
|
||||
//foreach (IGrouping<ResultState, DetectionFilter> group in conditionList)
|
||||
//{
|
||||
// //bool b = group.ToList().Any(f =>
|
||||
// //{
|
||||
// // return f.FilterOperation(d);
|
||||
// //});
|
||||
|
||||
|
||||
//if (b)
|
||||
//{
|
||||
// d.FinalResult = group.Key;
|
||||
// break;
|
||||
//}
|
||||
// //if (b)
|
||||
// //{
|
||||
// // d.FinalResult = group.Key;
|
||||
// // break;
|
||||
// //}
|
||||
|
||||
if (group.Any(f => f.FilterOperation(d)))
|
||||
{
|
||||
d.FinalResult = group.Key;
|
||||
break;
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// d.FinalResult = d.InferenceResult = ResultState.OK;
|
||||
//}
|
||||
}
|
||||
// if (group.Any(f => f.FilterOperation(d)))
|
||||
// {
|
||||
// d.FinalResult = group.Key;
|
||||
// break;
|
||||
// }
|
||||
// //else
|
||||
// //{
|
||||
// // d.FinalResult = d.InferenceResult = ResultState.OK;
|
||||
// //}
|
||||
//}
|
||||
});
|
||||
#endregion
|
||||
#region 5.统计缺陷过滤结果或预处理直接NG
|
||||
@ -395,18 +395,18 @@ namespace DH.Devices.Vision
|
||||
// 根据算法类型创建不同的实例
|
||||
switch (dc.ModelType)
|
||||
{
|
||||
case MLModelType.ImageClassification:
|
||||
case ModelType.图像分类:
|
||||
break;
|
||||
case MLModelType.ObjectDetection:
|
||||
case ModelType.目标检测:
|
||||
mLEngineSet.StationMLEngine = new SimboObjectDetection();
|
||||
break;
|
||||
case MLModelType.SemanticSegmentation:
|
||||
case ModelType.语义分割:
|
||||
|
||||
break;
|
||||
case MLModelType.InstanceSegmentation:
|
||||
case ModelType.实例分割:
|
||||
mLEngineSet.StationMLEngine = new SimboInstanceSegmentation();
|
||||
break;
|
||||
case MLModelType.ObjectGPUDetection:
|
||||
case ModelType.目标检测GPU:
|
||||
mLEngineSet.StationMLEngine = new SimboDetection();
|
||||
break;
|
||||
default:
|
||||
|
@ -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 MLModelType ModelType { get; set; }
|
||||
public ModelType ModelType { get; set; }
|
||||
|
||||
public IntPtr Model { get; set; }
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
|
||||
using DH.Commons.Enums;
|
||||
using DH.Commons.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
|
@ -25,8 +25,6 @@ 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}"
|
||||
@ -87,14 +85,6 @@ 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
|
||||
@ -140,7 +130,6 @@ 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}
|
||||
|
9
DHSoftware/App.config
Normal file
9
DHSoftware/App.config
Normal file
@ -0,0 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<configuration>
|
||||
<appSettings>
|
||||
<!-- 方案存储键(初始值为空) -->
|
||||
<add key="Schemes" value=""/>
|
||||
<!-- 当前方案键(初始值为空) -->
|
||||
<add key="CurrentScheme" value=""/>
|
||||
</appSettings>
|
||||
</configuration>
|
@ -13,6 +13,13 @@
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@ -40,7 +47,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AntdUI" Version="1.8.9" />
|
||||
<PackageReference Include="System.IO.Ports" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
@ -1,68 +0,0 @@
|
||||
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}' 的值");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
215
DHSoftware/MainWindow.Designer.cs
generated
215
DHSoftware/MainWindow.Designer.cs
generated
@ -29,14 +29,14 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
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();
|
||||
AntdUI.Tabs.StyleCard styleCard4 = new AntdUI.Tabs.StyleCard();
|
||||
AntdUI.Tabs.StyleCard styleCard5 = new AntdUI.Tabs.StyleCard();
|
||||
AntdUI.Tabs.StyleCard styleCard6 = 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();
|
||||
titlebar = new AntdUI.PageHeader();
|
||||
button_color = new AntdUI.Button();
|
||||
buttonSZ = new AntdUI.Button();
|
||||
@ -57,6 +57,11 @@
|
||||
tabsConfig = new AntdUI.Tabs();
|
||||
tabPage2 = new AntdUI.TabPage();
|
||||
panel1 = new AntdUI.Panel();
|
||||
stackPanel1 = new AntdUI.StackPanel();
|
||||
btnDeleteProject = new AntdUI.Button();
|
||||
btnAddProject = new AntdUI.Button();
|
||||
btnLoadProject = new AntdUI.Button();
|
||||
sltProjects = new AntdUI.Select();
|
||||
segmented1 = new AntdUI.Segmented();
|
||||
titlebar.SuspendLayout();
|
||||
pageHeader1.SuspendLayout();
|
||||
@ -77,6 +82,7 @@
|
||||
tabPage3.SuspendLayout();
|
||||
tabsConfig.SuspendLayout();
|
||||
panel1.SuspendLayout();
|
||||
stackPanel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// titlebar
|
||||
@ -152,10 +158,10 @@
|
||||
// divider2
|
||||
//
|
||||
divider2.Dock = DockStyle.Top;
|
||||
divider2.Location = new Point(54, 0);
|
||||
divider2.Location = new Point(0, 0);
|
||||
divider2.Name = "divider2";
|
||||
divider2.OrientationMargin = 0F;
|
||||
divider2.Size = new Size(970, 10);
|
||||
divider2.Size = new Size(1024, 10);
|
||||
divider2.TabIndex = 0;
|
||||
divider2.Text = "";
|
||||
//
|
||||
@ -241,13 +247,12 @@
|
||||
//
|
||||
// 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.Style = styleCard4;
|
||||
tabImgDisplay.TabIndex = 1;
|
||||
tabImgDisplay.Text = "tabs1";
|
||||
//
|
||||
@ -261,13 +266,12 @@
|
||||
//
|
||||
// tabsStas
|
||||
//
|
||||
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.Style = styleCard5;
|
||||
tabsStas.TabIndex = 3;
|
||||
tabsStas.Text = "tabs3";
|
||||
//
|
||||
@ -291,13 +295,12 @@
|
||||
//
|
||||
// tabsConfig
|
||||
//
|
||||
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.Style = styleCard6;
|
||||
tabsConfig.TabIndex = 2;
|
||||
tabsConfig.Text = "tabs2";
|
||||
//
|
||||
@ -312,6 +315,7 @@
|
||||
// panel1
|
||||
//
|
||||
panel1.Back = SystemColors.MenuHighlight;
|
||||
panel1.Controls.Add(stackPanel1);
|
||||
panel1.Controls.Add(segmented1);
|
||||
panel1.Dock = DockStyle.Top;
|
||||
panel1.Location = new Point(0, 0);
|
||||
@ -322,6 +326,57 @@
|
||||
panel1.TabIndex = 0;
|
||||
panel1.Text = "panel1";
|
||||
//
|
||||
// stackPanel1
|
||||
//
|
||||
stackPanel1.BackColor = SystemColors.MenuHighlight;
|
||||
stackPanel1.Controls.Add(btnDeleteProject);
|
||||
stackPanel1.Controls.Add(btnAddProject);
|
||||
stackPanel1.Controls.Add(btnLoadProject);
|
||||
stackPanel1.Controls.Add(sltProjects);
|
||||
stackPanel1.Dock = DockStyle.Right;
|
||||
stackPanel1.Location = new Point(525, 0);
|
||||
stackPanel1.Name = "stackPanel1";
|
||||
stackPanel1.Padding = new Padding(10);
|
||||
stackPanel1.Size = new Size(499, 68);
|
||||
stackPanel1.TabIndex = 2;
|
||||
stackPanel1.Text = "stackPanel1";
|
||||
//
|
||||
// btnDeleteProject
|
||||
//
|
||||
btnDeleteProject.Dock = DockStyle.Right;
|
||||
btnDeleteProject.Location = new Point(418, 13);
|
||||
btnDeleteProject.Name = "btnDeleteProject";
|
||||
btnDeleteProject.Size = new Size(73, 42);
|
||||
btnDeleteProject.TabIndex = 3;
|
||||
btnDeleteProject.Text = "删除";
|
||||
//
|
||||
// btnAddProject
|
||||
//
|
||||
btnAddProject.Dock = DockStyle.Right;
|
||||
btnAddProject.Location = new Point(339, 13);
|
||||
btnAddProject.Name = "btnAddProject";
|
||||
btnAddProject.Size = new Size(73, 42);
|
||||
btnAddProject.TabIndex = 2;
|
||||
btnAddProject.Text = "新增";
|
||||
//
|
||||
// btnLoadProject
|
||||
//
|
||||
btnLoadProject.Dock = DockStyle.Right;
|
||||
btnLoadProject.Location = new Point(260, 13);
|
||||
btnLoadProject.Name = "btnLoadProject";
|
||||
btnLoadProject.Size = new Size(73, 42);
|
||||
btnLoadProject.TabIndex = 1;
|
||||
btnLoadProject.Text = "载入";
|
||||
//
|
||||
// sltProjects
|
||||
//
|
||||
sltProjects.List = true;
|
||||
sltProjects.Location = new Point(13, 13);
|
||||
sltProjects.MaxCount = 10;
|
||||
sltProjects.Name = "sltProjects";
|
||||
sltProjects.Size = new Size(241, 42);
|
||||
sltProjects.TabIndex = 0;
|
||||
//
|
||||
// segmented1
|
||||
//
|
||||
segmented1.BackActive = Color.FromArgb(100, 255, 87, 34);
|
||||
@ -330,66 +385,66 @@
|
||||
segmented1.Font = new Font("Microsoft YaHei UI", 9F);
|
||||
segmented1.ForeColor = Color.White;
|
||||
segmented1.Full = true;
|
||||
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);
|
||||
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.IconActiveSvg = resources.GetString("segmentedItem6.IconActiveSvg");
|
||||
segmentedItem6.IconSvg = resources.GetString("segmentedItem6.IconSvg");
|
||||
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.IconActiveSvg = resources.GetString("segmentedItem7.IconActiveSvg");
|
||||
segmentedItem7.IconSvg = resources.GetString("segmentedItem7.IconSvg");
|
||||
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.IconActiveSvg = resources.GetString("segmentedItem8.IconActiveSvg");
|
||||
segmentedItem8.IconSvg = resources.GetString("segmentedItem8.IconSvg");
|
||||
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.IconActiveSvg = resources.GetString("segmentedItem9.IconActiveSvg");
|
||||
segmentedItem9.IconSvg = resources.GetString("segmentedItem9.IconSvg");
|
||||
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.IconActiveSvg = resources.GetString("segmentedItem10.IconActiveSvg");
|
||||
segmentedItem10.IconSvg = resources.GetString("segmentedItem10.IconSvg");
|
||||
segmentedItem10.Text = "登录";
|
||||
segmented1.Items.Add(segmentedItem6);
|
||||
segmented1.Items.Add(segmentedItem7);
|
||||
segmented1.Items.Add(segmentedItem8);
|
||||
segmented1.Items.Add(segmentedItem9);
|
||||
segmented1.Items.Add(segmentedItem10);
|
||||
segmented1.Location = new Point(0, 0);
|
||||
segmented1.Name = "segmented1";
|
||||
segmented1.Size = new Size(491, 68);
|
||||
@ -408,7 +463,7 @@
|
||||
Icon = (Icon)resources.GetObject("$this.Icon");
|
||||
Name = "MainWindow";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "AntdUI Demo";
|
||||
Text = "CCD光学筛选系统";
|
||||
WindowState = FormWindowState.Maximized;
|
||||
FormClosed += MainWindow_FormClosed;
|
||||
Load += MainWindow_Load;
|
||||
@ -432,6 +487,7 @@
|
||||
tabPage3.ResumeLayout(false);
|
||||
tabsConfig.ResumeLayout(false);
|
||||
panel1.ResumeLayout(false);
|
||||
stackPanel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
@ -459,5 +515,10 @@
|
||||
private RichTextBox richTextBox1;
|
||||
private AntdUI.Tabs tabsConfig;
|
||||
private AntdUI.TabPage tabPage2;
|
||||
private AntdUI.StackPanel stackPanel1;
|
||||
private AntdUI.Button btnLoadProject;
|
||||
private AntdUI.Select sltProjects;
|
||||
private AntdUI.Button btnAddProject;
|
||||
private AntdUI.Button btnDeleteProject;
|
||||
}
|
||||
}
|
@ -1,8 +1,10 @@
|
||||
using AntdUI;
|
||||
using AntdUI.Svg;
|
||||
using DH.Commons.Base;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Commons.Helper;
|
||||
using DH.Commons.Models;
|
||||
using DH.Devices.Camera;
|
||||
using DH.Devices.Devices;
|
||||
using DH.Devices.Motion;
|
||||
using DH.Devices.PLC;
|
||||
using DH.Devices.Vision;
|
||||
@ -40,20 +42,15 @@ namespace DHSoftware
|
||||
private UserControl currControl;
|
||||
private bool isUpdatingTabs = false;//用于阻止Tabs更新
|
||||
private bool isLight = true;
|
||||
// 定义一个语言切换事件
|
||||
public event EventHandler LanguageChanged;
|
||||
|
||||
|
||||
private System.Windows.Forms.Timer refreshTimer;
|
||||
private int testCounter = 1;
|
||||
|
||||
Dictionary<string, List<string>> _cameraRelatedDetectionDict = null;
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
refreshTimer = new System.Windows.Forms.Timer();
|
||||
refreshTimer.Interval = 1000; // 1秒间隔
|
||||
refreshTimer.Tick += RefreshTimer_Tick;
|
||||
|
||||
//refreshTimer.Start();
|
||||
//初始化数据
|
||||
InitData();
|
||||
@ -65,162 +62,185 @@ namespace DHSoftware
|
||||
userControlFrm.Dock = DockStyle.Fill;
|
||||
tabPage2.Controls.Add(userControlFrm);
|
||||
|
||||
// List<Camera> Cameras = new List<Camera>
|
||||
//{
|
||||
// new Camera
|
||||
// {
|
||||
// DeviceName = "Cam1",
|
||||
// Alias = "相机1",
|
||||
// ImagePath = @"D:\1.jpeg"
|
||||
// },
|
||||
// new Camera
|
||||
// {
|
||||
// DeviceName = "Cam2",
|
||||
// Alias = "相机2",
|
||||
// ImagePath = @"D:\2.jpeg"
|
||||
// },
|
||||
// new Camera
|
||||
// {
|
||||
// DeviceName = "Cam3",
|
||||
// Alias = "相机3",
|
||||
// ImagePath = @"D:\3.jpeg"
|
||||
// },
|
||||
// new Camera
|
||||
// {
|
||||
// DeviceName = "Cam4",
|
||||
// Alias = "相机4",
|
||||
// ImagePath = @"D:\4.jpeg"
|
||||
// },
|
||||
// new Camera
|
||||
// {
|
||||
// DeviceName = "Cam5",
|
||||
// Alias = "相机5",
|
||||
// ImagePath = @"D:\5.jpeg"
|
||||
// }
|
||||
//};
|
||||
|
||||
// if (Cameras.Count > 0)
|
||||
// {
|
||||
// tabImgDisplay.Controls.Clear();
|
||||
// foreach (var cam in Cameras)
|
||||
// {
|
||||
// AntdUI.TabPage tabPage = new AntdUI.TabPage();
|
||||
// tabPage.Name = $"tab{cam.DeviceName}";
|
||||
// tabPage.Text = cam.Alias;
|
||||
// //ImgDisplayControl imgDisplayControl = new ImgDisplayControl();
|
||||
// //imgDisplayControl.Name = $"img{cam.DeviceName}";
|
||||
// //imgDisplayControl.Dock = DockStyle.Fill;
|
||||
// //tabPage.Controls.Add(imgDisplayControl);
|
||||
// PictureBox pictureBox = new PictureBox();
|
||||
// pictureBox.Name = $"pic{cam.DeviceName}";
|
||||
// pictureBox.Dock = DockStyle.Fill;
|
||||
// pictureBox.SizeMode = PictureBoxSizeMode.Zoom;
|
||||
// tabPage.Controls.Add(pictureBox);
|
||||
// tabImgDisplay.Pages.Add(tabPage);
|
||||
|
||||
// }
|
||||
|
||||
// }
|
||||
}
|
||||
|
||||
private void RefreshTimer_Tick(object sender, EventArgs e)
|
||||
{
|
||||
//// 获取相机1的控件(通过控件名称查找)
|
||||
//var targetControl = FindControlRecursive(tabImgDisplay, "picCam1") as PictureBox;
|
||||
|
||||
//if (targetControl != null)
|
||||
//{
|
||||
// // 生成测试路径(示例路径)
|
||||
// string testPath = $@"D:\{testCounter}.png"; // 循环1-5的图片
|
||||
// testCounter++;
|
||||
|
||||
// // 加载并显示图片
|
||||
// targetControl.Image = Image.FromFile(testPath);
|
||||
// if (testCounter == 5)
|
||||
// {
|
||||
// testCounter = 1;
|
||||
// }
|
||||
// targetControl.Parent.Invalidate();
|
||||
//}
|
||||
}
|
||||
// 递归查找控件的方法
|
||||
private Control FindControlRecursive(Control parent, string name)
|
||||
{
|
||||
if (parent.Name == name) return parent;
|
||||
|
||||
foreach (Control child in parent.Controls)
|
||||
{
|
||||
var found = FindControlRecursive(child, name);
|
||||
if (found != null) return found;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
// 触发事件
|
||||
protected virtual void OnLanguageChanged(EventArgs e)
|
||||
{
|
||||
LanguageChanged?.Invoke(this, e);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
|
||||
//根据系统亮暗初始化一次
|
||||
isLight = ThemeHelper.IsLightMode();
|
||||
button_color.Toggle = !isLight;
|
||||
ThemeHelper.SetColorMode(this, isLight);
|
||||
//初始化消息弹出位置
|
||||
Config.ShowInWindow = true;
|
||||
|
||||
|
||||
|
||||
//加载方案
|
||||
LoadScheme();
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void LoadScheme()
|
||||
{
|
||||
try
|
||||
{
|
||||
//方案配置初始化
|
||||
SchemeHelper.Initialize();
|
||||
//读取方案列表
|
||||
List<string> list = SchemeHelper.GetAllSchemes();
|
||||
string CurrentScheme = "默认方案";
|
||||
//如果是空,新增默认数据
|
||||
if (list == null || list.Count <= 0)
|
||||
{
|
||||
list = new() { CurrentScheme };
|
||||
//显示到方案列表
|
||||
sltProjects.Items.Clear();
|
||||
|
||||
sltProjects.Items.Add(CurrentScheme);
|
||||
//保存到方案配置
|
||||
SchemeHelper.AddScheme(CurrentScheme);
|
||||
SchemeHelper.SetCurrentScheme(CurrentScheme);
|
||||
//新构建配置文件
|
||||
ConfigHelper.InitializeScheme(CurrentScheme);
|
||||
|
||||
sltProjects.SelectedIndex = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string s in list)
|
||||
{
|
||||
sltProjects.Items.Add(s);
|
||||
}
|
||||
CurrentScheme = SchemeHelper.GetCurrentScheme();
|
||||
sltProjects.SelectedValue = CurrentScheme;
|
||||
}
|
||||
SystemModel.CurrentScheme = CurrentScheme;
|
||||
//加载当前方案配置
|
||||
ConfigHelper.LoadConfig();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AntdUI.Message.error(this, ex.Message, autoClose: 3);
|
||||
}
|
||||
}
|
||||
private void BindEventHandler()
|
||||
{
|
||||
buttonSZ.Click += ButtonSZ_Click;
|
||||
button_color.Click += Button_color_Click;
|
||||
|
||||
btnAddProject.Click += BtnAddProject_Click;
|
||||
btnLoadProject.Click += BtnLoadProject_Click;
|
||||
btnDeleteProject.Click += BtnDeleteProject_Click;
|
||||
|
||||
|
||||
|
||||
//监听系统深浅色变化
|
||||
SystemEvents.UserPreferenceChanged += SystemEvents_UserPreferenceChanged;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void SystemEvents_UserPreferenceChanged(object sender, UserPreferenceChangedEventArgs e)
|
||||
private void BtnDeleteProject_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (e.Category == UserPreferenceCategory.General)
|
||||
try
|
||||
{
|
||||
isLight = ThemeHelper.IsLightMode();
|
||||
button_color.Toggle = !isLight;
|
||||
ThemeHelper.SetColorMode(this, isLight);
|
||||
if (sltProjects.Items.Count == 0 || sltProjects.SelectedIndex == -1) return;
|
||||
|
||||
var result = AntdUI.Modal.open(this, "删除警告!", "确认要删除该方案吗?", TType.Warn);
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
int selectedIndex = sltProjects.SelectedIndex;
|
||||
|
||||
// 删除当前选中项
|
||||
SchemeHelper.DeleteScheme(sltProjects.Text);
|
||||
ConfigHelper.DeleteSchemeConfig(sltProjects.Text);
|
||||
AntdUI.Message.success(this, $"删除方案{sltProjects.Text}成功!", autoClose: 3);
|
||||
sltProjects.Items.RemoveAt(selectedIndex);
|
||||
// 自动选择下一个(如果存在)
|
||||
if (sltProjects.Items.Count > 0)
|
||||
{
|
||||
// 如果删除的不是最后一项,则选中原位置的新项,否则选中最后一项
|
||||
sltProjects.SelectedIndex = selectedIndex < sltProjects.Items.Count
|
||||
? selectedIndex
|
||||
: sltProjects.Items.Count - 1;
|
||||
|
||||
SystemModel.CurrentScheme = sltProjects.Text;
|
||||
SchemeHelper.SetCurrentScheme(SystemModel.CurrentScheme);
|
||||
//加载当前方案配置
|
||||
ConfigHelper.LoadConfig();
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
sltProjects.SelectedIndex = -1; // 清空选择
|
||||
AntdUI.Modal.open(this, "空方案警告!", "当前方案全部删除,需重启程序!", TType.Warn);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AntdUI.Message.error(this, ex.Message, autoClose: 3);
|
||||
}
|
||||
}
|
||||
|
||||
private void Button_color_Click(object sender, EventArgs e)
|
||||
private void BtnLoadProject_Click(object? sender, EventArgs e)
|
||||
{
|
||||
isLight = !isLight;
|
||||
//这里使用了Toggle属性切换图标
|
||||
button_color.Toggle = !isLight;
|
||||
ThemeHelper.SetColorMode(this, isLight);
|
||||
try
|
||||
{
|
||||
if (sltProjects.Items.Count == 0 || sltProjects.SelectedIndex == -1) return;
|
||||
if (SystemModel.CurrentScheme == sltProjects.Text)
|
||||
{
|
||||
AntdUI.Message.warn(this, "当前已是该方案,无需重复载入!", autoClose: 3);
|
||||
return;
|
||||
}
|
||||
//修改当前软件当前方案
|
||||
SystemModel.CurrentScheme = sltProjects.Text;
|
||||
//修改配置当前方案
|
||||
SchemeHelper.SetCurrentScheme(SystemModel.CurrentScheme);
|
||||
//将配置文件替换为当前方案
|
||||
ConfigHelper.LoadConfig();
|
||||
AntdUI.Message.success(this, $"载入方案{SystemModel.CurrentScheme}成功!", autoClose: 3);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
AntdUI.Message.error(this, ex.Message, autoClose: 3);
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonSZ_Click(object sender, EventArgs e)
|
||||
private void BtnAddProject_Click(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
try
|
||||
{
|
||||
var form = new AddSchemeControl(this, "新增方案操作") { Size = new System.Drawing.Size(400, 300) };
|
||||
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
||||
{
|
||||
BtnHeight = 0,
|
||||
});
|
||||
if (form.submit)
|
||||
{
|
||||
string SchemeName = form.SchemeName;
|
||||
//保存到方案配置
|
||||
SchemeHelper.AddScheme(SchemeName);
|
||||
if (form.NullScheme)
|
||||
{
|
||||
//新构建配置文件
|
||||
ConfigHelper.InitializeScheme(SchemeName);
|
||||
}
|
||||
else
|
||||
{
|
||||
//派生当前方案
|
||||
ConfigHelper.DeriveScheme(SchemeName);
|
||||
}
|
||||
//刷新方案列表
|
||||
sltProjects.Items.Clear();
|
||||
List<string> list = SchemeHelper.GetAllSchemes();
|
||||
foreach (string s in list)
|
||||
{
|
||||
sltProjects.Items.Add(s);
|
||||
}
|
||||
string CurrentScheme = SchemeHelper.GetCurrentScheme();
|
||||
sltProjects.SelectedValue = CurrentScheme;
|
||||
AntdUI.Message.success(this, $"新增方案{SchemeName}成功!", autoClose: 3);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
AntdUI.Message.error(this, ex.Message, autoClose: 3);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public List<Camera> HKCameras { get; } = new List<Camera>();
|
||||
public List<Do3ThinkCamera> Cameras { get; } = new List<Do3ThinkCamera>();
|
||||
@ -272,6 +292,7 @@ namespace DHSoftware
|
||||
default:
|
||||
break;
|
||||
}
|
||||
segmented1.SelectIndex = -1;
|
||||
}
|
||||
public bool CurrentMachine = false;
|
||||
public volatile int ProductNum_Total = 0;
|
||||
@ -317,14 +338,14 @@ namespace DHSoftware
|
||||
|
||||
|
||||
|
||||
var det1 = new DetectionConfig("相机1", MLModelType.ObjectDetection, @"D:\PROJECTS\X015\Vision\Cam1.onnx", false, "Cam1");
|
||||
var det2 = new DetectionConfig("相机2", MLModelType.ObjectDetection, @"D:\PROJECTS\X015\Vision\Cam2.onnx", false, "Cam2");
|
||||
var det3 = new DetectionConfig("相机3", MLModelType.ObjectDetection, @"D:\PROJECTS\X015\Vision\Cam3.onnx", false, "Cam3");
|
||||
var det4 = new DetectionConfig("相机4", MLModelType.ObjectDetection, @"D:\PROJECTS\X015\Vision\Cam4.onnx", false, "Cam4");
|
||||
var det5 = new DetectionConfig("相机5", MLModelType.ObjectDetection, @"D:\PROJECTS\X015\Vision\Cam5.onnx", false, "Cam5");
|
||||
var det6 = new DetectionConfig("相机6", MLModelType.ObjectDetection, @"D:\PROJECTS\X015\Vision\Cam6.onnx", false, "Cam6");
|
||||
var det7 = new DetectionConfig("相机7", MLModelType.ObjectDetection, @"D:\PROJECTS\X015\Vision\Cam7.onnx", false, "Cam7");
|
||||
var det8 = new DetectionConfig("相机8", MLModelType.ObjectDetection, @"D:\PROJECTS\X015\Vision\Cam8.onnx", false, "Cam8");
|
||||
var det1 = new DetectionConfig("相机1", ModelType.目标检测, @"D:\PROJECTS\X015\Vision\Cam1.onnx", false, "Cam1");
|
||||
var det2 = new DetectionConfig("相机2", ModelType.目标检测, @"D:\PROJECTS\X015\Vision\Cam2.onnx", false, "Cam2");
|
||||
var det3 = new DetectionConfig("相机3", ModelType.目标检测, @"D:\PROJECTS\X015\Vision\Cam3.onnx", false, "Cam3");
|
||||
var det4 = new DetectionConfig("相机4", ModelType.目标检测, @"D:\PROJECTS\X015\Vision\Cam4.onnx", false, "Cam4");
|
||||
var det5 = new DetectionConfig("相机5", ModelType.目标检测, @"D:\PROJECTS\X015\Vision\Cam5.onnx", false, "Cam5");
|
||||
var det6 = new DetectionConfig("相机6", ModelType.目标检测, @"D:\PROJECTS\X015\Vision\Cam6.onnx", false, "Cam6");
|
||||
var det7 = new DetectionConfig("相机7", ModelType.目标检测, @"D:\PROJECTS\X015\Vision\Cam7.onnx", false, "Cam7");
|
||||
var det8 = new DetectionConfig("相机8", ModelType.目标检测, @"D:\PROJECTS\X015\Vision\Cam8.onnx", false, "Cam8");
|
||||
List<RelatedCamera> CameraCollects = new List<RelatedCamera>();
|
||||
CameraCollects.Add(new RelatedCamera("Cam1"));
|
||||
List<RelatedCamera> CameraCollects2 = new List<RelatedCamera>();
|
||||
@ -349,7 +370,7 @@ namespace DHSoftware
|
||||
det1.ModelconfThreshold = Conf;
|
||||
det1.ModelWidth = 640;
|
||||
det1.ModelHeight = 640;
|
||||
det1.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam1.txt";
|
||||
det1.In_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam1.txt";
|
||||
det1.IsEnabled = true;
|
||||
det1.ShowLocation.X = 1;
|
||||
det1.ShowLocation.Y = 1;
|
||||
@ -358,7 +379,7 @@ namespace DHSoftware
|
||||
det2.ModelconfThreshold = Conf;
|
||||
det2.ModelWidth = 640;
|
||||
det2.ModelHeight = 640;
|
||||
det2.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam2.txt";
|
||||
det2.In_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam2.txt";
|
||||
det2.IsEnabled = true;
|
||||
det2.ShowLocation.X = 2;
|
||||
det2.ShowLocation.Y = 1;
|
||||
@ -367,7 +388,7 @@ namespace DHSoftware
|
||||
det3.ModelconfThreshold = Conf;
|
||||
det3.ModelWidth = 640;
|
||||
det3.ModelHeight = 640;
|
||||
det3.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam3.txt";
|
||||
det3.In_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam3.txt";
|
||||
det3.IsEnabled = true;
|
||||
det3.ShowLocation.X = 3;
|
||||
det3.ShowLocation.Y = 1;
|
||||
@ -376,7 +397,7 @@ namespace DHSoftware
|
||||
det4.ModelconfThreshold = Conf;
|
||||
det4.ModelWidth = 640;
|
||||
det4.ModelHeight = 640;
|
||||
det4.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam4.txt";
|
||||
det4.In_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam4.txt";
|
||||
det4.IsEnabled = true;
|
||||
det4.ShowLocation.X = 4;
|
||||
det4.ShowLocation.Y = 1;
|
||||
@ -387,7 +408,7 @@ namespace DHSoftware
|
||||
det5.ModelconfThreshold = Conf;
|
||||
det5.ModelWidth = 640;
|
||||
det5.ModelHeight = 640;
|
||||
det5.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam5.txt";
|
||||
det5.In_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam5.txt";
|
||||
det5.IsEnabled = true;
|
||||
det5.ShowLocation.X = 1;
|
||||
det5.ShowLocation.Y = 2;
|
||||
@ -396,7 +417,7 @@ namespace DHSoftware
|
||||
det6.ModelconfThreshold = Conf;
|
||||
det6.ModelWidth = 640;
|
||||
det6.ModelHeight = 640;
|
||||
det6.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam6.txt";
|
||||
det6.In_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam6.txt";
|
||||
det6.IsEnabled = true;
|
||||
det6.ShowLocation.X = 2;
|
||||
det6.ShowLocation.Y = 2;
|
||||
@ -405,7 +426,7 @@ namespace DHSoftware
|
||||
det7.ModelconfThreshold = Conf;
|
||||
det7.ModelWidth = 640;
|
||||
det7.ModelHeight = 640;
|
||||
det7.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam7.txt";
|
||||
det7.In_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam7.txt";
|
||||
det7.IsEnabled = true;
|
||||
det7.ShowLocation.X = 3;
|
||||
det7.ShowLocation.Y = 2;
|
||||
@ -414,7 +435,7 @@ namespace DHSoftware
|
||||
det8.ModelconfThreshold = Conf;
|
||||
det8.ModelWidth = 640;
|
||||
det8.ModelHeight = 640;
|
||||
det8.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam8.txt";
|
||||
det8.In_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam8.txt";
|
||||
det8.IsEnabled = true;
|
||||
det8.ShowLocation.X = 4;
|
||||
det8.ShowLocation.Y = 2;
|
||||
@ -1020,7 +1041,7 @@ namespace DHSoftware
|
||||
listCamBase.Add(cam1);
|
||||
listCamBase.Add(cam2);
|
||||
|
||||
SettingWindow1 settingWindow = new SettingWindow1();
|
||||
SettingWindow settingWindow = new SettingWindow();
|
||||
settingWindow.Show();
|
||||
//s.cameras = listCamBase;
|
||||
//s.Show();
|
||||
|
@ -120,34 +120,34 @@
|
||||
<data name="buttonSZ.IconSvg" xml:space="preserve">
|
||||
<value><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"><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"></path><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"></path></svg></value>
|
||||
</data>
|
||||
<data name="segmentedItem1.IconActiveSvg" xml:space="preserve">
|
||||
<data name="segmentedItem6.IconActiveSvg" xml:space="preserve">
|
||||
<value><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><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"/><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"/></svg></value>
|
||||
</data>
|
||||
<data name="segmentedItem1.IconSvg" xml:space="preserve">
|
||||
<data name="segmentedItem6.IconSvg" xml:space="preserve">
|
||||
<value><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><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"/><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"/></svg></value>
|
||||
</data>
|
||||
<data name="segmentedItem2.IconActiveSvg" xml:space="preserve">
|
||||
<data name="segmentedItem7.IconActiveSvg" xml:space="preserve">
|
||||
<value><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><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"/></svg></value>
|
||||
</data>
|
||||
<data name="segmentedItem2.IconSvg" xml:space="preserve">
|
||||
<data name="segmentedItem7.IconSvg" xml:space="preserve">
|
||||
<value><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><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"/></svg></value>
|
||||
</data>
|
||||
<data name="segmentedItem3.IconActiveSvg" xml:space="preserve">
|
||||
<data name="segmentedItem8.IconActiveSvg" xml:space="preserve">
|
||||
<value><svg viewBox="0 0 1027 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><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"/><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"/></svg></value>
|
||||
</data>
|
||||
<data name="segmentedItem3.IconSvg" xml:space="preserve">
|
||||
<data name="segmentedItem8.IconSvg" xml:space="preserve">
|
||||
<value><svg viewBox="0 0 1027 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><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"/><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"/></svg></value>
|
||||
</data>
|
||||
<data name="segmentedItem4.IconActiveSvg" xml:space="preserve">
|
||||
<data name="segmentedItem9.IconActiveSvg" xml:space="preserve">
|
||||
<value><svg viewBox="0 0 1027 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><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"/><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"/><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"/></svg></value>
|
||||
</data>
|
||||
<data name="segmentedItem4.IconSvg" xml:space="preserve">
|
||||
<data name="segmentedItem9.IconSvg" xml:space="preserve">
|
||||
<value><svg viewBox="0 0 1027 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><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"/><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"/><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"/></svg></value>
|
||||
</data>
|
||||
<data name="segmentedItem5.IconActiveSvg" xml:space="preserve">
|
||||
<data name="segmentedItem10.IconActiveSvg" xml:space="preserve">
|
||||
<value><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><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"/><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"/></svg></value>
|
||||
</data>
|
||||
<data name="segmentedItem5.IconSvg" xml:space="preserve">
|
||||
<data name="segmentedItem10.IconSvg" xml:space="preserve">
|
||||
<value><svg viewBox="0 0 1024 1024" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><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"/><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"/></svg></value>
|
||||
</data>
|
||||
<assembly alias="System.Drawing" name="System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
|
||||
|
@ -1,155 +0,0 @@
|
||||
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>()
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
36
DHSoftware/Views/AddCameraControl.Designer.cs
generated
36
DHSoftware/Views/AddCameraControl.Designer.cs
generated
@ -29,6 +29,7 @@
|
||||
private void InitializeComponent()
|
||||
{
|
||||
panel1 = new AntdUI.Panel();
|
||||
lbTitleName = new AntdUI.Label();
|
||||
input_name = new AntdUI.Input();
|
||||
label3 = new AntdUI.Label();
|
||||
divider1 = new AntdUI.Divider();
|
||||
@ -36,7 +37,6 @@
|
||||
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(label1);
|
||||
panel1.Controls.Add(lbTitleName);
|
||||
panel1.Dock = DockStyle.Fill;
|
||||
panel1.Location = new Point(0, 0);
|
||||
panel1.Name = "panel1";
|
||||
@ -58,6 +58,16 @@
|
||||
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;
|
||||
@ -66,7 +76,7 @@
|
||||
input_name.Name = "input_name";
|
||||
input_name.Radius = 3;
|
||||
input_name.Size = new Size(464, 38);
|
||||
input_name.TabIndex = 22;
|
||||
input_name.TabIndex = 28;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
@ -75,7 +85,7 @@
|
||||
label3.Location = new Point(18, 110);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(464, 24);
|
||||
label3.TabIndex = 21;
|
||||
label3.TabIndex = 27;
|
||||
label3.Text = "相机名称";
|
||||
//
|
||||
// divider1
|
||||
@ -84,7 +94,7 @@
|
||||
divider1.Location = new Point(18, 98);
|
||||
divider1.Name = "divider1";
|
||||
divider1.Size = new Size(464, 12);
|
||||
divider1.TabIndex = 20;
|
||||
divider1.TabIndex = 26;
|
||||
//
|
||||
// stackPanel1
|
||||
//
|
||||
@ -95,7 +105,7 @@
|
||||
stackPanel1.Name = "stackPanel1";
|
||||
stackPanel1.RightToLeft = RightToLeft.No;
|
||||
stackPanel1.Size = new Size(464, 44);
|
||||
stackPanel1.TabIndex = 19;
|
||||
stackPanel1.TabIndex = 25;
|
||||
stackPanel1.Text = "stackPanel1";
|
||||
//
|
||||
// button_cancel
|
||||
@ -125,17 +135,7 @@
|
||||
divider2.Location = new Point(18, 42);
|
||||
divider2.Name = "divider2";
|
||||
divider2.Size = new Size(464, 12);
|
||||
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 = "新增相机操作";
|
||||
divider2.TabIndex = 24;
|
||||
//
|
||||
// AddCameraControl
|
||||
//
|
||||
@ -150,7 +150,6 @@
|
||||
#endregion
|
||||
|
||||
private AntdUI.Panel panel1;
|
||||
private AntdUI.Label label1;
|
||||
private AntdUI.Input input_name;
|
||||
private AntdUI.Label label3;
|
||||
private AntdUI.Divider divider1;
|
||||
@ -158,5 +157,6 @@
|
||||
private AntdUI.Button button_cancel;
|
||||
private AntdUI.Button button_ok;
|
||||
private AntdUI.Divider divider2;
|
||||
private AntdUI.Label lbTitleName;
|
||||
}
|
||||
}
|
||||
|
@ -7,10 +7,12 @@ namespace DHSoftware.Views
|
||||
private AntdUI.Window window;
|
||||
public bool submit;
|
||||
public string CubicleName;
|
||||
public AddCameraControl(AntdUI.Window _window)
|
||||
public AddCameraControl(AntdUI.Window _window, string TitleName)
|
||||
{
|
||||
this.window = _window;
|
||||
|
||||
InitializeComponent();
|
||||
lbTitleName.Text = TitleName;
|
||||
// 绑定事件
|
||||
BindEventHandler();
|
||||
}
|
||||
|
22
DHSoftware/Views/AddCubicleControl.Designer.cs
generated
22
DHSoftware/Views/AddCubicleControl.Designer.cs
generated
@ -36,7 +36,7 @@
|
||||
button_cancel = new AntdUI.Button();
|
||||
button_ok = new AntdUI.Button();
|
||||
divider2 = new AntdUI.Divider();
|
||||
label1 = new AntdUI.Label();
|
||||
lbTitleName = 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(label1);
|
||||
panel1.Controls.Add(lbTitleName);
|
||||
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;
|
||||
//
|
||||
// label1
|
||||
// lbTitleName
|
||||
//
|
||||
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 = "新增工位操作";
|
||||
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 = "新增工位操作";
|
||||
//
|
||||
// AddCubicleControl
|
||||
//
|
||||
@ -150,7 +150,7 @@
|
||||
#endregion
|
||||
|
||||
private AntdUI.Panel panel1;
|
||||
private AntdUI.Label label1;
|
||||
private AntdUI.Label lbTitleName;
|
||||
private AntdUI.Input input_name;
|
||||
private AntdUI.Label label3;
|
||||
private AntdUI.Divider divider1;
|
||||
|
@ -7,10 +7,11 @@ namespace DHSoftware.Views
|
||||
private AntdUI.Window window;
|
||||
public bool submit;
|
||||
public string CubicleName;
|
||||
public AddCubicleControl(AntdUI.Window _window)
|
||||
public AddCubicleControl(AntdUI.Window _window,string TitleName)
|
||||
{
|
||||
this.window = _window;
|
||||
InitializeComponent();
|
||||
lbTitleName.Text = TitleName;
|
||||
// 绑定事件
|
||||
BindEventHandler();
|
||||
}
|
||||
|
61
DHSoftware/Views/AddMotionControl.Designer.cs
generated
61
DHSoftware/Views/AddMotionControl.Designer.cs
generated
@ -36,31 +36,25 @@
|
||||
button_cancel = new AntdUI.Button();
|
||||
button_ok = new AntdUI.Button();
|
||||
divider2 = new AntdUI.Divider();
|
||||
label1 = new AntdUI.Label();
|
||||
label2 = new AntdUI.Label();
|
||||
divider3 = new AntdUI.Divider();
|
||||
select_type = new AntdUI.Select();
|
||||
lbTitleName = new AntdUI.Label();
|
||||
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(label1);
|
||||
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, 260);
|
||||
panel1.Size = new Size(500, 192);
|
||||
panel1.TabIndex = 0;
|
||||
panel1.Text = "panel1";
|
||||
//
|
||||
@ -133,47 +127,21 @@
|
||||
divider2.Size = new Size(464, 12);
|
||||
divider2.TabIndex = 18;
|
||||
//
|
||||
// label1
|
||||
// lbTitleName
|
||||
//
|
||||
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;
|
||||
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 = "新增运动控制操作";
|
||||
//
|
||||
// AddMotionControl
|
||||
//
|
||||
Controls.Add(panel1);
|
||||
Name = "AddMotionControl";
|
||||
Size = new Size(500, 260);
|
||||
Size = new Size(500, 192);
|
||||
panel1.ResumeLayout(false);
|
||||
stackPanel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
@ -182,7 +150,7 @@
|
||||
#endregion
|
||||
|
||||
private AntdUI.Panel panel1;
|
||||
private AntdUI.Label label1;
|
||||
private AntdUI.Label lbTitleName;
|
||||
private AntdUI.Input input_name;
|
||||
private AntdUI.Label label3;
|
||||
private AntdUI.Divider divider1;
|
||||
@ -190,8 +158,5 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -8,10 +8,11 @@ namespace DHSoftware.Views
|
||||
public bool submit;
|
||||
public string MotionName;
|
||||
public string MotionType;
|
||||
public AddMotionControl(AntdUI.Window _window)
|
||||
public AddMotionControl(AntdUI.Window _window,string TitleName)
|
||||
{
|
||||
this.window = _window;
|
||||
InitializeComponent();
|
||||
lbTitleName.Text = TitleName;
|
||||
// 绑定事件
|
||||
BindEventHandler();
|
||||
}
|
||||
@ -39,7 +40,6 @@ namespace DHSoftware.Views
|
||||
return;
|
||||
}
|
||||
MotionName = input_name.Text;
|
||||
MotionType = select_type.Text;
|
||||
submit = true;
|
||||
this.Dispose();
|
||||
}
|
||||
|
201
DHSoftware/Views/AddSchemeControl.Designer.cs
generated
Normal file
201
DHSoftware/Views/AddSchemeControl.Designer.cs
generated
Normal file
@ -0,0 +1,201 @@
|
||||
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;
|
||||
}
|
||||
}
|
52
DHSoftware/Views/AddSchemeControl.cs
Normal file
52
DHSoftware/Views/AddSchemeControl.cs
Normal file
@ -0,0 +1,52 @@
|
||||
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Devices;
|
||||
using DH.Commons.Base;
|
||||
using DH.Commons.Enums;
|
||||
using DVPCameraType;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
@ -1,5 +1,5 @@
|
||||
using AntdUI;
|
||||
using DH.Devices.Devices;
|
||||
using DH.Commons.Base;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
53
DHSoftware/Views/CameraControl.Designer.cs
generated
53
DHSoftware/Views/CameraControl.Designer.cs
generated
@ -50,6 +50,8 @@
|
||||
button1 = new AntdUI.Button();
|
||||
button2 = new AntdUI.Button();
|
||||
button3 = new AntdUI.Button();
|
||||
sthPic = new AntdUI.Switch();
|
||||
label6 = new AntdUI.Label();
|
||||
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
@ -72,7 +74,7 @@
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.Location = new Point(28, 71);
|
||||
label1.Location = new Point(28, 114);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(59, 23);
|
||||
label1.TabIndex = 14;
|
||||
@ -80,7 +82,7 @@
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.Location = new Point(28, 113);
|
||||
label2.Location = new Point(28, 156);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(59, 23);
|
||||
label2.TabIndex = 15;
|
||||
@ -88,7 +90,7 @@
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.Location = new Point(28, 155);
|
||||
label3.Location = new Point(28, 198);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(59, 23);
|
||||
label3.TabIndex = 16;
|
||||
@ -96,7 +98,7 @@
|
||||
//
|
||||
// iptExposure
|
||||
//
|
||||
iptExposure.Location = new Point(84, 57);
|
||||
iptExposure.Location = new Point(84, 100);
|
||||
iptExposure.Name = "iptExposure";
|
||||
iptExposure.Size = new Size(93, 37);
|
||||
iptExposure.TabIndex = 17;
|
||||
@ -105,7 +107,7 @@
|
||||
//
|
||||
// iptGain
|
||||
//
|
||||
iptGain.Location = new Point(84, 100);
|
||||
iptGain.Location = new Point(84, 143);
|
||||
iptGain.Name = "iptGain";
|
||||
iptGain.Size = new Size(93, 37);
|
||||
iptGain.TabIndex = 18;
|
||||
@ -113,7 +115,7 @@
|
||||
//
|
||||
// iptRevolve
|
||||
//
|
||||
iptRevolve.Location = new Point(84, 143);
|
||||
iptRevolve.Location = new Point(84, 186);
|
||||
iptRevolve.Name = "iptRevolve";
|
||||
iptRevolve.Size = new Size(93, 37);
|
||||
iptRevolve.TabIndex = 19;
|
||||
@ -121,7 +123,7 @@
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.Location = new Point(28, 199);
|
||||
label4.Location = new Point(28, 242);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(59, 23);
|
||||
label4.TabIndex = 20;
|
||||
@ -130,14 +132,14 @@
|
||||
// sltAcquisitionMode
|
||||
//
|
||||
sltAcquisitionMode.List = true;
|
||||
sltAcquisitionMode.Location = new Point(84, 186);
|
||||
sltAcquisitionMode.Location = new Point(84, 229);
|
||||
sltAcquisitionMode.Name = "sltAcquisitionMode";
|
||||
sltAcquisitionMode.Size = new Size(93, 36);
|
||||
sltAcquisitionMode.TabIndex = 21;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.Location = new Point(28, 244);
|
||||
label5.Location = new Point(28, 287);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(59, 23);
|
||||
label5.TabIndex = 22;
|
||||
@ -146,14 +148,14 @@
|
||||
// sltTriggerMode
|
||||
//
|
||||
sltTriggerMode.List = true;
|
||||
sltTriggerMode.Location = new Point(84, 231);
|
||||
sltTriggerMode.Location = new Point(84, 274);
|
||||
sltTriggerMode.Name = "sltTriggerMode";
|
||||
sltTriggerMode.Size = new Size(93, 36);
|
||||
sltTriggerMode.TabIndex = 26;
|
||||
//
|
||||
// label7
|
||||
//
|
||||
label7.Location = new Point(28, 354);
|
||||
label7.Location = new Point(28, 397);
|
||||
label7.Name = "label7";
|
||||
label7.Size = new Size(59, 23);
|
||||
label7.TabIndex = 28;
|
||||
@ -161,7 +163,7 @@
|
||||
//
|
||||
// iptROIW
|
||||
//
|
||||
iptROIW.Location = new Point(84, 371);
|
||||
iptROIW.Location = new Point(84, 414);
|
||||
iptROIW.Name = "iptROIW";
|
||||
iptROIW.Size = new Size(93, 37);
|
||||
iptROIW.TabIndex = 31;
|
||||
@ -169,7 +171,7 @@
|
||||
//
|
||||
// iptROIY
|
||||
//
|
||||
iptROIY.Location = new Point(84, 328);
|
||||
iptROIY.Location = new Point(84, 371);
|
||||
iptROIY.Name = "iptROIY";
|
||||
iptROIY.Size = new Size(93, 37);
|
||||
iptROIY.TabIndex = 30;
|
||||
@ -177,7 +179,7 @@
|
||||
//
|
||||
// iptROIX
|
||||
//
|
||||
iptROIX.Location = new Point(84, 285);
|
||||
iptROIX.Location = new Point(84, 328);
|
||||
iptROIX.Name = "iptROIX";
|
||||
iptROIX.Size = new Size(93, 37);
|
||||
iptROIX.TabIndex = 29;
|
||||
@ -186,7 +188,7 @@
|
||||
//
|
||||
// iptROIH
|
||||
//
|
||||
iptROIH.Location = new Point(84, 414);
|
||||
iptROIH.Location = new Point(84, 457);
|
||||
iptROIH.Name = "iptROIH";
|
||||
iptROIH.Size = new Size(93, 37);
|
||||
iptROIH.TabIndex = 32;
|
||||
@ -253,10 +255,29 @@
|
||||
button3.TabIndex = 37;
|
||||
button3.Text = "连续触发";
|
||||
//
|
||||
// sthPic
|
||||
//
|
||||
sthPic.CheckedText = "启用";
|
||||
sthPic.Location = new Point(84, 60);
|
||||
sthPic.Name = "sthPic";
|
||||
sthPic.Size = new Size(93, 33);
|
||||
sthPic.TabIndex = 39;
|
||||
sthPic.UnCheckedText = "关闭";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
label6.Location = new Point(28, 70);
|
||||
label6.Name = "label6";
|
||||
label6.Size = new Size(59, 23);
|
||||
label6.TabIndex = 38;
|
||||
label6.Text = "相 机 图";
|
||||
//
|
||||
// CameraControl
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(sthPic);
|
||||
Controls.Add(label6);
|
||||
Controls.Add(button3);
|
||||
Controls.Add(button2);
|
||||
Controls.Add(button1);
|
||||
@ -309,5 +330,7 @@
|
||||
private AntdUI.Button button1;
|
||||
private AntdUI.Button button2;
|
||||
private AntdUI.Button button3;
|
||||
private AntdUI.Switch sthPic;
|
||||
private AntdUI.Label label6;
|
||||
}
|
||||
}
|
||||
|
@ -8,8 +8,8 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using AntdUI;
|
||||
using DH.Commons.Base;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Devices;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
@ -48,6 +48,10 @@ namespace DHSoftware.Views
|
||||
|
||||
private void BindData()
|
||||
{
|
||||
|
||||
|
||||
sthPic.DataBindings.Add(nameof(sthPic.Checked), CameraBase, nameof(CameraBase.IsSavePicEnabled),
|
||||
true, DataSourceUpdateMode.OnPropertyChanged);
|
||||
// 启用状态绑定
|
||||
swhEnable.DataBindings.Add(nameof(swhEnable.Checked), CameraBase, nameof(CameraBase.IsEnabled),
|
||||
true, DataSourceUpdateMode.OnPropertyChanged);
|
||||
|
@ -3,7 +3,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using AntdUI;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Commons.Base;
|
||||
using DH.Devices.Vision;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
|
@ -7,10 +7,9 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using System.IO;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Devices;
|
||||
using DH.Commons.Base;
|
||||
|
||||
|
||||
namespace XKRS.UI.Device.Winform
|
||||
|
@ -15,6 +15,7 @@ using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using DH.Devices.Vision;
|
||||
using DH.Commons.Base;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
@ -23,7 +24,7 @@ namespace DHSoftware.Views
|
||||
|
||||
private DetectionConfig _currentConfig = new DetectionConfig();
|
||||
private readonly string _configName;
|
||||
List<KeyValuePair<string, int>> MLModelTypes = GetFilteredEnumDescriptionsAndValues<MLModelType>();
|
||||
List<KeyValuePair<string, int>> MLModelTypes = GetFilteredEnumDescriptionsAndValues<ModelType>();
|
||||
|
||||
public static List<KeyValuePair<string, int>> GetFilteredEnumDescriptionsAndValues<T>() where T : Enum
|
||||
{
|
||||
|
301
DHSoftware/Views/DetectControl.Designer.cs
generated
301
DHSoftware/Views/DetectControl.Designer.cs
generated
@ -40,10 +40,10 @@
|
||||
btnPreAdd = new AntdUI.Button();
|
||||
preTable = new AntdUI.Table();
|
||||
label3 = new AntdUI.Label();
|
||||
btnPath = new AntdUI.Button();
|
||||
switch1 = new AntdUI.Switch();
|
||||
btnPrePath = new AntdUI.Button();
|
||||
sthPreStatus = new AntdUI.Switch();
|
||||
label2 = new AntdUI.Label();
|
||||
iptPath = new AntdUI.Input();
|
||||
iptPrePath = new AntdUI.Input();
|
||||
label1 = new AntdUI.Label();
|
||||
tabPage2 = new AntdUI.TabPage();
|
||||
btnLableDelete = new AntdUI.Button();
|
||||
@ -51,36 +51,33 @@
|
||||
lableTable = new AntdUI.Table();
|
||||
label15 = new AntdUI.Label();
|
||||
btnPic = new AntdUI.Button();
|
||||
switch6 = new AntdUI.Switch();
|
||||
sthDetectNG = new AntdUI.Switch();
|
||||
label13 = new AntdUI.Label();
|
||||
switch7 = new AntdUI.Switch();
|
||||
sthOKDetect = new AntdUI.Switch();
|
||||
label14 = new AntdUI.Label();
|
||||
switch4 = new AntdUI.Switch();
|
||||
sthNGOriginal = new AntdUI.Switch();
|
||||
label6 = new AntdUI.Label();
|
||||
switch5 = new AntdUI.Switch();
|
||||
sthOKOriginal = new AntdUI.Switch();
|
||||
label12 = new AntdUI.Label();
|
||||
input1 = new AntdUI.Input();
|
||||
iptConfidence = new AntdUI.Input();
|
||||
label5 = new AntdUI.Label();
|
||||
flowPanel1 = new AntdUI.FlowPanel();
|
||||
flowCameraPanel = new AntdUI.FlowPanel();
|
||||
label11 = new AntdUI.Label();
|
||||
switch3 = new AntdUI.Switch();
|
||||
sthStation = new AntdUI.Switch();
|
||||
label10 = new AntdUI.Label();
|
||||
stDetectType = new AntdUI.Select();
|
||||
label9 = new AntdUI.Label();
|
||||
btnCorrelatedCamera = new AntdUI.Button();
|
||||
btnPath2 = new AntdUI.Button();
|
||||
switch2 = new AntdUI.Switch();
|
||||
sthDetectStatus = new AntdUI.Switch();
|
||||
label7 = new AntdUI.Label();
|
||||
iptPath2 = new AntdUI.Input();
|
||||
iptDetectPath = new AntdUI.Input();
|
||||
label8 = new AntdUI.Label();
|
||||
tabPage3 = new AntdUI.TabPage();
|
||||
tabPage4 = new AntdUI.TabPage();
|
||||
switch8 = new AntdUI.Switch();
|
||||
btnSizeDel = new AntdUI.Button();
|
||||
btnSizeAdd = new AntdUI.Button();
|
||||
SizeTable = new AntdUI.Table();
|
||||
label17 = new AntdUI.Label();
|
||||
label18 = new AntdUI.Label();
|
||||
tabs1.SuspendLayout();
|
||||
tabPage1.SuspendLayout();
|
||||
tabPage2.SuspendLayout();
|
||||
@ -114,10 +111,10 @@
|
||||
tabPage1.Controls.Add(btnPreAdd);
|
||||
tabPage1.Controls.Add(preTable);
|
||||
tabPage1.Controls.Add(label3);
|
||||
tabPage1.Controls.Add(btnPath);
|
||||
tabPage1.Controls.Add(switch1);
|
||||
tabPage1.Controls.Add(btnPrePath);
|
||||
tabPage1.Controls.Add(sthPreStatus);
|
||||
tabPage1.Controls.Add(label2);
|
||||
tabPage1.Controls.Add(iptPath);
|
||||
tabPage1.Controls.Add(iptPrePath);
|
||||
tabPage1.Controls.Add(label1);
|
||||
tabPage1.Location = new Point(-909, -575);
|
||||
tabPage1.Name = "tabPage1";
|
||||
@ -161,6 +158,8 @@
|
||||
//
|
||||
// PreOutTable
|
||||
//
|
||||
PreOutTable.EmptyHeader = true;
|
||||
PreOutTable.EnableHeaderResizing = true;
|
||||
PreOutTable.Location = new Point(191, 355);
|
||||
PreOutTable.Name = "PreOutTable";
|
||||
PreOutTable.Size = new Size(423, 181);
|
||||
@ -195,6 +194,8 @@
|
||||
//
|
||||
// preTable
|
||||
//
|
||||
preTable.EmptyHeader = true;
|
||||
preTable.EnableHeaderResizing = true;
|
||||
preTable.Location = new Point(191, 148);
|
||||
preTable.Name = "preTable";
|
||||
preTable.Size = new Size(423, 181);
|
||||
@ -209,27 +210,27 @@
|
||||
label3.TabIndex = 1;
|
||||
label3.Text = "输入参数";
|
||||
//
|
||||
// btnPath
|
||||
// btnPrePath
|
||||
//
|
||||
btnPath.BorderWidth = 2F;
|
||||
btnPath.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
btnPath.Ghost = true;
|
||||
btnPath.IconRatio = 0.8F;
|
||||
btnPath.IconSvg = resources.GetString("btnPath.IconSvg");
|
||||
btnPath.Location = new Point(620, 79);
|
||||
btnPath.Name = "btnPath";
|
||||
btnPath.Size = new Size(80, 38);
|
||||
btnPath.TabIndex = 7;
|
||||
btnPath.Text = "打开";
|
||||
btnPrePath.BorderWidth = 2F;
|
||||
btnPrePath.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
btnPrePath.Ghost = true;
|
||||
btnPrePath.IconRatio = 0.8F;
|
||||
btnPrePath.IconSvg = resources.GetString("btnPrePath.IconSvg");
|
||||
btnPrePath.Location = new Point(620, 79);
|
||||
btnPrePath.Name = "btnPrePath";
|
||||
btnPrePath.Size = new Size(80, 38);
|
||||
btnPrePath.TabIndex = 7;
|
||||
btnPrePath.Text = "打开";
|
||||
//
|
||||
// switch1
|
||||
// sthPreStatus
|
||||
//
|
||||
switch1.CheckedText = "启用";
|
||||
switch1.Location = new Point(207, 33);
|
||||
switch1.Name = "switch1";
|
||||
switch1.Size = new Size(82, 33);
|
||||
switch1.TabIndex = 4;
|
||||
switch1.UnCheckedText = "关闭";
|
||||
sthPreStatus.CheckedText = "启用";
|
||||
sthPreStatus.Location = new Point(207, 33);
|
||||
sthPreStatus.Name = "sthPreStatus";
|
||||
sthPreStatus.Size = new Size(82, 33);
|
||||
sthPreStatus.TabIndex = 4;
|
||||
sthPreStatus.UnCheckedText = "关闭";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
@ -239,14 +240,14 @@
|
||||
label2.TabIndex = 3;
|
||||
label2.Text = "状 态";
|
||||
//
|
||||
// iptPath
|
||||
// iptPrePath
|
||||
//
|
||||
iptPath.Location = new Point(191, 79);
|
||||
iptPath.Name = "iptPath";
|
||||
iptPath.PlaceholderText = "请点击打开按钮选择模型路径";
|
||||
iptPath.ReadOnly = true;
|
||||
iptPath.Size = new Size(423, 42);
|
||||
iptPath.TabIndex = 1;
|
||||
iptPrePath.Location = new Point(191, 79);
|
||||
iptPrePath.Name = "iptPrePath";
|
||||
iptPrePath.PlaceholderText = "请点击打开按钮选择模型路径";
|
||||
iptPrePath.ReadOnly = true;
|
||||
iptPrePath.Size = new Size(423, 42);
|
||||
iptPrePath.TabIndex = 1;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
@ -263,34 +264,33 @@
|
||||
tabPage2.Controls.Add(lableTable);
|
||||
tabPage2.Controls.Add(label15);
|
||||
tabPage2.Controls.Add(btnPic);
|
||||
tabPage2.Controls.Add(switch6);
|
||||
tabPage2.Controls.Add(sthDetectNG);
|
||||
tabPage2.Controls.Add(label13);
|
||||
tabPage2.Controls.Add(switch7);
|
||||
tabPage2.Controls.Add(sthOKDetect);
|
||||
tabPage2.Controls.Add(label14);
|
||||
tabPage2.Controls.Add(switch4);
|
||||
tabPage2.Controls.Add(sthNGOriginal);
|
||||
tabPage2.Controls.Add(label6);
|
||||
tabPage2.Controls.Add(switch5);
|
||||
tabPage2.Controls.Add(sthOKOriginal);
|
||||
tabPage2.Controls.Add(label12);
|
||||
tabPage2.Controls.Add(input1);
|
||||
tabPage2.Controls.Add(iptConfidence);
|
||||
tabPage2.Controls.Add(label5);
|
||||
tabPage2.Controls.Add(flowPanel1);
|
||||
tabPage2.Controls.Add(flowCameraPanel);
|
||||
tabPage2.Controls.Add(label11);
|
||||
tabPage2.Controls.Add(switch3);
|
||||
tabPage2.Controls.Add(sthStation);
|
||||
tabPage2.Controls.Add(label10);
|
||||
tabPage2.Controls.Add(stDetectType);
|
||||
tabPage2.Controls.Add(label9);
|
||||
tabPage2.Controls.Add(btnCorrelatedCamera);
|
||||
tabPage2.Controls.Add(btnPath2);
|
||||
tabPage2.Controls.Add(switch2);
|
||||
tabPage2.Controls.Add(sthDetectStatus);
|
||||
tabPage2.Controls.Add(label7);
|
||||
tabPage2.Controls.Add(iptPath2);
|
||||
tabPage2.Controls.Add(iptDetectPath);
|
||||
tabPage2.Controls.Add(label8);
|
||||
tabPage2.Location = new Point(-909, -575);
|
||||
tabPage2.Name = "tabPage2";
|
||||
tabPage2.Size = new Size(909, 575);
|
||||
tabPage2.TabIndex = 1;
|
||||
tabPage2.Text = "模型检测";
|
||||
tabPage2.Click += tabPage2_Click;
|
||||
//
|
||||
// btnLableDelete
|
||||
//
|
||||
@ -320,7 +320,8 @@
|
||||
//
|
||||
// lableTable
|
||||
//
|
||||
lableTable.BackColor = SystemColors.ControlLight;
|
||||
lableTable.BackColor = SystemColors.Window;
|
||||
lableTable.EmptyHeader = true;
|
||||
lableTable.Location = new Point(110, 252);
|
||||
lableTable.Name = "lableTable";
|
||||
lableTable.Size = new Size(656, 288);
|
||||
@ -348,14 +349,14 @@
|
||||
btnPic.TabIndex = 44;
|
||||
btnPic.Text = "查看图片";
|
||||
//
|
||||
// switch6
|
||||
// sthDetectNG
|
||||
//
|
||||
switch6.CheckedText = "启用";
|
||||
switch6.Location = new Point(607, 194);
|
||||
switch6.Name = "switch6";
|
||||
switch6.Size = new Size(82, 33);
|
||||
switch6.TabIndex = 43;
|
||||
switch6.UnCheckedText = "关闭";
|
||||
sthDetectNG.CheckedText = "启用";
|
||||
sthDetectNG.Location = new Point(607, 194);
|
||||
sthDetectNG.Name = "sthDetectNG";
|
||||
sthDetectNG.Size = new Size(82, 33);
|
||||
sthDetectNG.TabIndex = 43;
|
||||
sthDetectNG.UnCheckedText = "关闭";
|
||||
//
|
||||
// label13
|
||||
//
|
||||
@ -365,14 +366,14 @@
|
||||
label13.TabIndex = 42;
|
||||
label13.Text = "NG检测图";
|
||||
//
|
||||
// switch7
|
||||
// sthOKDetect
|
||||
//
|
||||
switch7.CheckedText = "启用";
|
||||
switch7.Location = new Point(438, 194);
|
||||
switch7.Name = "switch7";
|
||||
switch7.Size = new Size(82, 33);
|
||||
switch7.TabIndex = 41;
|
||||
switch7.UnCheckedText = "关闭";
|
||||
sthOKDetect.CheckedText = "启用";
|
||||
sthOKDetect.Location = new Point(438, 194);
|
||||
sthOKDetect.Name = "sthOKDetect";
|
||||
sthOKDetect.Size = new Size(82, 33);
|
||||
sthOKDetect.TabIndex = 41;
|
||||
sthOKDetect.UnCheckedText = "关闭";
|
||||
//
|
||||
// label14
|
||||
//
|
||||
@ -382,14 +383,14 @@
|
||||
label14.TabIndex = 40;
|
||||
label14.Text = "OK检测图";
|
||||
//
|
||||
// switch4
|
||||
// sthNGOriginal
|
||||
//
|
||||
switch4.CheckedText = "启用";
|
||||
switch4.Location = new Point(270, 194);
|
||||
switch4.Name = "switch4";
|
||||
switch4.Size = new Size(82, 33);
|
||||
switch4.TabIndex = 39;
|
||||
switch4.UnCheckedText = "关闭";
|
||||
sthNGOriginal.CheckedText = "启用";
|
||||
sthNGOriginal.Location = new Point(270, 194);
|
||||
sthNGOriginal.Name = "sthNGOriginal";
|
||||
sthNGOriginal.Size = new Size(82, 33);
|
||||
sthNGOriginal.TabIndex = 39;
|
||||
sthNGOriginal.UnCheckedText = "关闭";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
@ -399,14 +400,14 @@
|
||||
label6.TabIndex = 38;
|
||||
label6.Text = "NG原图";
|
||||
//
|
||||
// switch5
|
||||
// sthOKOriginal
|
||||
//
|
||||
switch5.CheckedText = "启用";
|
||||
switch5.Location = new Point(110, 194);
|
||||
switch5.Name = "switch5";
|
||||
switch5.Size = new Size(82, 33);
|
||||
switch5.TabIndex = 37;
|
||||
switch5.UnCheckedText = "关闭";
|
||||
sthOKOriginal.CheckedText = "启用";
|
||||
sthOKOriginal.Location = new Point(110, 194);
|
||||
sthOKOriginal.Name = "sthOKOriginal";
|
||||
sthOKOriginal.Size = new Size(82, 33);
|
||||
sthOKOriginal.TabIndex = 37;
|
||||
sthOKOriginal.UnCheckedText = "关闭";
|
||||
//
|
||||
// label12
|
||||
//
|
||||
@ -416,14 +417,14 @@
|
||||
label12.TabIndex = 36;
|
||||
label12.Text = "OK原图";
|
||||
//
|
||||
// input1
|
||||
// iptConfidence
|
||||
//
|
||||
input1.Location = new Point(649, 24);
|
||||
input1.Name = "input1";
|
||||
input1.PlaceholderText = "";
|
||||
input1.ReadOnly = true;
|
||||
input1.Size = new Size(117, 42);
|
||||
input1.TabIndex = 35;
|
||||
iptConfidence.Location = new Point(649, 24);
|
||||
iptConfidence.Name = "iptConfidence";
|
||||
iptConfidence.PlaceholderText = "";
|
||||
iptConfidence.ReadOnly = true;
|
||||
iptConfidence.Size = new Size(117, 42);
|
||||
iptConfidence.TabIndex = 35;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
@ -433,15 +434,15 @@
|
||||
label5.TabIndex = 34;
|
||||
label5.Text = "置信度";
|
||||
//
|
||||
// flowPanel1
|
||||
// flowCameraPanel
|
||||
//
|
||||
flowPanel1.AutoScroll = true;
|
||||
flowPanel1.BackColor = SystemColors.ControlLight;
|
||||
flowPanel1.Location = new Point(110, 136);
|
||||
flowPanel1.Name = "flowPanel1";
|
||||
flowPanel1.Size = new Size(656, 49);
|
||||
flowPanel1.TabIndex = 33;
|
||||
flowPanel1.Text = "flowPanel1";
|
||||
flowCameraPanel.AutoScroll = true;
|
||||
flowCameraPanel.BackColor = SystemColors.Window;
|
||||
flowCameraPanel.Location = new Point(110, 136);
|
||||
flowCameraPanel.Name = "flowCameraPanel";
|
||||
flowCameraPanel.Size = new Size(656, 49);
|
||||
flowCameraPanel.TabIndex = 33;
|
||||
flowCameraPanel.Text = "flowPanel1";
|
||||
//
|
||||
// label11
|
||||
//
|
||||
@ -451,14 +452,14 @@
|
||||
label11.TabIndex = 32;
|
||||
label11.Text = "关联相机";
|
||||
//
|
||||
// switch3
|
||||
// sthStation
|
||||
//
|
||||
switch3.CheckedText = "启用";
|
||||
switch3.Location = new Point(270, 26);
|
||||
switch3.Name = "switch3";
|
||||
switch3.Size = new Size(82, 33);
|
||||
switch3.TabIndex = 31;
|
||||
switch3.UnCheckedText = "关闭";
|
||||
sthStation.CheckedText = "启用";
|
||||
sthStation.Location = new Point(270, 26);
|
||||
sthStation.Name = "sthStation";
|
||||
sthStation.Size = new Size(82, 33);
|
||||
sthStation.TabIndex = 31;
|
||||
sthStation.UnCheckedText = "关闭";
|
||||
//
|
||||
// label10
|
||||
//
|
||||
@ -512,14 +513,14 @@
|
||||
btnPath2.TabIndex = 20;
|
||||
btnPath2.Text = "打开";
|
||||
//
|
||||
// switch2
|
||||
// sthDetectStatus
|
||||
//
|
||||
switch2.CheckedText = "启用";
|
||||
switch2.Location = new Point(110, 26);
|
||||
switch2.Name = "switch2";
|
||||
switch2.Size = new Size(82, 33);
|
||||
switch2.TabIndex = 19;
|
||||
switch2.UnCheckedText = "关闭";
|
||||
sthDetectStatus.CheckedText = "启用";
|
||||
sthDetectStatus.Location = new Point(110, 26);
|
||||
sthDetectStatus.Name = "sthDetectStatus";
|
||||
sthDetectStatus.Size = new Size(82, 33);
|
||||
sthDetectStatus.TabIndex = 19;
|
||||
sthDetectStatus.UnCheckedText = "关闭";
|
||||
//
|
||||
// label7
|
||||
//
|
||||
@ -529,14 +530,14 @@
|
||||
label7.TabIndex = 18;
|
||||
label7.Text = "状 态";
|
||||
//
|
||||
// iptPath2
|
||||
// iptDetectPath
|
||||
//
|
||||
iptPath2.Location = new Point(110, 75);
|
||||
iptPath2.Name = "iptPath2";
|
||||
iptPath2.PlaceholderText = "请点击打开按钮选择模型路径";
|
||||
iptPath2.ReadOnly = true;
|
||||
iptPath2.Size = new Size(656, 42);
|
||||
iptPath2.TabIndex = 17;
|
||||
iptDetectPath.Location = new Point(110, 75);
|
||||
iptDetectPath.Name = "iptDetectPath";
|
||||
iptDetectPath.PlaceholderText = "请点击打开按钮选择模型路径";
|
||||
iptDetectPath.ReadOnly = true;
|
||||
iptDetectPath.Size = new Size(656, 42);
|
||||
iptDetectPath.TabIndex = 17;
|
||||
//
|
||||
// label8
|
||||
//
|
||||
@ -557,27 +558,15 @@
|
||||
//
|
||||
// tabPage4
|
||||
//
|
||||
tabPage4.Controls.Add(switch8);
|
||||
tabPage4.Controls.Add(btnSizeDel);
|
||||
tabPage4.Controls.Add(btnSizeAdd);
|
||||
tabPage4.Controls.Add(SizeTable);
|
||||
tabPage4.Controls.Add(label17);
|
||||
tabPage4.Controls.Add(label18);
|
||||
tabPage4.Location = new Point(8, 8);
|
||||
tabPage4.Name = "tabPage4";
|
||||
tabPage4.Size = new Size(909, 575);
|
||||
tabPage4.TabIndex = 1;
|
||||
tabPage4.Text = "预处理";
|
||||
//
|
||||
// switch8
|
||||
//
|
||||
switch8.CheckedText = "启用";
|
||||
switch8.Location = new Point(120, 33);
|
||||
switch8.Name = "switch8";
|
||||
switch8.Size = new Size(82, 33);
|
||||
switch8.TabIndex = 11;
|
||||
switch8.UnCheckedText = "关闭";
|
||||
//
|
||||
// btnSizeDel
|
||||
//
|
||||
btnSizeDel.BorderWidth = 2F;
|
||||
@ -585,7 +574,7 @@
|
||||
btnSizeDel.Ghost = true;
|
||||
btnSizeDel.IconRatio = 0.8F;
|
||||
btnSizeDel.IconSvg = resources.GetString("btnSizeDel.IconSvg");
|
||||
btnSizeDel.Location = new Point(747, 192);
|
||||
btnSizeDel.Location = new Point(745, 147);
|
||||
btnSizeDel.Name = "btnSizeDel";
|
||||
btnSizeDel.Size = new Size(80, 38);
|
||||
btnSizeDel.TabIndex = 10;
|
||||
@ -598,7 +587,7 @@
|
||||
btnSizeAdd.Ghost = true;
|
||||
btnSizeAdd.IconRatio = 0.8F;
|
||||
btnSizeAdd.IconSvg = resources.GetString("btnSizeAdd.IconSvg");
|
||||
btnSizeAdd.Location = new Point(747, 148);
|
||||
btnSizeAdd.Location = new Point(745, 103);
|
||||
btnSizeAdd.Name = "btnSizeAdd";
|
||||
btnSizeAdd.Size = new Size(80, 38);
|
||||
btnSizeAdd.TabIndex = 9;
|
||||
@ -606,28 +595,13 @@
|
||||
//
|
||||
// SizeTable
|
||||
//
|
||||
SizeTable.Location = new Point(38, 118);
|
||||
SizeTable.EmptyHeader = true;
|
||||
SizeTable.Location = new Point(20, 52);
|
||||
SizeTable.Name = "SizeTable";
|
||||
SizeTable.Size = new Size(686, 402);
|
||||
SizeTable.Size = new Size(706, 402);
|
||||
SizeTable.TabIndex = 8;
|
||||
SizeTable.Text = "table1";
|
||||
//
|
||||
// label17
|
||||
//
|
||||
label17.Location = new Point(38, 89);
|
||||
label17.Name = "label17";
|
||||
label17.Size = new Size(91, 23);
|
||||
label17.TabIndex = 1;
|
||||
label17.Text = "配 置";
|
||||
//
|
||||
// label18
|
||||
//
|
||||
label18.Location = new Point(38, 43);
|
||||
label18.Name = "label18";
|
||||
label18.Size = new Size(91, 23);
|
||||
label18.TabIndex = 3;
|
||||
label18.Text = "状 态";
|
||||
//
|
||||
// DetectControl
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
@ -650,10 +624,10 @@
|
||||
private AntdUI.TabPage tabPage2;
|
||||
private AntdUI.TabPage tabPage3;
|
||||
private AntdUI.Label label1;
|
||||
private AntdUI.Input iptPath;
|
||||
private AntdUI.Input iptPrePath;
|
||||
private AntdUI.Label label2;
|
||||
private AntdUI.Switch switch1;
|
||||
private AntdUI.Button btnPath;
|
||||
private AntdUI.Switch sthPreStatus;
|
||||
private AntdUI.Button btnPrePath;
|
||||
private AntdUI.Label label3;
|
||||
private AntdUI.Button btnPreDelete;
|
||||
private AntdUI.Button btnPreAdd;
|
||||
@ -664,25 +638,25 @@
|
||||
private AntdUI.Table PreOutTable;
|
||||
private AntdUI.Button btnCorrelatedCamera;
|
||||
private AntdUI.Button btnPath2;
|
||||
private AntdUI.Switch switch2;
|
||||
private AntdUI.Switch sthDetectStatus;
|
||||
private AntdUI.Label label7;
|
||||
private AntdUI.Input iptPath2;
|
||||
private AntdUI.Input iptDetectPath;
|
||||
private AntdUI.Label label8;
|
||||
private AntdUI.Select stDetectType;
|
||||
private AntdUI.Label label9;
|
||||
private AntdUI.Switch switch3;
|
||||
private AntdUI.Switch sthStation;
|
||||
private AntdUI.Label label10;
|
||||
private AntdUI.Label label11;
|
||||
private AntdUI.FlowPanel flowPanel1;
|
||||
private AntdUI.FlowPanel flowCameraPanel;
|
||||
private AntdUI.Label label5;
|
||||
private AntdUI.Input input1;
|
||||
private AntdUI.Switch switch4;
|
||||
private AntdUI.Input iptConfidence;
|
||||
private AntdUI.Switch sthNGOriginal;
|
||||
private AntdUI.Label label6;
|
||||
private AntdUI.Switch switch5;
|
||||
private AntdUI.Switch sthOKOriginal;
|
||||
private AntdUI.Label label12;
|
||||
private AntdUI.Switch switch6;
|
||||
private AntdUI.Switch sthDetectNG;
|
||||
private AntdUI.Label label13;
|
||||
private AntdUI.Switch switch7;
|
||||
private AntdUI.Switch sthOKDetect;
|
||||
private AntdUI.Label label14;
|
||||
private AntdUI.Button btnPic;
|
||||
private AntdUI.Label label15;
|
||||
@ -693,8 +667,5 @@
|
||||
private AntdUI.Button btnSizeDel;
|
||||
private AntdUI.Button btnSizeAdd;
|
||||
private AntdUI.Table SizeTable;
|
||||
private AntdUI.Label label17;
|
||||
private AntdUI.Label label18;
|
||||
private AntdUI.Switch switch8;
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Xml.Linq;
|
||||
using AntdUI;
|
||||
using DH.Commons.Base;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Vision;
|
||||
using DH.Devices.PLC;
|
||||
using XKRS.CanFly;
|
||||
using static AntdUI.Table;
|
||||
using static System.Windows.Forms.AxHost;
|
||||
using static DH.Commons.Enums.EnumHelper;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
@ -21,9 +14,11 @@ namespace DHSoftware.Views
|
||||
public partial class DetectControl : UserControl
|
||||
{
|
||||
Window window;
|
||||
public DetectControl(Window _window)
|
||||
DetectionConfig detectionConfig;
|
||||
public DetectControl(Window _window,DetectionConfig _detection)
|
||||
{
|
||||
window = _window;
|
||||
detectionConfig = _detection;
|
||||
InitializeComponent();
|
||||
//初始化表格列头
|
||||
InitTableColumns();
|
||||
@ -34,7 +29,7 @@ namespace DHSoftware.Views
|
||||
private void BindEventHandler()
|
||||
{
|
||||
//预处理
|
||||
btnPath.Click += btnPath_Click;
|
||||
btnPrePath.Click += btnPath_Click;
|
||||
btnPreAdd.Click += BtnPreAdd_Click; ;
|
||||
btnPreDelete.Click += BtnPreDelete_Click; ;
|
||||
preTable.CellClick += PreTable_CellClick; ;
|
||||
@ -63,12 +58,11 @@ namespace DHSoftware.Views
|
||||
|
||||
if (e.Record is DetectionLable DetectionLable)
|
||||
{
|
||||
curDetectionLable = DetectionLable;
|
||||
switch (buttontext)
|
||||
{
|
||||
//暂不支持进入整行编辑,只支持指定单元格编辑,推荐使用弹窗或抽屉编辑整行数据
|
||||
case "编辑":
|
||||
var form = new DetectionLableEdit(window, curDetectionLable) { Size = new Size(500, 300) };
|
||||
var form = new DetectionLableEdit(window, DetectionLable) { Size = new Size(500, 300) };
|
||||
AntdUI.Drawer.open(new AntdUI.Drawer.Config(window, form)
|
||||
{
|
||||
OnLoad = () =>
|
||||
@ -84,7 +78,7 @@ namespace DHSoftware.Views
|
||||
case "删除":
|
||||
var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
|
||||
if (result == DialogResult.OK)
|
||||
DetectionLableList.Remove(DetectionLable);
|
||||
detectionConfig.DetectionLableList.Remove(DetectionLable);
|
||||
break;
|
||||
|
||||
}
|
||||
@ -98,12 +92,11 @@ namespace DHSoftware.Views
|
||||
|
||||
if (e.Record is SizeTreatParam sizeTreat)
|
||||
{
|
||||
SizeParamLable = sizeTreat;
|
||||
switch (buttontext)
|
||||
{
|
||||
//暂不支持进入整行编辑,只支持指定单元格编辑,推荐使用弹窗或抽屉编辑整行数据
|
||||
case "编辑":
|
||||
var form = new SizeLabelEdit(window, SizeParamLable) { Size = new Size(500, 300) };
|
||||
var form = new SizeLabelEdit(window, sizeTreat) { Size = new Size(500, 300) };
|
||||
AntdUI.Drawer.open(new AntdUI.Drawer.Config(window, form)
|
||||
{
|
||||
OnLoad = () =>
|
||||
@ -119,10 +112,10 @@ namespace DHSoftware.Views
|
||||
case "删除":
|
||||
var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
|
||||
if (result == DialogResult.OK)
|
||||
SizeLableList.Remove(sizeTreat);
|
||||
detectionConfig.SizeTreatParamList.Remove(sizeTreat);
|
||||
break;
|
||||
case "进行测量":
|
||||
var sizeType = ((int)SizeParamLable.PreType).ToString();
|
||||
var sizeType = ((int)sizeTreat.PreType).ToString();
|
||||
|
||||
// 根据测量类型打开不同的窗口
|
||||
switch (sizeType)
|
||||
@ -162,7 +155,7 @@ namespace DHSoftware.Views
|
||||
|
||||
private void BtnLableDelete_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (DetectionLableList.Count == 0 || !DetectionLableList.Any(x => x.Selected))
|
||||
if (detectionConfig.DetectionLableList.Count == 0 || !detectionConfig.DetectionLableList.Any(x => x.Selected))
|
||||
{
|
||||
AntdUI.Message.warn(window, "请选择要删除的行!", autoClose: 3);
|
||||
return;
|
||||
@ -172,12 +165,12 @@ namespace DHSoftware.Views
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
// 使用反转for循环删除主列表中选中的项
|
||||
for (int i = DetectionLableList.Count - 1; i >= 0; i--)
|
||||
for (int i = detectionConfig.DetectionLableList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// 删除选中的主列表项
|
||||
if (DetectionLableList[i].Selected)
|
||||
if (detectionConfig.DetectionLableList[i].Selected)
|
||||
{
|
||||
DetectionLableList.RemoveAt(i);
|
||||
detectionConfig.DetectionLableList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
// 提示删除完成
|
||||
@ -201,13 +194,13 @@ namespace DHSoftware.Views
|
||||
});
|
||||
if (form.submit)
|
||||
{
|
||||
DetectionLableList.Add(detectionLable);
|
||||
detectionConfig.DetectionLableList.Add(detectionLable);
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnSizeDelete_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (SizeLableList.Count == 0 || !SizeLableList.Any(x => x.Selected))
|
||||
if (detectionConfig.SizeTreatParamList.Count == 0 || !detectionConfig.SizeTreatParamList.Any(x => x.Selected))
|
||||
{
|
||||
AntdUI.Message.warn(window, "请选择要删除的行!", autoClose: 3);
|
||||
return;
|
||||
@ -217,12 +210,12 @@ namespace DHSoftware.Views
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
// 使用反转for循环删除主列表中选中的项
|
||||
for (int i = SizeLableList.Count - 1; i >= 0; i--)
|
||||
for (int i = detectionConfig.SizeTreatParamList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// 删除选中的主列表项
|
||||
if (SizeLableList[i].Selected)
|
||||
if (detectionConfig.SizeTreatParamList[i].Selected)
|
||||
{
|
||||
SizeLableList.RemoveAt(i);
|
||||
detectionConfig.SizeTreatParamList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
// 提示删除完成
|
||||
@ -251,7 +244,7 @@ namespace DHSoftware.Views
|
||||
});
|
||||
if (form.submit)
|
||||
{
|
||||
SizeLableList.Add(SizeParamLable);
|
||||
detectionConfig.SizeTreatParamList.Add(SizeParamLable);
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,23 +253,20 @@ namespace DHSoftware.Views
|
||||
|
||||
}
|
||||
|
||||
List<RelatedCamera> relatedCameras = new List<RelatedCamera>();
|
||||
private void BtnCorrelatedCamera_Click(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
|
||||
var form = new CorrelatedCameraEdit(window, relatedCameras) { Size = new Size(500, 400) };
|
||||
var form = new CorrelatedCameraEdit(window, detectionConfig.CameraCollects) { Size = new Size(500, 400) };
|
||||
AntdUI.Modal.open(new AntdUI.Modal.Config(window, "", form, TType.None)
|
||||
{
|
||||
BtnHeight = 0,
|
||||
});
|
||||
if (form.submit)
|
||||
{
|
||||
flowPanel1.Controls.Clear();
|
||||
if (relatedCameras.Count > 0)
|
||||
flowCameraPanel.Controls.Clear();
|
||||
if (detectionConfig.CameraCollects.Count > 0)
|
||||
{
|
||||
foreach (var item in relatedCameras)
|
||||
foreach (var item in detectionConfig.CameraCollects)
|
||||
{
|
||||
var control = new AntdUI.Tag()
|
||||
{
|
||||
@ -288,11 +278,11 @@ namespace DHSoftware.Views
|
||||
control.CloseChanged += (sender, e) =>
|
||||
{
|
||||
var tag = sender as Tag;
|
||||
foreach (var item in relatedCameras)
|
||||
foreach (var item in detectionConfig.CameraCollects)
|
||||
{
|
||||
if (item.CameraSourceId.Equals(tag.Text))
|
||||
{
|
||||
relatedCameras.Remove(item);
|
||||
detectionConfig.CameraCollects.Remove(item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -301,7 +291,7 @@ namespace DHSoftware.Views
|
||||
};
|
||||
// 通过主窗口设置DPI控制添加控件保持缩放比例
|
||||
window.AutoDpi(control);
|
||||
flowPanel1.Controls.Add(control);
|
||||
flowCameraPanel.Controls.Add(control);
|
||||
control.BringToFront();
|
||||
}
|
||||
}
|
||||
@ -329,7 +319,7 @@ namespace DHSoftware.Views
|
||||
{
|
||||
string filePath = openFileDialog.FileName;
|
||||
|
||||
iptPath2.Text = filePath;
|
||||
iptDetectPath.Text = filePath;
|
||||
|
||||
}
|
||||
}
|
||||
@ -341,12 +331,11 @@ namespace DHSoftware.Views
|
||||
|
||||
if (e.Record is PreTreatParam PreTreat)
|
||||
{
|
||||
curPreOutTreat = PreTreat;
|
||||
switch (buttontext)
|
||||
{
|
||||
//暂不支持进入整行编辑,只支持指定单元格编辑,推荐使用弹窗或抽屉编辑整行数据
|
||||
case "编辑":
|
||||
var form = new PreTreatEdit(window, curPreOutTreat) { Size = new Size(500, 300) };
|
||||
var form = new PreTreatEdit(window, PreTreat) { Size = new Size(500, 300) };
|
||||
AntdUI.Drawer.open(new AntdUI.Drawer.Config(window, form)
|
||||
{
|
||||
OnLoad = () =>
|
||||
@ -362,7 +351,7 @@ namespace DHSoftware.Views
|
||||
case "删除":
|
||||
var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
|
||||
if (result == DialogResult.OK)
|
||||
PreOutTreatList.Remove(PreTreat);
|
||||
detectionConfig.OUTPreTreatParams.Remove(PreTreat);
|
||||
break;
|
||||
|
||||
}
|
||||
@ -371,7 +360,7 @@ namespace DHSoftware.Views
|
||||
|
||||
private void BtnOutDelete_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (PreOutTreatList.Count == 0 || !PreOutTreatList.Any(x => x.Selected))
|
||||
if (detectionConfig.OUTPreTreatParams.Count == 0 || !detectionConfig.OUTPreTreatParams.Any(x => x.Selected))
|
||||
{
|
||||
AntdUI.Message.warn(window, "请选择要删除的行!", autoClose: 3);
|
||||
return;
|
||||
@ -381,12 +370,12 @@ namespace DHSoftware.Views
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
// 使用反转for循环删除主列表中选中的项
|
||||
for (int i = PreOutTreatList.Count - 1; i >= 0; i--)
|
||||
for (int i = detectionConfig.OUTPreTreatParams.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// 删除选中的主列表项
|
||||
if (PreOutTreatList[i].Selected)
|
||||
if (detectionConfig.OUTPreTreatParams[i].Selected)
|
||||
{
|
||||
PreOutTreatList.RemoveAt(i);
|
||||
detectionConfig.OUTPreTreatParams.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
// 提示删除完成
|
||||
@ -411,7 +400,7 @@ namespace DHSoftware.Views
|
||||
});
|
||||
if (form.submit)
|
||||
{
|
||||
PreOutTreatList.Add(preParam);
|
||||
detectionConfig.OUTPreTreatParams.Add(preParam);
|
||||
}
|
||||
}
|
||||
|
||||
@ -421,12 +410,11 @@ namespace DHSoftware.Views
|
||||
|
||||
if (e.Record is PreTreatParam PreTreat)
|
||||
{
|
||||
curPreTreat = PreTreat;
|
||||
switch (buttontext)
|
||||
{
|
||||
//暂不支持进入整行编辑,只支持指定单元格编辑,推荐使用弹窗或抽屉编辑整行数据
|
||||
case "编辑":
|
||||
var form = new PreTreatEdit(window, curPreTreat) { Size = new Size(500, 300) };
|
||||
var form = new PreTreatEdit(window, PreTreat) { Size = new Size(500, 300) };
|
||||
AntdUI.Drawer.open(new AntdUI.Drawer.Config(window, form)
|
||||
{
|
||||
OnLoad = () =>
|
||||
@ -442,7 +430,7 @@ namespace DHSoftware.Views
|
||||
case "删除":
|
||||
var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
|
||||
if (result == DialogResult.OK)
|
||||
PreTreatList.Remove(PreTreat);
|
||||
detectionConfig.PreTreatParams.Remove(PreTreat);
|
||||
break;
|
||||
|
||||
}
|
||||
@ -457,7 +445,7 @@ namespace DHSoftware.Views
|
||||
|
||||
private void BtnPreDelete_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (PreTreatList.Count == 0 || !PreTreatList.Any(x => x.Selected))
|
||||
if (detectionConfig.PreTreatParams.Count == 0 || !detectionConfig.PreTreatParams.Any(x => x.Selected))
|
||||
{
|
||||
AntdUI.Message.warn(window, "请选择要删除的行!", autoClose: 3);
|
||||
return;
|
||||
@ -467,12 +455,12 @@ namespace DHSoftware.Views
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
// 使用反转for循环删除主列表中选中的项
|
||||
for (int i = PreTreatList.Count - 1; i >= 0; i--)
|
||||
for (int i = detectionConfig.PreTreatParams.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// 删除选中的主列表项
|
||||
if (PreTreatList[i].Selected)
|
||||
if (detectionConfig.PreTreatParams[i].Selected)
|
||||
{
|
||||
PreTreatList.RemoveAt(i);
|
||||
detectionConfig.PreTreatParams.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
// 提示删除完成
|
||||
@ -496,41 +484,102 @@ namespace DHSoftware.Views
|
||||
});
|
||||
if (form.submit)
|
||||
{
|
||||
PreTreatList.Add(preParam);
|
||||
detectionConfig.PreTreatParams.Add(preParam);
|
||||
}
|
||||
}
|
||||
|
||||
AntList<PreTreatParam> PreTreatList;
|
||||
AntList<PreTreatParam> PreOutTreatList;
|
||||
AntList<DetectionLable> DetectionLableList;
|
||||
AntList<SizeTreatParam> SizeLableList;
|
||||
PreTreatParam curPreTreat;
|
||||
PreTreatParam curPreOutTreat;
|
||||
DetectionLable curDetectionLable;
|
||||
SizeTreatParam SizeParamLable;
|
||||
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
PreTreatList = new AntList<PreTreatParam>();
|
||||
|
||||
preTable.Binding(PreTreatList);
|
||||
|
||||
PreOutTreatList = new AntList<PreTreatParam>();
|
||||
|
||||
PreOutTable.Binding(PreOutTreatList);
|
||||
|
||||
|
||||
foreach (var item in MLModelTypes)
|
||||
stDetectType.Items.Clear();
|
||||
foreach (ModelType value in Enum.GetValues(typeof(ModelType)))
|
||||
{
|
||||
stDetectType.Items.Add(item.Key);
|
||||
stDetectType.Items.Add(value.ToString());
|
||||
}
|
||||
preTable.Binding(detectionConfig.PreTreatParams);
|
||||
PreOutTable.Binding(detectionConfig.OUTPreTreatParams);
|
||||
lableTable.Binding(detectionConfig.DetectionLableList);
|
||||
SizeTable.Binding(detectionConfig.SizeTreatParamList);
|
||||
|
||||
|
||||
if (detectionConfig.PreTreatParams.Count > 0)
|
||||
{
|
||||
foreach (var item in detectionConfig.PreTreatParams)
|
||||
{
|
||||
|
||||
item.CellLinks = new CellLink[] {
|
||||
new CellButton(Guid.NewGuid().ToString(), "编辑", TTypeMini.Primary) ,
|
||||
new CellButton(Guid.NewGuid().ToString(), "删除", TTypeMini.Error)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if (detectionConfig.OUTPreTreatParams.Count > 0)
|
||||
{
|
||||
foreach (var item in detectionConfig.OUTPreTreatParams)
|
||||
{
|
||||
|
||||
DetectionLableList = new AntList<DetectionLable>();
|
||||
item.CellLinks = new CellLink[] {
|
||||
new CellButton(Guid.NewGuid().ToString(), "编辑", TTypeMini.Primary) ,
|
||||
new CellButton(Guid.NewGuid().ToString(), "删除", TTypeMini.Error)
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
lableTable.Binding(DetectionLableList);
|
||||
if (detectionConfig.DetectionLableList.Count > 0)
|
||||
{
|
||||
foreach (var item in detectionConfig.DetectionLableList)
|
||||
{
|
||||
|
||||
SizeLableList = new AntList<SizeTreatParam>();
|
||||
SizeTable.Binding(SizeLableList);
|
||||
item.CellLinks = new CellLink[] {
|
||||
new CellButton(Guid.NewGuid().ToString(), "编辑", TTypeMini.Primary) ,
|
||||
new CellButton(Guid.NewGuid().ToString(), "删除", TTypeMini.Error)
|
||||
};
|
||||
}
|
||||
}
|
||||
if (detectionConfig.SizeTreatParamList.Count > 0)
|
||||
{
|
||||
foreach (var item in detectionConfig.SizeTreatParamList)
|
||||
{
|
||||
|
||||
item.CellLinks = new CellLink[] {
|
||||
new CellButton(Guid.NewGuid().ToString(), "编辑", TTypeMini.Primary) ,
|
||||
new CellButton(Guid.NewGuid().ToString(), "删除", TTypeMini.Error),
|
||||
new CellButton(Guid.NewGuid().ToString(),"进行测量",TTypeMini.Primary)
|
||||
};
|
||||
}
|
||||
}
|
||||
if (detectionConfig.CameraCollects.Count > 0)
|
||||
{
|
||||
foreach (var item in detectionConfig.CameraCollects)
|
||||
{
|
||||
var control = new AntdUI.Tag()
|
||||
{
|
||||
Font = new System.Drawing.Font("Microsoft YaHei UI", 9F),
|
||||
Size = new Size(90, 42),
|
||||
Text = item.CameraSourceId,
|
||||
CloseIcon = true
|
||||
};
|
||||
window.AutoDpi(control);
|
||||
flowCameraPanel.Controls.Add(control);
|
||||
control.BringToFront();
|
||||
}
|
||||
}
|
||||
//1
|
||||
sthPreStatus.DataBindings.Add("Checked", detectionConfig, "IsPreEnabled", true, DataSourceUpdateMode.OnPropertyChanged);
|
||||
iptPrePath.DataBindings.Add("Text", detectionConfig, "HalconAlgorithemPath_Pre", true, DataSourceUpdateMode.OnPropertyChanged);
|
||||
|
||||
//2
|
||||
sthDetectStatus.DataBindings.Add("Checked", detectionConfig, "IsEnabled", true, DataSourceUpdateMode.OnPropertyChanged);
|
||||
sthStation.DataBindings.Add("Checked", detectionConfig, "IsAddStation", true, DataSourceUpdateMode.OnPropertyChanged);
|
||||
stDetectType.DataBindings.Add("Text", detectionConfig, "ModelType",true, DataSourceUpdateMode.OnPropertyChanged);
|
||||
iptConfidence.DataBindings.Add("Text", detectionConfig, "ModelconfThreshold", true, DataSourceUpdateMode.OnPropertyChanged);
|
||||
iptDetectPath.DataBindings.Add("Text", detectionConfig, "ModelPath", true, DataSourceUpdateMode.OnPropertyChanged);
|
||||
sthOKOriginal.DataBindings.Add("Checked", detectionConfig, "SaveOKOriginal", true, DataSourceUpdateMode.OnPropertyChanged);
|
||||
sthNGOriginal.DataBindings.Add("Checked", detectionConfig, "SaveNGOriginal", true, DataSourceUpdateMode.OnPropertyChanged);
|
||||
sthOKDetect.DataBindings.Add("Checked", detectionConfig, "SaveOKDetect", true, DataSourceUpdateMode.OnPropertyChanged);
|
||||
sthDetectNG.DataBindings.Add("Checked", detectionConfig, "SaveNGDetect", true, DataSourceUpdateMode.OnPropertyChanged);
|
||||
|
||||
}
|
||||
|
||||
@ -590,7 +639,7 @@ namespace DHSoftware.Views
|
||||
{
|
||||
string filePath = openFileDialog.FileName;
|
||||
|
||||
iptPath.Text = filePath;
|
||||
iptPrePath.Text = filePath;
|
||||
|
||||
}
|
||||
}
|
||||
@ -600,31 +649,11 @@ namespace DHSoftware.Views
|
||||
|
||||
|
||||
|
||||
List<KeyValuePair<string, int>> MLModelTypes = GetFilteredEnumDescriptionsAndValues<MLModelType>();
|
||||
List<KeyValuePair<string, int>> SizeEnum = GetFilteredEnumDescriptionsAndValues<SizeEnum>();
|
||||
|
||||
|
||||
private void tabPage2_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static List<KeyValuePair<string, int>> GetFilteredEnumDescriptionsAndValues<T>() where T : Enum
|
||||
{
|
||||
return Enum.GetValues(typeof(T))
|
||||
.Cast<T>()
|
||||
.Select(e =>
|
||||
{
|
||||
// 获取枚举的 Description 属性,如果没有,则使用枚举的名称
|
||||
var description = e.GetType()
|
||||
.GetField(e.ToString())
|
||||
?.GetCustomAttribute<DescriptionAttribute>()
|
||||
?.Description ?? e.ToString();
|
||||
|
||||
// 返回枚举的描述和对应的整数值
|
||||
return new KeyValuePair<string, int>(description, Convert.ToInt32(e));
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
@ -48,7 +48,7 @@
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
@ -129,7 +129,7 @@
|
||||
<data name="btnPreAdd.IconSvg" xml:space="preserve">
|
||||
<value><svg t="1741939836774" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="21349" width="200" height="200"><path d="M1003.153333 404.96a52.933333 52.933333 0 0 0-42.38-20.96H896V266.666667a53.393333 53.393333 0 0 0-53.333333-53.333334H461.253333a10.573333 10.573333 0 0 1-7.54-3.126666L344.46 100.953333A52.986667 52.986667 0 0 0 306.746667 85.333333H53.333333a53.393333 53.393333 0 0 0-53.333333 53.333334v704a53.393333 53.393333 0 0 0 53.333333 53.333333h796.893334a53.453333 53.453333 0 0 0 51.453333-39.333333l110.546667-405.333334a52.953333 52.953333 0 0 0-9.073334-46.373333zM53.333333 128h253.413334a10.573333 10.573333 0 0 1 7.54 3.126667l109.253333 109.253333A52.986667 52.986667 0 0 0 461.253333 256H842.666667a10.666667 10.666667 0 0 1 10.666666 10.666667v117.333333H173.773333a53.453333 53.453333 0 0 0-51.453333 39.333333L42.666667 715.366667V138.666667a10.666667 10.666667 0 0 1 10.666666-10.666667zm917.726667 312.14l-110.546667 405.333333a10.666667 10.666667 0 0 1-10.286666 7.86H63.226667a10.666667 10.666667 0 0 1-10.286667-13.473333l110.546667-405.333333A10.666667 10.666667 0 0 1 173.773333 426.666667h787a10.666667 10.666667 0 0 1 10.286667 13.473333z" fill="#5C5C66" p-id="21350"/></svg></value>
|
||||
</data>
|
||||
<data name="btnPath.IconSvg" xml:space="preserve">
|
||||
<data name="btnPrePath.IconSvg" xml:space="preserve">
|
||||
<value><svg t="1741939836774" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="21349" width="200" height="200"><path d="M1003.153333 404.96a52.933333 52.933333 0 0 0-42.38-20.96H896V266.666667a53.393333 53.393333 0 0 0-53.333333-53.333334H461.253333a10.573333 10.573333 0 0 1-7.54-3.126666L344.46 100.953333A52.986667 52.986667 0 0 0 306.746667 85.333333H53.333333a53.393333 53.393333 0 0 0-53.333333 53.333334v704a53.393333 53.393333 0 0 0 53.333333 53.333333h796.893334a53.453333 53.453333 0 0 0 51.453333-39.333333l110.546667-405.333334a52.953333 52.953333 0 0 0-9.073334-46.373333zM53.333333 128h253.413334a10.573333 10.573333 0 0 1 7.54 3.126667l109.253333 109.253333A52.986667 52.986667 0 0 0 461.253333 256H842.666667a10.666667 10.666667 0 0 1 10.666666 10.666667v117.333333H173.773333a53.453333 53.453333 0 0 0-51.453333 39.333333L42.666667 715.366667V138.666667a10.666667 10.666667 0 0 1 10.666666-10.666667zm917.726667 312.14l-110.546667 405.333333a10.666667 10.666667 0 0 1-10.286666 7.86H63.226667a10.666667 10.666667 0 0 1-10.286667-13.473333l110.546667-405.333333A10.666667 10.666667 0 0 1 173.773333 426.666667h787a10.666667 10.666667 0 0 1 10.286667 13.473333z" fill="#5C5C66" p-id="21350"/></svg></value>
|
||||
</data>
|
||||
<data name="btnLableDelete.IconSvg" xml:space="preserve">
|
||||
|
@ -3,6 +3,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Reflection;
|
||||
using AntdUI;
|
||||
using DH.Commons.Base;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Vision;
|
||||
using static System.Windows.Forms.AxHost;
|
||||
|
422
DHSoftware/Views/MotionControl.Designer.cs
generated
Normal file
422
DHSoftware/Views/MotionControl.Designer.cs
generated
Normal file
@ -0,0 +1,422 @@
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
partial class MotionControl
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
stackPanel2 = new AntdUI.StackPanel();
|
||||
swhEnable = new AntdUI.Switch();
|
||||
label4 = new AntdUI.Label();
|
||||
stackPanel3 = new AntdUI.StackPanel();
|
||||
sltTpye = new AntdUI.Select();
|
||||
label1 = new AntdUI.Label();
|
||||
stpCom = new AntdUI.StackPanel();
|
||||
cmbCom = new AntdUI.Select();
|
||||
label2 = new AntdUI.Label();
|
||||
stackPanel1 = new AntdUI.StackPanel();
|
||||
stpPort = new AntdUI.StackPanel();
|
||||
iptPort = new AntdUI.Input();
|
||||
label9 = new AntdUI.Label();
|
||||
stpIP = new AntdUI.StackPanel();
|
||||
iptIP = new AntdUI.Input();
|
||||
label8 = new AntdUI.Label();
|
||||
stpParity = new AntdUI.StackPanel();
|
||||
cmbParity = new AntdUI.Select();
|
||||
label7 = new AntdUI.Label();
|
||||
stpStop = new AntdUI.StackPanel();
|
||||
cmbStopBits = new AntdUI.Select();
|
||||
label6 = new AntdUI.Label();
|
||||
stpData = new AntdUI.StackPanel();
|
||||
cmbDataBits = new AntdUI.Select();
|
||||
label5 = new AntdUI.Label();
|
||||
stpBaud = new AntdUI.StackPanel();
|
||||
cmbBaudRate = new AntdUI.Select();
|
||||
label3 = new AntdUI.Label();
|
||||
PLCItemsTable = new AntdUI.Table();
|
||||
btnDelete = new AntdUI.Button();
|
||||
btnAdd = new AntdUI.Button();
|
||||
stackPanel2.SuspendLayout();
|
||||
stackPanel3.SuspendLayout();
|
||||
stpCom.SuspendLayout();
|
||||
stackPanel1.SuspendLayout();
|
||||
stpPort.SuspendLayout();
|
||||
stpIP.SuspendLayout();
|
||||
stpParity.SuspendLayout();
|
||||
stpStop.SuspendLayout();
|
||||
stpData.SuspendLayout();
|
||||
stpBaud.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// stackPanel2
|
||||
//
|
||||
stackPanel2.Controls.Add(swhEnable);
|
||||
stackPanel2.Controls.Add(label4);
|
||||
stackPanel2.Dock = DockStyle.Top;
|
||||
stackPanel2.Location = new Point(3, 3);
|
||||
stackPanel2.Name = "stackPanel2";
|
||||
stackPanel2.Size = new Size(217, 43);
|
||||
stackPanel2.TabIndex = 0;
|
||||
stackPanel2.Text = "stackPanel2";
|
||||
//
|
||||
// swhEnable
|
||||
//
|
||||
swhEnable.CheckedText = "启用";
|
||||
swhEnable.Location = new Point(68, 3);
|
||||
swhEnable.Name = "swhEnable";
|
||||
swhEnable.Size = new Size(93, 37);
|
||||
swhEnable.TabIndex = 25;
|
||||
swhEnable.UnCheckedText = "关闭";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.Location = new Point(3, 3);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(59, 37);
|
||||
label4.TabIndex = 24;
|
||||
label4.Text = "状 态";
|
||||
//
|
||||
// stackPanel3
|
||||
//
|
||||
stackPanel3.Controls.Add(sltTpye);
|
||||
stackPanel3.Controls.Add(label1);
|
||||
stackPanel3.Dock = DockStyle.Top;
|
||||
stackPanel3.Location = new Point(3, 52);
|
||||
stackPanel3.Name = "stackPanel3";
|
||||
stackPanel3.Size = new Size(217, 43);
|
||||
stackPanel3.TabIndex = 1;
|
||||
stackPanel3.Text = "stackPanel3";
|
||||
//
|
||||
// sltTpye
|
||||
//
|
||||
sltTpye.List = true;
|
||||
sltTpye.Location = new Point(68, 3);
|
||||
sltTpye.Name = "sltTpye";
|
||||
sltTpye.Size = new Size(129, 37);
|
||||
sltTpye.TabIndex = 25;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.Location = new Point(3, 3);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(59, 37);
|
||||
label1.TabIndex = 24;
|
||||
label1.Text = "类 型";
|
||||
//
|
||||
// stpCom
|
||||
//
|
||||
stpCom.Controls.Add(cmbCom);
|
||||
stpCom.Controls.Add(label2);
|
||||
stpCom.Dock = DockStyle.Top;
|
||||
stpCom.Location = new Point(3, 101);
|
||||
stpCom.Name = "stpCom";
|
||||
stpCom.Size = new Size(217, 43);
|
||||
stpCom.TabIndex = 2;
|
||||
stpCom.Text = "stackPanel4";
|
||||
//
|
||||
// cmbCom
|
||||
//
|
||||
cmbCom.List = true;
|
||||
cmbCom.Location = new Point(68, 3);
|
||||
cmbCom.Name = "cmbCom";
|
||||
cmbCom.Size = new Size(129, 37);
|
||||
cmbCom.TabIndex = 25;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.Location = new Point(3, 3);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(59, 37);
|
||||
label2.TabIndex = 24;
|
||||
label2.Text = "串 口";
|
||||
//
|
||||
// stackPanel1
|
||||
//
|
||||
stackPanel1.Controls.Add(stpPort);
|
||||
stackPanel1.Controls.Add(stpIP);
|
||||
stackPanel1.Controls.Add(stpParity);
|
||||
stackPanel1.Controls.Add(stpStop);
|
||||
stackPanel1.Controls.Add(stpData);
|
||||
stackPanel1.Controls.Add(stpBaud);
|
||||
stackPanel1.Controls.Add(stpCom);
|
||||
stackPanel1.Controls.Add(stackPanel3);
|
||||
stackPanel1.Controls.Add(stackPanel2);
|
||||
stackPanel1.Location = new Point(19, 16);
|
||||
stackPanel1.Name = "stackPanel1";
|
||||
stackPanel1.Size = new Size(223, 478);
|
||||
stackPanel1.TabIndex = 25;
|
||||
stackPanel1.Text = "stackPanel1";
|
||||
stackPanel1.Vertical = true;
|
||||
//
|
||||
// stpPort
|
||||
//
|
||||
stpPort.Controls.Add(iptPort);
|
||||
stpPort.Controls.Add(label9);
|
||||
stpPort.Dock = DockStyle.Top;
|
||||
stpPort.Location = new Point(3, 395);
|
||||
stpPort.Name = "stpPort";
|
||||
stpPort.Size = new Size(217, 43);
|
||||
stpPort.TabIndex = 14;
|
||||
stpPort.Text = "stackPanel10";
|
||||
//
|
||||
// iptPort
|
||||
//
|
||||
iptPort.Location = new Point(68, 3);
|
||||
iptPort.Name = "iptPort";
|
||||
iptPort.Size = new Size(129, 37);
|
||||
iptPort.TabIndex = 26;
|
||||
//
|
||||
// label9
|
||||
//
|
||||
label9.Location = new Point(3, 3);
|
||||
label9.Name = "label9";
|
||||
label9.Size = new Size(59, 37);
|
||||
label9.TabIndex = 24;
|
||||
label9.Text = "端 口 号";
|
||||
//
|
||||
// stpIP
|
||||
//
|
||||
stpIP.Controls.Add(iptIP);
|
||||
stpIP.Controls.Add(label8);
|
||||
stpIP.Dock = DockStyle.Top;
|
||||
stpIP.Location = new Point(3, 346);
|
||||
stpIP.Name = "stpIP";
|
||||
stpIP.Size = new Size(217, 43);
|
||||
stpIP.TabIndex = 13;
|
||||
stpIP.Text = "stackPanel9";
|
||||
//
|
||||
// iptIP
|
||||
//
|
||||
iptIP.Location = new Point(68, 3);
|
||||
iptIP.Name = "iptIP";
|
||||
iptIP.Size = new Size(129, 37);
|
||||
iptIP.TabIndex = 25;
|
||||
//
|
||||
// label8
|
||||
//
|
||||
label8.Location = new Point(3, 3);
|
||||
label8.Name = "label8";
|
||||
label8.Size = new Size(59, 37);
|
||||
label8.TabIndex = 24;
|
||||
label8.Text = "I P 地 址";
|
||||
//
|
||||
// stpParity
|
||||
//
|
||||
stpParity.Controls.Add(cmbParity);
|
||||
stpParity.Controls.Add(label7);
|
||||
stpParity.Dock = DockStyle.Top;
|
||||
stpParity.Location = new Point(3, 297);
|
||||
stpParity.Name = "stpParity";
|
||||
stpParity.Size = new Size(217, 43);
|
||||
stpParity.TabIndex = 12;
|
||||
stpParity.Text = "stackPanel8";
|
||||
//
|
||||
// cmbParity
|
||||
//
|
||||
cmbParity.List = true;
|
||||
cmbParity.Location = new Point(68, 3);
|
||||
cmbParity.Name = "cmbParity";
|
||||
cmbParity.Size = new Size(129, 37);
|
||||
cmbParity.TabIndex = 25;
|
||||
//
|
||||
// label7
|
||||
//
|
||||
label7.Location = new Point(3, 3);
|
||||
label7.Name = "label7";
|
||||
label7.Size = new Size(59, 37);
|
||||
label7.TabIndex = 24;
|
||||
label7.Text = "校 验 位";
|
||||
//
|
||||
// stpStop
|
||||
//
|
||||
stpStop.Controls.Add(cmbStopBits);
|
||||
stpStop.Controls.Add(label6);
|
||||
stpStop.Dock = DockStyle.Top;
|
||||
stpStop.Location = new Point(3, 248);
|
||||
stpStop.Name = "stpStop";
|
||||
stpStop.Size = new Size(217, 43);
|
||||
stpStop.TabIndex = 11;
|
||||
stpStop.Text = "stackPanel7";
|
||||
//
|
||||
// cmbStopBits
|
||||
//
|
||||
cmbStopBits.List = true;
|
||||
cmbStopBits.Location = new Point(68, 3);
|
||||
cmbStopBits.Name = "cmbStopBits";
|
||||
cmbStopBits.Size = new Size(129, 37);
|
||||
cmbStopBits.TabIndex = 25;
|
||||
//
|
||||
// label6
|
||||
//
|
||||
label6.Location = new Point(3, 3);
|
||||
label6.Name = "label6";
|
||||
label6.Size = new Size(59, 37);
|
||||
label6.TabIndex = 24;
|
||||
label6.Text = "停 止 位";
|
||||
//
|
||||
// stpData
|
||||
//
|
||||
stpData.Controls.Add(cmbDataBits);
|
||||
stpData.Controls.Add(label5);
|
||||
stpData.Dock = DockStyle.Top;
|
||||
stpData.Location = new Point(3, 199);
|
||||
stpData.Name = "stpData";
|
||||
stpData.Size = new Size(217, 43);
|
||||
stpData.TabIndex = 10;
|
||||
stpData.Text = "stackPanel6";
|
||||
//
|
||||
// cmbDataBits
|
||||
//
|
||||
cmbDataBits.List = true;
|
||||
cmbDataBits.Location = new Point(68, 3);
|
||||
cmbDataBits.Name = "cmbDataBits";
|
||||
cmbDataBits.Size = new Size(129, 37);
|
||||
cmbDataBits.TabIndex = 25;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.Location = new Point(3, 3);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(59, 37);
|
||||
label5.TabIndex = 24;
|
||||
label5.Text = "数 据 位";
|
||||
//
|
||||
// stpBaud
|
||||
//
|
||||
stpBaud.Controls.Add(cmbBaudRate);
|
||||
stpBaud.Controls.Add(label3);
|
||||
stpBaud.Dock = DockStyle.Top;
|
||||
stpBaud.Location = new Point(3, 150);
|
||||
stpBaud.Name = "stpBaud";
|
||||
stpBaud.Size = new Size(217, 43);
|
||||
stpBaud.TabIndex = 9;
|
||||
stpBaud.Text = "stackPanel5";
|
||||
//
|
||||
// cmbBaudRate
|
||||
//
|
||||
cmbBaudRate.List = true;
|
||||
cmbBaudRate.Location = new Point(68, 3);
|
||||
cmbBaudRate.Name = "cmbBaudRate";
|
||||
cmbBaudRate.Size = new Size(129, 37);
|
||||
cmbBaudRate.TabIndex = 25;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.Location = new Point(3, 3);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(59, 37);
|
||||
label3.TabIndex = 24;
|
||||
label3.Text = "波 特 率";
|
||||
//
|
||||
// PLCItemsTable
|
||||
//
|
||||
PLCItemsTable.EmptyHeader = true;
|
||||
PLCItemsTable.Location = new Point(238, 71);
|
||||
PLCItemsTable.Name = "PLCItemsTable";
|
||||
PLCItemsTable.Size = new Size(634, 392);
|
||||
PLCItemsTable.TabIndex = 26;
|
||||
PLCItemsTable.Text = "table1";
|
||||
//
|
||||
// btnDelete
|
||||
//
|
||||
btnDelete.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
btnDelete.Location = new Point(331, 27);
|
||||
btnDelete.Name = "btnDelete";
|
||||
btnDelete.Size = new Size(80, 32);
|
||||
btnDelete.TabIndex = 28;
|
||||
btnDelete.Text = "删除";
|
||||
btnDelete.Type = AntdUI.TTypeMini.Error;
|
||||
btnDelete.WaveSize = 0;
|
||||
//
|
||||
// btnAdd
|
||||
//
|
||||
btnAdd.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
btnAdd.Location = new Point(245, 27);
|
||||
btnAdd.Name = "btnAdd";
|
||||
btnAdd.Size = new Size(80, 32);
|
||||
btnAdd.TabIndex = 27;
|
||||
btnAdd.Text = "新增";
|
||||
btnAdd.Type = AntdUI.TTypeMini.Primary;
|
||||
btnAdd.WaveSize = 0;
|
||||
//
|
||||
// MotionControl
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(btnDelete);
|
||||
Controls.Add(btnAdd);
|
||||
Controls.Add(PLCItemsTable);
|
||||
Controls.Add(stackPanel1);
|
||||
Name = "MotionControl";
|
||||
Size = new Size(898, 530);
|
||||
stackPanel2.ResumeLayout(false);
|
||||
stackPanel3.ResumeLayout(false);
|
||||
stpCom.ResumeLayout(false);
|
||||
stackPanel1.ResumeLayout(false);
|
||||
stpPort.ResumeLayout(false);
|
||||
stpIP.ResumeLayout(false);
|
||||
stpParity.ResumeLayout(false);
|
||||
stpStop.ResumeLayout(false);
|
||||
stpData.ResumeLayout(false);
|
||||
stpBaud.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private AntdUI.StackPanel stackPanel2;
|
||||
private AntdUI.Label label4;
|
||||
private AntdUI.StackPanel stackPanel3;
|
||||
private AntdUI.Select sltTpye;
|
||||
private AntdUI.Label label1;
|
||||
private AntdUI.StackPanel stpCom;
|
||||
private AntdUI.Select cmbCom;
|
||||
private AntdUI.Label label2;
|
||||
private AntdUI.StackPanel stackPanel1;
|
||||
private AntdUI.Switch swhEnable;
|
||||
private AntdUI.StackPanel stpPort;
|
||||
private AntdUI.Input iptPort;
|
||||
private AntdUI.Label label9;
|
||||
private AntdUI.StackPanel stpIP;
|
||||
private AntdUI.Input iptIP;
|
||||
private AntdUI.Label label8;
|
||||
private AntdUI.StackPanel stpParity;
|
||||
private AntdUI.Select cmbParity;
|
||||
private AntdUI.Label label7;
|
||||
private AntdUI.StackPanel stpStop;
|
||||
private AntdUI.Select cmbStopBits;
|
||||
private AntdUI.Label label6;
|
||||
private AntdUI.StackPanel stpData;
|
||||
private AntdUI.Select cmbDataBits;
|
||||
private AntdUI.Label label5;
|
||||
private AntdUI.StackPanel stpBaud;
|
||||
private AntdUI.Select cmbBaudRate;
|
||||
private AntdUI.Label label3;
|
||||
private AntdUI.Table PLCItemsTable;
|
||||
private AntdUI.Button btnDelete;
|
||||
private AntdUI.Button btnAdd;
|
||||
}
|
||||
}
|
304
DHSoftware/Views/MotionControl.cs
Normal file
304
DHSoftware/Views/MotionControl.cs
Normal file
@ -0,0 +1,304 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using AntdUI;
|
||||
using DH.Commons.Base;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.PLC;
|
||||
using XKRS.CanFly;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
public partial class MotionControl : UserControl
|
||||
{
|
||||
Window window;
|
||||
PLCBase pLCBase;
|
||||
public MotionControl(Window _window,PLCBase _pLCBase)
|
||||
{
|
||||
window= _window;
|
||||
pLCBase= _pLCBase;
|
||||
InitializeComponent();
|
||||
BindEventHandler();
|
||||
InitData();
|
||||
SetupDataBindings();
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void BindEventHandler()
|
||||
{
|
||||
sltTpye.TextChanged += SltTpye_TextChanged;
|
||||
btnAdd.Click += BtnAdd_Click;
|
||||
btnDelete.Click += BtnDelete_Click;
|
||||
PLCItemsTable.CellButtonClick += PLCItemsTable_CellButtonClick; ;
|
||||
}
|
||||
|
||||
private void PLCItemsTable_CellButtonClick(object sender, TableButtonEventArgs e)
|
||||
{
|
||||
var buttontext = e.Btn.Text;
|
||||
|
||||
if (e.Record is PLCItem pLCItem)
|
||||
{
|
||||
switch (buttontext)
|
||||
{
|
||||
//暂不支持进入整行编辑,只支持指定单元格编辑,推荐使用弹窗或抽屉编辑整行数据
|
||||
case "编辑":
|
||||
var form = new MotionEdit(window, pLCItem) { Size = new Size(500, 300) };
|
||||
AntdUI.Drawer.open(new AntdUI.Drawer.Config(window, form)
|
||||
{
|
||||
OnLoad = () =>
|
||||
{
|
||||
AntdUI.Message.info(window, "进入编辑", autoClose: 1);
|
||||
},
|
||||
OnClose = () =>
|
||||
{
|
||||
pLCItem.CellTags = new CellTag[] { };
|
||||
var tempList = pLCItem.CellTags.ToList();
|
||||
|
||||
if (pLCItem.StartExecute)
|
||||
{
|
||||
var newTag = new CellTag($"ON_{pLCItem.StartIndex}", TTypeMini.Primary);
|
||||
tempList.Add(newTag);
|
||||
}
|
||||
if (pLCItem.EndExecute)
|
||||
{
|
||||
var newTag = new CellTag($"OFF_{pLCItem.EndIndex}", TTypeMini.Warn);
|
||||
tempList.Add(newTag);
|
||||
}
|
||||
|
||||
// 重新赋值回数组
|
||||
pLCItem.CellTags = tempList.ToArray();
|
||||
AntdUI.Message.info(window, "结束编辑", autoClose: 1);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "删除":
|
||||
var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
pLCBase.PLCItemList.Remove(pLCItem);
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnDelete_Click(object? sender, EventArgs e)
|
||||
{
|
||||
if (pLCBase.PLCItemList.Count == 0 || !pLCBase.PLCItemList.Any(x => x.Selected))
|
||||
{
|
||||
AntdUI.Message.warn(window, "请选择要删除的行!", autoClose: 3);
|
||||
return;
|
||||
}
|
||||
|
||||
var result = Modal.open(window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
// 使用反转for循环删除主列表中选中的项
|
||||
for (int i = pLCBase.PLCItemList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// 删除选中的主列表项
|
||||
if (pLCBase.PLCItemList[i].Selected)
|
||||
{
|
||||
pLCBase.PLCItemList.RemoveAt(i);
|
||||
}
|
||||
}
|
||||
// 提示删除完成
|
||||
AntdUI.Message.success(window, "删除成功!", autoClose: 3);
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnAdd_Click(object? sender, EventArgs e)
|
||||
{
|
||||
PLCItem pLCItem = new PLCItem()
|
||||
{
|
||||
CellLinks = new CellLink[]
|
||||
{
|
||||
new CellButton(Guid.NewGuid().ToString(), "编辑", TTypeMini.Primary),
|
||||
new CellButton(Guid.NewGuid().ToString(), "删除", TTypeMini.Error)
|
||||
}
|
||||
};
|
||||
|
||||
var form = new MotionEdit(window, pLCItem) { Size = new Size(450, 550) };
|
||||
AntdUI.Modal.open(new AntdUI.Modal.Config(window, "", form, TType.None)
|
||||
{
|
||||
BtnHeight = 0,
|
||||
});
|
||||
|
||||
if (form.submit)
|
||||
{
|
||||
pLCItem.CellTags = new CellTag[] { };
|
||||
var tempList = pLCItem.CellTags.ToList();
|
||||
|
||||
if (pLCItem.StartExecute)
|
||||
{
|
||||
var newTag = new CellTag($"ON_{pLCItem.StartIndex}", TTypeMini.Primary);
|
||||
tempList.Add(newTag);
|
||||
}
|
||||
if (pLCItem.EndExecute)
|
||||
{
|
||||
var newTag = new CellTag($"OFF_{pLCItem.EndIndex}", TTypeMini.Warn);
|
||||
tempList.Add(newTag);
|
||||
}
|
||||
|
||||
// 重新赋值回数组
|
||||
pLCItem.CellTags = tempList.ToArray();
|
||||
|
||||
pLCBase.PLCItemList.Add(pLCItem);
|
||||
}
|
||||
}
|
||||
|
||||
private void SltTpye_TextChanged(object? sender, EventArgs e)
|
||||
{
|
||||
if (sender is Select slt && !string.IsNullOrEmpty(slt.Text))
|
||||
{
|
||||
// 将文本转换为枚举值
|
||||
if (Enum.TryParse<EnumPLCType>(slt.Text, out var plcType))
|
||||
{
|
||||
switch (plcType)
|
||||
{
|
||||
case EnumPLCType.信捷XC网口:
|
||||
case EnumPLCType.信捷XD网口:
|
||||
stpCom.Visible = false;
|
||||
stpBaud.Visible = false;
|
||||
stpData.Visible = false;
|
||||
stpParity.Visible = false;
|
||||
stpStop.Visible = false;
|
||||
stpIP.Visible = true;
|
||||
stpPort.Visible = true;
|
||||
break;
|
||||
|
||||
case EnumPLCType.信捷XD串口:
|
||||
case EnumPLCType.信捷XC串口:
|
||||
stpCom.Visible = true;
|
||||
stpBaud.Visible = true;
|
||||
stpData.Visible = true;
|
||||
stpParity.Visible = true;
|
||||
stpStop.Visible = true;
|
||||
stpIP.Visible = false;
|
||||
stpPort.Visible = false;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
// 获取枚举字段名列表(原描述改为字段名)
|
||||
sltTpye.Items.Clear();
|
||||
foreach (EnumPLCType value in Enum.GetValues(typeof(EnumPLCType)))
|
||||
{
|
||||
sltTpye.Items.Add(value.ToString());
|
||||
}
|
||||
|
||||
// 波特率选项(保持不变)
|
||||
cmbBaudRate.Items.AddRange(new object[] { 300, 600, 1200, 2400, 4800, 9600, 14400, 19200, 38400, 57600, 115200 });
|
||||
|
||||
// 数据位选项(保持不变)
|
||||
cmbDataBits.Items.AddRange(new object[] { 5, 6, 7, 8 });
|
||||
|
||||
// 停止位选项改为字段名
|
||||
var stopBitsNames = Enum.GetNames(typeof(StopBits));
|
||||
foreach (var name in stopBitsNames)
|
||||
{
|
||||
cmbStopBits.Items.Add(name);
|
||||
}
|
||||
|
||||
// 校验位选项改为字段名
|
||||
var parityNames = Enum.GetNames(typeof(Parity));
|
||||
foreach (var name in parityNames)
|
||||
{
|
||||
cmbParity.Items.Add(name);
|
||||
}
|
||||
|
||||
// COM端口列表(保持不变)
|
||||
List<string> comList = SerialPort.GetPortNames().ToList();
|
||||
foreach (var item in comList)
|
||||
{
|
||||
cmbCom.Items.Add(item);
|
||||
}
|
||||
|
||||
PLCItemsTable.Columns = new ColumnCollection() {
|
||||
new ColumnCheck("Selected"){Fixed = true},
|
||||
new Column("Name", "名称", ColumnAlign.Center),
|
||||
new Column("Type", "类型",ColumnAlign.Center),
|
||||
new Column("Address", "地址",ColumnAlign.Center),
|
||||
new Column("Value", "值",ColumnAlign.Center),
|
||||
new Column("CellTags", "标签",ColumnAlign.Center),
|
||||
new Column("CellLinks", "操作", ColumnAlign.Center)
|
||||
};
|
||||
if (pLCBase.PLCItemList.Count > 0)
|
||||
{
|
||||
foreach( var item in pLCBase.PLCItemList)
|
||||
{
|
||||
item.CellTags = new CellTag[] { };
|
||||
var tempList = item.CellTags.ToList();
|
||||
|
||||
if (item.StartExecute)
|
||||
{
|
||||
var newTag = new CellTag($"ON_{item.StartIndex}", TTypeMini.Primary);
|
||||
tempList.Add(newTag);
|
||||
}
|
||||
if (item.EndExecute)
|
||||
{
|
||||
var newTag = new CellTag($"OFF_{item.EndIndex}", TTypeMini.Warn);
|
||||
tempList.Add(newTag);
|
||||
}
|
||||
|
||||
// 重新赋值回数组
|
||||
item.CellTags = tempList.ToArray();
|
||||
|
||||
|
||||
|
||||
item.CellLinks = new CellLink[] {
|
||||
new CellButton(Guid.NewGuid().ToString(), "编辑", TTypeMini.Primary) ,
|
||||
new CellButton(Guid.NewGuid().ToString(), "删除", TTypeMini.Error)
|
||||
};
|
||||
}
|
||||
}
|
||||
PLCItemsTable.Binding(pLCBase.PLCItemList);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void SetupDataBindings()
|
||||
{
|
||||
// 添加双向类型转换
|
||||
sltTpye.DataBindings.Add("Text", pLCBase, "PLCType", true, DataSourceUpdateMode.OnPropertyChanged, "");
|
||||
cmbCom.DataBindings.Add(nameof(cmbCom.Text), pLCBase, nameof(pLCBase.COM));
|
||||
cmbBaudRate.DataBindings.Add(nameof(cmbBaudRate.Text), pLCBase, nameof(pLCBase.BaudRate));
|
||||
cmbDataBits.DataBindings.Add(nameof(cmbDataBits.Text), pLCBase, nameof(pLCBase.DataBit));
|
||||
cmbParity.DataBindings.Add(nameof(cmbParity.Text), pLCBase, nameof(pLCBase.Parity));
|
||||
cmbStopBits.DataBindings.Add(nameof(cmbStopBits.Text), pLCBase, nameof(pLCBase.StopBit));
|
||||
|
||||
iptIP.DataBindings.Add(nameof(iptIP.Text), pLCBase, nameof(pLCBase.IP));
|
||||
iptPort.DataBindings.Add(nameof(iptPort.Text), pLCBase, nameof(pLCBase.Port));
|
||||
|
||||
swhEnable.DataBindings.Add(nameof(swhEnable.Checked),pLCBase, nameof(pLCBase.Enable));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
392
DHSoftware/Views/MotionEdit.Designer.cs
generated
Normal file
392
DHSoftware/Views/MotionEdit.Designer.cs
generated
Normal file
@ -0,0 +1,392 @@
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
partial class MotionEdit
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
button_cancel = new AntdUI.Button();
|
||||
sltName = new AntdUI.Select();
|
||||
label2 = new AntdUI.Label();
|
||||
divider2 = new AntdUI.Divider();
|
||||
stackPanel1 = new AntdUI.StackPanel();
|
||||
button_ok = new AntdUI.Button();
|
||||
divider1 = new AntdUI.Divider();
|
||||
label1 = new AntdUI.Label();
|
||||
panel1 = new AntdUI.Panel();
|
||||
sltDataType = new AntdUI.Select();
|
||||
label3 = new AntdUI.Label();
|
||||
iptAddress = new AntdUI.Input();
|
||||
label7 = new AntdUI.Label();
|
||||
stackPanel3 = new AntdUI.StackPanel();
|
||||
iptEndIndex = new AntdUI.Input();
|
||||
sltEnd = new AntdUI.Select();
|
||||
label6 = new AntdUI.Label();
|
||||
stackPanel2 = new AntdUI.StackPanel();
|
||||
iptStartIndex = new AntdUI.Input();
|
||||
sltStart = new AntdUI.Select();
|
||||
label5 = new AntdUI.Label();
|
||||
sltBoolValue = new AntdUI.Select();
|
||||
stpNum = new AntdUI.StackPanel();
|
||||
sltIntType = new AntdUI.Select();
|
||||
iptValue = new AntdUI.Input();
|
||||
label4 = new AntdUI.Label();
|
||||
stackPanel1.SuspendLayout();
|
||||
panel1.SuspendLayout();
|
||||
stackPanel3.SuspendLayout();
|
||||
stackPanel2.SuspendLayout();
|
||||
stpNum.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// 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 = "取消";
|
||||
//
|
||||
// sltName
|
||||
//
|
||||
sltName.Dock = DockStyle.Top;
|
||||
sltName.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
sltName.Location = new Point(18, 134);
|
||||
sltName.MaxCount = 10;
|
||||
sltName.Name = "sltName";
|
||||
sltName.Radius = 3;
|
||||
sltName.Size = new Size(409, 38);
|
||||
sltName.TabIndex = 23;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.Dock = DockStyle.Top;
|
||||
label2.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
label2.Location = new Point(18, 110);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(409, 24);
|
||||
label2.TabIndex = 22;
|
||||
label2.Text = "名称";
|
||||
//
|
||||
// divider2
|
||||
//
|
||||
divider2.Dock = DockStyle.Top;
|
||||
divider2.Location = new Point(18, 98);
|
||||
divider2.Name = "divider2";
|
||||
divider2.Size = new Size(409, 12);
|
||||
divider2.TabIndex = 21;
|
||||
//
|
||||
// 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(409, 44);
|
||||
stackPanel1.TabIndex = 20;
|
||||
stackPanel1.Text = "stackPanel1";
|
||||
//
|
||||
// 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;
|
||||
//
|
||||
// divider1
|
||||
//
|
||||
divider1.Dock = DockStyle.Top;
|
||||
divider1.Location = new Point(18, 42);
|
||||
divider1.Name = "divider1";
|
||||
divider1.Size = new Size(409, 12);
|
||||
divider1.TabIndex = 19;
|
||||
//
|
||||
// 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(409, 24);
|
||||
label1.TabIndex = 17;
|
||||
label1.Text = "PLC点位操作";
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(stackPanel3);
|
||||
panel1.Controls.Add(label6);
|
||||
panel1.Controls.Add(stackPanel2);
|
||||
panel1.Controls.Add(label5);
|
||||
panel1.Controls.Add(sltBoolValue);
|
||||
panel1.Controls.Add(stpNum);
|
||||
panel1.Controls.Add(label4);
|
||||
panel1.Controls.Add(iptAddress);
|
||||
panel1.Controls.Add(label7);
|
||||
panel1.Controls.Add(sltDataType);
|
||||
panel1.Controls.Add(label3);
|
||||
panel1.Controls.Add(sltName);
|
||||
panel1.Controls.Add(label2);
|
||||
panel1.Controls.Add(divider2);
|
||||
panel1.Controls.Add(stackPanel1);
|
||||
panel1.Controls.Add(divider1);
|
||||
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(445, 572);
|
||||
panel1.TabIndex = 1;
|
||||
panel1.Text = "panel1";
|
||||
|
||||
//
|
||||
// sltDataType
|
||||
//
|
||||
sltDataType.Dock = DockStyle.Top;
|
||||
sltDataType.List = true;
|
||||
sltDataType.Location = new Point(18, 196);
|
||||
sltDataType.Name = "sltDataType";
|
||||
sltDataType.Size = new Size(409, 38);
|
||||
sltDataType.TabIndex = 45;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.Dock = DockStyle.Top;
|
||||
label3.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
label3.Location = new Point(18, 172);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(409, 24);
|
||||
label3.TabIndex = 44;
|
||||
label3.Text = "数据类型";
|
||||
//
|
||||
// iptAddress
|
||||
//
|
||||
iptAddress.Dock = DockStyle.Top;
|
||||
iptAddress.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
iptAddress.Location = new Point(18, 258);
|
||||
iptAddress.Name = "iptAddress";
|
||||
iptAddress.Radius = 3;
|
||||
iptAddress.Size = new Size(409, 38);
|
||||
iptAddress.TabIndex = 54;
|
||||
//
|
||||
// label7
|
||||
//
|
||||
label7.Dock = DockStyle.Top;
|
||||
label7.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
label7.Location = new Point(18, 234);
|
||||
label7.Name = "label7";
|
||||
label7.Size = new Size(409, 24);
|
||||
label7.TabIndex = 53;
|
||||
label7.Text = "地址";
|
||||
//
|
||||
// stackPanel3
|
||||
//
|
||||
stackPanel3.BackColor = SystemColors.Window;
|
||||
stackPanel3.Controls.Add(iptEndIndex);
|
||||
stackPanel3.Controls.Add(sltEnd);
|
||||
stackPanel3.Dock = DockStyle.Top;
|
||||
stackPanel3.Location = new Point(18, 496);
|
||||
stackPanel3.Name = "stackPanel3";
|
||||
stackPanel3.Size = new Size(409, 45);
|
||||
stackPanel3.TabIndex = 61;
|
||||
stackPanel3.Text = "stackPanel3";
|
||||
//
|
||||
// iptEndIndex
|
||||
//
|
||||
iptEndIndex.Dock = DockStyle.Left;
|
||||
iptEndIndex.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
iptEndIndex.Location = new Point(277, 3);
|
||||
iptEndIndex.Name = "iptEndIndex";
|
||||
iptEndIndex.PlaceholderText = "执行顺序标识(0开始)";
|
||||
iptEndIndex.Radius = 3;
|
||||
iptEndIndex.Size = new Size(132, 39);
|
||||
iptEndIndex.TabIndex = 36;
|
||||
//
|
||||
// sltEnd
|
||||
//
|
||||
sltEnd.Dock = DockStyle.Left;
|
||||
sltEnd.Items.AddRange(new object[] { "执行", "取消" });
|
||||
sltEnd.List = true;
|
||||
sltEnd.Location = new Point(3, 3);
|
||||
sltEnd.Name = "sltEnd";
|
||||
sltEnd.Size = new Size(268, 39);
|
||||
sltEnd.TabIndex = 35;
|
||||
//
|
||||
// label6
|
||||
//
|
||||
label6.Dock = DockStyle.Top;
|
||||
label6.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
label6.Location = new Point(18, 472);
|
||||
label6.Name = "label6";
|
||||
label6.Size = new Size(409, 24);
|
||||
label6.TabIndex = 60;
|
||||
label6.Text = "流程结束执行";
|
||||
//
|
||||
// stackPanel2
|
||||
//
|
||||
stackPanel2.BackColor = SystemColors.Window;
|
||||
stackPanel2.Controls.Add(iptStartIndex);
|
||||
stackPanel2.Controls.Add(sltStart);
|
||||
stackPanel2.Dock = DockStyle.Top;
|
||||
stackPanel2.Location = new Point(18, 427);
|
||||
stackPanel2.Name = "stackPanel2";
|
||||
stackPanel2.Size = new Size(409, 45);
|
||||
stackPanel2.TabIndex = 59;
|
||||
stackPanel2.Text = "stackPanel2";
|
||||
//
|
||||
// iptStartIndex
|
||||
//
|
||||
iptStartIndex.Dock = DockStyle.Left;
|
||||
iptStartIndex.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
iptStartIndex.Location = new Point(277, 3);
|
||||
iptStartIndex.Name = "iptStartIndex";
|
||||
iptStartIndex.PlaceholderText = "执行顺序标识(0开始)";
|
||||
iptStartIndex.Radius = 3;
|
||||
iptStartIndex.Size = new Size(132, 39);
|
||||
iptStartIndex.TabIndex = 36;
|
||||
//
|
||||
// sltStart
|
||||
//
|
||||
sltStart.Dock = DockStyle.Left;
|
||||
sltStart.Items.AddRange(new object[] { "执行", "取消" });
|
||||
sltStart.List = true;
|
||||
sltStart.Location = new Point(3, 3);
|
||||
sltStart.Name = "sltStart";
|
||||
sltStart.Size = new Size(268, 39);
|
||||
sltStart.TabIndex = 35;
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.Dock = DockStyle.Top;
|
||||
label5.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
label5.Location = new Point(18, 403);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(409, 24);
|
||||
label5.TabIndex = 58;
|
||||
label5.Text = "流程开始执行";
|
||||
//
|
||||
// sltBoolValue
|
||||
//
|
||||
sltBoolValue.Dock = DockStyle.Top;
|
||||
sltBoolValue.Items.AddRange(new object[] { "True", "False" });
|
||||
sltBoolValue.List = true;
|
||||
sltBoolValue.Location = new Point(18, 365);
|
||||
sltBoolValue.Name = "sltBoolValue";
|
||||
sltBoolValue.Size = new Size(409, 38);
|
||||
sltBoolValue.TabIndex = 57;
|
||||
//
|
||||
// stpNum
|
||||
//
|
||||
stpNum.BackColor = SystemColors.Window;
|
||||
stpNum.Controls.Add(sltIntType);
|
||||
stpNum.Controls.Add(iptValue);
|
||||
stpNum.Dock = DockStyle.Top;
|
||||
stpNum.Location = new Point(18, 320);
|
||||
stpNum.Name = "stpNum";
|
||||
stpNum.Size = new Size(409, 45);
|
||||
stpNum.TabIndex = 56;
|
||||
stpNum.Text = "stackPanel2";
|
||||
//
|
||||
// sltIntType
|
||||
//
|
||||
sltIntType.Dock = DockStyle.Left;
|
||||
sltIntType.List = true;
|
||||
sltIntType.Location = new Point(277, 3);
|
||||
sltIntType.Name = "sltIntType";
|
||||
sltIntType.Size = new Size(132, 39);
|
||||
sltIntType.TabIndex = 35;
|
||||
//
|
||||
// iptValue
|
||||
//
|
||||
iptValue.Dock = DockStyle.Left;
|
||||
iptValue.Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
iptValue.Location = new Point(3, 3);
|
||||
iptValue.Name = "iptValue";
|
||||
iptValue.Radius = 3;
|
||||
iptValue.Size = new Size(268, 39);
|
||||
iptValue.TabIndex = 24;
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.Dock = DockStyle.Top;
|
||||
label4.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
label4.Location = new Point(18, 296);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(409, 24);
|
||||
label4.TabIndex = 55;
|
||||
label4.Text = "值";
|
||||
//
|
||||
// MotionEdit
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(panel1);
|
||||
Name = "MotionEdit";
|
||||
Size = new Size(445, 572);
|
||||
stackPanel1.ResumeLayout(false);
|
||||
panel1.ResumeLayout(false);
|
||||
stackPanel3.ResumeLayout(false);
|
||||
stackPanel2.ResumeLayout(false);
|
||||
stpNum.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
private AntdUI.Button button_cancel;
|
||||
private AntdUI.Select sltName;
|
||||
private AntdUI.Label label2;
|
||||
private AntdUI.Divider divider2;
|
||||
private AntdUI.StackPanel stackPanel1;
|
||||
private AntdUI.Button button_ok;
|
||||
private AntdUI.Divider divider1;
|
||||
private AntdUI.Label label1;
|
||||
private AntdUI.Panel panel1;
|
||||
private AntdUI.Select sltDataType;
|
||||
private AntdUI.Label label3;
|
||||
private AntdUI.StackPanel stackPanel3;
|
||||
private AntdUI.Input iptEndIndex;
|
||||
private AntdUI.Select sltEnd;
|
||||
private AntdUI.Label label6;
|
||||
private AntdUI.StackPanel stackPanel2;
|
||||
private AntdUI.Input iptStartIndex;
|
||||
private AntdUI.Select sltStart;
|
||||
private AntdUI.Label label5;
|
||||
private AntdUI.Select sltBoolValue;
|
||||
private AntdUI.StackPanel stpNum;
|
||||
private AntdUI.Select sltIntType;
|
||||
private AntdUI.Input iptValue;
|
||||
private AntdUI.Label label4;
|
||||
private AntdUI.Input iptAddress;
|
||||
private AntdUI.Label label7;
|
||||
}
|
||||
}
|
125
DHSoftware/Views/MotionEdit.cs
Normal file
125
DHSoftware/Views/MotionEdit.cs
Normal file
@ -0,0 +1,125 @@
|
||||
using AntdUI;
|
||||
using DH.Commons.Base;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.PLC;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
public partial class MotionEdit : UserControl
|
||||
{
|
||||
private AntdUI.Window window;
|
||||
private PLCItem plcItem;
|
||||
public bool submit;
|
||||
public MotionEdit(AntdUI.Window _window, PLCItem _plcItem)
|
||||
{
|
||||
InitializeComponent();
|
||||
plcItem = _plcItem;
|
||||
// 绑定事件
|
||||
BindEventHandler();
|
||||
//设置默认值
|
||||
InitData();
|
||||
|
||||
}
|
||||
private void BindEventHandler()
|
||||
{
|
||||
button_ok.Click += Button_ok_Click;
|
||||
button_cancel.Click += Button_cancel_Click;
|
||||
|
||||
|
||||
sltDataType.SelectedIndexChanged += SltDataType_SelectedIndexChanged;
|
||||
sltStart.SelectedIndexChanged += SltStart_SelectedIndexChanged;
|
||||
sltEnd.SelectedIndexChanged += SltEnd_SelectedIndexChanged;
|
||||
}
|
||||
|
||||
private void SltEnd_SelectedIndexChanged(object sender, IntEventArgs e)
|
||||
{
|
||||
iptEndIndex.Visible = e.Value == 0;
|
||||
}
|
||||
|
||||
private void SltDataType_SelectedIndexChanged(object sender, IntEventArgs e)
|
||||
{
|
||||
var isMType = e.Value == 2;
|
||||
stpNum.Visible = !isMType;
|
||||
sltBoolValue.Visible = isMType;
|
||||
}
|
||||
|
||||
private void SltStart_SelectedIndexChanged(object sender, IntEventArgs e)
|
||||
{
|
||||
iptStartIndex.Visible = e.Value == 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void Button_cancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
submit = false;
|
||||
this.Dispose();
|
||||
}
|
||||
|
||||
private void Button_ok_Click(object sender, EventArgs e)
|
||||
{
|
||||
sltName.Status = AntdUI.TType.None;
|
||||
//检查输入内容
|
||||
if (String.IsNullOrEmpty(sltName.Text))
|
||||
{
|
||||
sltName.Status = AntdUI.TType.Error;
|
||||
AntdUI.Message.warn(window, "参数名称不能为空!", autoClose: 3);
|
||||
return;
|
||||
}
|
||||
|
||||
plcItem.Name = sltName.Text;
|
||||
plcItem.Address = iptAddress.Text;
|
||||
plcItem.Type = sltDataType.Text;
|
||||
plcItem.Value = sltDataType.SelectedIndex == 2 ? sltBoolValue.Text : iptValue.Text;
|
||||
plcItem.NumTpye = sltDataType.SelectedIndex == 2 ? string.Empty : sltIntType.Text;
|
||||
plcItem.StartExecute = sltStart.Text == "执行" ? true : false;
|
||||
plcItem.StartIndex = sltStart.Text == "执行" ? Convert.ToInt32(iptStartIndex.Text) : -1;
|
||||
plcItem.EndExecute = sltEnd.Text == "执行" ? true : false;
|
||||
plcItem.EndIndex = sltEnd.Text == "执行" ? Convert.ToInt32(iptEndIndex.Text) : -1;
|
||||
|
||||
submit = true;
|
||||
this.Dispose();
|
||||
}
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
var PLCItemNames = Enum.GetNames(typeof(EnumPLCOutputIO));
|
||||
foreach (var name in PLCItemNames)
|
||||
{
|
||||
sltName.Items.Add(name);
|
||||
}
|
||||
var PLCDataTypes = Enum.GetNames(typeof(EnumPLCDataType));
|
||||
foreach (var name in PLCDataTypes)
|
||||
{
|
||||
sltDataType.Items.Add(name);
|
||||
}
|
||||
sltDataType.SelectedIndex = 0;
|
||||
var PLCINTTypes = Enum.GetNames(typeof(EnumPLCINTType));
|
||||
foreach (var name in PLCINTTypes)
|
||||
{
|
||||
sltIntType.Items.Add(name);
|
||||
}
|
||||
|
||||
sltStart.SelectedIndex = 1;
|
||||
sltEnd.SelectedIndex = 1;
|
||||
|
||||
if (!string.IsNullOrEmpty(plcItem.Name))
|
||||
{
|
||||
sltName.Text = plcItem.Name;
|
||||
iptAddress.Text = plcItem.Address;
|
||||
sltDataType.SelectedValue = plcItem.Type;
|
||||
iptValue.Text = sltDataType.SelectedIndex != 2 ? plcItem.Value : string.Empty;
|
||||
sltBoolValue.SelectedValue = sltDataType.SelectedIndex == 2 ? plcItem.Value : string.Empty;
|
||||
sltIntType.SelectedValue = sltDataType.SelectedIndex == 2 ? string.Empty : plcItem.NumTpye;
|
||||
sltStart.SelectedValue = plcItem.StartExecute == true ? "执行" : "取消";
|
||||
sltEnd.SelectedValue = plcItem.EndExecute == true ? "执行" : "取消";
|
||||
iptStartIndex.Text = plcItem.StartExecute == true ? plcItem.StartIndex.ToString() : "-1";
|
||||
iptEndIndex.Text = plcItem.EndExecute == true ? plcItem.EndIndex.ToString() : "-1";
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
120
DHSoftware/Views/MotionEdit.resx
Normal file
120
DHSoftware/Views/MotionEdit.resx
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
using DH.Commons.Enums;
|
||||
using DH.Commons.Base;
|
||||
using DH.Devices.Vision;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
|
225
DHSoftware/Views/SettingWindow.Designer.cs
generated
225
DHSoftware/Views/SettingWindow.Designer.cs
generated
@ -28,93 +28,24 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
panel3 = new AntdUI.Panel();
|
||||
panel1 = new AntdUI.Panel();
|
||||
panel2 = new AntdUI.Panel();
|
||||
btnSave = new AntdUI.Button();
|
||||
btnAdd = new AntdUI.Button();
|
||||
menu1 = new AntdUI.Menu();
|
||||
AntdUI.MenuItem menuItem4 = new AntdUI.MenuItem();
|
||||
AntdUI.MenuItem menuItem5 = new AntdUI.MenuItem();
|
||||
AntdUI.MenuItem menuItem6 = new AntdUI.MenuItem();
|
||||
AntdUI.Tabs.StyleCard styleCard2 = new AntdUI.Tabs.StyleCard();
|
||||
pageHeader1 = new AntdUI.PageHeader();
|
||||
panel3.SuspendLayout();
|
||||
panel1 = new AntdUI.Panel();
|
||||
panel2 = new AntdUI.StackPanel();
|
||||
btnSave = new AntdUI.Dropdown();
|
||||
btnAdd = new AntdUI.Dropdown();
|
||||
menu1 = new AntdUI.Menu();
|
||||
panel3 = new AntdUI.Panel();
|
||||
tabs1 = new AntdUI.Tabs();
|
||||
divider1 = new AntdUI.Divider();
|
||||
panel1.SuspendLayout();
|
||||
panel2.SuspendLayout();
|
||||
panel3.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel3
|
||||
//
|
||||
panel3.Controls.Add(panel1);
|
||||
panel3.Controls.Add(pageHeader1);
|
||||
panel3.Dock = DockStyle.Fill;
|
||||
panel3.Location = new Point(0, 0);
|
||||
panel3.Name = "panel3";
|
||||
panel3.Size = new Size(838, 561);
|
||||
panel3.TabIndex = 1;
|
||||
panel3.Text = "panel3";
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(panel2);
|
||||
panel1.Controls.Add(menu1);
|
||||
panel1.Dock = DockStyle.Left;
|
||||
panel1.Location = new Point(0, 33);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(141, 528);
|
||||
panel1.TabIndex = 2;
|
||||
panel1.Text = "panel1";
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
panel2.Back = SystemColors.Window;
|
||||
panel2.BackColor = SystemColors.Window;
|
||||
panel2.Controls.Add(btnSave);
|
||||
panel2.Controls.Add(btnAdd);
|
||||
panel2.Dock = DockStyle.Fill;
|
||||
panel2.Location = new Point(0, 497);
|
||||
panel2.Name = "panel2";
|
||||
panel2.Size = new Size(141, 31);
|
||||
panel2.TabIndex = 1;
|
||||
panel2.Text = "panel2";
|
||||
//
|
||||
// btnSave
|
||||
//
|
||||
btnSave.BackActive = SystemColors.Control;
|
||||
btnSave.BackColor = SystemColors.Control;
|
||||
btnSave.Dock = DockStyle.Left;
|
||||
btnSave.ForeColor = Color.Black;
|
||||
btnSave.IconRatio = 1F;
|
||||
btnSave.IconSvg = "AppstoreAddOutlined";
|
||||
btnSave.Location = new Point(35, 0);
|
||||
btnSave.Name = "btnSave";
|
||||
btnSave.Size = new Size(35, 31);
|
||||
btnSave.TabIndex = 2;
|
||||
btnSave.Click += btnSave_Click;
|
||||
//
|
||||
// btnAdd
|
||||
//
|
||||
btnAdd.BackActive = SystemColors.Control;
|
||||
btnAdd.BackColor = SystemColors.Control;
|
||||
btnAdd.Dock = DockStyle.Left;
|
||||
btnAdd.ForeColor = Color.Black;
|
||||
btnAdd.IconRatio = 1F;
|
||||
btnAdd.IconSvg = "AppstoreAddOutlined";
|
||||
btnAdd.Location = new Point(0, 0);
|
||||
btnAdd.Name = "btnAdd";
|
||||
btnAdd.Size = new Size(35, 31);
|
||||
btnAdd.TabIndex = 1;
|
||||
btnAdd.Click += btnAdd_Click;
|
||||
//
|
||||
// menu1
|
||||
//
|
||||
menu1.BackColor = SystemColors.Window;
|
||||
menu1.Dock = DockStyle.Top;
|
||||
menu1.Location = new Point(0, 0);
|
||||
menu1.Name = "menu1";
|
||||
menu1.Size = new Size(141, 497);
|
||||
menu1.TabIndex = 0;
|
||||
menu1.Text = "menu1";
|
||||
menu1.MouseClick += menu1_MouseClick;
|
||||
menu1.MouseDown += Menu_MouseDown;
|
||||
//
|
||||
// pageHeader1
|
||||
//
|
||||
pageHeader1.BackColor = SystemColors.MenuHighlight;
|
||||
@ -124,32 +55,146 @@
|
||||
pageHeader1.Name = "pageHeader1";
|
||||
pageHeader1.ShowButton = true;
|
||||
pageHeader1.ShowIcon = true;
|
||||
pageHeader1.Size = new Size(838, 33);
|
||||
pageHeader1.Size = new Size(1042, 33);
|
||||
pageHeader1.TabIndex = 1;
|
||||
pageHeader1.Text = "设置";
|
||||
//
|
||||
// SettingWindow
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(panel2);
|
||||
panel1.Controls.Add(menu1);
|
||||
panel1.Dock = DockStyle.Left;
|
||||
panel1.Location = new Point(0, 33);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(141, 666);
|
||||
panel1.TabIndex = 2;
|
||||
panel1.Text = "panel1";
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
panel2.BackColor = SystemColors.Window;
|
||||
panel2.Controls.Add(btnSave);
|
||||
panel2.Controls.Add(btnAdd);
|
||||
panel2.Dock = DockStyle.Fill;
|
||||
panel2.Location = new Point(0, 632);
|
||||
panel2.Name = "panel2";
|
||||
panel2.Size = new Size(141, 34);
|
||||
panel2.TabIndex = 1;
|
||||
panel2.Text = "panel2";
|
||||
//
|
||||
// btnSave
|
||||
//
|
||||
btnSave.BackActive = SystemColors.Control;
|
||||
btnSave.BackColor = SystemColors.Control;
|
||||
btnSave.Dock = DockStyle.Right;
|
||||
btnSave.Font = new Font("Microsoft YaHei UI", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
btnSave.ForeColor = Color.Black;
|
||||
btnSave.IconSvg = "SaveOutlined";
|
||||
btnSave.Location = new Point(72, 3);
|
||||
btnSave.Name = "btnSave";
|
||||
btnSave.Size = new Size(63, 28);
|
||||
btnSave.TabIndex = 2;
|
||||
btnSave.Text = "保存";
|
||||
//
|
||||
// btnAdd
|
||||
//
|
||||
btnAdd.BackActive = SystemColors.Control;
|
||||
btnAdd.BackColor = SystemColors.Control;
|
||||
btnAdd.Dock = DockStyle.Left;
|
||||
btnAdd.Font = new Font("Microsoft YaHei UI", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
btnAdd.ForeColor = Color.Black;
|
||||
btnAdd.IconSvg = "AppstoreAddOutlined";
|
||||
btnAdd.Location = new Point(3, 3);
|
||||
btnAdd.Name = "btnAdd";
|
||||
btnAdd.Placement = AntdUI.TAlignFrom.TL;
|
||||
btnAdd.Size = new Size(63, 28);
|
||||
btnAdd.TabIndex = 1;
|
||||
btnAdd.Text = "新增";
|
||||
btnAdd.Trigger = AntdUI.Trigger.Hover;
|
||||
//
|
||||
// menu1
|
||||
//
|
||||
menu1.BackColor = SystemColors.Window;
|
||||
menu1.Dock = DockStyle.Top;
|
||||
menuItem4.IconSvg = "VideoCameraOutlined";
|
||||
menuItem4.Text = "相机设置";
|
||||
menuItem5.IconSvg = "AppstoreOutlined";
|
||||
menuItem5.Text = "工位设置";
|
||||
menuItem6.IconSvg = "ControlOutlined";
|
||||
menuItem6.Text = "运控设置";
|
||||
menu1.Items.Add(menuItem4);
|
||||
menu1.Items.Add(menuItem5);
|
||||
menu1.Items.Add(menuItem6);
|
||||
menu1.Location = new Point(0, 0);
|
||||
menu1.Name = "menu1";
|
||||
menu1.Size = new Size(141, 632);
|
||||
menu1.TabIndex = 0;
|
||||
menu1.Text = "menu1";
|
||||
menu1.MouseDown += menu1_MouseDown;
|
||||
//
|
||||
// panel3
|
||||
//
|
||||
panel3.Controls.Add(tabs1);
|
||||
panel3.Controls.Add(divider1);
|
||||
panel3.Controls.Add(panel1);
|
||||
panel3.Controls.Add(pageHeader1);
|
||||
panel3.Dock = DockStyle.Fill;
|
||||
panel3.Location = new Point(0, 0);
|
||||
panel3.Name = "panel3";
|
||||
panel3.Size = new Size(1042, 699);
|
||||
panel3.TabIndex = 1;
|
||||
panel3.Text = "panel3";
|
||||
//
|
||||
// tabs1
|
||||
//
|
||||
tabs1.BackColor = SystemColors.Window;
|
||||
tabs1.Dock = DockStyle.Fill;
|
||||
tabs1.Location = new Point(151, 33);
|
||||
tabs1.Name = "tabs1";
|
||||
tabs1.Size = new Size(891, 666);
|
||||
styleCard2.Closable = true;
|
||||
tabs1.Style = styleCard2;
|
||||
tabs1.TabIndex = 5;
|
||||
tabs1.Text = "tabs1";
|
||||
tabs1.Type = AntdUI.TabType.Card;
|
||||
//
|
||||
// divider1
|
||||
//
|
||||
divider1.BackColor = SystemColors.Window;
|
||||
divider1.Dock = DockStyle.Left;
|
||||
divider1.Location = new Point(141, 33);
|
||||
divider1.Name = "divider1";
|
||||
divider1.OrientationMargin = 0F;
|
||||
divider1.Size = new Size(10, 666);
|
||||
divider1.TabIndex = 4;
|
||||
divider1.Text = "";
|
||||
divider1.Vertical = true;
|
||||
//
|
||||
// SettingWindow1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(838, 561);
|
||||
ClientSize = new Size(1042, 699);
|
||||
Controls.Add(panel3);
|
||||
Name = "SettingWindow";
|
||||
Name = "SettingWindow1";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "SettingWinform";
|
||||
panel3.ResumeLayout(false);
|
||||
panel1.ResumeLayout(false);
|
||||
panel2.ResumeLayout(false);
|
||||
panel3.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
private AntdUI.Panel panel3;
|
||||
|
||||
private AntdUI.PageHeader pageHeader1;
|
||||
private AntdUI.Panel panel1;
|
||||
private AntdUI.Panel panel2;
|
||||
private AntdUI.Button btnAdd;
|
||||
private AntdUI.StackPanel panel2;
|
||||
private AntdUI.Menu menu1;
|
||||
private AntdUI.Panel panel3;
|
||||
private AntdUI.Tabs tabs1;
|
||||
private AntdUI.Divider divider1;
|
||||
private AntdUI.Dropdown btnAdd;
|
||||
private AntdUI.Button btnSave;
|
||||
}
|
||||
}
|
@ -1,43 +1,145 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using System.Data;
|
||||
using AntdUI;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Devices;
|
||||
using DH.Devices.Vision;
|
||||
|
||||
using DH.Commons.Helper;
|
||||
using DH.Commons.Models;
|
||||
using DHSoftware.Utils;
|
||||
using DH.Commons.Base;
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
|
||||
public partial class SettingWindow : Window
|
||||
{
|
||||
public List<CameraBase> cameras = new List<CameraBase>();
|
||||
public List<DetectionConfig> detections = new List<DetectionConfig>();
|
||||
private UserControl currControl;
|
||||
|
||||
|
||||
public SettingWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
AntdUI.TooltipComponent tooltip = new AntdUI.TooltipComponent()
|
||||
{
|
||||
Font = new Font("Microsoft YaHei UI", 9F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(134))),
|
||||
};
|
||||
tooltip.ArrowAlign = AntdUI.TAlign.Right;
|
||||
tooltip.SetTip(btnAdd, "新增工位");
|
||||
|
||||
|
||||
|
||||
BindEventHandler();
|
||||
InitData();
|
||||
|
||||
}
|
||||
|
||||
private void Menu_MouseDown(object sender, MouseEventArgs e)
|
||||
private void BindEventHandler()
|
||||
{
|
||||
if (e.Button == MouseButtons.Right)
|
||||
Resize += SettingWindow1_Resize;
|
||||
btnAdd.SelectedValueChanged += btnAdd_SelectedValueChanged;
|
||||
btnSave.Click += BtnSave_Click;
|
||||
|
||||
}
|
||||
private float x; //定义当前窗体的宽度
|
||||
private float y; //定义当前窗体的高度
|
||||
private void InitData()
|
||||
{
|
||||
btnAdd.Items.Clear();
|
||||
btnAdd.Items.Add("相机设置");
|
||||
btnAdd.Items.Add("工位设置");
|
||||
btnAdd.Items.Add("运控设置");
|
||||
|
||||
x = Width;
|
||||
y = Height;
|
||||
AdaptiveHelper.setTag(this);
|
||||
|
||||
|
||||
if (ConfigModel.CameraBaseList.Count > 0)
|
||||
{
|
||||
var workstationItem = FindMenuItem(menu1.Items, "相机设置");
|
||||
|
||||
if (workstationItem != null)
|
||||
{
|
||||
foreach (var item in ConfigModel.CameraBaseList)
|
||||
{
|
||||
var newItem = new MenuItem();
|
||||
newItem.Text = item.CameraName;
|
||||
newItem.IconSvg = "VideoCameraOutlined";
|
||||
workstationItem.Sub.Add(newItem);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ConfigModel.DetectionList.Count > 0)
|
||||
{
|
||||
var workstationItem = FindMenuItem(menu1.Items, "工位设置");
|
||||
|
||||
if (workstationItem != null)
|
||||
{
|
||||
foreach (var item in ConfigModel.DetectionList)
|
||||
{
|
||||
var newItem = new MenuItem();
|
||||
newItem.Text = item.Name;
|
||||
newItem.IconSvg = "AppstoreOutlined";
|
||||
workstationItem.Sub.Add(newItem);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ConfigModel.PLCBaseList.Count > 0)
|
||||
{
|
||||
var workstationItem = FindMenuItem(menu1.Items, "运控设置");
|
||||
|
||||
if (workstationItem != null)
|
||||
{
|
||||
foreach (var item in ConfigModel.PLCBaseList)
|
||||
{
|
||||
var newItem = new MenuItem();
|
||||
newItem.Text = item.PLCName;
|
||||
newItem.IconSvg = "ControlOutlined";
|
||||
workstationItem.Sub.Add(newItem);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void BtnSave_Click(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
ConfigHelper.SaveConfig();
|
||||
AntdUI.Message.success(this, "保存成功!", autoClose: 3);
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void SettingWindow1_Resize(object? sender, EventArgs e)
|
||||
{
|
||||
var newx = Width / x;
|
||||
var newy = Height / y;
|
||||
AdaptiveHelper.setControls(newx, newy, this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 递归查找菜单项
|
||||
private MenuItem FindMenuItem(MenuItemCollection items, string targetText)
|
||||
{
|
||||
foreach (MenuItem item in items)
|
||||
{
|
||||
if (item.Text == targetText) return item;
|
||||
if (item.Sub != null)
|
||||
{
|
||||
var subResult = FindMenuItem(item.Sub, targetText);
|
||||
if (subResult != null) return subResult;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool isUpdatingTabs = false;
|
||||
|
||||
|
||||
private void menu1_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
// 转换坐标到控件内部坐标系(考虑滚动条)
|
||||
Point clickPoint = new Point(e.X, e.Y + menu1.ScrollBar.Value);
|
||||
@ -47,21 +149,414 @@ namespace DHSoftware.Views
|
||||
|
||||
if (clickedItem != null)
|
||||
{
|
||||
// 显示节点名称弹窗
|
||||
//MessageBox.Show($"右键点击的节点: {clickedItem.Text}");
|
||||
|
||||
var menulist = new AntdUI.IContextMenuStripItem[]
|
||||
if (clickedItem.PARENTITEM == null)
|
||||
{
|
||||
new AntdUI.ContextMenuStripItem("关联相机", "")
|
||||
{
|
||||
IconSvg = "VideoCameraAddOutlined"
|
||||
}
|
||||
};
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (clickedItem.PARENTITEM.Text)
|
||||
{
|
||||
case "相机设置":
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//先获取是否存在该名称的配置
|
||||
//如果没有新建项
|
||||
CameraBase? CameraBase= ConfigModel.CameraBaseList.Where(c => c.CameraName == clickedItem.Text).FirstOrDefault();
|
||||
if (CameraBase == null)
|
||||
{
|
||||
CameraBase=new CameraBase();
|
||||
}
|
||||
UserControl control = null;
|
||||
control = new CameraControl(this, CameraBase);
|
||||
if (control != null)
|
||||
{
|
||||
//容器添加控件,需要调整dpi
|
||||
control.Dock = DockStyle.Fill;
|
||||
AutoDpi(control);
|
||||
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
||||
{
|
||||
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
||||
ReadOnly = false,
|
||||
|
||||
};
|
||||
tabPage.Controls.Add(control);
|
||||
tabs1.Pages.Add(tabPage);
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = tabPage;
|
||||
isUpdatingTabs = false;
|
||||
currControl = control;
|
||||
}
|
||||
break;
|
||||
case "工位设置":
|
||||
// 检查是否已存在同名 TabPage
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
DetectionConfig? detectionConfig = ConfigModel.DetectionList.Where(c => c.Name == clickedItem.Text).FirstOrDefault();
|
||||
if (detectionConfig == null)
|
||||
{
|
||||
detectionConfig = new DetectionConfig();
|
||||
}
|
||||
UserControl control1 = null;
|
||||
control1 = new DetectControl(this, detectionConfig);
|
||||
if (control1 != null)
|
||||
{
|
||||
//容器添加控件,需要调整dpi
|
||||
control1.Dock = DockStyle.Fill;
|
||||
AutoDpi(control1);
|
||||
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
||||
{
|
||||
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
||||
ReadOnly = false ,
|
||||
|
||||
};
|
||||
tabPage.Controls.Add(control1);
|
||||
tabs1.Pages.Add(tabPage);
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = tabPage;
|
||||
isUpdatingTabs = false;
|
||||
currControl = control1;
|
||||
}
|
||||
break;
|
||||
|
||||
case "运控设置":
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//先获取是否存在该名称的配置
|
||||
//如果没有新建项
|
||||
PLCBase? pLCBase = ConfigModel.PLCBaseList.Where(c => c.PLCName == clickedItem.Text).FirstOrDefault();
|
||||
if (pLCBase == null)
|
||||
{
|
||||
pLCBase = new PLCBase();
|
||||
}
|
||||
UserControl control2 = null;
|
||||
control = new MotionControl(this, pLCBase);
|
||||
if (control != null)
|
||||
{
|
||||
//容器添加控件,需要调整dpi
|
||||
control.Dock = DockStyle.Fill;
|
||||
AutoDpi(control);
|
||||
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
||||
{
|
||||
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
||||
ReadOnly = false,
|
||||
|
||||
};
|
||||
tabPage.Controls.Add(control);
|
||||
tabs1.Pages.Add(tabPage);
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = tabPage;
|
||||
isUpdatingTabs = false;
|
||||
currControl = control;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
|
||||
// 转换坐标到控件内部坐标系(考虑滚动条)
|
||||
Point clickPoint = new Point(e.X, e.Y + menu1.ScrollBar.Value);
|
||||
|
||||
// 递归查找命中的菜单项
|
||||
MenuItem clickedItem = FindClickedItem(menu1.Items, clickPoint);
|
||||
|
||||
if (clickedItem != null)
|
||||
{
|
||||
if (clickedItem.PARENTITEM == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (clickedItem.PARENTITEM.Text)
|
||||
{
|
||||
case "相机设置":
|
||||
var menulist = new AntdUI.IContextMenuStripItem[]
|
||||
{
|
||||
new AntdUI.ContextMenuStripItem("重命名", "")
|
||||
{
|
||||
IconSvg = "RetweetOutlined"
|
||||
},
|
||||
new AntdUI.ContextMenuStripItem("删除相机", "")
|
||||
{
|
||||
IconSvg = "DeleteOutlined"
|
||||
}
|
||||
|
||||
};
|
||||
AntdUI.ContextMenuStrip.open(menu1, it =>
|
||||
{
|
||||
switch (it.Text)
|
||||
{
|
||||
case "删除相机":
|
||||
menu1.Remove(clickedItem);
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs1.Pages.Remove(tab);
|
||||
ConfigModel.CameraBaseList.RemoveAll(c => c.CameraName == clickedItem.Text);
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
ConfigModel.CameraBaseList.RemoveAll(c => c.CameraName == clickedItem.Text);
|
||||
break;
|
||||
case "重命名":
|
||||
// 保存原始名称用于查找
|
||||
string originalName = clickedItem.Text;
|
||||
|
||||
var form = new AddCameraControl(this, "重命名相机操作")
|
||||
{
|
||||
Size = new Size(300, 200),
|
||||
// 传递当前名称到表单
|
||||
CubicleName = originalName
|
||||
};
|
||||
|
||||
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
||||
{
|
||||
BtnHeight = 0,
|
||||
});
|
||||
|
||||
if (form.submit && !string.IsNullOrWhiteSpace(form.CubicleName))
|
||||
{
|
||||
string newName = form.CubicleName.Trim();
|
||||
|
||||
if (ConfigModel.CameraBaseList.Any(c =>
|
||||
c.CameraName.Equals(newName, StringComparison.OrdinalIgnoreCase) &&
|
||||
c.CameraName != originalName))
|
||||
{
|
||||
AntdUI.Message.warn(this, $"相机名称 '{newName}' 已存在!", autoClose: 3);
|
||||
return;
|
||||
}
|
||||
|
||||
clickedItem.Text= newName;
|
||||
var camera = ConfigModel.CameraBaseList.FirstOrDefault(c =>
|
||||
c.CameraName.Equals(originalName, StringComparison.OrdinalIgnoreCase));
|
||||
camera.CameraName = newName;
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{originalName}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
existingTab.Text = $"{clickedItem.PARENTITEM.Text}-{newName}";
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
AntdUI.Message.success(this, $"已将 '{originalName}重命名成{newName}'!", autoClose: 3);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}, menulist);
|
||||
break;
|
||||
case "工位设置":
|
||||
var menulist1 = new AntdUI.IContextMenuStripItem[]
|
||||
{ new AntdUI.ContextMenuStripItem("重命名", "")
|
||||
{
|
||||
IconSvg = "RetweetOutlined"
|
||||
},
|
||||
new AntdUI.ContextMenuStripItem("删除工位", "")
|
||||
{
|
||||
IconSvg = "DeleteOutlined"
|
||||
}
|
||||
|
||||
};
|
||||
AntdUI.ContextMenuStrip.open(menu1, it =>
|
||||
{
|
||||
switch (it.Text)
|
||||
{
|
||||
case "删除工位":
|
||||
menu1.Remove(clickedItem);
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs1.Pages.Remove(tab);
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
ConfigModel.DetectionList.RemoveAll(c => c.Name == clickedItem.Text);
|
||||
break;
|
||||
case "重命名":
|
||||
// 保存原始名称用于查找
|
||||
string originalName = clickedItem.Text;
|
||||
|
||||
var form = new AddCubicleControl(this, "重命名工位操作")
|
||||
{
|
||||
Size = new Size(300, 200),
|
||||
// 传递当前名称到表单
|
||||
CubicleName = originalName
|
||||
};
|
||||
|
||||
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
||||
{
|
||||
BtnHeight = 0,
|
||||
});
|
||||
|
||||
if (form.submit && !string.IsNullOrWhiteSpace(form.CubicleName))
|
||||
{
|
||||
string newName = form.CubicleName.Trim();
|
||||
|
||||
if (ConfigModel.DetectionList.Any(c =>
|
||||
c.Name.Equals(newName, StringComparison.OrdinalIgnoreCase) &&
|
||||
c.Name != originalName))
|
||||
{
|
||||
AntdUI.Message.warn(this, $"工位名称 '{newName}' 已存在!", autoClose: 3);
|
||||
return;
|
||||
}
|
||||
|
||||
clickedItem.Text = newName;
|
||||
var detection = ConfigModel.DetectionList.FirstOrDefault(c =>
|
||||
c.Name.Equals(originalName, StringComparison.OrdinalIgnoreCase));
|
||||
detection.Name = newName;
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{originalName}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
existingTab.Text = $"{clickedItem.PARENTITEM.Text}-{newName}";
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
AntdUI.Message.success(this, $"已将 '{originalName}重命名成{newName}'!", autoClose: 3);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}, menulist1);
|
||||
break;
|
||||
|
||||
case "运控设置":
|
||||
var menulist2 = new AntdUI.IContextMenuStripItem[]
|
||||
{
|
||||
new AntdUI.ContextMenuStripItem("重命名", "")
|
||||
{
|
||||
IconSvg = "RetweetOutlined"
|
||||
},
|
||||
new AntdUI.ContextMenuStripItem("删除运控", "")
|
||||
{
|
||||
IconSvg = "DeleteOutlined"
|
||||
}
|
||||
|
||||
};
|
||||
AntdUI.ContextMenuStrip.open(menu1, it =>
|
||||
{
|
||||
switch (it.Text)
|
||||
{
|
||||
case "删除运控":
|
||||
menu1.Remove(clickedItem);
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
//tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||
tabs1.Pages.Remove(tab);
|
||||
ConfigModel.PLCBaseList.RemoveAll(c => c.PLCName == clickedItem.Text);
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
ConfigModel.PLCBaseList.RemoveAll(c => c.PLCName == clickedItem.Text);
|
||||
|
||||
break;
|
||||
case "重命名":
|
||||
|
||||
var form = new AddMotionControl(this, "重命名运动控制操作") { Size = new Size(300, 200) };
|
||||
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
||||
{
|
||||
BtnHeight = 0,
|
||||
});
|
||||
if (form.submit)
|
||||
{
|
||||
string originalName = clickedItem.Text;
|
||||
if (form.submit && !string.IsNullOrWhiteSpace(form.MotionName))
|
||||
{
|
||||
string newName = form.MotionName.Trim();
|
||||
|
||||
if (ConfigModel.PLCBaseList.Any(c =>
|
||||
c.PLCName.Equals(newName, StringComparison.OrdinalIgnoreCase) &&
|
||||
c.PLCName != originalName))
|
||||
{
|
||||
AntdUI.Message.warn(this, $"运动控制名称 '{newName}' 已存在!", autoClose: 3);
|
||||
return;
|
||||
}
|
||||
|
||||
clickedItem.Text = newName;
|
||||
var plc = ConfigModel.PLCBaseList.FirstOrDefault(c =>
|
||||
c.PLCName.Equals(originalName, StringComparison.OrdinalIgnoreCase));
|
||||
plc.PLCName = newName;
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{originalName}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
existingTab.Text = $"{clickedItem.PARENTITEM.Text}-{newName}";
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
AntdUI.Message.success(this, $"已将 '{originalName}重命名成{newName}'!", autoClose: 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}, menulist2);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private MenuItem FindClickedItem(MenuItemCollection items, Point clickPoint)
|
||||
{
|
||||
foreach (MenuItem item in items)
|
||||
@ -82,50 +577,104 @@ namespace DHSoftware.Views
|
||||
return null;
|
||||
}
|
||||
|
||||
private void btnAdd_Click(object sender, EventArgs e)
|
||||
|
||||
|
||||
private void btnAdd_SelectedValueChanged(object sender, ObjectNEventArgs e)
|
||||
{
|
||||
|
||||
var form = new AddCubicleControl(this) { Size = new Size(400, 300) };
|
||||
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
||||
string selectedValue = e.Value.ToString();
|
||||
switch (selectedValue)
|
||||
{
|
||||
BtnHeight = 0,
|
||||
});
|
||||
if (form.submit)
|
||||
{
|
||||
var newItem = new MenuItem(form.CubicleName);
|
||||
newItem.IconSvg = "AppstoreOutlined";
|
||||
// 防止重复添加
|
||||
if (!menu1.Items.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
|
||||
{
|
||||
menu1.Items.Add(newItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
AntdUI.Notification.warn(this, "新增工位失败", $"{form.CubicleName}已存在!", autoClose: 3, align: TAlignFrom.TR);
|
||||
}
|
||||
}
|
||||
case "相机设置":
|
||||
var workstationItem = FindMenuItem(menu1.Items, "相机设置");
|
||||
|
||||
|
||||
}
|
||||
if (workstationItem != null)
|
||||
{
|
||||
|
||||
private void menu1_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
//if (e.Button == MouseButtons.Right)
|
||||
//{
|
||||
// var menu =sender as Menu;
|
||||
// if (menu?.Items.Count == 0)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
var form = new AddCameraControl(this,"新增相机操作") { Size = new Size(300, 200) };
|
||||
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
||||
{
|
||||
BtnHeight = 0,
|
||||
});
|
||||
if (form.submit)
|
||||
{
|
||||
var newItem = new MenuItem(form.CubicleName);
|
||||
newItem.IconSvg = "VideoCameraOutlined";
|
||||
// 防止重复添加
|
||||
if (!workstationItem.Sub.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
|
||||
{
|
||||
workstationItem.Sub.Add(newItem);
|
||||
CameraBase cameraBase = new CameraBase();
|
||||
cameraBase.CameraName = form.CubicleName;
|
||||
ConfigModel.CameraBaseList.Add(cameraBase);
|
||||
}
|
||||
else
|
||||
{
|
||||
AntdUI.Message.warn(this, $"相机名称 '{form.CubicleName}' 已存在!", autoClose: 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "工位设置":
|
||||
// 查找工位设置项
|
||||
var workstationItem1= FindMenuItem(menu1.Items, "工位设置");
|
||||
|
||||
//}
|
||||
}
|
||||
if (workstationItem1 != null)
|
||||
{
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach(var item in menu1.Items)
|
||||
{
|
||||
var form = new AddCubicleControl(this,"新增工位操作") { Size = new Size(300, 200) };
|
||||
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
||||
{
|
||||
BtnHeight = 0,
|
||||
});
|
||||
if (form.submit)
|
||||
{
|
||||
var newItem = new MenuItem(form.CubicleName);
|
||||
newItem.IconSvg = "AppstoreOutlined";
|
||||
// 防止重复添加
|
||||
if (!workstationItem1.Sub.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
|
||||
{
|
||||
workstationItem1.Sub.Add(newItem);
|
||||
DetectionConfig detection = new DetectionConfig();
|
||||
detection.Name = form.CubicleName;
|
||||
ConfigModel.DetectionList.Add(detection);
|
||||
}
|
||||
else
|
||||
{
|
||||
AntdUI.Message.warn(this, $"工位名称 '{form.CubicleName}' 已存在!", autoClose: 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "运控设置":
|
||||
var workstationItem2 = FindMenuItem(menu1.Items, "运控设置");
|
||||
|
||||
if (workstationItem2 != null)
|
||||
{
|
||||
|
||||
var form = new AddMotionControl(this,"新增运动控制操作") { Size = new Size(300, 200) };
|
||||
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
||||
{
|
||||
BtnHeight = 0,
|
||||
});
|
||||
if (form.submit)
|
||||
{
|
||||
var newItem = new MenuItem(form.MotionName);
|
||||
newItem.IconSvg = "ControlOutlined";
|
||||
// 防止重复添加
|
||||
if (!workstationItem2.Sub.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
|
||||
{
|
||||
workstationItem2.Sub.Add(newItem);
|
||||
PLCBase pLCBase = new PLCBase();
|
||||
pLCBase.PLCName = form.MotionName;
|
||||
ConfigModel.PLCBaseList.Add(pLCBase);
|
||||
}
|
||||
else
|
||||
{
|
||||
AntdUI.Message.warn(this, $"运动控制名称 '{form.MotionName}' 已存在!", autoClose: 3);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
200
DHSoftware/Views/SettingWindow1.Designer.cs
generated
200
DHSoftware/Views/SettingWindow1.Designer.cs
generated
@ -1,200 +0,0 @@
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
partial class SettingWindow1
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
AntdUI.MenuItem menuItem4 = new AntdUI.MenuItem();
|
||||
AntdUI.MenuItem menuItem5 = new AntdUI.MenuItem();
|
||||
AntdUI.MenuItem menuItem6 = new AntdUI.MenuItem();
|
||||
AntdUI.Tabs.StyleCard styleCard2 = new AntdUI.Tabs.StyleCard();
|
||||
pageHeader1 = new AntdUI.PageHeader();
|
||||
panel1 = new AntdUI.Panel();
|
||||
panel2 = new AntdUI.StackPanel();
|
||||
btnSave = new AntdUI.Dropdown();
|
||||
btnAdd = new AntdUI.Dropdown();
|
||||
menu1 = new AntdUI.Menu();
|
||||
panel3 = new AntdUI.Panel();
|
||||
tabs1 = new AntdUI.Tabs();
|
||||
divider1 = new AntdUI.Divider();
|
||||
panel1.SuspendLayout();
|
||||
panel2.SuspendLayout();
|
||||
panel3.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pageHeader1
|
||||
//
|
||||
pageHeader1.BackColor = SystemColors.MenuHighlight;
|
||||
pageHeader1.Dock = DockStyle.Top;
|
||||
pageHeader1.Location = new Point(0, 0);
|
||||
pageHeader1.Mode = AntdUI.TAMode.Dark;
|
||||
pageHeader1.Name = "pageHeader1";
|
||||
pageHeader1.ShowButton = true;
|
||||
pageHeader1.ShowIcon = true;
|
||||
pageHeader1.Size = new Size(1042, 33);
|
||||
pageHeader1.TabIndex = 1;
|
||||
pageHeader1.Text = "设置";
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(panel2);
|
||||
panel1.Controls.Add(menu1);
|
||||
panel1.Dock = DockStyle.Left;
|
||||
panel1.Location = new Point(0, 33);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(141, 666);
|
||||
panel1.TabIndex = 2;
|
||||
panel1.Text = "panel1";
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
panel2.BackColor = SystemColors.Window;
|
||||
panel2.Controls.Add(btnSave);
|
||||
panel2.Controls.Add(btnAdd);
|
||||
panel2.Dock = DockStyle.Fill;
|
||||
panel2.Location = new Point(0, 632);
|
||||
panel2.Name = "panel2";
|
||||
panel2.Size = new Size(141, 34);
|
||||
panel2.TabIndex = 1;
|
||||
panel2.Text = "panel2";
|
||||
//
|
||||
// btnSave
|
||||
//
|
||||
btnSave.BackActive = SystemColors.Control;
|
||||
btnSave.BackColor = SystemColors.Control;
|
||||
btnSave.Dock = DockStyle.Right;
|
||||
btnSave.Font = new Font("Microsoft YaHei UI", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
btnSave.ForeColor = Color.Black;
|
||||
btnSave.IconSvg = "SaveOutlined";
|
||||
btnSave.Location = new Point(72, 3);
|
||||
btnSave.Name = "btnSave";
|
||||
btnSave.Size = new Size(63, 28);
|
||||
btnSave.TabIndex = 2;
|
||||
btnSave.Text = "保存";
|
||||
//
|
||||
// btnAdd
|
||||
//
|
||||
btnAdd.BackActive = SystemColors.Control;
|
||||
btnAdd.BackColor = SystemColors.Control;
|
||||
btnAdd.Dock = DockStyle.Left;
|
||||
btnAdd.Font = new Font("Microsoft YaHei UI", 10.5F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
btnAdd.ForeColor = Color.Black;
|
||||
btnAdd.IconSvg = "AppstoreAddOutlined";
|
||||
btnAdd.Location = new Point(3, 3);
|
||||
btnAdd.Name = "btnAdd";
|
||||
btnAdd.Placement = AntdUI.TAlignFrom.TL;
|
||||
btnAdd.Size = new Size(63, 28);
|
||||
btnAdd.TabIndex = 1;
|
||||
btnAdd.Text = "新增";
|
||||
btnAdd.Trigger = AntdUI.Trigger.Hover;
|
||||
//
|
||||
// menu1
|
||||
//
|
||||
menu1.BackColor = SystemColors.Window;
|
||||
menu1.Dock = DockStyle.Top;
|
||||
menuItem4.IconSvg = "VideoCameraOutlined";
|
||||
menuItem4.Text = "相机设置";
|
||||
menuItem5.IconSvg = "AppstoreOutlined";
|
||||
menuItem5.Text = "工位设置";
|
||||
menuItem6.IconSvg = "ControlOutlined";
|
||||
menuItem6.Text = "运控设置";
|
||||
menu1.Items.Add(menuItem4);
|
||||
menu1.Items.Add(menuItem5);
|
||||
menu1.Items.Add(menuItem6);
|
||||
menu1.Location = new Point(0, 0);
|
||||
menu1.Name = "menu1";
|
||||
menu1.Size = new Size(141, 632);
|
||||
menu1.TabIndex = 0;
|
||||
menu1.Text = "menu1";
|
||||
menu1.MouseDown += menu1_MouseDown;
|
||||
//
|
||||
// panel3
|
||||
//
|
||||
panel3.Controls.Add(tabs1);
|
||||
panel3.Controls.Add(divider1);
|
||||
panel3.Controls.Add(panel1);
|
||||
panel3.Controls.Add(pageHeader1);
|
||||
panel3.Dock = DockStyle.Fill;
|
||||
panel3.Location = new Point(0, 0);
|
||||
panel3.Name = "panel3";
|
||||
panel3.Size = new Size(1042, 699);
|
||||
panel3.TabIndex = 1;
|
||||
panel3.Text = "panel3";
|
||||
//
|
||||
// tabs1
|
||||
//
|
||||
tabs1.BackColor = SystemColors.Window;
|
||||
tabs1.Dock = DockStyle.Fill;
|
||||
tabs1.Location = new Point(151, 33);
|
||||
tabs1.Name = "tabs1";
|
||||
tabs1.Size = new Size(891, 666);
|
||||
styleCard2.Closable = true;
|
||||
tabs1.Style = styleCard2;
|
||||
tabs1.TabIndex = 5;
|
||||
tabs1.Text = "tabs1";
|
||||
tabs1.Type = AntdUI.TabType.Card;
|
||||
//
|
||||
// divider1
|
||||
//
|
||||
divider1.BackColor = SystemColors.Window;
|
||||
divider1.Dock = DockStyle.Left;
|
||||
divider1.Location = new Point(141, 33);
|
||||
divider1.Name = "divider1";
|
||||
divider1.OrientationMargin = 0F;
|
||||
divider1.Size = new Size(10, 666);
|
||||
divider1.TabIndex = 4;
|
||||
divider1.Text = "";
|
||||
divider1.Vertical = true;
|
||||
//
|
||||
// SettingWindow1
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(1042, 699);
|
||||
Controls.Add(panel3);
|
||||
Name = "SettingWindow1";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "SettingWinform";
|
||||
panel1.ResumeLayout(false);
|
||||
panel2.ResumeLayout(false);
|
||||
panel3.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private AntdUI.PageHeader pageHeader1;
|
||||
private AntdUI.Panel panel1;
|
||||
private AntdUI.StackPanel panel2;
|
||||
private AntdUI.Menu menu1;
|
||||
private AntdUI.Panel panel3;
|
||||
private AntdUI.Tabs tabs1;
|
||||
private AntdUI.Divider divider1;
|
||||
private AntdUI.Dropdown btnAdd;
|
||||
private AntdUI.Button btnSave;
|
||||
}
|
||||
}
|
@ -1,440 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using AntdUI;
|
||||
using AntdUI.Svg;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Commons.Helper;
|
||||
using DH.Devices.Devices;
|
||||
using DH.Devices.PLC;
|
||||
using DHSoftware.Utils;
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
public partial class SettingWindow1 : Window
|
||||
{
|
||||
private UserControl currControl;
|
||||
|
||||
List<CameraBase> CameraBaseList = new List<CameraBase>();
|
||||
List<PLCBase> PLCBaseList = new List<PLCBase>();
|
||||
List<DetectionConfig> DetectionList = new List<DetectionConfig>();
|
||||
public SettingWindow1()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
BindEventHandler();
|
||||
InitData();
|
||||
|
||||
}
|
||||
|
||||
private void BindEventHandler()
|
||||
{
|
||||
Resize += SettingWindow1_Resize;
|
||||
btnAdd.SelectedValueChanged += btnAdd_SelectedValueChanged;
|
||||
btnSave.Click += BtnSave_Click;
|
||||
|
||||
}
|
||||
private float x; //定义当前窗体的宽度
|
||||
private float y; //定义当前窗体的高度
|
||||
private void InitData()
|
||||
{
|
||||
btnAdd.Items.Clear();
|
||||
btnAdd.Items.Add("相机设置");
|
||||
btnAdd.Items.Add("工位设置");
|
||||
btnAdd.Items.Add("运控设置");
|
||||
|
||||
x = Width;
|
||||
y = Height;
|
||||
AdaptiveHelper.setTag(this);
|
||||
|
||||
// 从文件加载配置
|
||||
var loadedConfig = ConfigManager.LoadConfig();
|
||||
if (loadedConfig != null)
|
||||
{
|
||||
// 更新当前列表
|
||||
CameraBaseList = loadedConfig.Cameras;
|
||||
PLCBaseList = loadedConfig.PLCs;
|
||||
DetectionList = loadedConfig.Detections;
|
||||
if (CameraBaseList.Count > 0)
|
||||
{
|
||||
var workstationItem = FindMenuItem(menu1.Items, "相机设置");
|
||||
|
||||
if (workstationItem != null)
|
||||
{
|
||||
foreach (var item in CameraBaseList)
|
||||
{
|
||||
var newItem = new MenuItem();
|
||||
newItem.Text = item.CameraName;
|
||||
newItem.IconSvg = "VideoCameraOutlined";
|
||||
workstationItem.Sub.Add(newItem);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
if (DetectionList.Count > 0)
|
||||
{
|
||||
var workstationItem = FindMenuItem(menu1.Items, "工位设置");
|
||||
|
||||
if (workstationItem != null)
|
||||
{
|
||||
foreach (var item in DetectionList)
|
||||
{
|
||||
var newItem = new MenuItem();
|
||||
newItem.Text = item.Name;
|
||||
newItem.IconSvg = "AppstoreOutlined";
|
||||
workstationItem.Sub.Add(newItem);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (PLCBaseList.Count > 0)
|
||||
{
|
||||
var workstationItem = FindMenuItem(menu1.Items, "运控设置");
|
||||
|
||||
if (workstationItem != null)
|
||||
{
|
||||
foreach (var item in PLCBaseList)
|
||||
{
|
||||
var newItem = new MenuItem();
|
||||
newItem.Text = item.PLCName;
|
||||
newItem.IconSvg = "ControlOutlined";
|
||||
workstationItem.Sub.Add(newItem);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnSave_Click(object? sender, EventArgs e)
|
||||
{
|
||||
|
||||
var config = ConfigManager.CreateConfig(CameraBaseList, PLCBaseList, DetectionList);
|
||||
ConfigManager.SaveConfig(config);
|
||||
MessageBox.Show("保存成功!");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void SettingWindow1_Resize(object? sender, EventArgs e)
|
||||
{
|
||||
var newx = Width / x;
|
||||
var newy = Height / y;
|
||||
AdaptiveHelper.setControls(newx, newy, this);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// 递归查找菜单项
|
||||
private MenuItem FindMenuItem(MenuItemCollection items, string targetText)
|
||||
{
|
||||
foreach (MenuItem item in items)
|
||||
{
|
||||
if (item.Text == targetText) return item;
|
||||
if (item.Sub != null)
|
||||
{
|
||||
var subResult = FindMenuItem(item.Sub, targetText);
|
||||
if (subResult != null) return subResult;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
bool isUpdatingTabs = false;
|
||||
|
||||
|
||||
private void menu1_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
// 转换坐标到控件内部坐标系(考虑滚动条)
|
||||
Point clickPoint = new Point(e.X, e.Y + menu1.ScrollBar.Value);
|
||||
|
||||
// 递归查找命中的菜单项
|
||||
MenuItem clickedItem = FindClickedItem(menu1.Items, clickPoint);
|
||||
|
||||
if (clickedItem != null)
|
||||
{
|
||||
if (clickedItem.PARENTITEM == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (clickedItem.PARENTITEM.Text)
|
||||
{
|
||||
case "相机设置":
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
//先获取是否存在该名称的配置
|
||||
//如果没有新建项
|
||||
CameraBase? CameraBase= CameraBaseList.Where(c => c.CameraName == clickedItem.Text).FirstOrDefault();
|
||||
if (CameraBase == null)
|
||||
{
|
||||
CameraBase=new CameraBase();
|
||||
}
|
||||
UserControl control = null;
|
||||
control = new CameraControl(this, CameraBase);
|
||||
if (control != null)
|
||||
{
|
||||
//容器添加控件,需要调整dpi
|
||||
control.Dock = DockStyle.Fill;
|
||||
AutoDpi(control);
|
||||
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
||||
{
|
||||
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
||||
ReadOnly = false,
|
||||
|
||||
};
|
||||
tabPage.Controls.Add(control);
|
||||
tabs1.Pages.Add(tabPage);
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = tabPage;
|
||||
isUpdatingTabs = false;
|
||||
currControl = control;
|
||||
}
|
||||
break;
|
||||
case "工位设置":
|
||||
// 检查是否已存在同名 TabPage
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
UserControl control1 = null;
|
||||
control1 = new DetectControl(this);
|
||||
if (control1 != null)
|
||||
{
|
||||
//容器添加控件,需要调整dpi
|
||||
control1.Dock = DockStyle.Fill;
|
||||
AutoDpi(control1);
|
||||
AntdUI.TabPage tabPage = new AntdUI.TabPage()
|
||||
{
|
||||
Text = $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}",
|
||||
ReadOnly = false ,
|
||||
|
||||
};
|
||||
tabPage.Controls.Add(control1);
|
||||
tabs1.Pages.Add(tabPage);
|
||||
isUpdatingTabs = true;
|
||||
tabs1.SelectedTab = tabPage;
|
||||
isUpdatingTabs = false;
|
||||
currControl = control1;
|
||||
}
|
||||
break;
|
||||
|
||||
case "运控设置":
|
||||
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
else if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
|
||||
// 转换坐标到控件内部坐标系(考虑滚动条)
|
||||
Point clickPoint = new Point(e.X, e.Y + menu1.ScrollBar.Value);
|
||||
|
||||
// 递归查找命中的菜单项
|
||||
MenuItem clickedItem = FindClickedItem(menu1.Items, clickPoint);
|
||||
|
||||
if (clickedItem != null)
|
||||
{
|
||||
if (clickedItem.PARENTITEM == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
switch (clickedItem.PARENTITEM.Text)
|
||||
{
|
||||
case "相机设置":
|
||||
var menulist = new AntdUI.IContextMenuStripItem[]
|
||||
{
|
||||
new AntdUI.ContextMenuStripItem("删除相机", "")
|
||||
{
|
||||
IconSvg = "DeleteOutlined"
|
||||
}
|
||||
|
||||
};
|
||||
AntdUI.ContextMenuStrip.open(menu1, it =>
|
||||
{
|
||||
menu1.Remove(clickedItem);
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs1.Pages.Remove(tab);
|
||||
CameraBaseList.RemoveAll(c => c.CameraName == clickedItem.Text);
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
CameraBaseList.RemoveAll(c => c.CameraName == clickedItem.Text);
|
||||
}, menulist);
|
||||
break;
|
||||
case "工位设置":
|
||||
var menulist1 = new AntdUI.IContextMenuStripItem[]
|
||||
{
|
||||
new AntdUI.ContextMenuStripItem("删除工位", "")
|
||||
{
|
||||
IconSvg = "DeleteOutlined"
|
||||
}
|
||||
|
||||
};
|
||||
AntdUI.ContextMenuStrip.open(menu1, it =>
|
||||
{
|
||||
menu1.Remove(clickedItem);
|
||||
foreach (var tab in tabs1.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == $"{clickedItem.PARENTITEM.Text}-{clickedItem.Text}")
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
//tabs1.SelectedTab = existingTab; // 直接跳转到已存在的 TabPage
|
||||
tabs1.Pages.Remove(tab);
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}, menulist1);
|
||||
break;
|
||||
|
||||
case "运控设置":
|
||||
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private MenuItem FindClickedItem(MenuItemCollection items, Point clickPoint)
|
||||
{
|
||||
foreach (MenuItem item in items)
|
||||
{
|
||||
// 检查当前项是否可见且包含点击坐标
|
||||
if (item.Visible && item.Rect.Contains(clickPoint))
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
// 递归检查子项(如果展开)
|
||||
if (item.Expand && item.Sub != null)
|
||||
{
|
||||
var childResult = FindClickedItem(item.Sub, clickPoint);
|
||||
if (childResult != null) return childResult;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void btnAdd_SelectedValueChanged(object sender, ObjectNEventArgs e)
|
||||
{
|
||||
string selectedValue = e.Value.ToString();
|
||||
switch (selectedValue)
|
||||
{
|
||||
case "相机设置":
|
||||
var workstationItem = FindMenuItem(menu1.Items, "相机设置");
|
||||
|
||||
if (workstationItem != null)
|
||||
{
|
||||
|
||||
var form = new AddCameraControl(this) { Size = new Size(300, 200) };
|
||||
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
||||
{
|
||||
BtnHeight = 0,
|
||||
});
|
||||
if (form.submit)
|
||||
{
|
||||
var newItem = new MenuItem(form.CubicleName);
|
||||
newItem.IconSvg = "VideoCameraOutlined";
|
||||
// 防止重复添加
|
||||
if (!menu1.Items.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
|
||||
{
|
||||
workstationItem.Sub.Add(newItem);
|
||||
CameraBase cameraBase = new CameraBase();
|
||||
cameraBase.CameraName = form.CubicleName;
|
||||
CameraBaseList.Add(cameraBase);
|
||||
}
|
||||
else
|
||||
{
|
||||
AntdUI.Notification.warn(this, "新增相机失败", $"{form.CubicleName}已存在!", autoClose: 3, align: TAlignFrom.TR);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "工位设置":
|
||||
// 查找工位设置项
|
||||
var workstationItem1= FindMenuItem(menu1.Items, "工位设置");
|
||||
|
||||
if (workstationItem1 != null)
|
||||
{
|
||||
|
||||
var form = new AddCubicleControl(this) { Size = new Size(300, 200) };
|
||||
AntdUI.Modal.open(new AntdUI.Modal.Config(this, "", form, TType.None)
|
||||
{
|
||||
BtnHeight = 0,
|
||||
});
|
||||
if (form.submit)
|
||||
{
|
||||
var newItem = new MenuItem(form.CubicleName);
|
||||
newItem.IconSvg = "AppstoreOutlined";
|
||||
// 防止重复添加
|
||||
if (!menu1.Items.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
|
||||
{
|
||||
workstationItem1.Sub.Add(newItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
AntdUI.Notification.warn(this, "新增工位失败", $"{form.CubicleName}已存在!", autoClose: 3, align: TAlignFrom.TR);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "运控设置":
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using DH.Commons.Enums;
|
||||
using DH.Commons.Base;
|
||||
using DH.Commons.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
|
@ -1,7 +1,6 @@
|
||||
using AntdUI;
|
||||
using AntdUIDemo.Models;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Devices;
|
||||
using DH.Commons.Base;
|
||||
using DH.Devices.Vision;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
44
DHSoftware/Views/MotionControl.Designer.cs
generated
44
DHSoftware/Views/MotionControl.Designer.cs
generated
@ -1,44 +0,0 @@
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
partial class _MotionControl
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
SuspendLayout();
|
||||
//
|
||||
// _MotionControl
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Name = "_MotionControl";
|
||||
Size = new Size(782, 481);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
public partial class _MotionControl : UserControl
|
||||
{
|
||||
public _MotionControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
using DH.Commons.Enums;
|
||||
using DH.Commons.Base;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Vision;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
Loading…
x
Reference in New Issue
Block a user