Beispiel #1
0
void CSharedDirsTreeCtrl::Initalize(CSharedFilesCtrl* pSharedFilesCtrl){
	m_pSharedFilesCtrl = pSharedFilesCtrl;
	
	SendMessage(CCM_SETUNICODEFORMAT, TRUE);

	//WORD wWinVer = thePrefs.GetWindowsVersion();
	m_bUseIcons = true;/*(wWinVer == _WINVER_2K_ || wWinVer == _WINVER_XP_ || wWinVer == _WINVER_ME_);*/
	
	CImageList iml;
	iml.Create(16, 16, theApp.m_iDfltImageListColorFlags | ILC_MASK, 0, 1);

	iml.Add(CTempIconLoader(_T("ALLFILES")));			// All Directory
	iml.Add(CTempIconLoader(_T("INCOMPLETE")));		// Temp Directory
	iml.Add(CTempIconLoader(_T("OPENFOLDER")));		// Incoming Directory
	iml.Add(CTempIconLoader(_T("CATEGORY")));		// Cats
	iml.Add(CTempIconLoader(_T("HARDDISK")));		// All Dirs
	
	CString strTempDir = thePrefs.GetIncomingDir();
	if (strTempDir.Right(1) != "\\"){
		strTempDir += "\\";
	}
	int nImage = theApp.GetFileTypeSystemImageIdx(strTempDir); // System Folder Icon
	if (theApp.GetSystemImageList() != NULL){
		iml.Add(::ImageList_GetIcon(theApp.GetSystemImageList(), nImage, 0));
	}
	else{
		iml.Add(CTempIconLoader(_T("OPENFOLDER")));
	}
	iml.SetOverlayImage(iml.Add(CTempIconLoader(_T("ClientSecureOvl"))), 1);

	SetImageList(&iml,TVSIL_NORMAL);
	iml.Detach();

	COLORREF crBk = GetSysColor(COLOR_WINDOW);
	COLORREF crFg = GetSysColor(COLOR_WINDOWTEXT);

	theApp.LoadSkinColorAlt(_T("SharedDirsTvBk"), _T("DefLvBk"), crBk);
	theApp.LoadSkinColorAlt(_T("SharedDirsTvFg"), _T("DefLvFg"), crFg);

	SetBkColor(crBk);
	SetTextColor(crFg);
	InitalizeStandardItems();
	FilterTreeReloadTree();
	CreateMenues();
}
void CSharedDirsTreeCtrl::SetAllIcons()
{
	CImageList iml;
	iml.Create(16, 16, theApp.m_iDfltImageListColorFlags | ILC_MASK, 0, 1);
	iml.Add(CTempIconLoader(_T("ALLFILES")));		// All Directory
	iml.Add(CTempIconLoader(_T("INCOMPLETE")));		// Temp Directory
	iml.Add(CTempIconLoader(_T("OPENFOLDER")));		// Incoming Directory
	iml.Add(CTempIconLoader(_T("CATEGORY")));		// Cats
	iml.Add(CTempIconLoader(_T("HARDDISK")));		// All Dirs
	
	CString strTempDir = thePrefs.GetMuleDirectory(EMULE_INCOMINGDIR);
	if (strTempDir.Right(1) != "\\"){
		strTempDir += "\\";
	}
	//MODIFIED by fengwen on 2007/01/17	<begin> :	提升启动速度
	//int nImage = theApp.GetFileTypeSystemImageIdx(strTempDir); // System Folder Icon
	//if (theApp.GetSystemImageList() != NULL){
	//	iml.Add(::ImageList_GetIcon(theApp.GetSystemImageList(), nImage, 0));
	//}
	//else{
	//	iml.Add(CTempIconLoader(_T("OPENFOLDER")));
	//}
	iml.Add(CTempIconLoader(_T("OPENFOLDER")));
	//MODIFIED by fengwen on 2007/01/17	<end> :	提升启动速度
	iml.SetOverlayImage(iml.Add(CTempIconLoader(_T("ClientSecureOvl"))), 1);

	SetImageList(&iml, TVSIL_NORMAL);
	m_imlTree.DeleteImageList();
	m_imlTree.Attach(iml.Detach());

	COLORREF crBk = GetSysColor(COLOR_WINDOW);
	COLORREF crFg = GetSysColor(COLOR_WINDOWTEXT);
	theApp.LoadSkinColorAlt(_T("SharedDirsTvBk"), _T("DefLvBk"), crBk);
	theApp.LoadSkinColorAlt(_T("SharedDirsTvFg"), _T("DefLvFg"), crFg);
	SetBkColor(crBk);
	SetTextColor(crFg);
}
void CSetOverlayIcons::ShowIconSet(bool bSmallIcons)
{
	m_cIconList.SetRedraw(FALSE);
	m_cIconList.DeleteAllItems();
	m_ImageList.DeleteImageList();
	m_ImageListBig.DeleteImageList();
	m_ImageList.Create(16, 16, ILC_COLOR32 | ILC_MASK, 20, 10);
	m_ImageListBig.Create(32, 32, ILC_COLOR32 | ILC_MASK, 20, 10);
	m_cIconList.SetImageList(&m_ImageList, LVSIL_SMALL);
	m_cIconList.SetImageList(&m_ImageListBig, LVSIL_NORMAL);

	// find all the icons of the selected icon set
	CString sIconSet;
	int index = m_cIconSet.GetCurSel();
	if (index == CB_ERR)
	{
		// nothing selected. Shouldn't happen!
		return;
	}
	m_cIconSet.GetLBText(index, sIconSet);
	CString sIconSetPath = m_sIconPath + _T("\\") + sIconSet;

	CImageList * pImageList = bSmallIcons ? &m_ImageList : &m_ImageListBig;
	int pixelsize = (bSmallIcons ? 16 : 32);
	HICON hNormalOverlay = (HICON)LoadImage(NULL, sIconSetPath+_T("\\NormalIcon.ico"), IMAGE_ICON, pixelsize, pixelsize, LR_LOADFROMFILE);
	index = pImageList->Add(hNormalOverlay);
	VERIFY(pImageList->SetOverlayImage(index, 1));
	HICON hModifiedOverlay = (HICON)LoadImage(NULL, sIconSetPath+_T("\\ModifiedIcon.ico"), IMAGE_ICON, pixelsize, pixelsize, LR_LOADFROMFILE);
	index = pImageList->Add(hModifiedOverlay);
	VERIFY(pImageList->SetOverlayImage(index, 2));
	HICON hConflictedOverlay = (HICON)LoadImage(NULL, sIconSetPath+_T("\\ConflictIcon.ico"), IMAGE_ICON, pixelsize, pixelsize, LR_LOADFROMFILE);
	index = pImageList->Add(hConflictedOverlay);
	VERIFY(pImageList->SetOverlayImage(index, 3));
	HICON hReadOnlyOverlay = (HICON)LoadImage(NULL, sIconSetPath+_T("\\ReadOnlyIcon.ico"), IMAGE_ICON, pixelsize, pixelsize, LR_LOADFROMFILE);
	index = pImageList->Add(hReadOnlyOverlay);
	VERIFY(pImageList->SetOverlayImage(index, 4));
	HICON hDeletedOverlay = (HICON)LoadImage(NULL, sIconSetPath+_T("\\DeletedIcon.ico"), IMAGE_ICON, pixelsize, pixelsize, LR_LOADFROMFILE);
	index = pImageList->Add(hDeletedOverlay);
	VERIFY(pImageList->SetOverlayImage(index, 5));
	HICON hLockedOverlay = (HICON)LoadImage(NULL, sIconSetPath+_T("\\LockedIcon.ico"), IMAGE_ICON, pixelsize, pixelsize, LR_LOADFROMFILE);
	index = pImageList->Add(hLockedOverlay);
	VERIFY(pImageList->SetOverlayImage(index, 6));
	HICON hAddedOverlay = (HICON)LoadImage(NULL, sIconSetPath+_T("\\AddedIcon.ico"), IMAGE_ICON, pixelsize, pixelsize, LR_LOADFROMFILE);
	index = pImageList->Add(hAddedOverlay);
	VERIFY(pImageList->SetOverlayImage(index, 7));
	HICON hIgnoredOverlay = (HICON)LoadImage(NULL, sIconSetPath+_T("\\IgnoredIcon.ico"), IMAGE_ICON, pixelsize, pixelsize, LR_LOADFROMFILE);
	index = pImageList->Add(hIgnoredOverlay);
	VERIFY(pImageList->SetOverlayImage(index, 8));
	HICON hUnversionedOverlay = (HICON)LoadImage(NULL, sIconSetPath+_T("\\UnversionedIcon.ico"), IMAGE_ICON, pixelsize, pixelsize, LR_LOADFROMFILE);
	index = pImageList->Add(hUnversionedOverlay);
	VERIFY(pImageList->SetOverlayImage(index, 9));

	DestroyIcon(hNormalOverlay);
	DestroyIcon(hModifiedOverlay);
	DestroyIcon(hConflictedOverlay);
	DestroyIcon(hReadOnlyOverlay);
	DestroyIcon(hDeletedOverlay);
	DestroyIcon(hLockedOverlay);
	DestroyIcon(hAddedOverlay);
	DestroyIcon(hIgnoredOverlay);
	DestroyIcon(hUnversionedOverlay);

	// create an image list with different file icons
	SHFILEINFO sfi;
	SecureZeroMemory(&sfi, sizeof sfi);

	UINT flags = SHGFI_ICON | SHGFI_USEFILEATTRIBUTES;
	if (bSmallIcons)
		flags |= SHGFI_SMALLICON;
	else
		flags |= SHGFI_LARGEICON;
	SHGetFileInfo(
		_T("Doesn't matter"),
		FILE_ATTRIBUTE_DIRECTORY,
		&sfi, sizeof sfi,
		flags);

	int folderindex = pImageList->Add(sfi.hIcon);	//folder
	DestroyIcon(sfi.hIcon);
	//folders
	index = m_cIconList.InsertItem(m_cIconList.GetItemCount(), m_sNormal, folderindex);
	VERIFY(m_cIconList.SetItemState(index, INDEXTOOVERLAYMASK(1), TVIS_OVERLAYMASK));
	index = m_cIconList.InsertItem(m_cIconList.GetItemCount(), m_sModified, folderindex);
	m_cIconList.SetItemState(index, INDEXTOOVERLAYMASK(2), TVIS_OVERLAYMASK);
	index = m_cIconList.InsertItem(m_cIconList.GetItemCount(), m_sConflicted, folderindex);
	m_cIconList.SetItemState(index, INDEXTOOVERLAYMASK(3), TVIS_OVERLAYMASK);
	index = m_cIconList.InsertItem(m_cIconList.GetItemCount(), m_sReadOnly, folderindex);
	m_cIconList.SetItemState(index, INDEXTOOVERLAYMASK(4), TVIS_OVERLAYMASK);
	index = m_cIconList.InsertItem(m_cIconList.GetItemCount(), m_sDeleted, folderindex);
	m_cIconList.SetItemState(index, INDEXTOOVERLAYMASK(5), TVIS_OVERLAYMASK);
	index = m_cIconList.InsertItem(m_cIconList.GetItemCount(), m_sLocked, folderindex);
	m_cIconList.SetItemState(index, INDEXTOOVERLAYMASK(6), TVIS_OVERLAYMASK);
	index = m_cIconList.InsertItem(m_cIconList.GetItemCount(), m_sAdded, folderindex);
	m_cIconList.SetItemState(index, INDEXTOOVERLAYMASK(7), TVIS_OVERLAYMASK);
	index = m_cIconList.InsertItem(m_cIconList.GetItemCount(), m_sIgnored, folderindex);
	m_cIconList.SetItemState(index, INDEXTOOVERLAYMASK(8), TVIS_OVERLAYMASK);
	index = m_cIconList.InsertItem(m_cIconList.GetItemCount(), m_sUnversioned, folderindex);
	m_cIconList.SetItemState(index, INDEXTOOVERLAYMASK(9), TVIS_OVERLAYMASK);

	AddFileTypeGroup(_T(".cpp"), bSmallIcons);
	AddFileTypeGroup(_T(".h"), bSmallIcons);
	AddFileTypeGroup(_T(".txt"), bSmallIcons);
	AddFileTypeGroup(_T(".java"), bSmallIcons);
	AddFileTypeGroup(_T(".doc"), bSmallIcons);
	AddFileTypeGroup(_T(".pl"), bSmallIcons);
	AddFileTypeGroup(_T(".php"), bSmallIcons);
	AddFileTypeGroup(_T(".asp"), bSmallIcons);
	AddFileTypeGroup(_T(".cs"), bSmallIcons);
	AddFileTypeGroup(_T(".vb"), bSmallIcons);
	AddFileTypeGroup(_T(".xml"), bSmallIcons);
	AddFileTypeGroup(_T(".pas"), bSmallIcons);
	AddFileTypeGroup(_T(".dpr"), bSmallIcons);
	AddFileTypeGroup(_T(".dfm"), bSmallIcons);
	AddFileTypeGroup(_T(".res"), bSmallIcons);
	AddFileTypeGroup(_T(".asmx"), bSmallIcons);
	AddFileTypeGroup(_T(".aspx"), bSmallIcons);
	AddFileTypeGroup(_T(".resx"), bSmallIcons);
	AddFileTypeGroup(_T(".vbp"), bSmallIcons);
	AddFileTypeGroup(_T(".frm"), bSmallIcons);
	AddFileTypeGroup(_T(".frx"), bSmallIcons);
	AddFileTypeGroup(_T(".bas"), bSmallIcons);
	AddFileTypeGroup(_T(".config"), bSmallIcons);
	AddFileTypeGroup(_T(".css"), bSmallIcons);
	AddFileTypeGroup(_T(".acsx"), bSmallIcons);
	AddFileTypeGroup(_T(".jpg"), bSmallIcons);
	AddFileTypeGroup(_T(".png"), bSmallIcons);
	m_cIconList.SetRedraw(TRUE);
}