📄 emuledlg.cpp
字号:
SetActiveDialog(transferwnd);
break;
case TBN_IMPORTANTEVENT:
RestoreWindow();
SetActiveDialog(serverwnd);
break;
case TBN_LOG:
RestoreWindow();
SetActiveDialog(serverwnd);
break;
case TBN_NEWVERSION:{
CString theUrl;
theUrl.Format(_T("/en/version_check.php?version=%i&language=%i"),theApp.m_uCurVersionCheck,thePrefs.GetLanguageID());
theUrl = thePrefs.GetVersionCheckBaseURL()+theUrl;
ShellExecute(NULL, NULL, theUrl, NULL, thePrefs.GetAppDir(), SW_SHOWDEFAULT);
break;
}
}
return 0;
}
//END - enkeyDEV(kei-kun) -TaskbarNotifier-
void CemuleDlg::OnSysColorChange()
{
CTrayDialog::OnSysColorChange();
SetAllIcons();
}
void CemuleDlg::SetAllIcons()
{
// connection state
for (int i = 0; i < ARRSIZE(connicons); i++){
if (connicons[i]) VERIFY( ::DestroyIcon(connicons[i]) );
}
connicons[0] = theApp.LoadIcon(_T("ConnectedNotNot"), 16, 16);
connicons[1] = theApp.LoadIcon(_T("ConnectedNotLow"), 16, 16);
connicons[2] = theApp.LoadIcon(_T("ConnectedNotHigh"), 16, 16);
connicons[3] = theApp.LoadIcon(_T("ConnectedLowNot"), 16, 16);
connicons[4] = theApp.LoadIcon(_T("ConnectedLowLow"), 16, 16);
connicons[5] = theApp.LoadIcon(_T("ConnectedLowHigh"), 16, 16);
connicons[6] = theApp.LoadIcon(_T("ConnectedHighNot"), 16, 16);
connicons[7] = theApp.LoadIcon(_T("ConnectedHighLow"), 16, 16);
connicons[8] = theApp.LoadIcon(_T("ConnectedHighHigh"), 16, 16);
ShowConnectionStateIcon();
// transfer state
if (transicons[0]) VERIFY( ::DestroyIcon(transicons[0]) );
if (transicons[1]) VERIFY( ::DestroyIcon(transicons[1]) );
if (transicons[2]) VERIFY( ::DestroyIcon(transicons[2]) );
if (transicons[3]) VERIFY( ::DestroyIcon(transicons[3]) );
transicons[0] = theApp.LoadIcon(_T("UP0DOWN0"), 16, 16);
transicons[1] = theApp.LoadIcon(_T("UP0DOWN1"), 16, 16);
transicons[2] = theApp.LoadIcon(_T("UP1DOWN0"), 16, 16);
transicons[3] = theApp.LoadIcon(_T("UP1DOWN1"), 16, 16);
ShowTransferStateIcon();
// users state
if (usericon) VERIFY( ::DestroyIcon(usericon) );
usericon = theApp.LoadIcon(_T("StatsClients"), 16, 16);
ShowUserStateIcon();
// traybar icons: no support for changing traybar icons on-the-fly
// if (sourceTrayIcon) VERIFY( ::DestroyIcon(sourceTrayIcon) );
// if (sourceTrayIconGrey) VERIFY( ::DestroyIcon(sourceTrayIconGrey) );
// if (sourceTrayIconLow) VERIFY( ::DestroyIcon(sourceTrayIconLow) );
// sourceTrayIcon = theApp.LoadIcon("TrayConnected", 16, 16);
// sourceTrayIconGrey = theApp.LoadIcon("TrayNotConnected", 16, 16);
// sourceTrayIconLow = theApp.LoadIcon("TrayLowID", 16, 16);
if (imicons[0]) VERIFY( ::DestroyIcon(imicons[0]) );
if (imicons[1]) VERIFY( ::DestroyIcon(imicons[1]) );
if (imicons[2]) VERIFY( ::DestroyIcon(imicons[2]) );
imicons[0] = NULL;
imicons[1] = theApp.LoadIcon(_T("Message"), 16, 16);
imicons[2] = theApp.LoadIcon(_T("MessagePending"), 16, 16);
ShowMessageState(m_iMsgIcon);
}
void CemuleDlg::Localize()
{
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu)
{
VERIFY( pSysMenu->ModifyMenu(MP_ABOUTBOX, MF_BYCOMMAND | MF_STRING, MP_ABOUTBOX, GetResString(IDS_ABOUTBOX)) );
VERIFY( pSysMenu->ModifyMenu(MP_VERSIONCHECK, MF_BYCOMMAND | MF_STRING, MP_VERSIONCHECK, GetResString(IDS_VERSIONCHECK)) );
switch (thePrefs.GetWindowsVersion()){
case _WINVER_98_:
case _WINVER_95_:
case _WINVER_ME_:
// NOTE: I think the reason why the old version of the following code crashed under Win9X was because
// of the menus were destroyed right after they were added to the system menu. New code should work
// under Win9X too but I can't test it.
break;
default:{
// localize the 'speed control' sub menus by deleting the current menus and creating a new ones.
// remove any already available 'speed control' menus from system menu
UINT uOptMenuPos = pSysMenu->GetMenuItemCount() - 1;
CMenu* pAccelMenu = pSysMenu->GetSubMenu(uOptMenuPos);
if (pAccelMenu)
{
ASSERT( pAccelMenu->m_hMenu == m_SysMenuOptions.m_hMenu );
VERIFY( pSysMenu->RemoveMenu(uOptMenuPos, MF_BYPOSITION) );
pAccelMenu = NULL;
}
// destroy all 'speed control' menus
if (m_menuUploadCtrl)
VERIFY( m_menuUploadCtrl.DestroyMenu() );
if (m_menuDownloadCtrl)
VERIFY( m_menuDownloadCtrl.DestroyMenu() );
if (m_SysMenuOptions)
VERIFY( m_SysMenuOptions.DestroyMenu() );
// create new 'speed control' menus
if (m_SysMenuOptions.CreateMenu())
{
AddSpeedSelectorSys(&m_SysMenuOptions);
pSysMenu->AppendMenu(MF_STRING|MF_POPUP, (UINT_PTR)m_SysMenuOptions.m_hMenu, GetResString(IDS_EM_PREFS));
}
}
}
}
ShowUserStateIcon();
toolbar->Localize();
ShowConnectionState();
ShowTransferRate(true);
ShowUserCount();
}
void CemuleDlg::ShowUserStateIcon()
{
statusbar->SetIcon(1,usericon);
}
void CemuleDlg::QuickSpeedOther(UINT nID)
{
switch (nID) {
case MP_QS_PA: thePrefs.SetMaxUpload((uint16)(1));
thePrefs.SetMaxDownload((uint16)(1));
break ;
case MP_QS_UA:
thePrefs.SetMaxUpload((uint16)(thePrefs.GetMaxGraphUploadRate()));
thePrefs.SetMaxDownload((uint16)(thePrefs.GetMaxGraphDownloadRate()));
break ;
}
}
void CemuleDlg::QuickSpeedUpload(UINT nID)
{
switch (nID) {
case MP_QS_U10: thePrefs.SetMaxUpload((uint16)(thePrefs.GetMaxGraphUploadRate()*0.1)); break ;
case MP_QS_U20: thePrefs.SetMaxUpload((uint16)(thePrefs.GetMaxGraphUploadRate()*0.2)); break ;
case MP_QS_U30: thePrefs.SetMaxUpload((uint16)(thePrefs.GetMaxGraphUploadRate()*0.3)); break ;
case MP_QS_U40: thePrefs.SetMaxUpload((uint16)(thePrefs.GetMaxGraphUploadRate()*0.4)); break ;
case MP_QS_U50: thePrefs.SetMaxUpload((uint16)(thePrefs.GetMaxGraphUploadRate()*0.5)); break ;
case MP_QS_U60: thePrefs.SetMaxUpload((uint16)(thePrefs.GetMaxGraphUploadRate()*0.6)); break ;
case MP_QS_U70: thePrefs.SetMaxUpload((uint16)(thePrefs.GetMaxGraphUploadRate()*0.7)); break ;
case MP_QS_U80: thePrefs.SetMaxUpload((uint16)(thePrefs.GetMaxGraphUploadRate()*0.8)); break ;
case MP_QS_U90: thePrefs.SetMaxUpload((uint16)(thePrefs.GetMaxGraphUploadRate()*0.9)); break ;
case MP_QS_U100: thePrefs.SetMaxUpload(thePrefs.GetMaxGraphUploadRate()); break ;
// case MP_QS_UPC: thePrefs.SetMaxUpload(UNLIMITED); break ;
case MP_QS_UP10: thePrefs.SetMaxUpload(GetRecMaxUpload()); break ;
}
}
void CemuleDlg::QuickSpeedDownload(UINT nID)
{
switch (nID) {
case MP_QS_D10: thePrefs.SetMaxDownload((uint16)(thePrefs.GetMaxGraphDownloadRate()*0.1)); break ;
case MP_QS_D20: thePrefs.SetMaxDownload((uint16)(thePrefs.GetMaxGraphDownloadRate()*0.2)); break ;
case MP_QS_D30: thePrefs.SetMaxDownload((uint16)(thePrefs.GetMaxGraphDownloadRate()*0.3)); break ;
case MP_QS_D40: thePrefs.SetMaxDownload((uint16)(thePrefs.GetMaxGraphDownloadRate()*0.4)); break ;
case MP_QS_D50: thePrefs.SetMaxDownload((uint16)(thePrefs.GetMaxGraphDownloadRate()*0.5)); break ;
case MP_QS_D60: thePrefs.SetMaxDownload((uint16)(thePrefs.GetMaxGraphDownloadRate()*0.6)); break ;
case MP_QS_D70: thePrefs.SetMaxDownload((uint16)(thePrefs.GetMaxGraphDownloadRate()*0.7)); break ;
case MP_QS_D80: thePrefs.SetMaxDownload((uint16)(thePrefs.GetMaxGraphDownloadRate()*0.8)); break ;
case MP_QS_D90: thePrefs.SetMaxDownload((uint16)(thePrefs.GetMaxGraphDownloadRate()*0.9)); break ;
case MP_QS_D100: thePrefs.SetMaxDownload(thePrefs.GetMaxGraphDownloadRate()); break ;
// case MP_QS_DC: thePrefs.SetMaxDownload(UNLIMITED); break ;
}
}
// quick-speed changer -- based on xrmb
int CemuleDlg::GetRecMaxUpload() {
if (thePrefs.GetMaxGraphUploadRate()<7) return 0;
if (thePrefs.GetMaxGraphUploadRate()<15) return thePrefs.GetMaxGraphUploadRate()-3;
return (thePrefs.GetMaxGraphUploadRate()-4);
}
BOOL CemuleDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
switch(wParam)
{
case IDC_TOOLBARBUTTON + 0:
OnBnClickedButton2();
break;
case MP_HM_KAD:
case IDC_TOOLBARBUTTON +1:
SetActiveDialog(kademliawnd);
break;
case IDC_TOOLBARBUTTON + 2:
case MP_HM_SRVR:
SetActiveDialog(serverwnd);
break;
case IDC_TOOLBARBUTTON + 3:
case MP_HM_TRANSFER:
SetActiveDialog(transferwnd);
break;
case IDC_TOOLBARBUTTON + 4:
case MP_HM_SEARCH:
SetActiveDialog(searchwnd);
break;
case IDC_TOOLBARBUTTON + 5:
case MP_HM_FILES:
SetActiveDialog(sharedfileswnd);
break;
case IDC_TOOLBARBUTTON + 6:
case MP_HM_MSGS:
SetActiveDialog(chatwnd);
break;
case IDC_TOOLBARBUTTON + 7:
case MP_HM_IRC:
SetActiveDialog(ircwnd);
break;
case IDC_TOOLBARBUTTON + 8:
case MP_HM_STATS:
SetActiveDialog(statisticswnd);
break;
case IDC_TOOLBARBUTTON + 9:
case MP_HM_PREFS:
toolbar->CheckButton(IDC_TOOLBARBUTTON+9,TRUE);
preferenceswnd->DoModal();
toolbar->CheckButton(IDC_TOOLBARBUTTON+9,FALSE);
break;
case IDC_TOOLBARBUTTON + 10:
ShowToolPopup(true);
break;
case MP_HM_OPENINC:
ShellExecute(NULL, _T("open"), thePrefs.GetIncomingDir(),NULL, NULL, SW_SHOW);
break;
case MP_HM_HELP:
case IDC_TOOLBARBUTTON + 11:
wParam = ID_HELP;
break;
case MP_HM_CON:
OnBnClickedButton2();
break;
case MP_HM_EXIT:
OnClose();
break;
case MP_HM_LINK1: // MOD: dont remove!
ShellExecute(NULL, NULL, thePrefs.GetHomepageBaseURL(), NULL, thePrefs.GetAppDir(), SW_SHOWDEFAULT);
break;
case MP_HM_LINK2:
ShellExecute(NULL, NULL, thePrefs.GetHomepageBaseURL()+ CString(_T("/faq/")), NULL, thePrefs.GetAppDir(), SW_SHOWDEFAULT);
break;
case MP_HM_LINK3: {
CString theUrl;
theUrl.Format( thePrefs.GetVersionCheckBaseURL() + CString(_T("/en/version_check.php?version=%i&language=%i")),theApp.m_uCurVersionCheck,thePrefs.GetLanguageID());
ShellExecute(NULL, NULL, theUrl, NULL, thePrefs.GetAppDir(), SW_SHOWDEFAULT);
break;
}
case MP_WEBSVC_EDIT:
theWebServices.Edit();
break;
case MP_HM_CONVERTPF:
CPartFileConvert::ShowGUI();
break;
case MP_HM_SCHEDONOFF:
thePrefs.SetSchedulerEnabled(!thePrefs.IsSchedulerEnabled());
theApp.scheduler->Check(true);
break;
case MP_HM_1STSWIZARD:
extern BOOL FirstTimeWizard();
if (FirstTimeWizard()){
// start connection wizard
Wizard conWizard;
conWizard.DoModal();
}
break;
case MP_HM_IPFILTER:{
CIPFilterDlg dlg;
dlg.DoModal();
break;
}
case MP_HM_DIRECT_DOWNLOAD:{
CDirectDownloadDlg dlg;
dlg.DoModal();
break;
}
}
if (wParam>=MP_WEBURL && wParam<=MP_WEBURL+99) {
theWebServices.RunURL(NULL, wParam);
}
else if (wParam>=MP_SCHACTIONS && wParam<=MP_SCHACTIONS+99) {
theApp.scheduler->ActivateSchedule(wParam-MP_SCHACTIONS);
theApp.scheduler->SaveOriginals(); // use the new settings as original
}
return CTrayDialog::OnCommand(wParam, lParam);
}
LRESULT CemuleDlg::OnMenuChar(UINT nChar, UINT nFlags, CMenu* pMenu)
{
UINT nCmdID;
if (toolbar->MapAccelerator(nChar, &nCmdID)){
OnCommand(nCmdID, 0);
return MAKELONG(0,MNC_CLOSE);
}
return CTrayDialog::OnMenuChar(nChar, nFlags, pMenu);
}
BOOL CemuleDlg::OnQueryEndSession()
{
if (!CTrayDialog::OnQueryEndSession())
return FALSE;
return TRUE;
}
void CemuleDlg::OnEndSession(BOOL bEnding)
{
if (bEnding && theApp.m_app_state == APP_STATE_RUNNING)
{
theApp.m_app_state = APP_STATE_SHUTINGDOWN;
OnClose();
}
CTrayDialog::OnEndSession(bEnding);
}
// Barry - To find out if app is running or shutting/shut down
bool CemuleDlg::IsRunning()
{
return (theApp.m_app_state == APP_STATE_RUNNING);
}
void CemuleDlg::OnBnClickedHotmenu()
{
ShowToolPopup(false);
}
void CemuleDlg::ShowToolPopup(bool toolsonly)
{
POINT point;
::GetCursorPos(&point);
CTitleMenu menu;
menu.CreatePopupMenu();
if (!toolsonly)
menu.AddMenuTitle(GetResString(IDS_HOTMENU));
else
menu.AddMenuTitle(GetResString(IDS_TOOLS));
CMenu Links;
Links.CreateMenu();
Links.AppendMenu(MF_STRING,MP_HM_LINK1, GetResString(IDS_HM_LINKHP));
Links.AppendMenu(MF_STRING,MP_HM_LINK2, GetResString(IDS_HM_LINKFAQ));
Links.AppendMenu(MF_STRING,MP_HM_LINK3, GetResString(IDS_HM_LINKVC));
theWebServices.GetGeneralMenuEntries(Links);
Links.InsertMenu(3, MF_BYPOSITION | MF_SEPARATOR);
Links.AppendMenu(MF_STRING, MP_WEBSVC_EDIT, GetResString(IDS_WEBSVEDIT));
CMenu scheduler;
scheduler.CreateMenu();
CString schedonoff= (!thePrefs.IsSchedulerEnabled())?GetResString(IDS_HM_SCHED_ON):GetResString(IDS_HM_SCHED_OFF);
scheduler.AppendMenu(MF_STRING,MP_HM_SCHEDONOFF, schedonoff);
if (theApp.scheduler->GetCount()>0) {
scheduler.AppendMenu(MF_SEPARATOR);
for (int i=0; i<theApp.scheduler->GetCount();i++)
scheduler.AppendMenu(MF_STRING,MP_SCHACTIONS+i, theApp.scheduler->GetSchedule(i)->title );
}
if (!toolsonly) {
if (theApp.serverconnect->IsConnected())
menu.AppendMenu(MF_STRING,MP_HM_CON,GetResString(IDS_MAIN_BTN_DISCONNECT));
else if (theApp.serverconnect->IsConnecting())
menu.AppendMenu(MF_STRING,MP_HM_CON,GetResString(IDS_MAIN_BTN_CANCEL));
else
menu.AppendMenu(MF_STRING,MP_HM_CON,GetResString(IDS_MAIN_BTN_CONNECT));
menu.AppendMenu(MF_STRING,MP_HM_KAD, GetResString(IDS_EM_KADEMLIA) );
menu.AppendMenu(MF_STRING,MP_HM_SRVR, GetResString(IDS_EM_SERVER) );
menu.AppendMenu(MF_STRING,MP_HM_TRANSFER, GetResString(IDS_EM_TRANS));
menu.AppendMenu(MF_STRING,MP_HM_SEARCH, GetResString(IDS_EM_SEARCH));
menu.AppendMenu(MF_STRING,MP_HM_FILES, GetResString(IDS_EM_FILES));
menu.AppendMenu(MF_STRING,MP_HM_MSGS, GetResString(IDS_EM_MESSAGES));
menu.AppendMenu(MF_STRING,MP_HM_IRC, GetResString(IDS_IRC));
menu.AppendMenu(MF_STRING,MP_HM_STATS, GetResString(IDS_EM_STATISTIC));
menu.AppendMenu(MF_STRING,MP_HM_PREFS, GetResString(IDS_EM_PREFS));
menu.AppendMenu(MF_STRING,MP_HM_HELP, GetResString(IDS_EM_HELP));
menu.AppendMenu(MF_SEPARATOR);
}
menu.AppendMenu(MF_STRING,MP_HM_OPENINC, GetResString(IDS_OPENINC) + _T("..."));
menu.AppendMenu(MF_STRING,MP_HM_CONVERTPF, GetResString(IDS_IMPORTSPLPF) + _T("..."));
menu.AppendMenu(MF_STRING,MP_HM_1STSWIZARD, GetResString(IDS_WIZ1) + _T("..."));
menu.AppendMenu(MF_STRING,MP_HM_IPFILTER, GetResString(IDS_IPFILTER) + _T("..."));
menu.AppendMenu(MF_STRING,MP_HM_DIRECT_DOWNLOAD, GetResString(IDS_SW_DIRECTDOWNLOAD) + _T("..."));
men
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -