HTREEITEM CGrannyListView::InsertModelAOS(CTreeCtrl& tree, HTREEITEM htRoot, Uint32 id, cGrannyModelAOS *model)
{
	const UINT nMask = TVIF_TEXT | TVIF_PARAM;

	if (!model) return NULL;

	CString strText;
	strText.Format("%04d %s", GETID(id), model->desc.c_str());

	HTREEITEM htChar  = tree.InsertItem(nMask, strText, 0,0,0,0, SETCHAR(id), htRoot, 0);
	HTREEITEM htPart  = tree.InsertItem("part", htChar);
	//HTREEITEM htAnim  = tree.InsertItem("anim", htChar);
	HTREEITEM htEquip = tree.InsertItem("equip", htChar);

	std::map <int, cGrannyModelTD *> models = model->models;

	if (models.empty()) return htEquip;

	for (std::map<int, cGrannyModelTD*>::iterator i = models.begin(); i != models.end(); i++) {
		cGrannyModelTD *td = i->second;
		if (!td) continue;

		UINT id2 = 0xC000 | id<< 4 | i->first;
		strText.Format("%2d %s", i->first, cGrannyLoader::GetAosBodyName(i->first).c_str());
		HTREEITEM htPart2 = tree.InsertItem(nMask, strText, 0,0,0,0, SETCHAR(id2), htPart, 0);
		strText.Format("file: %s", td->m_filename.c_str());
		tree.InsertItem(strText, htPart2);
	}

	if (!model->desc.empty()) {
		strText.Format("desc: %s", model->desc.c_str());
		tree.InsertItem(strText, htChar);
	}

	strText.Format("hand: %s", getHandName(model->hand).c_str());
	tree.InsertItem(strText, htChar);

	strText.Format("bone left: %d, right: %d", model->left_hand_bone, model->right_hand_bone);
	tree.InsertItem(strText, htChar);

#if 0
	// part animation is same.
	std::map<int, std::string>& anim_names = models.begin()->second->animation_names;
	for (std::map<int, std::string>::iterator i = anim_names.begin(); i != anim_names.end(); i++) {
		strText.Format("%s (%s,%d)", getFileName(i->second).c_str(), 
			AnimTypeData::GetAnimTypeName(i->first).c_str(),i->first);
		HTREEITEM htItem = tree.InsertItem(nMask, strText, 0,0,0,0, SETANIM(i->first), htAnim,0);
		strText.Format("file: %s%s", isFileExist(i->second) ? "":"(x) ",i->second.c_str());
		tree.InsertItem(strText, htItem);
	}
#endif

	return htEquip;
}
BOOL CParamSecondPage::OnInitDialog() 
{
	CPropertyPage::OnInitDialog();
	
	// TODO: Add extra initialization here
	CTreeCtrl *pOwner = (CTreeCtrl*)(CTreeCtrl*)GetDlgItem(IDC_ENEMY_TREE);
	
	HTREEITEM hTmp =pOwner->InsertItem(_T("µÐ·½ÅäÖÃ"), 0, 0);
	
	pOwner->InsertItem(_T("º½Ä¸"), 1, 1, hTmp);
	pOwner->InsertItem(_T("·É»ú"), 1, 1, hTmp);
	
	pOwner->Expand(hTmp, TVE_EXPAND);

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
HTREEITEM CGrannyListView::InsertModelTD(CTreeCtrl& tree, HTREEITEM htRoot, Uint32 id, cGrannyModelTD *model)
{
	const UINT nMask = TVIF_TEXT | TVIF_PARAM;

	if (!model) return NULL;

	CString strText;
	strText.Format("%04d %s", GETID(id), getFileName(model->m_filename).c_str());
	
	HTREEITEM htChar  = tree.InsertItem(nMask, strText, 0,0,0,0, SETCHAR(id), htRoot, 0);
	//HTREEITEM htAnim  = tree.InsertItem("anim", htChar);
	HTREEITEM htEquip = IsPlayerModelID(id) ? tree.InsertItem("equip", htChar) : NULL;
	
	strText.Format("file: %s%s", isFileExist(model->m_filename) ? "":"(x) ",model->m_filename.c_str());
	tree.InsertItem(strText, htChar);

	if (!model->desc.empty()) {
		strText.Format("desc: %s", model->desc.c_str());
		tree.InsertItem(strText, htChar);
	}

	strText.Format("hand: %s", getHandName(model->hand).c_str());
	tree.InsertItem(strText, htChar);

	strText.Format("bone left: %d, right: %d", model->left_hand_bone, model->right_hand_bone);
	tree.InsertItem(strText, htChar);

#if 0
	strText.Format("%s (default)", getFileName(model->defaultanimname).c_str());
	HTREEITEM htItem = tree.InsertItem(nMask, strText, 0,0,0,0, SETANIM(AnimTypeData::GetAnimType("default.animation")), htAnim, 0);
	strText.Format("file: %s%s", isFileExist(model->defaultanimname) ? "":"(x) ",model->defaultanimname.c_str());
	tree.InsertItem(strText, htItem);
	

	std::map<int, std::string>& anim_names = model->animation_names;
	for (std::map<int, std::string>::iterator i = anim_names.begin(); i != anim_names.end(); i++) {
		strText.Format("%s (%s,%d)", getFileName(i->second).c_str(), 
			AnimTypeData::GetAnimTypeName(i->first).c_str(),i->first);
		HTREEITEM htItem = tree.InsertItem(nMask, strText, 0,0,0,0, SETANIM(i->first), htAnim,0);
		strText.Format("file: %s%s", isFileExist(i->second) ? "":"(x) ",i->second.c_str());
		tree.InsertItem(strText, htItem);
	}
#endif

	return htEquip;
}
void CGrannyListView::InsertAnimation(CTreeCtrl &tree, HTREEITEM htRoot, cGrannyLoader *pLoader)
{
	ASSERT(pLoader);
	const GrannyAnimMap &mapAnim = pLoader->GetAnimsetMap();

	CString strText;

	LPCTSTR szNames[SEACRET-MALE+1] = { "Male", "Female", "Animals", "Mosters", "SeaCreatures" };

	for (int i = MALE; i <= SEACRET; i++)
	{
		int a = i - MALE;
		GrannyAnimMap::const_iterator iter = mapAnim.find(a);
		if (iter == mapAnim.end()) continue;

		HTREEITEM htAnim = tree.InsertItem(szNames[a], htRoot);
		cAnimSet *animset = iter->second;

		std::map<int, std::string>::iterator it = animset->anim_names.begin();
		for (; it != animset->anim_names.end(); it++)
		{
			int aid = it->first;
			strText.Format("%3d %s", aid, cGrannyLoader::GetAnimName(aid).c_str());
			HTREEITEM htItem = tree.InsertItem(nMask, strText, 0,0,0,0, SETANIM(aid), htAnim, 0);
			strText.Format("file: %s", it->second.c_str());
			tree.InsertItem(strText, htItem);
		}
	}

	extern TypeData AnimTypeInfo[];

	HTREEITEM htAlls = tree.InsertItem("Alls", htRoot);

	for (int i = 0; AnimTypeInfo[i].blockid != -1; i++)
	{
		int aid = AnimTypeInfo[i].blockid;
		strText.Format("%3d %s", aid, cGrannyLoader::GetAnimName(aid).c_str());
		HTREEITEM htItem = tree.InsertItem(nMask, strText, 0,0,0,0, SETANIM(aid), htAlls, 0);
	}

}
HTREEITEM CGrannyListView::InsertEquipItem(CTreeCtrl& tree, HTREEITEM htRoot, Uint32 id, cGrannyModelTD *model)
{
	const UINT nMask = TVIF_TEXT | TVIF_PARAM;

	if (!model) return NULL;

	CString strText;
	strText.Format("%04d %s", GETID(id), getFileName(model->m_filename).c_str());
	
	HTREEITEM htChar = tree.InsertItem(nMask, strText, 0,0,0,0, SETCHAR(id), htRoot, 0);

	strText.Format("file: %s%s", isFileExist(model->m_filename) ? "":"(x) ",model->m_filename.c_str());
	tree.InsertItem(strText, htChar);

	strText.Format("id: %d (0x%08x)", id, id);
	tree.InsertItem(strText, htChar);

	if (!model->desc.empty()) {
		strText.Format("desc: %s", model->desc.c_str());
		tree.InsertItem(strText, htChar);
	}

	strText.Format("hand: %s", getHandName(model->hand).c_str());
	tree.InsertItem(strText, htChar);

	strText.Format("bone left: %d, right: %d", model->left_hand_bone, model->right_hand_bone);
	tree.InsertItem(strText, htChar);

	return htChar;
}
HTREEITEM CFilterCacheTypesDlg::InsertItem(CTreeCtrl& Tree, HTREEITEM ParentItem, const TCHAR* pText, void* pData, int Image)
{
	TVINSERTSTRUCT tvInsert;
	tvInsert.hParent = ParentItem;
	tvInsert.hInsertAfter = TVI_SORT;
	tvInsert.item.mask = TVIF_TEXT | TVIF_PARAM | TVIF_IMAGE | TVIF_SELECTEDIMAGE;
	tvInsert.item.pszText = (TCHAR*) pText;
	tvInsert.item.lParam = (LPARAM) pData;
	tvInsert.item.iImage = Image;
	tvInsert.item.iSelectedImage = Image;

	return Tree.InsertItem(&tvInsert);
}
BOOL CDocSelectDlg::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	
	CTreeCtrl* pTree = (CTreeCtrl*)GetDlgItem(IDC_DOCLIST_TRE);
	assert(pTree);
	for (int i = 0; i < m_aDocNames.GetSize(); i++)
		pTree->InsertItem(m_aDocNames[i]);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Beispiel #8
0
//************************************************************************************
void CFavorit::FillTree (CTreeCtrl& wndTree, HTREEITEM htreeItemParent)
{
	for (POSITION pos = m_lstSubItems.GetHeadPosition (); pos != NULL;)
	{
		CFavorit* pFavorit = (CFavorit*) m_lstSubItems.GetNext (pos);
		ASSERT_VALID (pFavorit);

		HTREEITEM hTreeItem = wndTree.InsertItem (pFavorit->m_strName, 
			pFavorit->m_iIcon, pFavorit->m_iIcon, htreeItemParent);
		wndTree.SetItemData (hTreeItem, (DWORD_PTR) pFavorit);

		pFavorit->FillTree (wndTree, hTreeItem);
	}
}
Beispiel #9
0
void CDiagRunView::CreateTree_OnOpen(Node *node, HTREEITEM parent_item, CModelTree *pTreeView, CTreeCtrl& m_ctlTree)
{
	if (node->IsDeleted()) 
		return;
	else
	{
		int treecount = m_ctlTree.GetCount();
		pTreeView->m_Tree.TreeItem[treecount-1]=m_ctlTree.InsertItem(node->GetName(),0,1,parent_item,TVI_LAST);
		pTreeView->m_Tree.NodeArray.Add(node);
		parent_item=pTreeView->m_Tree.TreeItem[treecount-1];
		int childcount=node->outLine.GetSize();
		for (int i=0;i<childcount;i++)
		{
			Node *son_node=node->outLine.GetAt(i)->sonNode;
			CreateTree_OnOpen(son_node,parent_item,pTreeView,m_ctlTree);
		}
	}
}
Beispiel #10
0
int CIISConfigHelper::PopulateTreeFromMetaBase(CTreeCtrl& cTree, HTREEITEM htParent, LPCWSTR pszMetaBasePath, LPCWSTR pszURI, IMSAdminBase* pAdminBase, const std::set<CStringW>& IgnoreDirNames, int nVirtualDirectoryIconIndex)
{
	if (htParent == NULL || pszMetaBasePath == NULL || pszURI == NULL || pAdminBase == NULL)
		return 0;	

	// we are going to enum the metabase...
	CIISMetaBase MetaBase(pAdminBase);
	
	// enum the given metabase path for child keys
	std::vector<std::wstring> saKeys;
	if (MetaBase.EnumKeys(CString(pszMetaBasePath), saKeys) == false || saKeys.size() == 0)
		return 0;

	// keep track of the number of child VRs we find
	int nTotalVRs = 0;

	// loop through all the child keys
	for (int i = 0; i < (int) saKeys.size(); i++)
	{
		// check to see whether we should ignore this dir
		if (IgnoreDirNames.find(saKeys[i].c_str()) != IgnoreDirNames.end())
			continue;

		CStringW sChildURI = pszURI;

		int nChildURILength = sChildURI.GetLength();
		if (nChildURILength > 0 && sChildURI[nChildURILength - 1] != '/')
			sChildURI += '/';

		sChildURI += saKeys[i].c_str();

		CStringW sChildMetaBasePath = pszMetaBasePath;
		sChildMetaBasePath += '/';
		sChildMetaBasePath += saKeys[i].c_str();

		// add the key to the tree (since children may need it)
		HTREEITEM htVR = cTree.InsertItem(CString(saKeys[i].c_str()), nVirtualDirectoryIconIndex, nVirtualDirectoryIconIndex, htParent);

		// drop down to enumerate the child key
		int nChildVRs = PopulateTreeFromMetaBase(cTree, htVR, sChildMetaBasePath, sChildURI, pAdminBase, IgnoreDirNames, nVirtualDirectoryIconIndex);

		// if the key doesn't have a VR itself or it didn't have any children with VRs then it's nothing
		// of interest. Delete the tree item and move to the next key.
		CIISMetaBaseData VRPath;		
		if (VRPath.ReadData(pAdminBase, sChildMetaBasePath, MD_VR_PATH) == false && nChildVRs <= 0)
		{
			cTree.DeleteItem(htVR);
			continue;		
		}		

		// we need an item data for this tree item
		IISURIItem* pItem = new IISURIItem;
		pItem->sMetaBasePath = sChildMetaBasePath;
		pItem->sURI = sChildURI;

		// get the VR_PATH (there may not be one)
		std::wstring sVRPath;
		if (VRPath.GetAsString(sVRPath) == true)
		{
			pItem->Type = IISURIItem::VirtualRoot;
			pItem->sFileSystemPath = sVRPath.c_str();
		}
		else
		{
			pItem->Type = IISURIItem::IncompleteFileSystemPath;
		}

		cTree.SetItemData(htVR, (DWORD_PTR) pItem);

		// keep track of the number of VRs in this branch
		nTotalVRs += nChildVRs;
		nTotalVRs++;
	}

	return nTotalVRs;
}
Beispiel #11
0
void CIISConfigHelper::PopulateTreeFromFileSystem(CTreeCtrl& cTree, HTREEITEM htParent, const std::set<CStringW>& IgnoreDirNames, int nMaxDepth)
{
	if (htParent == NULL)
		return;	

	// get the item data from the tree item
	IISURIItem* pParentItem = (IISURIItem*) cTree.GetItemData(htParent);
	if (pParentItem == NULL)
	{
		ASSERT(pParentItem != NULL);
		return;
	}

	// if the item is incomplete then we need to get it's file system path
	if (pParentItem->Type == IISURIItem::IncompleteFileSystemPath && pParentItem->sFileSystemPath.GetLength() <= 0)
	{
		// get the grand parent item
		HTREEITEM htGrandParent = cTree.GetParentItem(htParent);
		if (htGrandParent == NULL)
		{
			ASSERT(htGrandParent != NULL);
			return;
		}		

		// get the grand parent item data
		IISURIItem* pGrandParentItem = (IISURIItem*) cTree.GetItemData(htGrandParent);
		if (pGrandParentItem == NULL)
		{
			ASSERT(pGrandParentItem != NULL);
			return;
		}

		// the grand parent MUST not be incomplete
		if (pGrandParentItem->Type == IISURIItem::IncompleteFileSystemPath)
		{
			ASSERT(pGrandParentItem->Type != IISURIItem::IncompleteFileSystemPath);
			return;
		}

		// get the item name
		CStringW sName = CStringW(cTree.GetItemText(htParent));
		if (sName.GetLength() <= 0)
		{
			ASSERT(sName.GetLength() > 0);
			return;
		}

		// make the path to the parent item
		CPathT<CStringW> ItemFileSystemPath(pGrandParentItem->sFileSystemPath);
		ItemFileSystemPath.Append(sName);

		// assign the new file system path and set the type
		pParentItem->sFileSystemPath = (LPCWSTR) ItemFileSystemPath;
		pParentItem->Type = IISURIItem::FileSystem;
	}

	// if the item already has children then we need to build up a list of their names
	std::set<CStringW> KnownDirs;
	if (cTree.ItemHasChildren(htParent) == TRUE)
	{
		// loop through all the children
		HTREEITEM htChild = cTree.GetChildItem(htParent);
		while (htChild != NULL)
		{
			// get the child name
			CStringW sName = CStringW(cTree.GetItemText(htChild));

			// we need lower case so we can compare easier
			sName.MakeLower();

			// add the name to the known list
			KnownDirs.insert(sName);

			// move on to the next child item
			htChild = cTree.GetNextSiblingItem(htChild);
		}
	}

#ifdef _DEBUG
	ATLTRACE2(L"CIISConfigHelper::PopulateTreeFromFileSystem() : searching '%s'\n", pParentItem->sFileSystemPath);
#endif

	// create a search string
	CPathT<CStringW> FileSystemPath(pParentItem->sFileSystemPath);
	FileSystemPath.Append(L"*.*");
	CStringW sSearchPath = (LPCWSTR) FileSystemPath;	

	// start the search
	WIN32_FIND_DATAW FindData;	
	HANDLE hFind = ::FindFirstFileW(sSearchPath, &FindData);
	if (hFind == INVALID_HANDLE_VALUE)
	{
		// TODO: empty
		return;
	}

	CArray<CStringW, LPCWSTR> saDirs;	

	// guess that we will have 32 sub dirs (the array will grow if we have more)
	saDirs.SetSize(32);

	// keep track of the number of dirs we have actually found
	int nDirsFound = 0;

	do
	{		
		if ((FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
			continue;		

		// eliminate . and .. from the search
		if (FindData.cFileName[0] == '.')
		{
			if (FindData.cFileName[1] == '\0')
			{
				continue;
			}
			else if (FindData.cFileName[1] == '.' && FindData.cFileName[2] == '\0')
			{
				continue;
			}
		}		
			
		// convert to lower case
		CStringW sTempFileName = FindData.cFileName;
		sTempFileName.MakeLower();

		// only add to the collection if we don't already know about it
		if (KnownDirs.find(sTempFileName) != KnownDirs.end())
			continue;

		// if it's a known ignore dir name - then ignore it
		if (IgnoreDirNames.find(sTempFileName) != IgnoreDirNames.end())
			continue;
		
#ifdef _DEBUG
		ATLTRACE2(L"CIISConfigHelper::PopulateTreeFromFileSystem() : found '%s'\n", FindData.cFileName);
#endif

		saDirs.SetAtGrow(nDirsFound, FindData.cFileName);		

		// we have found one
		nDirsFound++;
	}
	while (::FindNextFileW(hFind, &FindData) == TRUE);	

	// get rid of the find handle
	::FindClose(hFind);
	hFind = NULL;	
	
	if (nDirsFound <= 0)
	{		
		return;
	}

	if (nMaxDepth <= 0)
	{
		cTree.InsertItem(EmptyNodeString, htParent);
		return;
	}

	for (int i = 0; i < nDirsFound; i++)
	{
		CString sDir(saDirs[i]);
		HTREEITEM htChild = cTree.InsertItem(sDir, htParent);		

		// create the child file system path
		CPathT<CStringW> FileSystemPath(pParentItem->sFileSystemPath);
		FileSystemPath.Append(saDirs[i]);

		// we need an item data for this tree item
		IISURIItem* pChildItem = new IISURIItem;
		pChildItem->Type = IISURIItem::FileSystem;
		pChildItem->sFileSystemPath = (LPCWSTR) FileSystemPath;

		// make the child URI
		CStringW sChildURI = pParentItem->sURI;
		int nChildURILength = sChildURI.GetLength();
		if (nChildURILength > 0 && sChildURI[nChildURILength - 1] != '/')
			sChildURI += '/';

		// append the dir name
		sChildURI += saDirs[i];

		// assign the URI to the item data
		pChildItem->sURI = sChildURI;

		// store the item data
		cTree.SetItemData(htChild, (DWORD_PTR) pChildItem);

		PopulateTreeFromFileSystem(cTree, htChild, IgnoreDirNames, nMaxDepth - 1);
	}
}
Beispiel #12
0
void CIISConfigHelper::PopulateTreeFromXML(CTreeCtrl& cTree, HTREEITEM htParent, int nVirtualDirectoryIconIndex, IISWebSite* pInstanceItem)
{
	if (pInstanceItem == NULL)
		return;

	// get the config file
	CComPtr<IXMLDOMDocument> pDoc;
	if (CIIS7XMLConfigHelper::GetApplicationHostConfigDocument(&pDoc) != S_OK || pDoc == NULL)
		return;	

	CComPtr<IXMLDOMNode> pSite;
	HRESULT hr = CIIS7XMLConfigHelper::GetSiteNode(pDoc, pInstanceItem->sInstance, &pSite);
	if (hr != S_OK || pSite == NULL)
		return;		

	// get the 'applications' of the site
	CComPtr<IXMLDOMNodeList> pApplications;
	hr = pSite->selectNodes(CComBSTR(L"application"), &pApplications);
	if (hr != S_OK || pApplications == NULL)
		return;

	long nApplications = 0;
	hr = pApplications->get_length(&nApplications);

	// we are going to turn the XML into a more usable form, so we need map for this
	std::map<std::wstring, IISURIItem> uriitems;

	// loop thru the applications
	for (long i = 0; i < nApplications; i++)
	{
		CComPtr<IXMLDOMNode> pApplicationNode;
		hr = pApplications->get_item(i, &pApplicationNode);
		if (hr != S_OK || pApplicationNode == NULL)
			continue;

		CComPtr<IXMLDOMNamedNodeMap> pApplicationAttribs;
		hr = pApplicationNode->get_attributes(&pApplicationAttribs);
		if (hr != S_OK || pApplicationAttribs == NULL)
			continue;
		
		CComPtr<IXMLDOMNode> pApplicationPathAttr;
		hr = pApplicationAttribs->getNamedItem(CComBSTR(L"path"), &pApplicationPathAttr);
		if (hr != S_OK || pApplicationPathAttr == NULL)
			continue;

		CComBSTR bsApplicationURI;
		hr = pApplicationPathAttr->get_text(&bsApplicationURI);

		CComPtr<IXMLDOMNodeList> pVirtualDirectories;
		hr = pApplicationNode->selectNodes(CComBSTR(L"virtualDirectory"), &pVirtualDirectories);
		if (hr != S_OK || pVirtualDirectories == NULL)
			continue;

		long nVirtualDirectories = 0;
		hr = pVirtualDirectories->get_length(&nVirtualDirectories);

		for (long j = 0; j < nVirtualDirectories; j++)
		{
			CComPtr<IXMLDOMNode> pVirtualDirectoryNode;
			hr = pVirtualDirectories->get_item(j, &pVirtualDirectoryNode);
			if (hr != S_OK || pVirtualDirectoryNode == NULL)
				continue;

			CComPtr<IXMLDOMNamedNodeMap> pVirtualDirectoryAttribs;
			hr = pVirtualDirectoryNode->get_attributes(&pVirtualDirectoryAttribs);
			if (hr != S_OK || pVirtualDirectoryAttribs == NULL)
				continue;

			CComPtr<IXMLDOMNode> pVirtualDirectoryPathNode;
			hr = pVirtualDirectoryAttribs->getNamedItem(CComBSTR(L"path"), &pVirtualDirectoryPathNode);

			CComBSTR bsVirtualDirectoryURI;
			hr = pVirtualDirectoryPathNode->get_text(&bsVirtualDirectoryURI);

			CComPtr<IXMLDOMNode> pPhysicalPathNode;
			hr = pVirtualDirectoryAttribs->getNamedItem(CComBSTR(L"physicalPath"), &pPhysicalPathNode);

			CComBSTR bsPhysicalPath;
			hr = pPhysicalPathNode->get_text(&bsPhysicalPath);

			IISURIItem item;			

			// figure out the type of the item
			if (bsApplicationURI == L"/" && bsVirtualDirectoryURI == L"/")
			{
				item.Type = IISURIItem::WebServer;
			}
			else
			{
				item.Type = IISURIItem::VirtualRoot;
			}			

			// we need to figure out on the URI required to get to the item
			if (bsApplicationURI == L"/")
			{
				// we are at the root of the app/web site, so the URI is the virtual dir portion
				item.sURI = bsVirtualDirectoryURI;
			}
			else if (bsVirtualDirectoryURI == L"/")
			{				
				// we are at the root of the app/virtual dir, so the URI is the app dir portion
				item.sURI = bsApplicationURI;
			}
			else
			{
				// we need both app and virtual directory strings
				item.sURI = bsApplicationURI;
				item.sURI += bsVirtualDirectoryURI;
			}
			 
			CIIS7XMLConfigHelper::ExpandEnvironmentStrings(bsPhysicalPath, item.sFileSystemPath);

			// add the item to the list
			uriitems[std::wstring(item.sURI)] = item;
		}		
	}

	// as we add the items to the tree keep track of them since we need to establish the
	// parent/child relationship
	std::map<std::wstring, HTREEITEM> uritreemap;

	// add the root to the map since it's already in the tree
	uritreemap[L"/"] = htParent;

	// loop thru the URI items
	std::map<std::wstring, IISURIItem>::const_iterator iter = uriitems.begin();
	for (; iter != uriitems.end(); ++iter)
	{
		// ignore the web server node since it has already been added
		if (iter->first == L"/")
			continue;

		// look for the last '/' in the URI string
		size_t nURIPrefixLength = iter->first.rfind('/');
		if (nURIPrefixLength == std::wstring::npos)
			continue;

		// get the URI prefix
		std::wstring sURIPrefix(iter->first.c_str(), nURIPrefixLength == 0 ? 1 : nURIPrefixLength);

		// get the URI tail (the bit we are going use for the tree node text)
		LPCWSTR pszURITail = iter->first.c_str() + nURIPrefixLength + 1;		

		// find the parent item
		std::map<std::wstring, HTREEITEM>::const_iterator uriiter = uritreemap.find(sURIPrefix);
		if (uriiter == uritreemap.end())
			continue;		
		
		// add the URI item to the tree
		HTREEITEM htItem = cTree.InsertItem(pszURITail, nVirtualDirectoryIconIndex, nVirtualDirectoryIconIndex, uriiter->second);

		// we need an item data for this tree item
		IISURIItem* pItem = new IISURIItem;
		pItem->Type = IISURIItem::VirtualRoot;
		pItem->sMetaBasePath = iter->second.sMetaBasePath;
		pItem->sFileSystemPath = iter->second.sFileSystemPath;
		pItem->sURI = iter->second.sURI;

		cTree.SetItemData(htItem, (DWORD_PTR) pItem);	

		// add the new item to the map (so children can find it on subseqent passes)
		uritreemap[iter->first] = htItem;
	}
}
Beispiel #13
0
void Cube::InsertItem(CTreeCtrl& c, HTREEITEM hParent, HTREEITEM hInsertAfter)
{
	c.SetItemData(c.InsertItem(m_Name, 8, 9, hParent, hInsertAfter), (DWORD)this);
}
Beispiel #14
0
// @pymethod int|PyCTreeCtrl|InsertItem|Inserts an item into the list.
PyObject *PyCTreeCtrl_InsertItem( PyObject *self, PyObject *args )
{
	CTreeCtrl *pList;
	HTREEITEM ret = NULL;
	UINT mask;
	int image, selImage, state, stateMask;
	PyObject *obParent, *obInsertAfter;
	LPARAM lParam;
	HTREEITEM hParent, hInsertAfter;
	TCHAR *text=NULL;
	PyObject *obtext=Py_None;
	if (!(pList=GetTreeCtrl(self)))
		return NULL;

	if (PyArg_ParseTuple(args, "iOiiiiOOO:InsertItem", 
						&mask, // @pyparmalt1 int|mask||Integer specifying which attributes to set
						&obtext, // @pyparmalt1 string|text||The text of the item.
						&image, // @pyparmalt1 int|image||The index of the image to use.
						&selImage, // @pyparmalt1 int|selectedImage||The index of the items selected image.
						&state, // @pyparmalt1 int|state||The initial state of the item.
						&stateMask, // @pyparmalt1 int|stateMask||Specifies which bits of the state are valid.
						&lParam, // @pyparmalt1 object|lParam||A user defined object for the item.
						&obParent, // @pyparmalt1 HTREEITEM|parent||The parent of the item.
						&obInsertAfter)) { // @pyparmalt1 HTREEITEM|parent||The parent of the item.
		if (!PyWinObject_AsHANDLE(obParent, (HANDLE *)&hParent))
			return NULL;
		if (!PyWinObject_AsHANDLE(obInsertAfter, (HANDLE *)&hInsertAfter))
			return NULL;
		if (!PyWinObject_AsTCHAR(obtext, &text, TRUE))
			return NULL;
		GUI_BGN_SAVE;
		ret = pList->InsertItem(mask, text, image, selImage, state, stateMask, lParam, hParent, hInsertAfter);
	 	GUI_END_SAVE;
		goto done;
		}

	PyErr_Clear();
	hParent = TVI_ROOT;
	hInsertAfter = TVI_LAST;
	if (PyArg_ParseTuple(args, "Oii|O&O&:InsertItem", 
			&obtext, // @pyparmalt2 string|text||The text for the item.
			&image, // @pyparmalt2 int|image||The index of the image to use.
			&selImage, // @pyparmalt2 int|selectedImage||The index of the items selected image.
			PyWinObject_AsHANDLE, &hParent,	// @pyparmalt2 HTREEITEM|parent|commctrl.TVI_ROOT|The parent of the item.
			PyWinObject_AsHANDLE, &hInsertAfter)	// @pyparmalt2 HTREEITEM|insertAfter|commctrl.TVI_LAST|The item to insert the new item after, or TVI_FIRST, TVI_LAST or TVI_SORT
		&& PyWinObject_AsTCHAR(obtext, &text, FALSE)){
		GUI_BGN_SAVE;
		ret = pList->InsertItem(text, image, selImage, hParent, hInsertAfter);
		GUI_END_SAVE;
		goto done;
		}

	// This arg format conflicts with the above.  Handle's can be parsed as ints, so if both optional items are
	//	passed, they will be caught by the above and never get here !
	PyErr_Clear();
	hParent = TVI_ROOT;
	hInsertAfter = TVI_LAST;
	if (PyArg_ParseTuple(args, "O|O&O&:InsertItem", 
			&obtext,	// @pyparmalt3 string|text||The text for the item.
			PyWinObject_AsHANDLE, &hParent,	// @pyparmalt3 HTREEITEM|parent|commctrl.TVI_ROOT|The parent of the item.
			PyWinObject_AsHANDLE, &hInsertAfter)	// @pyparmalt3 HTREEITEM|parent|commctrl.TVI_LAST|The parent of the item.
		&& PyWinObject_AsTCHAR(obtext, &text, FALSE)){	
		GUI_BGN_SAVE;
		ret = pList->InsertItem(text, hParent, hInsertAfter);
		GUI_END_SAVE;
		goto done;
		}

	PyErr_Clear();
	PyObject *obTVItem;
	TV_INSERTSTRUCT tvItem;
	if (PyArg_ParseTuple(args, "O&O&O:InsertItem",
			PyWinObject_AsHANDLE, &tvItem.hParent, // @pyparm HTREEITEM|hParent||The parent item.  If commctrl.TVI_ROOT or 0, it is added to the root.
			PyWinObject_AsHANDLE, &tvItem.hInsertAfter, // @pyparm HTREEITEM|hInsertAfter||The item to insert after.  Can be an item or TVI_FIRST, TVI_LAST or TVI_SORT
			&obTVItem)) { // @pyparm <o TV_ITEM>|item||A tuple describing the new item.
		if (!PyWinObject_AsTV_ITEM(obTVItem, &tvItem.item))
			return NULL;
		GUI_BGN_SAVE;
		ret = pList->InsertItem(&tvItem);
		GUI_END_SAVE;
		PyWinObject_FreeTV_ITEM(&tvItem.item);
		goto done;
		}

	PyErr_Clear();
	RETURN_ERR("InsertItem could not parse the params.");
	// And you will beat your brains out determining why ...

done:
	PyWinObject_FreeTCHAR(text);
	if (ret==NULL)
		RETURN_ERR("InsertItem failed");
	return PyWinLong_FromHANDLE(ret);
}
Beispiel #15
0
void CChatDlg::LoadPicFiles(CTreeCtrl& nTreeCtrl, CString nFilePath, HTREEITEM nRoot)
{

	// 判断nPicFolder是目录还是文件  
	// 如果是文件  
	//     直接将文件插入到树控件中 nTreeCtrl.InsertItem(nPicFolder,nRoot);  
	// 如果是目录  
	//     获取nPicFolder的第一层目录  
	//     判断nRoot目录下是否已经有此层目录  
	//     如果有此层目录  
	//         递归插入其他  
	//     如果无此层目录  
	//         插入此层目录,然后递归插入其他  


	CString nSubFolder;     //首层目录  
	CString nSubFilePath;   //去掉首层目录后的文件名  
	BOOL IsExist = FALSE;



	int nIndex = -1;
	nIndex = nFilePath.Find("/");

	if (nIndex >= 0) //目录  
	{
		nSubFolder = nFilePath.Left(nIndex);
		nSubFilePath = nFilePath.Right(nFilePath.GetLength() - nIndex - 1);

		HTREEITEM nSubRoot = NULL;
		if (nTreeCtrl.ItemHasChildren(nRoot))
			nSubRoot = nTreeCtrl.GetChildItem(nRoot);
		CString str;
		BOOL  bExist = FALSE;
		while (nSubRoot)
		{
			str = nTreeCtrl.GetItemText(nSubRoot);

			if (str.CompareNoCase(nSubFolder) == 0)
			{

				bExist = TRUE;
				break;
			}

			nSubRoot = nTreeCtrl.GetNextSiblingItem(nSubRoot);
		}

		if (!bExist)
		{

			nSubRoot = nTreeCtrl.InsertItem(nSubFolder, nRoot);

			LoadPicFiles(nTreeCtrl, nSubFilePath, nSubRoot);
		}
		else{
			LoadPicFiles(nTreeCtrl, nSubFilePath, nSubRoot);
		}
	}
	else 
	{
		nTreeCtrl.InsertItem(nFilePath, 1, 1, nRoot, 0);
	}
}
Beispiel #16
0
static void UpdateTreeStructure(CTreeCtrl& m_TreeControl, HTREEITEM root) {
  const int FOLDER_CLOSED = 1;
  const int FOLDER_OPENED = 2;

  std::vector<std::string> folderlist = GetFolderList("*");
  for (unsigned int i = 0; i < folderlist.size(); i++) {
    if (!strcmp(folderlist[i].c_str(), ".")
        || !strcmp(folderlist[i].c_str(), "..")) {
      continue;
    }

    // insert folder
    HTREEITEM item = m_TreeControl.InsertItem(
      TVIF_PARAM | TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE,
      folderlist[i].c_str(),
      FOLDER_CLOSED, // image,
      FOLDER_OPENED, // selected_image,
      0,
      0,
      0, // item,
      root == NULL ? TVI_ROOT : root,
      TVI_SORT
    );

    // insert files into that folder
    char directory[MAX_PATH] = {0};
    GetCurrentDirectory(MAX_PATH, directory);
    SetCurrentDirectory(folderlist[i].c_str());
    std::vector<std::string> filelist = GetFileList("*");

    for (unsigned int j = 0; j < filelist.size(); j++)
    {
      // don't show thumbs.db files
      if (filelist[j].size() >= strlen("thumbs.db") && strcmp_ci(filelist[j].c_str(), "thumbs.db") == 0)
        continue;

      // don't show folder.htt files
      if (filelist[j].size() >= strlen("folder.htt") && strcmp_ci(filelist[j].c_str(), "folder.htt") == 0)
        continue;

      // don't show desktop.ini files
      if (filelist[j].size() >= strlen("desktop.ini") && strcmp_ci(filelist[j].c_str(), "desktop.ini") == 0)
        continue;

      // don't show .pyc files
      if (filelist[j].size() >= 4 && filelist[j].rfind(".pyc") == filelist[j].size() - 4) {
        continue;
      }

      // don't show .class files
      if (filelist[j].size() >= 6 && filelist[j].rfind(".class") == filelist[j].size() - 6) {
        continue;
      }

      int image_index = IDI_FILETYPE_BASE - 1; // Unknown icon type
      std::string filename = filelist[j];
      for (int file_type = 0; file_type < FTL.GetNumFileTypes(); file_type++) {
        std::vector<std::string> extensions;
        FTL.GetFileTypeExtensions(file_type, false, extensions);

        for (unsigned int i = 0; i < extensions.size(); i++) {
          if (filename.rfind(extensions[i]) == filename.size() - extensions[i].size()) {
            image_index = IDI_FILETYPE_BASE + file_type;
            file_type = FTL.GetNumFileTypes();
            break;
          }
        }
      }

      m_TreeControl.InsertItem(
        TVIF_TEXT | TVIF_IMAGE | TVIF_SELECTEDIMAGE,
        filelist[j].c_str(),
        image_index, image_index, //image, image,
        0, 0, 0, item, TVI_SORT
      );
    }

    filelist.clear();
    if (GetFolderList("*").size() > 0)
      UpdateTreeStructure(m_TreeControl, item);

    SetCurrentDirectory(directory);
  }
}