Removed redundant code

This commit is contained in:
Birunthan Mohanathas 2012-08-12 17:02:08 +03:00
parent 489f2c5a30
commit adeb73478b
3 changed files with 154 additions and 198 deletions

View File

@ -2554,14 +2554,7 @@ bool CMeterWindow::UpdateMeasure(CMeasure* measure, bool force)
if (measure->HasDynamicVariables() && if (measure->HasDynamicVariables() &&
(measure->GetUpdateCounter() + 1) >= updateDivider) (measure->GetUpdateCounter() + 1) >= updateDivider)
{ {
try measure->ReadOptions(m_Parser);
{
measure->ReadOptions(m_Parser);
}
catch (CError& error)
{
LogError(error);
}
} }
if (measure->Update()) if (measure->Update())
@ -2592,14 +2585,7 @@ bool CMeterWindow::UpdateMeter(CMeter* meter, bool& bActiveTransition, bool forc
if (meter->HasDynamicVariables() && if (meter->HasDynamicVariables() &&
(meter->GetUpdateCounter() + 1) >= updateDivider) (meter->GetUpdateCounter() + 1) >= updateDivider)
{ {
try meter->ReadOptions(m_Parser);
{
meter->ReadOptions(m_Parser);
}
catch (CError& error)
{
LogError(error);
}
} }
if (meter->Update()) if (meter->Update())
@ -3213,172 +3199,165 @@ LRESULT CMeterWindow::OnMouseLeave(UINT uMsg, WPARAM wParam, LPARAM lParam)
*/ */
LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT CMeterWindow::OnCommand(UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
try if (wParam == IDM_SKIN_EDITSKIN)
{ {
if (wParam == IDM_SKIN_EDITSKIN) Rainmeter->EditSkinFile(m_FolderPath, m_FileName);
{ }
Rainmeter->EditSkinFile(m_FolderPath, m_FileName); else if (wParam == IDM_SKIN_REFRESH)
} {
else if (wParam == IDM_SKIN_REFRESH) Refresh(false);
{ }
Refresh(false); else if (wParam == IDM_SKIN_OPENSKINSFOLDER)
} {
else if (wParam == IDM_SKIN_OPENSKINSFOLDER) Rainmeter->OpenSkinFolder(m_FolderPath);
{ }
Rainmeter->OpenSkinFolder(m_FolderPath); else if (wParam == IDM_SKIN_MANAGESKIN)
} {
else if (wParam == IDM_SKIN_MANAGESKIN) CDialogManage::OpenSkin(this);
{ }
CDialogManage::OpenSkin(this); else if (wParam == IDM_SKIN_VERYTOPMOST)
} {
else if (wParam == IDM_SKIN_VERYTOPMOST) SetWindowZPosition(ZPOSITION_ONTOPMOST);
{ }
SetWindowZPosition(ZPOSITION_ONTOPMOST); else if (wParam == IDM_SKIN_TOPMOST)
} {
else if (wParam == IDM_SKIN_TOPMOST) SetWindowZPosition(ZPOSITION_ONTOP);
{ }
SetWindowZPosition(ZPOSITION_ONTOP); else if (wParam == IDM_SKIN_BOTTOM)
} {
else if (wParam == IDM_SKIN_BOTTOM) SetWindowZPosition(ZPOSITION_ONBOTTOM);
{ }
SetWindowZPosition(ZPOSITION_ONBOTTOM); else if (wParam == IDM_SKIN_NORMAL)
} {
else if (wParam == IDM_SKIN_NORMAL) SetWindowZPosition(ZPOSITION_NORMAL);
{ }
SetWindowZPosition(ZPOSITION_NORMAL); else if (wParam == IDM_SKIN_ONDESKTOP)
} {
else if (wParam == IDM_SKIN_ONDESKTOP) SetWindowZPosition(ZPOSITION_ONDESKTOP);
{ }
SetWindowZPosition(ZPOSITION_ONDESKTOP); else if (wParam == IDM_SKIN_KEEPONSCREEN)
} {
else if (wParam == IDM_SKIN_KEEPONSCREEN) SetKeepOnScreen(!m_KeepOnScreen);
{ }
SetKeepOnScreen(!m_KeepOnScreen); else if (wParam == IDM_SKIN_CLICKTHROUGH)
} {
else if (wParam == IDM_SKIN_CLICKTHROUGH) SetClickThrough(!m_ClickThrough);
{ }
SetClickThrough(!m_ClickThrough); else if (wParam == IDM_SKIN_DRAGGABLE)
} {
else if (wParam == IDM_SKIN_DRAGGABLE) SetWindowDraggable(!m_WindowDraggable);
{ }
SetWindowDraggable(!m_WindowDraggable); else if (wParam == IDM_SKIN_HIDEONMOUSE)
} {
else if (wParam == IDM_SKIN_HIDEONMOUSE) SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_HIDE : HIDEMODE_NONE);
{ }
SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_HIDE : HIDEMODE_NONE); else if (wParam == IDM_SKIN_TRANSPARENCY_FADEIN)
} {
else if (wParam == IDM_SKIN_TRANSPARENCY_FADEIN) SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_FADEIN : HIDEMODE_NONE);
{ }
SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_FADEIN : HIDEMODE_NONE); else if (wParam == IDM_SKIN_TRANSPARENCY_FADEOUT)
} {
else if (wParam == IDM_SKIN_TRANSPARENCY_FADEOUT) SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_FADEOUT : HIDEMODE_NONE);
{ }
SetWindowHide((m_WindowHide == HIDEMODE_NONE) ? HIDEMODE_FADEOUT : HIDEMODE_NONE); else if (wParam == IDM_SKIN_REMEMBERPOSITION)
} {
else if (wParam == IDM_SKIN_REMEMBERPOSITION) SetSavePosition(!m_SavePosition);
{ }
SetSavePosition(!m_SavePosition); else if (wParam == IDM_SKIN_SNAPTOEDGES)
} {
else if (wParam == IDM_SKIN_SNAPTOEDGES) SetSnapEdges(!m_SnapEdges);
{ }
SetSnapEdges(!m_SnapEdges); else if (wParam >= IDM_SKIN_TRANSPARENCY_0 && wParam <= IDM_SKIN_TRANSPARENCY_90)
} {
else if (wParam >= IDM_SKIN_TRANSPARENCY_0 && wParam <= IDM_SKIN_TRANSPARENCY_90) m_AlphaValue = (int)(255.0 - (wParam - IDM_SKIN_TRANSPARENCY_0) * (230.0 / (IDM_SKIN_TRANSPARENCY_90 - IDM_SKIN_TRANSPARENCY_0)));
{ UpdateWindow(m_AlphaValue, false);
m_AlphaValue = (int)(255.0 - (wParam - IDM_SKIN_TRANSPARENCY_0) * (230.0 / (IDM_SKIN_TRANSPARENCY_90 - IDM_SKIN_TRANSPARENCY_0))); WriteOptions(OPTION_ALPHAVALUE);
UpdateWindow(m_AlphaValue, false); }
WriteOptions(OPTION_ALPHAVALUE); else if (wParam == IDM_CLOSESKIN)
} {
else if (wParam == IDM_CLOSESKIN) Rainmeter->DeactivateSkin(this, -1);
{ }
Rainmeter->DeactivateSkin(this, -1); else if (wParam == IDM_SKIN_FROMRIGHT)
} {
else if (wParam == IDM_SKIN_FROMRIGHT) m_WindowXFromRight = !m_WindowXFromRight;
{
m_WindowXFromRight = !m_WindowXFromRight;
ScreenToWindow(); ScreenToWindow();
WriteOptions(OPTION_POSITION); WriteOptions(OPTION_POSITION);
} }
else if (wParam == IDM_SKIN_FROMBOTTOM) else if (wParam == IDM_SKIN_FROMBOTTOM)
{
m_WindowYFromBottom = !m_WindowYFromBottom;
ScreenToWindow();
WriteOptions(OPTION_POSITION);
}
else if (wParam == IDM_SKIN_XPERCENTAGE)
{
m_WindowXPercentage = !m_WindowXPercentage;
ScreenToWindow();
WriteOptions(OPTION_POSITION);
}
else if (wParam == IDM_SKIN_YPERCENTAGE)
{
m_WindowYPercentage = !m_WindowYPercentage;
ScreenToWindow();
WriteOptions(OPTION_POSITION);
}
else if (wParam == IDM_SKIN_MONITOR_AUTOSELECT)
{
m_AutoSelectScreen = !m_AutoSelectScreen;
ScreenToWindow();
WriteOptions(OPTION_POSITION | OPTION_AUTOSELECTSCREEN);
}
else if (wParam == IDM_SKIN_MONITOR_PRIMARY || wParam >= ID_MONITOR_FIRST && wParam <= ID_MONITOR_LAST)
{
const MultiMonitorInfo& multimonInfo = CSystem::GetMultiMonitorInfo();
const std::vector<MonitorInfo>& monitors = multimonInfo.monitors;
int screenIndex;
bool screenDefined;
if (wParam == IDM_SKIN_MONITOR_PRIMARY)
{ {
m_WindowYFromBottom = !m_WindowYFromBottom; screenIndex = multimonInfo.primary;
screenDefined = false;
ScreenToWindow();
WriteOptions(OPTION_POSITION);
}
else if (wParam == IDM_SKIN_XPERCENTAGE)
{
m_WindowXPercentage = !m_WindowXPercentage;
ScreenToWindow();
WriteOptions(OPTION_POSITION);
}
else if (wParam == IDM_SKIN_YPERCENTAGE)
{
m_WindowYPercentage = !m_WindowYPercentage;
ScreenToWindow();
WriteOptions(OPTION_POSITION);
}
else if (wParam == IDM_SKIN_MONITOR_AUTOSELECT)
{
m_AutoSelectScreen = !m_AutoSelectScreen;
ScreenToWindow();
WriteOptions(OPTION_POSITION | OPTION_AUTOSELECTSCREEN);
}
else if (wParam == IDM_SKIN_MONITOR_PRIMARY || wParam >= ID_MONITOR_FIRST && wParam <= ID_MONITOR_LAST)
{
const MultiMonitorInfo& multimonInfo = CSystem::GetMultiMonitorInfo();
const std::vector<MonitorInfo>& monitors = multimonInfo.monitors;
int screenIndex;
bool screenDefined;
if (wParam == IDM_SKIN_MONITOR_PRIMARY)
{
screenIndex = multimonInfo.primary;
screenDefined = false;
}
else
{
screenIndex = (wParam & 0x0ffff) - ID_MONITOR_FIRST;
screenDefined = true;
}
if (screenIndex >= 0 && (screenIndex == 0 || screenIndex <= (int)monitors.size() && monitors[screenIndex-1].active))
{
if (m_AutoSelectScreen)
{
m_AutoSelectScreen = false;
}
m_WindowXScreen = m_WindowYScreen = screenIndex;
m_WindowXScreenDefined = m_WindowYScreenDefined = screenDefined;
m_Parser.ResetMonitorVariables(this); // Set present monitor variables
ScreenToWindow();
WriteOptions(OPTION_POSITION | OPTION_AUTOSELECTSCREEN);
}
} }
else else
{ {
// Forward to tray window, which handles all the other commands screenIndex = (wParam & 0x0ffff) - ID_MONITOR_FIRST;
HWND tray = Rainmeter->GetTrayWindow()->GetWindow(); screenDefined = true;
}
if (wParam == IDM_QUIT) if (screenIndex >= 0 && (screenIndex == 0 || screenIndex <= (int)monitors.size() && monitors[screenIndex-1].active))
{
if (m_AutoSelectScreen)
{ {
PostMessage(tray, WM_COMMAND, wParam, lParam); m_AutoSelectScreen = false;
}
else
{
SendMessage(tray, WM_COMMAND, wParam, lParam);
} }
m_WindowXScreen = m_WindowYScreen = screenIndex;
m_WindowXScreenDefined = m_WindowYScreenDefined = screenDefined;
m_Parser.ResetMonitorVariables(this); // Set present monitor variables
ScreenToWindow();
WriteOptions(OPTION_POSITION | OPTION_AUTOSELECTSCREEN);
} }
} }
catch (CError& error) else
{ {
LogError(error); // Forward to tray window, which handles all the other commands
HWND tray = Rainmeter->GetTrayWindow()->GetWindow();
if (wParam == IDM_QUIT)
{
PostMessage(tray, WM_COMMAND, wParam, lParam);
}
else
{
SendMessage(tray, WM_COMMAND, wParam, lParam);
}
} }
return 0; return 0;
@ -4339,14 +4318,7 @@ LRESULT CALLBACK CMeterWindow::InitialWndProc(HWND hWnd, UINT uMsg, WPARAM wPara
*/ */
LRESULT CMeterWindow::OnDelayedRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam) LRESULT CMeterWindow::OnDelayedRefresh(UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
try Refresh(false);
{
Refresh(false);
}
catch (CError& error)
{
LogError(error);
}
return 0; return 0;
} }

View File

@ -2479,14 +2479,7 @@ void CRainmeter::RefreshAll()
continue; continue;
} }
try mw->Refresh(false, true);
{
mw->Refresh(false, true);
}
catch (CError& error)
{
LogError(error);
}
} }
} }

View File

@ -364,19 +364,10 @@ void CTrayWindow::ReadOptions(CConfigParser& parser)
CConfigParser* oldParser = Rainmeter->GetCurrentParser(); CConfigParser* oldParser = Rainmeter->GetCurrentParser();
Rainmeter->SetCurrentParser(&parser); Rainmeter->SetCurrentParser(&parser);
try m_Measure = CMeasure::Create(measureName.c_str(), NULL, L"TrayMeasure");
if (m_Measure)
{ {
m_Measure = CMeasure::Create(measureName.c_str(), NULL, L"TrayMeasure"); m_Measure->ReadOptions(parser);
if (m_Measure)
{
m_Measure->ReadOptions(parser);
}
}
catch (CError& error)
{
delete m_Measure;
m_Measure = NULL;
LogError(error);
} }
Rainmeter->SetCurrentParser(oldParser); Rainmeter->SetCurrentParser(oldParser);