void CMainFrame::InitViews() { // { CTreeItem t; CTreeItem tail; //如何插入根节点 { t = m_wndTreeView.InsertItem ( NULL, TVI_ROOT, TVI_LAST); t.SetText("root"); } //如何插入子节点 { tail = t.AddTail("child", 0); } //如同线性列表,head是头,tail是尾;如同std::list, push_front, push_back { tail.AddHead("head0", 0); tail.AddHead("head1", 0); tail.AddTail("tail0", 0); tail.AddTail("tail1", 0); } } // Create list view columns m_wndListView.InsertColumn(0, _T("Name"), LVCFMT_LEFT, 200, 0); m_wndListView.InsertColumn(1, _T("Size"), LVCFMT_RIGHT, 100, 1); m_wndListView.InsertColumn(2, _T("Type"), LVCFMT_LEFT, 100, 2); }
void CMainFrame::_createTreeView() { // m_tvCtrl.Create(m_hSplit, rcDefault, NULL, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | TVS_HASLINES | TVS_LINESATROOT | TVS_HASBUTTONS | TVS_SHOWSELALWAYS, WS_EX_CLIENTEDGE); m_hSplit.SetSplitterPane(SPLIT_PANE_TOP, m_tvCtrl); CTreeItem t; CTreeItem tail; //如何插入根节点 { t = m_tvCtrl.InsertItem ( NULL, TVI_ROOT, TVI_LAST); t.SetText("data"); } //如何插入子节点 { HANDLE hFind = INVALID_HANDLE_VALUE; std::string dataPath = Buddha::FileSystem::getInstancePtr()->getDataDirectory(); std::stack<std::string> pathes; std::stack<CTreeItem> items; pathes.push(dataPath); items.push(t); WIN32_FIND_DATA ffd; while(!pathes.empty()) { t = items.top(); items.pop(); dataPath = pathes.top(); pathes.pop(); hFind = FindFirstFile((dataPath + + "/*").c_str(), &ffd); do { std::string name = ffd.cFileName; if(name != "." && name != ".." ) { if (ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { pathes.push(dataPath + "/" + ffd.cFileName); tail = t.AddTail(ffd.cFileName, 0); items.push(tail); } else { std::string name = Buddha::FileSystem::getInstancePtr()->getFileExtension(ffd.cFileName); std::transform(name.begin(), name.end(), name.begin(), std::tolower); if (name == "mz" || name == "mesh" || name == "entity" || name == "group" || name == "subentity") { t.AddTail(ffd.cFileName, 0); } } } }while (FindNextFile(hFind, &ffd) != 0); } } m_uPane.SetClient(m_tvCtrl); }
void CNdasDevicePropGeneralPage::_UpdateLogDeviceData( ndas::UnitDevicePtr pUnitDevice) { NDAS_LOGICALDEVICE_ID logDeviceId = pUnitDevice->GetLogicalDeviceId(); ndas::LogicalDevicePtr pLogDevice; if (!ndas::FindLogicalDevice(pLogDevice, logDeviceId)) { m_wndLogDeviceTree.DeleteAllItems(); m_wndLogDeviceTree.ShowWindow(SW_HIDE); m_wndLogDeviceNA.ShowWindow(SW_SHOW); return; } else { m_wndLogDeviceTree.ShowWindow(SW_SHOW); m_wndLogDeviceNA.ShowWindow(SW_HIDE); } // // TODO: To handle errors // (void) pLogDevice->UpdateInfo(); (void) pLogDevice->UpdateStatus(); NDAS_LOGICALDEVICE_TYPE logDevType = pLogDevice->GetType(); NDAS_LOGICALDEVICE_STATUS logDevStatus = pLogDevice->GetStatus(); CString strStatus = pLogicalDeviceStatusString( logDevStatus, pLogDevice->GetNdasLogicalUnitError(), pLogDevice->GetMountedAccess()); CString strType = pLogicalDeviceTypeString(logDevType); const NDASUSER_LOGICALDEVICE_INFORMATION* pLogDeviceInfo = pLogDevice->GetLogicalDeviceInfo(); CString strCapacity = pBlockCapacityString( pLogDeviceInfo->SubType.LogicalDiskInformation.Blocks); CString strRootNode; strRootNode.Format(_T("%s (%s) - %s"), strType, strCapacity, strStatus); m_wndLogDeviceTree.DeleteAllItems(); CTreeItem rootItem = m_wndLogDeviceTree.InsertItem( strRootNode, TVI_ROOT, TVI_LAST); CString strNodeText; CString strLocationCaption; // strLocationCaption.LoadString(IDS_LOGDEV_LOCATION); // strNodeText.Format(_T("%s %s"), strLocationCaption, strLocation); // strNodeText.Format(_T("%s"), strLocation); // CTreeItem tiLocation = tiRoot.AddTail(strNodeText, 0); // tiLocation.Expand(); CTreeItem memberItem = rootItem; // .AddTail(_T("Members"), 0); // // Encryption information // { if (NULL != pLogDeviceInfo && IS_NDAS_LOGICALDEVICE_TYPE_DISK(pLogDevice->GetType()) && 0 != pLogDeviceInfo->SubType.LogicalDiskInformation.ContentEncrypt.Revision && NDAS_CONTENT_ENCRYPT_TYPE_NONE != pLogDeviceInfo->SubType.LogicalDiskInformation.ContentEncrypt.Type) { CString strNode = pNdasLogicalDiskEncryptString(pLogDeviceInfo); memberItem.AddTail(strNode, 0); // m_wndLogDeviceTree.InsertItem(strNode, TVI_ROOT, TVI_LAST); } } for (DWORD i = 0; i < pLogDevice->GetUnitDeviceInfoCount(); ++i) { CString strNode; ndas::LogicalDevice::UNITDEVICE_INFO ui = pLogDevice->GetUnitDeviceInfo(i); ndas::DevicePtr pMemberDevice; if (!ndas::FindDeviceByNdasId(pMemberDevice, ui.DeviceId)) { CString strMissingDeviceId = pDelimitedDeviceIdString2(CString(ui.DeviceId), m_chConcealed); if (0 == ui.UnitNo) { // "[%1!d!] %2!s! (Not registered)" strNode.FormatMessage( IDS_LOGICALDEVICE_ENTRY_MISSING_0_FMT, ui.Index + 1, strMissingDeviceId); } else { // "[%1!d!] %2!s!:%3!d! (Not registered)" strNode.FormatMessage( IDS_LOGICALDEVICE_ENTRY_MISSING_0_FMT, ui.Index + 1, strMissingDeviceId, ui.UnitNo + 1); } memberItem.AddTail(strNode, 0); continue; } ndas::UnitDevicePtr pMemberUnitDevice; if (!pMemberDevice->FindUnitDevice(pMemberUnitDevice, ui.UnitNo)) { if (0 == ui.UnitNo) { // "[%1!d!] Unavailable (%2!s!)" strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_UNAVAILABLE_0_FMT, ui.Index + 1, pMemberDevice->GetName()); } else { // "[%1!d!] Unavailable (%2!s!:%3!d!)" strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_UNAVAILABLE_FMT, ui.Index + 1, pMemberDevice->GetName(), ui.UnitNo + 1); } memberItem.AddTail(strNode, 0); continue; } if (0 == ui.UnitNo) { // "[%1!d!] %2!s!" strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_0_FMT, ui.Index + 1, pMemberDevice->GetName()); } else { // "[%1!d!] %2!s!:%3!d! " strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_FMT, ui.Index + 1, pMemberDevice->GetName(), ui.UnitNo + 1); } memberItem.AddTail(strNode, 0); } memberItem.Expand(); rootItem.Expand(); }
void CGeneralPage::GenerateLogDevTree( ndas::UnitDevice* pUnitDevice) { CString strRootNode; NDAS_LOGICALDEVICE_ID logDevId = pUnitDevice->GetLogicalDeviceId(); ndas::LogicalDevice* pLogDev = _pLogDevColl->FindLogicalDevice(logDevId); if (NULL == pLogDev) { strRootNode.LoadString(IDS_LOGDEV_INFO_UNAVAILABLE); CTreeItem tiRoot = m_tvLogDev.InsertItem( strRootNode, TVI_ROOT, TVI_LAST); return; } // // TODO: To handle errors // (VOID) pLogDev->UpdateInfo(); (VOID) pLogDev->UpdateStatus(); NDAS_LOGICALDEVICE_TYPE logDevType = pLogDev->GetType(); NDAS_LOGICALDEVICE_STATUS logDevStatus = pLogDev->GetStatus(); CString strType, strLocation, strStatus; pLogicalDeviceStatusString( strStatus, logDevStatus, pLogDev->GetMountedAccess()); pLogicalDeviceTypeString(strType, logDevType); // Slot %1!d!, Target ID %2!d!, LUN %3!d! //strLocation.FormatMessage( // IDS_LOGDEV_LOCATION_FMT, // pLogDev->GetLogicalDeviceId()); strRootNode.Format(_T("%s - %s"), strType, strStatus); m_tvLogDev.DeleteAllItems(); CTreeItem tiRoot = m_tvLogDev.InsertItem( strRootNode, TVI_ROOT, TVI_LAST); CString strNodeText; CString strLocationCaption; // strLocationCaption.LoadString(IDS_LOGDEV_LOCATION); // strNodeText.Format(_T("%s %s"), strLocationCaption, strLocation); strNodeText.Format(_T("%s"), strLocation); // CTreeItem tiLocation = tiRoot.AddTail(strNodeText, 0); // tiLocation.Expand(); CTreeItem tiMember = tiRoot; // .AddTail(_T("Members"), 0); for (DWORD i = 0; i < pLogDev->GetUnitDeviceInfoCount(); ++i) { CString strNode; ndas::LogicalDevice::UNITDEVICE_INFO ui = pLogDev->GetUnitDeviceInfo(i); ndas::Device* pMemberDevice = _pDeviceColl->FindDevice(ui.DeviceId); if (NULL == pMemberDevice) { // "[%1!d!] Missing Entry" strNode.FormatMessage( IDS_LOGICALDEVICE_ENTRY_MISSING_FMT, ui.Index + 1); tiMember.AddTail(strNode, 0); continue; } ndas::UnitDevice* pMemberUnitDevice = pMemberDevice->FindUnitDevice(ui.UnitNo); if (NULL == pMemberUnitDevice) { // "[%1!d!] Unavailable (%2!s!:%3!d!)" strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_UNAVAILABLE_FMT, ui.Index + 1, pMemberDevice->GetName(), ui.UnitNo); tiMember.AddTail(strNode, 0); pMemberDevice->Release(); continue; } // "[%1!d!] %2!s!:%3!d! " strNode.FormatMessage(IDS_LOGICALDEVICE_ENTRY_FMT, ui.Index + 1, pMemberDevice->GetName(), ui.UnitNo); tiMember.AddTail(strNode, 0); pMemberUnitDevice->Release(); pMemberDevice->Release(); } tiMember.Expand(); tiRoot.Expand(); pLogDev->Release(); }