From 22c4fd7bb3ef1d7c6bfc67baf79aed53d22d8636 Mon Sep 17 00:00:00 2001
From: chenluhua1980 <Chenluhua@qq.com>
Date: 星期五, 14 十一月 2025 18:00:06 +0800
Subject: [PATCH] 1.竖排slot格子指示;

---
 SourceCode/Bond/Servo/PageLog.cpp |   71 ++++++++++++++++++++---------------
 1 files changed, 41 insertions(+), 30 deletions(-)

diff --git a/SourceCode/Bond/Servo/PageLog.cpp b/SourceCode/Bond/Servo/PageLog.cpp
index 4729c34..555f862 100644
--- a/SourceCode/Bond/Servo/PageLog.cpp
+++ b/SourceCode/Bond/Servo/PageLog.cpp
@@ -20,8 +20,9 @@
 	m_hbrBkgnd = nullptr;
 	m_pObserver = nullptr;
 	m_nLevel = 0;
-	m_strIncludeText = _T("");
-	m_bIncludeRegex = FALSE;
+	m_strFilterText = _T("");
+	m_bRegex = FALSE;
+	m_filterMode = FilterMode::Include;
 }
 
 CPageLog::~CPageLog()
@@ -52,7 +53,7 @@
 // CLogDlg 消息处理程序
 
 
-void CPageLog::InitRxWindow()
+void CPageLog::InitRxWindows()
 {
 	/* code */
 	// 订阅数据
@@ -70,19 +71,29 @@
 					&& pAny->getIntValue("exCode", level)) {
 					if (level >= m_nLevel) {
 						CString strText = pszLogMsg;
-						BOOL bInclude = TRUE;
-						if (!m_strIncludeText.IsEmpty()) {
-							if (!m_bIncludeRegex) {
-								bInclude = (strText.Find(m_strIncludeText) >= 0);
+						BOOL bMatch = TRUE;
+						if (!m_strFilterText.IsEmpty()) {
+							if (!m_bRegex) {
+								bMatch = (strText.Find(m_strFilterText) >= 0);
 							}
 							else {
-								bInclude = std::regex_search((LPTSTR)(LPCTSTR)strText,
-									std::regex((LPTSTR)(LPCTSTR)m_strIncludeText));
+								CString strTemp = strText;
+								strTemp.TrimRight();
+								try {
+									bMatch = std::regex_match((LPTSTR)(LPCTSTR)strTemp,
+										std::regex((LPTSTR)(LPCTSTR)m_strFilterText));
+								}
+								catch (const std::regex_error& e) {
+									TRACE(_T("正在表达式匹配检测异常: %s\n"), e.what());
+								}
+							}
+							if (m_filterMode == FilterMode::Exclude) {
+								bMatch = !bMatch;
 							}
 						}
 
 
-						if (bInclude) {
+						if (bMatch) {
 							strText.Replace("\n", "\r\n");
 							AppendLog(level, (LPTSTR)(LPCTSTR)strText);
 						}
@@ -105,14 +116,17 @@
 BOOL CPageLog::OnInitDialog()
 {
 	CDialogEx::OnInitDialog();
-	InitRxWindow();
+	InitRxWindows();
 
 
 	// 缓存
 	m_nLevel = theApp.m_model.m_configuration.getLogcatLevel();
-	theApp.m_model.m_configuration.getLogcatIncludeText(m_strIncludeText);
-	m_bIncludeRegex = theApp.m_model.m_configuration.isLogcatIncludeRegex();
+	theApp.m_model.m_configuration.getLogcatIncludeText(m_strFilterText);
+	m_bRegex = theApp.m_model.m_configuration.isLogcatIncludeRegex();
 	theApp.m_model.m_configuration.getCustomLogcatIncludeTexts(m_customIncludeTexts);
+	m_customIncludeTexts.clear();
+	m_customIncludeTexts.push_back("包含");
+	m_customIncludeTexts.push_back("排除");
 
 
 	// Level
@@ -135,6 +149,9 @@
 		strIcon1, IMAGE_ICON, 24, 24,
 		LR_LOADFROMFILE | LR_DEFAULTCOLOR | LR_CREATEDIBSECTION | LR_DEFAULTSIZE);
 	m_btnInclude.SetIcon(hIcon, hIcon, 24);
+	m_filterMode = (FilterMode)theApp.m_model.m_configuration.getFilterMode();
+	m_btnInclude.SetTextRight();
+	m_btnInclude.SetWindowText(m_filterMode == FilterMode::Include ? "包含" : "排除");
 
 	{
 		HMENU hMenu = LoadMenu(AfxGetInstanceHandle(), MAKEINTRESOURCEA(IDR_MENU_INCLUDE));
@@ -143,19 +160,19 @@
 		int i = 0;
 		for (auto& item : m_customIncludeTexts) {
 			i++;
-			InsertMenu(hSubMenu, 0, MF_BYPOSITION, 0x1998 + i, item.c_str());
+			InsertMenu(hSubMenu, i, MF_BYPOSITION, 0x1998 + i, item.c_str());
 			m_btnInclude.SetMenu(hMenu);
 		}
 	}
 
 
-	SetDlgItemText(IDC_EDIT_INCLUDE, m_strIncludeText);
+	SetDlgItemText(IDC_EDIT_INCLUDE, m_strFilterText);
 	CButton* pCheckBox = (CButton*)GetDlgItem(IDC_CHECK_REGEX);
-	pCheckBox->SetCheck(m_bIncludeRegex ? BST_CHECKED : BST_UNCHECKED);
+	pCheckBox->SetCheck(m_bRegex ? BST_CHECKED : BST_UNCHECKED);
 
 
 	// 内容
-	m_logEdit.SetMaxLineCount(500);
+	m_logEdit.SetMaxLineCount(6000);
 	m_logEdit.SetLimitText(-1);
 	Resize();
 
@@ -290,28 +307,22 @@
 void CPageLog::OnButtonIncludeMenuClicked(NMHDR* pNMHDR, LRESULT* pResult)
 {
 	BLBUTTON_NMHDR* pblbNmhdr = reinterpret_cast<BLBUTTON_NMHDR*>(pNMHDR);
-	int position = (int)pblbNmhdr->dwData;
-	std::string& strInclude = m_customIncludeTexts.at(position);
-	SetDlgItemText(IDC_EDIT_INCLUDE, strInclude.c_str());
-	CButton* pCheckBox = (CButton*)GetDlgItem(IDC_CHECK_REGEX);
-	m_bIncludeRegex = FALSE;
-	pCheckBox->SetCheck(BST_UNCHECKED);
-
-	theApp.m_model.m_configuration.setLogcatIncludeRegex(m_bIncludeRegex);
-	theApp.m_model.m_configuration.setLogcatIncludeText(m_strIncludeText);
+	m_filterMode = (FilterMode)pblbNmhdr->dwData;
+	theApp.m_model.m_configuration.setFilterMode((int)m_filterMode);
+	m_btnInclude.SetWindowText(m_filterMode == FilterMode::Include ? "包含" : "排除");
 
 	*pResult = 0;
 }
 
 void CPageLog::OnEnChangeEditInclude()
 {
-	GetDlgItemText(IDC_EDIT_INCLUDE, m_strIncludeText);
-	theApp.m_model.m_configuration.setLogcatIncludeText(m_strIncludeText);
+	GetDlgItemText(IDC_EDIT_INCLUDE, m_strFilterText);
+	theApp.m_model.m_configuration.setLogcatIncludeText(m_strFilterText);
 }
 
 void CPageLog::OnBnClickedCheckRegex()
 {
 	CButton* pCheckBox = (CButton*)GetDlgItem(IDC_CHECK_REGEX);
-	m_bIncludeRegex = pCheckBox->GetCheck();
-	theApp.m_model.m_configuration.setLogcatIncludeRegex(m_bIncludeRegex);
+	m_bRegex = pCheckBox->GetCheck();
+	theApp.m_model.m_configuration.setLogcatIncludeRegex(m_bRegex);
 }

--
Gitblit v1.9.3