mrDarker
2025-06-23 69647c4a61e315027a5a222a28e34ceb1c868775
SourceCode/Bond/Servo/PageAlarm.cpp
@@ -39,6 +39,13 @@
CPageAlarm::~CPageAlarm()
{
   if (m_hbrBkgnd != nullptr) {
      ::DeleteObject(m_hbrBkgnd);
   }
   if (m_pObserver != nullptr) {
      m_pObserver->unsubscribe();
      m_pObserver = nullptr;
   }
}
void CPageAlarm::InitRxWindow()
@@ -75,12 +82,52 @@
void CPageAlarm::Resize()
{
   CWnd* pItem;
   CRect rcClient;
   GetClientRect(&rcClient);
   pItem = GetDlgItem(IDC_LIST_ALARM);
   pItem->MoveWindow(12, 58, rcClient.Width() - 24, rcClient.Height() - 64);
   // ===== 常量定义 =====
   const int nLeft = 12;
   const int nRight = 12;
   const int nTop = 58;
   const int nButtonHeight = 28;
   const int nButtonMarginBottom = 12;
   const int nSpacing = 8;
   const int nButtonWidth = 80;
   const int nLabelWidth = 100;
   // ===== 分页控件布局 =====
   int yBottom = rcClient.bottom - nButtonMarginBottom - nButtonHeight;
   int xRight = rcClient.Width() - nRight;
   CWnd* pBtnNext = GetDlgItem(IDC_BUTTON_NEXT_PAGE);
   CWnd* pBtnPrev = GetDlgItem(IDC_BUTTON_PREV_PAGE);
   CWnd* pLabelPage = GetDlgItem(IDC_LABEL_PAGE_NUMBER);
   if (pBtnNext && pBtnPrev && pLabelPage) {
      // 获取分页文本宽度估算
      //CString strLabel;
      //GetDlgItemText(IDC_LABEL_PAGE_NUMBER, strLabel);
      //if (strLabel.IsEmpty()) {
      //   strLabel = _T("第 1 / 1 页");
      //}
      //int nCharWidth = 8;
      //int nLabelWidth = strLabel.GetLength() * nCharWidth + 20;
      // 设置按钮和标签位置
      pBtnNext->MoveWindow(xRight - nButtonWidth, yBottom, nButtonWidth, nButtonHeight);
      xRight -= nButtonWidth + nSpacing;
      pLabelPage->MoveWindow(xRight - nLabelWidth, yBottom, nLabelWidth, nButtonHeight);
      xRight -= nLabelWidth + nSpacing;
      pBtnPrev->MoveWindow(xRight - nButtonWidth, yBottom, nButtonWidth, nButtonHeight);
   }
   // ===== 表格区域布局 =====
   if (nullptr != m_listCtrl.m_hWnd) {
      int listHeight = yBottom - nTop - nSpacing;
      m_listCtrl.MoveWindow(nLeft, nTop, rcClient.Width() - nLeft - nRight, listHeight);
   }
}
void CPageAlarm::LoadAlarms()
@@ -107,19 +154,18 @@
{
   // 更新分页信息
   CString strPage;
   strPage.Format(_T("第 %d 页"), m_nCurPage);
   strPage.Format(_T("第 %d / %d 页"), m_nCurPage, m_nTotalPages);
   SetDlgItemText(IDC_LABEL_PAGE_NUMBER, strPage);
   // 启用/禁用翻页按钮
   GetDlgItem(IDC_BUTTON_PREV_PAGE)->EnableWindow(m_nCurPage > 1);
   GetDlgItem(IDC_BUTTON_NEXT_PAGE)->EnableWindow(m_nCurPage < m_nTotalPages);
   // 调整控件大小
   // Resize();
}
<<<<<<< HEAD:SourceCode/Bond/Servo/AlarmDlg.cpp
void CAlarmDlg::FillDataToListCtrl(CListCtrl* pListCtrl, const std::vector<AlarmData>& vecData)
=======
void CPageAlarm::FillDataToListCtrl(CListCtrl* pListCtrl, const std::vector<AlarmData>& vecData)
>>>>>>> clh:SourceCode/Bond/Servo/PageAlarm.cpp
{
   if (pListCtrl == nullptr || pListCtrl->m_hWnd == nullptr) {
      return;
@@ -139,11 +185,7 @@
}
static char* pszAlarmLevel[] = { "Warning", "Error" };
<<<<<<< HEAD:SourceCode/Bond/Servo/AlarmDlg.cpp
void CAlarmDlg::InsertAlarmData(CListCtrl* pListCtrl, const AlarmData& alarmData)
=======
void CPageAlarm::InsertAlarmData(CListCtrl* pListCtrl, const AlarmData& alarmData)
>>>>>>> clh:SourceCode/Bond/Servo/PageAlarm.cpp
{
   if (pListCtrl == nullptr || pListCtrl->m_hWnd == nullptr) {
      return;
@@ -195,20 +237,11 @@
   ON_WM_DESTROY()
   ON_WM_CLOSE()
   ON_WM_SIZE()
<<<<<<< HEAD:SourceCode/Bond/Servo/AlarmDlg.cpp
   ON_WM_TIMER()
   ON_CBN_SELCHANGE(IDC_COMBO_DATETIME, &CAlarmDlg::OnCbnSelchangeComboDatetime)
   ON_BN_CLICKED(IDC_BUTTON_SEARCH, &CAlarmDlg::OnBnClickedButtonSearch)
   ON_BN_CLICKED(IDC_BUTTON_EXPORT, &CAlarmDlg::OnBnClickedButtonExport)
   ON_BN_CLICKED(IDC_BUTTON_PREV_PAGE, &CAlarmDlg::OnBnClickedButtonPrevPage)
   ON_BN_CLICKED(IDC_BUTTON_NEXT_PAGE, &CAlarmDlg::OnBnClickedButtonNextPage)
=======
   ON_CBN_SELCHANGE(IDC_COMBO_DATETIME, &CPageAlarm::OnCbnSelchangeComboDatetime)
   ON_BN_CLICKED(IDC_BUTTON_SEARCH, &CPageAlarm::OnBnClickedButtonSearch)
   ON_BN_CLICKED(IDC_BUTTON_EXPORT, &CPageAlarm::OnBnClickedButtonExport)
   ON_BN_CLICKED(IDC_BUTTON_PREV_PAGE, &CPageAlarm::OnBnClickedButtonPrevPage)
   ON_BN_CLICKED(IDC_BUTTON_NEXT_PAGE, &CPageAlarm::OnBnClickedButtonNextPage)
>>>>>>> clh:SourceCode/Bond/Servo/PageAlarm.cpp
END_MESSAGE_MAP()
@@ -331,19 +364,7 @@
   Resize();
}
<<<<<<< HEAD:SourceCode/Bond/Servo/AlarmDlg.cpp
void CAlarmDlg::OnTimer(UINT_PTR nIDEvent)
{
   if (1 == nIDEvent) {
      KillTimer(1);
      InitRxWindow();
   }
}
void CAlarmDlg::OnCbnSelchangeComboDatetime()
=======
void CPageAlarm::OnCbnSelchangeComboDatetime()
>>>>>>> clh:SourceCode/Bond/Servo/PageAlarm.cpp
{
   CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_DATETIME);
   int nIndex = pComboBox->GetCurSel();