⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 resorgoptions.cpp

📁 ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - Manage and Renumber Resource Symbol IDs Introduction The
💻 CPP
📖 第 1 页 / 共 3 页
字号:

bool CResOrgOptions::EnableMailingListPrompt(bool bEnable)
{
	return UpdateBooleanOption(OPTION_MAILING_LIST_PROMPT, m_bAskAboutMailingList, bEnable);
}


bool CResOrgOptions::EnableVersionChecking(bool bEnable)
{
	return UpdateBooleanOption(OPTION_VERSION_CHECKING, m_bEnableVersionChecking, bEnable);
}


bool CResOrgOptions::CheckDevelopmentVersions(bool bCheck)
{
	return UpdateBooleanOption(OPTION_VERSION_CHECK_DEV, m_bCheckDevelopmentVersions, bCheck);
}


bool CResOrgOptions::IsVersionCheckDue(void) const
{
	bool bDue = false;

	if (m_bEnableVersionChecking)
	{
		if (m_nVersionCheckInterval > 0)
		{
			CTime timeNow = CTime::GetCurrentTime();

			CTimeSpan span(m_nVersionCheckInterval, 0, 0, 0);

			bDue = (timeNow >= m_timeLastUpdateCheck + span);
		}
		else
		{
			bDue = true;		// Interval = 0 => check every time we startup
		}
	}
	return bDue;
}


bool CResOrgOptions::DoVersionCheck(void)
{
	if (IsVersionCheckDue() )
	{
		StartVersionCheck(	true,
							AfxGetMainWnd(),
							WM_COMMAND,
							ID_RESORG_VERSION_CHECK);

		return true;
	}
	return false;
}


CResOrgVersionCheck* CResOrgOptions::StartVersionCheck(	bool bDisableDialupPrompt,
														CWnd* pNotifyTarget /*= NULL*/,
														UINT uMsg /*= 0*/,
														UINT uID /*= 0*/)
{
	if (NULL == m_pVersionChecker)
	{
		m_pVersionChecker = new CResOrgVersionCheck(bDisableDialupPrompt);
		ASSERT_VALID(m_pVersionChecker);
	}
	if ( (NULL != m_pVersionChecker) && !m_pVersionChecker->IsDownloading() )
	{
		m_pVersionChecker->SetNotifyTarget(	pNotifyTarget,
											uMsg,
											uID);

		CString sURL = Options.GetWebURL() + _T("/version.txt");

		m_pVersionChecker->StartDownload(sURL);
	}
	return m_pVersionChecker;
}


bool CResOrgOptions::IsVersionCheckRunning(void) const
{
	if ( (NULL != m_pVersionChecker) && m_pVersionChecker->IsDownloading() )
	{
		return true;
	}
	return false;
}


void CResOrgOptions::OnOptionChanged(const CString& sOption) const
{
	UINT uMsg = ::RegisterWindowMessage(sOption);
	ASSERT(uMsg > 0);
	
	CWnd* pWnd = AfxGetMainWnd();
	if (NULL != pWnd)
	{
		AfxGetMainWnd()->PostMessage(uMsg, 0, 0L);
	}
}


