Compare commits
4 Commits
a9d02a5a9d
...
c49c45d6e4
| Author | SHA1 | Date | |
|---|---|---|---|
| c49c45d6e4 | |||
| ca6476b87c | |||
| 9a330c01f8 | |||
| 7828ca663f |
130
DH.Commons.Devies/Base/CameraBase.cs
Normal file
130
DH.Commons.Devies/Base/CameraBase.cs
Normal file
@@ -0,0 +1,130 @@
|
||||
using System.ComponentModel;
|
||||
using System.Drawing.Imaging;
|
||||
using OpenCvSharp;
|
||||
|
||||
namespace DH.Devices.Devices
|
||||
{
|
||||
public class CameraBase
|
||||
{
|
||||
public volatile int SnapshotCount = 0;
|
||||
|
||||
public virtual bool isEnabled { get; set; } = false;
|
||||
|
||||
[Category("采图模式")]
|
||||
[Description("是否连续模式。true:连续模式采图;false:触发模式采图")]
|
||||
[DisplayName("连续模式")]
|
||||
public bool IsContinueMode { get; set; } = false;
|
||||
|
||||
|
||||
public virtual bool isSavePicEnabled { get; set; } = false;
|
||||
|
||||
|
||||
|
||||
[Category("图片保存")]
|
||||
[Description("图片保存文件夹")]
|
||||
[DisplayName("图片保存文件夹")]
|
||||
public virtual string ImageSaveDirectory { get; set; }
|
||||
|
||||
[Category("图片保存")]
|
||||
[Description("图片保存格式")]
|
||||
[DisplayName("图片保存格式")]
|
||||
public ImageFormat ImageFormat { get; set; } = ImageFormat.Jpeg;
|
||||
|
||||
[Category("采图模式")]
|
||||
[Description("是否硬触发模式。true:硬触发;false:软触发")]
|
||||
[DisplayName("硬触发")]
|
||||
public bool IsHardwareTrigger { get; set; } = false;
|
||||
|
||||
public string SerialNumber { get; set; } = string.Empty;
|
||||
public string CameraName { get; set; } = string.Empty;
|
||||
|
||||
public string CameraIP { get; set; } = string.Empty;
|
||||
|
||||
public string ComputerIP { get; set; } = string.Empty;
|
||||
|
||||
// public StreamFormat dvpStreamFormat = dvpStreamFormat.;
|
||||
|
||||
[Category("采图模式")]
|
||||
[Description("是否传感器直接硬触发。true:传感器硬触发,不通过软件触发;false:通过软件触发IO 的硬触发模式")]
|
||||
[DisplayName("是否传感器直接硬触发")]
|
||||
public bool IsDirectHardwareTrigger { get; set; } = false;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 增益
|
||||
/// </summary>
|
||||
[Category("相机设置")]
|
||||
[DisplayName("增益")]
|
||||
[Description("Gain:增益,-1:不设置,不同型号相机的增益,请参考mvs")]
|
||||
public float Gain { get; set; } = -1;
|
||||
|
||||
[Category("图像旋转")]
|
||||
[Description("默认旋转,相机开启后默认不旋转")]
|
||||
[DisplayName("默认旋转")]
|
||||
public virtual float RotateImage { get; set; } = 0;
|
||||
|
||||
[Category("取像配置")]
|
||||
[Description("曝光")]
|
||||
[DisplayName("曝光")]
|
||||
public virtual float Exposure { get; set; } = 200;
|
||||
|
||||
[Category("相机设置")]
|
||||
[DisplayName("硬触发后的延迟")]
|
||||
[Description("TriggerDelay:硬触发后的延迟,单位:us 微秒")]
|
||||
public float TriggerDelay { get; set; } = 0;
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 滤波时间
|
||||
/// </summary>
|
||||
[Category("相机设置")]
|
||||
[DisplayName("滤波时间")]
|
||||
[Description("LineDebouncerTime:I/O去抖时间 单位:us")]
|
||||
public int LineDebouncerTime { get; set; } = 0;
|
||||
|
||||
|
||||
|
||||
public Action<DateTime, CameraBase, Mat> OnHImageOutput { get; set; }
|
||||
/// <summary>
|
||||
/// 相机连接
|
||||
/// </summary>
|
||||
/// <returns>是否成功</returns>
|
||||
public virtual bool CameraConnect() { return false; }
|
||||
|
||||
/// <summary>
|
||||
/// 相机断开
|
||||
/// </summary>
|
||||
/// <returns>是否成功</returns>
|
||||
public virtual bool CameraDisConnect() { return false; }
|
||||
|
||||
/// <summary>
|
||||
/// 抓取一张图像
|
||||
/// </summary>
|
||||
/// <returns>图像</returns>
|
||||
//internal virtual HObject GrabOneImage(string cameraName) { return null; }
|
||||
/// <summary>
|
||||
/// 设置曝光时间
|
||||
/// </summary>
|
||||
/// <param name="exposureTime">曝光时间</param>
|
||||
public virtual void SetExposure(int exposureTime, string cameraName) { }
|
||||
/// <summary>
|
||||
/// 设置增益
|
||||
/// </summary>
|
||||
/// <param name="exposure">增益</param>
|
||||
public virtual void SetGain(int gain, string cameraName) { }
|
||||
/// <summary>
|
||||
/// 设置采集模式
|
||||
/// </summary>
|
||||
/// <param name="mode">0=连续采集,即异步采集 1=单次采集,即同步采集</param>
|
||||
internal virtual void SetAcquisitionMode(int mode) { }
|
||||
/// <summary>
|
||||
/// 设置采集图像的ROI
|
||||
/// </summary>
|
||||
internal virtual void SetAcqRegion(int offsetV, int offsetH, int imageH, int imageW, string cameraName) { }
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
186
DH.Commons.Devies/Base/VisionEngineBase.cs
Normal file
186
DH.Commons.Devies/Base/VisionEngineBase.cs
Normal file
@@ -0,0 +1,186 @@
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using DH.Commons.Enums;
|
||||
using HalconDotNet;
|
||||
using OpenCvSharp;
|
||||
|
||||
|
||||
|
||||
namespace DH.Devices.Devices
|
||||
{
|
||||
/// <summary>
|
||||
/// 视觉处理引擎:1.传统视觉 2.深度学习
|
||||
/// CV深度学习 四大领域
|
||||
/// Image Classification 图像分类:判别图中物体是什么,比如是猫还是狗;
|
||||
/// Semantic Segmentation 语义分割:对图像进行像素级分类,预测每个像素属于的类别,不区分个体;
|
||||
/// Object Detection 目标检测:寻找图像中的物体并进行定位;
|
||||
/// Instance Segmentation 实例分割:定位图中每个物体,并进行像素级标注,区分不同个体;
|
||||
/// </summary>
|
||||
public abstract class VisionEngineBase
|
||||
{
|
||||
public List<DetectionConfig> DetectionConfigs = new List<DetectionConfig>();
|
||||
#region event
|
||||
public event Action<string, List<double>> OnCropParamsOutput;
|
||||
public event Action<string, Bitmap, List<IShapeElement>> OnDetectionDone;
|
||||
public event Action<string> OnDetectionWarningStop;//有无检测 需要报警停机
|
||||
#endregion
|
||||
//public VisionEngineInitialConfigBase IConfig
|
||||
//{
|
||||
// get => InitialConfig as VisionEngineInitialConfigBase;
|
||||
//}
|
||||
// public ImageSaveHelper ImageSaveHelper { get; set; } = new ImageSaveHelper();
|
||||
public string BatchNO { get; set; }
|
||||
|
||||
public HTuple hv_ModelID;
|
||||
|
||||
public abstract DetectStationResult RunInference(Mat originImgSet, string detectionId = null);
|
||||
|
||||
//public abstract void SaveDetectResultAsync(DetectStationResult detectResult);
|
||||
|
||||
|
||||
|
||||
public virtual void DetectionDone(string detectionId, Bitmap image, List<IShapeElement> detectionResults)
|
||||
{
|
||||
OnDetectionDone?.Invoke(detectionId, image, detectionResults);
|
||||
}
|
||||
|
||||
public virtual void DetectionWarningStop(string detectionDes)
|
||||
{
|
||||
OnDetectionWarningStop?.Invoke(detectionDes);
|
||||
}
|
||||
|
||||
public virtual void SaveImageAsync(string fullname, Bitmap saveMap, ImageFormat imageFormat)
|
||||
{
|
||||
if (saveMap != null)
|
||||
{
|
||||
//ImageSaveSet imageSaveSet = new ImageSaveSet()
|
||||
//{
|
||||
// FullName = fullname,
|
||||
// SaveImage = saveMap.CopyBitmap(),
|
||||
// ImageFormat = imageFormat.DeepSerializeClone()
|
||||
//};
|
||||
|
||||
//ImageSaveHelper.ImageSaveAsync(imageSaveSet);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class CamModuleXY
|
||||
{
|
||||
[Category("图片行")]
|
||||
[DisplayName("行")]
|
||||
[Description("行")]
|
||||
// [TypeConverter(typeof(DeviceIdSelectorConverter<CameraBase>))]
|
||||
//[TypeConverter(typeof(CollectionCountConvert))]
|
||||
public int PicRows { get; set; } = 1;
|
||||
|
||||
[Category("图片列")]
|
||||
[DisplayName("列")]
|
||||
[Description("列")]
|
||||
// [TypeConverter(typeof(DeviceIdSelectorConverter<CameraBase>))]
|
||||
//[TypeConverter(typeof(CollectionCountConvert))]
|
||||
public int PicCols { get; set; } = 1;
|
||||
|
||||
public string GetDisplayText()
|
||||
{
|
||||
return "行:" + PicRows.ToString() + "列:" + PicCols.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
//public class RelatedCamera
|
||||
//{
|
||||
|
||||
// [Category("关联相机")]
|
||||
// [DisplayName("关联相机")]
|
||||
// [Description("关联相机描述")]
|
||||
// //[TypeConverter(typeof(DeviceIdSelectorConverter<CameraBase>))]
|
||||
// //[TypeConverter(typeof(CollectionCountConvert))]
|
||||
// public string CameraSourceId { get; set; } = "";
|
||||
|
||||
|
||||
// //public string GetDisplayText()
|
||||
// //{
|
||||
// // using (var scope = GlobalVar.Container.BeginLifetimeScope())
|
||||
// // {
|
||||
// // List<IDevice> deviceList = scope.Resolve<List<IDevice>>();
|
||||
// // IDevice CameraDevice = deviceList.FirstOrDefault(dev => dev.Id.Equals(CameraSourceId));
|
||||
|
||||
// // if (CameraDevice != null && CameraDevice is CameraBase)
|
||||
// // {
|
||||
// // return CameraDevice.Name;
|
||||
// // }
|
||||
|
||||
// // }
|
||||
// // return CameraSourceId;
|
||||
// //}
|
||||
//}
|
||||
public class VisionEngineInitialConfigBase //: InitialConfigBase
|
||||
{
|
||||
[Category("深度学习检测配置")]
|
||||
[DisplayName("检测配置集合")]
|
||||
[Description("检测配置集合")]
|
||||
//[TypeConverter(typeof(CollectionCountConvert))]
|
||||
//[Editor(typeof(ComplexCollectionEditor<DetectionConfig>), typeof(UITypeEditor))]
|
||||
public List<DetectionConfig> DetectionConfigs { get; set; } = new List<DetectionConfig>();
|
||||
|
||||
[Category("深度学习检测配置")]
|
||||
[DisplayName("标签分类")]
|
||||
[Description("标签分类,A_NG,B_TBD...")]
|
||||
// [TypeConverter(typeof(CollectionCountConvert))]
|
||||
// [Editor(typeof(ComplexCollectionEditor<RecongnitionLabelCategory>), typeof(UITypeEditor))]
|
||||
public List<RecongnitionLabelCategory> RecongnitionLabelCategoryList { get; set; } = new List<RecongnitionLabelCategory>();
|
||||
|
||||
[Category("深度学习检测配置")]
|
||||
[DisplayName("检测标签定义集合")]
|
||||
[Description("定义检测标签的集合,例如:Seg/Detection模式:断裂、油污、划伤...;Class模式:ok、ng、上面、下面、套环、正常...")]
|
||||
// [TypeConverter(typeof(CollectionCountConvert))]
|
||||
// [Editor(typeof(ComplexCollectionEditor<RecongnitionLabel>), typeof(UITypeEditor))]
|
||||
public List<RecongnitionLabel> RecongnitionLabelList { get; set; } = new List<RecongnitionLabel>();
|
||||
|
||||
[Category("深度学习检测配置")]
|
||||
[DisplayName("标签置信度")]
|
||||
[Description("标签置信度,过滤小于改置信度的标签,大于该设置的标签才能识别")]
|
||||
public float Score { get; set; } = 0.5f;
|
||||
|
||||
[Category("深度学习检测配置")]
|
||||
[DisplayName("CPU线程数量")]
|
||||
[Description("用于深度学习的CPU线程数量,不要设置太大,会单独占用线程,影响其他程序运行")]
|
||||
public int CPUNums { get; set; } = 1;
|
||||
|
||||
//[Category("深度学习检测配置")]
|
||||
//[DisplayName("检测项GPU指定")]
|
||||
//[Description("将检测项指定到GPU")]
|
||||
// [TypeConverter(typeof(CollectionCountConvert))]
|
||||
// [Editor(typeof(ComplexCollectionEditor<DetectionGPUConfig>), typeof(UITypeEditor))]
|
||||
// public List<DetectionGPUConfig> DetectionGPUList { get; set; } = new List<DetectionGPUConfig>();
|
||||
|
||||
// [Category("数据保存配置")]
|
||||
//[DisplayName("是否保存检测明细CSV")]
|
||||
//[Description("是否保存 检测明细CSV")]
|
||||
//public override bool IsEnableCSV { get; set; } = true;
|
||||
|
||||
//[Category("数据保存配置")]
|
||||
//[DisplayName("是否保存检测图片")]
|
||||
//[Description("是否保存 检测图片,总开关")]
|
||||
//public bool IsSaveImage { get; set; } = true;
|
||||
|
||||
//[Category("数据保存配置")]
|
||||
//[Description("检测图片 保存文件夹")]
|
||||
//[DisplayName("检测图片保存文件夹")]
|
||||
//[Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
|
||||
//public string ImageSaveDirectory { get; set; } = "D:\\PROJECTS\\X017\\Images";
|
||||
|
||||
//[Category("数据保存配置")]
|
||||
//[Description("检测明细CSV文件夹")]
|
||||
//[DisplayName("检测明细CSV文件夹")]
|
||||
//[Editor(typeof(FoldDialogEditor), typeof(UITypeEditor))]
|
||||
//public string CSVDataPath { get; set; } = "D:\\PROJECTS\\X017\\Images";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
38
DH.Commons.Devies/DH.Commons.Devies.csproj
Normal file
38
DH.Commons.Devies/DH.Commons.Devies.csproj
Normal file
@@ -0,0 +1,38 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<BaseOutputPath>..\</BaseOutputPath>
|
||||
<AppendTargetFrameworkToOutputPath>output</AppendTargetFrameworkToOutputPath>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Enums\" />
|
||||
<Folder Include="Helper\" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<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" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="halcondotnet">
|
||||
<HintPath>..\x64\Debug\halcondotnet.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="hdevenginedotnet">
|
||||
<HintPath>..\x64\Debug\hdevenginedotnet.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -1,16 +1,18 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0</TargetFramework>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<Platforms>AnyCPU;X64</Platforms>
|
||||
<AllowUnsafeBlocks>True</AllowUnsafeBlocks>
|
||||
<BaseOutputPath>..\</BaseOutputPath>
|
||||
<AppendTargetFrameworkToOutputPath>output</AppendTargetFrameworkToOutputPath>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Helper\" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="OpenCvSharp4" Version="4.10.0.20241108" />
|
||||
|
||||
@@ -6,7 +6,7 @@ using System.Text.RegularExpressions;
|
||||
using System.Text;
|
||||
using System.Drawing.Design;
|
||||
|
||||
namespace DH.Devices.Vision
|
||||
namespace DH.Commons.Enums
|
||||
{
|
||||
public enum MLModelType
|
||||
{
|
||||
@@ -25,7 +25,9 @@ namespace DH.Devices.Vision
|
||||
}
|
||||
public class ModelLabel
|
||||
{
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string LabelId { get; set; }
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
|
||||
[Category("模型标签")]
|
||||
@@ -37,7 +39,9 @@ namespace DH.Devices.Vision
|
||||
[Category("模型标签")]
|
||||
[DisplayName("模型标签")]
|
||||
[Description("模型识别的标签名称")]
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string LabelName { get; set; }
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
|
||||
|
||||
@@ -57,7 +61,9 @@ namespace DH.Devices.Vision
|
||||
public class MLRequest
|
||||
{
|
||||
public int ImageChannels = 3;
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public Mat mImage;
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public int ResizeWidth;
|
||||
public int ResizeHeight;
|
||||
|
||||
@@ -68,11 +74,17 @@ namespace DH.Devices.Vision
|
||||
//public int ImageResizeCount;
|
||||
public bool IsCLDetection;
|
||||
public int ProCount;
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string in_node_name;
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string out_node_name;
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string in_lable_path;
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
public int ResizeImageSize;
|
||||
public int segmentWidth;
|
||||
@@ -81,7 +93,9 @@ namespace DH.Devices.Vision
|
||||
// public List<labelStringBase> OkClassTxtList;
|
||||
|
||||
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public List<ModelLabel> LabelNames;
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
|
||||
|
||||
@@ -113,16 +127,22 @@ namespace DH.Devices.Vision
|
||||
/// </summary>
|
||||
public class DetectionResultDetail
|
||||
{
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string LabelBGR { get; set; }//识别到对象的标签BGR
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
|
||||
public int LabelNo { get; set; } // 识别到对象的标签索引
|
||||
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string LabelName { get; set; }//识别到对象的标签名称
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
public double Score { get; set; }//识别目标结果的可能性、得分
|
||||
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string LabelDisplay { get; set; }//识别到对象的 显示信息
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
public double Area { get; set; }//识别目标的区域面积
|
||||
|
||||
@@ -141,8 +161,12 @@ namespace DH.Devices.Vision
|
||||
public class MLResult
|
||||
{
|
||||
public bool IsSuccess = false;
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string ResultMessage;
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public Bitmap ResultMap;
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public List<DetectionResultDetail> ResultDetails = new List<DetectionResultDetail>();
|
||||
}
|
||||
public class MLInit
|
||||
@@ -164,7 +188,11 @@ namespace DH.Devices.Vision
|
||||
public bool IsGPU;
|
||||
public int GPUId;
|
||||
public float Score_thre;
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public MLInit(string modelFile, bool isGPU, int gpuId, float score_thre)
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
{
|
||||
ModelFile = modelFile;
|
||||
IsGPU = isGPU;
|
||||
@@ -186,20 +214,27 @@ namespace DH.Devices.Vision
|
||||
}
|
||||
public class DetectStationResult
|
||||
{
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string Pid { get; set; }
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string TempPid { get; set; }
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
/// <summary>
|
||||
/// 检测工位名称
|
||||
/// </summary>
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string DetectName { get; set; }
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 深度学习 检测结果
|
||||
/// </summary>
|
||||
public List<DetectionResultDetail> DetectDetails = new List<DetectionResultDetail>();
|
||||
public List<IShapeElement> DetectionResultShapes = new List<IShapeElement>();
|
||||
|
||||
|
||||
/// <summary>
|
||||
@@ -237,7 +272,9 @@ namespace DH.Devices.Vision
|
||||
public int StationDetectElapsed { get; set; }
|
||||
public static string NormalizeAndClean(string input)
|
||||
{
|
||||
#pragma warning disable CS8603 // 可能返回 null 引用。
|
||||
if (input == null) return null;
|
||||
#pragma warning restore CS8603 // 可能返回 null 引用。
|
||||
|
||||
// Step 1: 标准化字符编码为 Form C (规范组合)
|
||||
string normalizedString = input.Normalize(NormalizationForm.FormC);
|
||||
@@ -274,6 +311,184 @@ namespace DH.Devices.Vision
|
||||
CameraSourceId = cameraSourceId;
|
||||
|
||||
}
|
||||
}
|
||||
public class CustomizedPoint : INotifyPropertyChanged, IComparable<CustomizedPoint>
|
||||
{
|
||||
private double x = 0;
|
||||
[Category("坐标设置")]
|
||||
[Description("X坐标")]
|
||||
public double X
|
||||
{
|
||||
get => x;
|
||||
set
|
||||
{
|
||||
if (value != x)
|
||||
{
|
||||
x = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("X"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private double y = 0;
|
||||
[Category("坐标设置")]
|
||||
[Description("Y坐标")]
|
||||
public double Y
|
||||
{
|
||||
get => y;
|
||||
set
|
||||
{
|
||||
if (value != y)
|
||||
{
|
||||
y = value;
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs("Y"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CustomizedPoint() { }
|
||||
|
||||
public CustomizedPoint(double x, double y)
|
||||
{
|
||||
X = x;
|
||||
Y = y;
|
||||
}
|
||||
|
||||
//public CustomizedPoint(Point p)
|
||||
//{
|
||||
// X = p.X;
|
||||
// Y = p.Y;
|
||||
//}
|
||||
|
||||
public CustomizedPoint(PointF p)
|
||||
{
|
||||
X = p.X;
|
||||
Y = p.Y;
|
||||
}
|
||||
|
||||
public CustomizedPoint(CustomizedPoint p)
|
||||
{
|
||||
X = p.X;
|
||||
Y = p.Y;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据PLC的读取数值获取点位坐标
|
||||
/// </summary>
|
||||
/// <param name="plcValues">0:X低位 1:X高位 2:Y低位 3:Y高位</param>
|
||||
//public CustomizedPoint(List<int> plcValues)
|
||||
//{
|
||||
// if (plcValues == null || plcValues.Count != 4)
|
||||
// return;
|
||||
|
||||
// var list = plcValues.ParseUnsignShortListToInt();
|
||||
|
||||
// X = list[0];
|
||||
// Y = list[1];
|
||||
//}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public static List<CustomizedPoint> GetPoints(List<double> Xs, List<double> Ys)
|
||||
{
|
||||
List<CustomizedPoint> points = new List<CustomizedPoint>();
|
||||
for (int i = 0; i < Xs.Count && i < Ys.Count; i++)
|
||||
{
|
||||
points.Add(new CustomizedPoint(Xs[i], Ys[i]));
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return GetDisplayText();
|
||||
}
|
||||
|
||||
public virtual string GetDisplayText()
|
||||
{
|
||||
return string.Format("X:{0};Y:{1}", X, Y);
|
||||
}
|
||||
|
||||
public virtual string GetCSVHead()
|
||||
{
|
||||
return "X,Y";
|
||||
}
|
||||
|
||||
public virtual string GetCSVData()
|
||||
{
|
||||
return X.ToString("f3") + ";" + Y.ToString("f3");
|
||||
}
|
||||
|
||||
//public static double GetCustomizedPointDistance(CustomizedPoint startPoint, CustomizedPoint endPoint)
|
||||
//{
|
||||
// return Math.Sqrt(Math.Pow(endPoint.X - startPoint.X, 2) + Math.Pow(endPoint.Y - startPoint.Y, 2));
|
||||
//}
|
||||
|
||||
public CustomizedPoint OffsetClone(CustomizedPoint point)
|
||||
{
|
||||
return new CustomizedPoint(X + point.X, Y + point.Y);
|
||||
}
|
||||
|
||||
public void Offset(CustomizedPoint point)
|
||||
{
|
||||
X += point.X;
|
||||
Y += point.Y;
|
||||
}
|
||||
|
||||
public int CompareTo(CustomizedPoint other)
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
public static CustomizedPoint operator -(CustomizedPoint p1, CustomizedPoint p2)
|
||||
{
|
||||
return new CustomizedPoint(p1.X - p2.X, p1.Y - p2.Y);
|
||||
}
|
||||
|
||||
public static CustomizedPoint operator +(CustomizedPoint p1, CustomizedPoint p2)
|
||||
{
|
||||
return new CustomizedPoint(p1.X + p2.X, p1.Y + p2.Y);
|
||||
}
|
||||
}
|
||||
public class PreTreatParam
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 参数名称
|
||||
/// </summary>
|
||||
///
|
||||
[Category("预处理参数")]
|
||||
[DisplayName("参数名称")]
|
||||
[Description("参数名称")]
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string Name { get; set; }
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 参数值
|
||||
/// </summary>
|
||||
///
|
||||
[Category("预处理参数")]
|
||||
[DisplayName("参数值")]
|
||||
[Description("参数值")]
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string Value { get; set; }
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
|
||||
}
|
||||
public class DetectionConfig
|
||||
{
|
||||
@@ -405,7 +620,12 @@ namespace DH.Devices.Vision
|
||||
//[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()
|
||||
{
|
||||
@@ -413,7 +633,7 @@ namespace DH.Devices.Vision
|
||||
}
|
||||
|
||||
public DetectionConfig(string name, MLModelType modelType, string modelPath, bool isEnableGPU,string sCameraSourceId)
|
||||
{
|
||||
{
|
||||
ModelPath = modelPath ?? string.Empty;
|
||||
Name = name;
|
||||
ModelType = modelType;
|
||||
@@ -463,7 +683,9 @@ namespace DH.Devices.Vision
|
||||
[DisplayName("检测项标签")]
|
||||
[Description("检测标签Id")]
|
||||
//[TypeConverter(typeof(DetectionLabelConverter))]
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string LabelId { get; set; }
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
[Browsable(false)]
|
||||
//public string LabelName { get => GetLabelName(); }
|
||||
@@ -562,11 +784,13 @@ namespace DH.Devices.Vision
|
||||
[DisplayName("检测标签")]
|
||||
[Description("检测标签信息")]
|
||||
//[TypeConverter(typeof(DetectionLabelConverter))]
|
||||
|
||||
public string LabelId { get; set; }
|
||||
|
||||
// [Browsable(false)]
|
||||
|
||||
public string LabelName { get; set; }
|
||||
|
||||
|
||||
[Category("过滤器基础信息")]
|
||||
[DisplayName("是否启用过滤器")]
|
||||
[Description("是否启用过滤器")]
|
||||
16
DH.Commons/Enums/ClassHelper.cs
Normal file
16
DH.Commons/Enums/ClassHelper.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DH.Commons.Enums
|
||||
{
|
||||
public class CameraInfo
|
||||
{
|
||||
public string CamName { get; set; }
|
||||
public string Serinum { get; set; }
|
||||
public string IP { get; set; }
|
||||
}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace XKRS.Common.Model.SolidMotionCard
|
||||
namespace DH.Commons.Enums
|
||||
{
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
|
||||
namespace XKRS.Common.Model
|
||||
namespace DH.Commons.Enums
|
||||
{
|
||||
public static class GlobalVar
|
||||
{
|
||||
|
||||
771
DH.Commons/Helper/EnumHelper.cs
Normal file
771
DH.Commons/Helper/EnumHelper.cs
Normal file
@@ -0,0 +1,771 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace DH.Commons.Enums
|
||||
{
|
||||
public static class EnumHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据枚举的代码名称获取枚举列表信息
|
||||
/// </summary>
|
||||
/// <param name="enumName"></param>
|
||||
/// <returns></returns>
|
||||
public static List<dynamic> GetEnumListByName(string enumName, string assemblyName = "Common.Model.Helper.EnumHelper+")
|
||||
{
|
||||
List<dynamic> list = new List<dynamic>();
|
||||
|
||||
string fullName = assemblyName + enumName;
|
||||
|
||||
Type t = typeof(EnumHelper).Assembly.GetType(fullName);
|
||||
|
||||
t.GetEnumNames().ToList().ForEach(e =>
|
||||
{
|
||||
int value = Convert.ToInt32(Enum.Parse(t, e));
|
||||
string desc = ((Enum)Enum.Parse(t, e)).GetEnumDescription();
|
||||
var item = new { Value = value, Desc = desc, Code = e };
|
||||
list.Add(item);
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取枚举的列表信息,一般供下拉列表使用
|
||||
/// </summary>
|
||||
/// <param name="enumType">枚举类型</param>
|
||||
/// <returns>Desc:中文描述 Value:整形值 Code:枚举值</returns>
|
||||
public static List<dynamic> GetEnumListByType(Type enumType)
|
||||
{
|
||||
List<dynamic> list = new List<dynamic>();
|
||||
|
||||
enumType.GetEnumNames().ToList().ForEach(e =>
|
||||
{
|
||||
int value = Convert.ToInt32(Enum.Parse(enumType, e));
|
||||
string desc = ((Enum)Enum.Parse(enumType, e)).GetEnumDescription();
|
||||
var item = new { Value = value, Desc = desc, Code = e };
|
||||
list.Add(item);
|
||||
});
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取具体某一枚举的中文描述
|
||||
/// </summary>
|
||||
/// <param name="enumObj"></param>
|
||||
/// <returns></returns>
|
||||
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 System.Windows.Media.Color GetEnumSelectedMediaColor(this Enum enumObj)
|
||||
//{
|
||||
// Type t = enumObj.GetType();
|
||||
// FieldInfo f = t.GetField(enumObj.ToString());
|
||||
|
||||
// ColorSelectAttribute attr = f.GetCustomAttribute<ColorSelectAttribute>();
|
||||
// if (attr != null)
|
||||
// {
|
||||
// var prop = typeof(System.Windows.Media.Colors).GetProperties().FirstOrDefault(p => p.Name == attr.SelectedColor);
|
||||
// if (prop != null)
|
||||
// {
|
||||
// return (System.Windows.Media.Color)prop.GetValue(null);
|
||||
// }
|
||||
// }
|
||||
// return System.Windows.Media.Colors.Transparent;
|
||||
//}
|
||||
|
||||
//public static System.Drawing.Color GetEnumSelectedColor(this Enum enumObj)
|
||||
//{
|
||||
// Type t = enumObj.GetType();
|
||||
// FieldInfo f = t.GetField(enumObj.ToString());
|
||||
|
||||
// ColorSelectAttribute attr = f.GetCustomAttribute<ColorSelectAttribute>();
|
||||
// if (attr != null)
|
||||
// {
|
||||
// return System.Drawing.Color.FromName(attr.SelectedColor);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return System.Drawing.Color.Transparent;
|
||||
// }
|
||||
//}
|
||||
|
||||
//public static System.Drawing.Color GetEnumSelectedFontColor(this Enum enumObj)
|
||||
//{
|
||||
// Type t = enumObj.GetType();
|
||||
// FieldInfo f = t.GetField(enumObj.ToString());
|
||||
|
||||
// var attr = f.GetCustomAttribute<FontColorSelectAttribute>();
|
||||
// if (attr != null)
|
||||
// {
|
||||
// return System.Drawing.Color.FromName(attr.SelectedColor);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return System.Drawing.Color.Transparent;
|
||||
// }
|
||||
//}
|
||||
|
||||
//public static string GetEnumSelectedColorString(this Enum enumObj)
|
||||
//{
|
||||
// Type t = enumObj.GetType();
|
||||
// FieldInfo f = t.GetField(enumObj.ToString());
|
||||
|
||||
// ColorSelectAttribute attr = f.GetCustomAttribute<ColorSelectAttribute>();
|
||||
// if (attr != null)
|
||||
// {
|
||||
// return attr.SelectedColor;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return "Transparent";
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 当枚举牵涉到状态变换,检查现状态是否满足待转换的状态的前置状态要求
|
||||
/// </summary>
|
||||
/// <param name="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());
|
||||
|
||||
// PreStateAttribute attr = f.GetCustomAttribute<PreStateAttribute>();
|
||||
// if (attr == null)
|
||||
// {
|
||||
// return true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return attr.CheckPreStateValid(currentState);
|
||||
// }
|
||||
//}
|
||||
|
||||
/// <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,
|
||||
//}
|
||||
|
||||
[Flags]
|
||||
public enum DeviceAttributeType
|
||||
{
|
||||
[Description("设备驱动")]
|
||||
Device = 1,
|
||||
|
||||
[Description("初始配置")]
|
||||
InitialConfig = 2,
|
||||
[Description("操作配置")]
|
||||
OperationConfig = 4,
|
||||
[Description("设备配置")]
|
||||
DeviceConfig = 8,
|
||||
[Description("输入配置")]
|
||||
InputConfig = 16,
|
||||
|
||||
[Description("初始配置控件")]
|
||||
InitialConfigCtrl = 32,
|
||||
[Description("操作配置控件")]
|
||||
OperationConfigCtrl = 64,
|
||||
[Description("设备配置控件")]
|
||||
DeviceConfigCtrl = 128,
|
||||
[Description("输入配置控件")]
|
||||
InputConfigCtrl = 256,
|
||||
|
||||
[Description("运行控件")]
|
||||
RunCtrl = 512,
|
||||
|
||||
[Description("操作配置面板")]
|
||||
OperationConfigPanel = 1024,
|
||||
}
|
||||
|
||||
public enum EnableState
|
||||
{
|
||||
[Description("启用")]
|
||||
Enabled = 0,
|
||||
[Description("禁用")]
|
||||
Disabled = 1,
|
||||
}
|
||||
|
||||
public enum EnableStateFilter
|
||||
{
|
||||
[Description("全部")]
|
||||
All = -1,
|
||||
[Description("启用")]
|
||||
Enabled = 0,
|
||||
[Description("禁用")]
|
||||
Disabled = 1,
|
||||
}
|
||||
|
||||
public enum OutputResult
|
||||
{
|
||||
[Description("OK")]
|
||||
OK = 1,
|
||||
[Description("NG")]
|
||||
NG = 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PLC项目的值的类型
|
||||
/// </summary>
|
||||
public enum PLCItemType
|
||||
{
|
||||
[Description("布尔类型")]
|
||||
Bool = 0,
|
||||
[Description("整型")]
|
||||
Integer = 1,
|
||||
[Description("字符串型")]
|
||||
String = 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 对PLC项目的操作类型
|
||||
/// </summary>
|
||||
public enum PLCOpType
|
||||
{
|
||||
[Description("读取")]
|
||||
Read = 1,
|
||||
[Description("写入")]
|
||||
Write = 2,
|
||||
[Description("监控")]
|
||||
Monitor = 4,
|
||||
|
||||
/// <summary>
|
||||
/// 报警监控 1+8
|
||||
/// </summary>
|
||||
[Description("报警监控")]
|
||||
WarningMonitor = 9,
|
||||
|
||||
/// <summary>
|
||||
/// CT监控 1+16
|
||||
/// </summary>
|
||||
[Description("CT监控")]
|
||||
CTMonitor = 17,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 相机运行模式
|
||||
/// </summary>
|
||||
public enum CameraOpMode
|
||||
{
|
||||
[Description("单次拍照")]
|
||||
SingleSnapShot = 1,
|
||||
[Description("连续模式")]
|
||||
ContinuousMode = 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日志类型
|
||||
/// </summary>
|
||||
public enum LogType
|
||||
{
|
||||
[Description("警告信息")]
|
||||
Exception_Warning = 1,
|
||||
[Description("错误信息")]
|
||||
Exception_Error = 2,
|
||||
[Description("致命信息")]
|
||||
Exception_Fatal = 3,
|
||||
|
||||
[Description("设备信息")]
|
||||
Info_Device = 11,
|
||||
[Description("工序信息")]
|
||||
Info_Process = 12,
|
||||
[Description("操作信息")]
|
||||
Info_Operation = 13,
|
||||
|
||||
[Description("用户操作信息")]
|
||||
User_Operation = 21,
|
||||
|
||||
[Description("测量结果")]
|
||||
MeasureResult = 31,
|
||||
}
|
||||
|
||||
//public enum CameraDriverType
|
||||
//{
|
||||
// Halcon,
|
||||
// //HalconPlugIn,
|
||||
// Hik,
|
||||
//}
|
||||
|
||||
//public enum ImageType
|
||||
//{
|
||||
// Bmp,
|
||||
// Png,
|
||||
// Jpeg,
|
||||
//}
|
||||
|
||||
//public enum ReplyValue
|
||||
//{
|
||||
// OK = 1,
|
||||
// NG = -1,
|
||||
// IGNORE = -999,
|
||||
//}
|
||||
|
||||
public enum PriorityDirection
|
||||
{
|
||||
X,
|
||||
Y,
|
||||
}
|
||||
|
||||
public enum ElementState
|
||||
{
|
||||
New = 1,
|
||||
MouseHover = 2,
|
||||
MouseInSide = 3,
|
||||
Selected = 4,
|
||||
Moving = 5,
|
||||
Editing = 6,
|
||||
|
||||
Normal = 11,
|
||||
|
||||
Measuring = 21,
|
||||
MeasureDoneOK = 22,
|
||||
MeasureDoneNG = 23,
|
||||
|
||||
CanStretchLeft = 41,
|
||||
CanStretchRight = 42,
|
||||
CanStretchTop = 43,
|
||||
CanStretchBottom = 44,
|
||||
|
||||
CanStretchLeftUpperCorner = 45,
|
||||
CanStretchLeftLowerCorner = 46,
|
||||
CanStretchRightUpperCorner = 47,
|
||||
CanStretchRightLowerCorner = 48,
|
||||
|
||||
StretchingLeft = 31,
|
||||
StretchingRight = 32,
|
||||
StretchingTop = 33,
|
||||
StretchingBottom = 34,
|
||||
|
||||
StretchingLeftUpperCorner = 35,
|
||||
StretchingLeftLowerCorner = 36,
|
||||
StretchingRightUpperCorner = 37,
|
||||
StretchingRightLowerCorner = 38,
|
||||
}
|
||||
|
||||
public enum MouseState
|
||||
{
|
||||
Normal = 1,
|
||||
HoverElement = 2,
|
||||
InSideElement = 3,
|
||||
|
||||
MoveElement = 4,
|
||||
|
||||
StretchingLeft = 11,
|
||||
StretchingRight = 12,
|
||||
StretchingTop = 13,
|
||||
StretchingBottom = 14,
|
||||
|
||||
StretchingLeftUpperCorner = 15,
|
||||
StretchingLeftLowerCorner = 16,
|
||||
StretchingRightUpperCorner = 17,
|
||||
StretchingRightLowerCorner = 18,
|
||||
|
||||
New = 21,
|
||||
Editing = 22,
|
||||
//SelectedElement = 23,
|
||||
|
||||
MovingAll = 31,
|
||||
|
||||
SelectionZone = 41,
|
||||
SelectionZoneDoing = 42,
|
||||
}
|
||||
|
||||
public enum RunMode
|
||||
{
|
||||
[Description("正常运行模式")]
|
||||
NormalMode = 1,
|
||||
[Description("调试模式")]
|
||||
DebugMode = 0,
|
||||
[Description("模拟模式")]
|
||||
DemoMode = 2,
|
||||
}
|
||||
|
||||
public enum MoveType
|
||||
{
|
||||
[Description("绝对运动")]
|
||||
AbsoluteMove = 1,
|
||||
[Description("机器人坐标系相对运动")]
|
||||
RobotRelativeMove = 2,
|
||||
[Description("相对某个基准点位的相对运动")]
|
||||
BasedPointRelativeMove = 3,
|
||||
[Description("回原点")]
|
||||
Origin = 4,
|
||||
[Description("左侧姿势")]
|
||||
LeftPose = 6,
|
||||
[Description("右侧姿势")]
|
||||
RightPose = 5,
|
||||
[Description("前侧姿势")]
|
||||
FrontPose = 7,
|
||||
[Description("相机坐标系相对运动")]
|
||||
CameraRelativeMove = 12,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 马达/运动板卡运行模式
|
||||
/// </summary>
|
||||
public enum MotionMode
|
||||
{
|
||||
/// <summary>
|
||||
/// 普通点位运动
|
||||
/// </summary>
|
||||
[Description("普通点位运动")]
|
||||
P2P = 1,
|
||||
|
||||
/// <summary>
|
||||
/// 找正限位运动
|
||||
/// </summary>
|
||||
[Description("找正限位运动")]
|
||||
FindPositive = 4,
|
||||
|
||||
/// <summary>
|
||||
/// 离开正限位
|
||||
/// </summary>
|
||||
[Description("离开正限位")]
|
||||
LeavePositive = 5,
|
||||
|
||||
/// <summary>
|
||||
/// 找负限位运动
|
||||
/// </summary>
|
||||
[Description("找负限位运动")]
|
||||
FindNegative = 6,
|
||||
|
||||
/// <summary>
|
||||
/// 离开负限位
|
||||
/// </summary>
|
||||
[Description("离开负限位")]
|
||||
LeaveNegative = 7,
|
||||
|
||||
/// <summary>
|
||||
/// 找原点运动
|
||||
/// </summary>
|
||||
[Description("回原点运动")]
|
||||
GoHome = 8,
|
||||
|
||||
/// <summary>
|
||||
/// Jog模式
|
||||
/// </summary>
|
||||
[Description("Jog模式")]
|
||||
Jog = 9,
|
||||
|
||||
///// <summary>
|
||||
///// 读数头找原点方式
|
||||
///// </summary>
|
||||
//[Description("找原点inde")]
|
||||
//FindOriIndex = 10,
|
||||
|
||||
///// <summary>
|
||||
///// 插补模式
|
||||
///// </summary>
|
||||
//[Description("插补模式")]
|
||||
//Coordinate = 11
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// IO预定义类型 主要针对输出
|
||||
/// </summary>
|
||||
public enum IOPrestatement
|
||||
{
|
||||
[Description("自定义")]
|
||||
Customized = 0,
|
||||
|
||||
[Description("指示灯-黄")]
|
||||
Light_Yellow = 1,
|
||||
[Description("指示灯-绿")]
|
||||
Light_Green = 2,
|
||||
[Description("指示灯-红")]
|
||||
Light_Red = 3,
|
||||
[Description("蜂鸣器")]
|
||||
Beep = 4,
|
||||
[Description("照明灯")]
|
||||
Light = 5,
|
||||
|
||||
[Description("急停")]
|
||||
EmergencyStop = 99,
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// GTS运动板卡控制返回控制码
|
||||
///// </summary>
|
||||
//public enum GTSRetCode
|
||||
//{
|
||||
// [Description("指令执行成功")]
|
||||
// GRCRunOK = 0, // 指令执行成功
|
||||
// [Description("指令执行错误")]
|
||||
// GRCRunErr = 1, // 指令执行错误
|
||||
// [Description("icense不支持")]
|
||||
// GRCNotSupport = 2, // icense不支持
|
||||
// [Description("指令参数错误")]
|
||||
// GRCInvalidParam = 7, // 指令参数错误
|
||||
// [Description("主机和运动控制器通讯失败")]
|
||||
// GRCCommErr = -1, // 主机和运动控制器通讯失败
|
||||
// [Description("打开控制器失败")]
|
||||
// GRCOpenErr = -6, // 打开控制器失败
|
||||
// [Description("运动控制器没有响应")]
|
||||
// GRCNotAck = -7 // 运动控制器没有响应
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// 运动板卡 IO 类型(IN OUT)
|
||||
/// </summary>
|
||||
public enum IOType
|
||||
{
|
||||
[Description("INPUT")]
|
||||
INPUT = 0,
|
||||
[Description("OUTPUT")]
|
||||
OUTPUT = 1
|
||||
}
|
||||
|
||||
public enum IOValue
|
||||
{
|
||||
[Description("关闭")]
|
||||
FALSE = 0,
|
||||
[Description("开启")]
|
||||
TRUE = 1,
|
||||
[Description("反转")]
|
||||
REVERSE = 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// PubSubCenter事件中心的消息类型
|
||||
/// </summary>
|
||||
public enum PubSubCenterMessageType
|
||||
{
|
||||
/// <summary>
|
||||
/// 运行界面更新产品下拉
|
||||
/// </summary>
|
||||
[Description("更新产品下拉")]
|
||||
UpdateProductionCodes,
|
||||
|
||||
/// <summary>
|
||||
/// 流程是否关闭
|
||||
/// </summary>
|
||||
[Description("流程是否打开")]
|
||||
IsProcessOpened,
|
||||
|
||||
/// <summary>
|
||||
/// 清除数据
|
||||
/// </summary>
|
||||
[Description("清除数据")]
|
||||
ClearData,
|
||||
/// <summary>
|
||||
/// 更新批次信息
|
||||
/// </summary>
|
||||
[Description("更新批次信息")]
|
||||
UpdateBatchNO,
|
||||
/// <summary>
|
||||
/// 请求批次信息
|
||||
/// </summary>
|
||||
[Description("更新批次信息")]
|
||||
RequestBatchNO,
|
||||
|
||||
/// <summary>
|
||||
/// 模型检测异常
|
||||
/// </summary>
|
||||
[Description("模型检测异常")]
|
||||
MLDetectException,
|
||||
}
|
||||
public enum SizeEnum
|
||||
{
|
||||
[Description("圆形测量")]
|
||||
Circle = 1,
|
||||
[Description("直线测量")]
|
||||
Line = 2,
|
||||
[Description("线线测量")]
|
||||
LineLine = 3,
|
||||
[Description("线圆测量")]
|
||||
LineCircle = 4,
|
||||
[Description("高度测量")]
|
||||
Height = 5,
|
||||
}
|
||||
|
||||
public enum MachineState
|
||||
{
|
||||
Unknown = 0,
|
||||
Ready = 1,
|
||||
Running = 2,
|
||||
Alarm = 3,
|
||||
Pause = 4,
|
||||
Resetting = 5,
|
||||
Closing = 6,
|
||||
ClearProduct = 7,
|
||||
Warning = 8,
|
||||
}
|
||||
|
||||
public enum ResultState
|
||||
{
|
||||
[Description("NA")]
|
||||
NA = -5,
|
||||
[Description("尺寸NG")]
|
||||
SizeNG = -4,
|
||||
[Description("检测NG")]
|
||||
DetectNG = -3,
|
||||
|
||||
//[Description("检测不足TBD")]
|
||||
// ShortageTBD = -2,
|
||||
[Description("检测结果TBD")]
|
||||
ResultTBD = -1,
|
||||
[Description("OK")]
|
||||
OK = 1,
|
||||
// [Description("NG")]
|
||||
// NG = 2,
|
||||
//统计结果
|
||||
[Description("A类NG")]
|
||||
A_NG = 25,
|
||||
[Description("B类NG")]
|
||||
B_NG = 26,
|
||||
[Description("C类NG")]
|
||||
C_NG = 27,
|
||||
}
|
||||
public enum HikCameraType
|
||||
{
|
||||
[Description("HikCamera-Gige")]
|
||||
Gige = 0,
|
||||
[Description("HikCamera-USB")]
|
||||
USB = 1
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 光源操作
|
||||
/// </summary>
|
||||
public enum LightOperation
|
||||
{
|
||||
[Description("打开")]
|
||||
Open = 1,
|
||||
[Description("关闭")]
|
||||
Close = 2,
|
||||
[Description("写入")]
|
||||
Write = 3,
|
||||
[Description("读取")]
|
||||
Read = 4,
|
||||
[Description("频闪")]
|
||||
Flash = 5,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 监听反馈数据值
|
||||
/// </summary>
|
||||
public enum ReturnValue
|
||||
{
|
||||
OKVALUE = 1,
|
||||
NGVALUE = -1,
|
||||
EXCEPTIONVALUE = -2,
|
||||
UNAUTHORIZATION = -10,
|
||||
IGNORE = -999,
|
||||
}
|
||||
|
||||
//public enum LogLevel
|
||||
//{
|
||||
// [Description("详细")]
|
||||
// [ColorSelect("White")]
|
||||
// [FontColorSelect("Green")]
|
||||
// Detail = 2,
|
||||
// [Description("信息")]
|
||||
// [ColorSelect("White")]
|
||||
// [FontColorSelect("Dark")]
|
||||
// Information = 3,
|
||||
// [Description("辅助")]
|
||||
// [ColorSelect("White")]
|
||||
// [FontColorSelect("Blue")]
|
||||
// Assist = 4,
|
||||
// [Description("动作")]
|
||||
// [ColorSelect("DarkGreen")]
|
||||
// [FontColorSelect("Yellow")]
|
||||
// Action = 5,
|
||||
// [Description("错误")]
|
||||
// [ColorSelect("Orange")]
|
||||
// [FontColorSelect("White")]
|
||||
// Error = 6,
|
||||
// [Description("警报")]
|
||||
// [ColorSelect("Brown")]
|
||||
// [FontColorSelect("White")]
|
||||
// Warning = 7,
|
||||
// [Description("异常")]
|
||||
// [ColorSelect("Red")]
|
||||
// [FontColorSelect("White")]
|
||||
// Exception = 8,
|
||||
//}
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ using System.Drawing.Imaging;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace XKRS.Common.Model
|
||||
namespace DH.Commons.Enums
|
||||
{
|
||||
public class HDevEngineTool : IDisposable
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@ using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace XKRS.Common.Model
|
||||
namespace DH.Commons.Enums
|
||||
{
|
||||
public class OpenCVEngineTool : IDisposable
|
||||
{
|
||||
|
||||
123
DH.Commons/Helper/UIHelper.cs
Normal file
123
DH.Commons/Helper/UIHelper.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DH.Commons.Enums
|
||||
{
|
||||
public static class UIHelper
|
||||
{
|
||||
public static void SetCombo(ComboBox cbo, object dataSource, string display, string value)
|
||||
{
|
||||
cbo.DataSource = dataSource;
|
||||
cbo.DisplayMember = display;
|
||||
if (!string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
cbo.ValueMember = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetCombo(ToolStripComboBox cbo, object dataSource, string display, string value)
|
||||
{
|
||||
cbo.ComboBox.DataSource = dataSource;
|
||||
cbo.ComboBox.DisplayMember = display;
|
||||
if (!string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
cbo.ComboBox.ValueMember = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetCombo(DataGridViewComboBoxColumn cbo, object dataSource, string display, string value)
|
||||
{
|
||||
cbo.DataSource = dataSource;
|
||||
cbo.DisplayMember = display;
|
||||
if (!string.IsNullOrWhiteSpace(value))
|
||||
{
|
||||
cbo.ValueMember = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region DataGridView设置列头为复选框
|
||||
public class DataGridViewCheckboxHeaderEventArgs : EventArgs
|
||||
{
|
||||
private bool checkedState = false;
|
||||
|
||||
public bool CheckedState
|
||||
{
|
||||
get { return checkedState; }
|
||||
set { checkedState = value; }
|
||||
}
|
||||
}
|
||||
|
||||
public delegate void DataGridViewCheckboxHeaderEventHander(object sender, DataGridViewCheckboxHeaderEventArgs e);
|
||||
public class DataGridViewCheckboxHeaderCell : DataGridViewColumnHeaderCell
|
||||
{
|
||||
Point checkBoxLocation;
|
||||
Size checkBoxSize;
|
||||
bool _checked = false;
|
||||
Point _cellLocation = new Point();
|
||||
System.Windows.Forms.VisualStyles.CheckBoxState _cbState = System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal;
|
||||
|
||||
public event DataGridViewCheckboxHeaderEventHander OnCheckBoxClicked;
|
||||
|
||||
//绘制列头checkbox
|
||||
protected override void Paint(System.Drawing.Graphics graphics,
|
||||
System.Drawing.Rectangle clipBounds,
|
||||
System.Drawing.Rectangle cellBounds,
|
||||
int rowIndex,
|
||||
DataGridViewElementStates dataGridViewElementState,
|
||||
object value,
|
||||
object formattedValue,
|
||||
string errorText,
|
||||
DataGridViewCellStyle cellStyle,
|
||||
DataGridViewAdvancedBorderStyle advancedBorderStyle,
|
||||
DataGridViewPaintParts paintParts)
|
||||
{
|
||||
base.Paint(graphics, clipBounds, cellBounds, rowIndex,
|
||||
dataGridViewElementState, value,
|
||||
formattedValue, errorText, cellStyle,
|
||||
advancedBorderStyle, paintParts);
|
||||
|
||||
Point p = new Point();
|
||||
Size s = CheckBoxRenderer.GetGlyphSize(graphics, System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal);
|
||||
p.X = cellBounds.Location.X + (cellBounds.Width / 2) - (s.Width / 2) - 1; //列头checkbox的X坐标
|
||||
p.Y = cellBounds.Location.Y + (cellBounds.Height / 2) - (s.Height / 2); //列头checkbox的Y坐标
|
||||
_cellLocation = cellBounds.Location;
|
||||
checkBoxLocation = p;
|
||||
checkBoxSize = s;
|
||||
if (_checked)
|
||||
_cbState = System.Windows.Forms.VisualStyles.CheckBoxState.CheckedNormal;
|
||||
else
|
||||
_cbState = System.Windows.Forms.VisualStyles.CheckBoxState.UncheckedNormal;
|
||||
|
||||
CheckBoxRenderer.DrawCheckBox(graphics, checkBoxLocation, _cbState);
|
||||
}
|
||||
|
||||
///
|
||||
/// 点击列头checkbox单击事件
|
||||
///
|
||||
protected override void OnMouseClick(DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
Point p = new Point(e.X + _cellLocation.X, e.Y + _cellLocation.Y);
|
||||
if (p.X >= checkBoxLocation.X && p.X <= checkBoxLocation.X + checkBoxSize.Width
|
||||
&& p.Y >= checkBoxLocation.Y && p.Y <= checkBoxLocation.Y + checkBoxSize.Height)
|
||||
{
|
||||
_checked = !_checked;
|
||||
|
||||
//获取列头checkbox的选择状态
|
||||
DataGridViewCheckboxHeaderEventArgs ex = new DataGridViewCheckboxHeaderEventArgs();
|
||||
ex.CheckedState = _checked;
|
||||
|
||||
object sender = new object();//此处不代表选择的列头checkbox,只是作为参数传递。因为列头checkbox是绘制出来的,无法获得它的实例
|
||||
|
||||
if (OnCheckBoxClicked != null)
|
||||
{
|
||||
OnCheckBoxClicked(sender, ex);//触发单击事件
|
||||
DataGridView.InvalidateCell(this);
|
||||
}
|
||||
}
|
||||
base.OnMouseClick(e);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
39
DH.Commons/Interface/IShapeElement.cs
Normal file
39
DH.Commons/Interface/IShapeElement.cs
Normal file
@@ -0,0 +1,39 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using static DH.Commons.Enums.EnumHelper;
|
||||
|
||||
|
||||
namespace DH.Commons.Enums
|
||||
{
|
||||
public interface IShapeElement : INotifyPropertyChanged, ICloneable
|
||||
{
|
||||
string ID { get; set; }
|
||||
|
||||
int Index { get; set; }
|
||||
int GroupIndex { get; set; }
|
||||
|
||||
string Name { get; set; }
|
||||
|
||||
void OnMouseDown(PointF point);
|
||||
void OnMouseUp(PointF point);
|
||||
void OnMouseMove(PointF point);
|
||||
void OnMouseDoubleClick(PointF point);
|
||||
bool IsIntersect(RectangleF rect);
|
||||
|
||||
bool IsEnabled { get; set; }
|
||||
void Draw(Graphics g);
|
||||
|
||||
void Translate(float x, float y);
|
||||
|
||||
/// <summary>
|
||||
/// WPF中标识该对象是否已经加入渲染,需要显示
|
||||
/// </summary>
|
||||
bool IsShowing { get; set; }
|
||||
|
||||
void Initial();
|
||||
bool IsCreatedDone();
|
||||
|
||||
ElementState State { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,6 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="CameraBase.cs" />
|
||||
<Compile Include="Do3ThinkCamera.cs" />
|
||||
<Compile Include="HikVisionCamera.cs" />
|
||||
</ItemGroup>
|
||||
@@ -25,6 +24,7 @@
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DH.Commons.Devies\DH.Commons.Devies.csproj" />
|
||||
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System.Diagnostics;
|
||||
using System.Reflection.Metadata;
|
||||
using System.Xml.Linq;
|
||||
using DH.Devices.Devices;
|
||||
using DVPCameraType;
|
||||
using OpenCvSharp;
|
||||
using static System.Net.Mime.MediaTypeNames;
|
||||
@@ -20,6 +21,7 @@ namespace DH.Devices.Camera
|
||||
|
||||
public int m_n_dev_count = 0;
|
||||
private DVPCamera.dvpStreamCallback ImageCallback;
|
||||
public dvpStreamFormat dvpStreamFormat = dvpStreamFormat.S_RGB24;
|
||||
public int m_CamCount = 0;
|
||||
public Double m_dfDisplayCount = 0;
|
||||
public Do3ThinkCamera()
|
||||
|
||||
@@ -5,6 +5,7 @@ using System.Runtime.InteropServices;
|
||||
using System.Xml.Linq;
|
||||
using DH.Commons.Enums;
|
||||
using static MvCamCtrl.NET.MyCamera;
|
||||
using DH.Devices.Devices;
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<BaseOutputPath>..\</BaseOutputPath>
|
||||
<AppendTargetFrameworkToOutputPath>output</AppendTargetFrameworkToOutputPath>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<BaseOutputPath>..\</BaseOutputPath>
|
||||
<AppendTargetFrameworkToOutputPath>output</AppendTargetFrameworkToOutputPath>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
|
||||
|
||||
@@ -22,4 +22,24 @@
|
||||
<PackageReference Include="OpenCvSharp4.runtime.win" Version="4.10.0.20241108" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<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>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="halcondotnet">
|
||||
<HintPath>..\x64\Debug\halcondotnet.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
10
DH.Devices.Vision/GlobalSuppressions.cs
Normal file
10
DH.Devices.Vision/GlobalSuppressions.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
// This file is used by Code Analysis to maintain SuppressMessage
|
||||
// attributes that are applied to this project.
|
||||
// Project-level suppressions either have no target or are given
|
||||
// a specific target and scoped to a namespace, type, member, etc.
|
||||
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
|
||||
[assembly: SuppressMessage("Usage", "CA2200:再次引发以保留堆栈详细信息", Justification = "<挂起>", Scope = "member", Target = "~M:DH.Devices.Vision.SimboDetection.Load(DH.Devices.Vision.MLInit)~System.Boolean")]
|
||||
[assembly: SuppressMessage("Usage", "CA2200:再次引发以保留堆栈详细信息", Justification = "<挂起>", Scope = "member", Target = "~M:DH.Devices.Vision.SimboInstanceSegmentation.Load(DH.Devices.Vision.MLInit)~System.Boolean")]
|
||||
[assembly: SuppressMessage("Usage", "CA2200:再次引发以保留堆栈详细信息", Justification = "<挂起>", Scope = "member", Target = "~M:DH.Devices.Vision.SimboObjectDetection.Load(DH.Devices.Vision.MLInit)~System.Boolean")]
|
||||
@@ -1,4 +1,4 @@
|
||||
#define USE_MULTI_THREAD
|
||||
//#define USE_MULTI_THREAD
|
||||
|
||||
using OpenCvSharp;
|
||||
using OpenCvSharp.Extensions;
|
||||
@@ -13,6 +13,7 @@ using System.Threading.Tasks;
|
||||
using System.Security.Cryptography.Xml;
|
||||
using System.Runtime.InteropServices;
|
||||
using Newtonsoft.Json;
|
||||
using DH.Commons.Enums;
|
||||
|
||||
|
||||
|
||||
@@ -103,14 +104,18 @@ namespace DH.Devices.Vision
|
||||
// json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}";
|
||||
//
|
||||
Console.WriteLine("检测结果JSON:" + json);
|
||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
HYoloResult detResult = JsonConvert.DeserializeObject<HYoloResult>(json);
|
||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
if (detResult == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int iNum = detResult.HYolo.Count;
|
||||
#pragma warning disable CS0219 // 变量已被赋值,但从未使用过它的值
|
||||
int IokNum = 0;
|
||||
#pragma warning restore CS0219 // 变量已被赋值,但从未使用过它的值
|
||||
for (int ix = 0; ix < iNum; ix++)
|
||||
{
|
||||
var det = detResult.HYolo[ix];
|
||||
@@ -140,6 +145,7 @@ namespace DH.Devices.Vision
|
||||
Mat originMat = new Mat();
|
||||
Mat detectMat = new Mat();
|
||||
|
||||
#pragma warning disable CS0168 // 声明了变量,但从未使用过
|
||||
try
|
||||
{
|
||||
if (req.mImage == null)
|
||||
@@ -228,15 +234,20 @@ namespace DH.Devices.Vision
|
||||
{
|
||||
|
||||
originMat?.Dispose();
|
||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
originMat = null;
|
||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
//maskMat?.Dispose();
|
||||
// maskMat = null;
|
||||
detectMat?.Dispose();
|
||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
detectMat = null;
|
||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
// maskWeighted?.Dispose();
|
||||
// maskWeighted = null;
|
||||
// GC.Collect();
|
||||
}
|
||||
#pragma warning restore CS0168 // 声明了变量,但从未使用过
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
using Newtonsoft.Json;
|
||||
using DH.Commons.Enums;
|
||||
|
||||
|
||||
namespace DH.Devices.Vision
|
||||
@@ -126,14 +127,18 @@ namespace DH.Devices.Vision
|
||||
// json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}";
|
||||
//
|
||||
Console.WriteLine("检测结果JSON:" + json);
|
||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
SegResult detResult = JsonConvert.DeserializeObject<SegResult>(json);
|
||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
if (detResult == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
int iNum = detResult.SegmentResult.Count;
|
||||
#pragma warning disable CS0219 // 变量已被赋值,但从未使用过它的值
|
||||
int IokNum = 0;
|
||||
#pragma warning restore CS0219 // 变量已被赋值,但从未使用过它的值
|
||||
for (int ix = 0; ix < iNum; ix++)
|
||||
{
|
||||
var det = detResult.SegmentResult[ix];
|
||||
@@ -166,6 +171,7 @@ namespace DH.Devices.Vision
|
||||
Mat originMat = new Mat();
|
||||
Mat detectMat = new Mat();
|
||||
|
||||
#pragma warning disable CS0168 // 声明了变量,但从未使用过
|
||||
try
|
||||
{
|
||||
if (req.mImage == null)
|
||||
@@ -253,11 +259,14 @@ namespace DH.Devices.Vision
|
||||
{
|
||||
|
||||
originMat?.Dispose();
|
||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
originMat = null;
|
||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
|
||||
|
||||
// GC.Collect();
|
||||
}
|
||||
#pragma warning restore CS0168 // 声明了变量,但从未使用过
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ using System.Threading.Tasks;
|
||||
using System.Runtime.InteropServices;
|
||||
using Newtonsoft.Json;
|
||||
using System.Xml;
|
||||
using DH.Commons.Enums;
|
||||
|
||||
|
||||
namespace DH.Devices.Vision
|
||||
@@ -135,7 +136,9 @@ namespace DH.Devices.Vision
|
||||
// json = "{\"FastDetResult\":[{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654843,\"rect\":[175,99,110,594]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654589,\"rect\":[2608,19,104,661]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.654285,\"rect\":[1275,19,104,662]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.620762,\"rect\":[1510,95,107,600]},{\"cls_id\":0,\"cls\":\"liewen\",\"fScore\":0.617812,\"rect\":[2844,93,106,602]}]}";
|
||||
//
|
||||
Console.WriteLine("检测结果JSON:" + json);
|
||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
SegResult detResult = JsonConvert.DeserializeObject<SegResult>(json);
|
||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
if (detResult == null)
|
||||
{
|
||||
return;
|
||||
@@ -173,6 +176,7 @@ namespace DH.Devices.Vision
|
||||
MLResult mlResult = new MLResult();
|
||||
Mat originMat=new Mat() ;
|
||||
Mat detectMat= new Mat();
|
||||
#pragma warning disable CS0168 // 声明了变量,但从未使用过
|
||||
try
|
||||
{
|
||||
if (req.mImage == null)
|
||||
@@ -263,19 +267,24 @@ namespace DH.Devices.Vision
|
||||
if (detectMat != null)
|
||||
{
|
||||
detectMat.Dispose();
|
||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
detectMat = null;
|
||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
}
|
||||
|
||||
if (originMat != null)
|
||||
{
|
||||
originMat.Dispose();
|
||||
#pragma warning disable CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
originMat = null;
|
||||
#pragma warning restore CS8600 // 将 null 字面量或可能为 null 的值转换为非 null 类型。
|
||||
}
|
||||
|
||||
|
||||
|
||||
// GC.Collect();
|
||||
}
|
||||
#pragma warning restore CS0168 // 声明了变量,但从未使用过
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
using OpenCvSharp;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Devices;
|
||||
using DH.UI.Model.Winform;
|
||||
using HalconDotNet;
|
||||
using OpenCvSharp;
|
||||
using OpenCvSharp.Extensions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
@@ -6,13 +11,659 @@ using System.Linq;
|
||||
using System.Runtime.ExceptionServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
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;
|
||||
|
||||
|
||||
namespace DH.Devices.Vision
|
||||
{
|
||||
public class SimboVisionDriver
|
||||
public class SimboVisionDriver : VisionEngineBase
|
||||
{
|
||||
public Dictionary<string, HDevEngineTool> HalconToolDict = new Dictionary<string, HDevEngineTool>();
|
||||
|
||||
public List<SimboStationMLEngineSet> SimboStationMLEngineList = new List<SimboStationMLEngineSet>();
|
||||
|
||||
public void Init()
|
||||
{
|
||||
//InitialQueue();
|
||||
InitialHalconTools();
|
||||
InitialSimboMLEnginesAsync();
|
||||
|
||||
// ImageSaveHelper.OnImageSaveExceptionRaised -= ImageSaveHelper_OnImageSaveExceptionRaised;
|
||||
// ImageSaveHelper.OnImageSaveExceptionRaised += ImageSaveHelper_OnImageSaveExceptionRaised;
|
||||
// base.Init();
|
||||
}
|
||||
|
||||
//private void ImageSaveHelper_OnImageSaveExceptionRaised(DateTime dt, string msg)
|
||||
//{
|
||||
// LogAsync(new LogMsg(dt, LogLevel.Error, msg));
|
||||
//}
|
||||
public override DetectStationResult RunInference(Mat originImgSet, string detectionId = null)
|
||||
{
|
||||
DetectStationResult detectResult = new DetectStationResult();
|
||||
DetectionConfig detectConfig = null;
|
||||
//找到对应的配置
|
||||
if (!string.IsNullOrWhiteSpace(detectionId))
|
||||
{
|
||||
detectConfig = DetectionConfigs.FirstOrDefault(u => u.Id == detectionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
//detectConfig = DetectionConfigs.FirstOrDefault(u => u.CameraSourceId == camera.CameraName);
|
||||
}
|
||||
|
||||
if (detectConfig == null)
|
||||
{
|
||||
|
||||
//未能获得检测配置
|
||||
return detectResult;
|
||||
}
|
||||
#region 1.预处理
|
||||
|
||||
using (Mat PreTMat = originImgSet.Clone())
|
||||
{
|
||||
PreTreated(detectConfig, detectResult, PreTMat);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
if (detectResult.IsPreTreatNG)
|
||||
{
|
||||
detectResult.ResultState = ResultState.DetectNG;
|
||||
detectResult.IsPreTreatDone = true;
|
||||
detectResult.IsMLDetectDone = false;
|
||||
return detectResult;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(detectConfig.ModelPath) && detectConfig.IsEnabled)
|
||||
{
|
||||
|
||||
|
||||
SimboStationMLEngineSet mlSet = null;
|
||||
mlSet = SimboStationMLEngineList.FirstOrDefault(t => t.DetectionId == detectConfig.Id);
|
||||
if (mlSet == null)
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception, $"异常:{detectConfig.Name}未能获取对应配置的模型检测工具");
|
||||
detectResult.IsMLDetectDone = false;
|
||||
|
||||
//HandleDetectDone(detectResult, detectConfig);
|
||||
return detectResult;
|
||||
}
|
||||
|
||||
#region 2.深度学习推理
|
||||
//LogAsync(DateTime.Now, LogLevel.Information, $"{detectConfig.Name} 产品{detectResult.TempPid} 模型检测执行");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(detectConfig.ModelPath))
|
||||
{
|
||||
Stopwatch mlWatch = new Stopwatch();
|
||||
var req = new MLRequest();
|
||||
//之前的检测图片都是相机存储成HImage
|
||||
|
||||
|
||||
req.ResizeWidth = (int)detectConfig.ModelWidth;
|
||||
req.ResizeHeight = (int)detectConfig.ModelHeight;
|
||||
// req.LabelNames = detectConfig.GetLabelNames();
|
||||
// req.Score = IIConfig.Score;
|
||||
req.mImage = originImgSet.Clone();
|
||||
|
||||
req.in_lable_path = detectConfig.in_lable_path;
|
||||
|
||||
req.confThreshold = detectConfig.ModelconfThreshold;
|
||||
req.iouThreshold = 0.3f;
|
||||
req.segmentWidth = 320;
|
||||
req.out_node_name = "output0";
|
||||
switch (detectConfig.ModelType)
|
||||
{
|
||||
case MLModelType.ImageClassification:
|
||||
break;
|
||||
case MLModelType.ObjectDetection:
|
||||
|
||||
break;
|
||||
case MLModelType.SemanticSegmentation:
|
||||
break;
|
||||
case MLModelType.InstanceSegmentation:
|
||||
break;
|
||||
case MLModelType.ObjectGPUDetection:
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// LogAsync(DateTime.Now, LogLevel.Information, $"{detectConfig.Name} 产品{detectResult.TempPid} RunInference BEGIN");
|
||||
mlWatch.Start();
|
||||
//20230802改成多线程推理 RunInferenceFixed
|
||||
|
||||
var result = mlSet.StationMLEngine.RunInference(req);
|
||||
// var result = mlSet.StationMLEngine.RunInferenceFixed(req);
|
||||
mlWatch.Stop();
|
||||
// LogAsync(DateTime.Now, LogLevel.Information, $"{detectConfig.Name} 产品{detectResult.TempPid} RunInference END");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// var req = new MLRequest();
|
||||
|
||||
//req.mImage = inferenceImage;
|
||||
|
||||
//req.ResizeWidth = detectConfig.ModelWidth;
|
||||
//req.ResizeHeight = detectConfig.ModelHeight;
|
||||
//req.confThreshold = detectConfig.ModelconfThreshold;
|
||||
//req.iouThreshold = 0.3f;
|
||||
//req.out_node_name = "output0";
|
||||
//req.in_lable_path = detectConfig.in_lable_path;
|
||||
|
||||
//Stopwatch sw = Stopwatch.StartNew();
|
||||
//var result = Dectection[detectionId].RunInference(req);
|
||||
//sw.Stop();
|
||||
//LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.1,产品{productNumber},耗时{sw.ElapsedMilliseconds}ms");
|
||||
|
||||
//this.BeginInvoke(new MethodInvoker(delegate ()
|
||||
//{
|
||||
// // pictureBox1.Image?.Dispose(); // 释放旧图像
|
||||
// // pictureBox1.Image = result.ResultMap;
|
||||
// richTextBox1.AppendText($"推理成功 {productNumber}, {result.IsSuccess}相机名字{camera.CameraName} 耗时 {mlWatch.ElapsedMilliseconds}ms\n");
|
||||
//}));
|
||||
//req.mImage?.Dispose();
|
||||
|
||||
|
||||
|
||||
|
||||
if (result == null || (result != null && !result.IsSuccess))
|
||||
{
|
||||
detectResult.IsMLDetectDone = false;
|
||||
}
|
||||
if (result != null && result.IsSuccess)
|
||||
{
|
||||
detectResult.DetectDetails = result.ResultDetails;
|
||||
if (detectResult.DetectDetails != null)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
detectResult.IsMLDetectDone = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 3.后处理
|
||||
#endregion
|
||||
//根据那些得分大于阈值的推理结果,判断产品是否成功
|
||||
#region 4.最终过滤(逻辑过滤)
|
||||
detectResult.DetectDetails?.ForEach(d =>
|
||||
{
|
||||
|
||||
|
||||
//当前检测项的 过滤条件
|
||||
//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)
|
||||
{
|
||||
|
||||
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);
|
||||
//});
|
||||
|
||||
|
||||
//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;
|
||||
//}
|
||||
}
|
||||
});
|
||||
#endregion
|
||||
#region 5.统计缺陷过滤结果或预处理直接NG
|
||||
//if (detectResult.DetectDetails?.Count > 0)
|
||||
//{
|
||||
// detectResult.ResultState = detectResult.DetectDetails.GroupBy(u => u.FinalResult).OrderBy(u => u.Key).First().First().FinalResult;
|
||||
// detectResult.ResultLabel = detectResult.ResultLabel;
|
||||
// detectResult.ResultLabelCategoryId = detectResult.ResultLabel;//TODO:设置优先级
|
||||
|
||||
|
||||
//}
|
||||
detectResult.ResultState = detectResult.DetectDetails?
|
||||
.GroupBy(u => u.FinalResult)
|
||||
.OrderBy(u => u.Key)
|
||||
.FirstOrDefault()?.Key ?? ResultState.OK;
|
||||
detectResult.ResultLabel = detectResult.ResultLabel;
|
||||
detectResult.ResultLabelCategoryId = detectResult.ResultLabel;//TODO:设置优先级
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
DisplayDetectionResult(detectResult, originImgSet.Clone(), detectionId);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
return detectResult;
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化深度学习工具
|
||||
/// </summary>
|
||||
private bool InitialSimboMLEnginesAsync()
|
||||
{
|
||||
//深度学习 模型加载
|
||||
var resultOK = MLLoadModel();
|
||||
return resultOK;
|
||||
}
|
||||
/// <summary>
|
||||
/// 深度学习 模型加载
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool MLLoadModel()
|
||||
{
|
||||
bool resultOK = false;
|
||||
try
|
||||
{
|
||||
// SimboStationMLEngineList = new List<SimboStationMLEngineSet>();
|
||||
// _cameraRelatedDetectionDict = IConfig.DetectionConfigs.Select(t => t.ModelPath).Distinct().ToList();
|
||||
DetectionConfigs.ForEach(dc =>
|
||||
//_cameraRelatedDetectionDict.ForEach(dc =>
|
||||
{
|
||||
|
||||
if (dc.IsEnabled && !string.IsNullOrWhiteSpace(dc.ModelPath))
|
||||
{
|
||||
if (dc.IsEnableGPU)
|
||||
{
|
||||
//if (IIConfig.IsLockGPU)
|
||||
//{
|
||||
//foreach (var validGPU in ValidGPUList2)
|
||||
//{
|
||||
// if (validGPU.DetectionIds.Contains(dc.Id))
|
||||
// {
|
||||
var engine = SingleMLLoadModel(dc, true, 0);
|
||||
SimboStationMLEngineList.Add(engine);
|
||||
// }
|
||||
//}
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// foreach (var validGPU in ValidGPUList)
|
||||
// {
|
||||
// //var validGPU = ValidGPUList.FirstOrDefault(u => u.DetectionIds.Contains(dc.Id));
|
||||
// if (validGPU.DetectionId == dc.Id)
|
||||
// {
|
||||
// var engine = SingleMLLoadModel(dc, true, validGPU.GPUNo);
|
||||
// SimboStationMLEngineList.Add(engine);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//for (int i = 0; i < IConfig.CPUNums; i++)
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
//var engine = SingleMLLoadModel(dc, false, i);
|
||||
var engine = SingleMLLoadModel(dc, false, i);
|
||||
SimboStationMLEngineList.Add(engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
resultOK = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception, $"异常:模型并发加载异常:{ex.GetExceptionMessage()}");
|
||||
resultOK = false;
|
||||
}
|
||||
|
||||
return resultOK;
|
||||
}
|
||||
/// <summary>
|
||||
/// 单个模型加载
|
||||
/// </summary>
|
||||
/// <param name="dc"></param>
|
||||
/// <param name="gpuNum"></param>
|
||||
/// <returns></returns>
|
||||
private SimboStationMLEngineSet SingleMLLoadModel(DetectionConfig dc, bool isGPU, int coreInx)
|
||||
{
|
||||
SimboStationMLEngineSet mLEngineSet = new SimboStationMLEngineSet();
|
||||
try
|
||||
{
|
||||
mLEngineSet.IsUseGPU = isGPU;
|
||||
if (isGPU)
|
||||
{
|
||||
mLEngineSet.GPUNo = coreInx;
|
||||
}
|
||||
else
|
||||
{
|
||||
mLEngineSet.CPUNo = coreInx;
|
||||
}
|
||||
mLEngineSet.DetectionId = dc.Id;
|
||||
mLEngineSet.DetectionName = dc.Name;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(dc.ModelPath))
|
||||
{
|
||||
// 根据算法类型创建不同的实例
|
||||
switch (dc.ModelType)
|
||||
{
|
||||
case MLModelType.ImageClassification:
|
||||
break;
|
||||
case MLModelType.ObjectDetection:
|
||||
mLEngineSet.StationMLEngine = new SimboObjectDetection();
|
||||
break;
|
||||
case MLModelType.SemanticSegmentation:
|
||||
|
||||
break;
|
||||
case MLModelType.InstanceSegmentation:
|
||||
mLEngineSet.StationMLEngine = new SimboInstanceSegmentation();
|
||||
break;
|
||||
case MLModelType.ObjectGPUDetection:
|
||||
mLEngineSet.StationMLEngine = new SimboDetection();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
MLInit mLInit;
|
||||
string inferenceDevice = "CPU";
|
||||
if (dc.IsEnableGPU)
|
||||
{
|
||||
inferenceDevice = "GPU";
|
||||
mLInit = new MLInit(dc.ModelPath, isGPU, coreInx, dc.ModelconfThreshold);
|
||||
}
|
||||
else
|
||||
{
|
||||
mLInit = new MLInit(dc.ModelPath, "images", inferenceDevice, (int)dc.ModelWidth, (int)dc.ModelHeight);
|
||||
|
||||
}
|
||||
|
||||
bool isSuccess = mLEngineSet.StationMLEngine.Load(mLInit);
|
||||
if (!isSuccess)
|
||||
{
|
||||
// throw new ProcessException("异常:模型加载异常", null);
|
||||
}
|
||||
//LogAsync(DateTime.Now, LogLevel.Information, $"模型加载成功;是否GPU:{isGPU} CoreInx:{coreInx} - {dc.Name}" + $" {dc.ModelType.GetEnumDescription()}:{dc.ModelPath}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//throw new ProcessException($"异常:是否GPU:{isGPU} CoreInx:{coreInx} - {dc.Name}模型加载异常:{ex.GetExceptionMessage()}");
|
||||
}
|
||||
return mLEngineSet;
|
||||
}
|
||||
private void InitialHalconTools()
|
||||
{
|
||||
HOperatorSet.SetSystem("parallelize_operators", "true");
|
||||
HOperatorSet.SetSystem("reentrant", "true");
|
||||
HOperatorSet.SetSystem("global_mem_cache", "exclusive");
|
||||
|
||||
HalconToolDict = new Dictionary<string, HDevEngineTool>();
|
||||
|
||||
DetectionConfigs.ForEach(c =>
|
||||
{
|
||||
if (!c.IsEnabled)
|
||||
return;
|
||||
|
||||
if (c.HalconAlgorithemPath_Pre != null)
|
||||
LoadHalconTool(c.HalconAlgorithemPath_Pre);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void LoadHalconTool(string path)
|
||||
{
|
||||
if (!HalconToolDict.ContainsKey(path))
|
||||
{
|
||||
|
||||
|
||||
string algorithemPath = path;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(algorithemPath))
|
||||
return;
|
||||
|
||||
string directoryPath = Path.GetDirectoryName(algorithemPath);
|
||||
string fileName = Path.GetFileNameWithoutExtension(algorithemPath);
|
||||
|
||||
HDevEngineTool tool = new HDevEngineTool(directoryPath);
|
||||
tool.LoadProcedure(fileName);
|
||||
|
||||
HalconToolDict[path] = tool;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 预处理
|
||||
/// </summary>
|
||||
/// <param name="detectConfig"></param>
|
||||
/// <param name="detectResult"></param>
|
||||
public void PreTreated(DetectionConfig detectConfig, DetectStationResult detectResult, Mat MhImage)
|
||||
{
|
||||
try
|
||||
{
|
||||
// detectResult.VisionImageSet.DetectionOriginImage = detectResult.VisionImageSet.HImage.ConvertHImageToBitmap();
|
||||
//detectResult.VisionImageSet.PreTreatedBitmap = detectResult.VisionImageSet.HImage.ConvertHImageToBitmap();
|
||||
//detectResult.VisionImageSet.DetectionResultImage = detectResult.VisionImageSet.PreTreatedBitmap?.CopyBitmap();
|
||||
if (!string.IsNullOrWhiteSpace(detectConfig.HalconAlgorithemPath_Pre))
|
||||
{
|
||||
HObject obj = OpenCVHelper.MatToHImage(MhImage);
|
||||
HImage hImage = HalconHelper.ConvertHObjectToHImage(obj);
|
||||
string toolKey = detectConfig.HalconAlgorithemPath_Pre;
|
||||
if (!HalconToolDict.ContainsKey(toolKey))
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception, $"{detectConfig.Name}未获取预处理算法");
|
||||
return;
|
||||
}
|
||||
//Mean_Thre Deviation_Thre Mean_standard Deviation_standard
|
||||
var tool = HalconToolDict[toolKey];
|
||||
|
||||
////tool.InputTupleDic["Mean_Thre"] = 123;
|
||||
for (int i = 0; i < detectConfig.PreTreatParams.Count; i++)
|
||||
{
|
||||
var param = detectConfig.PreTreatParams[i];
|
||||
tool.InputTupleDic[param.Name] = double.Parse(param.Value);
|
||||
}
|
||||
|
||||
// tool.InputTupleDic["fCricularity"] = 200;
|
||||
|
||||
tool.InputImageDic["INPUT_Image"] = hImage;
|
||||
|
||||
|
||||
if (!tool.RunProcedure(out string errorMsg, out _))
|
||||
{
|
||||
// detectResult.PreTreatedFlag = false;
|
||||
|
||||
detectResult.IsPreTreatDone = false;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var preTreatRet = tool.GetResultTuple("OUTPUT_Flag").I;
|
||||
|
||||
//var fRCricularity = tool.GetResultTuple("fRCricularity");
|
||||
|
||||
|
||||
// detectResult.IsPreTreatDone = detectResult.VisionImageSet.PreTreatedFlag = preTreatRet == 1;
|
||||
//detectResult.IsPreTreatDone = detectResult.VisionImageSet.PreTreatedFlag = true;
|
||||
// detectResult.VisionImageSet.PreTreatedTime = DateTime.Now;
|
||||
|
||||
for (int i = 0; i < detectConfig.OUTPreTreatParams.Count; i++)
|
||||
{
|
||||
var param = detectConfig.OUTPreTreatParams[i];
|
||||
tool.InputTupleDic[param.Name] = double.Parse(param.Value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 2023/10/16 新增预处理结果反馈,如果预处理结果为NG,直接返回
|
||||
if (preTreatRet != 0)
|
||||
{
|
||||
detectResult.ResultState = ResultState.DetectNG;
|
||||
|
||||
detectResult.IsPreTreatNG = true;
|
||||
|
||||
|
||||
|
||||
// if (detectResult.VisionImageSet.PreTreatedFlag)
|
||||
{
|
||||
//detectResult.VisionImageSet.MLImage = tool.GetResultObject("OUTPUT_PreTreatedImage");
|
||||
//DetectionResultImage
|
||||
// detectResult.VisionImageSet.DetectionResultImage = detectResult.VisionImageSet.MLImage.ConvertHImageToBitmap();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// detectResult.VisionImageSet.DetectionResultImage = detectResult.VisionImageSet.MLImage.ConvertHImageToBitmap();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
//detectResult.VisionImageSet.HImage?.Dispose();
|
||||
//detectResult.VisionImageSet.HImage = null;
|
||||
// MhImage?.Dispose();
|
||||
//MhImage = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示检测结果
|
||||
/// </summary>
|
||||
/// <param name="detectResult"></param>
|
||||
private void DisplayDetectionResult(DetectStationResult detectResult,Mat result,string DetectionId)
|
||||
{
|
||||
//结果显示上传
|
||||
Task.Run(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
string displayTxt = detectResult.ResultState.ToString() + "\r\n";
|
||||
if (detectResult.DetectDetails != null && detectResult.DetectDetails?.Count > 0)
|
||||
{
|
||||
detectResult.DetectDetails.ForEach(d =>
|
||||
{
|
||||
displayTxt +=
|
||||
$"{d.LabelName} score:{d.Score.ToString("f2")} area:{d.Area.ToString("f2")}\r\n";
|
||||
});
|
||||
}
|
||||
|
||||
//if (detectResult.realSpecs != null && detectResult.realSpecs?.Count > 0)
|
||||
//{
|
||||
// detectResult.realSpecs.ForEach(d =>
|
||||
// {
|
||||
// displayTxt +=
|
||||
// $"{d.Code} :{d.ActualValue} \r\n";
|
||||
// });
|
||||
//}
|
||||
Bitmap resultMask=result.ToBitmap();
|
||||
//if (detectResult.VisionImageSet.DetectionResultImage == null && detectResult.VisionImageSet.SizeResultImage == null)
|
||||
//{
|
||||
// return;
|
||||
//}
|
||||
//else if (detectResult.VisionImageSet.DetectionResultImage == null && detectResult.VisionImageSet.SizeResultImage != null)
|
||||
//{
|
||||
// detectResult.VisionImageSet.DetectionResultImage = detectResult.VisionImageSet.SizeResultImage.CopyBitmap();
|
||||
// resultMask = detectResult.VisionImageSet.DetectionResultImage.CopyBitmap();
|
||||
//}
|
||||
//else if (detectResult.VisionImageSet.DetectionResultImage != null && detectResult.VisionImageSet.SizeResultImage != null)
|
||||
//{
|
||||
// Mat img1 = ConvertBitmapToMat(detectResult.VisionImageSet.SizeResultImage.CopyBitmap()); // 第一张图片,已经带框
|
||||
// Mat img2 = ConvertBitmapToMat(detectResult.VisionImageSet.DetectionResultImage.CopyBitmap()); // 第二张图片,已经带框
|
||||
|
||||
// // 合成两张图像:可以选择叠加或拼接
|
||||
// Mat resultImg = new Mat();
|
||||
// Cv2.AddWeighted(img1, 0.5, img2, 0.5, 0, resultImg); // 使用加权平均法合成图像
|
||||
|
||||
// resultMask = resultImg.ToBitmap();
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// resultMask = detectResult.VisionImageSet.DetectionResultImage.CopyBitmap();
|
||||
//}
|
||||
|
||||
List<IShapeElement> detectionResultShapes =
|
||||
new List<IShapeElement>(detectResult.DetectionResultShapes);
|
||||
|
||||
DetectResultDisplay resultDisplay = new DetectResultDisplay(detectResult, resultMask, displayTxt);
|
||||
detectionResultShapes.Add(resultDisplay);
|
||||
List<IShapeElement> detectionResultShapesClone = new List<IShapeElement>(detectionResultShapes);
|
||||
|
||||
DetectionDone(DetectionId, resultMask, detectionResultShapes);
|
||||
|
||||
//SaveDetectResultImageAsync(detectResult);
|
||||
// SaveDetectResultCSVAsync(detectResult);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception,
|
||||
// $"{Name}显示{detectResult.DetectName}检测结果异常,{ex.GetExceptionMessage()}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
|
||||
using DH.Commons.Enums;
|
||||
using OpenCvSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -28,7 +29,7 @@ namespace DH.Devices.Vision
|
||||
MLGPUEngine.FreePredictor(Model);
|
||||
}
|
||||
catch (Exception e) { }
|
||||
// MLEngine.FreePredictor(Model);
|
||||
// MLEngine.FreePredictor(Model);
|
||||
}
|
||||
public void Dispose2()
|
||||
{
|
||||
@@ -41,7 +42,7 @@ namespace DH.Devices.Vision
|
||||
}
|
||||
public SimboVisionMLBase()
|
||||
{
|
||||
// ColorMap = OpenCVHelper.GetColorMap(256);//使用3个通道
|
||||
ColorMap = OpenCVHelper.GetColorMap(256);//使用3个通道
|
||||
// ColorLut = new Mat(1, 256, MatType.CV_8UC3, ColorMap);
|
||||
}
|
||||
}
|
||||
@@ -55,16 +56,22 @@ namespace DH.Devices.Vision
|
||||
// "rect": [421, 823, 6, 8]
|
||||
// }]
|
||||
//}
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public List<Result> HYolo;
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public class Result
|
||||
{
|
||||
|
||||
public double fScore;
|
||||
public int classId;
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string classname;
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
//public double area;
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public List<int> rect;
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
|
||||
}
|
||||
@@ -72,45 +79,28 @@ namespace DH.Devices.Vision
|
||||
}
|
||||
public class SegResult
|
||||
{
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public List<Result> SegmentResult;
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public class Result
|
||||
{
|
||||
|
||||
public double fScore;
|
||||
public int classId;
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string classname;
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
public double area;
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public List<int> rect;
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
public class PreTreatParam
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 参数名称
|
||||
/// </summary>
|
||||
///
|
||||
[Category("预处理参数")]
|
||||
[DisplayName("参数名称")]
|
||||
[Description("参数名称")]
|
||||
public string Name { get; set; }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 参数值
|
||||
/// </summary>
|
||||
///
|
||||
[Category("预处理参数")]
|
||||
[DisplayName("参数值")]
|
||||
[Description("参数值")]
|
||||
public string Value { get; set; }
|
||||
|
||||
|
||||
}
|
||||
public static class MLGPUEngine
|
||||
{
|
||||
|
||||
|
||||
@@ -22,14 +22,20 @@ namespace DH.Devices.Vision
|
||||
/// <summary>
|
||||
/// 检测配置ID
|
||||
/// </summary>
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string DetectionId { get; set; }
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public string DetectionName { get; set; }
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
/// <summary>
|
||||
/// 深度学习模型
|
||||
/// </summary>
|
||||
#pragma warning disable CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
public SimboVisionMLBase StationMLEngine { get; set; }
|
||||
#pragma warning restore CS8618 // 在退出构造函数时,不可为 null 的字段必须包含非 null 值。请考虑声明为可以为 null。
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
599
DH.UI.Model.Winform/Canvas.Designer.cs
generated
Normal file
599
DH.UI.Model.Winform/Canvas.Designer.cs
generated
Normal file
@@ -0,0 +1,599 @@
|
||||
namespace DH.UI.Model.Winform
|
||||
{
|
||||
partial class Canvas
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要修改
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Canvas));
|
||||
this.ctmsElements = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.tsmiResort = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tsmiInitialState = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tsmiClearStandardValue = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tsmiClearActualValue = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.ctmsKeepElements = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.tsmiUnselectElements = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tsmiKeepSelected = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tsmiKeepUnselected = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.BottomToolStripPanel = new System.Windows.Forms.ToolStripPanel();
|
||||
this.TopToolStripPanel = new System.Windows.Forms.ToolStripPanel();
|
||||
this.RightToolStripPanel = new System.Windows.Forms.ToolStripPanel();
|
||||
this.LeftToolStripPanel = new System.Windows.Forms.ToolStripPanel();
|
||||
this.ContentPanel = new System.Windows.Forms.ToolStripContentPanel();
|
||||
this.scMain = new System.Windows.Forms.SplitContainer();
|
||||
this.tsROIs = new System.Windows.Forms.ToolStrip();
|
||||
this.tsTool = new System.Windows.Forms.ToolStrip();
|
||||
this.tsBtnLoadImage = new System.Windows.Forms.ToolStripButton();
|
||||
this.tsBtnSaveImage = new System.Windows.Forms.ToolStripButton();
|
||||
this.tsBtnSaveImageWithElements = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.tsBtnMapSize = new System.Windows.Forms.ToolStripButton();
|
||||
this.tsBtnScreenSize = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripSeparator1 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.tsBtnModeNormal = new System.Windows.Forms.ToolStripButton();
|
||||
this.tsBtnModeSelection = new System.Windows.Forms.ToolStripButton();
|
||||
this.toolStripSeparator2 = new System.Windows.Forms.ToolStripSeparator();
|
||||
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
|
||||
this.chkShowChecked = new System.Windows.Forms.CheckBox();
|
||||
this.dgElements = new System.Windows.Forms.DataGridView();
|
||||
this.colEnableState = new System.Windows.Forms.DataGridViewCheckBoxColumn();
|
||||
this.colId = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.colIndex = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.colName = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.propGridElement = new System.Windows.Forms.PropertyGrid();
|
||||
this.miniToolStrip = new System.Windows.Forms.ToolStrip();
|
||||
this.stsStatus = new System.Windows.Forms.StatusStrip();
|
||||
this.tsslLocation = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.tsslMouseState = new System.Windows.Forms.ToolStripStatusLabel();
|
||||
this.dataGridViewCheckBoxColumn1 = new System.Windows.Forms.DataGridViewCheckBoxColumn();
|
||||
this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||
this.ctmsElements.SuspendLayout();
|
||||
this.ctmsKeepElements.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.scMain)).BeginInit();
|
||||
this.scMain.Panel1.SuspendLayout();
|
||||
this.scMain.Panel2.SuspendLayout();
|
||||
this.scMain.SuspendLayout();
|
||||
this.tsTool.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
|
||||
this.splitContainer1.Panel1.SuspendLayout();
|
||||
this.splitContainer1.Panel2.SuspendLayout();
|
||||
this.splitContainer1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgElements)).BeginInit();
|
||||
this.stsStatus.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ctmsElements
|
||||
//
|
||||
this.ctmsElements.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.tsmiResort,
|
||||
this.tsmiInitialState,
|
||||
this.tsmiClearStandardValue,
|
||||
this.tsmiClearActualValue});
|
||||
this.ctmsElements.Name = "ctmsElements";
|
||||
this.ctmsElements.Size = new System.Drawing.Size(137, 92);
|
||||
//
|
||||
// tsmiResort
|
||||
//
|
||||
this.tsmiResort.Name = "tsmiResort";
|
||||
this.tsmiResort.Size = new System.Drawing.Size(136, 22);
|
||||
this.tsmiResort.Text = "重新排序";
|
||||
this.tsmiResort.Click += new System.EventHandler(this.tsmiResort_Click);
|
||||
//
|
||||
// tsmiInitialState
|
||||
//
|
||||
this.tsmiInitialState.Name = "tsmiInitialState";
|
||||
this.tsmiInitialState.Size = new System.Drawing.Size(136, 22);
|
||||
this.tsmiInitialState.Text = "初始化";
|
||||
this.tsmiInitialState.Click += new System.EventHandler(this.tsmiInitialState_Click);
|
||||
//
|
||||
// tsmiClearStandardValue
|
||||
//
|
||||
this.tsmiClearStandardValue.Name = "tsmiClearStandardValue";
|
||||
this.tsmiClearStandardValue.Size = new System.Drawing.Size(136, 22);
|
||||
this.tsmiClearStandardValue.Text = "清空标准值";
|
||||
this.tsmiClearStandardValue.Click += new System.EventHandler(this.tsmiClearStandardValue_Click);
|
||||
//
|
||||
// tsmiClearActualValue
|
||||
//
|
||||
this.tsmiClearActualValue.Name = "tsmiClearActualValue";
|
||||
this.tsmiClearActualValue.Size = new System.Drawing.Size(136, 22);
|
||||
this.tsmiClearActualValue.Text = "清空测量值";
|
||||
this.tsmiClearActualValue.Click += new System.EventHandler(this.tsmiClearActualValue_Click);
|
||||
//
|
||||
// ctmsKeepElements
|
||||
//
|
||||
this.ctmsKeepElements.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.tsmiUnselectElements,
|
||||
this.tsmiKeepSelected,
|
||||
this.tsmiKeepUnselected});
|
||||
this.ctmsKeepElements.Name = "ctmsKeepElements";
|
||||
this.ctmsKeepElements.Size = new System.Drawing.Size(173, 70);
|
||||
//
|
||||
// tsmiUnselectElements
|
||||
//
|
||||
this.tsmiUnselectElements.Name = "tsmiUnselectElements";
|
||||
this.tsmiUnselectElements.Size = new System.Drawing.Size(172, 22);
|
||||
this.tsmiUnselectElements.Text = "取消全部基元选择";
|
||||
this.tsmiUnselectElements.Click += new System.EventHandler(this.tsmiUnselectElements_Click);
|
||||
//
|
||||
// tsmiKeepSelected
|
||||
//
|
||||
this.tsmiKeepSelected.Name = "tsmiKeepSelected";
|
||||
this.tsmiKeepSelected.Size = new System.Drawing.Size(172, 22);
|
||||
this.tsmiKeepSelected.Text = "保留选中的基元";
|
||||
this.tsmiKeepSelected.Click += new System.EventHandler(this.tsmiKeepSelected_Click);
|
||||
//
|
||||
// tsmiKeepUnselected
|
||||
//
|
||||
this.tsmiKeepUnselected.Name = "tsmiKeepUnselected";
|
||||
this.tsmiKeepUnselected.Size = new System.Drawing.Size(172, 22);
|
||||
this.tsmiKeepUnselected.Text = "保留未选中的基元";
|
||||
this.tsmiKeepUnselected.Click += new System.EventHandler(this.tsmiKeepUnselected_Click);
|
||||
//
|
||||
// BottomToolStripPanel
|
||||
//
|
||||
this.BottomToolStripPanel.Location = new System.Drawing.Point(0, 0);
|
||||
this.BottomToolStripPanel.Name = "BottomToolStripPanel";
|
||||
this.BottomToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
this.BottomToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.BottomToolStripPanel.Size = new System.Drawing.Size(0, 0);
|
||||
//
|
||||
// TopToolStripPanel
|
||||
//
|
||||
this.TopToolStripPanel.Location = new System.Drawing.Point(0, 0);
|
||||
this.TopToolStripPanel.Name = "TopToolStripPanel";
|
||||
this.TopToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
this.TopToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.TopToolStripPanel.Size = new System.Drawing.Size(0, 0);
|
||||
//
|
||||
// RightToolStripPanel
|
||||
//
|
||||
this.RightToolStripPanel.Location = new System.Drawing.Point(0, 0);
|
||||
this.RightToolStripPanel.Name = "RightToolStripPanel";
|
||||
this.RightToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
this.RightToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.RightToolStripPanel.Size = new System.Drawing.Size(0, 0);
|
||||
//
|
||||
// LeftToolStripPanel
|
||||
//
|
||||
this.LeftToolStripPanel.Location = new System.Drawing.Point(0, 0);
|
||||
this.LeftToolStripPanel.Name = "LeftToolStripPanel";
|
||||
this.LeftToolStripPanel.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
this.LeftToolStripPanel.RowMargin = new System.Windows.Forms.Padding(3, 0, 0, 0);
|
||||
this.LeftToolStripPanel.Size = new System.Drawing.Size(0, 0);
|
||||
//
|
||||
// ContentPanel
|
||||
//
|
||||
this.ContentPanel.Size = new System.Drawing.Size(610, 417);
|
||||
//
|
||||
// scMain
|
||||
//
|
||||
this.scMain.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.scMain.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
|
||||
this.scMain.Location = new System.Drawing.Point(0, 0);
|
||||
this.scMain.Name = "scMain";
|
||||
//
|
||||
// scMain.Panel1
|
||||
//
|
||||
this.scMain.Panel1.Controls.Add(this.tsROIs);
|
||||
this.scMain.Panel1.Controls.Add(this.tsTool);
|
||||
//
|
||||
// scMain.Panel2
|
||||
//
|
||||
this.scMain.Panel2.Controls.Add(this.splitContainer1);
|
||||
this.scMain.Size = new System.Drawing.Size(635, 467);
|
||||
this.scMain.SplitterDistance = 399;
|
||||
this.scMain.TabIndex = 4;
|
||||
//
|
||||
// tsROIs
|
||||
//
|
||||
this.tsROIs.Location = new System.Drawing.Point(29, 0);
|
||||
this.tsROIs.Name = "tsROIs";
|
||||
this.tsROIs.Size = new System.Drawing.Size(370, 25);
|
||||
this.tsROIs.TabIndex = 2;
|
||||
this.tsROIs.Text = "toolStrip1";
|
||||
this.tsROIs.Visible = false;
|
||||
//
|
||||
// tsTool
|
||||
//
|
||||
this.tsTool.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.tsTool.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
||||
this.tsTool.ImageScalingSize = new System.Drawing.Size(24, 24);
|
||||
this.tsTool.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.tsBtnLoadImage,
|
||||
this.tsBtnSaveImage,
|
||||
this.tsBtnSaveImageWithElements,
|
||||
this.toolStripSeparator4,
|
||||
this.tsBtnMapSize,
|
||||
this.tsBtnScreenSize,
|
||||
this.toolStripSeparator1,
|
||||
this.tsBtnModeNormal,
|
||||
this.tsBtnModeSelection,
|
||||
this.toolStripSeparator2});
|
||||
this.tsTool.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.VerticalStackWithOverflow;
|
||||
this.tsTool.Location = new System.Drawing.Point(0, 0);
|
||||
this.tsTool.Margin = new System.Windows.Forms.Padding(10, 0, 0, 0);
|
||||
this.tsTool.Name = "tsTool";
|
||||
this.tsTool.Size = new System.Drawing.Size(29, 467);
|
||||
this.tsTool.TabIndex = 1;
|
||||
this.tsTool.Text = "toolStrip1";
|
||||
//
|
||||
// tsBtnLoadImage
|
||||
//
|
||||
this.tsBtnLoadImage.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.tsBtnLoadImage.Image = ((System.Drawing.Image)(resources.GetObject("tsBtnLoadImage.Image")));
|
||||
this.tsBtnLoadImage.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsBtnLoadImage.Name = "tsBtnLoadImage";
|
||||
this.tsBtnLoadImage.Size = new System.Drawing.Size(26, 28);
|
||||
this.tsBtnLoadImage.Text = "LoadImage";
|
||||
this.tsBtnLoadImage.ToolTipText = "Load Image";
|
||||
this.tsBtnLoadImage.Click += new System.EventHandler(this.tsBtnLoadImage_Click);
|
||||
//
|
||||
// tsBtnSaveImage
|
||||
//
|
||||
this.tsBtnSaveImage.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.tsBtnSaveImage.Image = ((System.Drawing.Image)(resources.GetObject("tsBtnSaveImage.Image")));
|
||||
this.tsBtnSaveImage.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsBtnSaveImage.Name = "tsBtnSaveImage";
|
||||
this.tsBtnSaveImage.Size = new System.Drawing.Size(26, 28);
|
||||
this.tsBtnSaveImage.Text = "SaveImage";
|
||||
this.tsBtnSaveImage.Click += new System.EventHandler(this.tsBtnSaveImage_Click);
|
||||
//
|
||||
// tsBtnSaveImageWithElements
|
||||
//
|
||||
this.tsBtnSaveImageWithElements.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.tsBtnSaveImageWithElements.Image = ((System.Drawing.Image)(resources.GetObject("tsBtnSaveImageWithElements.Image")));
|
||||
this.tsBtnSaveImageWithElements.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsBtnSaveImageWithElements.Name = "tsBtnSaveImageWithElements";
|
||||
this.tsBtnSaveImageWithElements.Size = new System.Drawing.Size(26, 28);
|
||||
this.tsBtnSaveImageWithElements.Text = "SaveImageWithElements";
|
||||
this.tsBtnSaveImageWithElements.Click += new System.EventHandler(this.tsBtnSaveImageWithElements_Click);
|
||||
//
|
||||
// toolStripSeparator4
|
||||
//
|
||||
this.toolStripSeparator4.Name = "toolStripSeparator4";
|
||||
this.toolStripSeparator4.Size = new System.Drawing.Size(26, 6);
|
||||
//
|
||||
// tsBtnMapSize
|
||||
//
|
||||
this.tsBtnMapSize.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.tsBtnMapSize.Image = ((System.Drawing.Image)(resources.GetObject("tsBtnMapSize.Image")));
|
||||
this.tsBtnMapSize.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsBtnMapSize.Name = "tsBtnMapSize";
|
||||
this.tsBtnMapSize.Size = new System.Drawing.Size(26, 28);
|
||||
this.tsBtnMapSize.Text = "Original";
|
||||
this.tsBtnMapSize.ToolTipText = "Map Size";
|
||||
this.tsBtnMapSize.Click += new System.EventHandler(this.tsBtnMapSize_Click);
|
||||
//
|
||||
// tsBtnScreenSize
|
||||
//
|
||||
this.tsBtnScreenSize.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.tsBtnScreenSize.Image = ((System.Drawing.Image)(resources.GetObject("tsBtnScreenSize.Image")));
|
||||
this.tsBtnScreenSize.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsBtnScreenSize.Name = "tsBtnScreenSize";
|
||||
this.tsBtnScreenSize.Size = new System.Drawing.Size(26, 28);
|
||||
this.tsBtnScreenSize.Text = "toolStripButton2";
|
||||
this.tsBtnScreenSize.ToolTipText = "Screen Size";
|
||||
this.tsBtnScreenSize.Click += new System.EventHandler(this.tsBtnScreenSize_Click);
|
||||
//
|
||||
// toolStripSeparator1
|
||||
//
|
||||
this.toolStripSeparator1.Name = "toolStripSeparator1";
|
||||
this.toolStripSeparator1.Size = new System.Drawing.Size(26, 6);
|
||||
//
|
||||
// tsBtnModeNormal
|
||||
//
|
||||
this.tsBtnModeNormal.CheckOnClick = true;
|
||||
this.tsBtnModeNormal.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.tsBtnModeNormal.Image = ((System.Drawing.Image)(resources.GetObject("tsBtnModeNormal.Image")));
|
||||
this.tsBtnModeNormal.ImageTransparentColor = System.Drawing.SystemColors.Control;
|
||||
this.tsBtnModeNormal.Name = "tsBtnModeNormal";
|
||||
this.tsBtnModeNormal.Size = new System.Drawing.Size(26, 28);
|
||||
this.tsBtnModeNormal.Text = "Normal Mode";
|
||||
this.tsBtnModeNormal.ToolTipText = "Normal Mode";
|
||||
this.tsBtnModeNormal.CheckedChanged += new System.EventHandler(this.tsBtnModeNormal_CheckedChanged);
|
||||
//
|
||||
// tsBtnModeSelection
|
||||
//
|
||||
this.tsBtnModeSelection.CheckOnClick = true;
|
||||
this.tsBtnModeSelection.DisplayStyle = System.Windows.Forms.ToolStripItemDisplayStyle.Image;
|
||||
this.tsBtnModeSelection.Image = ((System.Drawing.Image)(resources.GetObject("tsBtnModeSelection.Image")));
|
||||
this.tsBtnModeSelection.ImageTransparentColor = System.Drawing.Color.Magenta;
|
||||
this.tsBtnModeSelection.Name = "tsBtnModeSelection";
|
||||
this.tsBtnModeSelection.Size = new System.Drawing.Size(26, 28);
|
||||
this.tsBtnModeSelection.Text = "Selection Mode";
|
||||
this.tsBtnModeSelection.CheckedChanged += new System.EventHandler(this.tsBtnModeNormal_CheckedChanged);
|
||||
//
|
||||
// toolStripSeparator2
|
||||
//
|
||||
this.toolStripSeparator2.Name = "toolStripSeparator2";
|
||||
this.toolStripSeparator2.Size = new System.Drawing.Size(26, 6);
|
||||
//
|
||||
// splitContainer1
|
||||
//
|
||||
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitContainer1.Name = "splitContainer1";
|
||||
this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
//
|
||||
// splitContainer1.Panel1
|
||||
//
|
||||
this.splitContainer1.Panel1.Controls.Add(this.chkShowChecked);
|
||||
this.splitContainer1.Panel1.Controls.Add(this.dgElements);
|
||||
//
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
this.splitContainer1.Panel2.Controls.Add(this.propGridElement);
|
||||
this.splitContainer1.Size = new System.Drawing.Size(232, 467);
|
||||
this.splitContainer1.SplitterDistance = 215;
|
||||
this.splitContainer1.TabIndex = 2;
|
||||
//
|
||||
// chkShowChecked
|
||||
//
|
||||
this.chkShowChecked.AutoSize = true;
|
||||
this.chkShowChecked.Location = new System.Drawing.Point(14, 8);
|
||||
this.chkShowChecked.Name = "chkShowChecked";
|
||||
this.chkShowChecked.Size = new System.Drawing.Size(110, 17);
|
||||
this.chkShowChecked.TabIndex = 1;
|
||||
this.chkShowChecked.Text = "仅显示选中项目";
|
||||
this.chkShowChecked.UseVisualStyleBackColor = true;
|
||||
this.chkShowChecked.CheckedChanged += new System.EventHandler(this.chkShowChecked_CheckedChanged);
|
||||
//
|
||||
// dgElements
|
||||
//
|
||||
this.dgElements.AllowUserToAddRows = false;
|
||||
this.dgElements.AllowUserToDeleteRows = false;
|
||||
this.dgElements.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.dgElements.BackgroundColor = System.Drawing.SystemColors.GradientInactiveCaption;
|
||||
this.dgElements.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
this.dgElements.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] {
|
||||
this.colEnableState,
|
||||
this.colId,
|
||||
this.colIndex,
|
||||
this.colName});
|
||||
this.dgElements.Location = new System.Drawing.Point(0, 30);
|
||||
this.dgElements.MultiSelect = false;
|
||||
this.dgElements.Name = "dgElements";
|
||||
this.dgElements.RowTemplate.Height = 23;
|
||||
this.dgElements.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
|
||||
this.dgElements.Size = new System.Drawing.Size(232, 185);
|
||||
this.dgElements.TabIndex = 0;
|
||||
this.dgElements.CellMouseDoubleClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dgElements_CellMouseDoubleClick);
|
||||
this.dgElements.SelectionChanged += new System.EventHandler(this.dgElements_SelectionChanged);
|
||||
//
|
||||
// colEnableState
|
||||
//
|
||||
this.colEnableState.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.colEnableState.DataPropertyName = "IsEnabled";
|
||||
this.colEnableState.FillWeight = 41.95804F;
|
||||
this.colEnableState.HeaderText = "";
|
||||
this.colEnableState.MinimumWidth = 30;
|
||||
this.colEnableState.Name = "colEnableState";
|
||||
this.colEnableState.Resizable = System.Windows.Forms.DataGridViewTriState.True;
|
||||
//
|
||||
// colId
|
||||
//
|
||||
this.colId.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.colId.DataPropertyName = "ID";
|
||||
this.colId.HeaderText = "ID";
|
||||
this.colId.MinimumWidth = 30;
|
||||
this.colId.Name = "colId";
|
||||
this.colId.ReadOnly = true;
|
||||
this.colId.Visible = false;
|
||||
//
|
||||
// colIndex
|
||||
//
|
||||
this.colIndex.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCells;
|
||||
this.colIndex.DataPropertyName = "Index";
|
||||
this.colIndex.HeaderText = "序号";
|
||||
this.colIndex.MinimumWidth = 40;
|
||||
this.colIndex.Name = "colIndex";
|
||||
this.colIndex.ReadOnly = true;
|
||||
this.colIndex.Width = 56;
|
||||
//
|
||||
// colName
|
||||
//
|
||||
this.colName.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.colName.DataPropertyName = "Name";
|
||||
this.colName.FillWeight = 158.042F;
|
||||
this.colName.HeaderText = "名称";
|
||||
this.colName.MinimumWidth = 60;
|
||||
this.colName.Name = "colName";
|
||||
this.colName.ReadOnly = true;
|
||||
//
|
||||
// propGridElement
|
||||
//
|
||||
this.propGridElement.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.propGridElement.LargeButtons = true;
|
||||
this.propGridElement.LineColor = System.Drawing.SystemColors.ControlDark;
|
||||
this.propGridElement.Location = new System.Drawing.Point(0, 0);
|
||||
this.propGridElement.Margin = new System.Windows.Forms.Padding(3, 3, 3, 50);
|
||||
this.propGridElement.Name = "propGridElement";
|
||||
this.propGridElement.Size = new System.Drawing.Size(232, 248);
|
||||
this.propGridElement.TabIndex = 0;
|
||||
this.propGridElement.ToolbarVisible = false;
|
||||
this.propGridElement.SelectedObjectsChanged += new System.EventHandler(this.propGridElement_SelectedObjectsChanged);
|
||||
//
|
||||
// miniToolStrip
|
||||
//
|
||||
this.miniToolStrip.AccessibleName = "新项选择";
|
||||
this.miniToolStrip.AccessibleRole = System.Windows.Forms.AccessibleRole.ButtonDropDown;
|
||||
this.miniToolStrip.AutoSize = false;
|
||||
this.miniToolStrip.CanOverflow = false;
|
||||
this.miniToolStrip.Dock = System.Windows.Forms.DockStyle.None;
|
||||
this.miniToolStrip.GripStyle = System.Windows.Forms.ToolStripGripStyle.Hidden;
|
||||
this.miniToolStrip.ImageScalingSize = new System.Drawing.Size(24, 24);
|
||||
this.miniToolStrip.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.VerticalStackWithOverflow;
|
||||
this.miniToolStrip.Location = new System.Drawing.Point(0, 235);
|
||||
this.miniToolStrip.Margin = new System.Windows.Forms.Padding(10, 0, 0, 0);
|
||||
this.miniToolStrip.Name = "miniToolStrip";
|
||||
this.miniToolStrip.Size = new System.Drawing.Size(29, 237);
|
||||
this.miniToolStrip.TabIndex = 1;
|
||||
//
|
||||
// stsStatus
|
||||
//
|
||||
this.stsStatus.BackColor = System.Drawing.Color.Transparent;
|
||||
this.stsStatus.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.tsslLocation,
|
||||
this.tsslMouseState});
|
||||
this.stsStatus.LayoutStyle = System.Windows.Forms.ToolStripLayoutStyle.Flow;
|
||||
this.stsStatus.Location = new System.Drawing.Point(0, 445);
|
||||
this.stsStatus.Name = "stsStatus";
|
||||
this.stsStatus.Size = new System.Drawing.Size(635, 22);
|
||||
this.stsStatus.TabIndex = 0;
|
||||
this.stsStatus.Text = "statusStrip1";
|
||||
//
|
||||
// tsslLocation
|
||||
//
|
||||
this.tsslLocation.Name = "tsslLocation";
|
||||
this.tsslLocation.Size = new System.Drawing.Size(24, 17);
|
||||
this.tsslLocation.Text = " ";
|
||||
//
|
||||
// tsslMouseState
|
||||
//
|
||||
this.tsslMouseState.Name = "tsslMouseState";
|
||||
this.tsslMouseState.Size = new System.Drawing.Size(52, 17);
|
||||
this.tsslMouseState.Text = " ";
|
||||
//
|
||||
// dataGridViewCheckBoxColumn1
|
||||
//
|
||||
this.dataGridViewCheckBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.dataGridViewCheckBoxColumn1.DataPropertyName = "IsEnabled";
|
||||
this.dataGridViewCheckBoxColumn1.FillWeight = 41.95804F;
|
||||
this.dataGridViewCheckBoxColumn1.HeaderText = "";
|
||||
this.dataGridViewCheckBoxColumn1.MinimumWidth = 30;
|
||||
this.dataGridViewCheckBoxColumn1.Name = "dataGridViewCheckBoxColumn1";
|
||||
this.dataGridViewCheckBoxColumn1.Resizable = System.Windows.Forms.DataGridViewTriState.True;
|
||||
//
|
||||
// dataGridViewTextBoxColumn1
|
||||
//
|
||||
this.dataGridViewTextBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
|
||||
this.dataGridViewTextBoxColumn1.DataPropertyName = "Id";
|
||||
this.dataGridViewTextBoxColumn1.HeaderText = "ID";
|
||||
this.dataGridViewTextBoxColumn1.MinimumWidth = 30;
|
||||
this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
|
||||
this.dataGridViewTextBoxColumn1.ReadOnly = true;
|
||||
this.dataGridViewTextBoxColumn1.Visible = false;
|
||||
//
|
||||
// dataGridViewTextBoxColumn2
|
||||
//
|
||||
this.dataGridViewTextBoxColumn2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
|
||||
this.dataGridViewTextBoxColumn2.DataPropertyName = "Index";
|
||||
this.dataGridViewTextBoxColumn2.HeaderText = "序号";
|
||||
this.dataGridViewTextBoxColumn2.MinimumWidth = 40;
|
||||
this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
|
||||
this.dataGridViewTextBoxColumn2.ReadOnly = true;
|
||||
//
|
||||
// dataGridViewTextBoxColumn3
|
||||
//
|
||||
this.dataGridViewTextBoxColumn3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.DisplayedCellsExceptHeader;
|
||||
this.dataGridViewTextBoxColumn3.DataPropertyName = "Name";
|
||||
this.dataGridViewTextBoxColumn3.FillWeight = 158.042F;
|
||||
this.dataGridViewTextBoxColumn3.HeaderText = "名称";
|
||||
this.dataGridViewTextBoxColumn3.MinimumWidth = 80;
|
||||
this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
|
||||
this.dataGridViewTextBoxColumn3.ReadOnly = true;
|
||||
//
|
||||
// Canvas
|
||||
//
|
||||
this.Controls.Add(this.stsStatus);
|
||||
this.Controls.Add(this.scMain);
|
||||
this.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134)));
|
||||
this.Name = "Canvas";
|
||||
this.Size = new System.Drawing.Size(635, 467);
|
||||
this.ctmsElements.ResumeLayout(false);
|
||||
this.ctmsKeepElements.ResumeLayout(false);
|
||||
this.scMain.Panel1.ResumeLayout(false);
|
||||
this.scMain.Panel1.PerformLayout();
|
||||
this.scMain.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.scMain)).EndInit();
|
||||
this.scMain.ResumeLayout(false);
|
||||
this.tsTool.ResumeLayout(false);
|
||||
this.tsTool.PerformLayout();
|
||||
this.splitContainer1.Panel1.ResumeLayout(false);
|
||||
this.splitContainer1.Panel1.PerformLayout();
|
||||
this.splitContainer1.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
|
||||
this.splitContainer1.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.dgElements)).EndInit();
|
||||
this.stsStatus.ResumeLayout(false);
|
||||
this.stsStatus.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;
|
||||
private System.Windows.Forms.ContextMenuStrip ctmsElements;
|
||||
private System.Windows.Forms.ToolStripMenuItem tsmiResort;
|
||||
private System.Windows.Forms.ToolStripMenuItem tsmiInitialState;
|
||||
private System.Windows.Forms.ToolStripMenuItem tsmiClearStandardValue;
|
||||
private System.Windows.Forms.ToolStripMenuItem tsmiClearActualValue;
|
||||
private System.Windows.Forms.DataGridViewCheckBoxColumn dataGridViewCheckBoxColumn1;
|
||||
private System.Windows.Forms.ContextMenuStrip ctmsKeepElements;
|
||||
private System.Windows.Forms.ToolStripMenuItem tsmiKeepSelected;
|
||||
private System.Windows.Forms.ToolStripMenuItem tsmiKeepUnselected;
|
||||
private System.Windows.Forms.ToolStripMenuItem tsmiUnselectElements;
|
||||
private System.Windows.Forms.ToolStripPanel BottomToolStripPanel;
|
||||
private System.Windows.Forms.ToolStripPanel TopToolStripPanel;
|
||||
private System.Windows.Forms.ToolStripPanel RightToolStripPanel;
|
||||
private System.Windows.Forms.ToolStripPanel LeftToolStripPanel;
|
||||
private System.Windows.Forms.ToolStripContentPanel ContentPanel;
|
||||
private System.Windows.Forms.SplitContainer scMain;
|
||||
private System.Windows.Forms.StatusStrip stsStatus;
|
||||
private System.Windows.Forms.ToolStripStatusLabel tsslLocation;
|
||||
private System.Windows.Forms.ToolStripStatusLabel tsslMouseState;
|
||||
private System.Windows.Forms.ToolStrip tsTool;
|
||||
private System.Windows.Forms.ToolStripButton tsBtnLoadImage;
|
||||
private System.Windows.Forms.ToolStripButton tsBtnSaveImage;
|
||||
private System.Windows.Forms.ToolStripButton tsBtnSaveImageWithElements;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator4;
|
||||
private System.Windows.Forms.ToolStripButton tsBtnMapSize;
|
||||
private System.Windows.Forms.ToolStripButton tsBtnScreenSize;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator1;
|
||||
private System.Windows.Forms.ToolStripButton tsBtnModeNormal;
|
||||
private System.Windows.Forms.ToolStripButton tsBtnModeSelection;
|
||||
private System.Windows.Forms.ToolStripSeparator toolStripSeparator2;
|
||||
private System.Windows.Forms.SplitContainer splitContainer1;
|
||||
private System.Windows.Forms.CheckBox chkShowChecked;
|
||||
private System.Windows.Forms.DataGridView dgElements;
|
||||
private System.Windows.Forms.DataGridViewCheckBoxColumn colEnableState;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn colId;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn colIndex;
|
||||
private System.Windows.Forms.DataGridViewTextBoxColumn colName;
|
||||
private System.Windows.Forms.PropertyGrid propGridElement;
|
||||
private System.Windows.Forms.ToolStrip miniToolStrip;
|
||||
private System.Windows.Forms.ToolStrip tsROIs;
|
||||
}
|
||||
}
|
||||
629
DH.UI.Model.Winform/Canvas.cs
Normal file
629
DH.UI.Model.Winform/Canvas.cs
Normal file
@@ -0,0 +1,629 @@
|
||||
|
||||
using DH.Commons.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static DH.Commons.Enums.EnumHelper;
|
||||
|
||||
|
||||
|
||||
namespace DH.UI.Model.Winform
|
||||
{
|
||||
public partial class Canvas : UserControl
|
||||
{
|
||||
readonly CanvasImage cvImage = new CanvasImage();
|
||||
|
||||
#region Grid
|
||||
readonly GridCtrl gridCtrl = new GridCtrl();
|
||||
|
||||
private void GridValueChanged(int gridValue)
|
||||
{
|
||||
cvImage.GridValue = gridValue;
|
||||
}
|
||||
|
||||
private void ShowGridChanged(bool isShowGrid)
|
||||
{
|
||||
cvImage.ShowGrid = isShowGrid;
|
||||
}
|
||||
|
||||
private void GridColorChanged(Color obj)
|
||||
{
|
||||
cvImage.Pen_Grid.Color = obj;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public Canvas()
|
||||
{
|
||||
InitializeComponent();
|
||||
DoubleBuffered = true;
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.ResizeRedraw |
|
||||
ControlStyles.AllPaintingInWmPaint, true);
|
||||
|
||||
cvImage.Dock = DockStyle.Fill;
|
||||
scMain.Panel1.Controls.Add(cvImage);
|
||||
|
||||
dgElements.AutoGenerateColumns = false;
|
||||
|
||||
var checkHead = new DataGridViewCheckboxHeaderCell();
|
||||
checkHead.OnCheckBoxClicked += CheckHead_OnCheckBoxClicked;
|
||||
dgElements.Columns[0].HeaderCell = checkHead;
|
||||
dgElements.Columns[0].HeaderCell.Value = string.Empty;
|
||||
|
||||
Elements.CollectionChanged += Elements_CollectionChanged;
|
||||
|
||||
cvImage.OnMouseLocationUpdated = OnMouseLocationUpdated;
|
||||
cvImage.OnMouseStateChanged += OnMouseStateChanged;
|
||||
|
||||
gridCtrl.IsShowGridChanged = ShowGridChanged;
|
||||
gridCtrl.GridValueChanged = GridValueChanged;
|
||||
gridCtrl.GridColorChanged = GridColorChanged;
|
||||
gridCtrl.Padding = new Padding(0, 5, 0, 5);
|
||||
tsTool.Items.Add(new GridCtrlHost(gridCtrl));
|
||||
tsTool.Invalidate();
|
||||
|
||||
_eleCollectionChangedTimer = new System.Threading.Timer(OnElementCollectionChangedBufferTimer, null, -1, -1);
|
||||
|
||||
//tsmiShowStatusBar.Checked = tsmiShowToolBar.Checked = IsShowElementList = IsShowROITool = IsShowStatusBar = IsShowToolBar = false;
|
||||
}
|
||||
|
||||
private void OnMouseStateChanged(MouseState ms)
|
||||
{
|
||||
if (ms != MouseState.SelectionZone && ms != MouseState.SelectionZoneDoing)
|
||||
{
|
||||
if (this.IsHandleCreated)
|
||||
{
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
tsBtnModeSelection.Checked = false;
|
||||
tsBtnModeNormal.Checked = true;
|
||||
}));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 底部状态栏
|
||||
public bool IsShowStatusBar
|
||||
{
|
||||
get => stsStatus.Visible;
|
||||
set => stsStatus.Visible = value;
|
||||
}
|
||||
|
||||
private void OnMouseLocationUpdated(Point screenPoint, PointF imagePoint, string colorDesc)
|
||||
{
|
||||
//await Task.Run(() => tsslLocation.Text = $"屏幕坐标X:{screenPoint.X},Y:{screenPoint.Y} 图片坐标X:{imagePoint.X},Y:{imagePoint.Y} 颜色:{colorDesc}");
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
tsslLocation.Text = $"屏幕坐标X:{screenPoint.X},Y:{screenPoint.Y} 图片坐标X:{imagePoint.X.ToString("f2")},Y:{imagePoint.Y.ToString("f2")} 颜色:{colorDesc}";
|
||||
}));
|
||||
}
|
||||
|
||||
//private void MouseLocationUpdated(Point screenPoint, Point imagePoint, string colorDesc)
|
||||
//{
|
||||
// if (InvokeRequired)
|
||||
// {
|
||||
// Invoke(new Action<Point, Point, string>(MouseLocationUpdated), screenPoint, imagePoint);
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// tsslLocation.Text = $"屏幕坐标X:{screenPoint.X},Y:{screenPoint.Y} 图片坐标X:{imagePoint.X},Y:{imagePoint.Y} 颜色:{colorDesc}";
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 属性
|
||||
#region CanvasImage相关
|
||||
//private MouseState mouseState = MouseState.Normal;
|
||||
//public MouseState MouseState
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// return mouseState;
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// if (mouseState != value)
|
||||
// {
|
||||
// mouseState = value;
|
||||
|
||||
// tsslMouseState.Text = mouseState.ToString();
|
||||
|
||||
// if (mouseState >= MouseState.SelectionZone)
|
||||
// {
|
||||
// tsBtnModeSelection.Checked = true;
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// tsBtnModeNormal.Checked = true;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
public string ImageFilePath { get; set; }
|
||||
|
||||
public Bitmap MAP
|
||||
{
|
||||
get => cvImage.MAP;
|
||||
set => cvImage.MAP = value;
|
||||
}
|
||||
public Matrix Matrix
|
||||
{
|
||||
get => cvImage.Matrix;
|
||||
set => cvImage.Matrix = value;
|
||||
}
|
||||
public MouseState MouseState
|
||||
{
|
||||
get => cvImage.MouseState;
|
||||
set => cvImage.MouseState = value;
|
||||
}
|
||||
public ObservableCollection<IShapeElement> Elements
|
||||
{
|
||||
get => cvImage.Elements;
|
||||
}
|
||||
#endregion
|
||||
|
||||
private bool isShowElementList = false;
|
||||
public bool IsShowElementList
|
||||
{
|
||||
get => isShowElementList;
|
||||
set
|
||||
{
|
||||
//if (isShowElementList != value)
|
||||
{
|
||||
isShowElementList = value;
|
||||
scMain.Panel2Collapsed = !value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool isShowROITool = false;
|
||||
public bool IsShowROITool
|
||||
{
|
||||
get => isShowROITool;
|
||||
set
|
||||
{
|
||||
tsROIs.Visible = isShowROITool = value;
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 图片操作
|
||||
/// <summary>
|
||||
/// 载入图片
|
||||
/// </summary>
|
||||
/// <param name="map"></param>
|
||||
public void LoadImage(Bitmap map)
|
||||
{
|
||||
cvImage.LoadImage(map);
|
||||
OnImageChanged?.Invoke();
|
||||
}
|
||||
public void Clear()
|
||||
{
|
||||
cvImage.Clear();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置图片为原始尺寸
|
||||
/// </summary>
|
||||
public void SetMapSize()
|
||||
{
|
||||
cvImage.SetMapSize();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置图片为适配尺寸
|
||||
/// </summary>
|
||||
public void SetScreenSize()
|
||||
{
|
||||
cvImage.SetScreenSize();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 基元列表
|
||||
private void chkShowChecked_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
dgElements.DataSource = null;
|
||||
|
||||
if (Elements != null && Elements.Count > 0)
|
||||
{
|
||||
if (chkShowChecked.Checked)
|
||||
{
|
||||
dgElements.DataSource = Elements.Where(u => u.IsEnabled && u.IsShowing).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
dgElements.DataSource = Elements.Where(u => u.IsShowing).ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckHead_OnCheckBoxClicked(object sender, DataGridViewCheckboxHeaderEventArgs e)
|
||||
{
|
||||
//foreach (IShapeElement ele in Elements)
|
||||
//{
|
||||
// ele.IsEnabled = e.CheckedState;
|
||||
//}
|
||||
for (int i = 0; i < Elements.Count; i++)
|
||||
{
|
||||
Elements[i].IsEnabled = e.CheckedState;
|
||||
}
|
||||
OnElementChanged(null);
|
||||
}
|
||||
|
||||
private void dgElements_SelectionChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (dgElements.SelectedRows.Count > 0)
|
||||
{
|
||||
var ele = Elements.FirstOrDefault(u => u.ID == dgElements.SelectedRows[0].Cells["colID"].Value.ToString());
|
||||
propGridElement.SelectedObject = ele;
|
||||
}
|
||||
}
|
||||
|
||||
private void dgElements_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
|
||||
{
|
||||
if (dgElements.SelectedRows.Count > 0)
|
||||
{
|
||||
var ele = Elements.FirstOrDefault(u => u.ID == dgElements.SelectedRows[0].Cells["colID"].Value.ToString());
|
||||
|
||||
for (int i = 0; i < Elements.Count; i++)
|
||||
{
|
||||
Elements[i].State = ElementState.Normal;
|
||||
}
|
||||
|
||||
ele.State = ElementState.Selected;
|
||||
|
||||
SetDeviceByElement?.Invoke(ele);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
System.Threading.Timer _eleCollectionChangedTimer = null;
|
||||
|
||||
private void OnElementCollectionChangedBufferTimer(object state)
|
||||
{
|
||||
OnElementChanged(null);
|
||||
for (int i = 0; i < Elements.Count; i++)
|
||||
{
|
||||
Elements[i].PropertyChanged -= Ele_PropertyChanged;
|
||||
Elements[i].PropertyChanged += Ele_PropertyChanged;
|
||||
}
|
||||
//foreach (IShapeElement ele in Elements)
|
||||
//{
|
||||
// ele.PropertyChanged -= Ele_PropertyChanged;
|
||||
// ele.PropertyChanged += Ele_PropertyChanged;
|
||||
//}
|
||||
}
|
||||
|
||||
private void Elements_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
//_eleCollectionChangedTimer?.Change(200, -1);
|
||||
OnElementChanged(null);
|
||||
for (int i = 0; i < Elements.Count; i++)
|
||||
{
|
||||
Elements[i].PropertyChanged -= Ele_PropertyChanged;
|
||||
Elements[i].PropertyChanged += Ele_PropertyChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void Ele_PropertyChanged(object sender, PropertyChangedEventArgs e)
|
||||
{
|
||||
if (e.PropertyName == "IsEnabled")
|
||||
{
|
||||
OnElementChanged(sender as IShapeElement);
|
||||
}
|
||||
else
|
||||
{
|
||||
Invoke(new Action(() =>
|
||||
{
|
||||
cvImage.Invalidate();
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnElementChanged(IShapeElement ele)
|
||||
{
|
||||
if (ele != null)
|
||||
OnElementChangedHandle?.Invoke(ele);
|
||||
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new Action(() => OnElementChanged(ele)));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isShowElementList)
|
||||
{
|
||||
dgElements.DataSource = null;
|
||||
if (Elements != null && Elements.Count > 0)
|
||||
{
|
||||
if (chkShowChecked.Checked)
|
||||
{
|
||||
dgElements.DataSource = Elements.ToList().Where(u => u.IsEnabled && u.IsShowing).ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
dgElements.DataSource = Elements.ToList().Where(u => u.IsShowing).ToList();
|
||||
}
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void propGridElement_SelectedObjectsChanged(object sender, EventArgs e)
|
||||
{
|
||||
propGridElement.ExpandAllGridItems();
|
||||
}
|
||||
|
||||
#region 基元列表右键菜单
|
||||
private void tsmiResort_Click(object sender, EventArgs e)
|
||||
{
|
||||
//Elements.Sort();
|
||||
}
|
||||
|
||||
private void tsmiClearActualValue_Click(object sender, EventArgs e)
|
||||
{
|
||||
//foreach (IShapeElement ele in Elements)
|
||||
//{
|
||||
// if (ele.IsEnabled)
|
||||
// {
|
||||
// ele.SetActualValue(0.0);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void tsmiInitialState_Click(object sender, EventArgs e)
|
||||
{
|
||||
//foreach (IShapeElement ele in Elements)
|
||||
//{
|
||||
// if (ele.IsEnabled)
|
||||
// {
|
||||
// ele.State = ElementState.Normal;
|
||||
// ele.InitialMeasureResult();
|
||||
// }
|
||||
//}
|
||||
}
|
||||
|
||||
private void tsmiClearStandardValue_Click(object sender, EventArgs e)
|
||||
{
|
||||
//foreach (IShapeElement ele in Elements)
|
||||
//{
|
||||
// if (ele.IsEnabled)
|
||||
// {
|
||||
// ele.SetStandardValue(0.0);
|
||||
// }
|
||||
//}
|
||||
}
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
#region 图像区域右键菜单
|
||||
private void tsmiKeepUnselected_Click(object sender, EventArgs e)
|
||||
{
|
||||
KeepElements(false);
|
||||
}
|
||||
|
||||
private void tsmiKeepSelected_Click(object sender, EventArgs e)
|
||||
{
|
||||
KeepElements(true);
|
||||
}
|
||||
|
||||
private void KeepElements(bool isKeepSelected)
|
||||
{
|
||||
for (int i = 0; i < Elements.Count; i++)
|
||||
{
|
||||
var ele = Elements[i];
|
||||
if (ele.IsEnabled)
|
||||
{
|
||||
if (ele.State == ElementState.Selected)
|
||||
{
|
||||
ele.IsEnabled = isKeepSelected;
|
||||
}
|
||||
else
|
||||
{
|
||||
ele.IsEnabled = !isKeepSelected;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tsmiUnselectElements_Click(object sender, EventArgs e)
|
||||
{
|
||||
//if (MouseState == MouseState.SelectedElement)
|
||||
//{
|
||||
// MouseState = MouseState.Normal;
|
||||
|
||||
// //Elements.ForEach(ele =>
|
||||
// foreach (IShapeElement ele in Elements)
|
||||
// {
|
||||
// ele.State = ElementState.Normal;
|
||||
// }
|
||||
// //);
|
||||
//}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 基元的设备属性 运动设置和相机设置
|
||||
public Action<IShapeElement> SetElementDevicePara;
|
||||
|
||||
public Action<IShapeElement> SetDeviceByElement;
|
||||
#endregion
|
||||
|
||||
#region 一般操作工具条
|
||||
public bool IsShowToolBar
|
||||
{
|
||||
get => tsTool.Visible;
|
||||
set => tsTool.Visible = value;
|
||||
}
|
||||
|
||||
private void tsBtnLoadImage_Click(object sender, EventArgs e)
|
||||
{
|
||||
Thread InvokeThread = new Thread(new ThreadStart(OpenLoadImage));
|
||||
InvokeThread.SetApartmentState(ApartmentState.STA);
|
||||
InvokeThread.Start();
|
||||
InvokeThread.Join();
|
||||
}
|
||||
|
||||
private void OpenLoadImage()
|
||||
{
|
||||
ImageFilePath = "";
|
||||
OpenFileDialog ofd = new OpenFileDialog();
|
||||
if (ofd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
ImageFilePath = ofd.FileName;
|
||||
LoadImage((Bitmap)Bitmap.FromFile(ImageFilePath));
|
||||
}
|
||||
}
|
||||
|
||||
private void tsBtnSaveImage_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MAP == null)
|
||||
return;
|
||||
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = "JPG文件|*.jpg|BMP文件|*.bmp";
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string filePath = sfd.FileName;
|
||||
if (filePath.EndsWith("bmp"))
|
||||
{
|
||||
MAP.Save(filePath, ImageFormat.Bmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
MAP.Save(filePath, ImageFormat.Jpeg);
|
||||
}
|
||||
MessageBox.Show("图片保存成功!");
|
||||
}
|
||||
}
|
||||
|
||||
private void tsBtnSaveImageWithElements_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (MAP == null)
|
||||
return;
|
||||
|
||||
SaveFileDialog sfd = new SaveFileDialog();
|
||||
sfd.Filter = "JPG文件|*.jpg|BMP文件|*.bmp";
|
||||
if (sfd.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
string filePath = sfd.FileName;
|
||||
|
||||
Bitmap bmp = new Bitmap(MAP.Width, MAP.Height, PixelFormat.Format32bppArgb);
|
||||
//Bitmap bmp = new Bitmap(MAP.Width, MAP.Height, MAP.PixelFormat);
|
||||
//Bitmap bmp = new Bitmap(MAP.Width, MAP.Height);
|
||||
using (Graphics g = Graphics.FromImage(bmp))
|
||||
{
|
||||
g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
|
||||
g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||
g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
|
||||
g.DrawImage(MAP, 0, 0);
|
||||
|
||||
for (int i = 0; i < Elements.Count; i++)
|
||||
{
|
||||
var ele = Elements[i];
|
||||
if (ele.IsEnabled)
|
||||
ele.Draw(g);
|
||||
}
|
||||
}
|
||||
|
||||
if (filePath.EndsWith("bmp"))
|
||||
{
|
||||
bmp.Save(filePath, ImageFormat.Bmp);
|
||||
}
|
||||
else
|
||||
{
|
||||
bmp.Save(filePath, ImageFormat.Jpeg);
|
||||
}
|
||||
MessageBox.Show("带基元图片保存成功!");
|
||||
}
|
||||
}
|
||||
|
||||
private void tsBtnMapSize_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetMapSize();
|
||||
}
|
||||
|
||||
private void tsBtnModeNormal_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
var btn = sender as ToolStripButton;
|
||||
if (btn.Checked)
|
||||
{
|
||||
btn.BackColor = SystemColors.ActiveCaption;
|
||||
|
||||
foreach (ToolStripItem c in tsTool.Items)
|
||||
{
|
||||
if (c is ToolStripButton)
|
||||
{
|
||||
if (c.Name.StartsWith("tsBtnMode") && c.Name != btn.Name)
|
||||
{
|
||||
var temp = c as ToolStripButton;
|
||||
temp.Checked = false;
|
||||
temp.BackColor = SystemColors.Control;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (btn.Name)
|
||||
{
|
||||
case "tsBtnModeNormal":
|
||||
MouseState = MouseState.Normal;
|
||||
break;
|
||||
case "tsBtnModeSelection":
|
||||
MouseState = MouseState.SelectionZone;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void tsBtnScreenSize_Click(object sender, EventArgs e)
|
||||
{
|
||||
SetScreenSize();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 基元工具条
|
||||
//private void LoadElementTools()
|
||||
//{
|
||||
// var eleDict = ElementFactory.GetAllElementsInfo();
|
||||
|
||||
// foreach (KeyValuePair<ElementAttribute, Type> pair in eleDict)
|
||||
// {
|
||||
|
||||
// }
|
||||
//}
|
||||
|
||||
public void SetNewROIType(IShapeElement element)
|
||||
{
|
||||
cvImage.DrawTemplate = element;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 事件
|
||||
public event Action<IShapeElement> OnElementChangedHandle;
|
||||
public event Action OnImageChanged;
|
||||
#endregion
|
||||
|
||||
#region 工具栏显示/隐藏右键菜单
|
||||
private void tsmiShowToolBar_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
//IsShowToolBar = tsmiShowToolBar.Checked;
|
||||
}
|
||||
|
||||
private void tsmiShowStatusBar_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
//IsShowStatusBar = tsmiShowStatusBar.Checked;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
120
DH.UI.Model.Winform/Canvas.resx
Normal file
120
DH.UI.Model.Winform/Canvas.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>
|
||||
33
DH.UI.Model.Winform/CanvasImage.Designer.cs
generated
Normal file
33
DH.UI.Model.Winform/CanvasImage.Designer.cs
generated
Normal file
@@ -0,0 +1,33 @@
|
||||
namespace DH.UI.Model.Winform
|
||||
{
|
||||
partial class CanvasImage
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要修改
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// CanvasImage
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.Name = "CanvasImage";
|
||||
this.Size = new System.Drawing.Size(575, 472);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
943
DH.UI.Model.Winform/CanvasImage.cs
Normal file
943
DH.UI.Model.Winform/CanvasImage.cs
Normal file
@@ -0,0 +1,943 @@
|
||||
|
||||
using DH.Commons.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using static DH.Commons.Enums.EnumHelper;
|
||||
|
||||
|
||||
namespace DH.UI.Model.Winform
|
||||
{
|
||||
public partial class CanvasImage : UserControl
|
||||
{
|
||||
public CanvasImage()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
DoubleBuffered = true;
|
||||
SetStyle(ControlStyles.OptimizedDoubleBuffer |
|
||||
ControlStyles.ResizeRedraw |
|
||||
ControlStyles.AllPaintingInWmPaint, true);
|
||||
|
||||
MouseWheel += Canvas_MouseWheel;
|
||||
KeyDown += OnCanvasKeyDown;
|
||||
KeyPress += OnCanvasKeyPressed;
|
||||
MouseDoubleClick += Canvas_MouseDoubleClick;
|
||||
MouseDown += Canvas_MouseDown;
|
||||
MouseMove += Canvas_MouseMove;
|
||||
MouseUp += Canvas_MouseUp;
|
||||
|
||||
// EventRouter.ChangeElementsMouseState -= OnElementChangeMouseState;
|
||||
// EventRouter.ChangeElementsMouseState += OnElementChangeMouseState;
|
||||
|
||||
//Elements.CollectionChanged += Elements_CollectionChanged;
|
||||
}
|
||||
|
||||
private void Elements_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
|
||||
{
|
||||
//this.Invoke(new Action(() =>
|
||||
//{
|
||||
// this.Invalidate();
|
||||
//}));
|
||||
}
|
||||
|
||||
#region Event
|
||||
public Action<MouseState> OnMouseStateChanged;
|
||||
public Action<IShapeElement> DrawTemplateChanged = null;
|
||||
public Action<Point, PointF, string> OnMouseLocationUpdated;
|
||||
#endregion
|
||||
|
||||
private MouseState mouseState = MouseState.Normal;
|
||||
public MouseState MouseState
|
||||
{
|
||||
get
|
||||
{
|
||||
return mouseState;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (mouseState != value)
|
||||
{
|
||||
mouseState = value;
|
||||
|
||||
// OnMouseStateChanged?.BeginInvoke(value, null, null);
|
||||
Task.Run(() => OnMouseStateChanged.Invoke(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#region 属性和字段
|
||||
|
||||
//private Bitmap map = new Bitmap(10, 10);
|
||||
//public Bitmap MAP
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// _mapLoadHandler.WaitOne();
|
||||
// return map;
|
||||
// }
|
||||
// set
|
||||
// {
|
||||
// map = value;
|
||||
// }
|
||||
//}
|
||||
|
||||
public Bitmap MAP { get; set; } = new Bitmap(10, 10);
|
||||
|
||||
public Matrix Matrix { get; set; } = new Matrix();
|
||||
public ObservableCollection<IShapeElement> Elements { get; set; } = new ObservableCollection<IShapeElement>();
|
||||
|
||||
RectangleF _selectionRect = new RectangleF();
|
||||
#endregion
|
||||
|
||||
#region 重绘
|
||||
protected override void OnPaint(PaintEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
//lock (_mapLoadLock)
|
||||
//{ }
|
||||
|
||||
Rectangle rect = ClientRectangle;
|
||||
Graphics originG = e.Graphics;
|
||||
BufferedGraphicsContext currentContext = BufferedGraphicsManager.Current;
|
||||
BufferedGraphics myBuffer = currentContext.Allocate(originG, rect);
|
||||
Graphics g = myBuffer.Graphics;
|
||||
g.SmoothingMode = SmoothingMode.HighSpeed;
|
||||
g.PixelOffsetMode = PixelOffsetMode.HighSpeed;
|
||||
g.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
g.Clear(BackColor);
|
||||
|
||||
g.MultiplyTransform(Matrix);
|
||||
|
||||
if (MAP != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
g.DrawImage(MAP, 0, 0, MAP.Width, MAP.Height);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g.Clear(BackColor);
|
||||
}
|
||||
|
||||
DrawTemplate?.Draw(g);
|
||||
foreach (IShapeElement ele in Elements)
|
||||
{
|
||||
if (ele.IsEnabled && ele.IsShowing)
|
||||
{
|
||||
ele.Draw(g);
|
||||
}
|
||||
}
|
||||
|
||||
#region Grid
|
||||
if (MAP != null)
|
||||
{
|
||||
if (ShowGrid)
|
||||
{
|
||||
int baseX = MAP.Width / 2;
|
||||
int baseY = MAP.Height / 2;
|
||||
|
||||
Point[] xPoint = new Point[] { new Point(0, baseY), new Point(MAP.Width, baseY) };
|
||||
Point[] yPoint = new Point[] { new Point(baseX, 0), new Point(baseX, MAP.Height) };
|
||||
|
||||
g.DrawLine(new Pen(Pen_Grid.Color, 5.0f), xPoint[0], xPoint[1]);
|
||||
g.DrawLine(new Pen(Pen_Grid.Color, 5.0f), yPoint[0], yPoint[1]);
|
||||
|
||||
if (GridValue > 0)
|
||||
{
|
||||
int stepX = MAP.Width / 2 / (GridValue * MAP.Width / 2 / _minGridStep / 10);
|
||||
int stepY = MAP.Height / 2 / (GridValue * MAP.Height / 2 / _minGridStep / 10);
|
||||
|
||||
//int stepX = _minGridStep + (10 - GridValue) * (MAP.Width / 2 - _minGridStep) / 10;
|
||||
//int stepY = _minGridStep + (10 - GridValue) * (MAP.Height / 2 - _minGridStep) / 10;
|
||||
|
||||
int yPositive = baseY;
|
||||
do
|
||||
{
|
||||
xPoint = new Point[] { new Point(0, yPositive), new Point(MAP.Width, yPositive) };
|
||||
g.DrawLine(Pen_Grid, xPoint[0], xPoint[1]);
|
||||
yPositive -= stepY;
|
||||
} while (yPositive > 0);
|
||||
|
||||
int yNegative = baseY;
|
||||
do
|
||||
{
|
||||
xPoint = new Point[] { new Point(0, yNegative), new Point(MAP.Width, yNegative) };
|
||||
g.DrawLine(Pen_Grid, xPoint[0], xPoint[1]);
|
||||
yNegative += stepY;
|
||||
} while (yNegative < MAP.Height);
|
||||
|
||||
int xPositive = baseX;
|
||||
do
|
||||
{
|
||||
yPoint = new Point[] { new Point(xPositive, 0), new Point(xPositive, MAP.Height) };
|
||||
g.DrawLine(Pen_Grid, yPoint[0], yPoint[1]);
|
||||
xPositive -= stepX;
|
||||
} while (xPositive > 0);
|
||||
|
||||
int xNegative = baseX;
|
||||
do
|
||||
{
|
||||
yPoint = new Point[] { new Point(xNegative, 0), new Point(xNegative, MAP.Height) };
|
||||
g.DrawLine(Pen_Grid, yPoint[0], yPoint[1]);
|
||||
xNegative += stepX;
|
||||
} while (xNegative < MAP.Width);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
if (MouseState == MouseState.SelectionZoneDoing)
|
||||
{
|
||||
g.DrawRectangle(Pens.AliceBlue, _selectionRect.X, _selectionRect.Y, _selectionRect.Width, _selectionRect.Height);
|
||||
g.FillRectangle(new SolidBrush(Color.FromArgb(40, 0, 0, 255)), _selectionRect);
|
||||
}
|
||||
|
||||
myBuffer.Render(originG);
|
||||
g.Dispose();
|
||||
myBuffer.Dispose();//释放资源
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
private void halfTransparent()
|
||||
{
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 绘制类型
|
||||
private IShapeElement drawTemplate = null;
|
||||
public IShapeElement DrawTemplate
|
||||
{
|
||||
get
|
||||
{
|
||||
return drawTemplate;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (drawTemplate != value)
|
||||
{
|
||||
|
||||
drawTemplate = value;
|
||||
|
||||
//DrawTemplateChanged?.BeginInvoke(value, null, null);
|
||||
Task.Run(() => DrawTemplateChanged.Invoke(value));
|
||||
|
||||
if (value == null)
|
||||
{
|
||||
MouseState = MouseState.Normal;
|
||||
return;
|
||||
}
|
||||
|
||||
MouseState = MouseState.New;
|
||||
|
||||
var existed = Elements.FirstOrDefault(e => e.ID == value.ID);
|
||||
if (existed != null)
|
||||
{
|
||||
Elements.Remove(existed);
|
||||
}
|
||||
|
||||
//if (DrawTemplate != null)
|
||||
//{
|
||||
// DrawTemplate.OnDrawDone += OnElementDrawDone;
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string currentElementId = "";
|
||||
string CurrentElementId
|
||||
{
|
||||
get
|
||||
{
|
||||
return currentElementId;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (currentElementId != value)
|
||||
{
|
||||
currentElementId = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnElementDrawDone(IShapeElement ele)
|
||||
{
|
||||
//int maxIndex = 1;
|
||||
//if (Elements.Count > 0)
|
||||
//{
|
||||
// maxIndex = Elements.Max(u => u.Index) + 1;
|
||||
//}
|
||||
//ele.Index = maxIndex;
|
||||
//ele.Name = maxIndex.ToString();
|
||||
|
||||
//#region 获取基元的设备属性,目前包括运动坐标和相机参数
|
||||
//SetElementDevicePara?.Invoke(ele);
|
||||
//#endregion
|
||||
|
||||
//Elements.Add(ele);
|
||||
//DrawTemplate = DrawTemplate?.Clone() as IShapeElement;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 状态变换
|
||||
private void OnElementChangeMouseState(IShapeElement ele, ElementState preState, ElementState curState)
|
||||
{
|
||||
if (curState != ElementState.Normal)
|
||||
{
|
||||
switch (curState)
|
||||
{
|
||||
case ElementState.New:
|
||||
MouseState = MouseState.New;
|
||||
break;
|
||||
case ElementState.Selected:
|
||||
CurrentElementId = ele.ID;
|
||||
Cursor = Cursors.Default;
|
||||
break;
|
||||
case ElementState.Moving:
|
||||
MouseState = MouseState.MoveElement;
|
||||
Cursor = Cursors.NoMove2D;
|
||||
break;
|
||||
case ElementState.Editing:
|
||||
MouseState = MouseState.Editing;
|
||||
Cursor = Cursors.Hand;
|
||||
break;
|
||||
case ElementState.MouseInSide:
|
||||
MouseState = MouseState.InSideElement;
|
||||
break;
|
||||
case ElementState.MouseHover:
|
||||
MouseState = MouseState.HoverElement;
|
||||
break;
|
||||
case ElementState.CanStretchLeft:
|
||||
Cursor = Cursors.SizeWE;
|
||||
break;
|
||||
case ElementState.StretchingLeft:
|
||||
MouseState = MouseState.StretchingLeft;
|
||||
Cursor = Cursors.SizeWE;
|
||||
break;
|
||||
case ElementState.CanStretchBottom:
|
||||
Cursor = Cursors.SizeNS;
|
||||
break;
|
||||
case ElementState.StretchingBottom:
|
||||
MouseState = MouseState.StretchingBottom;
|
||||
Cursor = Cursors.SizeNS;
|
||||
break;
|
||||
case ElementState.CanStretchRight:
|
||||
Cursor = Cursors.SizeWE;
|
||||
break;
|
||||
case ElementState.StretchingRight:
|
||||
MouseState = MouseState.StretchingRight;
|
||||
Cursor = Cursors.SizeWE;
|
||||
break;
|
||||
case ElementState.CanStretchTop:
|
||||
Cursor = Cursors.SizeNS;
|
||||
break;
|
||||
case ElementState.StretchingTop:
|
||||
MouseState = MouseState.StretchingTop;
|
||||
Cursor = Cursors.SizeNS;
|
||||
break;
|
||||
|
||||
case ElementState.CanStretchLeftLowerCorner:
|
||||
Cursor = Cursors.SizeNESW;
|
||||
break;
|
||||
case ElementState.StretchingLeftLowerCorner:
|
||||
MouseState = MouseState.StretchingLeftLowerCorner;
|
||||
Cursor = Cursors.SizeNESW;
|
||||
break;
|
||||
case ElementState.CanStretchLeftUpperCorner:
|
||||
Cursor = Cursors.SizeNWSE;
|
||||
break;
|
||||
case ElementState.StretchingLeftUpperCorner:
|
||||
MouseState = MouseState.StretchingLeftUpperCorner;
|
||||
Cursor = Cursors.SizeNWSE;
|
||||
break;
|
||||
case ElementState.CanStretchRightLowerCorner:
|
||||
Cursor = Cursors.SizeNWSE;
|
||||
break;
|
||||
case ElementState.StretchingRightLowerCorner:
|
||||
MouseState = MouseState.StretchingRightLowerCorner;
|
||||
Cursor = Cursors.SizeNWSE;
|
||||
break;
|
||||
case ElementState.CanStretchRightUpperCorner:
|
||||
Cursor = Cursors.SizeNESW;
|
||||
break;
|
||||
case ElementState.StretchingRightUpperCorner:
|
||||
MouseState = MouseState.StretchingRightUpperCorner;
|
||||
Cursor = Cursors.SizeNESW;
|
||||
break;
|
||||
default:
|
||||
//MouseState = MouseState.Normal;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Elements.All(e => e.State == ElementState.Normal))
|
||||
{
|
||||
CurrentElementId = null;
|
||||
|
||||
if (preState == ElementState.Selected)
|
||||
{
|
||||
DrawTemplate = null;
|
||||
}
|
||||
else if (DrawTemplate != null)
|
||||
{
|
||||
MouseState = MouseState.New;
|
||||
return;
|
||||
}
|
||||
|
||||
//MouseState = MouseState.Normal;
|
||||
}
|
||||
}
|
||||
|
||||
this.Invalidate();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 鼠标动作
|
||||
private void Canvas_MouseWheel(object sender, MouseEventArgs e)
|
||||
{
|
||||
PointF prePoint = ToMapPoint(e.Location);
|
||||
|
||||
//先缩放
|
||||
if (e.Delta > 0)
|
||||
{
|
||||
Matrix.Scale((float)1.1, (float)1.1);
|
||||
}
|
||||
else
|
||||
{
|
||||
Matrix.Scale((float)0.9, (float)0.9);
|
||||
}
|
||||
|
||||
PointF afterPoint = ToMapPoint(e.Location);
|
||||
|
||||
//后平移
|
||||
Matrix.Translate(afterPoint.X - prePoint.X, afterPoint.Y - prePoint.Y);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
PointF startPoint, currentPoint;
|
||||
bool _isMouseBtnPressing = false;
|
||||
|
||||
private void Canvas_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
PointF p = ToMapPoint(e.Location);
|
||||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
_isMouseBtnPressing = true;
|
||||
|
||||
switch (MouseState)
|
||||
{
|
||||
case MouseState.Normal:
|
||||
startPoint = e.Location;
|
||||
break;
|
||||
case MouseState.StretchingLeft:
|
||||
break;
|
||||
case MouseState.StretchingRight:
|
||||
break;
|
||||
case MouseState.StretchingTop:
|
||||
break;
|
||||
case MouseState.StretchingBottom:
|
||||
break;
|
||||
case MouseState.MoveElement:
|
||||
break;
|
||||
case MouseState.HoverElement:
|
||||
case MouseState.InSideElement:
|
||||
case MouseState.New:
|
||||
DrawTemplate?.OnMouseDown(p);
|
||||
break;
|
||||
case MouseState.Editing:
|
||||
break;
|
||||
case MouseState.SelectionZone:
|
||||
MouseState = MouseState.SelectionZoneDoing;
|
||||
startPoint = p;
|
||||
break;
|
||||
}
|
||||
|
||||
foreach (IShapeElement ele in Elements)
|
||||
{
|
||||
ele.OnMouseDown(p);
|
||||
}
|
||||
}
|
||||
else if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
if (DrawTemplate != null && DrawTemplate.State == ElementState.New && DrawTemplate.IsCreatedDone())
|
||||
{
|
||||
IShapeElement ele = DrawTemplate.Clone() as IShapeElement;
|
||||
ele.State = ElementState.Normal;
|
||||
Elements.Add(ele);
|
||||
|
||||
// (DrawTemplate as ElementBase).Initial();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Canvas_MouseUp(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button != MouseButtons.Left)
|
||||
return;
|
||||
|
||||
_isMouseBtnPressing = false;
|
||||
switch (MouseState)
|
||||
{
|
||||
case MouseState.Normal:
|
||||
break;
|
||||
case MouseState.HoverElement:
|
||||
break;
|
||||
case MouseState.InSideElement:
|
||||
break;
|
||||
case MouseState.StretchingLeft:
|
||||
break;
|
||||
case MouseState.StretchingRight:
|
||||
break;
|
||||
case MouseState.StretchingTop:
|
||||
break;
|
||||
case MouseState.StretchingBottom:
|
||||
break;
|
||||
case MouseState.MoveElement:
|
||||
//MouseState = MouseState.SelectedElement;
|
||||
break;
|
||||
case MouseState.New:
|
||||
break;
|
||||
case MouseState.Editing:
|
||||
break;
|
||||
case MouseState.MovingAll:
|
||||
MouseState = MouseState.Normal;
|
||||
break;
|
||||
case MouseState.SelectionZone:
|
||||
break;
|
||||
case MouseState.SelectionZoneDoing:
|
||||
MouseState = MouseState.SelectionZone;
|
||||
|
||||
foreach (IShapeElement ele in Elements)
|
||||
{
|
||||
ele.State = ElementState.Normal;
|
||||
if (ele.IsIntersect(_selectionRect))
|
||||
{
|
||||
ele.State = ElementState.Selected;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Cursor = Cursors.Default;
|
||||
|
||||
if (MouseState != MouseState.SelectionZone)
|
||||
{
|
||||
PointF p = ToMapPoint(e.Location);
|
||||
DrawTemplate?.OnMouseUp(p);
|
||||
foreach (IShapeElement ele in Elements)
|
||||
{
|
||||
ele.OnMouseUp(p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Canvas_MouseMove(object sender, MouseEventArgs e)
|
||||
{
|
||||
PointF p = ToMapPoint(e.Location);
|
||||
|
||||
switch (MouseState)
|
||||
{
|
||||
case MouseState.Normal:
|
||||
{
|
||||
if (_isMouseBtnPressing)
|
||||
{
|
||||
currentPoint = e.Location;
|
||||
PointF p1 = ToMapPoint(startPoint);
|
||||
PointF p2 = ToMapPoint(currentPoint);
|
||||
Matrix.Translate(p2.X - p1.X, p2.Y - p1.Y);
|
||||
startPoint = e.Location;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case MouseState.StretchingLeft:
|
||||
break;
|
||||
case MouseState.StretchingRight:
|
||||
break;
|
||||
case MouseState.StretchingTop:
|
||||
break;
|
||||
case MouseState.StretchingBottom:
|
||||
break;
|
||||
case MouseState.MoveElement:
|
||||
break;
|
||||
case MouseState.HoverElement:
|
||||
case MouseState.InSideElement:
|
||||
case MouseState.New:
|
||||
DrawTemplate?.OnMouseMove(p);
|
||||
break;
|
||||
case MouseState.Editing:
|
||||
break;
|
||||
case MouseState.MovingAll:
|
||||
break;
|
||||
case MouseState.SelectionZoneDoing:
|
||||
{
|
||||
currentPoint = p;
|
||||
|
||||
float[] x2 = new float[2] { startPoint.X, currentPoint.X };
|
||||
float[] y2 = new float[2] { startPoint.Y, currentPoint.Y };
|
||||
|
||||
float xMin = x2.Min();
|
||||
float xMax = x2.Max();
|
||||
float yMin = y2.Min();
|
||||
float yMax = y2.Max();
|
||||
|
||||
_selectionRect = new RectangleF(xMin, yMin, xMax - xMin, yMax - yMin);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
PointF mapPoint = ToMapPoint(e.Location);
|
||||
Color color = Color.Transparent;
|
||||
if (MAP != null && mapPoint.X > 0 && mapPoint.X < MAP.Width && mapPoint.Y > 0 && mapPoint.Y < MAP.Height)
|
||||
{
|
||||
color = MAP.GetPixel((int)mapPoint.X, (int)mapPoint.Y);
|
||||
}
|
||||
|
||||
// OnMouseLocationUpdated?.BeginInvoke(e.Location, mapPoint, color.Name, null, null);
|
||||
Task.Run(() => OnMouseLocationUpdated?.Invoke(e.Location, mapPoint, color.Name));
|
||||
|
||||
if (MouseState != MouseState.SelectionZoneDoing)
|
||||
{
|
||||
Elements.ToList().ForEach(ele => ele?.OnMouseMove(p));
|
||||
}
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
private void Canvas_MouseDoubleClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
PointF p = ToMapPoint(e.Location);
|
||||
|
||||
if (e.Button == MouseButtons.Left)
|
||||
{
|
||||
switch (MouseState)
|
||||
{
|
||||
//case MouseState.SelectedElement:
|
||||
case MouseState.HoverElement:
|
||||
case MouseState.InSideElement:
|
||||
case MouseState.MoveElement:
|
||||
case MouseState.Normal:
|
||||
//Elements.ForEach(ele =>
|
||||
foreach (IShapeElement ele in Elements)
|
||||
{
|
||||
ele.OnMouseDoubleClick(p);
|
||||
}
|
||||
//);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//if (MouseState == MouseState.SelectedElement)
|
||||
{
|
||||
MouseState = MouseState.Normal;
|
||||
|
||||
//Elements.ForEach(ele =>
|
||||
foreach (IShapeElement ele in Elements)
|
||||
{
|
||||
ele.State = ElementState.Normal;
|
||||
}
|
||||
//);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 图片操作
|
||||
bool _firstLoad = true;
|
||||
object _mapLoadLock = new object();
|
||||
ManualResetEvent _mapLoadHandler = new ManualResetEvent(true);
|
||||
ManualResetEvent _mapUsingHandler = new ManualResetEvent(false);
|
||||
|
||||
/// <summary>
|
||||
/// 载入图片
|
||||
/// </summary>
|
||||
/// <param name="bitmap"></param>
|
||||
public void LoadImage(Bitmap bitmap)
|
||||
{
|
||||
if (bitmap == null)
|
||||
return;
|
||||
|
||||
////lock (_mapLoadLock)
|
||||
////_mapUsingHandler.WaitOne();
|
||||
//_mapLoadHandler.Reset();
|
||||
//{
|
||||
// map?.Dispose();
|
||||
// map = null;
|
||||
// map = bitmap;
|
||||
//}
|
||||
//_mapLoadHandler.Set();
|
||||
|
||||
MAP = bitmap;
|
||||
|
||||
if (_firstLoad)
|
||||
{
|
||||
SetScreenSize();
|
||||
_firstLoad = false;
|
||||
}
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
public void Clear()
|
||||
{
|
||||
MAP = null;
|
||||
Elements.Clear();
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置图片为原始尺寸
|
||||
/// </summary>
|
||||
public void SetMapSize()
|
||||
{
|
||||
Matrix = new Matrix();
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 设置图片为适配尺寸
|
||||
/// </summary>
|
||||
public void SetScreenSize()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (MAP == null)
|
||||
return;
|
||||
|
||||
Matrix = new Matrix();
|
||||
|
||||
//先缩放
|
||||
List<float> ratios = new List<float>() { MAP.Width / (float)Width, MAP.Height / (float)Height };
|
||||
float ratio = 1 / ratios.Max();
|
||||
Matrix.Scale(ratio, ratio);
|
||||
|
||||
//再平移
|
||||
//将plMain的中心转换为图片坐标
|
||||
PointF screenCenter = new PointF(Width / 2.0f, Height / 2.0f);
|
||||
PointF mapPoint = ToMapPoint(screenCenter);
|
||||
|
||||
//目标坐标减去当前坐标
|
||||
Matrix.Translate(-MAP.Width / 2.0f + mapPoint.X, -MAP.Height / 2.0f + mapPoint.Y);
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//Trace.TraceError(ex.GetExceptionMessage());
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 私有方法
|
||||
//private void DisplayMouseLocation(Point location)
|
||||
//{
|
||||
// string screenPoint = string.Format("屏幕坐标X:{0};Y:{1}", location.X, location.Y);
|
||||
|
||||
// Point mapPoint = ToMapPoint(location);
|
||||
// string mapPointStr = string.Format("图片坐标X:{0};Y:{1}", mapPoint.X, mapPoint.Y);
|
||||
|
||||
// tsslLocation.Text = screenPoint + " " + mapPointStr;
|
||||
//}
|
||||
|
||||
private PointF ToMapPoint(PointF p)
|
||||
{
|
||||
PointF[] ps = new PointF[] { p };
|
||||
Matrix invertMatrix = Matrix.Clone();
|
||||
invertMatrix.Invert();
|
||||
invertMatrix.TransformPoints(ps);
|
||||
|
||||
return ps[0];
|
||||
}
|
||||
|
||||
private Point ToScreenPoint(Point p)
|
||||
{
|
||||
Point[] ps = new Point[] { p };
|
||||
Matrix.TransformPoints(ps);
|
||||
|
||||
return ps[0];
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 按键操作
|
||||
public void OnCanvasKeyPressed(object sender, KeyPressEventArgs e)
|
||||
{
|
||||
//if (e.KeyChar == 27) //Esc
|
||||
//{
|
||||
// //if (MouseState == MouseState.SelectedElement)
|
||||
// {
|
||||
// MouseState = MouseState.Normal;
|
||||
|
||||
// //Elements.ForEach(ele =>
|
||||
// foreach (IShapeElement ele in Elements)
|
||||
// {
|
||||
// ele.State = ElementState.Normal;
|
||||
// }
|
||||
// //);
|
||||
// }
|
||||
//}
|
||||
|
||||
//Invalidate();
|
||||
}
|
||||
|
||||
public void OnCanvasKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Delete) //delete键
|
||||
{
|
||||
Elements.Remove(Elements.FirstOrDefault(u => u.ID == CurrentElementId));
|
||||
}
|
||||
|
||||
if (e.KeyData == Keys.Escape) //Esc
|
||||
{
|
||||
if (DrawTemplate != null /*&& (DrawTemplate as ElementBase).CreatePoints.Count > 0*/)
|
||||
{
|
||||
DrawTemplate.Initial();
|
||||
}
|
||||
else
|
||||
{
|
||||
DrawTemplate = null;
|
||||
|
||||
if (MouseState != MouseState.Normal)
|
||||
{
|
||||
MouseState = MouseState.Normal;
|
||||
}
|
||||
else
|
||||
{
|
||||
Elements.ToList().ForEach(u => u.State = ElementState.Normal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//if (e.KeyData == Keys.Up)
|
||||
//{
|
||||
// Elements.ToList().ForEach(u =>
|
||||
// {
|
||||
// if (u.State == ElementState.Selected)
|
||||
// {
|
||||
// u.Translate(0, -1);
|
||||
// }
|
||||
// });
|
||||
//}
|
||||
|
||||
//if (e.KeyData == Keys.Down)
|
||||
//{
|
||||
// Elements.ToList().ForEach(u =>
|
||||
// {
|
||||
// if (u.State == ElementState.Selected)
|
||||
// {
|
||||
// u.Translate(0, 1);
|
||||
// }
|
||||
// });
|
||||
//}
|
||||
|
||||
//if (e.KeyData == Keys.Left)
|
||||
//{
|
||||
// Elements.ToList().ForEach(u =>
|
||||
// {
|
||||
// if (u.State == ElementState.Selected)
|
||||
// {
|
||||
// u.Translate(-1, 0);
|
||||
// }
|
||||
// });
|
||||
//}
|
||||
|
||||
//if (e.KeyData == Keys.Right)
|
||||
//{
|
||||
// Elements.ToList().ForEach(u =>
|
||||
// {
|
||||
// if (u.State == ElementState.Selected)
|
||||
// {
|
||||
// u.Translate(1, 0);
|
||||
// }
|
||||
// });
|
||||
//}
|
||||
|
||||
Invalidate();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 基元的设备属性 运动设置和相机设置
|
||||
public Action<IShapeElement> SetElementDevicePara;
|
||||
|
||||
public Action<IShapeElement> SetDeviceByElement;
|
||||
#endregion
|
||||
|
||||
#region Grid
|
||||
private bool showGrid = false;
|
||||
public bool ShowGrid
|
||||
{
|
||||
get => showGrid;
|
||||
set
|
||||
{
|
||||
showGrid = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private int gridValue = 0;
|
||||
public int GridValue
|
||||
{
|
||||
get => gridValue;
|
||||
set
|
||||
{
|
||||
gridValue = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private Pen penGrid = new Pen(Color.FromArgb(120, Color.Red), 1.0f);
|
||||
public Pen Pen_Grid
|
||||
{
|
||||
get => penGrid;
|
||||
set
|
||||
{
|
||||
penGrid = value;
|
||||
Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
readonly int _minGridStep = 10;
|
||||
#endregion
|
||||
|
||||
#region Dispose
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
MAP?.Dispose();
|
||||
Matrix?.Dispose();
|
||||
penGrid?.Dispose();
|
||||
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
120
DH.UI.Model.Winform/CanvasImage.resx
Normal file
120
DH.UI.Model.Winform/CanvasImage.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>
|
||||
109
DH.UI.Model.Winform/Ctrl/GridCtrl.Designer.cs
generated
Normal file
109
DH.UI.Model.Winform/Ctrl/GridCtrl.Designer.cs
generated
Normal file
@@ -0,0 +1,109 @@
|
||||
namespace DH.UI.Model.Winform
|
||||
{
|
||||
partial class GridCtrl
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要修改
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.chkShowGrid = new System.Windows.Forms.CheckBox();
|
||||
this.tbGridValue = new System.Windows.Forms.TrackBar();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.colorDialog1 = new System.Windows.Forms.ColorDialog();
|
||||
this.btnColor = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbGridValue)).BeginInit();
|
||||
this.panel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// chkShowGrid
|
||||
//
|
||||
this.chkShowGrid.Appearance = System.Windows.Forms.Appearance.Button;
|
||||
//this.chkShowGrid.BackgroundImage = global::XKRS.UI.Model.Winform.Properties.Resources.grid;
|
||||
this.chkShowGrid.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.chkShowGrid.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.chkShowGrid.Location = new System.Drawing.Point(0, 0);
|
||||
this.chkShowGrid.Name = "chkShowGrid";
|
||||
this.chkShowGrid.Size = new System.Drawing.Size(32, 30);
|
||||
this.chkShowGrid.TabIndex = 0;
|
||||
this.chkShowGrid.UseVisualStyleBackColor = true;
|
||||
this.chkShowGrid.CheckedChanged += new System.EventHandler(this.chkShowGrid_CheckedChanged);
|
||||
//
|
||||
// tbGridValue
|
||||
//
|
||||
this.tbGridValue.AutoSize = false;
|
||||
this.tbGridValue.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.tbGridValue.Location = new System.Drawing.Point(0, 21);
|
||||
this.tbGridValue.Name = "tbGridValue";
|
||||
this.tbGridValue.Orientation = System.Windows.Forms.Orientation.Vertical;
|
||||
this.tbGridValue.Size = new System.Drawing.Size(32, 121);
|
||||
this.tbGridValue.TabIndex = 1;
|
||||
this.tbGridValue.TickStyle = System.Windows.Forms.TickStyle.Both;
|
||||
this.tbGridValue.ValueChanged += new System.EventHandler(this.tbGridValue_ValueChanged);
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.panel1.Controls.Add(this.chkShowGrid);
|
||||
this.panel1.Controls.Add(this.tbGridValue);
|
||||
this.panel1.Location = new System.Drawing.Point(1, 1);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(32, 142);
|
||||
this.panel1.TabIndex = 2;
|
||||
//
|
||||
// btnColor
|
||||
//
|
||||
this.btnColor.BackColor = System.Drawing.Color.Red;
|
||||
this.btnColor.Location = new System.Drawing.Point(4, 150);
|
||||
this.btnColor.Name = "btnColor";
|
||||
this.btnColor.Size = new System.Drawing.Size(25, 23);
|
||||
this.btnColor.TabIndex = 3;
|
||||
this.btnColor.Text = " ";
|
||||
this.btnColor.UseVisualStyleBackColor = false;
|
||||
this.btnColor.Click += new System.EventHandler(this.btnColor_Click);
|
||||
//
|
||||
// GridCtrl
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.Controls.Add(this.btnColor);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134)));
|
||||
this.Name = "GridCtrl";
|
||||
this.Size = new System.Drawing.Size(32, 192);
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbGridValue)).EndInit();
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.CheckBox chkShowGrid;
|
||||
private System.Windows.Forms.TrackBar tbGridValue;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.ColorDialog colorDialog1;
|
||||
private System.Windows.Forms.Button btnColor;
|
||||
}
|
||||
}
|
||||
74
DH.UI.Model.Winform/Ctrl/GridCtrl.cs
Normal file
74
DH.UI.Model.Winform/Ctrl/GridCtrl.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DH.UI.Model.Winform
|
||||
{
|
||||
public partial class GridCtrl : UserControl
|
||||
{
|
||||
public Action<bool> IsShowGridChanged { get; set; }
|
||||
|
||||
public Action<int> GridValueChanged { get; set; }
|
||||
|
||||
public Action<Color> GridColorChanged { get; set; }
|
||||
|
||||
public GridCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
IsChecked = chkShowGrid.Checked;
|
||||
GridValue = tbGridValue.Value;
|
||||
}
|
||||
|
||||
bool isChecked = false;
|
||||
bool IsChecked
|
||||
{
|
||||
get => isChecked;
|
||||
set
|
||||
{
|
||||
if (isChecked != value)
|
||||
{
|
||||
// IsShowGridChanged?.BeginInvoke(value, null, null);
|
||||
Task.Run(() => IsShowGridChanged.Invoke(value));
|
||||
}
|
||||
|
||||
isChecked = value;
|
||||
}
|
||||
}
|
||||
|
||||
int gridValue = 0;
|
||||
int GridValue
|
||||
{
|
||||
get => gridValue;
|
||||
set
|
||||
{
|
||||
if (gridValue != value)
|
||||
{
|
||||
// GridValueChanged?.BeginInvoke(value, null, null);
|
||||
Task.Run(() => GridValueChanged.Invoke(value));
|
||||
}
|
||||
|
||||
gridValue = value;
|
||||
}
|
||||
}
|
||||
private void chkShowGrid_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
IsChecked = chkShowGrid.Checked;
|
||||
}
|
||||
|
||||
private void tbGridValue_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
GridValue = tbGridValue.Value;
|
||||
}
|
||||
|
||||
private void btnColor_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (colorDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
btnColor.BackColor = colorDialog1.Color;
|
||||
// GridColorChanged?.BeginInvoke(btnColor.BackColor, null, null);
|
||||
Task.Run(() => GridColorChanged.Invoke(btnColor.BackColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
DH.UI.Model.Winform/Ctrl/GridCtrl.resx
Normal file
120
DH.UI.Model.Winform/Ctrl/GridCtrl.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>
|
||||
12
DH.UI.Model.Winform/Ctrl/GridCtrlHost.cs
Normal file
12
DH.UI.Model.Winform/Ctrl/GridCtrlHost.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DH.UI.Model.Winform
|
||||
{
|
||||
public class GridCtrlHost : ToolStripControlHost
|
||||
{
|
||||
public GridCtrlHost(GridCtrl grid) : base(grid)
|
||||
{
|
||||
//Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, 134);
|
||||
}
|
||||
}
|
||||
}
|
||||
78
DH.UI.Model.Winform/Ctrl/IOIndicatorCtrl.Designer.cs
generated
Normal file
78
DH.UI.Model.Winform/Ctrl/IOIndicatorCtrl.Designer.cs
generated
Normal file
@@ -0,0 +1,78 @@
|
||||
namespace DH.UI.Model.Winform
|
||||
{
|
||||
partial class IOIndicatorCtrl
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
plStatus = new Panel();
|
||||
lblDesc = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// plStatus
|
||||
//
|
||||
plStatus.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
plStatus.Location = new Point(0, 0);
|
||||
plStatus.Margin = new Padding(4);
|
||||
plStatus.Name = "plStatus";
|
||||
plStatus.Size = new Size(28, 34);
|
||||
plStatus.TabIndex = 0;
|
||||
plStatus.Paint += plStatus_Paint;
|
||||
plStatus.DoubleClick += plStatus_DoubleClick;
|
||||
//
|
||||
// lblDesc
|
||||
//
|
||||
lblDesc.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
lblDesc.AutoSize = true;
|
||||
lblDesc.Font = new Font("Tahoma", 11F, FontStyle.Regular, GraphicsUnit.World);
|
||||
lblDesc.Location = new Point(36, 11);
|
||||
lblDesc.Margin = new Padding(4, 0, 4, 0);
|
||||
lblDesc.Name = "lblDesc";
|
||||
lblDesc.Size = new Size(31, 13);
|
||||
lblDesc.TabIndex = 1;
|
||||
lblDesc.Text = "XXXX";
|
||||
lblDesc.TextAlign = ContentAlignment.MiddleLeft;
|
||||
lblDesc.DoubleClick += lblDesc_DoubleClick;
|
||||
//
|
||||
// IOIndicatorCtrl
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(lblDesc);
|
||||
Controls.Add(plStatus);
|
||||
Margin = new Padding(4);
|
||||
Name = "IOIndicatorCtrl";
|
||||
Size = new Size(138, 34);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel plStatus;
|
||||
private Label lblDesc;
|
||||
}
|
||||
}
|
||||
126
DH.UI.Model.Winform/Ctrl/IOIndicatorCtrl.cs
Normal file
126
DH.UI.Model.Winform/Ctrl/IOIndicatorCtrl.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DH.UI.Model.Winform
|
||||
{
|
||||
public partial class IOIndicatorCtrl : UserControl
|
||||
{
|
||||
public IOIndicatorCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private bool isON = false;
|
||||
|
||||
public bool IsOn
|
||||
{
|
||||
get => isON;
|
||||
set
|
||||
{
|
||||
bool? temp = isON;
|
||||
isON = value;
|
||||
|
||||
if (temp != isON)
|
||||
{
|
||||
RefreshStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshStatus()
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new Action(() => RefreshStatus()));
|
||||
}
|
||||
else
|
||||
{
|
||||
plStatus.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private string desc = "";
|
||||
public string Desc
|
||||
{
|
||||
get => desc;
|
||||
set
|
||||
{
|
||||
desc = value;
|
||||
|
||||
DisplayDesc();
|
||||
}
|
||||
}
|
||||
|
||||
public int Index { get; set; }
|
||||
|
||||
private void DisplayDesc()
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new Action(() => DisplayDesc()));
|
||||
}
|
||||
else
|
||||
{
|
||||
lblDesc.Text = Desc;
|
||||
}
|
||||
}
|
||||
|
||||
readonly PointF[] regionBlink = new PointF[]
|
||||
{
|
||||
new PointF(5,10),
|
||||
new PointF(10,13),
|
||||
new PointF(12,7),
|
||||
new PointF(10,5)
|
||||
};
|
||||
|
||||
public IOIndicatorCtrl(bool _isOn, string _desc, int index = 0)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
IsOn = _isOn;
|
||||
Desc = _desc;
|
||||
Index = index;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新绘制图标
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void plStatus_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
Panel pl = sender as Panel;
|
||||
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
g.Clear(SystemColors.Control);
|
||||
|
||||
|
||||
if (IsOn)
|
||||
{
|
||||
g.FillEllipse(Brushes.LightGreen, pl.ClientRectangle);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.FillEllipse(Brushes.Gray, pl.ClientRectangle);
|
||||
}
|
||||
|
||||
g.FillPolygon(Brushes.White, regionBlink);
|
||||
|
||||
}
|
||||
|
||||
public event Action<string, bool, int> OnIODoubleClick;
|
||||
|
||||
|
||||
private void lblDesc_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
OnIODoubleClick?.Invoke(Name, IsOn, Index);
|
||||
}
|
||||
|
||||
private void plStatus_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
OnIODoubleClick?.Invoke(Name, IsOn, Index);
|
||||
}
|
||||
}
|
||||
}
|
||||
120
DH.UI.Model.Winform/Ctrl/IOIndicatorCtrl.resx
Normal file
120
DH.UI.Model.Winform/Ctrl/IOIndicatorCtrl.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>
|
||||
48
DH.UI.Model.Winform/DH.UI.Model.Winform.csproj
Normal file
48
DH.UI.Model.Winform/DH.UI.Model.Winform.csproj
Normal file
@@ -0,0 +1,48 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net8.0-windows</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
<BaseOutputPath>..\</BaseOutputPath>
|
||||
<AppendTargetFrameworkToOutputPath>output</AppendTargetFrameworkToOutputPath>
|
||||
<UseWindowsForms>true</UseWindowsForms>
|
||||
<Platforms>AnyCPU;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\DH.Commons\DH.Commons.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Update="Properties\Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Update="Properties\Settings.Designer.cs">
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<None Update="Properties\Settings.settings">
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
199
DH.UI.Model.Winform/Element/CommonHelper.cs
Normal file
199
DH.UI.Model.Winform/Element/CommonHelper.cs
Normal file
@@ -0,0 +1,199 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using static DH.Commons.Enums.EnumHelper;
|
||||
|
||||
|
||||
namespace DH.UI.Model.Winform
|
||||
{
|
||||
//public static class AOIEnumHelper
|
||||
//{
|
||||
// public enum ElementState
|
||||
// {
|
||||
// New = 1,
|
||||
// MouseHover = 2,
|
||||
// MouseInSide = 3,
|
||||
// Selected = 4,
|
||||
// Moving = 5,
|
||||
|
||||
// Normal = 11,
|
||||
|
||||
// Measuring = 21,
|
||||
// MeasureDoneOK = 22,
|
||||
// MeasureDoneNG = 23,
|
||||
// }
|
||||
|
||||
// public enum MouseState
|
||||
// {
|
||||
// Normal = 1,
|
||||
// HoverElement = 2,
|
||||
// InSideElement = 3,
|
||||
|
||||
// StretchingLeft = 11,
|
||||
// StretchingRight = 12,
|
||||
// StretchingUp = 13,
|
||||
// StretchingDown = 14,
|
||||
// MoveElement = 15,
|
||||
|
||||
// New = 21,
|
||||
// Editing = 22,
|
||||
// SelectedElement = 23,
|
||||
|
||||
// MovingAll = 31,
|
||||
|
||||
// SelectionZone = 41,
|
||||
// SelectionZoneDoing = 42,
|
||||
// }
|
||||
|
||||
// public enum RunMode
|
||||
// {
|
||||
// [Description("设置模式")]
|
||||
// SetMode = 0,
|
||||
// [Description("运行模式")]
|
||||
// RunMode = 1,
|
||||
// }
|
||||
//}
|
||||
|
||||
public static class EventRouter
|
||||
{
|
||||
/// <summary>
|
||||
/// ElementBase 基元
|
||||
/// 1st MouseState 初始状态
|
||||
/// 2nd MouseState 变化状态
|
||||
/// </summary>
|
||||
public static event Action<ElementBase, ElementState, ElementState> ChangeElementsMouseState;
|
||||
|
||||
public static void TriggerElementsMouseStateChanged(ElementBase ele, ElementState preState, ElementState curState)
|
||||
{
|
||||
ChangeElementsMouseState?.Invoke(ele, preState, curState);
|
||||
}
|
||||
}
|
||||
|
||||
public class NoticedPoints : List<PointF>
|
||||
{
|
||||
public Action OnItemChanged;
|
||||
|
||||
public NoticedPoints() { }
|
||||
|
||||
public NoticedPoints(List<PointF> points)
|
||||
{
|
||||
AddRange(points);
|
||||
}
|
||||
|
||||
public new PointF this[int index]
|
||||
{
|
||||
get
|
||||
{
|
||||
if (index >= 0 && index < Count)
|
||||
{
|
||||
return base[index];
|
||||
}
|
||||
else
|
||||
{
|
||||
return new Point();
|
||||
}
|
||||
|
||||
}
|
||||
set
|
||||
{
|
||||
if (base[index] != value)
|
||||
{
|
||||
base[index] = value;
|
||||
OnItemChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public new void Add(PointF item)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
base.Add(item);
|
||||
OnItemChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public new void AddRange(IEnumerable<PointF> collection)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
base.AddRange(collection);
|
||||
OnItemChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public new void Clear()
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
base.Clear();
|
||||
OnItemChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public new void Insert(int index, PointF item)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
base.Insert(index, item);
|
||||
OnItemChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public new void InsertRange(int index, IEnumerable<PointF> collection)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
base.InsertRange(index, collection);
|
||||
OnItemChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public new bool Remove(PointF item)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
bool flag = base.Remove(item);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
OnItemChanged?.Invoke();
|
||||
}
|
||||
|
||||
return flag;
|
||||
}
|
||||
}
|
||||
|
||||
public new int RemoveAll(Predicate<PointF> match)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
int i = base.RemoveAll(match);
|
||||
if (i > 0)
|
||||
{
|
||||
OnItemChanged?.Invoke();
|
||||
}
|
||||
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
public new void RemoveAt(int index)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
base.RemoveAt(index);
|
||||
OnItemChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public new void RemoveRange(int index, int count)
|
||||
{
|
||||
lock (this)
|
||||
{
|
||||
base.RemoveRange(index, count);
|
||||
OnItemChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
980
DH.UI.Model.Winform/Element/ElementBase.cs
Normal file
980
DH.UI.Model.Winform/Element/ElementBase.cs
Normal file
@@ -0,0 +1,980 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using System.Text.Json.Serialization;
|
||||
using DH.Commons.Enums;
|
||||
using static DH.Commons.Enums.EnumHelper;
|
||||
|
||||
|
||||
namespace DH.UI.Model.Winform
|
||||
{
|
||||
[Serializable]
|
||||
public abstract class ElementBase : IShapeElement, IEventHandle, ICloneable, IComparable<ElementBase>, IDisposable
|
||||
{
|
||||
#region 常量
|
||||
protected int _mouseIntersectDistance = 4;
|
||||
#endregion
|
||||
|
||||
#region 标识符
|
||||
/// <summary>
|
||||
/// ID,采用GUID
|
||||
/// </summary>
|
||||
[ReadOnly(true)]
|
||||
[Category("\t通用标识")]
|
||||
[Description("GUID")]
|
||||
public virtual string ID { get; set; } = Guid.NewGuid().ToString().ToUpper();
|
||||
|
||||
/// <summary>
|
||||
/// 序号
|
||||
/// </summary>
|
||||
[Category("\t通用标识")]
|
||||
[Description("序号")]
|
||||
public virtual int Index { get; set; } = 0;
|
||||
|
||||
[Browsable(false)]
|
||||
public virtual int GroupIndex { get; set; } = 0;
|
||||
|
||||
private string name = "";
|
||||
/// <summary>
|
||||
/// 名称
|
||||
/// </summary>
|
||||
[Category("\t通用标识")]
|
||||
[Description("名称")]
|
||||
public virtual string Name
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(name))
|
||||
{
|
||||
return GetDisplayText();
|
||||
}
|
||||
else
|
||||
{
|
||||
return name;
|
||||
}
|
||||
}
|
||||
set => name = value;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 启用状态
|
||||
private bool isEnabled = true;
|
||||
|
||||
//[Browsable(false)]
|
||||
public virtual bool IsEnabled
|
||||
{
|
||||
get
|
||||
{
|
||||
return isEnabled;
|
||||
}
|
||||
set
|
||||
{
|
||||
//if (isEnabled != value)
|
||||
//{
|
||||
// isEnabled = value;
|
||||
|
||||
// PropertyChanged?.BeginInvoke(this, new PropertyChangedEventArgs("IsEnabled"), null, null);
|
||||
//}
|
||||
|
||||
Set(ref isEnabled, value);
|
||||
}
|
||||
}
|
||||
|
||||
[Browsable(false)]
|
||||
public virtual bool IsShowing { get; set; } = true;
|
||||
|
||||
private bool showList = true;
|
||||
[Browsable(false)]
|
||||
public virtual bool ShowList
|
||||
{
|
||||
get => showList;
|
||||
set => Set(ref showList, value);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 字段
|
||||
[JsonIgnore]
|
||||
protected PointF _startPoint, _currentPoint;
|
||||
#endregion
|
||||
|
||||
#region 绘图特性
|
||||
[Browsable(false)]
|
||||
public NoticedPoints CreatePoints { get; set; } = new NoticedPoints();
|
||||
|
||||
public virtual bool IsCreatedDone()
|
||||
{
|
||||
return CreatePoints.Count >= 2;
|
||||
}
|
||||
|
||||
//protected Region Region { get; set; }
|
||||
|
||||
#region 画笔相关
|
||||
#region 绘图画笔
|
||||
[JsonIgnore]
|
||||
[Browsable(false)]
|
||||
protected Pen Pen { get; set; } = new Pen(Color.Red, 1);
|
||||
|
||||
protected virtual void SetNewStatePen()
|
||||
{
|
||||
Pen = new Pen(Color.Red, 3);
|
||||
}
|
||||
|
||||
protected virtual void SetNormalPen()
|
||||
{
|
||||
Pen = new Pen(Color.Red, 1);
|
||||
}
|
||||
|
||||
protected virtual void SetHoverPen()
|
||||
{
|
||||
Pen = new Pen(Color.BlueViolet, 3);
|
||||
}
|
||||
|
||||
protected virtual void SetInSidePen()
|
||||
{
|
||||
Pen = new Pen(Color.YellowGreen, 3);
|
||||
}
|
||||
|
||||
protected virtual void SetSelectedPen()
|
||||
{
|
||||
Pen = new Pen(Color.Pink, 3);
|
||||
}
|
||||
|
||||
protected virtual void SetMeasureDoneOKPen()
|
||||
{
|
||||
Pen = new Pen(Color.Green, 2);
|
||||
}
|
||||
|
||||
protected virtual void SetMeasureDoneNGPen()
|
||||
{
|
||||
Pen = new Pen(Color.Red, 2);
|
||||
}
|
||||
|
||||
protected virtual void SetMeasuringPen()
|
||||
{
|
||||
Pen = new Pen(Color.Yellow, 3);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 文字画笔
|
||||
//[JsonIgnore]
|
||||
//protected Pen PenText = new Pen(Color.Black, 1);
|
||||
//[JsonIgnore]
|
||||
//protected Pen PenTextOK = new Pen(Color.Green, 1.5f);
|
||||
//[JsonIgnore]
|
||||
//protected Pen PenTextNG = new Pen(Color.Red, 2);
|
||||
|
||||
///// <summary>
|
||||
///// 字体大小
|
||||
///// </summary>
|
||||
//[Category("显示属性")]
|
||||
//[Description("字体大小")]
|
||||
////[Browsable(false)]
|
||||
//public virtual float FontSize { get; set; } = 15;
|
||||
/// <summary>
|
||||
/// 字体大小
|
||||
/// </summary>
|
||||
[Category("显示属性")]
|
||||
[Description("字体设置")]
|
||||
[Browsable(false)]
|
||||
public virtual Font Font { get; set; } = new Font(new FontFamily("Tahoma"), 15, GraphicsUnit.World);
|
||||
|
||||
/// <summary>
|
||||
/// 字体和基元的距离
|
||||
/// </summary>
|
||||
[Category("显示属性")]
|
||||
[Description("字体和基元的距离")]
|
||||
[Browsable(false)]
|
||||
public virtual int FontDistance { get; set; } = 15;
|
||||
|
||||
[Category("显示属性")]
|
||||
[Description("显示字符说明")]
|
||||
[Browsable(false)]
|
||||
public virtual bool IsShowRemark { get; set; } = true;
|
||||
|
||||
#endregion
|
||||
#endregion
|
||||
|
||||
//public Graphics Graphics { get; set; }
|
||||
public abstract void Draw(Graphics g);
|
||||
protected abstract void DrawResult(Graphics g);
|
||||
#endregion
|
||||
|
||||
#region 状态
|
||||
private ElementState state = ElementState.New;
|
||||
[JsonIgnore]
|
||||
[Browsable(false)]
|
||||
public ElementState State
|
||||
{
|
||||
get
|
||||
{
|
||||
return state;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (state != value)
|
||||
{
|
||||
ElementState preState = state;
|
||||
Set(ref state, value);
|
||||
EventRouter.TriggerElementsMouseStateChanged(this, preState, state);
|
||||
switch (state)
|
||||
{
|
||||
case ElementState.MouseHover:
|
||||
SetHoverPen();
|
||||
break;
|
||||
case ElementState.MouseInSide:
|
||||
SetInSidePen();
|
||||
break;
|
||||
case ElementState.Selected:
|
||||
SetSelectedPen();
|
||||
break;
|
||||
case ElementState.Normal:
|
||||
SetNormalPen();
|
||||
break;
|
||||
case ElementState.Measuring:
|
||||
SetMeasuringPen();
|
||||
break;
|
||||
case ElementState.MeasureDoneOK:
|
||||
SetMeasureDoneOKPen();
|
||||
break;
|
||||
case ElementState.MeasureDoneNG:
|
||||
SetMeasureDoneNGPen();
|
||||
break;
|
||||
case ElementState.New:
|
||||
SetNewStatePen();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 是否是运行模式
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public RunMode RunMode { get; set; } = RunMode.NormalMode;
|
||||
#endregion
|
||||
|
||||
#region 复制
|
||||
public abstract object Clone();
|
||||
|
||||
public virtual void Initial()
|
||||
{
|
||||
State = ElementState.New;
|
||||
CreatePoints = new NoticedPoints();
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IMouseEvent
|
||||
public virtual void OnMouseDoubleClick(PointF p)
|
||||
{
|
||||
if (State == ElementState.MeasureDoneNG || State == ElementState.MeasureDoneOK)
|
||||
return;
|
||||
|
||||
//if (State == ElementState.MouseInSide)
|
||||
//{
|
||||
// State = ElementState.Selected;
|
||||
//}
|
||||
//else if (State == ElementState.Selected || State == ElementState.Moving)
|
||||
//{
|
||||
// if (IsMouseInSide(p))
|
||||
// {
|
||||
// State = ElementState.MouseInSide;
|
||||
// }
|
||||
//}
|
||||
if (IsMouseInSide(p))
|
||||
{
|
||||
State = ElementState.Selected;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void OnKeyDown(object sender, KeyEventArgs e);
|
||||
|
||||
public abstract void OnKeyUp(object sender, KeyEventArgs e);
|
||||
|
||||
public virtual void OnMouseDown(PointF p)
|
||||
{
|
||||
//switch (State)
|
||||
//{
|
||||
// case ElementState.New:
|
||||
// OnMouseDownWhenNew(p);
|
||||
// break;
|
||||
// case ElementState.MouseHover:
|
||||
// break;
|
||||
// case ElementState.MouseInSide:
|
||||
// State = ElementState.Selected;
|
||||
// break;
|
||||
// case ElementState.Selected:
|
||||
// _startPoint = p;
|
||||
// State = ElementState.Moving;
|
||||
// break;
|
||||
// case ElementState.Normal:
|
||||
// break;
|
||||
//}
|
||||
if (State == ElementState.New)
|
||||
{
|
||||
OnMouseDownWhenNew(p);
|
||||
}
|
||||
else if (IsMouseCanMoveElement(p) && State == ElementState.Selected)
|
||||
{
|
||||
State = ElementState.Moving;
|
||||
}
|
||||
else if (IsMouseCanStretchBottom(p) && State == ElementState.CanStretchBottom)
|
||||
{
|
||||
State = ElementState.StretchingBottom;
|
||||
}
|
||||
else if (IsMouseCanStretchTop(p) && State == ElementState.CanStretchTop)
|
||||
{
|
||||
State = ElementState.StretchingTop;
|
||||
}
|
||||
else if (IsMouseCanStretchLeft(p) && State == ElementState.CanStretchLeft)
|
||||
{
|
||||
State = ElementState.StretchingLeft;
|
||||
}
|
||||
else if (IsMouseCanStretchRight(p) && State == ElementState.CanStretchRight)
|
||||
{
|
||||
State = ElementState.StretchingRight;
|
||||
}
|
||||
else if (IsMouseCanStretchLeftLowerCorner(p) && State == ElementState.CanStretchLeftLowerCorner)
|
||||
{
|
||||
State = ElementState.StretchingLeftLowerCorner;
|
||||
}
|
||||
else if (IsMouseCanStretchLeftUpperCorner(p) && State == ElementState.CanStretchLeftUpperCorner)
|
||||
{
|
||||
State = ElementState.StretchingLeftUpperCorner;
|
||||
}
|
||||
else if (IsMouseCanStretchRightLowerCorner(p) && State == ElementState.CanStretchRightLowerCorner)
|
||||
{
|
||||
State = ElementState.StretchingRightLowerCorner;
|
||||
}
|
||||
else if (IsMouseCanStretchRightUpperCorner(p) && State == ElementState.CanStretchRightUpperCorner)
|
||||
{
|
||||
State = ElementState.StretchingRightUpperCorner;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnMouseMove(PointF p)
|
||||
{
|
||||
switch (State)
|
||||
{
|
||||
case ElementState.New:
|
||||
OnMouseMoveWhenNew(p);
|
||||
break;
|
||||
case ElementState.Selected:
|
||||
{
|
||||
if (IsMouseCanStretchLeft(p))
|
||||
{
|
||||
State = ElementState.CanStretchLeft;
|
||||
}
|
||||
else if (IsMouseCanStretchRight(p))
|
||||
{
|
||||
State = ElementState.CanStretchRight;
|
||||
}
|
||||
else if (IsMouseCanStretchTop(p))
|
||||
{
|
||||
State = ElementState.CanStretchTop;
|
||||
}
|
||||
else if (IsMouseCanStretchBottom(p))
|
||||
{
|
||||
State = ElementState.CanStretchBottom;
|
||||
}
|
||||
else if (IsMouseCanStretchLeftLowerCorner(p))
|
||||
{
|
||||
State = ElementState.CanStretchLeftLowerCorner;
|
||||
}
|
||||
else if (IsMouseCanStretchLeftUpperCorner(p))
|
||||
{
|
||||
State = ElementState.CanStretchLeftUpperCorner;
|
||||
}
|
||||
else if (IsMouseCanStretchRightLowerCorner(p))
|
||||
{
|
||||
State = ElementState.CanStretchRightLowerCorner;
|
||||
}
|
||||
else if (IsMouseCanStretchRightUpperCorner(p))
|
||||
{
|
||||
State = ElementState.CanStretchRightUpperCorner;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case ElementState.Moving:
|
||||
_currentPoint = p;
|
||||
//Translate(_currentPoint.X - _startPoint.X, _currentPoint.Y - _startPoint.Y);
|
||||
//_startPoint = _currentPoint;
|
||||
Relocate(p);
|
||||
break;
|
||||
case ElementState.MouseHover:
|
||||
case ElementState.MouseInSide:
|
||||
case ElementState.Normal:
|
||||
//if (IsMouseInSide(p))
|
||||
//{
|
||||
// State = ElementState.MouseInSide;
|
||||
//}
|
||||
//else if (IsMouseHover(p))
|
||||
//{
|
||||
// State = ElementState.MouseHover;
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// State = ElementState.Normal;
|
||||
//}
|
||||
break;
|
||||
case ElementState.CanStretchBottom:
|
||||
if (!IsMouseCanStretchBottom(p))
|
||||
{
|
||||
State = ElementState.Selected;
|
||||
}
|
||||
break;
|
||||
case ElementState.CanStretchTop:
|
||||
if (!IsMouseCanStretchTop(p))
|
||||
{
|
||||
State = ElementState.Selected;
|
||||
}
|
||||
break;
|
||||
case ElementState.CanStretchLeft:
|
||||
if (!IsMouseCanStretchLeft(p))
|
||||
{
|
||||
State = ElementState.Selected;
|
||||
}
|
||||
break;
|
||||
case ElementState.CanStretchRight:
|
||||
if (!IsMouseCanStretchRight(p))
|
||||
{
|
||||
State = ElementState.Selected;
|
||||
}
|
||||
break;
|
||||
case ElementState.CanStretchLeftUpperCorner:
|
||||
if (!IsMouseCanStretchLeftUpperCorner(p))
|
||||
{
|
||||
State = ElementState.Selected;
|
||||
}
|
||||
break;
|
||||
case ElementState.CanStretchLeftLowerCorner:
|
||||
if (!IsMouseCanStretchLeftLowerCorner(p))
|
||||
{
|
||||
State = ElementState.Selected;
|
||||
}
|
||||
break;
|
||||
case ElementState.CanStretchRightLowerCorner:
|
||||
if (!IsMouseCanStretchRightLowerCorner(p))
|
||||
{
|
||||
State = ElementState.Selected;
|
||||
}
|
||||
break;
|
||||
case ElementState.CanStretchRightUpperCorner:
|
||||
if (!IsMouseCanStretchRightUpperCorner(p))
|
||||
{
|
||||
State = ElementState.Selected;
|
||||
}
|
||||
break;
|
||||
case ElementState.StretchingTop:
|
||||
StretchTop(p);
|
||||
break;
|
||||
case ElementState.StretchingBottom:
|
||||
StretchBottom(p);
|
||||
break;
|
||||
case ElementState.StretchingLeft:
|
||||
StretchLeft(p);
|
||||
break;
|
||||
case ElementState.StretchingRight:
|
||||
StretchRight(p);
|
||||
break;
|
||||
case ElementState.StretchingLeftLowerCorner:
|
||||
StretchLeftLowerCorner(p);
|
||||
break;
|
||||
case ElementState.StretchingLeftUpperCorner:
|
||||
StretchLeftUpperCorner(p);
|
||||
break;
|
||||
case ElementState.StretchingRightLowerCorner:
|
||||
StretchRightLowerCorner(p);
|
||||
break;
|
||||
case ElementState.StretchingRightUpperCorner:
|
||||
StretchRightUpperCorner(p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void OnMouseUp(PointF p)
|
||||
{
|
||||
switch (State)
|
||||
{
|
||||
case ElementState.New:
|
||||
OnMouseUpWhenNew(p);
|
||||
break;
|
||||
case ElementState.Moving:
|
||||
State = ElementState.Selected;
|
||||
break;
|
||||
case ElementState.Selected:
|
||||
if (!IsMouseInSide(p))
|
||||
{
|
||||
State = ElementState.Normal;
|
||||
}
|
||||
break;
|
||||
case ElementState.StretchingBottom:
|
||||
State = ElementState.CanStretchBottom;
|
||||
break;
|
||||
case ElementState.StretchingLeft:
|
||||
State = ElementState.CanStretchLeft;
|
||||
break;
|
||||
case ElementState.StretchingRight:
|
||||
State = ElementState.CanStretchRight;
|
||||
break;
|
||||
case ElementState.StretchingTop:
|
||||
State = ElementState.CanStretchTop;
|
||||
break;
|
||||
case ElementState.StretchingLeftLowerCorner:
|
||||
State = ElementState.CanStretchLeftLowerCorner;
|
||||
break;
|
||||
case ElementState.StretchingLeftUpperCorner:
|
||||
State = ElementState.CanStretchLeftUpperCorner;
|
||||
break;
|
||||
case ElementState.StretchingRightUpperCorner:
|
||||
State = ElementState.CanStretchRightUpperCorner;
|
||||
break;
|
||||
case ElementState.StretchingRightLowerCorner:
|
||||
State = ElementState.CanStretchRightLowerCorner;
|
||||
break;
|
||||
default:
|
||||
State = ElementState.Normal;
|
||||
break;
|
||||
}
|
||||
|
||||
AfterTranformOp();
|
||||
}
|
||||
|
||||
public virtual void AfterTranformOp()
|
||||
{
|
||||
}
|
||||
|
||||
#region 当基元状态为新建或可编辑时的鼠标操作动作
|
||||
/// <summary>
|
||||
/// 当状态为New时的鼠标按下操作
|
||||
/// </summary>
|
||||
/// <param name="p"></param>
|
||||
public abstract void OnMouseDownWhenNew(PointF p);
|
||||
|
||||
public abstract void OnMouseMoveWhenNew(PointF p);
|
||||
|
||||
public abstract void OnMouseUpWhenNew(PointF p);
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region 委托事件
|
||||
[JsonIgnore]
|
||||
public Action<ElementBase> OnDrawDone;
|
||||
[JsonIgnore]
|
||||
public Action<ElementBase> OnMeasureDone;
|
||||
[JsonIgnore]
|
||||
public Action<ElementBase> OnElementEnableChanged;
|
||||
#endregion
|
||||
|
||||
#region 几何特性
|
||||
/// <summary>
|
||||
/// 基类基础的Rectangle 用于计算MouseHover和Inside等
|
||||
/// </summary>
|
||||
[Browsable(false)]
|
||||
public Rectangle BaseRectangle { get; set; }
|
||||
EnumHelper.ElementState IShapeElement.State { get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
|
||||
|
||||
public abstract bool IsMouseHover(PointF p);
|
||||
|
||||
public abstract bool IsMouseInSide(PointF p);
|
||||
|
||||
public abstract bool IsIntersect(RectangleF rect);
|
||||
#region Move & Stretch & Move Anchor
|
||||
public virtual bool IsMouseCanMoveElement(PointF p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool IsMouseCanStretchLeft(PointF p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool IsMouseCanStretchRight(PointF p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool IsMouseCanStretchTop(PointF p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool IsMouseCanStretchBottom(PointF p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void StretchLeft(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void StretchRight(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void StretchTop(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void StretchBottom(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool IsMouseCanStretchLeftUpperCorner(PointF p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool IsMouseCanStretchRightUpperCorner(PointF p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool IsMouseCanStretchLeftLowerCorner(PointF p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual bool IsMouseCanStretchRightLowerCorner(PointF p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public virtual void StretchLeftUpperCorner(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void StretchRightUpperCorner(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void StretchLeftLowerCorner(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual void StretchRightLowerCorner(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public virtual bool IsMouseCanMoveAnchor(PointF p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#endregion
|
||||
|
||||
#region 变形操作
|
||||
public abstract void Translate(float x, float y);
|
||||
|
||||
public virtual void Relocate(PointF point) { }
|
||||
|
||||
//public abstract void RotateAt(int x, int y, float degree);
|
||||
#endregion
|
||||
|
||||
#region 运动
|
||||
//[Browsable(false)]
|
||||
//public PlanPoint MovePoint { get; set; }
|
||||
#endregion
|
||||
|
||||
#region 相机
|
||||
//[Browsable(false)]
|
||||
//public CameraOperationConfigBase CameraOpConfig { get; set; }
|
||||
#endregion
|
||||
|
||||
#region 光源
|
||||
#endregion
|
||||
|
||||
#region 算法
|
||||
/// <summary>
|
||||
/// 算法
|
||||
/// </summary>
|
||||
/// <param name="paras">计算参数</param>
|
||||
public virtual void Calculate(Bitmap image) { }
|
||||
|
||||
public virtual void Calculate(IntPtr imagePtr, int ptrSize, int imageWidth, int imageHeight) { }
|
||||
|
||||
public virtual void Calculate(string imagePath) { }
|
||||
#endregion
|
||||
|
||||
#region 图片保存
|
||||
//[Description("图片保存方式")]
|
||||
//public ImageSaveMode ImageSaveMode { get; set; } = ImageSaveMode.NoSave;
|
||||
|
||||
//public virtual void SaveImage(Bitmap image)
|
||||
//{
|
||||
// if (string.IsNullOrWhiteSpace(AOIMeasure.GlobalVar.ImageSaveDirectory) || ImageSaveMode == ImageSaveMode.NoSave)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// DirectoryInfo dir = new DirectoryInfo(GlobalVar.ImageSaveDirectory);
|
||||
// if (!dir.Exists)
|
||||
// {
|
||||
// dir.Create();
|
||||
// }
|
||||
|
||||
// string imgPath = Path.Combine(AOIMeasure.GlobalVar.ImageSaveDirectory, Name + "_" + DateTime.Now.ToString("MMdd_HHmmss") + ".bmp");
|
||||
// switch (ImageSaveMode)
|
||||
// {
|
||||
// case ImageSaveMode.SaveImage:
|
||||
// image.Save(imgPath);
|
||||
// break;
|
||||
// case ImageSaveMode.SaveImageWithElement:
|
||||
// Bitmap bmp = new Bitmap(image.Width, image.Height, PixelFormat.Format32bppArgb);
|
||||
// using (Graphics g = Graphics.FromImage(bmp))
|
||||
// {
|
||||
// g.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
|
||||
// g.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
|
||||
// g.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
|
||||
// g.DrawImage(image, 0, 0, image.Width, image.Height);
|
||||
|
||||
// Draw(g);
|
||||
// }
|
||||
|
||||
// bmp.Save(imgPath);
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
|
||||
//public virtual void SaveImage(IntPtr imagePtr, int ptrSize)
|
||||
//{
|
||||
// Bitmap map = null;
|
||||
// unsafe
|
||||
// {
|
||||
// byte* pArray = (byte*)imagePtr;
|
||||
// byte[] array = new byte[ptrSize];
|
||||
// Marshal.Copy(imagePtr, array, 0, ptrSize);
|
||||
// using (MemoryStream ms = new MemoryStream(array))
|
||||
// {
|
||||
// map = (Bitmap)Image.FromStream(ms);
|
||||
// }
|
||||
// }
|
||||
|
||||
// SaveImage(map);
|
||||
//}
|
||||
|
||||
//public virtual void SaveImage(string imagePath)
|
||||
//{
|
||||
// using (Bitmap map = Image.FromFile(imagePath) as Bitmap)
|
||||
// {
|
||||
// SaveImage(map);
|
||||
// }
|
||||
//}
|
||||
#endregion
|
||||
|
||||
#region 值设置
|
||||
public virtual void InitialMeasureResult()
|
||||
{
|
||||
//PropertyInfo[] prop = this.GetType().GetProperties();
|
||||
//Array.ForEach(prop, p =>
|
||||
//{
|
||||
// if ((p.PropertyType.Name == typeof(MeasureSpec).Name) && p.CanRead && p.CanWrite)
|
||||
// {
|
||||
// MeasureSpec spec = p.GetValue(this) as MeasureSpec;
|
||||
// spec.Result = MeasureResult.NotYet;
|
||||
// p.SetValue(this, spec);
|
||||
// }
|
||||
//});
|
||||
}
|
||||
|
||||
public virtual void SetActualValue(double v)
|
||||
{
|
||||
//PropertyInfo[] prop = this.GetType().GetProperties();
|
||||
//Array.ForEach(prop, p =>
|
||||
// {
|
||||
// if ((p.PropertyType.Name == typeof(MeasureSpec).Name) && p.CanRead && p.CanWrite)
|
||||
// {
|
||||
// MeasureSpec spec = p.GetValue(this) as MeasureSpec;
|
||||
// spec.ActualValue = (float)v;
|
||||
// p.SetValue(this, spec);
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
public virtual void SetStandardValue(double v)
|
||||
{
|
||||
//PropertyInfo[] prop = this.GetType().GetProperties();
|
||||
//Array.ForEach(prop, p =>
|
||||
//{
|
||||
// if ((p.PropertyType.Name == typeof(MeasureSpec).Name) && p.CanRead && p.CanWrite)
|
||||
// {
|
||||
// MeasureSpec spec = p.GetValue(this) as MeasureSpec;
|
||||
// spec.StandardValue = (float)v;
|
||||
// p.SetValue(this, spec);
|
||||
// }
|
||||
//});
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IPropertyChanged
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
public virtual void Set<T>(ref T field, T newValue, [CallerMemberName] string propName = null)
|
||||
{
|
||||
if (!field.Equals(newValue))
|
||||
{
|
||||
field = newValue;
|
||||
//PropertyChanged?.BeginInvoke(this, new PropertyChangedEventArgs(propName), null, null);
|
||||
RaisePropertyChanged(propName);
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void RaisePropertyChanged(string propName = "")
|
||||
{
|
||||
//PropertyChanged?.BeginInvoke(this, new PropertyChangedEventArgs(propName), null, null);
|
||||
|
||||
//Task.Run(() =>
|
||||
//{
|
||||
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propName));
|
||||
//});
|
||||
}
|
||||
#endregion
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return GetDisplayText();
|
||||
}
|
||||
|
||||
public abstract string GetDisplayText();
|
||||
|
||||
#region IComparable
|
||||
public virtual int CompareTo(ElementBase other)
|
||||
{
|
||||
//throw new NotImplementedException();
|
||||
return Index - other.Index;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region IDisposable Support
|
||||
private bool disposedValue = false; // 要检测冗余调用
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!disposedValue)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
// 释放托管状态(托管对象)。
|
||||
Pen?.Dispose();
|
||||
}
|
||||
|
||||
// TODO: 释放未托管的资源(未托管的对象)并在以下内容中替代终结器。
|
||||
// TODO: 将大型字段设置为 null。
|
||||
|
||||
disposedValue = true;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: 仅当以上 Dispose(bool disposing) 拥有用于释放未托管资源的代码时才替代终结器。
|
||||
// ~ElementBase()
|
||||
// {
|
||||
// // 请勿更改此代码。将清理代码放入以上 Dispose(bool disposing) 中。
|
||||
// Dispose(false);
|
||||
// }
|
||||
|
||||
// 添加此代码以正确实现可处置模式。
|
||||
public void Dispose()
|
||||
{
|
||||
// 请勿更改此代码。将清理代码放入以上 Dispose(bool disposing) 中。
|
||||
Dispose(true);
|
||||
// TODO: 如果在以上内容中替代了终结器,则取消注释以下行。
|
||||
// GC.SuppressFinalize(this);
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
||||
[Serializable]
|
||||
public abstract class DisplayElementBase : ElementBase
|
||||
{
|
||||
//public override object Clone()
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
|
||||
//public override void Draw(Graphics g)
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
|
||||
//public override string GetDisplayText()
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
|
||||
//public override bool IsIntersect(Rectangle rect)
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
|
||||
public override bool IsMouseHover(PointF p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
//public override bool IsMouseInSide(Point p)
|
||||
//{
|
||||
// throw new NotImplementedException();
|
||||
//}
|
||||
|
||||
public override void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnKeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnMouseDownWhenNew(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnMouseMoveWhenNew(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnMouseUpWhenNew(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Translate(float x, float y)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void DrawResult(Graphics g)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public interface IEventHandle
|
||||
{
|
||||
void OnMouseMove(PointF p);
|
||||
|
||||
void OnMouseDown(PointF p);
|
||||
|
||||
void OnMouseUp(PointF p);
|
||||
|
||||
void OnMouseDoubleClick(PointF p);
|
||||
|
||||
void OnKeyDown(object sender, KeyEventArgs e);
|
||||
|
||||
void OnKeyUp(object sender, KeyEventArgs e);
|
||||
}
|
||||
|
||||
public class ElementIndexCompare : IComparer<ElementBase>
|
||||
{
|
||||
public int Compare(ElementBase x, ElementBase y)
|
||||
{
|
||||
return x.Index - y.Index;
|
||||
}
|
||||
}
|
||||
}
|
||||
325
DH.UI.Model.Winform/Element/MLResultDisplay.cs
Normal file
325
DH.UI.Model.Winform/Element/MLResultDisplay.cs
Normal file
@@ -0,0 +1,325 @@
|
||||
|
||||
using DH.Commons.Enums;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
|
||||
namespace DH.UI.Model.Winform
|
||||
{
|
||||
public class DetectResultDisplay : ElementBase
|
||||
{
|
||||
//深度学习 显示结果
|
||||
private List<DetectionResultDetail> mlResultList = null;
|
||||
public List<DetectionResultDetail> MLResultList
|
||||
{
|
||||
get => mlResultList;
|
||||
set
|
||||
{
|
||||
if (mlResultList != value)
|
||||
{
|
||||
mlResultList = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//测量结果
|
||||
//private List<IndexedSpec> specResultList = null;
|
||||
//public List<IndexedSpec> SpecResultList
|
||||
//{
|
||||
// get => specResultList;
|
||||
// set
|
||||
// {
|
||||
// if (specResultList != value)
|
||||
// {
|
||||
// specResultList = value;
|
||||
|
||||
// string specDisplay = "";
|
||||
// if (specResultList != null && specResultList.Count > 0)
|
||||
// {
|
||||
// specResultList.ForEach(s =>
|
||||
// {
|
||||
// specDisplay += $"{s.Code}:{(s.ActualValue ?? 0).ToString("f2")}\r\n";
|
||||
// });
|
||||
// }
|
||||
|
||||
// if (!string.IsNullOrWhiteSpace(specDisplay))
|
||||
// {
|
||||
// DisplayTxt += specDisplay;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
ResultState ResultState = ResultState.DetectNG;
|
||||
|
||||
string DisplayTxt = "";
|
||||
Bitmap ResultImage = null;
|
||||
PointF StartPoint = new PointF();
|
||||
Brush FontBrush = new SolidBrush(Color.Green);
|
||||
Pen DetectResultRectPen = new Pen(new SolidBrush(Color.Green));
|
||||
Font DetectResultFont = new Font(new FontFamily("Tahoma"), 15, GraphicsUnit.World);
|
||||
|
||||
public int ImageWidth { get; set; }
|
||||
public int ImageHeight { get; set; }
|
||||
public DetectResultDisplay() { }
|
||||
|
||||
//public DetectResultDisplay(NetResult result, List<IndexedSpec> specs, ResultState resultState, int imageWidth)
|
||||
//{
|
||||
// ImageWidth = imageWidth;
|
||||
|
||||
// ResultState = resultState;
|
||||
|
||||
// displayTxt = resultState.ToString() + "\r\n";
|
||||
// if (resultState != ResultState.OK)
|
||||
// {
|
||||
// fontBrush = new SolidBrush(Color.Red);
|
||||
// }
|
||||
|
||||
// NetResult = result;
|
||||
// SpecList = specs;
|
||||
|
||||
// Font = new Font(new FontFamily("Tahoma"), 35 * ImageWidth / 1400, GraphicsUnit.World);
|
||||
// startPoint = new PointF(150 * ImageWidth / 1400, 150 * ImageWidth / 1400);
|
||||
//}
|
||||
|
||||
public DetectResultDisplay(DetectStationResult detectResult, Bitmap resultImage, string displayTxt)
|
||||
{
|
||||
ImageWidth = resultImage.Width;
|
||||
ImageHeight = resultImage.Height;
|
||||
var longSide = ImageWidth > ImageHeight ? ImageWidth : ImageHeight;
|
||||
|
||||
MLResultList = detectResult.DetectDetails;
|
||||
// SpecResultList = detectResult.Specs;
|
||||
ResultState = detectResult.ResultState;
|
||||
ResultImage = resultImage;
|
||||
DisplayTxt = displayTxt;
|
||||
if (ResultState != ResultState.OK)
|
||||
{
|
||||
FontBrush = new SolidBrush(Color.Red);
|
||||
DetectResultRectPen = new Pen(new SolidBrush(Color.Red));
|
||||
}
|
||||
Font = new Font(new FontFamily("Tahoma"), 35 * longSide / 1400, GraphicsUnit.World);
|
||||
DetectResultFont = new Font(new FontFamily("Tahoma"), 25 * longSide / 1400, GraphicsUnit.World);
|
||||
StartPoint = new PointF(100 * ImageWidth / 1400, 100 * ImageHeight / 1400);
|
||||
}
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
//画检测结果图
|
||||
if (ResultImage != null && ResultState != ResultState.OK)
|
||||
{
|
||||
g.DrawImage(ResultImage, new Point(0, 0));
|
||||
}
|
||||
//画文字
|
||||
if (!string.IsNullOrWhiteSpace(DisplayTxt))
|
||||
{
|
||||
g.DrawString(DisplayTxt, Font, FontBrush, StartPoint);
|
||||
}
|
||||
//画外接矩形+label 深度学习
|
||||
if (MLResultList != null && MLResultList.Count > 0)
|
||||
{
|
||||
MLResultList.ForEach(d =>
|
||||
{
|
||||
g.DrawRectangle(DetectResultRectPen, d.Rect);
|
||||
|
||||
string locationTxt = $"{d.LabelDisplay}";
|
||||
var locationX = d.Rect.X;
|
||||
var locationY = d.Rect.Y <= 20 ? d.Rect.Y + 20 : d.Rect.Y - 20;
|
||||
g.DrawString(locationTxt, DetectResultFont, FontBrush, locationX, locationY);
|
||||
});
|
||||
}
|
||||
//画spec信息
|
||||
|
||||
//if (DetectResult != null && DetectResult.NetResult?.DetectDetails?.Count > 0)
|
||||
//{
|
||||
// DetectResult.NetResult?.DetectDetails.ForEach(d =>
|
||||
// {
|
||||
// g.DrawRectangle(defectRectPen, d.Rect);
|
||||
|
||||
// string locationTxt = $"{d.Rect.X},{d.Rect.Y}";
|
||||
// g.DrawString(locationTxt, defectFont, fontBrush, d.Rect.X, d.Rect.Y - 5);
|
||||
// });
|
||||
//}
|
||||
|
||||
//float fontHeight = g.MeasureString(displayTxt, Font).Height;
|
||||
//startPoint.Y += fontHeight * 1.2f;
|
||||
|
||||
//var defects = DetectResult.NetResult?.DetectDetails;
|
||||
//if (defects != null && defects.Count > 0)
|
||||
//{
|
||||
// defects.ForEach(d =>
|
||||
// {
|
||||
// g.DrawString($"{d.ClassName} X:{d.Rect.X.ToString("f2")} Y:{d.Rect.Y.ToString("f2")} S:{d.Area}", Font, d.FinalResult == EnumHelper.ResultState.OK ? fontBrushOK : fontBrushNG, startPoint);
|
||||
|
||||
// startPoint.Y += fontHeight;
|
||||
// });
|
||||
//}
|
||||
|
||||
//DetectResult.Specs.ForEach(s =>
|
||||
//{
|
||||
// g.DrawString($"{s.Code}:{(s.ActualValue ?? 0).ToString("f2")}", Font, s.MeasureResult ?? false == true ? fontBrushOK : fontBrushNG, startPoint);
|
||||
|
||||
// startPoint.Y += fontHeight;
|
||||
//});
|
||||
}
|
||||
|
||||
public override string GetDisplayText()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public override bool IsIntersect(RectangleF rect)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool IsMouseHover(PointF p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool IsMouseInSide(PointF p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnKeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void DrawResult(Graphics g)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnMouseDownWhenNew(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnMouseMoveWhenNew(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnMouseUpWhenNew(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Translate(float x, float y)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class RectResultDisplay : ElementBase
|
||||
{
|
||||
ResultState ResultState = ResultState.DetectNG;
|
||||
public string DisplayTxt = "";
|
||||
Color FillColor = Color.Lime;
|
||||
int FontSize = 15;
|
||||
RectangleF Rect = new RectangleF();
|
||||
bool IsFilled = false;
|
||||
|
||||
public RectResultDisplay() { }
|
||||
|
||||
public RectResultDisplay(ResultState _resultState, RectangleF _rect, string _displayTxt, Color _fillColor, bool _isFilled, int _fontSize)
|
||||
{
|
||||
ResultState = _resultState;
|
||||
Rect = _rect;
|
||||
DisplayTxt = _displayTxt;
|
||||
FillColor = _fillColor;
|
||||
IsFilled = _isFilled;
|
||||
FontSize = _fontSize;
|
||||
}
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
RectResultDisplay rect = new RectResultDisplay();
|
||||
|
||||
rect.ResultState = ResultState;
|
||||
rect.Rect = Rect;
|
||||
rect.DisplayTxt = DisplayTxt;
|
||||
rect.FillColor = FillColor;
|
||||
rect.FontSize = FontSize;
|
||||
rect.IsFilled = IsFilled;
|
||||
|
||||
return rect;
|
||||
}
|
||||
|
||||
public override void Draw(Graphics g)
|
||||
{
|
||||
g.DrawRectangle(new Pen(FillColor, 1), Rect.X, Rect.Y, Rect.Width, Rect.Height);
|
||||
|
||||
if (IsFilled)
|
||||
{
|
||||
g.FillRectangle(new SolidBrush(Color.FromArgb(20, FillColor)), Rect);
|
||||
}
|
||||
|
||||
Font font = new Font("Tahoma", FontSize);
|
||||
var txtSize = g.MeasureString(DisplayTxt, font);
|
||||
|
||||
g.DrawString(DisplayTxt, font, new SolidBrush(FillColor), (float)(Rect.X + Rect.Width / 2.0 - txtSize.Width / 2.0), Rect.Y + Rect.Height + 5);
|
||||
}
|
||||
|
||||
public override string GetDisplayText()
|
||||
{
|
||||
return $"{ResultState} {DisplayTxt} ({Rect.X},{Rect.Y},{Rect.Width},{Rect.Height})";
|
||||
}
|
||||
|
||||
public override bool IsIntersect(RectangleF rect)
|
||||
{
|
||||
return rect.IntersectsWith(Rect);
|
||||
}
|
||||
|
||||
public override bool IsMouseHover(PointF p)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool IsMouseInSide(PointF p)
|
||||
{
|
||||
return Rect.Contains(p);
|
||||
}
|
||||
|
||||
public override void OnKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnKeyUp(object sender, KeyEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnMouseDownWhenNew(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnMouseMoveWhenNew(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public override void OnMouseUpWhenNew(PointF p)
|
||||
{
|
||||
}
|
||||
|
||||
public override void Translate(float x, float y)
|
||||
{
|
||||
Rect.Offset(new PointF(x, y));
|
||||
}
|
||||
|
||||
protected override void DrawResult(Graphics g)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
109
DH.UI.Model.Winform/GridCtrl.Designer.cs
generated
Normal file
109
DH.UI.Model.Winform/GridCtrl.Designer.cs
generated
Normal file
@@ -0,0 +1,109 @@
|
||||
namespace XKRS.UI.Model.Winform
|
||||
{
|
||||
partial class GridCtrl
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要修改
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.chkShowGrid = new System.Windows.Forms.CheckBox();
|
||||
this.tbGridValue = new System.Windows.Forms.TrackBar();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.colorDialog1 = new System.Windows.Forms.ColorDialog();
|
||||
this.btnColor = new System.Windows.Forms.Button();
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbGridValue)).BeginInit();
|
||||
this.panel1.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// chkShowGrid
|
||||
//
|
||||
this.chkShowGrid.Appearance = System.Windows.Forms.Appearance.Button;
|
||||
// this.chkShowGrid.BackgroundImage = global::XKRS.UI.Model.Winform.Properties.Resources.grid;
|
||||
this.chkShowGrid.BackgroundImageLayout = System.Windows.Forms.ImageLayout.Stretch;
|
||||
this.chkShowGrid.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.chkShowGrid.Location = new System.Drawing.Point(0, 0);
|
||||
this.chkShowGrid.Name = "chkShowGrid";
|
||||
this.chkShowGrid.Size = new System.Drawing.Size(32, 30);
|
||||
this.chkShowGrid.TabIndex = 0;
|
||||
this.chkShowGrid.UseVisualStyleBackColor = true;
|
||||
this.chkShowGrid.CheckedChanged += new System.EventHandler(this.chkShowGrid_CheckedChanged);
|
||||
//
|
||||
// tbGridValue
|
||||
//
|
||||
this.tbGridValue.AutoSize = false;
|
||||
this.tbGridValue.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.tbGridValue.Location = new System.Drawing.Point(0, 21);
|
||||
this.tbGridValue.Name = "tbGridValue";
|
||||
this.tbGridValue.Orientation = System.Windows.Forms.Orientation.Vertical;
|
||||
this.tbGridValue.Size = new System.Drawing.Size(32, 121);
|
||||
this.tbGridValue.TabIndex = 1;
|
||||
this.tbGridValue.TickStyle = System.Windows.Forms.TickStyle.Both;
|
||||
this.tbGridValue.ValueChanged += new System.EventHandler(this.tbGridValue_ValueChanged);
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.panel1.Controls.Add(this.chkShowGrid);
|
||||
this.panel1.Controls.Add(this.tbGridValue);
|
||||
this.panel1.Location = new System.Drawing.Point(1, 1);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(32, 142);
|
||||
this.panel1.TabIndex = 2;
|
||||
//
|
||||
// btnColor
|
||||
//
|
||||
this.btnColor.BackColor = System.Drawing.Color.Red;
|
||||
this.btnColor.Location = new System.Drawing.Point(4, 150);
|
||||
this.btnColor.Name = "btnColor";
|
||||
this.btnColor.Size = new System.Drawing.Size(25, 23);
|
||||
this.btnColor.TabIndex = 3;
|
||||
this.btnColor.Text = " ";
|
||||
this.btnColor.UseVisualStyleBackColor = false;
|
||||
this.btnColor.Click += new System.EventHandler(this.btnColor_Click);
|
||||
//
|
||||
// GridCtrl
|
||||
//
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
|
||||
this.Controls.Add(this.btnColor);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, ((byte)(134)));
|
||||
this.Name = "GridCtrl";
|
||||
this.Size = new System.Drawing.Size(32, 192);
|
||||
((System.ComponentModel.ISupportInitialize)(this.tbGridValue)).EndInit();
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.CheckBox chkShowGrid;
|
||||
private System.Windows.Forms.TrackBar tbGridValue;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.ColorDialog colorDialog1;
|
||||
private System.Windows.Forms.Button btnColor;
|
||||
}
|
||||
}
|
||||
74
DH.UI.Model.Winform/GridCtrl.cs
Normal file
74
DH.UI.Model.Winform/GridCtrl.cs
Normal file
@@ -0,0 +1,74 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace XKRS.UI.Model.Winform
|
||||
{
|
||||
public partial class GridCtrl : UserControl
|
||||
{
|
||||
public Action<bool> IsShowGridChanged { get; set; }
|
||||
|
||||
public Action<int> GridValueChanged { get; set; }
|
||||
|
||||
public Action<Color> GridColorChanged { get; set; }
|
||||
|
||||
public GridCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
IsChecked = chkShowGrid.Checked;
|
||||
GridValue = tbGridValue.Value;
|
||||
}
|
||||
|
||||
bool isChecked = false;
|
||||
bool IsChecked
|
||||
{
|
||||
get => isChecked;
|
||||
set
|
||||
{
|
||||
if (isChecked != value)
|
||||
{
|
||||
// IsShowGridChanged?.BeginInvoke(value, null, null);
|
||||
Task.Run(() => IsShowGridChanged.Invoke(value));
|
||||
}
|
||||
|
||||
isChecked = value;
|
||||
}
|
||||
}
|
||||
|
||||
int gridValue = 0;
|
||||
int GridValue
|
||||
{
|
||||
get => gridValue;
|
||||
set
|
||||
{
|
||||
if (gridValue != value)
|
||||
{
|
||||
// GridValueChanged?.BeginInvoke(value, null, null);
|
||||
Task.Run(() => GridValueChanged.Invoke(value));
|
||||
}
|
||||
|
||||
gridValue = value;
|
||||
}
|
||||
}
|
||||
private void chkShowGrid_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
IsChecked = chkShowGrid.Checked;
|
||||
}
|
||||
|
||||
private void tbGridValue_ValueChanged(object sender, EventArgs e)
|
||||
{
|
||||
GridValue = tbGridValue.Value;
|
||||
}
|
||||
|
||||
private void btnColor_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (colorDialog1.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
btnColor.BackColor = colorDialog1.Color;
|
||||
// GridColorChanged?.BeginInvoke(btnColor.BackColor, null, null);
|
||||
Task.Run(() => GridColorChanged.Invoke(btnColor.BackColor));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
DH.UI.Model.Winform/GridCtrl.resx
Normal file
120
DH.UI.Model.Winform/GridCtrl.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>
|
||||
12
DH.UI.Model.Winform/GridCtrlHost.cs
Normal file
12
DH.UI.Model.Winform/GridCtrlHost.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace XKRS.UI.Model.Winform
|
||||
{
|
||||
public class GridCtrlHost : ToolStripControlHost
|
||||
{
|
||||
public GridCtrlHost(GridCtrl grid) : base(grid)
|
||||
{
|
||||
//Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.World, 134);
|
||||
}
|
||||
}
|
||||
}
|
||||
78
DH.UI.Model.Winform/IOIndicatorCtrl.Designer.cs
generated
Normal file
78
DH.UI.Model.Winform/IOIndicatorCtrl.Designer.cs
generated
Normal file
@@ -0,0 +1,78 @@
|
||||
namespace XKRS.UI.Model.Winform
|
||||
{
|
||||
partial class IOIndicatorCtrl
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
plStatus = new Panel();
|
||||
lblDesc = new Label();
|
||||
SuspendLayout();
|
||||
//
|
||||
// plStatus
|
||||
//
|
||||
plStatus.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left;
|
||||
plStatus.Location = new Point(0, 0);
|
||||
plStatus.Margin = new Padding(4);
|
||||
plStatus.Name = "plStatus";
|
||||
plStatus.Size = new Size(28, 34);
|
||||
plStatus.TabIndex = 0;
|
||||
plStatus.Paint += plStatus_Paint;
|
||||
plStatus.DoubleClick += plStatus_DoubleClick;
|
||||
//
|
||||
// lblDesc
|
||||
//
|
||||
lblDesc.Anchor = AnchorStyles.Top | AnchorStyles.Bottom | AnchorStyles.Left | AnchorStyles.Right;
|
||||
lblDesc.AutoSize = true;
|
||||
lblDesc.Font = new Font("Tahoma", 11F, FontStyle.Regular, GraphicsUnit.World);
|
||||
lblDesc.Location = new Point(36, 11);
|
||||
lblDesc.Margin = new Padding(4, 0, 4, 0);
|
||||
lblDesc.Name = "lblDesc";
|
||||
lblDesc.Size = new Size(31, 13);
|
||||
lblDesc.TabIndex = 1;
|
||||
lblDesc.Text = "XXXX";
|
||||
lblDesc.TextAlign = ContentAlignment.MiddleLeft;
|
||||
lblDesc.DoubleClick += lblDesc_DoubleClick;
|
||||
//
|
||||
// IOIndicatorCtrl
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(lblDesc);
|
||||
Controls.Add(plStatus);
|
||||
Margin = new Padding(4);
|
||||
Name = "IOIndicatorCtrl";
|
||||
Size = new Size(138, 34);
|
||||
ResumeLayout(false);
|
||||
PerformLayout();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel plStatus;
|
||||
private Label lblDesc;
|
||||
}
|
||||
}
|
||||
126
DH.UI.Model.Winform/IOIndicatorCtrl.cs
Normal file
126
DH.UI.Model.Winform/IOIndicatorCtrl.cs
Normal file
@@ -0,0 +1,126 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace XKRS.UI.Model.Winform
|
||||
{
|
||||
public partial class IOIndicatorCtrl : UserControl
|
||||
{
|
||||
public IOIndicatorCtrl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
private bool isON = false;
|
||||
|
||||
public bool IsOn
|
||||
{
|
||||
get => isON;
|
||||
set
|
||||
{
|
||||
bool? temp = isON;
|
||||
isON = value;
|
||||
|
||||
if (temp != isON)
|
||||
{
|
||||
RefreshStatus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshStatus()
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new Action(() => RefreshStatus()));
|
||||
}
|
||||
else
|
||||
{
|
||||
plStatus.Invalidate();
|
||||
}
|
||||
}
|
||||
|
||||
private string desc = "";
|
||||
public string Desc
|
||||
{
|
||||
get => desc;
|
||||
set
|
||||
{
|
||||
desc = value;
|
||||
|
||||
DisplayDesc();
|
||||
}
|
||||
}
|
||||
|
||||
public int Index { get; set; }
|
||||
|
||||
private void DisplayDesc()
|
||||
{
|
||||
if (InvokeRequired)
|
||||
{
|
||||
Invoke(new Action(() => DisplayDesc()));
|
||||
}
|
||||
else
|
||||
{
|
||||
lblDesc.Text = Desc;
|
||||
}
|
||||
}
|
||||
|
||||
readonly PointF[] regionBlink = new PointF[]
|
||||
{
|
||||
new PointF(5,10),
|
||||
new PointF(10,13),
|
||||
new PointF(12,7),
|
||||
new PointF(10,5)
|
||||
};
|
||||
|
||||
public IOIndicatorCtrl(bool _isOn, string _desc, int index = 0)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
IsOn = _isOn;
|
||||
Desc = _desc;
|
||||
Index = index;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新绘制图标
|
||||
/// </summary>
|
||||
/// <param name="sender"></param>
|
||||
/// <param name="e"></param>
|
||||
private void plStatus_Paint(object sender, PaintEventArgs e)
|
||||
{
|
||||
Panel pl = sender as Panel;
|
||||
|
||||
Graphics g = e.Graphics;
|
||||
|
||||
g.Clear(SystemColors.Control);
|
||||
|
||||
|
||||
if (IsOn)
|
||||
{
|
||||
g.FillEllipse(Brushes.LightGreen, pl.ClientRectangle);
|
||||
}
|
||||
else
|
||||
{
|
||||
g.FillEllipse(Brushes.Gray, pl.ClientRectangle);
|
||||
}
|
||||
|
||||
g.FillPolygon(Brushes.White, regionBlink);
|
||||
|
||||
}
|
||||
|
||||
public event Action<string, bool, int> OnIODoubleClick;
|
||||
|
||||
|
||||
private void lblDesc_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
OnIODoubleClick?.Invoke(Name, IsOn, Index);
|
||||
}
|
||||
|
||||
private void plStatus_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
OnIODoubleClick?.Invoke(Name, IsOn, Index);
|
||||
}
|
||||
}
|
||||
}
|
||||
120
DH.UI.Model.Winform/IOIndicatorCtrl.resx
Normal file
120
DH.UI.Model.Winform/IOIndicatorCtrl.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>
|
||||
@@ -17,8 +17,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Commons", "Commons", "{0AB4
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DH.Commons", "DH.Commons\DH.Commons.csproj", "{027373EC-C5CB-4161-8D43-AB6009371FDE}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DH.Devices.Vision", "DH.Devices.Vision\DH.Devices.Vision.csproj", "{97B55FCF-54A3-449E-8437-735E65C35291}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DH.Devices.Camera", "DH.Devices.Camera\DH.Devices.Camera.csproj", "{1378A932-1C25-40EF-BA31-A3463B23F4E5}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DH.Devices.PLC", "DH.Devices.PLC\DH.Devices.PLC.csproj", "{458B2CF6-6F1B-4B8B-BB85-C6FD7F453A5D}"
|
||||
@@ -27,6 +25,14 @@ 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}"
|
||||
EndProject
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DH.Devices.Vision", "DH.Devices.Vision\DH.Devices.Vision.csproj", "{5AD3A29E-149A-4C37-9548-7638A36C8175}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
@@ -51,14 +57,6 @@ Global
|
||||
{027373EC-C5CB-4161-8D43-AB6009371FDE}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{027373EC-C5CB-4161-8D43-AB6009371FDE}.Release|x64.ActiveCfg = Release|x64
|
||||
{027373EC-C5CB-4161-8D43-AB6009371FDE}.Release|x64.Build.0 = Release|x64
|
||||
{97B55FCF-54A3-449E-8437-735E65C35291}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{97B55FCF-54A3-449E-8437-735E65C35291}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{97B55FCF-54A3-449E-8437-735E65C35291}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{97B55FCF-54A3-449E-8437-735E65C35291}.Debug|x64.Build.0 = Debug|x64
|
||||
{97B55FCF-54A3-449E-8437-735E65C35291}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{97B55FCF-54A3-449E-8437-735E65C35291}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{97B55FCF-54A3-449E-8437-735E65C35291}.Release|x64.ActiveCfg = Release|x64
|
||||
{97B55FCF-54A3-449E-8437-735E65C35291}.Release|x64.Build.0 = Release|x64
|
||||
{1378A932-1C25-40EF-BA31-A3463B23F4E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{1378A932-1C25-40EF-BA31-A3463B23F4E5}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{1378A932-1C25-40EF-BA31-A3463B23F4E5}.Debug|x64.ActiveCfg = Debug|x64
|
||||
@@ -83,6 +81,30 @@ 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
|
||||
{12CB9041-B1B1-41AE-B308-AABDACAA580E}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{12CB9041-B1B1-41AE-B308-AABDACAA580E}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{12CB9041-B1B1-41AE-B308-AABDACAA580E}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{12CB9041-B1B1-41AE-B308-AABDACAA580E}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{12CB9041-B1B1-41AE-B308-AABDACAA580E}.Release|x64.Build.0 = Release|Any CPU
|
||||
{5AD3A29E-149A-4C37-9548-7638A36C8175}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{5AD3A29E-149A-4C37-9548-7638A36C8175}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{5AD3A29E-149A-4C37-9548-7638A36C8175}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{5AD3A29E-149A-4C37-9548-7638A36C8175}.Debug|x64.Build.0 = Debug|x64
|
||||
{5AD3A29E-149A-4C37-9548-7638A36C8175}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{5AD3A29E-149A-4C37-9548-7638A36C8175}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{5AD3A29E-149A-4C37-9548-7638A36C8175}.Release|x64.ActiveCfg = Release|x64
|
||||
{5AD3A29E-149A-4C37-9548-7638A36C8175}.Release|x64.Build.0 = Release|x64
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
@@ -92,11 +114,13 @@ Global
|
||||
{1591B03B-0015-42FC-B784-0D9F740E2A23} = {8EC33C16-65CE-4C12-9C8D-DB2425F9F7C0}
|
||||
{F77AF94C-280D-44C5-B7C0-FC86AA9EC504} = {8EC33C16-65CE-4C12-9C8D-DB2425F9F7C0}
|
||||
{027373EC-C5CB-4161-8D43-AB6009371FDE} = {0AB4BB9A-A861-4F80-B549-CD331490942B}
|
||||
{97B55FCF-54A3-449E-8437-735E65C35291} = {F77AF94C-280D-44C5-B7C0-FC86AA9EC504}
|
||||
{1378A932-1C25-40EF-BA31-A3463B23F4E5} = {1591B03B-0015-42FC-B784-0D9F740E2A23}
|
||||
{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}
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
SolutionGuid = {6FC1A8DF-636E-434C-981E-10F20FAD723B}
|
||||
|
||||
@@ -12,20 +12,18 @@
|
||||
<OutputType>WinExe</OutputType>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="Views\CamConfigFrm.cs" />
|
||||
<Compile Include="Views\CamConfigFrm.Designer.cs" />
|
||||
<Compile Include="Views\UserConfigFrm.cs" />
|
||||
<Compile Include="Views\UserConfigFrm.Designer.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Views\CamConfigFrm.resx" />
|
||||
<EmbeddedResource Include="Views\UserConfigFrm.resx" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AntdUI" Version="1.8.9" />
|
||||
<PackageReference Include="AntdUI" Version="1.9.3" />
|
||||
<PackageReference Include="System.IO.Ports" Version="9.0.2" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -34,6 +32,7 @@
|
||||
<ProjectReference Include="..\DH.Devices.Motion\DH.Devices.Motion.csproj" />
|
||||
<ProjectReference Include="..\DH.Devices.PLC\DH.Devices.PLC.csproj" />
|
||||
<ProjectReference Include="..\DH.Devices.Vision\DH.Devices.Vision.csproj" />
|
||||
<ProjectReference Include="..\DH.UI.Model.Winform\DH.UI.Model.Winform.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
220
DHSoftware/MainWindow.Designer.cs
generated
220
DHSoftware/MainWindow.Designer.cs
generated
@@ -47,17 +47,15 @@
|
||||
panel2 = new AntdUI.Panel();
|
||||
panel4 = new AntdUI.Panel();
|
||||
panel6 = new AntdUI.Panel();
|
||||
splitContainer1 = new SplitContainer();
|
||||
splitContainer2 = new SplitContainer();
|
||||
tabImgDisplay = new AntdUI.Tabs();
|
||||
tabPage1 = new AntdUI.TabPage();
|
||||
panel5 = new AntdUI.Panel();
|
||||
tabs3 = new AntdUI.Tabs();
|
||||
tabMain = new AntdUI.TabPage();
|
||||
tabsStas = new AntdUI.Tabs();
|
||||
tabPage3 = new AntdUI.TabPage();
|
||||
richTextBox1 = new RichTextBox();
|
||||
divider3 = new AntdUI.Divider();
|
||||
panel3 = new AntdUI.Panel();
|
||||
tabs2 = new AntdUI.Tabs();
|
||||
tabsConfig = new AntdUI.Tabs();
|
||||
tabPage2 = new AntdUI.TabPage();
|
||||
divider1 = new AntdUI.Divider();
|
||||
panel1 = new AntdUI.Panel();
|
||||
segmented1 = new AntdUI.Segmented();
|
||||
titlebar.SuspendLayout();
|
||||
@@ -66,12 +64,18 @@
|
||||
panel2.SuspendLayout();
|
||||
panel4.SuspendLayout();
|
||||
panel6.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)splitContainer1).BeginInit();
|
||||
splitContainer1.Panel1.SuspendLayout();
|
||||
splitContainer1.Panel2.SuspendLayout();
|
||||
splitContainer1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)splitContainer2).BeginInit();
|
||||
splitContainer2.Panel1.SuspendLayout();
|
||||
splitContainer2.Panel2.SuspendLayout();
|
||||
splitContainer2.SuspendLayout();
|
||||
tabImgDisplay.SuspendLayout();
|
||||
panel5.SuspendLayout();
|
||||
tabs3.SuspendLayout();
|
||||
tabsStas.SuspendLayout();
|
||||
tabPage3.SuspendLayout();
|
||||
panel3.SuspendLayout();
|
||||
tabs2.SuspendLayout();
|
||||
tabsConfig.SuspendLayout();
|
||||
panel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
@@ -139,7 +143,7 @@
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(61, 10);
|
||||
label1.Location = new Point(979, 10);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(64, 21);
|
||||
label1.TabIndex = 1;
|
||||
@@ -148,10 +152,10 @@
|
||||
// divider2
|
||||
//
|
||||
divider2.Dock = DockStyle.Top;
|
||||
divider2.Location = new Point(0, 0);
|
||||
divider2.Location = new Point(54, 0);
|
||||
divider2.Name = "divider2";
|
||||
divider2.OrientationMargin = 0F;
|
||||
divider2.Size = new Size(1024, 10);
|
||||
divider2.Size = new Size(970, 10);
|
||||
divider2.TabIndex = 0;
|
||||
divider2.Text = "";
|
||||
//
|
||||
@@ -169,7 +173,6 @@
|
||||
// panel2
|
||||
//
|
||||
panel2.Controls.Add(panel4);
|
||||
panel2.Controls.Add(panel3);
|
||||
panel2.Dock = DockStyle.Fill;
|
||||
panel2.Location = new Point(0, 68);
|
||||
panel2.Name = "panel2";
|
||||
@@ -180,71 +183,100 @@
|
||||
// panel4
|
||||
//
|
||||
panel4.Controls.Add(panel6);
|
||||
panel4.Controls.Add(panel5);
|
||||
panel4.Dock = DockStyle.Fill;
|
||||
panel4.Location = new Point(0, 0);
|
||||
panel4.Name = "panel4";
|
||||
panel4.Size = new Size(661, 500);
|
||||
panel4.Size = new Size(1024, 500);
|
||||
panel4.TabIndex = 1;
|
||||
panel4.Text = "panel4";
|
||||
//
|
||||
// panel6
|
||||
//
|
||||
panel6.Controls.Add(tabImgDisplay);
|
||||
panel6.Controls.Add(splitContainer1);
|
||||
panel6.Dock = DockStyle.Fill;
|
||||
panel6.Location = new Point(0, 0);
|
||||
panel6.Name = "panel6";
|
||||
panel6.Size = new Size(661, 358);
|
||||
panel6.Size = new Size(1024, 500);
|
||||
panel6.TabIndex = 1;
|
||||
panel6.Text = "panel6";
|
||||
//
|
||||
// splitContainer1
|
||||
//
|
||||
splitContainer1.BackColor = SystemColors.Control;
|
||||
splitContainer1.Dock = DockStyle.Fill;
|
||||
splitContainer1.Location = new Point(0, 0);
|
||||
splitContainer1.Name = "splitContainer1";
|
||||
//
|
||||
// splitContainer1.Panel1
|
||||
//
|
||||
splitContainer1.Panel1.Controls.Add(splitContainer2);
|
||||
//
|
||||
// splitContainer1.Panel2
|
||||
//
|
||||
splitContainer1.Panel2.BackColor = SystemColors.ButtonFace;
|
||||
splitContainer1.Panel2.Controls.Add(tabsConfig);
|
||||
splitContainer1.Size = new Size(1024, 500);
|
||||
splitContainer1.SplitterDistance = 580;
|
||||
splitContainer1.SplitterIncrement = 2;
|
||||
splitContainer1.SplitterWidth = 10;
|
||||
splitContainer1.TabIndex = 0;
|
||||
//
|
||||
// splitContainer2
|
||||
//
|
||||
splitContainer2.Dock = DockStyle.Fill;
|
||||
splitContainer2.Location = new Point(0, 0);
|
||||
splitContainer2.Name = "splitContainer2";
|
||||
splitContainer2.Orientation = Orientation.Horizontal;
|
||||
//
|
||||
// splitContainer2.Panel1
|
||||
//
|
||||
splitContainer2.Panel1.Controls.Add(tabImgDisplay);
|
||||
//
|
||||
// splitContainer2.Panel2
|
||||
//
|
||||
splitContainer2.Panel2.Controls.Add(tabsStas);
|
||||
splitContainer2.Size = new Size(580, 500);
|
||||
splitContainer2.SplitterDistance = 320;
|
||||
splitContainer2.TabIndex = 0;
|
||||
//
|
||||
// tabImgDisplay
|
||||
//
|
||||
tabImgDisplay.Controls.Add(tabMain);
|
||||
tabImgDisplay.Dock = DockStyle.Fill;
|
||||
tabImgDisplay.Location = new Point(0, 0);
|
||||
tabImgDisplay.Name = "tabImgDisplay";
|
||||
tabImgDisplay.Pages.Add(tabPage1);
|
||||
tabImgDisplay.Size = new Size(661, 358);
|
||||
tabImgDisplay.Pages.Add(tabMain);
|
||||
tabImgDisplay.Size = new Size(580, 320);
|
||||
tabImgDisplay.Style = styleCard1;
|
||||
tabImgDisplay.TabIndex = 0;
|
||||
tabImgDisplay.TabIndex = 1;
|
||||
tabImgDisplay.Text = "tabs1";
|
||||
//
|
||||
// tabPage1
|
||||
// tabMain
|
||||
//
|
||||
tabPage1.Location = new Point(3, 28);
|
||||
tabPage1.Name = "tabPage1";
|
||||
tabPage1.Size = new Size(655, 327);
|
||||
tabPage1.TabIndex = 0;
|
||||
tabPage1.Text = "检测";
|
||||
tabMain.Location = new Point(3, 28);
|
||||
tabMain.Name = "tabMain";
|
||||
tabMain.Size = new Size(574, 289);
|
||||
tabMain.TabIndex = 0;
|
||||
tabMain.Text = "检测";
|
||||
//
|
||||
// panel5
|
||||
// tabsStas
|
||||
//
|
||||
panel5.Controls.Add(tabs3);
|
||||
panel5.Controls.Add(divider3);
|
||||
panel5.Dock = DockStyle.Bottom;
|
||||
panel5.Location = new Point(0, 358);
|
||||
panel5.Name = "panel5";
|
||||
panel5.Size = new Size(661, 142);
|
||||
panel5.TabIndex = 0;
|
||||
panel5.Text = "panel5";
|
||||
//
|
||||
// tabs3
|
||||
//
|
||||
tabs3.Dock = DockStyle.Fill;
|
||||
tabs3.Location = new Point(0, 10);
|
||||
tabs3.Name = "tabs3";
|
||||
tabs3.Pages.Add(tabPage3);
|
||||
tabs3.Size = new Size(661, 132);
|
||||
tabs3.Style = styleCard2;
|
||||
tabs3.TabIndex = 2;
|
||||
tabs3.Text = "tabs3";
|
||||
tabsStas.Controls.Add(tabPage3);
|
||||
tabsStas.Dock = DockStyle.Fill;
|
||||
tabsStas.Location = new Point(0, 0);
|
||||
tabsStas.Name = "tabsStas";
|
||||
tabsStas.Pages.Add(tabPage3);
|
||||
tabsStas.Size = new Size(580, 176);
|
||||
tabsStas.Style = styleCard2;
|
||||
tabsStas.TabIndex = 3;
|
||||
tabsStas.Text = "tabs3";
|
||||
//
|
||||
// tabPage3
|
||||
//
|
||||
tabPage3.Controls.Add(richTextBox1);
|
||||
tabPage3.Location = new Point(3, 28);
|
||||
tabPage3.Name = "tabPage3";
|
||||
tabPage3.Size = new Size(655, 101);
|
||||
tabPage3.Size = new Size(574, 145);
|
||||
tabPage3.TabIndex = 0;
|
||||
tabPage3.Text = "日志";
|
||||
//
|
||||
@@ -253,61 +285,30 @@
|
||||
richTextBox1.Dock = DockStyle.Fill;
|
||||
richTextBox1.Location = new Point(0, 0);
|
||||
richTextBox1.Name = "richTextBox1";
|
||||
richTextBox1.Size = new Size(655, 101);
|
||||
richTextBox1.Size = new Size(574, 145);
|
||||
richTextBox1.TabIndex = 0;
|
||||
richTextBox1.Text = "";
|
||||
//
|
||||
// divider3
|
||||
// tabsConfig
|
||||
//
|
||||
divider3.Dock = DockStyle.Top;
|
||||
divider3.Location = new Point(0, 0);
|
||||
divider3.Name = "divider3";
|
||||
divider3.OrientationMargin = 0F;
|
||||
divider3.Size = new Size(661, 10);
|
||||
divider3.TabIndex = 1;
|
||||
divider3.Text = "";
|
||||
//
|
||||
// panel3
|
||||
//
|
||||
panel3.Controls.Add(tabs2);
|
||||
panel3.Controls.Add(divider1);
|
||||
panel3.Dock = DockStyle.Right;
|
||||
panel3.Location = new Point(661, 0);
|
||||
panel3.Name = "panel3";
|
||||
panel3.Size = new Size(363, 500);
|
||||
panel3.TabIndex = 0;
|
||||
panel3.Text = "panel3";
|
||||
//
|
||||
// tabs2
|
||||
//
|
||||
tabs2.Dock = DockStyle.Fill;
|
||||
tabs2.Location = new Point(10, 0);
|
||||
tabs2.Name = "tabs2";
|
||||
tabs2.Pages.Add(tabPage2);
|
||||
tabs2.Size = new Size(353, 500);
|
||||
tabs2.Style = styleCard3;
|
||||
tabs2.TabIndex = 1;
|
||||
tabs2.Text = "tabs2";
|
||||
tabsConfig.Controls.Add(tabPage2);
|
||||
tabsConfig.Dock = DockStyle.Fill;
|
||||
tabsConfig.Location = new Point(0, 0);
|
||||
tabsConfig.Name = "tabsConfig";
|
||||
tabsConfig.Pages.Add(tabPage2);
|
||||
tabsConfig.Size = new Size(434, 500);
|
||||
tabsConfig.Style = styleCard3;
|
||||
tabsConfig.TabIndex = 2;
|
||||
tabsConfig.Text = "tabs2";
|
||||
//
|
||||
// tabPage2
|
||||
//
|
||||
tabPage2.Location = new Point(3, 28);
|
||||
tabPage2.Name = "tabPage2";
|
||||
tabPage2.Size = new Size(347, 469);
|
||||
tabPage2.Size = new Size(428, 469);
|
||||
tabPage2.TabIndex = 0;
|
||||
tabPage2.Text = "配置";
|
||||
//
|
||||
// divider1
|
||||
//
|
||||
divider1.Dock = DockStyle.Left;
|
||||
divider1.Location = new Point(0, 0);
|
||||
divider1.Name = "divider1";
|
||||
divider1.OrientationMargin = 0F;
|
||||
divider1.Size = new Size(10, 500);
|
||||
divider1.TabIndex = 0;
|
||||
divider1.Text = "";
|
||||
divider1.Vertical = true;
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Back = SystemColors.MenuHighlight;
|
||||
@@ -418,12 +419,18 @@
|
||||
panel2.ResumeLayout(false);
|
||||
panel4.ResumeLayout(false);
|
||||
panel6.ResumeLayout(false);
|
||||
splitContainer1.Panel1.ResumeLayout(false);
|
||||
splitContainer1.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)splitContainer1).EndInit();
|
||||
splitContainer1.ResumeLayout(false);
|
||||
splitContainer2.Panel1.ResumeLayout(false);
|
||||
splitContainer2.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)splitContainer2).EndInit();
|
||||
splitContainer2.ResumeLayout(false);
|
||||
tabImgDisplay.ResumeLayout(false);
|
||||
panel5.ResumeLayout(false);
|
||||
tabs3.ResumeLayout(false);
|
||||
tabsStas.ResumeLayout(false);
|
||||
tabPage3.ResumeLayout(false);
|
||||
panel3.ResumeLayout(false);
|
||||
tabs2.ResumeLayout(false);
|
||||
tabsConfig.ResumeLayout(false);
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
@@ -441,17 +448,16 @@
|
||||
private AntdUI.Panel panel2;
|
||||
private AntdUI.Panel panel4;
|
||||
private AntdUI.Panel panel6;
|
||||
private AntdUI.Panel panel5;
|
||||
private AntdUI.Panel panel3;
|
||||
private AntdUI.Tabs tabImgDisplay;
|
||||
private AntdUI.TabPage tabPage1;
|
||||
private AntdUI.Tabs tabs3;
|
||||
private AntdUI.TabPage tabPage3;
|
||||
private AntdUI.Divider divider3;
|
||||
private AntdUI.Tabs tabs2;
|
||||
private AntdUI.TabPage tabPage2;
|
||||
private AntdUI.Divider divider1;
|
||||
private RichTextBox richTextBox1;
|
||||
private Label label1;
|
||||
private AntdUI.Splitter splitter1;
|
||||
private SplitContainer splitContainer1;
|
||||
private SplitContainer splitContainer2;
|
||||
private AntdUI.Tabs tabImgDisplay;
|
||||
private AntdUI.TabPage tabMain;
|
||||
private AntdUI.Tabs tabsStas;
|
||||
private AntdUI.TabPage tabPage3;
|
||||
private RichTextBox richTextBox1;
|
||||
private AntdUI.Tabs tabsConfig;
|
||||
private AntdUI.TabPage tabPage2;
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,14 @@
|
||||
using AntdUI.Svg;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Camera;
|
||||
using DH.Devices.Devices;
|
||||
using DH.Devices.Motion;
|
||||
using DH.Devices.PLC;
|
||||
using DH.Devices.Vision;
|
||||
using DHSoftware.Languages;
|
||||
using DHSoftware.Models;
|
||||
using DHSoftware.Utils;
|
||||
using DHSoftware.Views;
|
||||
using DVPCameraType;
|
||||
using HalconDotNet;
|
||||
using Microsoft.Win32;
|
||||
@@ -24,7 +26,7 @@ using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using XKRS.Common.Model;
|
||||
using XKRS.UI.Device.Winform;
|
||||
using static AntdUI.Math3D;
|
||||
using Camera = DHSoftware.Models.Camera;
|
||||
|
||||
@@ -57,84 +59,89 @@ namespace DHSoftware
|
||||
InitData();
|
||||
//绑定事件
|
||||
BindEventHandler();
|
||||
tabImgDisplay.Pages.Clear();
|
||||
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"
|
||||
}
|
||||
};
|
||||
UserConfigFrm userControlFrm = new UserConfigFrm();
|
||||
|
||||
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);
|
||||
userControlFrm.Window = this;
|
||||
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;
|
||||
//// 获取相机1的控件(通过控件名称查找)
|
||||
//var targetControl = FindControlRecursive(tabImgDisplay, "picCam1") as PictureBox;
|
||||
|
||||
if (targetControl != null)
|
||||
{
|
||||
// 生成测试路径(示例路径)
|
||||
string testPath = $@"D:\{testCounter}.png"; // 循环1-5的图片
|
||||
testCounter++;
|
||||
//if (targetControl != null)
|
||||
//{
|
||||
// // 生成测试路径(示例路径)
|
||||
// string testPath = $@"D:\{testCounter}.png"; // 循环1-5的图片
|
||||
// testCounter++;
|
||||
|
||||
// 加载并显示图片
|
||||
targetControl.Image = Image.FromFile(testPath);
|
||||
if (testCounter == 5)
|
||||
{
|
||||
testCounter = 1;
|
||||
}
|
||||
targetControl.Parent.Invalidate();
|
||||
}
|
||||
// // 加载并显示图片
|
||||
// targetControl.Image = Image.FromFile(testPath);
|
||||
// if (testCounter == 5)
|
||||
// {
|
||||
// testCounter = 1;
|
||||
// }
|
||||
// targetControl.Parent.Invalidate();
|
||||
//}
|
||||
}
|
||||
// 递归查找控件的方法
|
||||
private Control FindControlRecursive(Control parent, string name)
|
||||
@@ -215,7 +222,7 @@ namespace DHSoftware
|
||||
|
||||
|
||||
|
||||
public List<HikVisionCamera> HKCameras { get; } = new List<HikVisionCamera>();
|
||||
public List<Camera> HKCameras { get; } = new List<Camera>();
|
||||
public List<Do3ThinkCamera> Cameras { get; } = new List<Do3ThinkCamera>();
|
||||
public Dictionary<string, SimboObjectDetection> Dectection { get; } = new Dictionary<string, SimboObjectDetection>();
|
||||
public XinJEPLCTcpNet PLC { get; } = new XinJEPLCTcpNet();
|
||||
@@ -233,7 +240,8 @@ namespace DHSoftware
|
||||
}
|
||||
foreach (var camera in HKCameras)
|
||||
{
|
||||
camera.CameraDisConnect();
|
||||
//var hk as HikVisionCamera;
|
||||
//camera.CameraDisConnect();
|
||||
}
|
||||
PLC.PLCDisConnect();
|
||||
}
|
||||
@@ -269,6 +277,7 @@ namespace DHSoftware
|
||||
public volatile int ProductNum_Total = 0;
|
||||
public volatile int ProductNum_OK = 0;
|
||||
private readonly object _cameraSummaryLock = new object();
|
||||
public SimboVisionDriver? _visionEngine = null;
|
||||
List<DetectionConfig> DetectionConfigs = new List<DetectionConfig>();
|
||||
List<SimboStationMLEngineSet> SimboStationMLEngineList = new List<SimboStationMLEngineSet>();
|
||||
Dictionary<string, HDevEngineTool> HalconToolDict = new Dictionary<string, HDevEngineTool>();
|
||||
@@ -277,6 +286,8 @@ namespace DHSoftware
|
||||
private void HandleStartButton()
|
||||
{
|
||||
CurrentMachine = true;
|
||||
|
||||
//_visionEngine.Start();
|
||||
//[Category("深度学习检测配置")]
|
||||
//[DisplayName("检测标签定义集合")]
|
||||
//[Description("定义检测标签的集合,例如:Seg/Detection模式:断裂、油污、划伤...;Class模式:ok、ng、上面、下面、套环、正常...")]
|
||||
@@ -340,6 +351,8 @@ namespace DHSoftware
|
||||
det1.ModelHeight = 640;
|
||||
det1.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam1.txt";
|
||||
det1.IsEnabled = true;
|
||||
det1.ShowLocation.X = 1;
|
||||
det1.ShowLocation.Y = 1;
|
||||
|
||||
det2.CameraCollects = CameraCollects2;
|
||||
det2.ModelconfThreshold = Conf;
|
||||
@@ -347,6 +360,8 @@ namespace DHSoftware
|
||||
det2.ModelHeight = 640;
|
||||
det2.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam2.txt";
|
||||
det2.IsEnabled = true;
|
||||
det2.ShowLocation.X = 2;
|
||||
det2.ShowLocation.Y = 1;
|
||||
|
||||
det3.CameraCollects = CameraCollects3;
|
||||
det3.ModelconfThreshold = Conf;
|
||||
@@ -354,6 +369,8 @@ namespace DHSoftware
|
||||
det3.ModelHeight = 640;
|
||||
det3.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam3.txt";
|
||||
det3.IsEnabled = true;
|
||||
det3.ShowLocation.X = 3;
|
||||
det3.ShowLocation.Y = 1;
|
||||
|
||||
det4.CameraCollects = CameraCollects4;
|
||||
det4.ModelconfThreshold = Conf;
|
||||
@@ -361,6 +378,8 @@ namespace DHSoftware
|
||||
det4.ModelHeight = 640;
|
||||
det4.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam4.txt";
|
||||
det4.IsEnabled = true;
|
||||
det4.ShowLocation.X = 4;
|
||||
det4.ShowLocation.Y = 1;
|
||||
|
||||
|
||||
|
||||
@@ -370,6 +389,8 @@ namespace DHSoftware
|
||||
det5.ModelHeight = 640;
|
||||
det5.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam5.txt";
|
||||
det5.IsEnabled = true;
|
||||
det5.ShowLocation.X = 1;
|
||||
det5.ShowLocation.Y = 2;
|
||||
|
||||
det6.CameraCollects = CameraCollects6;
|
||||
det6.ModelconfThreshold = Conf;
|
||||
@@ -377,6 +398,8 @@ namespace DHSoftware
|
||||
det6.ModelHeight = 640;
|
||||
det6.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam6.txt";
|
||||
det6.IsEnabled = true;
|
||||
det6.ShowLocation.X = 2;
|
||||
det6.ShowLocation.Y = 2;
|
||||
|
||||
det7.CameraCollects = CameraCollects7;
|
||||
det7.ModelconfThreshold = Conf;
|
||||
@@ -384,6 +407,8 @@ namespace DHSoftware
|
||||
det7.ModelHeight = 640;
|
||||
det7.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam7.txt";
|
||||
det7.IsEnabled = true;
|
||||
det7.ShowLocation.X = 3;
|
||||
det7.ShowLocation.Y = 2;
|
||||
|
||||
det8.CameraCollects = CameraCollects8;
|
||||
det8.ModelconfThreshold = Conf;
|
||||
@@ -391,6 +416,8 @@ namespace DHSoftware
|
||||
det8.ModelHeight = 640;
|
||||
det8.in_lable_path = "D:\\PROJECTS\\X015\\Vision\\Cam8.txt";
|
||||
det8.IsEnabled = true;
|
||||
det8.ShowLocation.X = 4;
|
||||
det8.ShowLocation.Y = 2;
|
||||
|
||||
DetectionConfigs.Add(det1);
|
||||
DetectionConfigs.Add(det2);
|
||||
@@ -476,20 +503,25 @@ namespace DHSoftware
|
||||
|
||||
|
||||
|
||||
_visionEngine = new SimboVisionDriver();
|
||||
_visionEngine.DetectionConfigs = DetectionConfigs;
|
||||
|
||||
_visionEngine.Init();
|
||||
CtrlVisionRunBase ctrlVisionRun = new CtrlVisionRunBase(_visionEngine);
|
||||
tabImgDisplay.Controls.Add(ctrlVisionRun);
|
||||
|
||||
//Add the code for the "启动" button click here
|
||||
|
||||
//初始化Halcon工具
|
||||
InitialHalconTools();
|
||||
////初始化Halcon工具
|
||||
//InitialHalconTools();
|
||||
|
||||
//深度学习模型加载
|
||||
bool resultOK = InitialSimboMLEnginesAsync();
|
||||
if (resultOK)
|
||||
{
|
||||
//初始化失败
|
||||
// return;
|
||||
}
|
||||
////深度学习模型加载
|
||||
//bool resultOK = InitialSimboMLEnginesAsync();
|
||||
//if (resultOK)
|
||||
//{
|
||||
// //初始化失败
|
||||
// // return;
|
||||
//}
|
||||
//位置比较卡
|
||||
|
||||
sLDMotion.AxisSettings = new List<AxisSetting>();
|
||||
@@ -632,7 +664,7 @@ namespace DHSoftware
|
||||
string logStr = $"时间:{DateTime.Now} 轴{axisIndex}新产品{pieceNumber}加入队列{index}----入料计数{PieceCount}\n";
|
||||
Task.Run(() =>
|
||||
{
|
||||
this.BeginInvoke(new MethodInvoker(delegate () { richTextBox1.AppendText(logStr); }));
|
||||
//this.BeginInvoke(new MethodInvoker(delegate () { richTextBox1.AppendText(logStr); }));
|
||||
|
||||
});
|
||||
DateTime dtNow = DateTime.Now;
|
||||
@@ -649,296 +681,6 @@ namespace DHSoftware
|
||||
});
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化深度学习工具
|
||||
/// </summary>
|
||||
private bool InitialSimboMLEnginesAsync()
|
||||
{
|
||||
//深度学习 模型加载
|
||||
var resultOK = MLLoadModel();
|
||||
return resultOK;
|
||||
}
|
||||
/// <summary>
|
||||
/// 深度学习 模型加载
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private bool MLLoadModel()
|
||||
{
|
||||
bool resultOK = false;
|
||||
try
|
||||
{
|
||||
SimboStationMLEngineList = new List<SimboStationMLEngineSet>();
|
||||
// _cameraRelatedDetectionDict = IConfig.DetectionConfigs.Select(t => t.ModelPath).Distinct().ToList();
|
||||
DetectionConfigs.ForEach(dc =>
|
||||
//_cameraRelatedDetectionDict.ForEach(dc =>
|
||||
{
|
||||
|
||||
if (dc.IsEnabled && !string.IsNullOrWhiteSpace(dc.ModelPath))
|
||||
{
|
||||
if (dc.IsEnableGPU)
|
||||
{
|
||||
//if (IIConfig.IsLockGPU)
|
||||
//{
|
||||
//foreach (var validGPU in ValidGPUList2)
|
||||
//{
|
||||
// if (validGPU.DetectionIds.Contains(dc.Id))
|
||||
// {
|
||||
var engine = SingleMLLoadModel(dc, true, 0);
|
||||
SimboStationMLEngineList.Add(engine);
|
||||
// }
|
||||
//}
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// foreach (var validGPU in ValidGPUList)
|
||||
// {
|
||||
// //var validGPU = ValidGPUList.FirstOrDefault(u => u.DetectionIds.Contains(dc.Id));
|
||||
// if (validGPU.DetectionId == dc.Id)
|
||||
// {
|
||||
// var engine = SingleMLLoadModel(dc, true, validGPU.GPUNo);
|
||||
// SimboStationMLEngineList.Add(engine);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
//for (int i = 0; i < IConfig.CPUNums; i++)
|
||||
for (int i = 0; i < 1; i++)
|
||||
{
|
||||
//var engine = SingleMLLoadModel(dc, false, i);
|
||||
var engine = SingleMLLoadModel(dc, false, i);
|
||||
SimboStationMLEngineList.Add(engine);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
resultOK = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception, $"异常:模型并发加载异常:{ex.GetExceptionMessage()}");
|
||||
resultOK = false;
|
||||
}
|
||||
|
||||
return resultOK;
|
||||
}
|
||||
/// <summary>
|
||||
/// 单个模型加载
|
||||
/// </summary>
|
||||
/// <param name="dc"></param>
|
||||
/// <param name="gpuNum"></param>
|
||||
/// <returns></returns>
|
||||
private SimboStationMLEngineSet SingleMLLoadModel(DetectionConfig dc, bool isGPU, int coreInx)
|
||||
{
|
||||
SimboStationMLEngineSet mLEngineSet = new SimboStationMLEngineSet();
|
||||
try
|
||||
{
|
||||
mLEngineSet.IsUseGPU = isGPU;
|
||||
if (isGPU)
|
||||
{
|
||||
mLEngineSet.GPUNo = coreInx;
|
||||
}
|
||||
else
|
||||
{
|
||||
mLEngineSet.CPUNo = coreInx;
|
||||
}
|
||||
mLEngineSet.DetectionId = dc.Id;
|
||||
mLEngineSet.DetectionName = dc.Name;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(dc.ModelPath))
|
||||
{
|
||||
// 根据算法类型创建不同的实例
|
||||
switch (dc.ModelType)
|
||||
{
|
||||
case MLModelType.ImageClassification:
|
||||
break;
|
||||
case MLModelType.ObjectDetection:
|
||||
mLEngineSet.StationMLEngine = new SimboObjectDetection();
|
||||
break;
|
||||
case MLModelType.SemanticSegmentation:
|
||||
|
||||
break;
|
||||
case MLModelType.InstanceSegmentation:
|
||||
mLEngineSet.StationMLEngine = new SimboInstanceSegmentation();
|
||||
break;
|
||||
case MLModelType.ObjectGPUDetection:
|
||||
mLEngineSet.StationMLEngine = new SimboDetection();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
MLInit mLInit;
|
||||
string inferenceDevice = "CPU";
|
||||
if (dc.IsEnableGPU)
|
||||
{
|
||||
inferenceDevice = "GPU";
|
||||
mLInit = new MLInit(dc.ModelPath, isGPU, coreInx, dc.ModelconfThreshold);
|
||||
}
|
||||
else
|
||||
{
|
||||
mLInit = new MLInit(dc.ModelPath, "images", inferenceDevice, (int)dc.ModelWidth, (int)dc.ModelHeight);
|
||||
|
||||
}
|
||||
|
||||
bool isSuccess = mLEngineSet.StationMLEngine.Load(mLInit);
|
||||
if (!isSuccess)
|
||||
{
|
||||
// throw new ProcessException("异常:模型加载异常", null);
|
||||
}
|
||||
//LogAsync(DateTime.Now, LogLevel.Information, $"模型加载成功;是否GPU:{isGPU} CoreInx:{coreInx} - {dc.Name}" + $" {dc.ModelType.GetEnumDescription()}:{dc.ModelPath}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
//throw new ProcessException($"异常:是否GPU:{isGPU} CoreInx:{coreInx} - {dc.Name}模型加载异常:{ex.GetExceptionMessage()}");
|
||||
}
|
||||
return mLEngineSet;
|
||||
}
|
||||
private void InitialHalconTools()
|
||||
{
|
||||
HOperatorSet.SetSystem("parallelize_operators", "true");
|
||||
HOperatorSet.SetSystem("reentrant", "true");
|
||||
HOperatorSet.SetSystem("global_mem_cache", "exclusive");
|
||||
|
||||
HalconToolDict = new Dictionary<string, HDevEngineTool>();
|
||||
|
||||
DetectionConfigs.ForEach(c =>
|
||||
{
|
||||
if (!c.IsEnabled)
|
||||
return;
|
||||
|
||||
if (c.HalconAlgorithemPath_Pre != null)
|
||||
LoadHalconTool(c.HalconAlgorithemPath_Pre);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void LoadHalconTool(string path)
|
||||
{
|
||||
if (!HalconToolDict.ContainsKey(path))
|
||||
{
|
||||
|
||||
|
||||
string algorithemPath = path;
|
||||
|
||||
if (string.IsNullOrWhiteSpace(algorithemPath))
|
||||
return;
|
||||
|
||||
string directoryPath = Path.GetDirectoryName(algorithemPath);
|
||||
string fileName = Path.GetFileNameWithoutExtension(algorithemPath);
|
||||
|
||||
HDevEngineTool tool = new HDevEngineTool(directoryPath);
|
||||
tool.LoadProcedure(fileName);
|
||||
|
||||
HalconToolDict[path] = tool;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 预处理
|
||||
/// </summary>
|
||||
/// <param name="detectConfig"></param>
|
||||
/// <param name="detectResult"></param>
|
||||
public void PreTreated(DetectionConfig detectConfig, DetectStationResult detectResult, Mat MhImage)
|
||||
{
|
||||
try
|
||||
{
|
||||
// detectResult.VisionImageSet.DetectionOriginImage = detectResult.VisionImageSet.HImage.ConvertHImageToBitmap();
|
||||
//detectResult.VisionImageSet.PreTreatedBitmap = detectResult.VisionImageSet.HImage.ConvertHImageToBitmap();
|
||||
//detectResult.VisionImageSet.DetectionResultImage = detectResult.VisionImageSet.PreTreatedBitmap?.CopyBitmap();
|
||||
if (!string.IsNullOrWhiteSpace(detectConfig.HalconAlgorithemPath_Pre))
|
||||
{
|
||||
HObject obj = OpenCVHelper.MatToHImage(MhImage);
|
||||
HImage hImage = HalconHelper.ConvertHObjectToHImage(obj);
|
||||
string toolKey = detectConfig.HalconAlgorithemPath_Pre;
|
||||
if (!HalconToolDict.ContainsKey(toolKey))
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception, $"{detectConfig.Name}未获取预处理算法");
|
||||
return;
|
||||
}
|
||||
//Mean_Thre Deviation_Thre Mean_standard Deviation_standard
|
||||
var tool = HalconToolDict[toolKey];
|
||||
|
||||
////tool.InputTupleDic["Mean_Thre"] = 123;
|
||||
for (int i = 0; i < detectConfig.PreTreatParams.Count; i++)
|
||||
{
|
||||
var param = detectConfig.PreTreatParams[i];
|
||||
tool.InputTupleDic[param.Name] = double.Parse(param.Value);
|
||||
}
|
||||
|
||||
// tool.InputTupleDic["fCricularity"] = 200;
|
||||
|
||||
tool.InputImageDic["INPUT_Image"] = hImage;
|
||||
|
||||
|
||||
if (!tool.RunProcedure(out string errorMsg, out _))
|
||||
{
|
||||
// detectResult.PreTreatedFlag = false;
|
||||
|
||||
detectResult.IsPreTreatDone = false;
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
var preTreatRet = tool.GetResultTuple("OUTPUT_Flag").I;
|
||||
|
||||
//var fRCricularity = tool.GetResultTuple("fRCricularity");
|
||||
|
||||
|
||||
// detectResult.IsPreTreatDone = detectResult.VisionImageSet.PreTreatedFlag = preTreatRet == 1;
|
||||
//detectResult.IsPreTreatDone = detectResult.VisionImageSet.PreTreatedFlag = true;
|
||||
// detectResult.VisionImageSet.PreTreatedTime = DateTime.Now;
|
||||
|
||||
for (int i = 0; i < detectConfig.OUTPreTreatParams.Count; i++)
|
||||
{
|
||||
var param = detectConfig.OUTPreTreatParams[i];
|
||||
tool.InputTupleDic[param.Name] = double.Parse(param.Value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// 2023/10/16 新增预处理结果反馈,如果预处理结果为NG,直接返回
|
||||
if (preTreatRet != 0)
|
||||
{
|
||||
detectResult.ResultState = ResultState.DetectNG;
|
||||
|
||||
detectResult.IsPreTreatNG = true;
|
||||
|
||||
|
||||
|
||||
// if (detectResult.VisionImageSet.PreTreatedFlag)
|
||||
{
|
||||
//detectResult.VisionImageSet.MLImage = tool.GetResultObject("OUTPUT_PreTreatedImage");
|
||||
//DetectionResultImage
|
||||
// detectResult.VisionImageSet.DetectionResultImage = detectResult.VisionImageSet.MLImage.ConvertHImageToBitmap();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
// detectResult.VisionImageSet.DetectionResultImage = detectResult.VisionImageSet.MLImage.ConvertHImageToBitmap();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
finally
|
||||
{
|
||||
//detectResult.VisionImageSet.HImage?.Dispose();
|
||||
//detectResult.VisionImageSet.HImage = null;
|
||||
// MhImage?.Dispose();
|
||||
//MhImage = null;
|
||||
}
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 相机回调
|
||||
/// </summary>
|
||||
/// <param name="dt"></param>
|
||||
@@ -1032,7 +774,7 @@ namespace DHSoftware
|
||||
|
||||
int currentScrollPosition = richTextBox1.GetPositionFromCharIndex(richTextBox1.TextLength).Y;
|
||||
|
||||
richTextBox1.AppendText(productNumber+"提前推出" + camera.CameraName);
|
||||
richTextBox1.AppendText(productNumber + "提前推出" + camera.CameraName);
|
||||
|
||||
// 设置回原来的滚动位置
|
||||
richTextBox1.SelectionStart = richTextBox1.TextLength;
|
||||
@@ -1042,7 +784,7 @@ namespace DHSoftware
|
||||
|
||||
using (StreamWriter sw = new StreamWriter("D://123log.txt", true, Encoding.UTF8))
|
||||
{
|
||||
sw.WriteLine(productNumber+"提前推出" + camera.CameraName);
|
||||
sw.WriteLine(productNumber + "提前推出" + camera.CameraName);
|
||||
}
|
||||
// LogAsync(DateTime.Now, LogLevel.Warning, $"{camera.Name} 找到产品{productNumber},但是没有推理1");
|
||||
|
||||
@@ -1059,255 +801,18 @@ namespace DHSoftware
|
||||
{
|
||||
string detectionId = detectionDict[i];
|
||||
|
||||
DetectionConfig detectConfig = null;
|
||||
//找到对应的配置
|
||||
if (!string.IsNullOrWhiteSpace(detectionId))
|
||||
{
|
||||
detectConfig = DetectionConfigs.FirstOrDefault(u => u.Id == detectionId);
|
||||
}
|
||||
else
|
||||
{
|
||||
detectConfig = DetectionConfigs.FirstOrDefault(u => u.CameraSourceId == camera.CameraName);
|
||||
}
|
||||
|
||||
if (detectConfig == null)
|
||||
{
|
||||
|
||||
//未能获得检测配置
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// 1. 预处理
|
||||
using (Mat inferenceImage = localImageSet.Clone()) // 仅在此处克隆,确保推理过程中 Mat 有独立副本
|
||||
{
|
||||
DetectStationResult detectResult = new DetectStationResult();
|
||||
#region 1.预处理
|
||||
DetectStationResult temp1=_visionEngine.RunInference(inferenceImage, detectionId);
|
||||
|
||||
using (Mat PreTMat = inferenceImage.Clone())
|
||||
{
|
||||
PreTreated(detectConfig, detectResult, PreTMat);
|
||||
}
|
||||
resultStates.Add(temp1.ResultState);
|
||||
|
||||
|
||||
|
||||
#endregion
|
||||
if (detectResult.IsPreTreatNG)
|
||||
{
|
||||
detectResult.ResultState = ResultState.DetectNG;
|
||||
detectResult.IsPreTreatDone = true;
|
||||
detectResult.IsMLDetectDone = false;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(detectConfig.ModelPath) && detectConfig.IsEnabled)
|
||||
{
|
||||
|
||||
|
||||
SimboStationMLEngineSet mlSet = null;
|
||||
mlSet = SimboStationMLEngineList.FirstOrDefault(t => t.DetectionId == detectConfig.Id);
|
||||
if (mlSet == null)
|
||||
{
|
||||
// LogAsync(DateTime.Now, LogLevel.Exception, $"异常:{detectConfig.Name}未能获取对应配置的模型检测工具");
|
||||
detectResult.IsMLDetectDone = false;
|
||||
|
||||
//HandleDetectDone(detectResult, detectConfig);
|
||||
return;
|
||||
}
|
||||
|
||||
#region 2.深度学习推理
|
||||
//LogAsync(DateTime.Now, LogLevel.Information, $"{detectConfig.Name} 产品{detectResult.TempPid} 模型检测执行");
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(detectConfig.ModelPath))
|
||||
{
|
||||
Stopwatch mlWatch = new Stopwatch();
|
||||
var req = new MLRequest();
|
||||
//之前的检测图片都是相机存储成HImage
|
||||
|
||||
|
||||
req.ResizeWidth = (int)detectConfig.ModelWidth;
|
||||
req.ResizeHeight = (int)detectConfig.ModelHeight;
|
||||
// req.LabelNames = detectConfig.GetLabelNames();
|
||||
// req.Score = IIConfig.Score;
|
||||
req.mImage = inferenceImage.Clone();
|
||||
|
||||
req.in_lable_path = detectConfig.in_lable_path;
|
||||
|
||||
req.confThreshold = detectConfig.ModelconfThreshold;
|
||||
req.iouThreshold = 0.3f;
|
||||
req.segmentWidth = 320;
|
||||
req.out_node_name = "output0";
|
||||
switch (detectConfig.ModelType)
|
||||
{
|
||||
case MLModelType.ImageClassification:
|
||||
break;
|
||||
case MLModelType.ObjectDetection:
|
||||
|
||||
break;
|
||||
case MLModelType.SemanticSegmentation:
|
||||
break;
|
||||
case MLModelType.InstanceSegmentation:
|
||||
break;
|
||||
case MLModelType.ObjectGPUDetection:
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// LogAsync(DateTime.Now, LogLevel.Information, $"{detectConfig.Name} 产品{detectResult.TempPid} RunInference BEGIN");
|
||||
mlWatch.Start();
|
||||
//20230802改成多线程推理 RunInferenceFixed
|
||||
|
||||
var result = mlSet.StationMLEngine.RunInference(req);
|
||||
// var result = mlSet.StationMLEngine.RunInferenceFixed(req);
|
||||
mlWatch.Stop();
|
||||
// LogAsync(DateTime.Now, LogLevel.Information, $"{detectConfig.Name} 产品{detectResult.TempPid} RunInference END");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// var req = new MLRequest();
|
||||
|
||||
//req.mImage = inferenceImage;
|
||||
|
||||
//req.ResizeWidth = detectConfig.ModelWidth;
|
||||
//req.ResizeHeight = detectConfig.ModelHeight;
|
||||
//req.confThreshold = detectConfig.ModelconfThreshold;
|
||||
//req.iouThreshold = 0.3f;
|
||||
//req.out_node_name = "output0";
|
||||
//req.in_lable_path = detectConfig.in_lable_path;
|
||||
|
||||
//Stopwatch sw = Stopwatch.StartNew();
|
||||
//var result = Dectection[detectionId].RunInference(req);
|
||||
//sw.Stop();
|
||||
//LogAsync(DateTime.Now, LogLevel.Information, $"{camera.Name} 推理进度1.1,产品{productNumber},耗时{sw.ElapsedMilliseconds}ms");
|
||||
|
||||
this.BeginInvoke(new MethodInvoker(delegate ()
|
||||
{
|
||||
pictureBox1.Image?.Dispose(); // 释放旧图像
|
||||
pictureBox1.Image = result.ResultMap;
|
||||
richTextBox1.AppendText($"推理成功 {productNumber}, {result.IsSuccess}相机名字{camera.CameraName} 耗时 {mlWatch.ElapsedMilliseconds}ms\n");
|
||||
}));
|
||||
req.mImage?.Dispose();
|
||||
|
||||
|
||||
|
||||
|
||||
if (result == null || (result != null && !result.IsSuccess))
|
||||
{
|
||||
detectResult.IsMLDetectDone = false;
|
||||
}
|
||||
if (result != null && result.IsSuccess)
|
||||
{
|
||||
detectResult.DetectDetails = result.ResultDetails;
|
||||
if (detectResult.DetectDetails != null)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
detectResult.IsMLDetectDone = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
#region 3.后处理
|
||||
#endregion
|
||||
//根据那些得分大于阈值的推理结果,判断产品是否成功
|
||||
#region 4.最终过滤(逻辑过滤)
|
||||
detectResult.DetectDetails?.ForEach(d =>
|
||||
{
|
||||
|
||||
|
||||
//当前检测项的 过滤条件
|
||||
//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)
|
||||
{
|
||||
|
||||
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);
|
||||
//});
|
||||
|
||||
|
||||
//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;
|
||||
//}
|
||||
}
|
||||
});
|
||||
#endregion
|
||||
#region 5.统计缺陷过滤结果或预处理直接NG
|
||||
//if (detectResult.DetectDetails?.Count > 0)
|
||||
//{
|
||||
// detectResult.ResultState = detectResult.DetectDetails.GroupBy(u => u.FinalResult).OrderBy(u => u.Key).First().First().FinalResult;
|
||||
// detectResult.ResultLabel = detectResult.ResultLabel;
|
||||
// detectResult.ResultLabelCategoryId = detectResult.ResultLabel;//TODO:设置优先级
|
||||
|
||||
|
||||
//}
|
||||
detectResult.ResultState = detectResult.DetectDetails?
|
||||
.GroupBy(u => u.FinalResult)
|
||||
.OrderBy(u => u.Key)
|
||||
.FirstOrDefault()?.Key ?? ResultState.OK;
|
||||
detectResult.ResultLabel = detectResult.ResultLabel;
|
||||
detectResult.ResultLabelCategoryId = detectResult.ResultLabel;//TODO:设置优先级
|
||||
#endregion
|
||||
|
||||
resultStates.Add(detectResult.ResultState);
|
||||
|
||||
product.ResultCollection.Add(detectResult);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
product.ResultCollection.Add(temp1);
|
||||
|
||||
|
||||
}
|
||||
@@ -1431,6 +936,8 @@ namespace DHSoftware
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public void SetResult()
|
||||
{
|
||||
|
||||
@@ -1487,7 +994,36 @@ namespace DHSoftware
|
||||
private void HandleSettingsButton()
|
||||
{
|
||||
// Add the code for the "设置" button click here
|
||||
MessageBox.Show("设置按钮按下");
|
||||
// MessageBox.Show("设置按钮按下");
|
||||
|
||||
List<CameraBase> listCamBase = new List<CameraBase>();
|
||||
CameraBase cam1 = new CameraBase
|
||||
{
|
||||
CameraName = "Cam1",
|
||||
CameraIP = "192.168.1.101",
|
||||
SerialNumber = "1000001",
|
||||
Gain = 60,
|
||||
Exposure = 10,
|
||||
RotateImage = 0,
|
||||
isEnabled = false,
|
||||
};
|
||||
CameraBase cam2 = new CameraBase
|
||||
{
|
||||
CameraName = "Cam2",
|
||||
CameraIP = "192.168.1.101",
|
||||
SerialNumber = "1000002",
|
||||
Gain = 60,
|
||||
Exposure = 10,
|
||||
RotateImage = 0,
|
||||
isEnabled = false,
|
||||
};
|
||||
listCamBase.Add(cam1);
|
||||
listCamBase.Add(cam2);
|
||||
|
||||
SettingWindow s = new SettingWindow();
|
||||
s.cameras = listCamBase;
|
||||
s.Show();
|
||||
|
||||
}
|
||||
|
||||
private void HandleLoginButton()
|
||||
@@ -1496,5 +1032,9 @@ namespace DHSoftware
|
||||
MessageBox.Show("登录按钮按下");
|
||||
}
|
||||
|
||||
private void splitter1_SplitterMoved(object sender, SplitterEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
38
DHSoftware/Models/DataModel.cs
Normal file
38
DHSoftware/Models/DataModel.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using AntdUI;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DHSoftware.Models
|
||||
{
|
||||
public class DataModel
|
||||
{
|
||||
}
|
||||
public class DefectRow:NotifyProperty
|
||||
{
|
||||
private bool selected = false;
|
||||
public string LabelId { get; set; }
|
||||
public string LabelDescription { get; set; }
|
||||
public bool IsEnable { get; set; }
|
||||
public double ScoreMinValue { get; set; }
|
||||
public double ScoreMaxValue { get; set; }
|
||||
public bool IsScoreEnable { get; set; }
|
||||
public double AreaMinValue { get; set; }
|
||||
public double AreaMaxValue { get; set; }
|
||||
public bool isAreaEnable { get; set; }
|
||||
public int ResultState { get; set; } // 结果状态(枚举值对应整数)
|
||||
|
||||
public bool Selected
|
||||
{
|
||||
get { return selected; }
|
||||
set
|
||||
{
|
||||
if (selected == value) return;
|
||||
selected = value;
|
||||
OnPropertyChanged(nameof(Selected));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
228
DHSoftware/Models/DataUtil.cs
Normal file
228
DHSoftware/Models/DataUtil.cs
Normal file
@@ -0,0 +1,228 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace AntdUIDemo.Models
|
||||
{
|
||||
public class DataUtil
|
||||
{
|
||||
public static readonly Dictionary<string, List<MenuItems>> Menu_decetion = new Dictionary<string, List<MenuItems>>()
|
||||
{
|
||||
{ "检测项", new List<MenuItems>
|
||||
{
|
||||
new MenuItems { Text = "工位1" , Tag = "工位1"},
|
||||
new MenuItems { Text = "工位2", Tag = "工位2"},
|
||||
new MenuItems { Text = "工位3", Tag = "工位3"},
|
||||
//new MenuItems { Text = "保存配置", Tag = "保存配置"},
|
||||
}
|
||||
},
|
||||
//{ "布局", new List<MenuItems>
|
||||
// {
|
||||
// new MenuItems { Text = "Divider 分割线", Tag = "Divider" },
|
||||
// new MenuItems { Text = "FlowPanel 流动布局", Tag = "FlowPanel"},
|
||||
// new MenuItems { Text = "GridPanel 网格布局", Tag = "GridPanel"},
|
||||
// new MenuItems { Text = "Panel 面板", Tag = "Panel"},
|
||||
// new MenuItems { Text = "Splitter 分隔面板", Tag = "Splitter"},
|
||||
// new MenuItems { Text = "StackPanel 堆叠布局", Tag = "StackPanel"}
|
||||
// }
|
||||
//},
|
||||
//{ "导航", new List<MenuItems>
|
||||
// {
|
||||
// new MenuItems { Text = "Breadcrumb 面包屑", Tag = "Breadcrumb"},
|
||||
// new MenuItems { Text = "Dropdown 下拉菜单", Tag = "Dropdown"},
|
||||
// new MenuItems { Text = "Menu 导航菜单", Tag = "Menu"},
|
||||
// new MenuItems { Text = "Pagination 分页", Tag = "Pagination"},
|
||||
// new MenuItems { Text = "Steps 步骤条", Tag = "Steps"}
|
||||
// }
|
||||
//},
|
||||
//{ "数据录入", new List<MenuItems>
|
||||
// {
|
||||
// new MenuItems { Text = "Checkbox 多选框", Tag = "Checkbox"},
|
||||
// new MenuItems { Text = "ColorPicker 颜色选择器", Tag = "ColorPicker"},
|
||||
// new MenuItems { Text = "DatePicker 日期选择器", Tag = "DatePicker"},
|
||||
// new MenuItems { Text = "DatePickerRange 日期范围选择器", Tag = "DatePickerRange"},
|
||||
// new MenuItems { Text = "Input 输入框", Tag = "Input"},
|
||||
// new MenuItems { Text = "InputNumber 数字输入框", Tag = "InputNumber"},
|
||||
// new MenuItems { Text = "Radio 单选框", Tag = "Radio"},
|
||||
// new MenuItems { Text = "Rate 评分", Tag = "Rate"},
|
||||
// new MenuItems { Text = "Select 选择器", Tag = "Select"},
|
||||
// new MenuItems { Text = "SelectMultiple 多选选择器", Tag = "SelectMultiple"},
|
||||
// new MenuItems { Text = "Slider 滑动输入条", Tag = "Slider"},
|
||||
// new MenuItems { Text = "SliderRange 滑动范围输入条", Tag = "SliderRange"},
|
||||
// new MenuItems { Text = "Switch 开关", Tag = "Switch"},
|
||||
// new MenuItems { Text = "TimePicker 时间选择框", Tag = "TimePicker"},
|
||||
// new MenuItems { Text = "UploadDragger 上传", Tag = "UploadDragger"}
|
||||
// }
|
||||
//},
|
||||
//{ "数据展示", new List<MenuItems>
|
||||
// {
|
||||
// new MenuItems { Text = "Avatar 头像", Tag = "Avatar"},
|
||||
// new MenuItems { Text = "Badge 徽标数", Tag = "Badge"},
|
||||
// new MenuItems { Text = "Calendar 日历", Tag = "Calendar"},
|
||||
// new MenuItems { Text = "Carousel 走马灯", Tag = "Carousel"},
|
||||
// new MenuItems { Text = "Collapse 折叠面板", Tag = "Collapse"},
|
||||
// new MenuItems { Text = "Label 标签", Tag = "Label"},
|
||||
// new MenuItems { Text = "LabelTime 时间标签", Tag = "LabelTime"},
|
||||
// new MenuItems { Text = "Popover 气泡卡片", Tag = "Popover"},
|
||||
// new MenuItems { Text = "Preview 图片预览", Tag = "Preview"},
|
||||
// new MenuItems { Text = "Segmented 分段控制器", Tag = "Segmented"},
|
||||
// new MenuItems { Text = "Table 表格", Tag = "Table"},
|
||||
// new MenuItems { Text = "Tabs 标签页", Tag = "Tabs"},
|
||||
// new MenuItems { Text = "Tag 标签", Tag = "Tag"},
|
||||
// new MenuItems { Text = "Timeline 时间轴", Tag = "Timeline"},
|
||||
// new MenuItems { Text = "Tooltip 文字提示", Tag = "Tooltip"},
|
||||
// new MenuItems { Text = "Tour 漫游式引导" , Tag = "Tour"},
|
||||
// new MenuItems { Text = "Tree 树形控件", Tag = "Tree"}
|
||||
// }
|
||||
//},
|
||||
//{ "反馈", new List<MenuItems>
|
||||
// {
|
||||
// new MenuItems { Text = "Alert 警告提示", Tag = "Alert"},
|
||||
// new MenuItems { Text = "Drawer 抽屉", Tag = "Drawer"},
|
||||
// new MenuItems { Text = "Message 全局提示", Tag = "Message"},
|
||||
// new MenuItems { Text = "Modal 对话框", Tag = "Modal"},
|
||||
// new MenuItems { Text = "Notification 通知提醒框", Tag = "Notification"},
|
||||
// new MenuItems { Text = "Progress 进度条", Tag = "Progress"},
|
||||
// new MenuItems { Text = "Spin 加载中", Tag = "Spin"}
|
||||
// }
|
||||
//},
|
||||
//{ "聊天", new List<MenuItems>
|
||||
// {
|
||||
// new MenuItems { Text = "ChatList 气泡聊天列表", Tag = "ChatList"},
|
||||
// new MenuItems { Text = "MsgList 好友消息列表", Tag = "MsgList"}
|
||||
// }
|
||||
//},
|
||||
//{ "其它", new List<MenuItems>
|
||||
// {
|
||||
// new MenuItems { Text = "Battery 电池", Tag = "Battery" },
|
||||
// new MenuItems { Text = "ContextMenuStrip 快捷菜单", Tag = "ContextMenuStrip" },
|
||||
// new MenuItems { Text = "Image3D 图片3D", Tag = "Image3D" },
|
||||
// new MenuItems { Text = "PageHeader 页头", Tag= "PageHeader"},
|
||||
// new MenuItems { Text = "Signal 信号", Tag = "Signal" }
|
||||
// }
|
||||
//}
|
||||
};
|
||||
|
||||
public static readonly Dictionary<string, string> MenuIcons_zhcn = new Dictionary<string, string>
|
||||
{
|
||||
{ "通用", "AppstoreOutlined" },
|
||||
{ "布局", "LayoutOutlined" },
|
||||
{ "导航", "CompressOutlined" },
|
||||
{ "数据录入", "EditOutlined" },
|
||||
{ "数据展示", "BarChartOutlined" },
|
||||
{ "反馈", "NotificationOutlined" },
|
||||
{ "聊天", "MessageOutlined" },
|
||||
{ "其它", "SettingOutlined" }
|
||||
};
|
||||
|
||||
public static readonly Dictionary<string, List<MenuItems>> MenuItems_enus = new Dictionary<string, List<MenuItems>>()
|
||||
{
|
||||
{ "General", new List<MenuItems>
|
||||
{
|
||||
new MenuItems { Text = "Button" , Tag = "Button"},
|
||||
new MenuItems { Text = "FloatButton", Tag = "FloatButton"},
|
||||
new MenuItems { Text = "Icon", Tag = "Icon"},
|
||||
}
|
||||
},
|
||||
{ "Layout", new List<MenuItems>
|
||||
{
|
||||
new MenuItems { Text = "Divider", Tag = "Divider" },
|
||||
new MenuItems { Text = "FlowPanel", Tag = "FlowPanel"},
|
||||
new MenuItems { Text = "GridPanel", Tag = "GridPanel"},
|
||||
new MenuItems { Text = "Panel", Tag = "Panel"},
|
||||
new MenuItems { Text = "Splitter ", Tag = "Splitter"},
|
||||
new MenuItems { Text = "StackPanel", Tag = "StackPanel"}
|
||||
}
|
||||
},
|
||||
{ "Navigation", new List<MenuItems>
|
||||
{
|
||||
new MenuItems { Text = "Breadcrumb", Tag = "Breadcrumb"},
|
||||
new MenuItems { Text = "Dropdown", Tag = "Dropdown"},
|
||||
new MenuItems { Text = "Menu", Tag = "Menu"},
|
||||
new MenuItems { Text = "Pagination", Tag = "Pagination"},
|
||||
new MenuItems { Text = "Steps", Tag = "Steps"}
|
||||
}
|
||||
},
|
||||
{ "Data Entry", new List<MenuItems>
|
||||
{
|
||||
new MenuItems { Text = "Checkbox", Tag = "Checkbox"},
|
||||
new MenuItems { Text = "ColorPicker", Tag = "ColorPicker"},
|
||||
new MenuItems { Text = "DatePicker", Tag = "DatePicker"},
|
||||
new MenuItems { Text = "DatePickerRange", Tag = "DatePickerRange"},
|
||||
new MenuItems { Text = "Input", Tag = "Input"},
|
||||
new MenuItems { Text = "InputNumber", Tag = "InputNumber"},
|
||||
new MenuItems { Text = "Radio", Tag = "Radio"},
|
||||
new MenuItems { Text = "Rate", Tag = "Rate"},
|
||||
new MenuItems { Text = "Select", Tag = "Select"},
|
||||
new MenuItems { Text = "SelectMultiple", Tag = "SelectMultiple"},
|
||||
new MenuItems { Text = "Slider", Tag = "Slider"},
|
||||
new MenuItems { Text = "SliderRange", Tag = "SliderRange"},
|
||||
new MenuItems { Text = "Switch", Tag = "Switch"},
|
||||
new MenuItems { Text = "TimePicker", Tag = "TimePicker"},
|
||||
new MenuItems { Text = "UploadDragger", Tag = "UploadDragger"}
|
||||
}
|
||||
},
|
||||
{ "Data Display", new List<MenuItems>
|
||||
{
|
||||
new MenuItems { Text = "Avatar", Tag = "Avatar"},
|
||||
new MenuItems { Text = "Badge", Tag = "Badge"},
|
||||
new MenuItems { Text = "Calendar", Tag = "Calendar"},
|
||||
new MenuItems { Text = "Carousel", Tag = "Carousel"},
|
||||
new MenuItems { Text = "Collapse", Tag = "Collapse"},
|
||||
new MenuItems { Text = "Label", Tag = "Label"},
|
||||
new MenuItems { Text = "LabelTime", Tag = "LabelTime"},
|
||||
new MenuItems { Text = "Popover", Tag = "Popover"},
|
||||
new MenuItems { Text = "Preview", Tag = "Preview"},
|
||||
new MenuItems { Text = "Segmented", Tag = "Segmented"},
|
||||
new MenuItems { Text = "Table", Tag = "Table"},
|
||||
new MenuItems { Text = "Tabs", Tag = "Tabs"},
|
||||
new MenuItems { Text = "Tag", Tag = "Tag"},
|
||||
new MenuItems { Text = "Timeline", Tag = "Timeline"},
|
||||
new MenuItems { Text = "Tooltip", Tag = "Tooltip"},
|
||||
new MenuItems { Text = "Tour" , Tag = "Tour"},
|
||||
new MenuItems { Text = "Tree", Tag = "Tree"}
|
||||
}
|
||||
},
|
||||
{ "Feedback", new List<MenuItems>
|
||||
{
|
||||
new MenuItems { Text = "Alert", Tag = "Alert"},
|
||||
new MenuItems { Text = "Drawer", Tag = "Drawer"},
|
||||
new MenuItems { Text = "Message", Tag = "Message"},
|
||||
new MenuItems { Text = "Modal", Tag = "Modal"},
|
||||
new MenuItems { Text = "Notification", Tag = "Notification"},
|
||||
new MenuItems { Text = "Progress", Tag = "Progress"},
|
||||
new MenuItems { Text = "Spin", Tag = "Spin"}
|
||||
}
|
||||
},
|
||||
{ "Chat", new List<MenuItems>
|
||||
{
|
||||
new MenuItems { Text = "ChatList", Tag = "ChatList"},
|
||||
new MenuItems { Text = "MsgList", Tag = "MsgList"}
|
||||
}
|
||||
},
|
||||
{ "Other", new List<MenuItems>
|
||||
{
|
||||
new MenuItems { Text = "Battery", Tag = "Battery" },
|
||||
new MenuItems { Text = "ContextMenuStrip", Tag = "ContextMenuStrip" },
|
||||
new MenuItems { Text = "Image3D", Tag = "Image3D" },
|
||||
new MenuItems { Text = "PageHeader", Tag= "PageHeader"},
|
||||
new MenuItems { Text = "Signal", Tag = "Signal" }
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public static readonly Dictionary<string, string> MenuIcons_enus = new Dictionary<string, string>
|
||||
{
|
||||
{ "General", "AppstoreOutlined" },
|
||||
{ "Layout", "LayoutOutlined" },
|
||||
{ "Navigation", "CompressOutlined" },
|
||||
{ "Data Entry", "EditOutlined" },
|
||||
{ "Data Display", "BarChartOutlined" },
|
||||
{ "Feedback", "NotificationOutlined" },
|
||||
{ "Chat", "MessageOutlined" },
|
||||
{ "Other", "SettingOutlined" }
|
||||
};
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
9
DHSoftware/Models/MenuItems.cs
Normal file
9
DHSoftware/Models/MenuItems.cs
Normal file
@@ -0,0 +1,9 @@
|
||||
namespace AntdUIDemo.Models
|
||||
{
|
||||
public class MenuItems
|
||||
{
|
||||
public string IconSvg { get; set; } = null;
|
||||
public string Text { get; set; } = string.Empty;
|
||||
public string Tag { get; set; } = null;
|
||||
}
|
||||
}
|
||||
166
DHSoftware/Models/User.cs
Normal file
166
DHSoftware/Models/User.cs
Normal file
@@ -0,0 +1,166 @@
|
||||
using AntdUI;
|
||||
|
||||
namespace AntdUIDemo.Models
|
||||
{
|
||||
public class User : NotifyProperty
|
||||
{
|
||||
private bool selected = false;
|
||||
private string name;
|
||||
private int age = 0;
|
||||
private string address;
|
||||
private bool enabled = false;
|
||||
private CellImage[] cellImages;
|
||||
private CellTag[] cellTags;
|
||||
private CellBadge cellBadge;
|
||||
private CellText cellText;
|
||||
private CellLink[] cellLinks;
|
||||
private CellProgress cellProgress;
|
||||
private CellDivider cellDivider;
|
||||
//用于设置树形表格,加入自身数组
|
||||
private User[] users;
|
||||
|
||||
public bool Selected
|
||||
{
|
||||
get { return selected; }
|
||||
set
|
||||
{
|
||||
if (selected == value) return;
|
||||
selected = value;
|
||||
OnPropertyChanged(nameof(Selected));
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return name; }
|
||||
set
|
||||
{
|
||||
if (name == value) return;
|
||||
name = value;
|
||||
OnPropertyChanged(nameof(Name));
|
||||
}
|
||||
}
|
||||
|
||||
public int Age
|
||||
{
|
||||
get { return age; }
|
||||
set
|
||||
{
|
||||
if (age == value) return;
|
||||
age = value;
|
||||
OnPropertyChanged(nameof(Age));
|
||||
}
|
||||
}
|
||||
|
||||
public string Address
|
||||
{
|
||||
get { return address; }
|
||||
set
|
||||
{
|
||||
if (address == value) return;
|
||||
address = value;
|
||||
OnPropertyChanged(nameof(Address));
|
||||
}
|
||||
}
|
||||
|
||||
public bool Enabled
|
||||
{
|
||||
get { return enabled; }
|
||||
set
|
||||
{
|
||||
if (enabled == value) return;
|
||||
enabled = value;
|
||||
OnPropertyChanged(nameof(Enabled));
|
||||
}
|
||||
}
|
||||
|
||||
public CellImage[] CellImages
|
||||
{
|
||||
get { return cellImages; }
|
||||
set
|
||||
{
|
||||
if (cellImages == value) return;
|
||||
cellImages = value;
|
||||
OnPropertyChanged(nameof(CellImages));
|
||||
}
|
||||
}
|
||||
|
||||
public CellTag[] CellTags
|
||||
{
|
||||
get { return cellTags; }
|
||||
set
|
||||
{
|
||||
if (cellTags == value) return;
|
||||
cellTags = value;
|
||||
OnPropertyChanged(nameof(CellTags));
|
||||
}
|
||||
}
|
||||
|
||||
public CellBadge CellBadge
|
||||
{
|
||||
get { return cellBadge; }
|
||||
set
|
||||
{
|
||||
if (cellBadge == value) return;
|
||||
cellBadge = value;
|
||||
OnPropertyChanged(nameof(CellBadge));
|
||||
}
|
||||
}
|
||||
|
||||
public CellText CellText
|
||||
{
|
||||
get { return cellText; }
|
||||
set
|
||||
{
|
||||
if (cellText == value) return;
|
||||
cellText = value;
|
||||
OnPropertyChanged(nameof(CellText));
|
||||
}
|
||||
}
|
||||
|
||||
public CellLink[] CellLinks
|
||||
{
|
||||
get { return cellLinks; }
|
||||
set
|
||||
{
|
||||
if (cellLinks == value) return;
|
||||
cellLinks = value;
|
||||
OnPropertyChanged(nameof(CellLinks));
|
||||
}
|
||||
}
|
||||
|
||||
public CellProgress CellProgress
|
||||
{
|
||||
get { return cellProgress; }
|
||||
set
|
||||
{
|
||||
if (cellProgress == value) return;
|
||||
cellProgress = value;
|
||||
OnPropertyChanged(nameof(CellProgress));
|
||||
}
|
||||
}
|
||||
|
||||
public CellDivider CellDivider
|
||||
{
|
||||
get { return cellDivider; }
|
||||
set
|
||||
{
|
||||
if (cellDivider == value) return;
|
||||
cellDivider = value;
|
||||
OnPropertyChanged(nameof(CellDivider));
|
||||
}
|
||||
}
|
||||
|
||||
public User[] Users
|
||||
{
|
||||
get { return users; }
|
||||
set
|
||||
{
|
||||
if (users == value) return;
|
||||
users = value;
|
||||
OnPropertyChanged(nameof(Users));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
81
DHSoftware/Views/AddCameraWindow.Designer.cs
generated
Normal file
81
DHSoftware/Views/AddCameraWindow.Designer.cs
generated
Normal file
@@ -0,0 +1,81 @@
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
partial class AddCameraWindow
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
btnOK = new AntdUI.Button();
|
||||
btnCancel = new AntdUI.Button();
|
||||
stName = new AntdUI.Select();
|
||||
SuspendLayout();
|
||||
//
|
||||
// btnOK
|
||||
//
|
||||
btnOK.Location = new Point(170, 136);
|
||||
btnOK.Name = "btnOK";
|
||||
btnOK.Size = new Size(75, 40);
|
||||
btnOK.TabIndex = 1;
|
||||
btnOK.Text = "确定";
|
||||
btnOK.Click += btnOK_Click;
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
btnCancel.Location = new Point(259, 136);
|
||||
btnCancel.Name = "btnCancel";
|
||||
btnCancel.Size = new Size(75, 40);
|
||||
btnCancel.TabIndex = 2;
|
||||
btnCancel.Text = "取消";
|
||||
btnCancel.Click += btnCancel_Click;
|
||||
//
|
||||
// stName
|
||||
//
|
||||
stName.Location = new Point(39, 46);
|
||||
stName.Name = "stName";
|
||||
stName.PlaceholderText = "请选择关联相机";
|
||||
stName.Size = new Size(281, 50);
|
||||
stName.TabIndex = 3;
|
||||
//
|
||||
// AddCameraWindow
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(369, 188);
|
||||
Controls.Add(stName);
|
||||
Controls.Add(btnCancel);
|
||||
Controls.Add(btnOK);
|
||||
Name = "AddCameraWindow";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "AddCubicleWindow";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
private AntdUI.Button btnOK;
|
||||
private AntdUI.Button btnCancel;
|
||||
private AntdUI.Select stName;
|
||||
}
|
||||
}
|
||||
64
DHSoftware/Views/AddCameraWindow.cs
Normal file
64
DHSoftware/Views/AddCameraWindow.cs
Normal file
@@ -0,0 +1,64 @@
|
||||
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.Xml.Linq;
|
||||
using AntdUI;
|
||||
using DH.Devices.Devices;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
public partial class AddCameraWindow : Window
|
||||
{
|
||||
public AddCameraWindow(List<CameraBase> cameras)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
|
||||
btnOK.DialogResult = DialogResult.OK;
|
||||
btnCancel.DialogResult = DialogResult.Cancel;
|
||||
this.AcceptButton = btnOK;
|
||||
this.CancelButton = btnCancel;
|
||||
|
||||
|
||||
stName.Items.Clear();
|
||||
for (int i = 0; i < cameras.Count; i++)
|
||||
{
|
||||
stName.Items.Add(cameras[i].CameraName);
|
||||
}
|
||||
}
|
||||
public string CubicleName { get; private set; }
|
||||
private void btnOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ValidateInput())
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private bool ValidateInput()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(stName.Text))
|
||||
{
|
||||
MessageBox.Show("请选择关联相机", "输入错误",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
return false;
|
||||
}
|
||||
CubicleName = stName.Text.Trim();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
DHSoftware/Views/AddCameraWindow.resx
Normal file
120
DHSoftware/Views/AddCameraWindow.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>
|
||||
82
DHSoftware/Views/AddCubicleWindow.Designer.cs
generated
Normal file
82
DHSoftware/Views/AddCubicleWindow.Designer.cs
generated
Normal file
@@ -0,0 +1,82 @@
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
partial class AddCubicleWindow
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
txtName = new AntdUI.Input();
|
||||
btnOK = new AntdUI.Button();
|
||||
btnCancel = new AntdUI.Button();
|
||||
SuspendLayout();
|
||||
//
|
||||
// txtName
|
||||
//
|
||||
txtName.Location = new Point(35, 47);
|
||||
txtName.Name = "txtName";
|
||||
txtName.PlaceholderText = "请输入新增工位名称";
|
||||
txtName.Size = new Size(299, 48);
|
||||
txtName.TabIndex = 0;
|
||||
//
|
||||
// btnOK
|
||||
//
|
||||
btnOK.Location = new Point(170, 136);
|
||||
btnOK.Name = "btnOK";
|
||||
btnOK.Size = new Size(75, 40);
|
||||
btnOK.TabIndex = 1;
|
||||
btnOK.Text = "确定";
|
||||
btnOK.Click += btnOK_Click;
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
btnCancel.Location = new Point(259, 136);
|
||||
btnCancel.Name = "btnCancel";
|
||||
btnCancel.Size = new Size(75, 40);
|
||||
btnCancel.TabIndex = 2;
|
||||
btnCancel.Text = "取消";
|
||||
btnCancel.Click += btnCancel_Click;
|
||||
//
|
||||
// AddCubicleWindow
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(369, 188);
|
||||
Controls.Add(btnCancel);
|
||||
Controls.Add(btnOK);
|
||||
Controls.Add(txtName);
|
||||
Name = "AddCubicleWindow";
|
||||
StartPosition = FormStartPosition.CenterParent;
|
||||
Text = "AddCubicleWindow";
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private AntdUI.Input txtName;
|
||||
private AntdUI.Button btnOK;
|
||||
private AntdUI.Button btnCancel;
|
||||
}
|
||||
}
|
||||
55
DHSoftware/Views/AddCubicleWindow.cs
Normal file
55
DHSoftware/Views/AddCubicleWindow.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
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.Xml.Linq;
|
||||
using AntdUI;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
public partial class AddCubicleWindow : Window
|
||||
{
|
||||
public AddCubicleWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
btnOK.DialogResult = DialogResult.OK;
|
||||
btnCancel.DialogResult = DialogResult.Cancel;
|
||||
this.AcceptButton = btnOK;
|
||||
this.CancelButton = btnCancel;
|
||||
}
|
||||
public string CubicleName { get; private set; }
|
||||
private void btnOK_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (ValidateInput())
|
||||
{
|
||||
this.DialogResult = DialogResult.OK;
|
||||
this.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e)
|
||||
{
|
||||
this.DialogResult = DialogResult.Cancel;
|
||||
this.Close();
|
||||
}
|
||||
|
||||
private bool ValidateInput()
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(txtName.Text))
|
||||
{
|
||||
MessageBox.Show("请输入有效的名称", "输入错误",
|
||||
MessageBoxButtons.OK,
|
||||
MessageBoxIcon.Warning);
|
||||
txtName.Focus();
|
||||
return false;
|
||||
}
|
||||
CubicleName = txtName.Text.Trim();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
DHSoftware/Views/AddCubicleWindow.resx
Normal file
120
DHSoftware/Views/AddCubicleWindow.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>
|
||||
108
DHSoftware/Views/CamConfigFrm.Designer.cs
generated
108
DHSoftware/Views/CamConfigFrm.Designer.cs
generated
@@ -2,6 +2,7 @@
|
||||
{
|
||||
partial class CamConfigFrm
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
@@ -28,17 +29,122 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AntdUI.Tabs.StyleLine styleLine1 = new AntdUI.Tabs.StyleLine();
|
||||
tabs1 = new AntdUI.Tabs();
|
||||
tabPage1 = new AntdUI.TabPage();
|
||||
label1 = new Label();
|
||||
btnRefreshCamList = new Button();
|
||||
dgvCams = new DataGridView();
|
||||
CamName = new DataGridViewTextBoxColumn();
|
||||
Serinum = new DataGridViewTextBoxColumn();
|
||||
IP = new DataGridViewTextBoxColumn();
|
||||
COMBO_DEVICES = new ComboBox();
|
||||
tabs1.SuspendLayout();
|
||||
tabPage1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dgvCams).BeginInit();
|
||||
SuspendLayout();
|
||||
//
|
||||
// tabs1
|
||||
//
|
||||
tabs1.Controls.Add(tabPage1);
|
||||
tabs1.Dock = DockStyle.Fill;
|
||||
tabs1.Location = new Point(0, 0);
|
||||
tabs1.Name = "tabs1";
|
||||
tabs1.Pages.Add(tabPage1);
|
||||
tabs1.Size = new Size(489, 563);
|
||||
tabs1.Style = styleLine1;
|
||||
tabs1.TabIndex = 0;
|
||||
tabs1.Text = "tabs1";
|
||||
//
|
||||
// tabPage1
|
||||
//
|
||||
tabPage1.Controls.Add(label1);
|
||||
tabPage1.Controls.Add(btnRefreshCamList);
|
||||
tabPage1.Controls.Add(dgvCams);
|
||||
tabPage1.Controls.Add(COMBO_DEVICES);
|
||||
tabPage1.Location = new Point(3, 28);
|
||||
tabPage1.Name = "tabPage1";
|
||||
tabPage1.Size = new Size(483, 532);
|
||||
tabPage1.TabIndex = 0;
|
||||
tabPage1.Text = "相机配置";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.AutoSize = true;
|
||||
label1.Location = new Point(38, 15);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(56, 17);
|
||||
label1.TabIndex = 3;
|
||||
label1.Text = "相机类型";
|
||||
//
|
||||
// btnRefreshCamList
|
||||
//
|
||||
btnRefreshCamList.Location = new Point(36, 43);
|
||||
btnRefreshCamList.Name = "btnRefreshCamList";
|
||||
btnRefreshCamList.Size = new Size(423, 33);
|
||||
btnRefreshCamList.TabIndex = 2;
|
||||
btnRefreshCamList.Text = "刷新相机列表";
|
||||
btnRefreshCamList.UseVisualStyleBackColor = true;
|
||||
btnRefreshCamList.Click += btnRefreshCamList_Click;
|
||||
//
|
||||
// dgvCams
|
||||
//
|
||||
dgvCams.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dgvCams.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dgvCams.Columns.AddRange(new DataGridViewColumn[] { CamName, Serinum, IP });
|
||||
dgvCams.Location = new Point(38, 82);
|
||||
dgvCams.Name = "dgvCams";
|
||||
dgvCams.Size = new Size(421, 206);
|
||||
dgvCams.TabIndex = 1;
|
||||
//
|
||||
// CamName
|
||||
//
|
||||
CamName.HeaderText = "相机名";
|
||||
CamName.Name = "CamName";
|
||||
//
|
||||
// Serinum
|
||||
//
|
||||
Serinum.HeaderText = "序列号";
|
||||
Serinum.Name = "Serinum";
|
||||
//
|
||||
// IP
|
||||
//
|
||||
IP.HeaderText = "相机IP";
|
||||
IP.Name = "IP";
|
||||
//
|
||||
// COMBO_DEVICES
|
||||
//
|
||||
COMBO_DEVICES.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
COMBO_DEVICES.FormattingEnabled = true;
|
||||
COMBO_DEVICES.Location = new Point(100, 12);
|
||||
COMBO_DEVICES.Name = "COMBO_DEVICES";
|
||||
COMBO_DEVICES.Size = new Size(359, 25);
|
||||
COMBO_DEVICES.TabIndex = 0;
|
||||
//
|
||||
// CamConfigFrm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(tabs1);
|
||||
Name = "CamConfigFrm";
|
||||
Size = new Size(869, 521);
|
||||
Size = new Size(489, 563);
|
||||
tabs1.ResumeLayout(false);
|
||||
tabPage1.ResumeLayout(false);
|
||||
tabPage1.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)dgvCams).EndInit();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private AntdUI.Tabs tabs1;
|
||||
private AntdUI.TabPage tabPage1;
|
||||
private ComboBox COMBO_DEVICES;
|
||||
private Button btnRefreshCamList;
|
||||
private DataGridView dgvCams;
|
||||
private Label label1;
|
||||
private DataGridViewTextBoxColumn CamName;
|
||||
private DataGridViewTextBoxColumn Serinum;
|
||||
private DataGridViewTextBoxColumn IP;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,178 @@
|
||||
using System;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Devices;
|
||||
using DVPCameraType;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
|
||||
public partial class CamConfigFrm : UserControl
|
||||
{
|
||||
public int m_n_dev_count = 0;
|
||||
public static int m_CamCount = 0;
|
||||
public static dvpCameraInfo[] m_info = new dvpCameraInfo[16];
|
||||
|
||||
// 在窗体类中声明一个绑定列表(用于动态更新)
|
||||
private BindingList<CameraBase> _cameraList = new BindingList<CameraBase>();
|
||||
public CamConfigFrm()
|
||||
{
|
||||
InitializeComponent();
|
||||
// 添加 ComboBox 的项
|
||||
COMBO_DEVICES.Items.AddRange(new string[] { " 度申Do3", "海康Hik", "巴斯勒Basler", "虚拟相机" });
|
||||
|
||||
// 绑定 SelectedIndexChanged 事件
|
||||
COMBO_DEVICES.SelectedIndexChanged += ComboBox_SelectedIndexChanged;
|
||||
|
||||
dgvCams.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
|
||||
dgvCams.ColumnHeadersHeightSizeMode = DataGridViewColumnHeadersHeightSizeMode.AutoSize;
|
||||
dgvCams.DataSource = _cameraList; // 绑定数据源
|
||||
dgvCams.Location = new Point(38, 82);
|
||||
dgvCams.Name = "dgvCams";
|
||||
dgvCams.Size = new Size(284, 206);
|
||||
dgvCams.TabIndex = 1;
|
||||
}
|
||||
private void ComboBox_SelectedIndexChanged(object sender, EventArgs e)
|
||||
{
|
||||
if (COMBO_DEVICES.SelectedItem == null) return;
|
||||
|
||||
string selectedMethod = COMBO_DEVICES.SelectedItem.ToString();
|
||||
switch (selectedMethod)
|
||||
{
|
||||
case "度申Do3":
|
||||
Do3Think();
|
||||
break;
|
||||
case "海康Hik":
|
||||
HiK();
|
||||
break;
|
||||
case "巴斯勒Basler":
|
||||
Basler();
|
||||
break;
|
||||
case "虚拟相机":
|
||||
Virtul();
|
||||
break;
|
||||
default:
|
||||
MessageBox.Show("未找到对应方法");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 其他方法定义...
|
||||
private void Do3Think()
|
||||
{
|
||||
InitDevList();
|
||||
}
|
||||
|
||||
private void HiK()
|
||||
{
|
||||
|
||||
}
|
||||
private void Basler()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void Virtul()
|
||||
{
|
||||
|
||||
}
|
||||
private void btnRefreshCamList_Click(object sender, EventArgs e)
|
||||
{
|
||||
//搜索度申相机
|
||||
InitDevList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 搜索度申相机
|
||||
/// </summary>
|
||||
// Initialize the device list.
|
||||
public void InitDevList()
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dvpStatus status;
|
||||
uint i, n = 0;
|
||||
dvpCameraInfo dev_info = new dvpCameraInfo();
|
||||
|
||||
// 清空旧数据
|
||||
_cameraList.Clear();
|
||||
|
||||
// Get the number of cameras that has been connected to a computer.
|
||||
status = DVPCamera.dvpRefresh(ref n);
|
||||
Debug.Assert(status == dvpStatus.DVP_STATUS_OK);
|
||||
m_n_dev_count = (int)n;
|
||||
if (status == dvpStatus.DVP_STATUS_OK)
|
||||
{
|
||||
m_CamCount = 0;
|
||||
for (i = 0; i < n; i++)
|
||||
{
|
||||
// Acquire each camera's information one by one.
|
||||
status = DVPCamera.dvpEnum(i, ref dev_info);
|
||||
|
||||
if (status == dvpStatus.DVP_STATUS_OK)
|
||||
{
|
||||
m_info[m_CamCount] = dev_info;
|
||||
|
||||
int item = -1;
|
||||
//if (!UserDefinedName.Checked)
|
||||
{
|
||||
// add FriendlyName
|
||||
item = COMBO_DEVICES.Items.Add(dev_info.FriendlyName);
|
||||
CameraBase info = new CameraBase
|
||||
{
|
||||
CameraName = dev_info.FriendlyName,
|
||||
SerialNumber = dev_info.SerialNumber,
|
||||
// IP = dev_info.IP
|
||||
};
|
||||
|
||||
_cameraList.Add(info);
|
||||
|
||||
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// // add User Define Name
|
||||
// item = COMBO_DEVICES.Items.Add(dev_info.UserID);
|
||||
//}
|
||||
|
||||
m_CamCount++;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Assert(status == dvpStatus.DVP_STATUS_OK);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (n == 0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void btnsubmit_Click(object sender, EventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,4 +117,13 @@
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="CamName.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="Serinum.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
<metadata name="IP.UserAddedColumn" type="System.Boolean, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
|
||||
<value>True</value>
|
||||
</metadata>
|
||||
</root>
|
||||
200
DHSoftware/Views/CameraConfigControl.Designer.cs
generated
Normal file
200
DHSoftware/Views/CameraConfigControl.Designer.cs
generated
Normal file
@@ -0,0 +1,200 @@
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
partial class CameraConfigControl
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
label1 = new AntdUI.Label();
|
||||
cbxCamName = new ComboBox();
|
||||
switchCamEnable = new AntdUI.Switch();
|
||||
label2 = new AntdUI.Label();
|
||||
numExpose = new AntdUI.InputNumber();
|
||||
numGain = new AntdUI.InputNumber();
|
||||
label3 = new AntdUI.Label();
|
||||
numRotate = new AntdUI.InputNumber();
|
||||
label4 = new AntdUI.Label();
|
||||
label5 = new AntdUI.Label();
|
||||
label6 = new AntdUI.Label();
|
||||
switchSaveCamPic = new AntdUI.Switch();
|
||||
panel1 = new Panel();
|
||||
panel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.Location = new Point(15, 14);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(58, 23);
|
||||
label1.TabIndex = 0;
|
||||
label1.Text = "相机名";
|
||||
//
|
||||
// cbxCamName
|
||||
//
|
||||
cbxCamName.DropDownStyle = ComboBoxStyle.DropDownList;
|
||||
cbxCamName.FormattingEnabled = true;
|
||||
cbxCamName.Location = new Point(79, 12);
|
||||
cbxCamName.Name = "cbxCamName";
|
||||
cbxCamName.Size = new Size(165, 25);
|
||||
cbxCamName.TabIndex = 1;
|
||||
//
|
||||
// switchCamEnable
|
||||
//
|
||||
switchCamEnable.Location = new Point(330, 12);
|
||||
switchCamEnable.Name = "switchCamEnable";
|
||||
switchCamEnable.Size = new Size(57, 23);
|
||||
switchCamEnable.TabIndex = 2;
|
||||
switchCamEnable.Text = "switch1";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.Location = new Point(15, 43);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(58, 38);
|
||||
label2.TabIndex = 3;
|
||||
label2.Text = "曝光时间";
|
||||
//
|
||||
// numExpose
|
||||
//
|
||||
numExpose.Location = new Point(79, 43);
|
||||
numExpose.Maximum = new decimal(new int[] { 10000000, 0, 0, 0 });
|
||||
numExpose.Minimum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
numExpose.Name = "numExpose";
|
||||
numExpose.Size = new Size(165, 38);
|
||||
numExpose.TabIndex = 4;
|
||||
numExpose.Text = "1";
|
||||
numExpose.Value = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
//
|
||||
// numGain
|
||||
//
|
||||
numGain.Location = new Point(79, 87);
|
||||
numGain.Maximum = new decimal(new int[] { 16, 0, 0, 0 });
|
||||
numGain.Minimum = new decimal(new int[] { 0, 0, 0, 0 });
|
||||
numGain.Name = "numGain";
|
||||
numGain.Size = new Size(165, 38);
|
||||
numGain.TabIndex = 6;
|
||||
numGain.Text = "0";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.Location = new Point(15, 87);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(58, 38);
|
||||
label3.TabIndex = 5;
|
||||
label3.Text = "增益";
|
||||
//
|
||||
// numRotate
|
||||
//
|
||||
numRotate.Increment = new decimal(new int[] { 90, 0, 0, 0 });
|
||||
numRotate.Location = new Point(79, 131);
|
||||
numRotate.Maximum = new decimal(new int[] { 360, 0, 0, 0 });
|
||||
numRotate.Minimum = new decimal(new int[] { 0, 0, 0, 0 });
|
||||
numRotate.Name = "numRotate";
|
||||
numRotate.Size = new Size(165, 38);
|
||||
numRotate.TabIndex = 8;
|
||||
numRotate.Text = "0";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.Location = new Point(15, 131);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(58, 38);
|
||||
label4.TabIndex = 7;
|
||||
label4.Text = "旋转";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.Location = new Point(266, 5);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(58, 36);
|
||||
label5.TabIndex = 9;
|
||||
label5.Text = "相机启用";
|
||||
//
|
||||
// label6
|
||||
//
|
||||
label6.Location = new Point(266, 47);
|
||||
label6.Name = "label6";
|
||||
label6.Size = new Size(58, 36);
|
||||
label6.TabIndex = 11;
|
||||
label6.Text = "保存原图";
|
||||
//
|
||||
// switchSaveCamPic
|
||||
//
|
||||
switchSaveCamPic.Location = new Point(330, 54);
|
||||
switchSaveCamPic.Name = "switchSaveCamPic";
|
||||
switchSaveCamPic.Size = new Size(57, 23);
|
||||
switchSaveCamPic.TabIndex = 10;
|
||||
switchSaveCamPic.Text = "switch2";
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.BorderStyle = BorderStyle.FixedSingle;
|
||||
panel1.Controls.Add(cbxCamName);
|
||||
panel1.Controls.Add(label6);
|
||||
panel1.Controls.Add(label1);
|
||||
panel1.Controls.Add(switchSaveCamPic);
|
||||
panel1.Controls.Add(switchCamEnable);
|
||||
panel1.Controls.Add(label5);
|
||||
panel1.Controls.Add(label2);
|
||||
panel1.Controls.Add(numRotate);
|
||||
panel1.Controls.Add(numExpose);
|
||||
panel1.Controls.Add(label4);
|
||||
panel1.Controls.Add(label3);
|
||||
panel1.Controls.Add(numGain);
|
||||
panel1.Dock = DockStyle.Fill;
|
||||
panel1.Location = new Point(0, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(620, 201);
|
||||
panel1.TabIndex = 12;
|
||||
//
|
||||
// CameraConfigControl
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(panel1);
|
||||
Name = "CameraConfigControl";
|
||||
Size = new Size(620, 201);
|
||||
panel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private AntdUI.Label label1;
|
||||
private ComboBox cbxCamName;
|
||||
private AntdUI.Switch switchCamEnable;
|
||||
private AntdUI.Label label2;
|
||||
private AntdUI.InputNumber numExpose;
|
||||
private AntdUI.InputNumber numGain;
|
||||
private AntdUI.Label label3;
|
||||
private AntdUI.InputNumber numRotate;
|
||||
private AntdUI.Label label4;
|
||||
private AntdUI.Label label5;
|
||||
private AntdUI.Label label6;
|
||||
private AntdUI.Switch switchSaveCamPic;
|
||||
private Panel panel1;
|
||||
}
|
||||
}
|
||||
127
DHSoftware/Views/CameraConfigControl.cs
Normal file
127
DHSoftware/Views/CameraConfigControl.cs
Normal file
@@ -0,0 +1,127 @@
|
||||
using AntdUI;
|
||||
using DH.Devices.Devices;
|
||||
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 CameraConfigControl : UserControl
|
||||
{
|
||||
public CameraConfigControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
// InitTableColumns();
|
||||
InitData();
|
||||
}
|
||||
AntList<CameraBase> antList = null;
|
||||
CameraBase curUser;
|
||||
//private void InitTableColumns()
|
||||
//{
|
||||
// table_base.Columns = new ColumnCollection() {
|
||||
// new ColumnCheck("Selected"){Fixed = true},
|
||||
// new Column("CameraName", "相机名", ColumnAlign.Center)
|
||||
// {
|
||||
// Width="120",
|
||||
// //设置树节点,名称需和User里的User[]名称保持一致
|
||||
// KeyTree = "Users"
|
||||
// },
|
||||
// new Column("CameraIP", "相机IP",ColumnAlign.Center),
|
||||
// new Column("Gain", "增益"){
|
||||
// Width = "120",
|
||||
// LineBreak = true,
|
||||
// },
|
||||
// new ColumnSwitch("IsHardwareTrigger", "硬触发", ColumnAlign.Center){
|
||||
|
||||
// },
|
||||
// new Column("RotateImage", "旋转",ColumnAlign.Center),
|
||||
// new Column("Exposure", "曝光",ColumnAlign.Center),
|
||||
// //new Column("CellBadge", "徽标",ColumnAlign.Center),
|
||||
// //new Column("CellText", "富文本")
|
||||
// //{
|
||||
// // ColAlign = ColumnAlign.Center,//支持表头位置单独设置
|
||||
// //},
|
||||
// //new Column("CellProgress", "进度条",ColumnAlign.Center),
|
||||
// //new Column("CellDivider", "分割线",ColumnAlign.Center),
|
||||
// //new Column("CellLinks", "链接", ColumnAlign.Center)
|
||||
// //{
|
||||
// // Fixed = true,//冻结列
|
||||
// //},
|
||||
// };
|
||||
//}
|
||||
private void InitData()
|
||||
{
|
||||
antList = new AntList<CameraBase>();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
antList.Add(new CameraBase
|
||||
{
|
||||
CameraName = "相机1",
|
||||
CameraIP = "",
|
||||
Gain = 6,
|
||||
IsHardwareTrigger = true,
|
||||
RotateImage = 50,
|
||||
Exposure = 100,
|
||||
|
||||
|
||||
//CellLinks = new CellLink[] {new CellLink("https://gitee.com/antdui/AntdUI", "AntdUI"),
|
||||
//new CellButton(Guid.NewGuid().ToString(),"编辑",TTypeMini.Primary),
|
||||
//new CellButton(Guid.NewGuid().ToString(), "徽标", TTypeMini.Success)
|
||||
//{
|
||||
// //支持所有单元格控件
|
||||
// DropDownItems = new ISelectItem[]
|
||||
// {
|
||||
// new AntdUI.SelectItem(TState.Default),
|
||||
// new AntdUI.SelectItem(TState.Primary),
|
||||
// new AntdUI.SelectItem(TState.Success),
|
||||
// new AntdUI.SelectItem(TState.Error),
|
||||
// new AntdUI.SelectItem(TState.Warn),
|
||||
// new AntdUI.SelectItem(TState.Processing),
|
||||
|
||||
// },
|
||||
// DropDownValueChanged = (value) =>
|
||||
// {
|
||||
// string badge = value.ToString();
|
||||
// //switch(badge) {
|
||||
// //case "Default":
|
||||
// // curUser.CellBadge = new CellBadge(TState.Default, badge); break;
|
||||
// //case "Primary":
|
||||
// // curUser.CellBadge = new CellBadge(TState.Primary, badge); break;
|
||||
// //case "Success":
|
||||
// // curUser.CellBadge = new CellBadge(TState.Success, badge); break;
|
||||
// //case "Error":
|
||||
// // curUser.CellBadge = new CellBadge(TState.Error, badge); break;
|
||||
// //case "Warn":
|
||||
// // curUser.CellBadge = new CellBadge(TState.Warn, badge); break;
|
||||
// //case "Processing":
|
||||
// // curUser.CellBadge = new CellBadge(TState.Processing, badge); break;
|
||||
// //}
|
||||
// }
|
||||
//},
|
||||
//new CellButton(Guid.NewGuid().ToString(),"删除",TTypeMini.Error),
|
||||
//new CellButton(Guid.NewGuid().ToString(),"查看图片",TTypeMini.Primary)},
|
||||
//value:0-1
|
||||
// CellProgress = new CellProgress(0.5f),
|
||||
// CellDivider = new CellDivider(),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
//设置树数据,可为任意行设置
|
||||
|
||||
// antList[1].Users = subUsers.ToArray();
|
||||
// table_base.Binding(antList);
|
||||
|
||||
//设置行禁用
|
||||
// table_base.SetRowEnable(0, false, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
120
DHSoftware/Views/CameraConfigControl.resx
Normal file
120
DHSoftware/Views/CameraConfigControl.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>
|
||||
196
DHSoftware/Views/CtrlVisionDisplay.Designer.cs
generated
Normal file
196
DHSoftware/Views/CtrlVisionDisplay.Designer.cs
generated
Normal file
@@ -0,0 +1,196 @@
|
||||
namespace XKRS.UI.Device.Winform
|
||||
{
|
||||
partial class CtrlVisionDisplay
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要修改
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.ctmsVisibleControl = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.tsmiShowToolBar = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tsmiShowImageSwitch = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tsmiShowStatusBar = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.tsmiShowOpConfig = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.gBox = new System.Windows.Forms.GroupBox();
|
||||
this.tscImageSwitch = new System.Windows.Forms.ToolStripContainer();
|
||||
this.chkShowDefect = new System.Windows.Forms.CheckBox();
|
||||
this.chkShowOrigin = new System.Windows.Forms.CheckBox();
|
||||
this.plMain = new System.Windows.Forms.Panel();
|
||||
this.ctmsVisibleControl.SuspendLayout();
|
||||
this.gBox.SuspendLayout();
|
||||
this.tscImageSwitch.ContentPanel.SuspendLayout();
|
||||
this.tscImageSwitch.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// ctmsVisibleControl
|
||||
//
|
||||
this.ctmsVisibleControl.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.tsmiShowToolBar,
|
||||
this.tsmiShowImageSwitch,
|
||||
this.tsmiShowStatusBar,
|
||||
this.tsmiShowOpConfig});
|
||||
this.ctmsVisibleControl.Name = "ctmsVisibleControl";
|
||||
this.ctmsVisibleControl.Size = new System.Drawing.Size(149, 92);
|
||||
//
|
||||
// tsmiShowToolBar
|
||||
//
|
||||
this.tsmiShowToolBar.CheckOnClick = true;
|
||||
this.tsmiShowToolBar.Name = "tsmiShowToolBar";
|
||||
this.tsmiShowToolBar.Size = new System.Drawing.Size(148, 22);
|
||||
this.tsmiShowToolBar.Text = "显示工具栏";
|
||||
this.tsmiShowToolBar.CheckedChanged += new System.EventHandler(this.tsmiShowToolBar_CheckedChanged);
|
||||
//
|
||||
// tsmiShowImageSwitch
|
||||
//
|
||||
this.tsmiShowImageSwitch.CheckOnClick = true;
|
||||
this.tsmiShowImageSwitch.Name = "tsmiShowImageSwitch";
|
||||
this.tsmiShowImageSwitch.Size = new System.Drawing.Size(148, 22);
|
||||
this.tsmiShowImageSwitch.Text = "显示图像开关";
|
||||
this.tsmiShowImageSwitch.CheckedChanged += new System.EventHandler(this.tsmiShowOpBar_CheckedChanged);
|
||||
//
|
||||
// tsmiShowStatusBar
|
||||
//
|
||||
this.tsmiShowStatusBar.CheckOnClick = true;
|
||||
this.tsmiShowStatusBar.Name = "tsmiShowStatusBar";
|
||||
this.tsmiShowStatusBar.Size = new System.Drawing.Size(148, 22);
|
||||
this.tsmiShowStatusBar.Text = "显示状态栏";
|
||||
this.tsmiShowStatusBar.CheckedChanged += new System.EventHandler(this.tsmiShowStatusBar_CheckedChanged);
|
||||
//
|
||||
// tsmiShowOpConfig
|
||||
//
|
||||
this.tsmiShowOpConfig.CheckOnClick = true;
|
||||
this.tsmiShowOpConfig.Name = "tsmiShowOpConfig";
|
||||
this.tsmiShowOpConfig.Size = new System.Drawing.Size(148, 22);
|
||||
this.tsmiShowOpConfig.Text = "显示操作配置";
|
||||
this.tsmiShowOpConfig.CheckedChanged += new System.EventHandler(this.tsmiShowOpConfig_CheckedChanged);
|
||||
//
|
||||
// gBox
|
||||
//
|
||||
this.gBox.Controls.Add(this.tscImageSwitch);
|
||||
this.gBox.Controls.Add(this.plMain);
|
||||
this.gBox.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.gBox.Font = new System.Drawing.Font("Tahoma", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.gBox.Location = new System.Drawing.Point(0, 0);
|
||||
this.gBox.Name = "gBox";
|
||||
this.gBox.Size = new System.Drawing.Size(596, 488);
|
||||
this.gBox.TabIndex = 2;
|
||||
this.gBox.TabStop = false;
|
||||
this.gBox.Text = "groupBox1";
|
||||
//
|
||||
// tscImageSwitch
|
||||
//
|
||||
this.tscImageSwitch.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tscImageSwitch.BottomToolStripPanelVisible = false;
|
||||
//
|
||||
// tscImageSwitch.ContentPanel
|
||||
//
|
||||
this.tscImageSwitch.ContentPanel.BackColor = System.Drawing.Color.Transparent;
|
||||
this.tscImageSwitch.ContentPanel.Controls.Add(this.chkShowDefect);
|
||||
this.tscImageSwitch.ContentPanel.Controls.Add(this.chkShowOrigin);
|
||||
this.tscImageSwitch.ContentPanel.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.tscImageSwitch.ContentPanel.Size = new System.Drawing.Size(202, 24);
|
||||
this.tscImageSwitch.LeftToolStripPanelVisible = false;
|
||||
this.tscImageSwitch.Location = new System.Drawing.Point(78, 13);
|
||||
this.tscImageSwitch.Name = "tscImageSwitch";
|
||||
this.tscImageSwitch.RightToolStripPanelVisible = false;
|
||||
this.tscImageSwitch.Size = new System.Drawing.Size(202, 24);
|
||||
this.tscImageSwitch.TabIndex = 3;
|
||||
this.tscImageSwitch.Text = "toolStripContainer2";
|
||||
this.tscImageSwitch.TopToolStripPanelVisible = false;
|
||||
this.tscImageSwitch.Visible = false;
|
||||
//
|
||||
// chkShowDefect
|
||||
//
|
||||
this.chkShowDefect.AutoSize = true;
|
||||
this.chkShowDefect.Checked = true;
|
||||
this.chkShowDefect.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.chkShowDefect.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.chkShowDefect.Location = new System.Drawing.Point(3, 3);
|
||||
this.chkShowDefect.Name = "chkShowDefect";
|
||||
this.chkShowDefect.Size = new System.Drawing.Size(74, 18);
|
||||
this.chkShowDefect.TabIndex = 0;
|
||||
this.chkShowDefect.Text = "显示缺陷";
|
||||
this.chkShowDefect.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.chkShowDefect.TextImageRelation = System.Windows.Forms.TextImageRelation.TextAboveImage;
|
||||
this.chkShowDefect.UseVisualStyleBackColor = true;
|
||||
this.chkShowDefect.CheckedChanged += new System.EventHandler(this.chkShowDefect_CheckedChanged);
|
||||
//
|
||||
// chkShowOrigin
|
||||
//
|
||||
this.chkShowOrigin.AutoSize = true;
|
||||
this.chkShowOrigin.Checked = true;
|
||||
this.chkShowOrigin.CheckState = System.Windows.Forms.CheckState.Checked;
|
||||
this.chkShowOrigin.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.chkShowOrigin.Location = new System.Drawing.Point(83, 3);
|
||||
this.chkShowOrigin.Name = "chkShowOrigin";
|
||||
this.chkShowOrigin.Size = new System.Drawing.Size(74, 18);
|
||||
this.chkShowOrigin.TabIndex = 1;
|
||||
this.chkShowOrigin.Text = "显示原图";
|
||||
this.chkShowOrigin.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.chkShowOrigin.TextImageRelation = System.Windows.Forms.TextImageRelation.TextAboveImage;
|
||||
this.chkShowOrigin.UseVisualStyleBackColor = true;
|
||||
this.chkShowOrigin.CheckedChanged += new System.EventHandler(this.chkShowOrigin_CheckedChanged);
|
||||
//
|
||||
// plMain
|
||||
//
|
||||
this.plMain.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.plMain.Location = new System.Drawing.Point(3, 18);
|
||||
this.plMain.Name = "plMain";
|
||||
this.plMain.Size = new System.Drawing.Size(590, 467);
|
||||
this.plMain.TabIndex = 0;
|
||||
//
|
||||
// CtrlDetectionDisplay
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ContextMenuStrip = this.ctmsVisibleControl;
|
||||
this.Controls.Add(this.gBox);
|
||||
this.Name = "CtrlDetectionDisplay";
|
||||
this.Size = new System.Drawing.Size(596, 488);
|
||||
this.ctmsVisibleControl.ResumeLayout(false);
|
||||
this.gBox.ResumeLayout(false);
|
||||
this.tscImageSwitch.ContentPanel.ResumeLayout(false);
|
||||
this.tscImageSwitch.ContentPanel.PerformLayout();
|
||||
this.tscImageSwitch.ResumeLayout(false);
|
||||
this.tscImageSwitch.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.ContextMenuStrip ctmsVisibleControl;
|
||||
private System.Windows.Forms.ToolStripMenuItem tsmiShowToolBar;
|
||||
private System.Windows.Forms.ToolStripMenuItem tsmiShowImageSwitch;
|
||||
private System.Windows.Forms.ToolStripMenuItem tsmiShowStatusBar;
|
||||
private System.Windows.Forms.GroupBox gBox;
|
||||
private System.Windows.Forms.Panel plMain;
|
||||
private System.Windows.Forms.ToolStripMenuItem tsmiShowOpConfig;
|
||||
private System.Windows.Forms.ToolStripContainer tscImageSwitch;
|
||||
private System.Windows.Forms.CheckBox chkShowDefect;
|
||||
private System.Windows.Forms.CheckBox chkShowOrigin;
|
||||
}
|
||||
}
|
||||
172
DHSoftware/Views/CtrlVisionDisplay.cs
Normal file
172
DHSoftware/Views/CtrlVisionDisplay.cs
Normal file
@@ -0,0 +1,172 @@
|
||||
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using DH.Commons.Enums;
|
||||
using DH.UI.Model.Winform;
|
||||
|
||||
namespace XKRS.UI.Device.Winform
|
||||
{
|
||||
public partial class CtrlVisionDisplay : UserControl
|
||||
{
|
||||
public Canvas CvImage { get; set; }
|
||||
public bool IsShowPreTreatedImage { get; set; } = true;
|
||||
public bool IsShowDefectImage { get; set; } = true;
|
||||
|
||||
public Bitmap CurrBitmap { get; set; }
|
||||
public List<IShapeElement> CurrDetectionResults { get; set; } = new List<IShapeElement>();
|
||||
|
||||
public event Action<bool> OnShowOpConfigMenuStateChanged;
|
||||
|
||||
public CtrlVisionDisplay()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
CvImage = new Canvas();
|
||||
CvImage.IsShowElementList = false;
|
||||
CvImage.IsShowROITool = false;
|
||||
CvImage.Dock = DockStyle.Fill;
|
||||
|
||||
CvImage.ContextMenuStrip = ctmsVisibleControl;
|
||||
|
||||
plMain.Controls.Add(CvImage);
|
||||
|
||||
InitialToolBarVisible();
|
||||
|
||||
this.Load += ((s, e) =>
|
||||
{
|
||||
gBox.Text = DetectionName;
|
||||
});
|
||||
}
|
||||
|
||||
public string DetectionId { get; set; }
|
||||
|
||||
public string DetectionName { get; set; }
|
||||
|
||||
public int RowIndex { get; set; }
|
||||
|
||||
public int ColIndex { get; set; }
|
||||
|
||||
public void RefreshDetectionResult(Bitmap image, List<IShapeElement> detectionResults)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (image == null)
|
||||
return;
|
||||
|
||||
CurrBitmap = image;
|
||||
if (detectionResults != null)
|
||||
{
|
||||
CurrDetectionResults = new List<IShapeElement>(detectionResults);
|
||||
}
|
||||
|
||||
if (CvImage.IsHandleCreated)
|
||||
{
|
||||
CvImage.Elements.Clear();
|
||||
if (IsShowPreTreatedImage)
|
||||
{
|
||||
CvImage.LoadImage(image);
|
||||
}
|
||||
else
|
||||
{
|
||||
//加载一张同样大小的 空白图
|
||||
Bitmap newImage = new Bitmap(image.Width, image.Height);
|
||||
using (Graphics grp = Graphics.FromImage(newImage))
|
||||
{
|
||||
grp.FillRectangle(Brushes.White, 0, 0, newImage.Width, newImage.Height);
|
||||
}
|
||||
|
||||
CvImage.LoadImage(newImage);
|
||||
}
|
||||
|
||||
if (IsShowDefectImage && detectionResults != null)
|
||||
{
|
||||
detectionResults.ForEach(e => CvImage.Elements.Add(e));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
#region 图像显示开关
|
||||
|
||||
private void chkShowDefect_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
IsShowDefectImage = chkShowDefect.Checked;
|
||||
RefreshDetectionResult(CurrBitmap, CurrDetectionResults);
|
||||
}
|
||||
|
||||
private void chkShowOrigin_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
IsShowPreTreatedImage = chkShowOrigin.Checked;
|
||||
RefreshDetectionResult(CurrBitmap, CurrDetectionResults);
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region 显示控制
|
||||
public bool IsShowOperationBar
|
||||
{
|
||||
get => tscImageSwitch.Visible;
|
||||
set => tsmiShowImageSwitch.Checked = tscImageSwitch.Visible = value;
|
||||
}
|
||||
|
||||
public bool IsShowToolBar
|
||||
{
|
||||
get => CvImage.IsShowToolBar;
|
||||
set => tsmiShowToolBar.Checked = CvImage.IsShowToolBar = value;
|
||||
}
|
||||
|
||||
public bool IsShowStatusBar
|
||||
{
|
||||
get => CvImage.IsShowStatusBar;
|
||||
set => tsmiShowStatusBar.Checked = CvImage.IsShowStatusBar = value;
|
||||
}
|
||||
|
||||
private bool isShowOpConfig = false;
|
||||
public bool IsShowOpConfig
|
||||
{
|
||||
get => tsmiShowOpConfig.Checked;
|
||||
set
|
||||
{
|
||||
if (tsmiShowOpConfig.Checked != value)
|
||||
{
|
||||
tsmiShowOpConfig.Checked = value;
|
||||
}
|
||||
|
||||
OnShowOpConfigMenuStateChanged?.Invoke(value);
|
||||
}
|
||||
}
|
||||
|
||||
private void tsmiShowOpConfig_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
IsShowOpConfig = tsmiShowOpConfig.Checked;
|
||||
}
|
||||
|
||||
private void InitialToolBarVisible()
|
||||
{
|
||||
IsShowOperationBar = IsShowToolBar = IsShowStatusBar = false;
|
||||
}
|
||||
|
||||
private void tsmiShowToolBar_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
IsShowToolBar = tsmiShowToolBar.Checked;
|
||||
}
|
||||
|
||||
private void tsmiShowOpBar_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
IsShowOperationBar = tsmiShowImageSwitch.Checked;
|
||||
}
|
||||
|
||||
private void tsmiShowStatusBar_CheckedChanged(object sender, EventArgs e)
|
||||
{
|
||||
IsShowStatusBar = tsmiShowStatusBar.Checked;
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
123
DHSoftware/Views/CtrlVisionDisplay.resx
Normal file
123
DHSoftware/Views/CtrlVisionDisplay.resx
Normal file
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<metadata name="ctmsVisibleControl.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
|
||||
<value>44, 19</value>
|
||||
</metadata>
|
||||
</root>
|
||||
174
DHSoftware/Views/CtrlVisionRunBase.Designer.cs
generated
Normal file
174
DHSoftware/Views/CtrlVisionRunBase.Designer.cs
generated
Normal file
@@ -0,0 +1,174 @@
|
||||
|
||||
namespace XKRS.UI.Device.Winform
|
||||
{
|
||||
partial class CtrlVisionRunBase
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要修改
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.tableDisplay = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.tlpOpConfig = new System.Windows.Forms.TableLayoutPanel();
|
||||
this.propOpConfig = new System.Windows.Forms.PropertyGrid();
|
||||
this.flowLayoutPanel1 = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.btnExecuteOpConfig = new System.Windows.Forms.Button();
|
||||
this.btnBatchRun = new System.Windows.Forms.Button();
|
||||
this.splitCMain = new System.Windows.Forms.SplitContainer();
|
||||
this.tlpOpConfig.SuspendLayout();
|
||||
this.flowLayoutPanel1.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitCMain)).BeginInit();
|
||||
this.splitCMain.Panel1.SuspendLayout();
|
||||
this.splitCMain.Panel2.SuspendLayout();
|
||||
this.splitCMain.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tableDisplay
|
||||
//
|
||||
this.tableDisplay.ColumnCount = 2;
|
||||
this.tableDisplay.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableDisplay.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableDisplay.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tableDisplay.Location = new System.Drawing.Point(0, 0);
|
||||
this.tableDisplay.Name = "tableDisplay";
|
||||
this.tableDisplay.RowCount = 2;
|
||||
this.tableDisplay.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableDisplay.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
||||
this.tableDisplay.Size = new System.Drawing.Size(769, 251);
|
||||
this.tableDisplay.TabIndex = 0;
|
||||
//
|
||||
// tlpOpConfig
|
||||
//
|
||||
this.tlpOpConfig.ColumnCount = 1;
|
||||
this.tlpOpConfig.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tlpOpConfig.Controls.Add(this.propOpConfig, 0, 1);
|
||||
this.tlpOpConfig.Controls.Add(this.flowLayoutPanel1, 0, 0);
|
||||
this.tlpOpConfig.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.tlpOpConfig.Location = new System.Drawing.Point(0, 0);
|
||||
this.tlpOpConfig.Name = "tlpOpConfig";
|
||||
this.tlpOpConfig.RowCount = 2;
|
||||
this.tlpOpConfig.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 35F));
|
||||
this.tlpOpConfig.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tlpOpConfig.Size = new System.Drawing.Size(769, 247);
|
||||
this.tlpOpConfig.TabIndex = 0;
|
||||
//
|
||||
// propOpConfig
|
||||
//
|
||||
this.propOpConfig.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.propOpConfig.Location = new System.Drawing.Point(3, 38);
|
||||
this.propOpConfig.Name = "propOpConfig";
|
||||
this.propOpConfig.Size = new System.Drawing.Size(763, 206);
|
||||
this.propOpConfig.TabIndex = 1;
|
||||
this.propOpConfig.ToolbarVisible = false;
|
||||
//
|
||||
// flowLayoutPanel1
|
||||
//
|
||||
this.flowLayoutPanel1.Controls.Add(this.btnExecuteOpConfig);
|
||||
this.flowLayoutPanel1.Controls.Add(this.btnBatchRun);
|
||||
this.flowLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.flowLayoutPanel1.FlowDirection = System.Windows.Forms.FlowDirection.RightToLeft;
|
||||
this.flowLayoutPanel1.Location = new System.Drawing.Point(0, 0);
|
||||
this.flowLayoutPanel1.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.flowLayoutPanel1.Name = "flowLayoutPanel1";
|
||||
this.flowLayoutPanel1.Size = new System.Drawing.Size(769, 35);
|
||||
this.flowLayoutPanel1.TabIndex = 2;
|
||||
//
|
||||
// btnExecuteOpConfig
|
||||
//
|
||||
this.btnExecuteOpConfig.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnExecuteOpConfig.BackColor = System.Drawing.SystemColors.GradientActiveCaption;
|
||||
this.btnExecuteOpConfig.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnExecuteOpConfig.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.btnExecuteOpConfig.Location = new System.Drawing.Point(598, 3);
|
||||
this.btnExecuteOpConfig.Margin = new System.Windows.Forms.Padding(5, 3, 5, 3);
|
||||
this.btnExecuteOpConfig.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.btnExecuteOpConfig.Name = "btnExecuteOpConfig";
|
||||
this.btnExecuteOpConfig.Size = new System.Drawing.Size(166, 30);
|
||||
this.btnExecuteOpConfig.TabIndex = 0;
|
||||
this.btnExecuteOpConfig.Text = "执行当前配置操作";
|
||||
this.btnExecuteOpConfig.UseVisualStyleBackColor = false;
|
||||
// this.btnExecuteOpConfig.Click += new System.EventHandler(this.btnExecuteOpConfig_Click);
|
||||
//
|
||||
// btnBatchRun
|
||||
//
|
||||
this.btnBatchRun.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnBatchRun.BackColor = System.Drawing.SystemColors.Info;
|
||||
this.btnBatchRun.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.btnBatchRun.Font = new System.Drawing.Font("微软雅黑", 12F);
|
||||
this.btnBatchRun.Location = new System.Drawing.Point(488, 3);
|
||||
this.btnBatchRun.Margin = new System.Windows.Forms.Padding(5, 3, 5, 3);
|
||||
this.btnBatchRun.MinimumSize = new System.Drawing.Size(1, 1);
|
||||
this.btnBatchRun.Name = "btnBatchRun";
|
||||
this.btnBatchRun.Size = new System.Drawing.Size(100, 30);
|
||||
this.btnBatchRun.TabIndex = 0;
|
||||
this.btnBatchRun.Text = "批量检测";
|
||||
this.btnBatchRun.UseVisualStyleBackColor = false;
|
||||
// this.btnBatchRun.Click += new System.EventHandler(this.btnBatchRun_Click);
|
||||
//
|
||||
// splitCMain
|
||||
//
|
||||
this.splitCMain.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.splitCMain.Location = new System.Drawing.Point(0, 0);
|
||||
this.splitCMain.Name = "splitCMain";
|
||||
this.splitCMain.Orientation = System.Windows.Forms.Orientation.Horizontal;
|
||||
//
|
||||
// splitCMain.Panel1
|
||||
//
|
||||
this.splitCMain.Panel1.Controls.Add(this.tableDisplay);
|
||||
//
|
||||
// splitCMain.Panel2
|
||||
//
|
||||
this.splitCMain.Panel2.Controls.Add(this.tlpOpConfig);
|
||||
this.splitCMain.Size = new System.Drawing.Size(769, 502);
|
||||
this.splitCMain.SplitterDistance = 251;
|
||||
this.splitCMain.TabIndex = 2;
|
||||
//
|
||||
// CtrlVisionRunBase
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.splitCMain);
|
||||
this.Name = "CtrlVisionRunBase";
|
||||
this.Size = new System.Drawing.Size(769, 502);
|
||||
this.tlpOpConfig.ResumeLayout(false);
|
||||
this.flowLayoutPanel1.ResumeLayout(false);
|
||||
this.splitCMain.Panel1.ResumeLayout(false);
|
||||
this.splitCMain.Panel2.ResumeLayout(false);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitCMain)).EndInit();
|
||||
this.splitCMain.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TableLayoutPanel tableDisplay;
|
||||
private System.Windows.Forms.TableLayoutPanel tlpOpConfig;
|
||||
private System.Windows.Forms.Button btnExecuteOpConfig;
|
||||
private System.Windows.Forms.PropertyGrid propOpConfig;
|
||||
private System.Windows.Forms.SplitContainer splitCMain;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowLayoutPanel1;
|
||||
private System.Windows.Forms.Button btnBatchRun;
|
||||
}
|
||||
}
|
||||
249
DHSoftware/Views/CtrlVisionRunBase.cs
Normal file
249
DHSoftware/Views/CtrlVisionRunBase.cs
Normal file
@@ -0,0 +1,249 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
using System.IO;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Devices;
|
||||
|
||||
|
||||
namespace XKRS.UI.Device.Winform
|
||||
{
|
||||
public partial class CtrlVisionRunBase : UserControl
|
||||
{
|
||||
|
||||
private DateTime LastDisplayTime = DateTime.MinValue;
|
||||
|
||||
|
||||
//public CtrlVisionRunBase()
|
||||
//{
|
||||
// InitializeComponent();
|
||||
//}
|
||||
|
||||
//private object OnUpdateBatchNO(ISubscriber arg1, object arg2, object arg3)
|
||||
//{
|
||||
// //获取BatchNO
|
||||
// if (arg2 is string batchNo)
|
||||
// {
|
||||
// ML.BatchNO = string.IsNullOrEmpty(batchNo) ? "OFFline_" + DateTime.Now.ToString("yyyyMMdd") : batchNo;
|
||||
// }
|
||||
// return null;
|
||||
//}
|
||||
|
||||
public CtrlVisionRunBase(VisionEngineBase device)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
Device = device;
|
||||
InitialLayout();
|
||||
|
||||
this.Load += (s, e) =>
|
||||
{
|
||||
ML.OnDetectionDone -= ML_OnDetectionDone;
|
||||
ML.OnDetectionDone += ML_OnDetectionDone;
|
||||
};
|
||||
|
||||
// PubSubCenter.GetInstance().RemoveSubscribers(PubSubCenterMessageType.UpdateBatchNO.ToString());
|
||||
// PubSubCenter.GetInstance().Subscribe(PubSubCenterMessageType.UpdateBatchNO.ToString(), OnUpdateBatchNO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private async void ML_OnDetectionDone(string detectionId, Bitmap image, List<IShapeElement> detectionResults)
|
||||
{
|
||||
|
||||
await Task.Run(() =>
|
||||
{
|
||||
if (!this.IsHandleCreated)
|
||||
return;
|
||||
|
||||
this.Invoke(new Action(() =>
|
||||
{
|
||||
if (this.IsDisposed)
|
||||
return;
|
||||
var display = displayList.FirstOrDefault(u => u.DetectionId == detectionId);
|
||||
if (display != null)
|
||||
{
|
||||
display.RefreshDetectionResult(image, detectionResults);
|
||||
}
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
public VisionEngineBase Device { get; set; }
|
||||
|
||||
protected VisionEngineBase ML
|
||||
{
|
||||
get => Device as VisionEngineBase;
|
||||
}
|
||||
|
||||
//VisionEngineInitialConfigBase IConfig => ML?.InitialConfig as VisionEngineInitialConfigBase;
|
||||
|
||||
//VisionEngineOperationConfigBase OpConfig = new VisionEngineOperationConfigBase();
|
||||
|
||||
//private void btnExecuteOpConfig_Click(object sender, EventArgs e)
|
||||
//{
|
||||
// try
|
||||
// {
|
||||
// PubSubCenter.GetInstance().Publish(PubSubCenterMessageType.RequestBatchNO.ToString(), null, null);
|
||||
// var msg = ML.RunWrap(OpConfig);
|
||||
|
||||
// if (msg.Result != 1)
|
||||
// {
|
||||
// MessageBox.Show(msg.Message);
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// MessageBox.Show(ex.GetExceptionMessage());
|
||||
// }
|
||||
//}
|
||||
|
||||
#region Layout
|
||||
int rows = 1;
|
||||
int cols = 1;
|
||||
|
||||
public int Rows
|
||||
{
|
||||
get => rows;
|
||||
set
|
||||
{
|
||||
if (value <= 1)
|
||||
{
|
||||
rows = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rows = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Cols
|
||||
{
|
||||
get => cols;
|
||||
set
|
||||
{
|
||||
if (value <= 1)
|
||||
{
|
||||
cols = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
cols = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<CtrlVisionDisplay> displayList = null;
|
||||
|
||||
private void InitialLayout()
|
||||
{
|
||||
if (ML.DetectionConfigs.Count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var locations = ML.DetectionConfigs.Select(u => u.ShowLocation).ToList();
|
||||
|
||||
if (locations.Count > 0)
|
||||
{
|
||||
Rows = (int)locations.Max(u => u.Y);
|
||||
Cols = (int)locations.Max(u => u.X);
|
||||
}
|
||||
|
||||
|
||||
tableDisplay.ColumnCount = Cols;
|
||||
tableDisplay.RowCount = Rows;
|
||||
|
||||
tableDisplay.ColumnStyles.Clear();
|
||||
for (int i = 0; i < Cols; i++)
|
||||
{
|
||||
ColumnStyle colStyle = new ColumnStyle();
|
||||
colStyle.SizeType = SizeType.Percent;
|
||||
colStyle.Width = 1.0f / (float)Cols;
|
||||
|
||||
tableDisplay.ColumnStyles.Add(colStyle);
|
||||
}
|
||||
|
||||
tableDisplay.RowStyles.Clear();
|
||||
for (int i = 0; i < Rows; i++)
|
||||
{
|
||||
RowStyle rowStyle = new RowStyle();
|
||||
rowStyle.SizeType = SizeType.Percent;
|
||||
rowStyle.Height = 1.0f / (float)Rows;
|
||||
|
||||
tableDisplay.RowStyles.Add(rowStyle);
|
||||
}
|
||||
|
||||
tableDisplay.Controls.Clear();
|
||||
displayList = new List<CtrlVisionDisplay>();
|
||||
|
||||
ML.DetectionConfigs.ForEach(d =>
|
||||
{
|
||||
//if (!d.IsShowInUI)
|
||||
// return;
|
||||
|
||||
CtrlVisionDisplay display = new CtrlVisionDisplay();
|
||||
display.DetectionId = d.Id;
|
||||
display.DetectionName = d.Name;
|
||||
display.RowIndex = (int)d.ShowLocation.Y - 1;
|
||||
display.ColIndex = (int)d.ShowLocation.X - 1;
|
||||
//display.RowIndex = (int)count%row;
|
||||
//display.ColIndex = (int)count / row;
|
||||
|
||||
display.Dock = DockStyle.Fill;
|
||||
|
||||
display.OnShowOpConfigMenuStateChanged -= Display_OnShowOpConfigMenuStateChanged;
|
||||
display.OnShowOpConfigMenuStateChanged += Display_OnShowOpConfigMenuStateChanged;
|
||||
|
||||
displayList.Add(display);
|
||||
tableDisplay.Controls.Add(display);
|
||||
tableDisplay.SetCellPosition(display, new TableLayoutPanelCellPosition(display.ColIndex, display.RowIndex));
|
||||
});
|
||||
|
||||
splitCMain.Panel2Collapsed = true;
|
||||
|
||||
// propOpConfig.SelectedObject = OpConfig;
|
||||
}
|
||||
|
||||
private void Display_OnShowOpConfigMenuStateChanged(bool isVisible)
|
||||
{
|
||||
IsShowOpConfig = isVisible;
|
||||
}
|
||||
|
||||
public bool IsShowOpConfig
|
||||
{
|
||||
get => !splitCMain.Panel2Collapsed;
|
||||
set
|
||||
{
|
||||
if (splitCMain.Panel2Collapsed == value)
|
||||
{
|
||||
splitCMain.Panel2Collapsed = !value;
|
||||
|
||||
displayList.ForEach(d => d.IsShowOpConfig = value);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
//private void btnBatchRun_Click(object sender, EventArgs e)
|
||||
//{
|
||||
// FrmMLBatchRun frmMLBatchRun = new FrmMLBatchRun(Device);
|
||||
|
||||
// frmMLBatchRun.MdiParent = (this.Parent as DeviceRunFrmBase).MdiParent;
|
||||
// frmMLBatchRun.DockPanel = (this.Parent as DeviceRunFrmBase).DockPanel;
|
||||
// frmMLBatchRun.DockState = DockState.Document;
|
||||
// frmMLBatchRun.Text = $"{Device.Name}_批量检测";
|
||||
|
||||
// frmMLBatchRun.Show();
|
||||
//}
|
||||
}
|
||||
}
|
||||
120
DHSoftware/Views/CtrlVisionRunBase.resx
Normal file
120
DHSoftware/Views/CtrlVisionRunBase.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>
|
||||
284
DHSoftware/Views/DefectRowEdit.Designer.cs
generated
Normal file
284
DHSoftware/Views/DefectRowEdit.Designer.cs
generated
Normal file
@@ -0,0 +1,284 @@
|
||||
namespace AntdUIDemo.Views.Table
|
||||
{
|
||||
partial class DefectRowEdit
|
||||
{
|
||||
/// <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();
|
||||
select_Result = new AntdUI.Select();
|
||||
label5 = new AntdUI.Label();
|
||||
input_maxArea = new AntdUI.InputNumber();
|
||||
label3 = new AntdUI.Label();
|
||||
input_minArea = new AntdUI.InputNumber();
|
||||
label4 = new AntdUI.Label();
|
||||
input_maxScore = new AntdUI.InputNumber();
|
||||
label2 = new AntdUI.Label();
|
||||
input_minScore = new AntdUI.InputNumber();
|
||||
label1 = new AntdUI.Label();
|
||||
input_name = new AntdUI.Input();
|
||||
标签名 = new AntdUI.Label();
|
||||
divider1 = new AntdUI.Divider();
|
||||
stackPanel1 = new AntdUI.StackPanel();
|
||||
button_cancel = new AntdUI.Button();
|
||||
button_ok = new AntdUI.Button();
|
||||
panel1.SuspendLayout();
|
||||
stackPanel1.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Controls.Add(select_Result);
|
||||
panel1.Controls.Add(label5);
|
||||
panel1.Controls.Add(input_maxArea);
|
||||
panel1.Controls.Add(label3);
|
||||
panel1.Controls.Add(input_minArea);
|
||||
panel1.Controls.Add(label4);
|
||||
panel1.Controls.Add(input_maxScore);
|
||||
panel1.Controls.Add(label2);
|
||||
panel1.Controls.Add(input_minScore);
|
||||
panel1.Controls.Add(label1);
|
||||
panel1.Controls.Add(input_name);
|
||||
panel1.Controls.Add(标签名);
|
||||
panel1.Controls.Add(divider1);
|
||||
panel1.Controls.Add(stackPanel1);
|
||||
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, 505);
|
||||
panel1.TabIndex = 0;
|
||||
panel1.Text = "panel1";
|
||||
//
|
||||
// select_Result
|
||||
//
|
||||
select_Result.Dock = DockStyle.Top;
|
||||
select_Result.Location = new Point(18, 408);
|
||||
select_Result.Name = "select_Result";
|
||||
select_Result.Size = new Size(464, 41);
|
||||
select_Result.TabIndex = 27;
|
||||
select_Result.Text = "select1";
|
||||
//
|
||||
// label5
|
||||
//
|
||||
label5.Dock = DockStyle.Top;
|
||||
label5.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
label5.Location = new Point(18, 384);
|
||||
label5.Name = "label5";
|
||||
label5.Size = new Size(464, 24);
|
||||
label5.TabIndex = 25;
|
||||
label5.Text = "标签结果";
|
||||
//
|
||||
// input_maxArea
|
||||
//
|
||||
input_maxArea.Dock = DockStyle.Top;
|
||||
input_maxArea.Font = new Font("Microsoft YaHei UI", 9F);
|
||||
input_maxArea.Increment = new decimal(new int[] { 10, 0, 0, 0 });
|
||||
input_maxArea.Location = new Point(18, 346);
|
||||
input_maxArea.Maximum = new decimal(new int[] { 999999999, 0, 0, 0 });
|
||||
input_maxArea.Minimum = new decimal(new int[] { 0, 0, 0, 0 });
|
||||
input_maxArea.Name = "input_maxArea";
|
||||
input_maxArea.Radius = 3;
|
||||
input_maxArea.Size = new Size(464, 38);
|
||||
input_maxArea.TabIndex = 24;
|
||||
input_maxArea.Text = "0";
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.Dock = DockStyle.Top;
|
||||
label3.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
label3.Location = new Point(18, 322);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(464, 24);
|
||||
label3.TabIndex = 23;
|
||||
label3.Text = "最大面积";
|
||||
//
|
||||
// input_minArea
|
||||
//
|
||||
input_minArea.Dock = DockStyle.Top;
|
||||
input_minArea.Font = new Font("Microsoft YaHei UI", 9F);
|
||||
input_minArea.Increment = new decimal(new int[] { 10, 0, 0, 0 });
|
||||
input_minArea.Location = new Point(18, 284);
|
||||
input_minArea.Maximum = new decimal(new int[] { 999999999, 0, 0, 0 });
|
||||
input_minArea.Minimum = new decimal(new int[] { 0, 0, 0, 0 });
|
||||
input_minArea.Name = "input_minArea";
|
||||
input_minArea.Radius = 3;
|
||||
input_minArea.Size = new Size(464, 38);
|
||||
input_minArea.TabIndex = 22;
|
||||
input_minArea.Text = "0";
|
||||
//
|
||||
// label4
|
||||
//
|
||||
label4.Dock = DockStyle.Top;
|
||||
label4.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
label4.Location = new Point(18, 260);
|
||||
label4.Name = "label4";
|
||||
label4.Size = new Size(464, 24);
|
||||
label4.TabIndex = 21;
|
||||
label4.Text = "最小面积";
|
||||
//
|
||||
// input_maxScore
|
||||
//
|
||||
input_maxScore.Dock = DockStyle.Top;
|
||||
input_maxScore.Font = new Font("Microsoft YaHei UI", 9F);
|
||||
input_maxScore.Increment = new decimal(new int[] { 1, 0, 0, 65536 });
|
||||
input_maxScore.Location = new Point(18, 222);
|
||||
input_maxScore.Maximum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
input_maxScore.Minimum = new decimal(new int[] { 0, 0, 0, 0 });
|
||||
input_maxScore.Name = "input_maxScore";
|
||||
input_maxScore.Radius = 3;
|
||||
input_maxScore.Size = new Size(464, 38);
|
||||
input_maxScore.TabIndex = 20;
|
||||
input_maxScore.Text = "0";
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.Dock = DockStyle.Top;
|
||||
label2.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
label2.Location = new Point(18, 198);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(464, 24);
|
||||
label2.TabIndex = 19;
|
||||
label2.Text = "最大得分";
|
||||
//
|
||||
// input_minScore
|
||||
//
|
||||
input_minScore.Dock = DockStyle.Top;
|
||||
input_minScore.Font = new Font("Microsoft YaHei UI", 9F);
|
||||
input_minScore.Increment = new decimal(new int[] { 1, 0, 0, 65536 });
|
||||
input_minScore.Location = new Point(18, 160);
|
||||
input_minScore.Maximum = new decimal(new int[] { 1, 0, 0, 0 });
|
||||
input_minScore.Minimum = new decimal(new int[] { 0, 0, 0, 0 });
|
||||
input_minScore.Name = "input_minScore";
|
||||
input_minScore.Radius = 3;
|
||||
input_minScore.Size = new Size(464, 38);
|
||||
input_minScore.TabIndex = 18;
|
||||
input_minScore.Text = "0";
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.Dock = DockStyle.Top;
|
||||
label1.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
label1.Location = new Point(18, 136);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(464, 24);
|
||||
label1.TabIndex = 17;
|
||||
label1.Text = "最小得分";
|
||||
//
|
||||
// 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, 98);
|
||||
input_name.Name = "input_name";
|
||||
input_name.Radius = 3;
|
||||
input_name.Size = new Size(464, 38);
|
||||
input_name.TabIndex = 16;
|
||||
//
|
||||
// 标签名
|
||||
//
|
||||
标签名.Dock = DockStyle.Top;
|
||||
标签名.Font = new Font("Microsoft YaHei UI", 12F, FontStyle.Regular, GraphicsUnit.Point, 134);
|
||||
标签名.Location = new Point(18, 74);
|
||||
标签名.Name = "标签名";
|
||||
标签名.Size = new Size(464, 24);
|
||||
标签名.TabIndex = 15;
|
||||
标签名.Text = "标签名";
|
||||
//
|
||||
// divider1
|
||||
//
|
||||
divider1.Dock = DockStyle.Top;
|
||||
divider1.Location = new Point(18, 62);
|
||||
divider1.Name = "divider1";
|
||||
divider1.Size = new Size(464, 12);
|
||||
divider1.TabIndex = 14;
|
||||
//
|
||||
// stackPanel1
|
||||
//
|
||||
stackPanel1.Controls.Add(button_cancel);
|
||||
stackPanel1.Controls.Add(button_ok);
|
||||
stackPanel1.Dock = DockStyle.Top;
|
||||
stackPanel1.Location = new Point(18, 18);
|
||||
stackPanel1.Name = "stackPanel1";
|
||||
stackPanel1.RightToLeft = RightToLeft.No;
|
||||
stackPanel1.Size = new Size(464, 44);
|
||||
stackPanel1.TabIndex = 3;
|
||||
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 = "Cancel";
|
||||
//
|
||||
// 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 = "Submit";
|
||||
button_ok.Type = AntdUI.TTypeMini.Primary;
|
||||
//
|
||||
// DefectRowEdit
|
||||
//
|
||||
Controls.Add(panel1);
|
||||
Name = "DefectRowEdit";
|
||||
Size = new Size(500, 505);
|
||||
panel1.ResumeLayout(false);
|
||||
stackPanel1.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private AntdUI.Panel panel1;
|
||||
private AntdUI.StackPanel stackPanel1;
|
||||
private AntdUI.Button button_cancel;
|
||||
private AntdUI.Button button_ok;
|
||||
private AntdUI.Divider divider1;
|
||||
private AntdUI.Input input_addr;
|
||||
private AntdUI.Label label2;
|
||||
private AntdUI.InputNumber input_minScore;
|
||||
private AntdUI.Label label1;
|
||||
private AntdUI.Input input_name;
|
||||
private AntdUI.Label 标签名;
|
||||
private AntdUI.InputNumber input_maxScore;
|
||||
private AntdUI.InputNumber input_maxArea;
|
||||
private AntdUI.Label label3;
|
||||
private AntdUI.InputNumber input_minArea;
|
||||
private AntdUI.Label label4;
|
||||
private AntdUI.Label label5;
|
||||
private AntdUI.Select select_Result;
|
||||
}
|
||||
}
|
||||
65
DHSoftware/Views/DefectRowEdit.cs
Normal file
65
DHSoftware/Views/DefectRowEdit.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using AntdUIDemo.Models;
|
||||
using DHSoftware.Models;
|
||||
using DHSoftware.Views;
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace AntdUIDemo.Views.Table
|
||||
{
|
||||
public partial class DefectRowEdit : UserControl
|
||||
{
|
||||
DetectConfigControl detectConfigControl;
|
||||
private AntdUI.Window window;
|
||||
private DefectRow user;
|
||||
public bool submit;
|
||||
public DefectRowEdit(AntdUI.Window _window, DefectRow _user)
|
||||
{
|
||||
this.window = _window;
|
||||
user = _user;
|
||||
InitializeComponent();
|
||||
//设置默认值
|
||||
InitData();
|
||||
// 绑定事件
|
||||
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;
|
||||
}
|
||||
user.LabelDescription = input_name.Text;
|
||||
user.ScoreMinValue =(double)input_minScore.Value;
|
||||
user.ScoreMaxValue = (double)input_maxScore.Value;
|
||||
submit = true;
|
||||
this.Dispose();
|
||||
}
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
input_name.Text = user.LabelDescription;
|
||||
// input_addr.Text = user.Address;
|
||||
input_minScore.Value =(decimal) user.ScoreMinValue;
|
||||
input_maxScore.Value =(decimal) user.ScoreMaxValue;
|
||||
input_minArea.Value =(decimal) user.ScoreMaxValue;
|
||||
input_maxScore.Value =(decimal) user.ScoreMaxValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
120
DHSoftware/Views/DefectRowEdit.resx
Normal file
120
DHSoftware/Views/DefectRowEdit.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>
|
||||
297
DHSoftware/Views/DetectConfigControl.Designer.cs
generated
Normal file
297
DHSoftware/Views/DetectConfigControl.Designer.cs
generated
Normal file
@@ -0,0 +1,297 @@
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
partial class DetectConfigControl
|
||||
{
|
||||
/// <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 Panel();
|
||||
panel3 = new Panel();
|
||||
label6 = new AntdUI.Label();
|
||||
cbxDetectType = new AntdUI.Select();
|
||||
label1 = new AntdUI.Label();
|
||||
tbDetectName = new AntdUI.Input();
|
||||
btnPreOpen = new AntdUI.Button();
|
||||
tbModelpath = new AntdUI.Input();
|
||||
button3 = new AntdUI.Button();
|
||||
switchEnable = new AntdUI.Switch();
|
||||
label8 = new AntdUI.Label();
|
||||
label10 = new AntdUI.Label();
|
||||
sthPic = new AntdUI.Switch();
|
||||
sthSaveNGPic = new AntdUI.Switch();
|
||||
label7 = new AntdUI.Label();
|
||||
label9 = new AntdUI.Label();
|
||||
swSaveOKPic = new AntdUI.Switch();
|
||||
panel2 = new Panel();
|
||||
label2 = new AntdUI.Label();
|
||||
buttonDEL = new AntdUI.Button();
|
||||
table_base = new AntdUI.Table();
|
||||
buttonADD = new AntdUI.Button();
|
||||
panel1.SuspendLayout();
|
||||
panel3.SuspendLayout();
|
||||
panel2.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.BorderStyle = BorderStyle.FixedSingle;
|
||||
panel1.Controls.Add(panel3);
|
||||
panel1.Controls.Add(panel2);
|
||||
panel1.Dock = DockStyle.Fill;
|
||||
panel1.Location = new Point(0, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(600, 445);
|
||||
panel1.TabIndex = 0;
|
||||
//
|
||||
// panel3
|
||||
//
|
||||
panel3.Controls.Add(label6);
|
||||
panel3.Controls.Add(cbxDetectType);
|
||||
panel3.Controls.Add(label1);
|
||||
panel3.Controls.Add(tbDetectName);
|
||||
panel3.Controls.Add(btnPreOpen);
|
||||
panel3.Controls.Add(tbModelpath);
|
||||
panel3.Controls.Add(button3);
|
||||
panel3.Controls.Add(switchEnable);
|
||||
panel3.Controls.Add(label8);
|
||||
panel3.Controls.Add(label10);
|
||||
panel3.Controls.Add(sthPic);
|
||||
panel3.Controls.Add(sthSaveNGPic);
|
||||
panel3.Controls.Add(label7);
|
||||
panel3.Controls.Add(label9);
|
||||
panel3.Controls.Add(swSaveOKPic);
|
||||
panel3.Dock = DockStyle.Fill;
|
||||
panel3.Location = new Point(0, 0);
|
||||
panel3.Name = "panel3";
|
||||
panel3.Size = new Size(598, 206);
|
||||
panel3.TabIndex = 41;
|
||||
//
|
||||
// label6
|
||||
//
|
||||
label6.Location = new Point(3, 15);
|
||||
label6.Name = "label6";
|
||||
label6.Size = new Size(58, 23);
|
||||
label6.TabIndex = 25;
|
||||
label6.Text = "检测名称";
|
||||
//
|
||||
// cbxDetectType
|
||||
//
|
||||
cbxDetectType.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
cbxDetectType.Location = new Point(341, 7);
|
||||
cbxDetectType.Name = "cbxDetectType";
|
||||
cbxDetectType.Size = new Size(226, 31);
|
||||
cbxDetectType.TabIndex = 40;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.Location = new Point(3, 44);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(73, 23);
|
||||
label1.TabIndex = 9;
|
||||
label1.Text = "模型路径";
|
||||
//
|
||||
// tbDetectName
|
||||
//
|
||||
tbDetectName.Location = new Point(82, 7);
|
||||
tbDetectName.Name = "tbDetectName";
|
||||
tbDetectName.Size = new Size(249, 31);
|
||||
tbDetectName.TabIndex = 39;
|
||||
//
|
||||
// btnPreOpen
|
||||
//
|
||||
btnPreOpen.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
btnPreOpen.Location = new Point(507, 36);
|
||||
btnPreOpen.MinimumSize = new Size(20, 0);
|
||||
btnPreOpen.Name = "btnPreOpen";
|
||||
btnPreOpen.Size = new Size(60, 31);
|
||||
btnPreOpen.TabIndex = 22;
|
||||
btnPreOpen.Text = "...";
|
||||
//
|
||||
// tbModelpath
|
||||
//
|
||||
tbModelpath.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
tbModelpath.Location = new Point(82, 36);
|
||||
tbModelpath.Name = "tbModelpath";
|
||||
tbModelpath.Size = new Size(415, 31);
|
||||
tbModelpath.TabIndex = 38;
|
||||
//
|
||||
// button3
|
||||
//
|
||||
button3.Anchor = AnchorStyles.Top | AnchorStyles.Right;
|
||||
button3.Location = new Point(385, 73);
|
||||
button3.Name = "button3";
|
||||
button3.Size = new Size(182, 34);
|
||||
button3.TabIndex = 37;
|
||||
button3.Text = "查看文件夹";
|
||||
//
|
||||
// switchEnable
|
||||
//
|
||||
switchEnable.Location = new Point(82, 84);
|
||||
switchEnable.Name = "switchEnable";
|
||||
switchEnable.Size = new Size(60, 23);
|
||||
switchEnable.TabIndex = 27;
|
||||
switchEnable.Text = "switch1";
|
||||
//
|
||||
// label8
|
||||
//
|
||||
label8.Location = new Point(3, 84);
|
||||
label8.Name = "label8";
|
||||
label8.Size = new Size(58, 23);
|
||||
label8.TabIndex = 28;
|
||||
label8.Text = "模型启用";
|
||||
//
|
||||
// label10
|
||||
//
|
||||
label10.Location = new Point(176, 113);
|
||||
label10.Name = "label10";
|
||||
label10.Size = new Size(73, 23);
|
||||
label10.TabIndex = 34;
|
||||
label10.Text = "保存NG原图";
|
||||
//
|
||||
// sthPic
|
||||
//
|
||||
sthPic.Location = new Point(263, 84);
|
||||
sthPic.Name = "sthPic";
|
||||
sthPic.Size = new Size(60, 23);
|
||||
sthPic.TabIndex = 29;
|
||||
sthPic.Text = "switch2";
|
||||
//
|
||||
// sthSaveNGPic
|
||||
//
|
||||
sthSaveNGPic.Location = new Point(263, 113);
|
||||
sthSaveNGPic.Name = "sthSaveNGPic";
|
||||
sthSaveNGPic.Size = new Size(60, 23);
|
||||
sthSaveNGPic.TabIndex = 33;
|
||||
sthSaveNGPic.Text = "switch4";
|
||||
//
|
||||
// label7
|
||||
//
|
||||
label7.Location = new Point(184, 84);
|
||||
label7.Name = "label7";
|
||||
label7.Size = new Size(58, 23);
|
||||
label7.TabIndex = 30;
|
||||
label7.Text = "数据保存";
|
||||
//
|
||||
// label9
|
||||
//
|
||||
label9.Location = new Point(3, 113);
|
||||
label9.Name = "label9";
|
||||
label9.Size = new Size(73, 23);
|
||||
label9.TabIndex = 32;
|
||||
label9.Text = "保存OK原图";
|
||||
//
|
||||
// swSaveOKPic
|
||||
//
|
||||
swSaveOKPic.Location = new Point(82, 113);
|
||||
swSaveOKPic.Name = "swSaveOKPic";
|
||||
swSaveOKPic.Size = new Size(60, 23);
|
||||
swSaveOKPic.TabIndex = 31;
|
||||
swSaveOKPic.Text = "switch3";
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
panel2.Controls.Add(label2);
|
||||
panel2.Controls.Add(buttonDEL);
|
||||
panel2.Controls.Add(table_base);
|
||||
panel2.Controls.Add(buttonADD);
|
||||
panel2.Dock = DockStyle.Bottom;
|
||||
panel2.Location = new Point(0, 206);
|
||||
panel2.Name = "panel2";
|
||||
panel2.Size = new Size(598, 237);
|
||||
panel2.TabIndex = 35;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.Location = new Point(3, 3);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(58, 23);
|
||||
label2.TabIndex = 29;
|
||||
label2.Text = "模型参数";
|
||||
//
|
||||
// buttonDEL
|
||||
//
|
||||
buttonDEL.Location = new Point(93, 28);
|
||||
buttonDEL.Name = "buttonDEL";
|
||||
buttonDEL.Size = new Size(84, 34);
|
||||
buttonDEL.TabIndex = 24;
|
||||
buttonDEL.Text = "删除";
|
||||
//
|
||||
// table_base
|
||||
//
|
||||
table_base.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
table_base.Location = new Point(0, 68);
|
||||
table_base.Name = "table_base";
|
||||
table_base.Size = new Size(598, 169);
|
||||
table_base.TabIndex = 22;
|
||||
table_base.Text = "table1";
|
||||
//
|
||||
// buttonADD
|
||||
//
|
||||
buttonADD.Location = new Point(3, 28);
|
||||
buttonADD.Name = "buttonADD";
|
||||
buttonADD.Size = new Size(84, 34);
|
||||
buttonADD.TabIndex = 23;
|
||||
buttonADD.Text = "新增";
|
||||
//
|
||||
// DetectConfigControl
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(panel1);
|
||||
Name = "DetectConfigControl";
|
||||
Size = new Size(600, 445);
|
||||
panel1.ResumeLayout(false);
|
||||
panel3.ResumeLayout(false);
|
||||
panel2.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel1;
|
||||
private AntdUI.Label label1;
|
||||
private AntdUI.Label label6;
|
||||
private AntdUI.Button btnPreOpen;
|
||||
private AntdUI.Label label7;
|
||||
private AntdUI.Switch sthPic;
|
||||
private AntdUI.Label label8;
|
||||
private AntdUI.Switch switchEnable;
|
||||
private AntdUI.Label label10;
|
||||
private AntdUI.Switch sthSaveNGPic;
|
||||
private AntdUI.Label label9;
|
||||
private AntdUI.Switch swSaveOKPic;
|
||||
private Panel panel2;
|
||||
private AntdUI.Button buttonDEL;
|
||||
private AntdUI.Table table_base;
|
||||
private AntdUI.Button buttonADD;
|
||||
private AntdUI.Button button3;
|
||||
private AntdUI.Input tbDetectName;
|
||||
private AntdUI.Input tbModelpath;
|
||||
private AntdUI.Label label2;
|
||||
private AntdUI.Select cbxDetectType;
|
||||
private Panel panel3;
|
||||
}
|
||||
}
|
||||
455
DHSoftware/Views/DetectConfigControl.cs
Normal file
455
DHSoftware/Views/DetectConfigControl.cs
Normal file
@@ -0,0 +1,455 @@
|
||||
using AntdUI;
|
||||
using AntdUIDemo.Views.Table;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Vision;
|
||||
using DHSoftware.Models;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Data.Common;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
public partial class DetectConfigControl : UserControl
|
||||
{
|
||||
List<KeyValuePair<string, int>> MLModelTypes = GetFilteredEnumDescriptionsAndValues<MLModelType>();
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
List<KeyValuePair<string, int>> resultStates = GetFilteredEnumDescriptionsAndValues<ResultState>();
|
||||
// 获取枚举的描述和对应的值,只筛选出 OK 和 NG
|
||||
public static List<KeyValuePair<string, int>> GetFilteredEnumDescriptionsAndValuesres<T>() where T : Enum
|
||||
{
|
||||
return Enum.GetValues(typeof(T))
|
||||
.Cast<T>()
|
||||
.Where(e => e.Equals(ResultState.OK) || e.Equals(ResultState.DetectNG)) // 只保留 OK 和 NG
|
||||
.Select(e =>
|
||||
{
|
||||
// 通过反射获取 DescriptionAttribute 描述,如果没有描述,则使用枚举项名称
|
||||
var description = e.GetType()
|
||||
.GetField(e.ToString())
|
||||
?.GetCustomAttribute<DescriptionAttribute>()
|
||||
?.Description ?? e.ToString(); // 如果没有 DescriptionAttribute,则使用枚举名称
|
||||
|
||||
// 返回描述和值的键值对
|
||||
return new KeyValuePair<string, int>(description, Convert.ToInt32(e));
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
DetectionConfig Detection = new DetectionConfig();
|
||||
AntList<DefectRow> antList;
|
||||
public AntdUI.Window _window;
|
||||
DefectRow curUser;
|
||||
public DetectConfigControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
InitTableColumns();
|
||||
InitData();
|
||||
BindEventHandler();
|
||||
foreach (var item in MLModelTypes)
|
||||
{
|
||||
cbxDetectType.Items.Add(item.Key);
|
||||
}
|
||||
cbxDetectType.SelectedIndex = (int)Detection.ModelType - 1;
|
||||
tbDetectName.Text = Detection.Name;
|
||||
|
||||
}
|
||||
|
||||
public bool IsEnabled
|
||||
{
|
||||
get => switchEnable.AutoCheck;
|
||||
set => switchEnable.AutoCheck = value;
|
||||
}
|
||||
// 模型路径属性
|
||||
public string ModelPath
|
||||
{
|
||||
get => Detection.ModelPath;
|
||||
set
|
||||
{
|
||||
Detection.ModelPath = value;
|
||||
tbModelpath.Text = value; // 更新到文本框
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public bool IsPicNGEnable
|
||||
{
|
||||
|
||||
get => sthSaveNGPic.AutoCheck;
|
||||
set => sthSaveNGPic.AutoCheck = value;
|
||||
}
|
||||
public bool IsPicEnable
|
||||
{
|
||||
|
||||
get => sthPic.AutoCheck;
|
||||
set => sthPic.AutoCheck = value;
|
||||
}
|
||||
//public MLModelType LModelType
|
||||
//{
|
||||
|
||||
//}
|
||||
|
||||
private string _picTag;
|
||||
|
||||
public string picTag
|
||||
{
|
||||
get => _picTag;
|
||||
set
|
||||
{
|
||||
_picTag = value;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private string _afterTag;
|
||||
|
||||
public string afterTag
|
||||
{
|
||||
get => _afterTag;
|
||||
set
|
||||
{
|
||||
_afterTag = value;
|
||||
}
|
||||
}
|
||||
private void InitTableColumns()
|
||||
{
|
||||
table_base.Columns = new ColumnCollection() {
|
||||
new ColumnCheck("Selected"){Fixed = true},
|
||||
new Column("LabelDescription", "标签名", ColumnAlign.Center)
|
||||
{
|
||||
Width="120",
|
||||
//设置树节点,名称需和User里的User[]名称保持一致
|
||||
KeyTree = "Users"
|
||||
},
|
||||
new ColumnSwitch("IsEnable", "是否启用", ColumnAlign.Center){
|
||||
//支持点击回调
|
||||
//Call= (value,record, i_row, i_col) =>{
|
||||
// //执行耗时操作
|
||||
// Thread.Sleep(10);
|
||||
// // AntdUI.Message.info(window, value.ToString(),autoClose:1);
|
||||
// return value;
|
||||
//}
|
||||
},
|
||||
new Column("ScoreMinValue", "最小得分",ColumnAlign.Center),
|
||||
new Column("ScoreMaxValue", "最大得分",ColumnAlign.Center),
|
||||
|
||||
new Column("AreaMinValue", "最小面积",ColumnAlign.Center),
|
||||
new Column("AreaMaxValue", "最大面积",ColumnAlign.Center),
|
||||
//new Column("CellBadge", "徽标",ColumnAlign.Center),
|
||||
//new Column("CellText", "富文本")
|
||||
//{
|
||||
// ColAlign = ColumnAlign.Center,//支持表头位置单独设置
|
||||
//},
|
||||
//new Column("CellProgress", "进度条",ColumnAlign.Center),
|
||||
//new Column("CellDivider", "分割线",ColumnAlign.Center),
|
||||
//new Column("CellLinks", "链接", ColumnAlign.Center)
|
||||
//{
|
||||
// Fixed = true,//冻结列
|
||||
//},
|
||||
};
|
||||
}
|
||||
|
||||
private void InitData()
|
||||
{
|
||||
antList = new AntList<DefectRow>();
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
antList.Add(new DefectRow
|
||||
{
|
||||
LabelDescription = "张三",
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
table_base.Binding(antList);
|
||||
|
||||
//设置行禁用
|
||||
// table_base.SetRowEnable(0, false, true);
|
||||
}
|
||||
|
||||
|
||||
private void BindEventHandler()
|
||||
{
|
||||
buttonADD.Click += ButtonADD_Click;
|
||||
buttonDEL.Click += ButtonDEL_Click;
|
||||
|
||||
|
||||
table_base.CellClick += Table_base_CellClick;
|
||||
table_base.CellButtonClick += Table_base_CellButtonClick;
|
||||
}
|
||||
|
||||
|
||||
private AntdUI.Table.CellStyleInfo Table_base_SetRowStyle(object sender, TableSetRowStyleEventArgs e)
|
||||
{
|
||||
if (e.RowIndex % 2 == 0)
|
||||
{
|
||||
return new AntdUI.Table.CellStyleInfo
|
||||
{
|
||||
BackColor = AntdUI.Style.Db.ErrorBg,
|
||||
};
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void ButtonADD_Click(object sender, EventArgs e)
|
||||
{
|
||||
DefectRow useradd = new DefectRow()
|
||||
{
|
||||
LabelDescription="xinquexian",
|
||||
IsEnable=true,
|
||||
ScoreMinValue=0.3,
|
||||
ScoreMaxValue=1,
|
||||
AreaMinValue=1,
|
||||
AreaMaxValue=999999999,
|
||||
|
||||
};
|
||||
var form = new DefectRowEdit(_window, useradd) { Size = new Size(700, 500) };
|
||||
AntdUI.Modal.open(new AntdUI.Modal.Config(_window, "", form, TType.None)
|
||||
{
|
||||
BtnHeight = 0,
|
||||
});
|
||||
if (form.submit)
|
||||
{
|
||||
antList.Add(useradd);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void Table_base_CellClick(object sender, TableClickEventArgs e)
|
||||
{
|
||||
var record = e.Record;
|
||||
if (record is DefectRow user)
|
||||
{
|
||||
curUser = user;
|
||||
//判断是否右键
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
if (antList.Count == 0) return;
|
||||
AntdUI.ContextMenuStrip.open(new AntdUI.ContextMenuStrip.Config(table_base,
|
||||
(item) =>
|
||||
{
|
||||
if (item.Text == "开启")
|
||||
{
|
||||
user.IsEnable = true;
|
||||
}
|
||||
else if (item.Text == "关闭")
|
||||
{
|
||||
user.IsEnable = false;
|
||||
}
|
||||
else if (item.Text == "编辑")
|
||||
{
|
||||
var form = new DefectRowEdit(_window, user) { Size = new Size(500, 300) };
|
||||
AntdUI.Drawer.open(new AntdUI.Drawer.Config(_window, form)
|
||||
{
|
||||
OnLoad = () =>
|
||||
{
|
||||
AntdUI.Message.info(_window, "进入编辑", autoClose: 1);
|
||||
},
|
||||
OnClose = () =>
|
||||
{
|
||||
AntdUI.Message.info(_window, "结束编辑", autoClose: 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
else if (item.Text == "删除")
|
||||
{
|
||||
var result = Modal.open(_window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
//父元素没有勾选或者子元素也没有勾选,则删除当前行
|
||||
bool delCurrent = !antList.Any(x => x.Selected /*|| (x.?.Any(u => u.Selected) ?? false)*/);
|
||||
|
||||
if (delCurrent)
|
||||
{
|
||||
//删除当前行,先判断是否父元素,再判断是否子元素,只支持一层子元素,需实现嵌套查询
|
||||
for (int i = 0; i < antList.Count; i++)
|
||||
{
|
||||
if (antList[i] == user)
|
||||
{
|
||||
antList.RemoveAt(i);
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// antList[i].Users = antList[i].Users?.Where(x => x != user).ToArray();
|
||||
//}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 使用反转for循环删除主列表中选中的项
|
||||
for (int i = antList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// 1.删除选中的主列表项
|
||||
if (antList[i].Selected)
|
||||
{
|
||||
antList.RemoveAt(i);
|
||||
}
|
||||
//else
|
||||
//{
|
||||
// // 删除子列表中选中的项
|
||||
// antList[i].Users = antList[i].Users?.Where(childUser => !childUser.Selected).ToArray();
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else if (item.Text == "查看图片")
|
||||
{
|
||||
//查看其他来源的高清图片
|
||||
Preview.open(new Preview.Config(_window, Properties.Resources.head2));
|
||||
}
|
||||
else
|
||||
AntdUI.Message.info(_window, item.Text, autoClose: 1);
|
||||
},
|
||||
new IContextMenuStripItem[] {
|
||||
//根据行数据动态修改右键菜单
|
||||
user.IsEnable? new ContextMenuStripItem("关闭")
|
||||
{
|
||||
IconSvg = "CloseOutlined"
|
||||
}:new ContextMenuStripItem("开启")
|
||||
{
|
||||
IconSvg = "CheckOutlined"
|
||||
},
|
||||
new AntdUI.ContextMenuStripItem("编辑"){
|
||||
IconSvg = "EditOutlined",
|
||||
},
|
||||
new AntdUI.ContextMenuStripItem("删除"){
|
||||
IconSvg = "DeleteOutlined"
|
||||
},
|
||||
new ContextMenuStripItem("查看图片")
|
||||
{
|
||||
IconSvg = "FundViewOutlined"
|
||||
},
|
||||
new ContextMenuStripItemDivider(),
|
||||
new AntdUI.ContextMenuStripItem("详情"){
|
||||
Sub = new IContextMenuStripItem[]{ new AntdUI.ContextMenuStripItem("打印", "Ctrl + P") { },
|
||||
new AntdUI.ContextMenuStripItem("另存为", "Ctrl + S") { } },
|
||||
IconSvg = "<svg t=\"1725101601993\" class=\"icon\" viewBox=\"0 0 1024 1024\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\" p-id=\"1414\" width=\"200\" height=\"200\"><path d=\"M450.23 831.7c-164.87 0-316.85-108.51-366.94-269.68-30.4-97.82-20.9-201.62 26.76-292.29s127.79-157.35 225.6-187.75c97.83-30.42 201.61-20.9 292.29 26.76 90.67 47.67 157.35 127.79 187.75 225.61 35.78 115.12 16.24 237.58-53.6 335.99a383.494 383.494 0 0 1-43 50.66c-15.04 14.89-39.34 14.78-54.23-0.29-14.9-15.05-14.77-39.34 0.29-54.23a307.844 307.844 0 0 0 34.39-40.52c55.9-78.76 71.54-176.75 42.92-268.84-50.21-161.54-222.49-252.1-384.03-201.9-78.26 24.32-142.35 77.67-180.48 150.2-38.14 72.53-45.74 155.57-21.42 233.83 44.58 143.44 190.03 234.7 338.26 212.42 20.98-3.14 40.48 11.26 43.64 32.2 3.16 20.95-11.26 40.48-32.2 43.64a377.753 377.753 0 0 1-56 4.19z\" p-id=\"1415\"></path><path d=\"M919.84 959.5c-9.81 0-19.63-3.74-27.11-11.24L666.75 722.29c-14.98-14.97-14.98-39.25 0-54.23 14.97-14.98 39.26-14.98 54.23 0l225.97 225.97c14.98 14.97 14.98 39.25 0 54.23-7.48 7.5-17.3 11.24-27.11 11.24z\" p-id=\"1416\"></path></svg>",
|
||||
}
|
||||
}));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//表格内部按钮事件
|
||||
private void Table_base_CellButtonClick(object sender, TableButtonEventArgs e)
|
||||
{
|
||||
var buttontext = e.Btn.Text;
|
||||
|
||||
if (e.Record is DefectRow user)
|
||||
{
|
||||
curUser = user;
|
||||
switch (buttontext)
|
||||
{
|
||||
//暂不支持进入整行编辑,只支持指定单元格编辑,推荐使用弹窗或抽屉编辑整行数据
|
||||
case "编辑":
|
||||
var form = new DefectRowEdit(_window, user) { Size = new Size(500, 300) };
|
||||
AntdUI.Drawer.open(new AntdUI.Drawer.Config(_window, form)
|
||||
{
|
||||
OnLoad = () =>
|
||||
{
|
||||
AntdUI.Message.info(_window, "进入编辑", autoClose: 1);
|
||||
},
|
||||
OnClose = () =>
|
||||
{
|
||||
AntdUI.Message.info(_window, "结束编辑", autoClose: 1);
|
||||
}
|
||||
});
|
||||
break;
|
||||
case "删除":
|
||||
var result = Modal.open(_window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
|
||||
if (result == DialogResult.OK)
|
||||
antList.Remove(user);
|
||||
break;
|
||||
case "AntdUI":
|
||||
//超链接内容
|
||||
// AntdUI.Message.info(_window, user.CellLinks.FirstOrDefault().Id, autoClose: 1);
|
||||
break;
|
||||
case "查看图片":
|
||||
//使用clone可以防止table中的image被修改
|
||||
// Preview.open(new Preview.Config(window, (Image)curUser.CellImages[0].Image.Clone()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ButtonDEL_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (antList.Count == 0 || !antList.Any(x => x.Selected))
|
||||
{
|
||||
bool isSubSelected = false;
|
||||
//// 判断子元素是否勾选
|
||||
//for (int i = 0; i < antList.Count; i++)
|
||||
//{
|
||||
// if (antList[i].Users != null && antList[i].Users.Any(x => x.Selected))
|
||||
// {
|
||||
// isSubSelected = true;
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
if (!isSubSelected)
|
||||
{
|
||||
AntdUI.Message.warn(_window, "请选择要删除的行!", autoClose: 3);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
var result = Modal.open(_window, "删除警告!", "确认要删除选择的数据吗?", TType.Warn);
|
||||
if (result == DialogResult.OK)
|
||||
{
|
||||
// 使用反转for循环删除主列表中选中的项
|
||||
for (int i = antList.Count - 1; i >= 0; i--)
|
||||
{
|
||||
// 删除选中的主列表项
|
||||
if (antList[i].Selected)
|
||||
{
|
||||
antList.RemoveAt(i);
|
||||
}
|
||||
else
|
||||
{
|
||||
// 删除子列表中选中的项
|
||||
// antList[i].Users = antList[i].Users?.Where(user => !user.Selected).ToArray();
|
||||
}
|
||||
}
|
||||
// 提示删除完成
|
||||
// AntdUI.Message.success(this.w, "删除成功!", autoClose: 3);
|
||||
MessageBox.Show("删除成功!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
120
DHSoftware/Views/DetectConfigControl.resx
Normal file
120
DHSoftware/Views/DetectConfigControl.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>
|
||||
212
DHSoftware/Views/PreTreatUserControl.Designer.cs
generated
Normal file
212
DHSoftware/Views/PreTreatUserControl.Designer.cs
generated
Normal file
@@ -0,0 +1,212 @@
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
partial class PreTreatUserControl
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
btnPreOpen = new AntdUI.Button();
|
||||
tbxPrePath = new TextBox();
|
||||
label1 = new AntdUI.Label();
|
||||
panel1 = new Panel();
|
||||
btnOParmDel = new Panel();
|
||||
label3 = new Label();
|
||||
btnDelOParm = new AntdUI.Button();
|
||||
tbOutputParm = new AntdUI.Table();
|
||||
btnAddOParm = new AntdUI.Button();
|
||||
panel2 = new Panel();
|
||||
label2 = new Label();
|
||||
btnDelIParm = new AntdUI.Button();
|
||||
tbInputParm = new AntdUI.Table();
|
||||
btnAddIParm = new AntdUI.Button();
|
||||
panel1.SuspendLayout();
|
||||
btnOParmDel.SuspendLayout();
|
||||
panel2.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// btnPreOpen
|
||||
//
|
||||
btnPreOpen.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
btnPreOpen.Location = new Point(570, 17);
|
||||
btnPreOpen.Name = "btnPreOpen";
|
||||
btnPreOpen.Size = new Size(28, 23);
|
||||
btnPreOpen.TabIndex = 21;
|
||||
btnPreOpen.Text = "...";
|
||||
//
|
||||
// tbxPrePath
|
||||
//
|
||||
tbxPrePath.Location = new Point(91, 17);
|
||||
tbxPrePath.Name = "tbxPrePath";
|
||||
tbxPrePath.Size = new Size(473, 23);
|
||||
tbxPrePath.TabIndex = 20;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
label1.Location = new Point(12, 17);
|
||||
label1.Name = "label1";
|
||||
label1.Size = new Size(73, 23);
|
||||
label1.TabIndex = 19;
|
||||
label1.Text = "预处理路径";
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
panel1.BorderStyle = BorderStyle.FixedSingle;
|
||||
panel1.Controls.Add(btnOParmDel);
|
||||
panel1.Controls.Add(panel2);
|
||||
panel1.Controls.Add(label1);
|
||||
panel1.Controls.Add(btnPreOpen);
|
||||
panel1.Controls.Add(tbxPrePath);
|
||||
panel1.Location = new Point(0, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(633, 243);
|
||||
panel1.TabIndex = 22;
|
||||
//
|
||||
// btnOParmDel
|
||||
//
|
||||
btnOParmDel.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
btnOParmDel.Controls.Add(label3);
|
||||
btnOParmDel.Controls.Add(btnDelOParm);
|
||||
btnOParmDel.Controls.Add(tbOutputParm);
|
||||
btnOParmDel.Controls.Add(btnAddOParm);
|
||||
btnOParmDel.Location = new Point(352, 44);
|
||||
btnOParmDel.Name = "btnOParmDel";
|
||||
btnOParmDel.Size = new Size(246, 194);
|
||||
btnOParmDel.TabIndex = 26;
|
||||
//
|
||||
// label3
|
||||
//
|
||||
label3.AutoSize = true;
|
||||
label3.Location = new Point(3, 2);
|
||||
label3.Name = "label3";
|
||||
label3.Size = new Size(56, 17);
|
||||
label3.TabIndex = 25;
|
||||
label3.Text = "输出参数";
|
||||
//
|
||||
// btnDelOParm
|
||||
//
|
||||
btnDelOParm.Location = new Point(93, 25);
|
||||
btnDelOParm.Name = "btnDelOParm";
|
||||
btnDelOParm.Size = new Size(84, 34);
|
||||
btnDelOParm.TabIndex = 24;
|
||||
btnDelOParm.Text = "删除";
|
||||
//
|
||||
// tbOutputParm
|
||||
//
|
||||
tbOutputParm.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
tbOutputParm.Location = new Point(3, 65);
|
||||
tbOutputParm.Name = "tbOutputParm";
|
||||
tbOutputParm.Size = new Size(240, 126);
|
||||
tbOutputParm.TabIndex = 22;
|
||||
tbOutputParm.Text = "table2";
|
||||
//
|
||||
// btnAddOParm
|
||||
//
|
||||
btnAddOParm.Location = new Point(3, 25);
|
||||
btnAddOParm.Name = "btnAddOParm";
|
||||
btnAddOParm.Size = new Size(84, 34);
|
||||
btnAddOParm.TabIndex = 23;
|
||||
btnAddOParm.Text = "新增";
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
panel2.Controls.Add(label2);
|
||||
panel2.Controls.Add(btnDelIParm);
|
||||
panel2.Controls.Add(tbInputParm);
|
||||
panel2.Controls.Add(btnAddIParm);
|
||||
panel2.Location = new Point(12, 45);
|
||||
panel2.Name = "panel2";
|
||||
panel2.Size = new Size(264, 194);
|
||||
panel2.TabIndex = 25;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(3, 5);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(56, 17);
|
||||
label2.TabIndex = 25;
|
||||
label2.Text = "输入参数";
|
||||
//
|
||||
// btnDelIParm
|
||||
//
|
||||
btnDelIParm.Location = new Point(93, 25);
|
||||
btnDelIParm.Name = "btnDelIParm";
|
||||
btnDelIParm.Size = new Size(84, 34);
|
||||
btnDelIParm.TabIndex = 24;
|
||||
btnDelIParm.Text = "删除";
|
||||
//
|
||||
// tbInputParm
|
||||
//
|
||||
tbInputParm.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right;
|
||||
tbInputParm.Location = new Point(3, 65);
|
||||
tbInputParm.Name = "tbInputParm";
|
||||
tbInputParm.Size = new Size(258, 126);
|
||||
tbInputParm.TabIndex = 22;
|
||||
tbInputParm.Text = "table1";
|
||||
//
|
||||
// btnAddIParm
|
||||
//
|
||||
btnAddIParm.Location = new Point(3, 25);
|
||||
btnAddIParm.Name = "btnAddIParm";
|
||||
btnAddIParm.Size = new Size(84, 34);
|
||||
btnAddIParm.TabIndex = 23;
|
||||
btnAddIParm.Text = "新增";
|
||||
//
|
||||
// PreTreatUserControl
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(panel1);
|
||||
Name = "PreTreatUserControl";
|
||||
Size = new Size(635, 243);
|
||||
panel1.ResumeLayout(false);
|
||||
panel1.PerformLayout();
|
||||
btnOParmDel.ResumeLayout(false);
|
||||
btnOParmDel.PerformLayout();
|
||||
panel2.ResumeLayout(false);
|
||||
panel2.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private AntdUI.Button btnPreOpen;
|
||||
private TextBox tbxPrePath;
|
||||
private AntdUI.Label label1;
|
||||
private Panel panel1;
|
||||
private AntdUI.Button btnDelIParm;
|
||||
private AntdUI.Button btnAddIParm;
|
||||
private AntdUI.Table tbInputParm;
|
||||
private Panel panel2;
|
||||
private Panel btnOParmDel;
|
||||
private Label label3;
|
||||
private AntdUI.Button btnDelOParm;
|
||||
private AntdUI.Table tbOutputParm;
|
||||
private AntdUI.Button btnAddOParm;
|
||||
private Label label2;
|
||||
}
|
||||
}
|
||||
20
DHSoftware/Views/PreTreatUserControl.cs
Normal file
20
DHSoftware/Views/PreTreatUserControl.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
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 PreTreatUserControl : UserControl
|
||||
{
|
||||
public PreTreatUserControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
DHSoftware/Views/PreTreatUserControl.resx
Normal file
120
DHSoftware/Views/PreTreatUserControl.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>
|
||||
155
DHSoftware/Views/SettingWindow.Designer.cs
generated
Normal file
155
DHSoftware/Views/SettingWindow.Designer.cs
generated
Normal file
@@ -0,0 +1,155 @@
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
partial class SettingWindow
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
panel3 = new AntdUI.Panel();
|
||||
panel1 = new AntdUI.Panel();
|
||||
panel2 = new AntdUI.Panel();
|
||||
btnSave = new AntdUI.Button();
|
||||
btnAdd = new AntdUI.Button();
|
||||
menu1 = new AntdUI.Menu();
|
||||
pageHeader1 = new AntdUI.PageHeader();
|
||||
panel3.SuspendLayout();
|
||||
panel1.SuspendLayout();
|
||||
panel2.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;
|
||||
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(838, 33);
|
||||
pageHeader1.TabIndex = 1;
|
||||
pageHeader1.Text = "设置";
|
||||
//
|
||||
// SettingWindow
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
ClientSize = new Size(838, 561);
|
||||
Controls.Add(panel3);
|
||||
Name = "SettingWindow";
|
||||
StartPosition = FormStartPosition.CenterScreen;
|
||||
Text = "SettingWinform";
|
||||
panel3.ResumeLayout(false);
|
||||
panel1.ResumeLayout(false);
|
||||
panel2.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.Menu menu1;
|
||||
private AntdUI.Button btnSave;
|
||||
}
|
||||
}
|
||||
145
DHSoftware/Views/SettingWindow.cs
Normal file
145
DHSoftware/Views/SettingWindow.cs
Normal file
@@ -0,0 +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 AntdUI;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Devices;
|
||||
using DH.Devices.Vision;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
|
||||
public partial class SettingWindow : Window
|
||||
{
|
||||
public List<CameraBase> cameras = new List<CameraBase>();
|
||||
public List<DetectionConfig> detections = new List<DetectionConfig>();
|
||||
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, "新增工位");
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void Menu_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
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)
|
||||
{
|
||||
// 显示节点名称弹窗
|
||||
//MessageBox.Show($"右键点击的节点: {clickedItem.Text}");
|
||||
|
||||
var menulist = new AntdUI.IContextMenuStripItem[]
|
||||
{
|
||||
new AntdUI.ContextMenuStripItem("关联相机", "")
|
||||
{
|
||||
IconSvg = "VideoCameraAddOutlined"
|
||||
}
|
||||
};
|
||||
AntdUI.ContextMenuStrip.open(menu1, it =>
|
||||
{
|
||||
if (it.Text == "关联相机")
|
||||
{
|
||||
using (var dlg = new AddCameraWindow(cameras))
|
||||
{
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var newItem = new MenuItem(dlg.CubicleName);
|
||||
newItem.IconSvg = "VideoCameraOutlined";
|
||||
//// 防止重复添加
|
||||
//if (!menu1.Items.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
|
||||
//{
|
||||
clickedItem.Sub.Add(newItem);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// AntdUI.Notification.warn(this, "新增失败", $"{dlg.CubicleName}已存在!", autoClose: 3, align: TAlignFrom.TR);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, menulist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private MenuItem FindClickedItem(MenuItemCollection items, Point clickPoint)
|
||||
{
|
||||
foreach (MenuItem item in items)
|
||||
{
|
||||
// 检查当前项是否可见且包含点击坐标
|
||||
if (item.Visible && item.Rect.Contains(clickPoint))
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var dlg = new AddCubicleWindow())
|
||||
{
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var newItem = new MenuItem(dlg.CubicleName);
|
||||
newItem.IconSvg = "AppstoreOutlined";
|
||||
// 防止重复添加
|
||||
if (!menu1.Items.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
|
||||
{
|
||||
menu1.Items.Add(newItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
AntdUI.Notification.warn(this, "新增工位失败", $"{dlg.CubicleName}已存在!", autoClose: 3, align: TAlignFrom.TR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void menu1_MouseClick(object sender, MouseEventArgs e)
|
||||
{
|
||||
//if (e.Button == MouseButtons.Right)
|
||||
//{
|
||||
// var menu =sender as Menu;
|
||||
// if (menu?.Items.Count == 0)
|
||||
// {
|
||||
// return;
|
||||
// }
|
||||
|
||||
//}
|
||||
}
|
||||
|
||||
private void btnSave_Click(object sender, EventArgs e)
|
||||
{
|
||||
foreach(var item in menu1.Items)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
120
DHSoftware/Views/SettingWindow.resx
Normal file
120
DHSoftware/Views/SettingWindow.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>
|
||||
104
DHSoftware/Views/SizeConfigControl.Designer.cs
generated
Normal file
104
DHSoftware/Views/SizeConfigControl.Designer.cs
generated
Normal file
@@ -0,0 +1,104 @@
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
partial class SizeConfigControl
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
panel2 = new Panel();
|
||||
label2 = new Label();
|
||||
btnDelSizeParm = new AntdUI.Button();
|
||||
tbSizeParm = new AntdUI.Table();
|
||||
btnAddSizeParm = new AntdUI.Button();
|
||||
panel2.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
panel2.Controls.Add(label2);
|
||||
panel2.Controls.Add(btnDelSizeParm);
|
||||
panel2.Controls.Add(tbSizeParm);
|
||||
panel2.Controls.Add(btnAddSizeParm);
|
||||
panel2.Location = new Point(3, 3);
|
||||
panel2.Name = "panel2";
|
||||
panel2.Size = new Size(779, 286);
|
||||
panel2.TabIndex = 36;
|
||||
//
|
||||
// label2
|
||||
//
|
||||
label2.AutoSize = true;
|
||||
label2.Location = new Point(3, 5);
|
||||
label2.Name = "label2";
|
||||
label2.Size = new Size(56, 17);
|
||||
label2.TabIndex = 25;
|
||||
label2.Text = "尺寸参数";
|
||||
//
|
||||
// btnDelSizeParm
|
||||
//
|
||||
btnDelSizeParm.Location = new Point(93, 25);
|
||||
btnDelSizeParm.Name = "btnDelSizeParm";
|
||||
btnDelSizeParm.Size = new Size(84, 34);
|
||||
btnDelSizeParm.TabIndex = 24;
|
||||
btnDelSizeParm.Text = "删除";
|
||||
//
|
||||
// tbSizeParm
|
||||
//
|
||||
tbSizeParm.Location = new Point(3, 65);
|
||||
tbSizeParm.Name = "tbSizeParm";
|
||||
tbSizeParm.Size = new Size(773, 218);
|
||||
tbSizeParm.TabIndex = 22;
|
||||
tbSizeParm.Text = "table1";
|
||||
//
|
||||
// btnAddSizeParm
|
||||
//
|
||||
btnAddSizeParm.Location = new Point(3, 25);
|
||||
btnAddSizeParm.Name = "btnAddSizeParm";
|
||||
btnAddSizeParm.Size = new Size(84, 34);
|
||||
btnAddSizeParm.TabIndex = 23;
|
||||
btnAddSizeParm.Text = "新增";
|
||||
//
|
||||
// SizeConfigControl
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
BorderStyle = BorderStyle.FixedSingle;
|
||||
Controls.Add(panel2);
|
||||
Name = "SizeConfigControl";
|
||||
Size = new Size(783, 290);
|
||||
panel2.ResumeLayout(false);
|
||||
panel2.PerformLayout();
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private Panel panel2;
|
||||
private Label label2;
|
||||
private AntdUI.Button btnDelSizeParm;
|
||||
private AntdUI.Table tbSizeParm;
|
||||
private AntdUI.Button btnAddSizeParm;
|
||||
}
|
||||
}
|
||||
20
DHSoftware/Views/SizeConfigControl.cs
Normal file
20
DHSoftware/Views/SizeConfigControl.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
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 SizeConfigControl : UserControl
|
||||
{
|
||||
public SizeConfigControl()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
120
DHSoftware/Views/SizeConfigControl.resx
Normal file
120
DHSoftware/Views/SizeConfigControl.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>
|
||||
125
DHSoftware/Views/UserConfigFrm.Designer.cs
generated
125
DHSoftware/Views/UserConfigFrm.Designer.cs
generated
@@ -28,17 +28,140 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
AntdUI.Tabs.StyleCard styleCard1 = new AntdUI.Tabs.StyleCard();
|
||||
pnlMenu = new AntdUI.Panel();
|
||||
panel3 = new AntdUI.Panel();
|
||||
btnSave = new AntdUI.Button();
|
||||
btnAdd = new AntdUI.Button();
|
||||
menu = new AntdUI.Menu();
|
||||
panel2 = new AntdUI.Panel();
|
||||
divider1 = new AntdUI.Divider();
|
||||
tabs = new AntdUI.Tabs();
|
||||
pnlMenu.SuspendLayout();
|
||||
panel3.SuspendLayout();
|
||||
panel2.SuspendLayout();
|
||||
SuspendLayout();
|
||||
//
|
||||
// pnlMenu
|
||||
//
|
||||
pnlMenu.Controls.Add(panel3);
|
||||
pnlMenu.Controls.Add(menu);
|
||||
pnlMenu.Dock = DockStyle.Left;
|
||||
pnlMenu.Location = new Point(0, 0);
|
||||
pnlMenu.Name = "pnlMenu";
|
||||
pnlMenu.Size = new Size(135, 542);
|
||||
pnlMenu.TabIndex = 0;
|
||||
pnlMenu.Text = "panel1";
|
||||
//
|
||||
// panel3
|
||||
//
|
||||
panel3.Back = SystemColors.Window;
|
||||
panel3.BackColor = SystemColors.Window;
|
||||
panel3.Controls.Add(btnSave);
|
||||
panel3.Controls.Add(btnAdd);
|
||||
panel3.Dock = DockStyle.Bottom;
|
||||
panel3.Location = new Point(0, 516);
|
||||
panel3.Name = "panel3";
|
||||
panel3.Size = new Size(135, 26);
|
||||
panel3.TabIndex = 2;
|
||||
panel3.Text = "panel3";
|
||||
//
|
||||
// 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, 26);
|
||||
btnSave.TabIndex = 2;
|
||||
//
|
||||
// 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, 26);
|
||||
btnAdd.TabIndex = 1;
|
||||
btnAdd.Click += btnAdd_Click;
|
||||
//
|
||||
// menu
|
||||
//
|
||||
menu.Dock = DockStyle.Fill;
|
||||
menu.Location = new Point(0, 0);
|
||||
menu.Name = "menu";
|
||||
menu.Size = new Size(135, 542);
|
||||
menu.TabIndex = 0;
|
||||
menu.Text = "menu1";
|
||||
menu.SelectChanged += Menu_SelectChanged;
|
||||
menu.MouseDown += Menu_MouseDown;
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
panel2.Controls.Add(divider1);
|
||||
panel2.Controls.Add(tabs);
|
||||
panel2.Dock = DockStyle.Fill;
|
||||
panel2.Location = new Point(135, 0);
|
||||
panel2.Name = "panel2";
|
||||
panel2.Size = new Size(745, 542);
|
||||
panel2.TabIndex = 1;
|
||||
panel2.Text = "panel2";
|
||||
//
|
||||
// divider1
|
||||
//
|
||||
divider1.BackColor = SystemColors.ActiveCaption;
|
||||
divider1.Dock = DockStyle.Left;
|
||||
divider1.Location = new Point(0, 0);
|
||||
divider1.Name = "divider1";
|
||||
divider1.Size = new Size(10, 542);
|
||||
divider1.TabIndex = 1;
|
||||
divider1.Text = "";
|
||||
divider1.Vertical = true;
|
||||
//
|
||||
// tabs
|
||||
//
|
||||
tabs.Dock = DockStyle.Fill;
|
||||
tabs.Location = new Point(0, 0);
|
||||
tabs.Name = "tabs";
|
||||
tabs.Size = new Size(745, 542);
|
||||
tabs.Style = styleCard1;
|
||||
tabs.TabIndex = 0;
|
||||
tabs.Text = "tabs1";
|
||||
tabs.Type = AntdUI.TabType.Card;
|
||||
tabs.SelectedIndexChanged += tabs_SelectedIndexChanged;
|
||||
//
|
||||
// UserConfigFrm
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
AutoSize = true;
|
||||
Controls.Add(panel2);
|
||||
Controls.Add(pnlMenu);
|
||||
Name = "UserConfigFrm";
|
||||
Size = new Size(749, 536);
|
||||
Size = new Size(880, 542);
|
||||
pnlMenu.ResumeLayout(false);
|
||||
panel3.ResumeLayout(false);
|
||||
panel2.ResumeLayout(false);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
private AntdUI.Tabs tabs;
|
||||
private AntdUI.Panel pnlMenu;
|
||||
private AntdUI.Panel panel2;
|
||||
private AntdUI.Menu menu;
|
||||
private AntdUI.Panel panel3;
|
||||
private AntdUI.Button btnSave;
|
||||
private AntdUI.Button btnAdd;
|
||||
private AntdUI.Divider divider1;
|
||||
// private AntdUI.Tabs tabs;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
using System;
|
||||
using AntdUI;
|
||||
using AntdUIDemo.Models;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Devices;
|
||||
using DH.Devices.Vision;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
@@ -7,14 +12,247 @@ using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement;
|
||||
using Window = AntdUI.Window;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
public partial class UserConfigFrm : UserControl
|
||||
{
|
||||
public List<CameraBase> cameras = new List<CameraBase>();
|
||||
public List<DetectionConfig> detections = new List<DetectionConfig>();
|
||||
private UserControl currControl;
|
||||
private bool isUpdatingTabs = false;//用于阻止Tabs更新
|
||||
public Window Window;
|
||||
public UserConfigFrm()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
LoadMenu();
|
||||
menu.Width = (int)(100 * Config.Dpi);
|
||||
|
||||
}
|
||||
private void LoadMenu(string filter = "")
|
||||
{
|
||||
menu.Items.Clear();
|
||||
|
||||
string lang = AntdUI.Localization.CurrentLanguage;
|
||||
var menuItems = DataUtil.Menu_decetion;
|
||||
//var menuIcons = DataUtil.MenuIcons_zhcn;
|
||||
//if (lang.StartsWith("en"))
|
||||
//{
|
||||
// menuItems = DataUtil.MenuItems_enus;
|
||||
// menuIcons = DataUtil.MenuIcons_enus;
|
||||
//}
|
||||
|
||||
foreach (var rootItem in menuItems)
|
||||
{
|
||||
var rootKey = rootItem.Key.ToLower();
|
||||
var rootMenu = new AntdUI.MenuItem
|
||||
{
|
||||
Text = rootItem.Key,
|
||||
//IconSvg = menuIcons.TryGetValue(rootItem.Key, out var icon) ? icon : "UnorderedListOutlined",
|
||||
};
|
||||
bool rootVisible = false; // 用于标记是否显示根节点
|
||||
|
||||
foreach (var item in rootItem.Value)
|
||||
{
|
||||
var childText = item.Text.ToLower();
|
||||
|
||||
// 如果子节点包含搜索文本
|
||||
if (childText.Contains(filter))
|
||||
{
|
||||
var menuItem = new AntdUI.MenuItem
|
||||
{
|
||||
Text = item.Text,
|
||||
IconSvg = item.IconSvg,
|
||||
Tag = item.Tag,
|
||||
};
|
||||
rootMenu.Sub.Add(menuItem);
|
||||
rootVisible = true; // 如果有子节点包含,则显示根节点
|
||||
}
|
||||
}
|
||||
|
||||
// 如果根节点包含搜索文本,或有可见的子节点,则显示根节点
|
||||
if (rootKey.Contains(filter) || rootVisible)
|
||||
{
|
||||
menu.Items.Add(rootMenu);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void SelectMenu()
|
||||
{
|
||||
if (isUpdatingTabs) return;
|
||||
var text = tabs.SelectedTab?.Text; // 使用安全导航操作符,防止 SelectedTab 为 null
|
||||
if (string.IsNullOrEmpty(text)) // 检查 text 是否为 null 或空
|
||||
{
|
||||
return; // 如果 text 为空,直接退出方法
|
||||
}
|
||||
//首页
|
||||
if (text == AntdUI.Localization.Get("home", "主页"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
var rootIndex = 0;
|
||||
var subIndex = 0;
|
||||
var menuItemsCopy = menu.Items.ToList(); // 创建副本
|
||||
for (int i = 0; i < menuItemsCopy.Count; i++)
|
||||
{
|
||||
for (int j = 0; j < menuItemsCopy[i].Sub.Count; j++)
|
||||
{
|
||||
if (menuItemsCopy[i].Sub[j].Tag.ToString() == text)
|
||||
{
|
||||
rootIndex = i;
|
||||
subIndex = j;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
menu.SelectIndex(rootIndex, subIndex, true);
|
||||
}
|
||||
private void Menu_MouseDown(object sender, MouseEventArgs e)
|
||||
{
|
||||
if (e.Button == MouseButtons.Right)
|
||||
{
|
||||
// 转换坐标到控件内部坐标系(考虑滚动条)
|
||||
Point clickPoint = new Point(e.X, e.Y + menu.ScrollBar.Value);
|
||||
|
||||
// 递归查找命中的菜单项
|
||||
MenuItem clickedItem = FindClickedItem(menu.Items, clickPoint);
|
||||
|
||||
if (clickedItem != null)
|
||||
{
|
||||
// 显示节点名称弹窗
|
||||
//MessageBox.Show($"右键点击的节点: {clickedItem.Text}");
|
||||
|
||||
var menulist = new AntdUI.IContextMenuStripItem[]
|
||||
{
|
||||
new AntdUI.ContextMenuStripItem("关联相机", "")
|
||||
{
|
||||
IconSvg = "VideoCameraAddOutlined"
|
||||
}
|
||||
};
|
||||
AntdUI.ContextMenuStrip.open(menu, it =>
|
||||
{
|
||||
if (it.Text == "关联相机")
|
||||
{
|
||||
using (var dlg = new AddCameraWindow(cameras))
|
||||
{
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var newItem = new MenuItem(dlg.CubicleName);
|
||||
newItem.IconSvg = "VideoCameraOutlined";
|
||||
//// 防止重复添加
|
||||
//if (!menu1.Items.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
|
||||
//{
|
||||
clickedItem.Sub.Add(newItem);
|
||||
//}
|
||||
//else
|
||||
//{
|
||||
// AntdUI.Notification.warn(this, "新增失败", $"{dlg.CubicleName}已存在!", autoClose: 3, align: TAlignFrom.TR);
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, menulist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private MenuItem FindClickedItem(MenuItemCollection items, Point clickPoint)
|
||||
{
|
||||
foreach (MenuItem item in items)
|
||||
{
|
||||
// 检查当前项是否可见且包含点击坐标
|
||||
if (item.Visible && item.Rect.Contains(clickPoint))
|
||||
{
|
||||
return item;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void Menu_SelectChanged(object sender, MenuSelectEventArgs e)
|
||||
{
|
||||
string name = (string)e.Value.Tag;
|
||||
|
||||
//// 清理上一个浮动按钮窗体
|
||||
//if (currControl is FloatButtonDemo floatButtonDemo)
|
||||
//{
|
||||
// floatButtonDemo.CloseFloatButtonForm();
|
||||
//}
|
||||
|
||||
// 检查是否已存在同名 TabPage
|
||||
foreach (var tab in tabs.Pages)
|
||||
{
|
||||
if (tab is AntdUI.TabPage existingTab && existingTab.Text == name)
|
||||
{
|
||||
isUpdatingTabs = true;
|
||||
tabs.SelectedTab = existingTab;
|
||||
isUpdatingTabs = false;
|
||||
currControl = existingTab.Controls.Count > 0 ? existingTab.Controls[0] as UserControl : null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
int width = tabs.Width;
|
||||
int height = tabs.Height;
|
||||
// 创建新 TabPage
|
||||
UserDetetion control = new UserDetetion(Window,width, height);
|
||||
// control._windows = Window;
|
||||
switch (name)
|
||||
{
|
||||
case "工位1":
|
||||
// control =
|
||||
break;
|
||||
}
|
||||
|
||||
if (control != null)
|
||||
{
|
||||
control.Dock = DockStyle.Fill;
|
||||
// AutoDpi(control); // 如果有 DPI 适配逻辑
|
||||
|
||||
var tabPage = new AntdUI.TabPage
|
||||
{
|
||||
Dock = DockStyle.Fill,
|
||||
Text = name,
|
||||
};
|
||||
tabPage.Controls.Add(control);
|
||||
tabs.Pages.Add(tabPage);
|
||||
|
||||
isUpdatingTabs = true;
|
||||
tabs.SelectedTab = tabPage;
|
||||
isUpdatingTabs = false;
|
||||
currControl = control;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void tabs_SelectedIndexChanged(object sender, IntEventArgs e)
|
||||
{
|
||||
SelectMenu();
|
||||
}
|
||||
|
||||
private void btnAdd_Click(object sender, EventArgs e)
|
||||
{
|
||||
using (var dlg = new AddCubicleWindow())
|
||||
{
|
||||
if (dlg.ShowDialog() == DialogResult.OK)
|
||||
{
|
||||
var newItem = new MenuItem(dlg.CubicleName);
|
||||
//newItem.IconSvg = "AppstoreOutlined";
|
||||
// 防止重复添加
|
||||
if (!menu.Items.Cast<MenuItem>().Any(m => m.Text == newItem.Text))
|
||||
{
|
||||
menu.Items.Add(newItem);
|
||||
}
|
||||
else
|
||||
{
|
||||
// AntdUI.Notification.warn(this, "新增工位失败", $"{dlg.CubicleName}已存在!", autoClose: 3, align: TAlignFrom.TR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
70
DHSoftware/Views/UserDetetion.Designer.cs
generated
Normal file
70
DHSoftware/Views/UserDetetion.Designer.cs
generated
Normal file
@@ -0,0 +1,70 @@
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
partial class UserDetetion
|
||||
{
|
||||
/// <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()
|
||||
{
|
||||
collapse1 = new AntdUI.Collapse();
|
||||
panel1 = new Panel();
|
||||
SuspendLayout();
|
||||
//
|
||||
// collapse1
|
||||
//
|
||||
collapse1.Dock = DockStyle.Fill;
|
||||
collapse1.Location = new Point(0, 0);
|
||||
collapse1.Name = "collapse1";
|
||||
collapse1.Size = new Size(842, 568);
|
||||
collapse1.TabIndex = 0;
|
||||
collapse1.Text = "collapse1";
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
panel1.BackColor = SystemColors.GradientActiveCaption;
|
||||
panel1.Dock = DockStyle.Left;
|
||||
panel1.Location = new Point(0, 0);
|
||||
panel1.Name = "panel1";
|
||||
panel1.Size = new Size(2, 568);
|
||||
panel1.TabIndex = 0;
|
||||
//
|
||||
// UserDetetion
|
||||
//
|
||||
AutoScaleDimensions = new SizeF(7F, 17F);
|
||||
AutoScaleMode = AutoScaleMode.Font;
|
||||
Controls.Add(panel1);
|
||||
Controls.Add(collapse1);
|
||||
Name = "UserDetetion";
|
||||
Size = new Size(842, 568);
|
||||
ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private AntdUI.Collapse collapse1;
|
||||
private Panel panel1;
|
||||
//private AntdUI.Button button1;
|
||||
}
|
||||
}
|
||||
226
DHSoftware/Views/UserDetetion.cs
Normal file
226
DHSoftware/Views/UserDetetion.cs
Normal file
@@ -0,0 +1,226 @@
|
||||
using AntdUI;
|
||||
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 Button = AntdUI.Button;
|
||||
|
||||
namespace DHSoftware.Views
|
||||
{
|
||||
public partial class UserDetetion : UserControl
|
||||
{
|
||||
private StackPanel panel, panel2, panel3, panel4;
|
||||
public Window _windows;
|
||||
//根据检测配置 将对应的相机配置、中处理预处理、尺寸测量
|
||||
public UserDetetion(Window windows,int parentWidth, int parentHeight)
|
||||
{
|
||||
InitializeComponent();
|
||||
_windows = windows;
|
||||
AntdUI.CollapseItem group1 = new CollapseItem();
|
||||
group1.Height = parentHeight / 4;
|
||||
group1.Text = "相机配置";
|
||||
AntdUI.CollapseItem group2 = new CollapseItem();
|
||||
group2.Text = "预处理";
|
||||
group2.Height = parentHeight/4;
|
||||
|
||||
AntdUI.CollapseItem group3 = new CollapseItem();
|
||||
group3.Text = "中处理";
|
||||
group3.Height = parentHeight - 300;
|
||||
|
||||
AntdUI.CollapseItem group4 = new CollapseItem();
|
||||
group4.Text = "尺寸测量";
|
||||
group4.Height = parentHeight / 4;
|
||||
|
||||
|
||||
// 初始化内容面板
|
||||
panel = CreateScrollPanel();
|
||||
panel2 = CreateScrollPanel();
|
||||
panel3 = CreateScrollPanel();
|
||||
panel4 = CreateScrollPanel();
|
||||
|
||||
// 添加预处理控件
|
||||
var ptuc = new PreTreatUserControl { AutoScroll = true, Dock = DockStyle.Top };
|
||||
var detect = new DetectConfigControl { AutoScroll = true , Dock = DockStyle.Fill };
|
||||
detect._window = this._windows;
|
||||
|
||||
// 添加尺寸测量控件
|
||||
var sizeFrm = new SizeConfigControl();
|
||||
|
||||
|
||||
CameraConfigControl camConfigFrm = new CameraConfigControl();
|
||||
camConfigFrm.Dock = DockStyle.Fill;
|
||||
|
||||
|
||||
|
||||
//PreTreatUserControl ptuc = new PreTreatUserControl();
|
||||
//ptuc.AutoScroll = true;
|
||||
//panel2.Controls.Add(ptuc);
|
||||
//DetectConfigControl detect = new DetectConfigControl();
|
||||
//// detect.Dock = DockStyle.Fill;
|
||||
//detect.AutoScroll = true;
|
||||
//panel2.Controls.Add(detect);
|
||||
|
||||
|
||||
//SizeConfigControl Sizefc = new SizeConfigControl();
|
||||
//Sizefc.Dock = DockStyle.Fill;
|
||||
//panel3.Controls.Add(Sizefc);
|
||||
|
||||
|
||||
|
||||
Button btnAddCam = new Button
|
||||
{
|
||||
Width = 100,
|
||||
Height = 30,
|
||||
Text = "添加相机配置",
|
||||
//Dock=DockStyle.Bottom
|
||||
};
|
||||
Button btnDelCam = new Button
|
||||
{
|
||||
Width = 100,
|
||||
Height = 30,
|
||||
Text = "删除相机配置",
|
||||
// Dock = DockStyle.Bottom
|
||||
};
|
||||
|
||||
|
||||
Button btnAddModel = new Button
|
||||
{
|
||||
Width = 100,
|
||||
Height = 30,
|
||||
Text = "添加模型配置",
|
||||
//Dock=DockStyle.Bottom
|
||||
};
|
||||
Button btnDelModel = new Button
|
||||
{
|
||||
Width = 100,
|
||||
Height = 30,
|
||||
Text = "删除模型配置",
|
||||
// Dock = DockStyle.Bottom
|
||||
};
|
||||
|
||||
FlowLayoutPanel flow = new FlowLayoutPanel();
|
||||
flow.Dock = DockStyle.Bottom;
|
||||
flow.Controls.Add(btnAddCam);
|
||||
flow.Controls.Add(btnDelCam);
|
||||
|
||||
FlowLayoutPanel flowmodel = new FlowLayoutPanel();
|
||||
flowmodel.Dock = DockStyle.Bottom;
|
||||
flowmodel.Controls.Add(btnAddModel);
|
||||
flowmodel.Controls.Add(btnDelModel);
|
||||
btnAddCam.Click += btnAddCam_Click;
|
||||
btnDelCam.Click += btnDelCam_Click;
|
||||
btnAddModel.Click += btnAddModel_Click;
|
||||
btnDelModel.Click += btnDelModel_Click;
|
||||
|
||||
panel.Controls.Add(flow);
|
||||
panel.Controls.Add(camConfigFrm);
|
||||
|
||||
panel2.Controls.Add(ptuc);
|
||||
panel3.Controls.Add(flowmodel);
|
||||
panel3.Controls.Add(detect);
|
||||
panel4.Controls.Add(sizeFrm);
|
||||
group1.Controls.Add(panel);
|
||||
group2.Controls.Add(panel2);
|
||||
group3.Controls.Add(panel3);
|
||||
group4.Controls.Add(panel4);
|
||||
|
||||
|
||||
//collapse1.Items.Add(group1);
|
||||
collapse1.Items.Add(group1);
|
||||
collapse1.Items.Add(group2);
|
||||
collapse1.Items.Add(group3);
|
||||
collapse1.Items.Add(group4);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// 统一事件处理
|
||||
private void CameraOperation_Click(object sender, EventArgs e)
|
||||
{
|
||||
if (sender is Button btn)
|
||||
{
|
||||
switch (btn.Tag?.ToString())
|
||||
{
|
||||
case "Add":
|
||||
AddCameraConfig();
|
||||
break;
|
||||
case "Delete":
|
||||
DeleteCameraConfig();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 实际业务方法
|
||||
private void AddCameraConfig()
|
||||
{
|
||||
var newCamConfig = new CameraConfigControl { Dock = DockStyle.Top };
|
||||
panel.Controls.Add(newCamConfig);
|
||||
panel.ScrollControlIntoView(newCamConfig);
|
||||
}
|
||||
|
||||
private void DeleteCameraConfig()
|
||||
{
|
||||
if (panel.Controls.Count > 1)
|
||||
{
|
||||
panel.Controls.RemoveAt(panel.Controls.Count - 2);
|
||||
}
|
||||
}
|
||||
// 创建带滚动条的面板
|
||||
private StackPanel CreateScrollPanel()
|
||||
{
|
||||
return new StackPanel
|
||||
{
|
||||
Dock = DockStyle.Fill,
|
||||
Vertical = true,
|
||||
AutoScroll = true,
|
||||
Padding = new Padding(5) // 添加内边距避免内容贴边
|
||||
};
|
||||
}
|
||||
|
||||
private void btnAddCam_Click(object sender, EventArgs e)
|
||||
{
|
||||
CameraConfigControl camConfigFrm2 = new CameraConfigControl();
|
||||
camConfigFrm2.Dock = DockStyle.Fill;
|
||||
|
||||
panel.Controls.Add(camConfigFrm2);
|
||||
}
|
||||
private void btnDelCam_Click(object sender, EventArgs e)
|
||||
{
|
||||
// 遍历 panel 的 Controls,找到最后一个 CameraConfigControl 并移除
|
||||
for (int i = panel.Controls.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (panel.Controls[i] is CameraConfigControl)
|
||||
{
|
||||
panel.Controls.RemoveAt(i);
|
||||
break; // 只删除一个
|
||||
}
|
||||
}
|
||||
}
|
||||
private void btnAddModel_Click(object sender, EventArgs e)
|
||||
{
|
||||
DetectConfigControl DetectFrm = new DetectConfigControl();
|
||||
DetectFrm._window = this._windows;
|
||||
DetectFrm.Dock = DockStyle.Fill;
|
||||
|
||||
panel3.Controls.Add(DetectFrm);
|
||||
}
|
||||
private void btnDelModel_Click(object sender, EventArgs e)
|
||||
{
|
||||
// 遍历 panel 的 Controls,找到最后一个 CameraConfigControl 并移除
|
||||
for (int i = panel3.Controls.Count - 1; i >= 0; i--)
|
||||
{
|
||||
if (panel3.Controls[i] is DetectConfigControl)
|
||||
{
|
||||
panel3.Controls.RemoveAt(i);
|
||||
break; // 只删除一个
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
120
DHSoftware/Views/UserDetetion.resx
Normal file
120
DHSoftware/Views/UserDetetion.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,4 +1,5 @@
|
||||
using DH.Devices.Vision;
|
||||
using DH.Commons.Enums;
|
||||
using DH.Devices.Vision;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
Reference in New Issue
Block a user