| | |
| | | m_slotTable.SetTitleHeight(m_slotTableTitleHeight); |
| | | m_slotTable.SetLineColor(lineColor); |
| | | m_slotTable.SetHeaderBgColor(headerBgColor); |
| | | LOGI("[Graph1] SlotTable create ret=%d hwnd=%p err=%lu rc=(%d,%d)-(%d,%d)", |
| | | created, m_slotTable.GetSafeHwnd(), GetLastError(), |
| | | rcTable.left, rcTable.top, rcTable.right, rcTable.bottom); |
| | | (void)created; |
| | | } |
| | | else { |
| | | m_slotTable.MoveWindow(&rcTable); |
| | |
| | | m_slotTable.SetTitleHeight(m_slotTableTitleHeight); |
| | | m_slotTable.SetLineColor(lineColor); |
| | | m_slotTable.SetHeaderBgColor(headerBgColor); |
| | | LOGI("[Graph1] SlotTable moved rc=(%d,%d)-(%d,%d)", rcTable.left, rcTable.top, rcTable.right, rcTable.bottom); |
| | | } |
| | | |
| | | // 如果超出可视区域,强制移到左上角作为兜底 |
| | | CRect rcWnd; |
| | | m_slotTable.GetWindowRect(&rcWnd); |
| | | ScreenToClient(&rcWnd); |
| | | LOGI("[Graph1] SlotTable wnd rc=(%d,%d)-(%d,%d) client=(%d,%d)", |
| | | rcWnd.left, rcWnd.top, rcWnd.right, rcWnd.bottom, rcClient.right, rcClient.bottom); |
| | | if (rcWnd.right <= 0 || rcWnd.bottom <= 0 || |
| | | rcWnd.left >= rcClient.right || rcWnd.top >= rcClient.bottom) { |
| | | CRect rcFallback(10, 10, 10 + cfgW, 10 + cfgH); |
| | | m_slotTable.MoveWindow(&rcFallback); |
| | | LOGI("[Graph1] SlotTable fallback rc=(%d,%d)-(%d,%d)", rcFallback.left, rcFallback.top, rcFallback.right, rcFallback.bottom); |
| | | } |
| | | m_slotTable.SetWindowPos(&CWnd::wndTop, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW); |
| | | |
| | |
| | | |
| | | std::vector<CSlotTableCtrl::Row> rows; |
| | | if (pEquipment != nullptr) { |
| | | LOGI("[Graph1] UpdateSlotTable eq=%s(%p)", pEquipment->getName().c_str(), pEquipment); |
| | | for (int i = 0; i < SLOT_MAX && rows.size() < 8; ++i) { |
| | | SERVO::CSlot* pSlot = pEquipment->getSlot(i); |
| | | if (pSlot == nullptr || !pSlot->isEnable()) continue; |
| | |
| | | rows.push_back(row); |
| | | } |
| | | } |
| | | LOGI("[Graph1] SlotTable rows=%zu", rows.size()); |
| | | |
| | | m_slotTableRowCount = static_cast<int>(rows.size()); |
| | | if (m_slotTableRowCount < 1) m_slotTableRowCount = 1; |
| | |
| | | if (auto* pGraphWnd = GetDlgItem(IDC_SERVO_GRAPH1)) { |
| | | pGraphWnd->ModifyStyle(0, WS_CLIPSIBLINGS); |
| | | } |
| | | std::string iniPath = GetConfigPath(); |
| | | CString strPath; |
| | | strPath.Format(_T("%s\\res\\Servo001.bmp"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir); |
| | | auto resolveGraphImagePath = [&](const char* iniKey, const char* defaultName) -> CString { |
| | | char value[MAX_PATH] = { 0 }; |
| | | GetPrivateProfileStringA("Graph1", iniKey, defaultName, value, (DWORD)sizeof(value), iniPath.c_str()); |
| | | std::string file = value; |
| | | auto trim = [](std::string& s) { |
| | | while (!s.empty() && (s.front() == ' ' || s.front() == '\t' || s.front() == '\r' || s.front() == '\n')) s.erase(s.begin()); |
| | | while (!s.empty() && (s.back() == ' ' || s.back() == '\t' || s.back() == '\r' || s.back() == '\n')) s.pop_back(); |
| | | }; |
| | | trim(file); |
| | | if (file.empty()) file = defaultName; |
| | | |
| | | CString path; |
| | | const bool isAbs = (file.size() > 1 && file[1] == ':') || (!file.empty() && (file[0] == '\\' || file[0] == '/')); |
| | | if (isAbs) { |
| | | path = file.c_str(); |
| | | } |
| | | else if (file.rfind("res\\", 0) == 0 || file.rfind("res/", 0) == 0) { |
| | | path.Format(_T("%s\\%s"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, CString(file.c_str())); |
| | | } |
| | | else { |
| | | path.Format(_T("%s\\res\\%s"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, CString(file.c_str())); |
| | | } |
| | | |
| | | DWORD attr = GetFileAttributes(path); |
| | | if (attr == INVALID_FILE_ATTRIBUTES || (attr & FILE_ATTRIBUTE_DIRECTORY)) { |
| | | path.Format(_T("%s\\res\\%s"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir, CString(defaultName)); |
| | | } |
| | | return path; |
| | | }; |
| | | |
| | | strPath = resolveGraphImagePath("BackgroundBmp", "Servo001.bmp"); |
| | | m_pGraph->AddImage(1, (LPTSTR)(LPCTSTR)strPath, 0, 0); |
| | | |
| | | strPath.Format(_T("%s\\res\\Robot001.bmp"), (LPTSTR)(LPCTSTR)theApp.m_strAppDir); |
| | |
| | | // 添加指示器 |
| | | // Bonder |
| | | // size config |
| | | std::string iniPath = GetConfigPath(); |
| | | int boxSize = GetPrivateProfileIntA("Graph1", "BoxSize", 56, iniPath.c_str()); |
| | | if (boxSize < 40) boxSize = 40; |
| | | if (boxSize > 80) boxSize = 80; |