DWORD CResOrgOptions::OnVersionCheckCompleted(bool bCheckDevelopmentVersions /*= false*/,
											  bool bPromptAlways /*= false*/)
{
	DWORD dwErrorCode = ERROR_INTERNET_CANNOT_CONNECT;

	if (NULL != m_pVersionChecker)
	{
		dwErrorCode = m_pVersionChecker->GetErrorCode();

		if (ERROR_SUCCESS == dwErrorCode)
		{
			m_timeLastUpdateCheck  = CTime::GetCurrentTime();

			::AfxGetApp()->WriteProfileInt(	OPTIONS,
											OPTION_LAST_UPDATE_CHECK,
											(int)m_timeLastUpdateCheck.GetTime());

			// Update website URLs
			UpdateURLs();

			CNGModuleVersion ver;
			ver.GetFileVersionInfo();

			CString sCurrentVer = ver.GetValue( _T("FileVersion") );

			int nCompareVersionsRelease		= 0;
			int nCompareVersionsDevelopment	= 0;

			if (bCheckDevelopmentVersions)
			{
				nCompareVersionsDevelopment = m_pVersionChecker->CompareVersions(VER_CHECK_SECTION_DEV, sCurrentVer);

			}
			if (nCompareVersionsDevelopment <= 0)
			{
				nCompareVersionsRelease = m_pVersionChecker->CompareVersions(VER_CHECK_SECTION_RELEASE, sCurrentVer);

			}
			if ( (nCompareVersionsDevelopment > 0) || (nCompareVersionsRelease > 0) )
			{
				// A newer version is available - either development or release
				bool bIsDevVersion		= (nCompareVersionsDevelopment > 0);

				CString sSection		= bIsDevVersion ? VER_CHECK_SECTION_DEV : VER_CHECK_SECTION_RELEASE;

				CString sVersion		= m_pVersionChecker->GetValue(	sSection,
																		_T("Version") );

				CString sDescription	= m_pVersionChecker->GetValue(	sSection,
																		_T("Description") );

				CString sDownLoadUrl	= m_pVersionChecker->GetValue(	sSection,
																		_T("Downloads") );

				CNGMessageBox dlg;
				dlg.FormatMsgEx(MAKEINTRESOURCE(IDS_RESORG_UPDATED),
								_T("RTF"),
								sVersion,
								sDescription);

				dlg.SetRtf();
				dlg.SetTitle(bIsDevVersion ? IDP_RESORG_NEW_DEV_VER : IDP_RESORG_NEW_VER);
				dlg.SetStandardIcon(IDI_INFORMATION);
				dlg.AddButton(IDYES,	false, false,	_T("&Yes") );
				dlg.AddButton(IDNO,		true, true,		_T("&No") );

				if (IDYES == dlg.DoModal())
				{
					::ShellExecute(	GetDesktopWindow(),
									_T("open"),
									sDownLoadUrl,
									NULL,
									NULL,
									SW_SHOWNORMAL);
				}
			}
			else if (bPromptAlways)
			{

				#ifdef _RESORG_EXPIRY_DATE
					CString sBuildType = _T("development ");
				#else
					CString sBuildType;
				#endif

				if ( (0 == nCompareVersionsDevelopment) && (0 == nCompareVersionsRelease) )
				{
					CNGMessageBox dlg;
					dlg.SetTitle(_T("Version up to date") );

					dlg.FormatMsg(IDP_RESORG_VER_LATEST_INSTALLED);
					
					dlg.SetStandardIcon(IDI_INFORMATION);
					dlg.AddButton(IDOK,		true, true,		_T("OK") );
					
					dlg.DoModal();
				}
				else if (nCompareVersionsDevelopment < 0)
				{
					CNGMessageBox dlg;
					dlg.SetTitle(_T("Version more than up to date") );

					CString sCurrentVersion = m_pVersionChecker->GetValue(VER_CHECK_SECTION_DEV, _T("Version") );

					if (sCurrentVersion.IsEmpty() )
					{
						sCurrentVersion = m_pVersionChecker->GetValue(VER_CHECK_SECTION_RELEASE, _T("Version") );
					}

					dlg.FormatMsg(_T("Congratulations! This %sversion of ResOrg (%s) is newer than the current released version (%s)"),
									sBuildType,
									sCurrentVer,
									sCurrentVersion);


					dlg.SetStandardIcon(IDI_EXCLAMATION);
					dlg.AddButton(IDOK,		true, true,		_T("OK") );
					
					dlg.DoModal();
				}
				else if (nCompareVersionsRelease < 0)
				{
					CNGMessageBox dlg;
					dlg.SetTitle(_T("Version up to date") );

					dlg.FormatMsg(_T("This %sversion of ResOrg (%s) is newer than the current released version (%s)"),
									sBuildType,
									sCurrentVer,
									m_pVersionChecker->GetValue(VER_CHECK_SECTION_RELEASE, _T("Version") ) );


					dlg.SetStandardIcon(IDI_INFORMATION);
					dlg.AddButton(IDOK,		true, true,		_T("OK") );
					
					dlg.DoModal();
				}
			}
		}

		delete m_pVersionChecker;
		m_pVersionChecker = NULL;
	}
	return dwErrorCode;
}


bool CResOrgOptions::OnExit(void)
{
	// If a version check is running, Wait until it finishes
	// before exiting (by now the main window has gone)
	while (IsVersionCheckRunning()) { Sleep(100); }

	return true;
}


/////////////////////////////////////////////////////////////////////////////
// Implementation

bool CResOrgOptions::UpdateBooleanOption(const CString& sOptionName,
										 bool& rbMemberVar,
										 bool bNewValue)
{
	if (bNewValue != rbMemberVar)
	{
		rbMemberVar = bNewValue;

		::AfxGetApp()->WriteProfileInt(	OPTIONS,
										sOptionName,
										rbMemberVar);

		OnOptionChanged(sOptionName);

		return true;
	}
	return false;
}


void CResOrgOptions::OnCmdResOrgUpdateCheckCompleted(void)
{
	OnVersionCheckCompleted(m_bCheckDevelopmentVersions);
}


bool CResOrgOptions::UpdateURLs(void)
{
	if (NULL != m_pVersionChecker)
	{
		CString sSection			= VER_CHECK_SECTION_RELEASE;

		CString sWebURL				= m_pVersionChecker->GetValue(	sSection,
																	_T("WebSite") );

		CString sEmailURL			= m_pVersionChecker->GetValue(	sSection,
																	_T("Email") );

		CString sFaqURL				= m_pVersionChecker->GetValue(	sSection,
																	_T("FAQ") );

		CString sDiscussionBoardURL	= m_pVersionChecker->GetValue(	sSection,
																	_T("DiscussionBoard") );

		CString sKnownBugsURL		= m_pVersionChecker->GetValue(	sSection,
																	_T("KnownBugs") );

		CString	sMailingListURL		= m_pVersionChecker->GetValue(	sSection,
																	_T("MailingList") );

		CString	sAboutMeURL			= m_pVersionChecker->GetValue(	sSection,
																	_T("AboutMe") );

		if (!sWebURL.IsEmpty() )
		{
			// Only set the website URL if we get one
			// (I'm being extra careful with this one!)
			SetWebURL(sWebURL);
		}
		
		if (!sEmailURL.IsEmpty() )
		{
			// Only set the website URL if we get one
			// (I'm being extra careful with this one!)
			SetEmailURL(sEmailURL);
		}

		SetFaqURL(sFaqURL);
		SetDiscussionBoardURL(sDiscussionBoardURL);
		SetKnownBugsURL(sKnownBugsURL);
		SetMailingListURL(sMailingListURL);
		if (!sAboutMeURL.IsEmpty() )
		{
			SetAboutMeURL(sAboutMeURL);
		}

		return true;
	}
	return false;
}


bool CResOrgOptions::IsFixedSymbol(const CString& sSymbolName)
{
	if (m_setFixedSymbols.find(sSymbolName) != m_setFixedSymbols.end() )
	{
		return true;
	}
	return false;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -