|
|
|
@@ -6,6 +6,7 @@ using CCWin.SkinControl; |
|
|
|
using CCWin.Win32;
|
|
|
|
using CCWin.Win32.Const;
|
|
|
|
using DocumentFormat.OpenXml.Spreadsheet;
|
|
|
|
using DocumentFormat.OpenXml.Wordprocessing;
|
|
|
|
using GeBoShi.ImageDefect;
|
|
|
|
using GeBoShi.UI.InageShow;
|
|
|
|
using HalconDotNet;
|
|
|
|
@@ -34,6 +35,7 @@ using System; |
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel;
|
|
|
|
using System.Data;
|
|
|
|
using System.Diagnostics;
|
|
|
|
using System.Drawing;
|
|
|
|
@@ -133,6 +135,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
//实时速度
|
|
|
|
private double ActiveSpeed = 0;
|
|
|
|
//图片队列
|
|
|
|
private int _DefectEnd = 0;
|
|
|
|
private int listCntMax = 60;
|
|
|
|
private int Cam1Cnt = 0;
|
|
|
|
private int Cam2Cnt = 0;
|
|
|
|
@@ -166,11 +169,12 @@ namespace GeBoShi.SysCtrl |
|
|
|
photoIndex = _photoIndex;
|
|
|
|
path = _path;
|
|
|
|
}
|
|
|
|
public ScanPhotoInfo(int _devIndex, int _photoIndex, Mat _mat)
|
|
|
|
public ScanPhotoInfo(int _devIndex, int _photoIndex, Mat _mat, bool haveEdge = true)
|
|
|
|
{
|
|
|
|
devIndex = _devIndex;
|
|
|
|
photoIndex = _photoIndex;
|
|
|
|
mat = _mat;
|
|
|
|
EdgeSts = haveEdge;
|
|
|
|
}
|
|
|
|
public int devIndex { get; set; }
|
|
|
|
/// <summary>
|
|
|
|
@@ -180,6 +184,8 @@ namespace GeBoShi.SysCtrl |
|
|
|
public string path { get; set; }
|
|
|
|
public Mat mat { get; set; }
|
|
|
|
|
|
|
|
public bool EdgeSts { get; set; }
|
|
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
private ConcurrentQueue<ScanPhotoInfo> _matList1 = new ConcurrentQueue<ScanPhotoInfo>();
|
|
|
|
@@ -633,6 +639,21 @@ namespace GeBoShi.SysCtrl |
|
|
|
return statusMgr.Status == SystemStsEnum.Pause || statusMgr.Warning == WarningEnum.High;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取缺陷数据
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="liPhotoIndex"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private List<DefectInfo> GetDefectListInfo(int liPhotoIndex)
|
|
|
|
{
|
|
|
|
List<DefectInfo> ret;
|
|
|
|
lock (lock_defectPuase)
|
|
|
|
{
|
|
|
|
ret = defectPuaseList.Where(m => m.PhotoIndex == liPhotoIndex).ToList();
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取速度和长度
|
|
|
|
/// </summary>
|
|
|
|
@@ -736,7 +757,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
//if ((yqjimi - atcDis) < (defectPuaseList[0].Y / 100 + 1))
|
|
|
|
{
|
|
|
|
Log($"二次判断", $"计米器{yqjimi},瑕疵位置{defectPuaseList[0].Y / 100},停车距离{confMgr.SysConfigParams.StopLookDis}m,停车减速时间{confMgr.SysConfigParams.StopDecTime}s,减速位移{StopDecRunDis},实际停车距离{atcDis},实时速度{tRunSpd},匀速{aveSpd}", WarningEnum.Normal, false);
|
|
|
|
List<DefectInfo> lstEditDefect0 = defectPuaseList.Where(m => m.PhotoIndex == defectPuaseList[0].PhotoIndex).ToList();
|
|
|
|
List<DefectInfo> lstEditDefect0 = GetDefectListInfo(defectPuaseList[0].PhotoIndex);
|
|
|
|
Log($"二次判断", $"(图像{defectPuaseList[0].PhotoIndex})已达观察台,瑕疵二次判断=》({string.Join(",", lstEditDefect0.Select(m => m.Code).ToArray())})是否包含在({string.Join(",", curRecord.ProductInfo.DefectPauseOption.ToArray())})中。", WarningEnum.Normal, false);
|
|
|
|
//瑕疵选项过滤
|
|
|
|
if (curRecord.ProductInfo.DefectPauseOption.Count == 0 || lstEditDefect0.Where(x => curRecord.ProductInfo.DefectPauseOption.Contains(x.Code)).Count() > 0)
|
|
|
|
@@ -747,7 +768,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
Stop();
|
|
|
|
//获取完整数据
|
|
|
|
Thread.Sleep(500);
|
|
|
|
var lstEditDefect = defectPuaseList.Where(m => m.PhotoIndex == defectPuaseList[0].PhotoIndex).ToList();
|
|
|
|
var lstEditDefect = GetDefectListInfo(defectPuaseList[0].PhotoIndex);
|
|
|
|
#region 二级界面
|
|
|
|
int liPhotoIndex = defectPuaseList[0].PhotoIndex;
|
|
|
|
#region 加载界面
|
|
|
|
@@ -871,6 +892,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
private void Cam1ThreadFunction()
|
|
|
|
{
|
|
|
|
int errStep = 0;
|
|
|
|
int marginWidth0 = 0;
|
|
|
|
#if Online
|
|
|
|
#else
|
|
|
|
string imgfilePath = "D:\\CPL\\img\\L1.bmp";
|
|
|
|
@@ -939,25 +961,26 @@ namespace GeBoShi.SysCtrl |
|
|
|
if (defectPuaseList.Count > 0)
|
|
|
|
{
|
|
|
|
errStep = 12;
|
|
|
|
List<DefectInfo> lstEditDefect = defectPuaseList.Where(m => m.PhotoIndex == liPhotoIndex).ToList();
|
|
|
|
Log($"二次判断2", $"(图像{liPhotoIndex})已达观察台,瑕疵二次判断=》({string.Join(",", lstEditDefect.Select(m => m.Code).ToArray())})是否包含在({string.Join(",", curRecord.ProductInfo.DefectPauseOption.ToArray())})中。", WarningEnum.Normal, false);
|
|
|
|
List<DefectInfo> lstEditDefect = GetDefectListInfo(liPhotoIndex);
|
|
|
|
Log($"二次判断2", $"(图像{liPhotoIndex})已达观察台,瑕疵二次判断=》({string.Join(",", lstEditDefect.Select(m => m.Code).ToArray())})是否包含在({string.Join(",", DefectItemsPuaseNameList.ToArray())})或({string.Join(",", curRecord.ProductInfo.DefectPauseOption.ToArray())})中。", WarningEnum.Normal, false);
|
|
|
|
//瑕疵选项过滤
|
|
|
|
if (curRecord.ProductInfo.DefectPauseOption.Count == 0 || lstEditDefect.Where(x => curRecord.ProductInfo.DefectPauseOption.Contains(x.Code)).Count() > 0)
|
|
|
|
{
|
|
|
|
Log($"二次判断2", $"(图像{liPhotoIndex})需瑕疵二次判断,已达观察台,进入暂停。速度:{GetSpd()}");
|
|
|
|
Log($"二次判断2", $"(图像{liPhotoIndex})需瑕疵二次判断,已达观察台,进入暂停。速度:{GetSpd()},停车缺陷数:{lstEditDefect.Where(x => DefectItemsPuaseNameList.Contains(x.Name)).Count()}");
|
|
|
|
// if (lstEditDefect.Where(x => x.Code == "jietou").Count() > 0)
|
|
|
|
if (lstEditDefect.Where(x => DefectItemsPuaseNameList.Contains(x.Name)).Count() > 0)
|
|
|
|
//if (lstEditDefect.Where(x => DefectItemsPuaseNameList.Contains(x.Name)).Count() > 0)
|
|
|
|
{
|
|
|
|
Stop();
|
|
|
|
//获取完整数据
|
|
|
|
Thread.Sleep(500);
|
|
|
|
|
|
|
|
lstEditDefect = defectPuaseList.Where(m => m.PhotoIndex == liPhotoIndex).ToList();
|
|
|
|
lstEditDefect = GetDefectListInfo(liPhotoIndex);
|
|
|
|
//获取完整数据
|
|
|
|
#region 二级界面
|
|
|
|
#region 加载界面
|
|
|
|
if (defectPuaseImgList.ContainsKey(liPhotoIndex))
|
|
|
|
{
|
|
|
|
Log($"二次判断2", $"(图像{liPhotoIndex})需瑕疵二次判断,缺陷数:{lstEditDefect.Count}");
|
|
|
|
var pmat = defectPuaseImgList[liPhotoIndex].Clone();
|
|
|
|
OnAutoRuning(new RunEventArgs(liPhotoIndex, lstEditDefect, curRecord, pmat));
|
|
|
|
#if false
|
|
|
|
@@ -1023,8 +1046,8 @@ namespace GeBoShi.SysCtrl |
|
|
|
#endregion
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//预处理
|
|
|
|
Stopwatch stopWatch = new Stopwatch();
|
|
|
|
//预处理
|
|
|
|
Stopwatch stopWatch = new Stopwatch();
|
|
|
|
//Log($"图像预处理", $"相机1-{Cam1Cnt}", WarningEnum.Normal, false);
|
|
|
|
string time = "";
|
|
|
|
stopWatch.Start();
|
|
|
|
@@ -1089,8 +1112,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
}
|
|
|
|
}
|
|
|
|
errStep = 4;
|
|
|
|
//左裁边
|
|
|
|
int marginWidth0;
|
|
|
|
//左裁边
|
|
|
|
mat = OpencvUtils.getMaxInsetRect2(mat, true, confMgr.SysConfigParams.HolePx, out marginWidth0);
|
|
|
|
//存储裁边异常相机图 差异5cm
|
|
|
|
if (_marginWidth1 == 0)
|
|
|
|
@@ -1115,7 +1137,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
}
|
|
|
|
//Log($"图像1入队列", $"相机1-{Cam1Cnt}", WarningEnum.Normal, false);
|
|
|
|
//Cv2.Flip(img, img, FlipMode.XY);//翻转
|
|
|
|
_matList1.Enqueue(new ScanPhotoInfo(0, Cam1Cnt++, mat.Clone()));
|
|
|
|
_matList1.Enqueue(new ScanPhotoInfo(0, Cam1Cnt++, mat.Clone(), marginWidth0 != 0));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Log($"相机1", $"(图像)-未扫码,图像丢弃!", WarningEnum.Low);
|
|
|
|
@@ -1150,7 +1172,9 @@ namespace GeBoShi.SysCtrl |
|
|
|
/// 相机2采图预处理
|
|
|
|
/// </summary>
|
|
|
|
private void Cam2ThreadFunction()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int errStep = 0;
|
|
|
|
int marginWidth0 = 0;
|
|
|
|
#if Online
|
|
|
|
#else
|
|
|
|
string imgfilePath = "D:\\CPL\\img\\R1.bmp";
|
|
|
|
@@ -1234,7 +1258,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
System.GC.Collect();
|
|
|
|
}
|
|
|
|
|
|
|
|
int errStep = 0;
|
|
|
|
|
|
|
|
Mat mat = img;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
@@ -1254,7 +1278,6 @@ namespace GeBoShi.SysCtrl |
|
|
|
}
|
|
|
|
errStep = 4;
|
|
|
|
//右裁边
|
|
|
|
int marginWidth0;
|
|
|
|
mat = OpencvUtils.getMaxInsetRect2(mat, false, confMgr.SysConfigParams.HolePx, out marginWidth0);
|
|
|
|
//存储裁边异常相机图 差异5cm
|
|
|
|
if (_marginWidth2 == 0)
|
|
|
|
@@ -1277,7 +1300,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
}
|
|
|
|
//Log($"图像2入队列", $"相机2-{Cam1Cnt}", WarningEnum.Normal, false);
|
|
|
|
//Cv2.Flip(img, img, FlipMode.XY);//翻转
|
|
|
|
_matList2.Enqueue(new ScanPhotoInfo(1, Cam2Cnt++, mat.Clone()));
|
|
|
|
_matList2.Enqueue(new ScanPhotoInfo(1, Cam2Cnt++, mat.Clone(), marginWidth0 != 0));
|
|
|
|
//System.GC.Collect();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
@@ -1856,34 +1879,46 @@ namespace GeBoShi.SysCtrl |
|
|
|
#endregion
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//----缺陷队列
|
|
|
|
//比例缩放图片
|
|
|
|
int xw;
|
|
|
|
int resizeWidth = OpencvUtils.GetWidthForResize(mat0.Width + mat1.Width - confMgr.SysConfigParams.MidCoin);
|
|
|
|
if (resizeWidth == 0)
|
|
|
|
throw new Exception("GetWidthForResize result 0 失败!");
|
|
|
|
var resize = new System.Drawing.Size(resizeWidth, OpencvUtils.image_height * 2);//固定8192*2张*4096
|
|
|
|
mat = OpencvUtils.Resize(mat, resize.Width, resize.Height, out xw);
|
|
|
|
//Log($"图像处理", $"(图像{scanPhotos0.photoIndex})-合成图resize后:{mat.Width}*{mat.Height}", WarningEnum.Normal, false);
|
|
|
|
defectLib.add(new DefectTask()
|
|
|
|
if (scanPhotos1.EdgeSts == false && scanPhotos0.EdgeSts == false && _DefectEnd >= 1)
|
|
|
|
{
|
|
|
|
modelName = curRecord.ProductInfo.ModelName,
|
|
|
|
record = curRecord,
|
|
|
|
bmp = mat,
|
|
|
|
bmpTag = mat.Clone(),
|
|
|
|
photoIndex = scanPhotos0.photoIndex,//0-n 首张必需为0,因下面计算长度是从0开始
|
|
|
|
widthRatio = 1.0f,//等比例缩放,高度不变
|
|
|
|
qualifiedLimitList = curRecord.ProductInfo.QualifiedLimitList,
|
|
|
|
labelDic = GetDefectCode(),
|
|
|
|
finishEvent = callBackDefectEvent,
|
|
|
|
xw = xw,
|
|
|
|
cm2px_x = confMgr.SysConfigParams.Cm2px_x,
|
|
|
|
cm2px_y = confMgr.SysConfigParams.Cm2px_y,
|
|
|
|
expand_pixel = confMgr.SysConfigParams.Expand_pixel,
|
|
|
|
});
|
|
|
|
curRecord.ScannerPhotoCount++;
|
|
|
|
errStep = 10;
|
|
|
|
time += $"->加入瑕疵待检队列({stopWatch.ElapsedMilliseconds})";
|
|
|
|
//出现第二次判断没有边缘
|
|
|
|
Log($"图像处理", $"未找到边缘当作空跑处理:(图像{scanPhotos0.photoIndex})", WarningEnum.Normal, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (scanPhotos1.EdgeSts == false && scanPhotos0.EdgeSts == false)
|
|
|
|
_DefectEnd++;//没边计数
|
|
|
|
else
|
|
|
|
_DefectEnd = 0; //有边的情况重置
|
|
|
|
//----缺陷队列
|
|
|
|
//比例缩放图片
|
|
|
|
int xw;
|
|
|
|
int resizeWidth = OpencvUtils.GetWidthForResize(mat0.Width + mat1.Width - confMgr.SysConfigParams.MidCoin);
|
|
|
|
if (resizeWidth == 0)
|
|
|
|
throw new Exception("GetWidthForResize result 0 失败!");
|
|
|
|
var resize = new System.Drawing.Size(resizeWidth, OpencvUtils.image_height * 2);//固定8192*2张*4096
|
|
|
|
mat = OpencvUtils.Resize(mat, resize.Width, resize.Height, out xw);
|
|
|
|
//Log($"图像处理", $"(图像{scanPhotos0.photoIndex})-合成图resize后:{mat.Width}*{mat.Height}", WarningEnum.Normal, false);
|
|
|
|
defectLib.add(new DefectTask()
|
|
|
|
{
|
|
|
|
modelName = curRecord.ProductInfo.ModelName,
|
|
|
|
record = curRecord,
|
|
|
|
bmp = mat,
|
|
|
|
bmpTag = mat.Clone(),
|
|
|
|
photoIndex = scanPhotos0.photoIndex,//0-n 首张必需为0,因下面计算长度是从0开始
|
|
|
|
widthRatio = 1.0f,//等比例缩放,高度不变
|
|
|
|
qualifiedLimitList = curRecord.ProductInfo.QualifiedLimitList,
|
|
|
|
labelDic = GetDefectCode(),
|
|
|
|
finishEvent = callBackDefectEvent,
|
|
|
|
xw = xw,
|
|
|
|
cm2px_x = confMgr.SysConfigParams.Cm2px_x,
|
|
|
|
cm2px_y = confMgr.SysConfigParams.Cm2px_y,
|
|
|
|
expand_pixel = confMgr.SysConfigParams.Expand_pixel,
|
|
|
|
});
|
|
|
|
curRecord.ScannerPhotoCount++;
|
|
|
|
errStep = 10;
|
|
|
|
time += $"->加入瑕疵待检队列({stopWatch.ElapsedMilliseconds})";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
@@ -2296,7 +2331,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
saveImgInfo.Img = null;
|
|
|
|
System.GC.Collect();
|
|
|
|
}
|
|
|
|
Log("存图警告", "存图超限-出队", WarningEnum.Low);
|
|
|
|
Log("存图警告", "存图超限-出队", WarningEnum.Normal);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
private void AddImageSave(string path, DataTable dt)
|
|
|
|
@@ -2345,7 +2380,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
saveImgInfo.Img = null;
|
|
|
|
System.GC.Collect();
|
|
|
|
}
|
|
|
|
Log("存图警告", "存图超限-紧急出队", WarningEnum.Low);
|
|
|
|
Log("存图警告", "存图超限-紧急出队", WarningEnum.Normal);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
@@ -3396,6 +3431,7 @@ namespace GeBoShi.SysCtrl |
|
|
|
_marginWidth1 = 0;
|
|
|
|
_marginWidth2 = 0;
|
|
|
|
|
|
|
|
_DefectEnd = 0;
|
|
|
|
Cam1Cnt = 0;
|
|
|
|
Cam2Cnt = 0;
|
|
|
|
|
|
|
|
@@ -3531,21 +3567,30 @@ namespace GeBoShi.SysCtrl |
|
|
|
int count;
|
|
|
|
foreach (GradeLimit item in gradeLimitList)
|
|
|
|
{
|
|
|
|
if (model.DefectInfoList != null && model.DefectInfoList.Count > 0)
|
|
|
|
if (item.A == 0 && item.B == 0 && item.C == 0 && item.D == 0 && item.E == 0)
|
|
|
|
{
|
|
|
|
count = model.DefectInfoList.Where(m => m.Code == item.Code).Count();
|
|
|
|
if (count <= item.A && model.Grade <= 1) model.Grade = 1;
|
|
|
|
else if (count <= item.B && item.B > 0 && model.Grade <= 2) model.Grade = 2;
|
|
|
|
else if (count <= item.C && item.C > 0 && model.Grade <= 3) model.Grade = 3;
|
|
|
|
else if (count <= item.D && item.D > 0 && model.Grade <= 4) model.Grade = 4;
|
|
|
|
else if (count <= item.E && item.E > 0 && model.Grade <= 5) model.Grade = 5;
|
|
|
|
else if (count > 0) model.Grade = 6;//不合格
|
|
|
|
Log("标准判断", $"({key}) 条码({model.BarCode}),标准={(char)(model.Grade + 64)} [{item.Code}:{count};A<={item.A};B<={item.B};C<={item.C};D<={item.D};E<={item.E}]");
|
|
|
|
model.Grade = 1;
|
|
|
|
Log("标准判断", $"({key}) 条码({model.BarCode}),无设置标准={(char)(model.Grade + 64)} [{item.Code}:{count};A<={item.A};B<={item.B};C<={item.C};D<={item.D};E<={item.E}]");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
model.Grade = 1;
|
|
|
|
Log("标准判断", $"({key}) 条码({model.BarCode}),标准={(char)(model.Grade + 64)} [{item.Code}:{0};A<={item.A};B<={item.B};C<={item.C};D<={item.D};E<={item.E}]");
|
|
|
|
if (model.DefectInfoList != null && model.DefectInfoList.Count > 0)
|
|
|
|
{
|
|
|
|
count = model.DefectInfoList.Where(m => m.Code == item.Code).Count();
|
|
|
|
if (count <= item.A && model.Grade <= 1) model.Grade = 1;
|
|
|
|
else if (count <= item.B && item.B > 0 && model.Grade <= 2) model.Grade = 2;
|
|
|
|
else if (count <= item.C && item.C > 0 && model.Grade <= 3) model.Grade = 3;
|
|
|
|
else if (count <= item.D && item.D > 0 && model.Grade <= 4) model.Grade = 4;
|
|
|
|
else if (count <= item.E && item.E > 0 && model.Grade <= 5) model.Grade = 5;
|
|
|
|
else if (count > 0) model.Grade = 6;//不合格
|
|
|
|
Log("标准判断", $"({key}) 条码({model.BarCode}),标准={(char)(model.Grade + 64)} [{item.Code}:{count};A<={item.A};B<={item.B};C<={item.C};D<={item.D};E<={item.E}]");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
model.Grade = 1;
|
|
|
|
Log("标准判断", $"({key}) 条码({model.BarCode}),标准={(char)(model.Grade + 64)} [{item.Code}:{0};A<={item.A};B<={item.B};C<={item.C};D<={item.D};E<={item.E}]");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
step = 5;
|
|
|
|
@@ -3705,6 +3750,133 @@ namespace GeBoShi.SysCtrl |
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 颜色判断
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 根据RGB判断颜色
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="Clr"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public static string CLRToName(System.Drawing.Color Clr)
|
|
|
|
{
|
|
|
|
double d_r = (double)Clr.R / 83;
|
|
|
|
double d_g = (double)Clr.G / 83;
|
|
|
|
double d_b = (double)Clr.B / 83;
|
|
|
|
int r = (int)Math.Round(d_r);
|
|
|
|
int g = (int)Math.Round(d_g);
|
|
|
|
int b = (int)Math.Round(d_b);
|
|
|
|
string rgb = r.ToString() + "," + g.ToString() + "," + b.ToString();
|
|
|
|
#region "switch (rgb)"
|
|
|
|
switch (rgb)
|
|
|
|
{
|
|
|
|
case "0,0,0":
|
|
|
|
case "1,1,1":
|
|
|
|
case "2,2,2":
|
|
|
|
case "3,3,3":
|
|
|
|
if (r == 0) return RGBName.Black.GetDescription();
|
|
|
|
if (r == 1) return RGBName.Gray.GetDescription();
|
|
|
|
if (r == 2) return RGBName.LightGray.GetDescription();
|
|
|
|
if (r == 3) return RGBName.White.GetDescription();
|
|
|
|
break;
|
|
|
|
case "0,0,3":
|
|
|
|
case "0,3,0":
|
|
|
|
case "3,0,0":
|
|
|
|
case "1,1,3":
|
|
|
|
case "1,3,1":
|
|
|
|
case "3,1,1":
|
|
|
|
case "0,1,3":
|
|
|
|
case "0,3,1":
|
|
|
|
case "3,0,1":
|
|
|
|
case "1,0,3":
|
|
|
|
case "1,3,0":
|
|
|
|
case "3,1,0":
|
|
|
|
case "0,0,2":
|
|
|
|
case "0,2,0":
|
|
|
|
case "2,0,0":
|
|
|
|
case "1,1,2":
|
|
|
|
case "1,2,1":
|
|
|
|
case "2,1,1":
|
|
|
|
case "0,1,2":
|
|
|
|
case "0,2,1":
|
|
|
|
case "2,0,1":
|
|
|
|
case "1,0,2":
|
|
|
|
case "1,2,0":
|
|
|
|
case "2,1,0":
|
|
|
|
if (r == 2) return RGBName.DarkRed.GetDescription();
|
|
|
|
if (g == 2) return RGBName.DarkGreen.GetDescription();
|
|
|
|
if (b == 2) return RGBName.DarkBlue.GetDescription();
|
|
|
|
if (r == 3) return RGBName.Red.GetDescription();
|
|
|
|
if (g == 3) return RGBName.Green.GetDescription();
|
|
|
|
if (b == 3) return RGBName.Blue.GetDescription();
|
|
|
|
break;
|
|
|
|
case "0,0,1":
|
|
|
|
case "0,1,0":
|
|
|
|
case "1,0,0":
|
|
|
|
case "2,2,3":
|
|
|
|
case "2,3,2":
|
|
|
|
case "3,2,2":
|
|
|
|
if (r == 1) return RGBName.DarkRed.GetDescription();
|
|
|
|
if (g == 1) return RGBName.DarkGreen.GetDescription();
|
|
|
|
if (b == 1) return RGBName.DarkBlue.GetDescription();
|
|
|
|
if (r == 3) return RGBName.LightRed.GetDescription();
|
|
|
|
if (g == 3) return RGBName.LightGreen.GetDescription();
|
|
|
|
if (b == 3) return RGBName.LightBlue.GetDescription();
|
|
|
|
break;
|
|
|
|
case "1,1,0":
|
|
|
|
case "0,1,1":
|
|
|
|
case "1,0,1":
|
|
|
|
case "2,2,0":
|
|
|
|
case "0,2,2":
|
|
|
|
case "2,0,2":
|
|
|
|
case "2,2,1":
|
|
|
|
case "1,2,2":
|
|
|
|
case "2,1,2":
|
|
|
|
case "3,3,0":
|
|
|
|
case "0,3,3":
|
|
|
|
case "3,0,3":
|
|
|
|
case "3,3,1":
|
|
|
|
case "1,3,3":
|
|
|
|
case "3,1,3":
|
|
|
|
case "3,3,2":
|
|
|
|
case "2,3,3":
|
|
|
|
case "3,2,3":
|
|
|
|
if (r == 1 && g == 1) return RGBName.DarkYellow.GetDescription();
|
|
|
|
if (g == 1 && b == 1) return RGBName.DarkCyan.GetDescription();
|
|
|
|
if (r == 1 && b == 1) return RGBName.DarkPurple.GetDescription();
|
|
|
|
if (r == 2 && g == 2) return RGBName.Yellow.GetDescription();
|
|
|
|
if (g == 2 && b == 2) return RGBName.Cyan.GetDescription();
|
|
|
|
if (r == 2 && b == 2) return RGBName.Purple.GetDescription();
|
|
|
|
if (r == 3 && g == 3) return RGBName.LightYellow.GetDescription();
|
|
|
|
if (g == 3 && b == 3) return RGBName.LightCyan.GetDescription();
|
|
|
|
if (r == 3 && b == 3) return RGBName.LightPurple.GetDescription();
|
|
|
|
break;
|
|
|
|
case "3,2,0":
|
|
|
|
case "3,2,1":
|
|
|
|
return RGBName.Orange.GetDescription();
|
|
|
|
case "2,3,0":
|
|
|
|
case "2,3,1":
|
|
|
|
return RGBName.YellowGreen.GetDescription();
|
|
|
|
case "0,3,2":
|
|
|
|
case "1,3,2":
|
|
|
|
return RGBName.CyanGreen.GetDescription();
|
|
|
|
case "0,2,3":
|
|
|
|
case "1,2,3":
|
|
|
|
return RGBName.CyanBlue.GetDescription();
|
|
|
|
case "3,0,2":
|
|
|
|
case "3,1,2":
|
|
|
|
return RGBName.PurpleRed.GetDescription();
|
|
|
|
case "2,0,3":
|
|
|
|
case "2,1,3":
|
|
|
|
return RGBName.PurpleBlue.GetDescription();
|
|
|
|
default:
|
|
|
|
return "Error";
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
return "Error";
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
#region 系统事件
|
|
|
|
/// <summary>
|
|
|
|
@@ -3922,4 +4094,76 @@ namespace GeBoShi.SysCtrl |
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 颜色定义
|
|
|
|
public enum RGBName
|
|
|
|
{
|
|
|
|
[Description("红")]
|
|
|
|
Red = 1,
|
|
|
|
[Description("绿")]
|
|
|
|
Green,
|
|
|
|
[Description("蓝")]
|
|
|
|
Blue,
|
|
|
|
[Description("深红")]
|
|
|
|
DarkRed,
|
|
|
|
[Description("深绿")]
|
|
|
|
DarkGreen,
|
|
|
|
[Description("深蓝")]
|
|
|
|
DarkBlue,
|
|
|
|
[Description("浅红")]
|
|
|
|
LightRed,
|
|
|
|
[Description("浅绿")]
|
|
|
|
LightGreen,
|
|
|
|
[Description("浅蓝")]
|
|
|
|
LightBlue,
|
|
|
|
[Description("黄")]
|
|
|
|
Yellow,
|
|
|
|
[Description("青")]
|
|
|
|
Cyan,
|
|
|
|
[Description("紫")]
|
|
|
|
Purple,
|
|
|
|
[Description("深黄")]
|
|
|
|
DarkYellow,
|
|
|
|
[Description("深青")]
|
|
|
|
DarkCyan,
|
|
|
|
[Description("深紫")]
|
|
|
|
DarkPurple,
|
|
|
|
[Description("浅黄")]
|
|
|
|
LightYellow,
|
|
|
|
[Description("浅青")]
|
|
|
|
LightCyan,
|
|
|
|
[Description("浅紫")]
|
|
|
|
LightPurple,
|
|
|
|
[Description("橙")]
|
|
|
|
Orange,
|
|
|
|
[Description("黄绿")]
|
|
|
|
YellowGreen,
|
|
|
|
[Description("青绿")]
|
|
|
|
CyanGreen,
|
|
|
|
[Description("青蓝")]
|
|
|
|
CyanBlue,
|
|
|
|
[Description("紫蓝")]
|
|
|
|
PurpleBlue,
|
|
|
|
[Description("紫红")]
|
|
|
|
PurpleRed,
|
|
|
|
[Description("黑")]
|
|
|
|
Black,
|
|
|
|
[Description("白")]
|
|
|
|
White,
|
|
|
|
[Description("灰")]
|
|
|
|
Gray,
|
|
|
|
[Description("浅灰")]
|
|
|
|
LightGray,
|
|
|
|
}
|
|
|
|
|
|
|
|
static class EnumExtensions
|
|
|
|
{
|
|
|
|
public static string GetDescription(this Enum val)
|
|
|
|
{
|
|
|
|
var field = val.GetType().GetField(val.ToString());
|
|
|
|
var customAttribute = Attribute.GetCustomAttribute(field, typeof(DescriptionAttribute));
|
|
|
|
return customAttribute == null ? val.ToString() : ((DescriptionAttribute)customAttribute).Description;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|