| | |
| | | ON_WM_SIZE() |
| | | ON_WM_ACTIVATE() |
| | | ON_BN_CLICKED(IDC_BUTTON_ABORT_TASK, &CRobotTaskDlg::OnBnClickedAbortTask) |
| | | ON_BN_CLICKED(IDC_BUTTON_RESTORE, &CRobotTaskDlg::OnBnClickedRestore) |
| | | END_MESSAGE_MAP() |
| | | |
| | | |
| | |
| | | |
| | | if (m_btnAbortTask.m_hWnd) { |
| | | m_btnAbortTask.ShowWindow(m_pRobotTask ? SW_SHOW : SW_HIDE); |
| | | } |
| | | if (m_btnRestore.m_hWnd) { |
| | | m_btnRestore.ShowWindow(m_pRobotTask ? SW_SHOW : SW_HIDE); |
| | | } |
| | | |
| | | if (m_pRobotTask != nullptr) { |
| | |
| | | CDialogEx::OnInitDialog(); |
| | | |
| | | // TODO: 在此添加额外的初始化 |
| | | // 创建“停止任务”按钮 |
| | | // 创建“停止任务”按钮和“撤回”按钮 |
| | | m_btnAbortTask.Create(_T("停止任务"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(0, 0, 100, 30), this, IDC_BUTTON_ABORT_TASK); |
| | | m_btnRestore.Create(_T("撤回"), WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, CRect(0, 0, 100, 30), this, IDC_BUTTON_RESTORE); |
| | | |
| | | // 动态按钮创建后设置字体 |
| | | if (m_fontButton.GetSafeHandle() == nullptr) { |
| | | m_fontButton.CreatePointFont(110, _T("微软雅黑")); // 或 "Segoe UI" |
| | | } |
| | | m_btnAbortTask.SetFont(&m_fontButton); |
| | | m_btnRestore.SetFont(&m_fontButton); |
| | | |
| | | // 设置 LABEL 控件的字体 |
| | | if (m_fontDetail.GetSafeHandle() == nullptr) { |
| | |
| | | } |
| | | |
| | | // 设置“停止任务”按钮位置(右下角) |
| | | if (m_btnAbortTask.m_hWnd != nullptr) { |
| | | const int nBtnWidth = 100; |
| | | const int nBtnHeight = 28; |
| | | const int nMargin = 12; |
| | | const int nMargin2 = 8; |
| | | const int x = rcClient.right - nBtnWidth - nMargin; |
| | | int y = rcClient.bottom - nMargin; |
| | | if (m_btnAbortTask.m_hWnd != nullptr) { |
| | | m_btnAbortTask.MoveWindow(x, y - nBtnHeight, nBtnWidth, nBtnHeight); |
| | | y -= nBtnHeight; |
| | | y -= nMargin2; |
| | | } |
| | | |
| | | const int nPosX = rcClient.right - nBtnWidth - nMargin; |
| | | const int nPosY = rcClient.bottom - nBtnHeight - nMargin; |
| | | |
| | | m_btnAbortTask.MoveWindow(nPosX, nPosY, nBtnWidth, nBtnHeight); |
| | | // 设置“停止任务”按钮位置(右下角) |
| | | if (m_btnRestore.m_hWnd != nullptr) { |
| | | m_btnRestore.MoveWindow(x, y - nBtnHeight, nBtnWidth, nBtnHeight); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | theApp.m_model.getMaster().abortCurrentTask(); |
| | | } |
| | | |
| | | void CRobotTaskDlg::OnBnClickedRestore() |
| | | { |
| | | int ret = AfxMessageBox(_T("物料将会被搬运回原位置,确认要回撤当前任务吗?除非发生了异常,否则请不要回撤任务!"), MB_OKCANCEL | MB_ICONEXCLAMATION); |
| | | if (ret != IDOK) { |
| | | return; |
| | | } |
| | | |
| | | theApp.m_model.getMaster().restoreCurrentTask(); |
| | | } |