From 78068989fbfb9059dab6851b8dffad7080b48312 Mon Sep 17 00:00:00 2001 From: wyj <157651241@qq.com> Date: Fri, 5 Jul 2024 13:52:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BA=A2=E8=89=B2=E8=BD=AF=E4=BB=B6=E5=8D=A1?= =?UTF-8?q?=E6=8E=A7Recipe=E5=90=8D=E7=A7=B0=E7=9A=84=E7=89=B9=E6=AE=8A?= =?UTF-8?q?=E5=AD=97=E7=AC=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitignore | 1 + LaipuDrawing/RecipeMgr.cpp | 53 +++++++++++++++++++++++++++++++++----- LaipuDrawing/RecipeMgr.h | 3 ++- 3 files changed, 49 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index de242d9..3034cb2 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ /LaiPuLaser/Debug *.ipch /LaiPuLaser/LaiPuLaser +/LaipuDrawing/LaiPuLaser.aps diff --git a/LaipuDrawing/RecipeMgr.cpp b/LaipuDrawing/RecipeMgr.cpp index cea5123..56481b6 100644 --- a/LaipuDrawing/RecipeMgr.cpp +++ b/LaipuDrawing/RecipeMgr.cpp @@ -1581,18 +1581,22 @@ CString CRecipeMgr::RecipeCtrlExcute(CRecipeCtrlItem &CtrlItem) if(RecipeCtrlType==_RecipeCtrl_AddGroup ||RecipeCtrlType==_RecipeCtrl_GroupName ||RecipeCtrlType==_RecipeCtrl_RecipeName - ||RecipeCtrlType==_RecipeCtrl_AddRecipe) + ||RecipeCtrlType==_RecipeCtrl_AddRecipe + || RecipeCtrlType == _RecipeCtrl_CopyRecipe) { - if(EditName2.Find('.',0)!= -1) - { - ErrMsg = "不能有小数点!"; - return ErrMsg; - } - if(EditName2=="") + if(EditName2=="") { ErrMsg = "输入不能为空!"; return ErrMsg; } + else + { + ErrMsg = CheckInvalidChar(EditName2); + if (!ErrMsg.IsEmpty()) + { + return ErrMsg; + } + } } switch(RecipeCtrlType) @@ -2526,4 +2530,39 @@ CString CRecipeMgr::GetShowParText(int Row) return str; } +CString CRecipeMgr::CheckInvalidChar(CString Str) +{ + CString RetStr = ""; + int Len = Str.GetLength(); + const char* CheckCh = (LPCTSTR)Str; + char ch; + for (int i = 0; i= 'a' && ch <= 'z') + || (ch >= 'A' && ch <= 'Z') + || ('%'==ch ) + || (ch >= '0' && ch <= '9') + || ('_' == ch) + || ('.' == ch&&i!=0&&i!= Len-1)) + { + continue; + } + else + { + if ('.' == ch) + { + RetStr = "'.'不能位于首尾!"; + } + else + { + RetStr = "含无效字符!(有效字符含字母大小写、数字、小数点、下划线、百分号)"; + } + break; + } + + } + return RetStr; +} + #endif diff --git a/LaipuDrawing/RecipeMgr.h b/LaipuDrawing/RecipeMgr.h index be37d89..4cc47e5 100644 --- a/LaipuDrawing/RecipeMgr.h +++ b/LaipuDrawing/RecipeMgr.h @@ -272,6 +272,8 @@ public: void UpdateRecipeGroupInfo(); CString GetOffsetTablePath(CString TabName); CString GetShowParText(int Row); + + CString CheckInvalidChar(CString Str); private: CString GetGroupDirPath(int GroupIdx); CString GetRecipeNameListPath(); @@ -323,7 +325,6 @@ private: double m_FocusAdjustMin;//焦距调整范围最小值 double m_FocusAdjustMax;//焦距调整范围最大值 - }; extern CRecipeMgr *gRecipeMgr; \ No newline at end of file