| | |
| | | CCjPage2::CCjPage2(CWnd* pParent /*=nullptr*/) |
| | | : CCjPageBase(IDD_CJ_PAGE2, pParent) |
| | | { |
| | | |
| | | m_nSelRadioId = 0; |
| | | } |
| | | |
| | | CCjPage2::~CCjPage2() |
| | |
| | | ON_BN_CLICKED(IDC_RADIO2, &CCjPage2::OnBnClickedRadio2) |
| | | ON_BN_CLICKED(IDC_RADIO3, &CCjPage2::OnBnClickedRadio3) |
| | | ON_BN_CLICKED(IDC_RADIO4, &CCjPage2::OnBnClickedRadio4) |
| | | ON_NOTIFY(CSGN_SEL_CHANGED, IDC_GRID1, &CCjPage2::OnGridSelChanged) |
| | | ON_NOTIFY(CSGN_MAT_CHANGED, IDC_GRID1, &CCjPage2::OnGridMatChanged) |
| | | END_MESSAGE_MAP() |
| | | |
| | | |
| | |
| | | m_grid.SubclassDlgItem(IDC_GRID1, this); |
| | | m_grid.InitGrid(4, 8); |
| | | m_grid.SetColumnWidths(100, 220); |
| | | m_grid.SetRowHeight(28); |
| | | m_grid.SetHeaderHeight(32); |
| | | m_grid.SetRowHeight(32); |
| | | m_grid.SetHeaderHeight(36); |
| | | m_grid.EnableColumnResize(FALSE); // 禁止拖动列宽 |
| | | m_grid.SetShowMaterialToggle(TRUE); |
| | | m_grid.DisableSystemScrollbars(); |
| | | m_grid.ResizeWindowToFitAll(TRUE); // TRUE=包含非客户区(边框、标题栏) |
| | | m_grid.SetNoScrollbarsMode(TRUE); // 彻底禁用滚动条 |
| | | m_grid.FitWindowToContentNoScroll(TRUE); // 窗口尺寸刚好容纳全部内容(不出现滚动条) |
| | | |
| | | m_grid.SetPortInfo(0, _T("Port 1"), _T("")); |
| | | m_grid.SetPortInfo(1, _T("Port 2"), _T("")); |
| | | m_grid.SetPortInfo(2, _T("Port 3"), _T("")); |
| | | m_grid.SetPortInfo(3, _T("Port 4"), _T("")); |
| | | |
| | | |
| | | // 测试数据 |
| | | char szBuffer[256]; |
| | | for (int port = 0; port < 4; port++) { |
| | | for (int slot = 0; slot < 8; slot++) { |
| | | sprintf_s(szBuffer, 256, "Gls%04d%04d", port + 1, slot + 1); |
| | | m_grid.SetSlotGlass(port, slot, TRUE, szBuffer, CCarrierSlotGrid::MAT_G1); |
| | | } |
| | | } |
| | | |
| | | UpdatePjData(); |
| | | |
| | |
| | | |
| | | // 让控件窗口尺寸自动匹配当前列宽/行数(不出现滚动条) |
| | | if (::IsWindow(m_grid.m_hWnd)) { |
| | | CSize best = m_grid.CalcBestWindowSize(TRUE); // 计算到含非客户区的最终窗口大小 |
| | | CSize best = m_grid.CalcBestWindowSize(TRUE, -1, 2, 2); |
| | | pItem->MoveWindow(rcItem.left, rcItem.top, best.cx, best.cy); |
| | | pItem->Invalidate(); |
| | | } |
| | | } |
| | | |
| | | void CCjPage2::OnApply() |
| | | int CCjPage2::OnApply() |
| | | { |
| | | //SERVO::CProcessJob* |
| | | if (m_pContext == nullptr) return; |
| | | if (m_pContext == nullptr) return -1; |
| | | PJWarp* pPjWarp = (PJWarp*)m_pContext; |
| | | SERVO::CProcessJob* pProcessJob = (SERVO::CProcessJob*)pPjWarp->pj; |
| | | |
| | |
| | | char szBuffer[256]; |
| | | GetDlgItemText(IDC_EDIT_PJ_ID, szBuffer, 256); |
| | | for (auto item : m_pjWarps) { |
| | | if (item.pj != m_pContext) { |
| | | if (item.pj != pProcessJob) { |
| | | SERVO::CProcessJob* temp = (SERVO::CProcessJob*)item.pj; |
| | | if (temp->id().compare(std::string(szBuffer)) == 0) { |
| | | bOkName = FALSE; |
| | |
| | | } |
| | | if (!bOkName) { |
| | | AfxMessageBox("不能使用和其它Process Job相同的ID"); |
| | | return; |
| | | return -1; |
| | | } |
| | | |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | // 更新Port |
| | | int port = -1; |
| | | static int ids[] = { IDC_RADIO1, IDC_RADIO2, IDC_RADIO3, IDC_RADIO4 }; |
| | | for (int i = 0; i < 4; i++) { |
| | | int state = ((CButton*)GetDlgItem(ids[i]))->GetCheck(); |
| | | if (state == BST_CHECKED) port = i; |
| | | } |
| | | pPjWarp->port = port; |
| | | |
| | | if (pPjWarp->port != -1) { |
| | | for (int i = 0; i < 8; i++) { |
| | | pPjWarp->checkSlot[i] = m_grid.GetSlotChecked(pPjWarp->port, i); |
| | | pPjWarp->material[i] = m_grid.GetSlotMaterialType(pPjWarp->port, i); |
| | | } |
| | | } |
| | | |
| | | |
| | | ContentChanged(1); |
| | | return 0; |
| | | } |
| | | |
| | | void CCjPage2::UpdatePjData() |
| | | { |
| | | if (m_pContext == nullptr) return; |
| | | |
| | | m_bContentChangedLock = TRUE; |
| | | |
| | | CComboBox* pComboBox = (CComboBox*)GetDlgItem(IDC_COMBO_RECIPE); |
| | |
| | | pComboBox->AddString(CString(recipe.c_str())); |
| | | } |
| | | |
| | | if (m_pContext) { |
| | | PJWarp* pPjWarp = (PJWarp*)m_pContext; |
| | | SERVO::CProcessJob* pProcessJob = (SERVO::CProcessJob*)pPjWarp->pj; |
| | | SetDlgItemText(IDC_EDIT_PJ_ID, pProcessJob->id().c_str()); |
| | | int idx = pComboBox->FindStringExact(-1, pProcessJob->recipeSpec().c_str()); |
| | | if (idx != CB_ERR) pComboBox->SetCurSel(idx); |
| | | |
| | | // ComboBox |
| | | PJWarp* pPjWarp = (PJWarp*)m_pContext; |
| | | SERVO::CProcessJob* pProcessJob = (SERVO::CProcessJob*)pPjWarp->pj; |
| | | SetDlgItemText(IDC_EDIT_PJ_ID, pProcessJob->id().c_str()); |
| | | int idx = pComboBox->FindStringExact(-1, pProcessJob->recipeSpec().c_str()); |
| | | if (idx != CB_ERR) pComboBox->SetCurSel(idx); |
| | | |
| | | |
| | | // 4个checkbox |
| | | static int ids[] = { IDC_RADIO1, IDC_RADIO2, IDC_RADIO3, IDC_RADIO4}; |
| | | static char* pszUsed[] = { "Port1(已占用)", "Port2(已占用)", "Port3(已占用)", "Port4(已占用)" }; |
| | | static char* pszUnUsed[] = { "Port1(可用)", "Port2(可用)", "Port3(可用)", "Port4(可用)" }; |
| | | |
| | | int portIndex = -1; |
| | | bool enable[] = {true, true, true, true}; |
| | | bool checked[] = { false, false, false, false }; |
| | | for (auto item : m_pjWarps) { |
| | | if (0 <= item.port && item.port <= 4 && item.pj != ((PJWarp*)m_pContext)->pj) { |
| | | enable[item.port] = false; |
| | | } |
| | | } |
| | | if (0 <= ((PJWarp*)m_pContext)->port && ((PJWarp*)m_pContext)->port <= 3) { |
| | | checked[((PJWarp*)m_pContext)->port] = true; |
| | | portIndex = ((PJWarp*)m_pContext)->port; |
| | | m_nSelRadioId = ids[((PJWarp*)m_pContext)->port]; |
| | | } |
| | | |
| | | // 示例:设置Port信息、锁列、填充Glass |
| | | /* |
| | | m_grid.SetPortInfo(0, _T("Port 1"), _T("")); |
| | | m_grid.SetPortInfo(1, _T("Port 2"), _T("")); |
| | | m_grid.SetPortInfo(2, _T("Port 3"), _T("Carrier C")); |
| | | m_grid.SetPortInfo(3, _T("Port 4"), _T("Carrier D")); |
| | | m_grid.SetPortAllocated(2, TRUE, _T("ProcessJob 1")); |
| | | m_grid.SetSlotGlass(0, 0, TRUE, _T("A00123"), CCarrierSlotGrid::MAT_G1); |
| | | m_grid.SetSlotGlass(0, 1, TRUE, _T("A00124"), CCarrierSlotGrid::MAT_G1); |
| | | */ |
| | | for (int i = 0; i < 4; i++) { |
| | | CButton* pButton = (CButton*)GetDlgItem(ids[i]); |
| | | pButton->SetCheck(checked[i] ? BST_CHECKED : BST_UNCHECKED); |
| | | pButton->SetWindowText(enable[i] ? pszUnUsed[i] : pszUsed[i]); |
| | | pButton->EnableWindow(enable[i]); |
| | | |
| | | m_grid.SetPortAllocated(i, !checked[i], _T("")); |
| | | } |
| | | |
| | | |
| | | // 设置勾选数据 |
| | | if (portIndex != -1) { |
| | | for (int i = 0; i < 8; i++) { |
| | | m_grid.SetSlotChecked(portIndex, i, ((PJWarp*)m_pContext)->checkSlot[i]); |
| | | m_grid.SetSlotMaterialType(portIndex, i, ((PJWarp*)m_pContext)->material[i]); |
| | | } |
| | | } |
| | | |
| | | m_bContentChangedLock = FALSE; |
| | | } |
| | |
| | | |
| | | void CCjPage2::OnBnClickedRadio1() |
| | | { |
| | | m_grid.SetPortAllocated(0, FALSE, _T("")); |
| | | m_grid.SetPortAllocated(1, TRUE, _T("")); |
| | | m_grid.SetPortAllocated(2, TRUE, _T("")); |
| | | m_grid.SetPortAllocated(3, TRUE, _T("")); |
| | | BOOL lock[] = {TRUE, TRUE, TRUE, TRUE}; |
| | | if (IDC_RADIO1 == m_nSelRadioId) { |
| | | CheckRadioButton(IDC_RADIO1, IDC_RADIO4, 0); |
| | | m_nSelRadioId = 0; |
| | | } |
| | | else { |
| | | CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO1); |
| | | m_nSelRadioId = IDC_RADIO1; |
| | | lock[0] = FALSE; |
| | | } |
| | | |
| | | for (int i = 0; i < 4; i++) { |
| | | m_grid.SetPortAllocated(i, lock[i], _T("")); |
| | | } |
| | | |
| | | ContentChanged(0); |
| | | } |
| | | |
| | | void CCjPage2::OnBnClickedRadio2() |
| | | { |
| | | m_grid.SetPortAllocated(0, TRUE, _T("")); |
| | | m_grid.SetPortAllocated(1, FALSE, _T("")); |
| | | m_grid.SetPortAllocated(2, TRUE, _T("")); |
| | | m_grid.SetPortAllocated(3, TRUE, _T("")); |
| | | BOOL lock[] = { TRUE, TRUE, TRUE, TRUE }; |
| | | if (IDC_RADIO2 == m_nSelRadioId) { |
| | | CheckRadioButton(IDC_RADIO1, IDC_RADIO4, 0); |
| | | m_nSelRadioId = 0; |
| | | } |
| | | else { |
| | | CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO2); |
| | | m_nSelRadioId = IDC_RADIO2; |
| | | lock[1] = FALSE; |
| | | } |
| | | |
| | | for (int i = 0; i < 4; i++) { |
| | | m_grid.SetPortAllocated(i, lock[i], _T("")); |
| | | } |
| | | |
| | | ContentChanged(0); |
| | | } |
| | | |
| | | void CCjPage2::OnBnClickedRadio3() |
| | | { |
| | | m_grid.SetPortAllocated(0, TRUE, _T("")); |
| | | m_grid.SetPortAllocated(1, TRUE, _T("")); |
| | | m_grid.SetPortAllocated(2, FALSE, _T("")); |
| | | m_grid.SetPortAllocated(3, TRUE, _T("")); |
| | | BOOL lock[] = { TRUE, TRUE, TRUE, TRUE }; |
| | | if (IDC_RADIO3 == m_nSelRadioId) { |
| | | CheckRadioButton(IDC_RADIO1, IDC_RADIO4, 0); |
| | | m_nSelRadioId = 0; |
| | | } |
| | | else { |
| | | CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO3); |
| | | m_nSelRadioId = IDC_RADIO3; |
| | | lock[2] = FALSE; |
| | | } |
| | | |
| | | for (int i = 0; i < 4; i++) { |
| | | m_grid.SetPortAllocated(i, lock[i], _T("")); |
| | | } |
| | | |
| | | ContentChanged(0); |
| | | } |
| | | |
| | | void CCjPage2::OnBnClickedRadio4() |
| | | { |
| | | m_grid.SetPortAllocated(0, TRUE, _T("")); |
| | | m_grid.SetPortAllocated(1, TRUE, _T("")); |
| | | m_grid.SetPortAllocated(2, TRUE, _T("")); |
| | | m_grid.SetPortAllocated(3, FALSE, _T("")); |
| | | BOOL lock[] = { TRUE, TRUE, TRUE, TRUE }; |
| | | if (IDC_RADIO4 == m_nSelRadioId) { |
| | | CheckRadioButton(IDC_RADIO1, IDC_RADIO4, 0); |
| | | m_nSelRadioId = 0; |
| | | } |
| | | else { |
| | | CheckRadioButton(IDC_RADIO1, IDC_RADIO4, IDC_RADIO4); |
| | | m_nSelRadioId = IDC_RADIO4; |
| | | lock[3] = FALSE; |
| | | } |
| | | |
| | | for (int i = 0; i < 4; i++) { |
| | | m_grid.SetPortAllocated(i, lock[i], _T("")); |
| | | } |
| | | |
| | | ContentChanged(0); |
| | | } |
| | | |
| | | void CCjPage2::OnGridSelChanged(NMHDR* pNMHDR, LRESULT* pResult) |
| | | { |
| | | auto* nm = reinterpret_cast<CSG_SEL_CHANGE*>(pNMHDR); |
| | | const int port = nm->port; |
| | | const int slot = nm->slot; |
| | | const BOOL chk = nm->checked; |
| | | |
| | | // 这里写你的业务逻辑 |
| | | // 例如:更新状态栏 / 同步其它控件 / 统计数量 |
| | | ContentChanged(0); |
| | | |
| | | /* |
| | | if (m_pContext != nullptr) { |
| | | PJWarp* pjWarp = (PJWarp*)m_pContext; |
| | | for (int i = 0; i < 8; i++) { |
| | | pjWarp->checkSlot[i] = m_grid.GetSlotChecked(port, i); |
| | | pjWarp->material[i] = m_grid.GetSlotMaterialType(port, i); |
| | | } |
| | | } |
| | | */ |
| | | |
| | | *pResult = 0; |
| | | } |
| | | |
| | | void CCjPage2::OnGridMatChanged(NMHDR* pNMHDR, LRESULT* pResult) |
| | | { |
| | | auto* nm = reinterpret_cast<CSG_MAT_CHANGE*>(pNMHDR); |
| | | const int port = nm->port; |
| | | const int slot = nm->slot; |
| | | const int mat = nm->material; // 1/2 |
| | | |
| | | // 例如:即刻刷新右侧预览/记录日志等 |
| | | ContentChanged(0); |
| | | |
| | | /* |
| | | if (m_pContext != nullptr) { |
| | | PJWarp* pjWarp = (PJWarp*)m_pContext; |
| | | for (int i = 0; i < 8; i++) { |
| | | pjWarp->checkSlot[i] = m_grid.GetSlotChecked(port, i); |
| | | pjWarp->material[i] = m_grid.GetSlotMaterialType(port, i); |
| | | } |
| | | } |
| | | */ |
| | | |
| | | *pResult = 0; |
| | | } |