| | |
| | | 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() |
| | |
| | | BEGIN_MESSAGE_MAP(CPageLog, CDialogEx) |
| | | ON_WM_CTLCOLOR() |
| | | ON_WM_SIZE() |
| | | ON_WM_TIMER() |
| | | ON_WM_DESTROY() |
| | | ON_WM_CLOSE() |
| | | ON_NOTIFY(BLBUTTON_MENU_ITEM_CLICKED, IDC_BUTTON_LEVEL, &CPageLog::OnButtonLevelMenuClicked) |
| | |
| | | && 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) { |
| | | |
| | | } |
| | | } |
| | | if (m_filterMode == FilterMode::Exclude) { |
| | | bMatch = !bMatch; |
| | | } |
| | | } |
| | | |
| | | |
| | | if (bInclude) { |
| | | if (bMatch) { |
| | | strText.Replace("\n", "\r\n"); |
| | | AppendLog(level, (LPTSTR)(LPCTSTR)strText); |
| | | } |
| | |
| | | BOOL CPageLog::OnInitDialog() |
| | | { |
| | | CDialogEx::OnInitDialog(); |
| | | SetTimer(1, 3000, nullptr); |
| | | InitRxWindow(); |
| | | |
| | | |
| | | // 缓存 |
| | | 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 |
| | |
| | | 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)); |
| | |
| | | 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(); |
| | | |
| | | |
| | |
| | | CDialogEx::OnSize(nType, cx, cy); |
| | | if (GetDlgItem(IDC_EDIT_LOG) == nullptr) return; |
| | | Resize(); |
| | | } |
| | | |
| | | void CPageLog::OnTimer(UINT_PTR nIDEvent) |
| | | { |
| | | if (1 == nIDEvent) { |
| | | KillTimer(1); |
| | | InitRxWindow(); |
| | | } |
| | | } |
| | | |
| | | void CPageLog::Resize() |
| | |
| | | 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); |
| | | } |