📄 clientlistctrl.cpp
字号:
break;
case DS_REQHASHSET:
Sbuffer = GetResString(IDS_RECHASHSET);
break;
case DS_NONEEDEDPARTS:
Sbuffer = GetResString(IDS_NONEEDEDPARTS);
break;
case DS_LOWTOLOWIP:
Sbuffer = GetResString(IDS_NOCONNECTLOW2LOW);
break;
case DS_TOOMANYCONNS:
Sbuffer = GetResString(IDS_TOOMANYCONNS);
break;
default:
Sbuffer = "";
}
break;
}
case 4:{
if(client->credits)
Sbuffer.Format("%s", CastItoXBytes(client->credits->GetDownloadedTotal()));
else
Sbuffer = "";
break;
}
case 5:{
switch(client->GetClientSoft()){
case SO_EDONKEY:
Sbuffer.Format("eDonkey v%.1f",(float)client->GetVersion()/10.0f);
break;
case SO_EDONKEYHYBRID:
Sbuffer.Format( "eDonkeyHybrid v%.1f",(float)client->GetVersion()/10.0f);
break;
case SO_EMULE:
case SO_OLDEMULE:{
Sbuffer.Format("eMule v%.2f",(float)client->GetVersion()/1000.0f);
break;
}
case SO_LMULE:{
Sbuffer.Format("lMule v%.2f",(float)client->GetVersion()/1000.0f);
break;
}
case SO_CDONKEY:{
Sbuffer.Format("cDonkey v%.2f",(float)client->GetVersion()/1000.0f);
break;
}
case SO_MLDONKEY:
Sbuffer.Format("Old MlDonkey");
break;
case SO_UNKNOWN:
Sbuffer.Format( "%s", GetResString(IDS_UNKNOWN));
break;
default:
Sbuffer.Format( "%s", GetResString(IDS_UNKNOWN));
}
break;
}
case 6:{
if(client->socket){
if(client->socket->IsConnected()){
Sbuffer.Format( "%s", GetResString(IDS_YES) );
break;
}
}
Sbuffer.Format( "%s", GetResString(IDS_NO) );
break;
}
case 7:{
Sbuffer ="";
CString buffer2;
for (uint16 i = 0;i != 16;i++){
buffer2.Format("%02X",client->GetUserHash()[i]);
Sbuffer+=buffer2;
}
break;
}
}
if( iColumn != 0)
dc->DrawText(Sbuffer,Sbuffer.GetLength(),&cur_rec,DLC_DT_TEXT);
cur_rec.left += GetColumnWidth(iColumn);
}
}
//draw rectangle around selected item(s)
if ((lpDrawItemStruct->itemAction | ODA_SELECT) && (lpDrawItemStruct->itemState & ODS_SELECTED))
{
RECT outline_rec;
memcpy(&outline_rec,&lpDrawItemStruct->rcItem,sizeof(RECT));
outline_rec.top--;
outline_rec.bottom++;
dc->FrameRect(&outline_rec, &CBrush(GetBkColor()));
outline_rec.top++;
outline_rec.bottom--;
outline_rec.left++;
outline_rec.right--;
if(bCtrlFocused)
dc->FrameRect(&outline_rec, &CBrush(m_crFocusLine));
else
dc->FrameRect(&outline_rec, &CBrush(m_crNoFocusLine));
}
}
BEGIN_MESSAGE_MAP(CClientListCtrl, CMuleListCtrl)
ON_WM_CONTEXTMENU()
ON_NOTIFY_REFLECT(LVN_COLUMNCLICK, OnColumnClick)
END_MESSAGE_MAP()
// CClientListCtrl message handlers
void CClientListCtrl::OnContextMenu(CWnd* pWnd, CPoint point){
if (m_ClientMenu) m_ClientMenu.DestroyMenu();
m_ClientMenu.CreatePopupMenu();
m_ClientMenu.AddMenuTitle(GetResString(IDS_CLIENTS));
m_ClientMenu.AppendMenu(MF_STRING,MP_DETAIL, GetResString(IDS_SHOWDETAILS));
m_ClientMenu.AppendMenu(MF_STRING,MP_ADDFRIEND, GetResString(IDS_ADDFRIEND));
m_ClientMenu.AppendMenu(MF_STRING,MP_MESSAGE, GetResString(IDS_SEND_MSG));
m_ClientMenu.AppendMenu(MF_STRING,MP_SHOWLIST, GetResString(IDS_VIEWFILES));
//not needed since the button, is it?!
//m_ClientMenu.AppendMenu(MF_SEPARATOR);
//m_ClientMenu.AppendMenu(MF_STRING,MP_SWITCHCTRL, GetResString(IDS_VIEWQUEUE));
SetMenu(&m_ClientMenu);
m_ClientMenu.TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, point.x, point.y, this);
m_ClientMenu.DestroyMenu();
}
BOOL CClientListCtrl::OnCommand(WPARAM wParam,LPARAM lParam ){
if (GetSelectionMark() != (-1)){
CUpDownClient* client = (CUpDownClient*)GetItemData(GetSelectionMark());
switch (wParam){
case MP_SHOWLIST:
client->RequestSharedFileList();
break;
case MP_MESSAGE:{
theApp.emuledlg->chatwnd.StartSession(client);
break;
}
case MP_ADDFRIEND:{
theApp.friendlist->AddFriend(client);
break;
}
case MP_UNBAN:{
if( client->IsBanned() )
client->UnBan();
break;
}
case MP_DETAIL:
CClientDetailDialog dialog(client);
dialog.DoModal();
break;
}
}
return true;
}
void CClientListCtrl::OnColumnClick( NMHDR* pNMHDR, LRESULT* pResult){
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
// Barry - Store sort order in preferences
// Determine ascending based on whether already sorted on this column
int sortItem = theApp.glob_prefs->GetColumnSortItem(CPreferences::tableClientList);
bool m_oldSortAscending = theApp.glob_prefs->GetColumnSortAscending(CPreferences::tableClientList);
bool sortAscending = (sortItem != pNMListView->iSubItem) ? true : !m_oldSortAscending;
// Item is column clicked
sortItem = pNMListView->iSubItem;
// Save new preferences
theApp.glob_prefs->SetColumnSortItem(CPreferences::tableClientList, sortItem);
theApp.glob_prefs->SetColumnSortAscending(CPreferences::tableClientList, sortAscending);
// Sort table
SetSortArrow(sortItem, sortAscending);
SortItems(SortProc, sortItem + (sortAscending ? 0:100));
*pResult = 0;
}
int CClientListCtrl::SortProc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort){
CUpDownClient* item1 = (CUpDownClient*)lParam1;
CUpDownClient* item2 = (CUpDownClient*)lParam2;
CKnownFile* file1 = theApp.sharedfiles->GetFileByID(item1->GetUploadFileID());
CKnownFile* file2 = theApp.sharedfiles->GetFileByID(item2->GetUploadFileID());
switch(lParamSort){
case 0:
if(item1->GetUserName() && item2->GetUserName())
return CString(item1->GetUserName()).CompareNoCase(item2->GetUserName());
else if(item1->GetUserName())
return 1;
else
return -1;
case 100:
if(item1->GetUserName() && item2->GetUserName())
return CString(item2->GetUserName()).CompareNoCase(item1->GetUserName());
else if(item2->GetUserName())
return 1;
else
return -1;
case 1:
return item1->GetUploadState()-item2->GetUploadState();
case 101:
return item2->GetUploadState()-item1->GetUploadState();
case 2:
if( item1->credits && item2->credits )
return item1->credits->GetUploadedTotal()-item2->credits->GetUploadedTotal();
else if( !item1->credits )
return 1;
else
return -1;
case 102:
if( item1->credits && item2->credits )
return item2->credits->GetUploadedTotal()-item1->credits->GetUploadedTotal();
else if( !item1->credits )
return 1;
else
return -1;
case 3:
return item1->GetDownloadState()-item2->GetDownloadState();
case 103:
return item2->GetDownloadState()-item1->GetDownloadState();
case 4:
if( item1->credits && item2->credits )
return item1->credits->GetDownloadedTotal()-item2->credits->GetDownloadedTotal();
else if( !item1->credits )
return 1;
else
return -1;
case 104:
if( item1->credits && item2->credits )
return item2->credits->GetDownloadedTotal()-item1->credits->GetDownloadedTotal();
else if( !item1->credits )
return 1;
else
return -1;
case 5:
if( item1->GetClientSoft() == item2->GetClientSoft() )
return item2->GetVersion() - item1->GetVersion();
return item1->GetClientSoft() - item2->GetClientSoft();
case 105:
if( item1->GetClientSoft() == item2->GetClientSoft() )
return item1->GetVersion() - item2->GetVersion();
return item2->GetClientSoft() - item1->GetClientSoft();
case 6:
if( item1->socket && item2->socket )
return item1->socket->IsConnected()-item2->socket->IsConnected();
else if( !item1->socket )
return -1;
else
return 1;
case 106:
if( item1->socket && item2->socket )
return item2->socket->IsConnected()-item1->socket->IsConnected();
else if( !item2->socket )
return -1;
else
return 1;
case 7:{
CString Sbuffer1;
CString Sbuffer2;
CString buffer2;
for (uint16 i = 0;i != 16;i++){
buffer2.Format("%02X",item1->GetUserHash()[i]);
Sbuffer1+=buffer2;
}
for (uint16 i = 0;i != 16;i++){
buffer2.Format("%02X",item2->GetUserHash()[i]);
Sbuffer2+=buffer2;
}
return Sbuffer1.Compare(Sbuffer2);
}
case 107:{
CString Sbuffer1;
CString Sbuffer2;
CString buffer2;
for (uint16 i = 0;i != 16;i++){
buffer2.Format("%02X",item1->GetUserHash()[i]);
Sbuffer1+=buffer2;
}
for (uint16 i = 0;i != 16;i++){
buffer2.Format("%02X",item2->GetUserHash()[i]);
Sbuffer2+=buffer2;
}
return Sbuffer2.Compare(Sbuffer1);
}
default:
return 0;
}
}
void CClientListCtrl::ShowSelectedUserDetails() {
POINT point;
::GetCursorPos(&point);
CPoint p = point;
ScreenToClient(&p);
int it = HitTest(p);
if (it == -1) return;
SetSelectionMark(it); // display selection mark correctly!
CUpDownClient* client = (CUpDownClient*)GetItemData(GetSelectionMark());
if (client){
CClientDetailDialog dialog(client);
dialog.DoModal();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -