/* ** Read the options specified in the ini file. ** */ void CMeterImage::ReadOptions(CConfigParser& parser, const WCHAR* section) { CMeter::ReadOptions(parser, section); m_Path = parser.ReadString(section, L"Path", L""); if (!m_Path.empty()) { if (!CSystem::IsPathSeparator(m_Path[m_Path.length() - 1])) { m_Path += L'\\'; } } m_ImageName = parser.ReadString(section, L"ImageName", L""); m_PreserveAspectRatio = 0!=parser.ReadInt(section, L"PreserveAspectRatio", 0); m_Tile = 0!=parser.ReadInt(section, L"Tile", 0); static const RECT defMargins = {0}; m_ScaleMargins = parser.ReadRECT(section, L"ScaleMargins", defMargins); // Read tinting options m_Image.ReadOptions(parser, section); if (m_Initialized && m_Measures.empty() && !m_DynamicVariables) { Initialize(); m_NeedsRedraw = true; } }
/* ** Read the options specified in the ini file. ** */ void CMeasureCalc::ReadOptions(CConfigParser& parser, const WCHAR* section) { CMeasure::ReadOptions(parser, section); // Store the current values so we know if the value needs to be updated int oldLowBound = m_LowBound; int oldHighBound = m_HighBound; bool oldUpdateRandom = m_UpdateRandom; std::wstring oldFormula = m_Formula; m_Formula = parser.ReadString(section, L"Formula", L""); m_LowBound = parser.ReadInt(section, L"LowBound", 0); m_HighBound = parser.ReadInt(section, L"HighBound", 100); m_UpdateRandom = 0!=parser.ReadInt(section, L"UpdateRandom", 0); if (!m_Initialized || wcscmp(m_Formula.c_str(), oldFormula.c_str()) != 0 || oldLowBound != m_LowBound || oldHighBound != m_HighBound || oldUpdateRandom != m_UpdateRandom) { if (!m_UpdateRandom) { FormulaReplace(); } const WCHAR* errMsg = MathParser::Check(m_Formula.c_str()); if (errMsg != NULL) { LogWithArgs(LOG_ERROR, L"Calc: %s in [%s]", errMsg, m_Name.c_str()); m_Formula.clear(); } } }
/* ** Read the options specified in the ini file. ** */ void CMeterBar::ReadOptions(CConfigParser& parser, const WCHAR* section) { // Store the current values so we know if the image needs to be updated std::wstring oldImageName = m_ImageName; int oldW = m_W; int oldH = m_H; CMeter::ReadOptions(parser, section); m_Color = parser.ReadColor(section, L"BarColor", Color::Green); m_ImageName = parser.ReadString(section, L"BarImage", L""); if (!m_ImageName.empty()) { m_MeterWindow->MakePathAbsolute(m_ImageName); // Read tinting options m_Image.ReadOptions(parser, section); } else { m_Image.ClearOptionFlags(); } m_Border = parser.ReadInt(section, L"BarBorder", 0); m_Flip = 0!=parser.ReadInt(section, L"Flip", 0); const WCHAR* orientation = parser.ReadString(section, L"BarOrientation", L"VERTICAL").c_str(); if (_wcsicmp(L"VERTICAL", orientation) == 0) { m_Orientation = VERTICAL; } else if (_wcsicmp(L"HORIZONTAL", orientation) == 0) { m_Orientation = HORIZONTAL; } else { LogWithArgs(LOG_ERROR, L"BarOrientation=%s is not valid in [%s]", orientation, m_Name.c_str()); } if (m_Initialized) { m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0); if (m_NeedsReload || m_Image.IsOptionsChanged()) { Initialize(); // Reload the image } else if (!m_ImageName.empty()) { // Reset to old dimensions m_W = oldW; m_H = oldH; } } }
/* ** Read the options specified in the ini file. ** */ void CMeasureNet::ReadOptions(CConfigParser& parser, const WCHAR* section) { CMeasure::ReadOptions(parser, section); double value; const WCHAR* netName = NULL; if (m_Net == NET_IN) { netName = L"NetInSpeed"; value = Rainmeter->GetGlobalOptions().netInSpeed; } else if (m_Net == NET_OUT) { netName = L"NetOutSpeed"; value = Rainmeter->GetGlobalOptions().netOutSpeed; } else // if (m_Net == NET_TOTAL) { netName = L"NetTotalSpeed"; value = Rainmeter->GetGlobalOptions().netInSpeed + Rainmeter->GetGlobalOptions().netOutSpeed; } double maxValue = parser.ReadFloat(section, L"MaxValue", -1); if (maxValue == -1) { maxValue = parser.ReadFloat(section, netName, -1); if (maxValue == -1) { maxValue = value; } } m_Interface = parser.ReadInt(section, L"Interface", 0); m_Cumulative = 0!=parser.ReadInt(section, L"Cumulative", 0); if (m_Cumulative) { Rainmeter->SetNetworkStatisticsTimer(); } if (maxValue == 0.0) { if (!m_LogMaxValue) { m_MaxValue = 1.0; m_LogMaxValue = true; m_MedianValues.clear(); } } else { m_MaxValue = maxValue / 8; m_LogMaxValue = false; } }
/* ** Read the options specified in the ini file. Base implementation for In/Out/Total. ** */ void CMeasureNet::ReadOptions(CConfigParser& parser, const WCHAR* section, NET net) { double value; const WCHAR* netName = NULL; if (net == NET_IN) { netName = L"NetInSpeed"; value = Rainmeter->GetGlobalOptions().netInSpeed; } else if (net == NET_OUT) { netName = L"NetOutSpeed"; value = Rainmeter->GetGlobalOptions().netOutSpeed; } else { netName = L"NetTotalSpeed"; value = Rainmeter->GetGlobalOptions().netInSpeed + Rainmeter->GetGlobalOptions().netOutSpeed; } double maxValue = parser.ReadFloat(section, L"MaxValue", -1); if (maxValue == -1) { maxValue = parser.ReadFloat(section, netName, -1); if (maxValue == -1) { maxValue = value; } } m_Interface = parser.ReadInt(section, L"Interface", 0); m_Cumulative = 0!=parser.ReadInt(section, L"Cumulative", 0); if (m_Cumulative) { Rainmeter->SetNetworkStatisticsTimer(); } m_TrafficValue = parser.ReadFloat(section, L"TrafficValue", 0.0); m_TrafficAction = parser.ReadString(section, L"TrafficAction", L"", false); if (maxValue == 0) { m_MaxValue = 1; m_LogMaxValue = true; } else { m_MaxValue = maxValue / 8; } }
/* ** Read the options specified in the ini file. ** */ void CMeterImage::ReadOptions(CConfigParser& parser, const WCHAR* section) { CMeter::ReadOptions(parser, section); m_Path = parser.ReadString(section, L"Path", L""); if (!m_Path.empty()) { if (!CSystem::IsPathSeparator(m_Path[m_Path.length() - 1])) { m_Path += L'\\'; } } m_ImageName = parser.ReadString(section, L"ImageName", L""); int mode = parser.ReadInt(section, L"Tile", 0); if (mode != 0) { m_DrawMode = DRAWMODE_TILE; } else { mode = parser.ReadInt(section, L"PreserveAspectRatio", 0); switch (mode) { case 0: m_DrawMode = DRAWMODE_NONE; break; case 1: default: m_DrawMode = DRAWMODE_KEEPRATIO; break; case 2: m_DrawMode = DRAWMODE_KEEPRATIOANDCROP; break; } } static const RECT defMargins = {0}; m_ScaleMargins = parser.ReadRECT(section, L"ScaleMargins", defMargins); // Read tinting options m_Image.ReadOptions(parser, section); if (m_Initialized && m_Measures.empty() && !m_DynamicVariables) { Initialize(); m_NeedsRedraw = true; } }
/* ** Read the options specified in the ini file. ** */ void CMeasureTime::ReadOptions(CConfigParser& parser, const WCHAR* section) { CMeasure::ReadOptions(parser, section); m_Format = parser.ReadString(section, L"Format", L""); const WCHAR* timezone = parser.ReadString(section, L"TimeZone", L"local").c_str(); if (_wcsicmp(L"local", timezone) == 0) { SYSTEMTIME sysLocalTime, sysUTCTime; GetLocalTime(&sysLocalTime); GetSystemTime(&sysUTCTime); FILETIME ftLocalTime, ftUTCTime; SystemTimeToFileTime(&sysLocalTime, &ftLocalTime); SystemTimeToFileTime(&sysUTCTime, &ftUTCTime); LARGE_INTEGER largeInt1, largeInt2; largeInt1.HighPart = ftLocalTime.dwHighDateTime; largeInt1.LowPart = ftLocalTime.dwLowDateTime; largeInt2.HighPart = ftUTCTime.dwHighDateTime; largeInt2.LowPart = ftUTCTime.dwLowDateTime; m_DeltaTime.QuadPart = largeInt1.QuadPart - largeInt2.QuadPart; } else { double zone = wcstod(timezone, NULL); bool dst = 1 == parser.ReadInt(section, L"DaylightSavingTime", 1); struct tm* today; time_t now; time(&now); today = localtime(&now); if (dst && today->tm_isdst) { // Add DST TIME_ZONE_INFORMATION tzi; GetTimeZoneInformation(&tzi); m_DeltaTime.QuadPart = (LONGLONG)((zone * 3600) - tzi.DaylightBias * 60) * 10000000; } else { m_DeltaTime.QuadPart = (LONGLONG)(zone * 3600) * 10000000; } } if (!m_Initialized) { // Initialize m_Time to avoid causing EINVAL in TimeToString() until calling UpdateValue() FillCurrentTime(); } }
/* ** Read the options specified in the ini file. ** */ void CMeasureVirtualMemory::ReadOptions(CConfigParser& parser, const WCHAR* section) { CMeasure::ReadOptions(parser, section); m_Total = (1 == parser.ReadInt(section, L"Total", 0)); MEMORYSTATUSEX stat; stat.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&stat); m_MaxValue = (double)(__int64)stat.ullTotalPageFile; }
/* ** Read the options specified in the ini file. ** */ void CMeterRotator::ReadOptions(CConfigParser& parser, const WCHAR* section) { // Store the current values so we know if the image needs to be updated std::wstring oldImageName = m_ImageName; CMeter::ReadOptions(parser, section); m_ImageName = parser.ReadString(section, L"ImageName", L""); if (!m_ImageName.empty()) { m_MeterWindow->MakePathAbsolute(m_ImageName); // Read tinting options m_Image.ReadOptions(parser, section); } else { m_Image.ClearOptionFlags(); } m_OffsetX = parser.ReadFloat(section, L"OffsetX", 0.0); m_OffsetY = parser.ReadFloat(section, L"OffsetY", 0.0); m_StartAngle = parser.ReadFloat(section, L"StartAngle", 0.0); m_RotationAngle = parser.ReadFloat(section, L"RotationAngle", 6.2832); m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo m_ValueRemainder = parser.ReadInt(section, L"ValueRemainder", m_ValueRemainder); if (m_Initialized) { m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0); if (m_NeedsReload || m_Image.IsOptionsChanged()) { Initialize(); // Reload the image } } }
/* ** Read the options specified in the ini file. ** */ void CMeasureUptime::ReadOptions(CConfigParser& parser, const WCHAR* section) { CMeasure::ReadOptions(parser, section); m_Format = parser.ReadString(section, L"Format", L"%4!i!d %3!i!:%2!02i!"); if (m_Format.find(L"%4") == std::wstring::npos) { m_AddDaysToHours = 0!=parser.ReadInt(section, L"AddDaysToHours", 1); } else { m_AddDaysToHours = false; } }
/* ** Reads the measure specific configs. ** */ void CMeasureCPU::ReadConfig(CConfigParser& parser, const WCHAR* section) { CMeasure::ReadConfig(parser, section); int processor = parser.ReadInt(section, L"Processor", 0); if (processor < 0 || processor > c_NumOfProcessors) { LogWithArgs(LOG_WARNING, L"CPU: Processor=%i invalid in [%s]", m_Processor, section); processor = 0; } if (processor != m_Processor) { m_Processor = processor; m_OldTime[0] = m_OldTime[1] = 0.0; } }
/* ** Reads statistics. ** */ void CMeasureNet::ReadStats(const WCHAR* iniFile, std::wstring& statsDate) { WCHAR buffer[64]; CConfigParser parser; parser.Initialize(iniFile, NULL, NULL, L"Statistics"); const std::wstring& date = parser.ReadString(L"Statistics", L"Since", L"", false); if (!date.empty()) { statsDate = date; } int count = parser.ReadInt(L"Statistics", L"NetStatsCount", 0); c_StatValues.clear(); c_StatValues.reserve(count * 2); for (int i = 1; i <= count; ++i) { ULARGE_INTEGER value; _snwprintf_s(buffer, _TRUNCATE, L"NetStatsInHigh%i", i); value.HighPart = parser.ReadUInt(L"Statistics", buffer, 0); _snwprintf_s(buffer, _TRUNCATE, L"NetStatsInLow%i", i); value.LowPart = parser.ReadUInt(L"Statistics", buffer, 0); c_StatValues.push_back(value.QuadPart); _snwprintf_s(buffer, _TRUNCATE, L"NetStatsOutHigh%i", i); value.HighPart = parser.ReadUInt(L"Statistics", buffer, 0); _snwprintf_s(buffer, _TRUNCATE, L"NetStatsOutLow%i", i); value.LowPart = parser.ReadUInt(L"Statistics", buffer, 0); c_StatValues.push_back(value.QuadPart); } }
/* ** Read the options specified in the ini file. ** */ void CMeterRoundLine::ReadOptions(CConfigParser& parser, const WCHAR* section) { CMeter::ReadOptions(parser, section); m_LineWidth = parser.ReadFloat(section, L"LineWidth", 1.0); m_LineLength = parser.ReadFloat(section, L"LineLength", 20.0); m_LineStart = parser.ReadFloat(section, L"LineStart", -1.0); m_StartAngle = parser.ReadFloat(section, L"StartAngle", 0.0); m_RotationAngle = parser.ReadFloat(section, L"RotationAngle", 6.2832); m_ValueRemainder = parser.ReadInt(section, L"ValueReminder", 0); // Typo m_ValueRemainder = parser.ReadInt(section, L"ValueRemainder", m_ValueRemainder); m_LineColor = parser.ReadColor(section, L"LineColor", Color::Black); m_Solid = 0!=parser.ReadInt(section, L"Solid", 0); m_CntrlAngle = 0!=parser.ReadInt(section, L"ControlAngle", 1); m_CntrlLineStart = 0!=parser.ReadInt(section, L"ControlStart", 0); m_CntrlLineLength = 0!=parser.ReadInt(section, L"ControlLength", 0); m_LineStartShift = parser.ReadFloat(section, L"StartShift", 0.0); m_LineLengthShift = parser.ReadFloat(section, L"LengthShift", 0.0); }
/* ** Read the options specified in the ini file. ** */ void CMeterLine::ReadOptions(CConfigParser& parser, const WCHAR* section) { WCHAR tmpName[64]; // Store the current number of lines so we know if the buffer needs to be updated int oldLineCount = (int)m_Colors.size(); int oldW = m_W; CMeter::ReadOptions(parser, section); int lineCount = parser.ReadInt(section, L"LineCount", 1); m_Colors.clear(); m_ScaleValues.clear(); for (int i = 0; i < lineCount; ++i) { if (i == 0) { wcsncpy_s(tmpName, L"LineColor", _TRUNCATE); } else { _snwprintf_s(tmpName, _TRUNCATE, L"LineColor%i", i + 1); } m_Colors.push_back(parser.ReadColor(section, tmpName, Color::White)); if (i == 0) { wcsncpy_s(tmpName, L"Scale", _TRUNCATE); } else { _snwprintf_s(tmpName, _TRUNCATE, L"Scale%i", i + 1); } m_ScaleValues.push_back(parser.ReadFloat(section, tmpName, 1.0)); if (!m_Initialized && !m_MeasureName.empty()) { if (i != 0) { _snwprintf_s(tmpName, _TRUNCATE, L"MeasureName%i", i + 1); m_MeasureNames.push_back(parser.ReadString(section, tmpName, L"")); } } } m_Flip = 0!=parser.ReadInt(section, L"Flip", 0); m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0); m_LineWidth = parser.ReadFloat(section, L"LineWidth", 1.0); m_HorizontalLines = 0!=parser.ReadInt(section, L"HorizontalLines", 0); ARGB color = parser.ReadColor(section, L"HorizontalColor", Color::Black); // This is left here for backwards compatibility m_HorizontalColor = parser.ReadColor(section, L"HorizontalLineColor", color); // This is what it should be if (m_Initialized && (oldLineCount != lineCount || oldW != m_W)) { Initialize(); } const WCHAR* graph = parser.ReadString(section, L"GraphStart", L"RIGHT").c_str(); if (_wcsicmp(graph, L"RIGHT") == 0) { m_GraphStartLeft = false; } else if (_wcsicmp(graph, L"LEFT") == 0) { m_GraphStartLeft = true; } else { LogWithArgs(LOG_ERROR, L"StartFrom=%s is not valid in [%s]", graph, m_Name.c_str()); } graph = parser.ReadString(section, L"GraphOrientation", L"VERTICAL").c_str(); if (_wcsicmp(graph, L"VERTICAL") == 0) { // Restart graph if (m_GraphHorizontalOrientation) { m_GraphHorizontalOrientation = false; m_AllValues.clear(); Initialize(); m_CurrentPos = 0; } else { m_GraphHorizontalOrientation = false; } } else if (_wcsicmp(graph, L"HORIZONTAL") == 0) { // Restart graph if (!m_GraphHorizontalOrientation) { m_GraphHorizontalOrientation = true; m_AllValues.clear(); Initialize(); m_CurrentPos = 0; } else { m_GraphHorizontalOrientation = true; } } else { LogWithArgs(LOG_ERROR, L"GraphOrientation=%s is not valid in [%s]", graph, m_Name.c_str()); } }
void CMouse::ReadOptions(CConfigParser& parser, const WCHAR* section, CMeterWindow* meterWindow) { DestroyCustomCursor(); m_LeftDownAction = parser.ReadString(section, L"LeftMouseDownAction", L"", false); m_RightDownAction = parser.ReadString(section, L"RightMouseDownAction", L"", false); m_MiddleDownAction = parser.ReadString(section, L"MiddleMouseDownAction", L"", false); m_X1DownAction = parser.ReadString(section, L"X1MouseDownAction", L"", false); m_X2DownAction = parser.ReadString(section, L"X2MouseDownAction", L"", false); m_LeftUpAction = parser.ReadString(section, L"LeftMouseUpAction", L"", false); m_RightUpAction = parser.ReadString(section, L"RightMouseUpAction", L"", false); m_MiddleUpAction = parser.ReadString(section, L"MiddleMouseUpAction", L"", false); m_X1UpAction = parser.ReadString(section, L"X1MouseUpAction", L"", false); m_X2UpAction = parser.ReadString(section, L"X2MouseUpAction", L"", false); m_LeftDoubleClickAction = parser.ReadString(section, L"LeftMouseDoubleClickAction", L"", false); m_RightDoubleClickAction = parser.ReadString(section, L"RightMouseDoubleClickAction", L"", false); m_MiddleDoubleClickAction = parser.ReadString(section, L"MiddleMouseDoubleClickAction", L"", false); m_X1DoubleClickAction = parser.ReadString(section, L"X1MouseDoubleClickAction", L"", false); m_X2DoubleClickAction = parser.ReadString(section, L"X2MouseDoubleClickAction", L"", false); m_OverAction = parser.ReadString(section, L"MouseOverAction", L"", false); m_LeaveAction = parser.ReadString(section, L"MouseLeaveAction", L"", false); m_MouseScrollDownAction = parser.ReadString(section, L"MouseScrollDownAction", L"", false); m_MouseScrollUpAction = parser.ReadString(section, L"MouseScrollUpAction", L"", false); m_MouseScrollLeftAction = parser.ReadString(section, L"MouseScrollLeftAction", L"", false); m_MouseScrollRightAction = parser.ReadString(section, L"MouseScrollRightAction", L"", false); if (!m_MouseScrollDownAction.empty() || !m_MouseScrollUpAction.empty() || !m_MouseScrollLeftAction.empty() || !m_MouseScrollRightAction.empty()) { meterWindow->SetHasMouseScrollAction(); } const bool defaultState = (section == L"Rainmeter") ? true : meterWindow->GetMouse().GetCursorState(); m_CursorState = 0!=parser.ReadInt(section, L"MouseActionCursor", defaultState); const WCHAR* defaultMouseCursor = (section == L"Rainmeter") ? L"HAND" : L""; const WCHAR* mouseCursor = parser.ReadString(section, L"MouseActionCursorName", defaultMouseCursor).c_str(); if (_wcsicmp(mouseCursor, L"HAND") == 0) { m_CursorType = MOUSECURSOR_HAND; } else if (_wcsicmp(mouseCursor, L"TEXT") == 0) { m_CursorType = MOUSECURSOR_TEXT; } else if (_wcsicmp(mouseCursor, L"HELP") == 0) { m_CursorType = MOUSECURSOR_HELP; } else if (_wcsicmp(mouseCursor, L"BUSY") == 0) { m_CursorType = MOUSECURSOR_BUSY; } else if (_wcsicmp(mouseCursor, L"CROSS") == 0) { m_CursorType = MOUSECURSOR_CROSS; } else if (_wcsicmp(mouseCursor, L"PEN") == 0) { m_CursorType = MOUSECURSOR_PEN; } else if (wcschr(mouseCursor, L'.')) { m_CursorType = MOUSECURSOR_CUSTOM; } else { // Inherit from [Rainmeter]. m_CursorType = meterWindow->GetMouse().GetCursorType(); if (m_CursorType == MOUSECURSOR_CUSTOM) { mouseCursor = meterWindow->GetParser().ReadString(L"Rainmeter", L"MouseActionCursorName", L"").c_str(); } } if (m_CursorType == MOUSECURSOR_CUSTOM) { std::wstring cursorPath = meterWindow->GetResourcesPath(); cursorPath += L"Cursors\\"; cursorPath += mouseCursor; m_CustomCursor = LoadCursorFromFile(cursorPath.c_str()); if (!m_CustomCursor) { m_CursorType = MOUSECURSOR_ARROW; LogWithArgs(LOG_ERROR, L"Invalid cursor: %s", cursorPath.c_str()); } } }
/* ** Read the options specified in the ini file. ** */ void CMeterHistogram::ReadOptions(CConfigParser& parser, const WCHAR* section) { // Store the current values so we know if the image needs to be updated std::wstring oldPrimaryImageName = m_PrimaryImageName; std::wstring oldSecondaryImageName = m_SecondaryImageName; std::wstring oldBothImageName = m_OverlapImageName; int oldW = m_W; int oldH = m_H; bool oldGraphHorizontalOrientation = m_GraphHorizontalOrientation; CMeter::ReadOptions(parser, section); m_PrimaryColor = parser.ReadColor(section, L"PrimaryColor", Color::Green); m_SecondaryColor = parser.ReadColor(section, L"SecondaryColor", Color::Red); m_OverlapColor = parser.ReadColor(section, L"BothColor", Color::Yellow); m_PrimaryImageName = parser.ReadString(section, L"PrimaryImage", L""); if (!m_PrimaryImageName.empty()) { m_MeterWindow->MakePathAbsolute(m_PrimaryImageName); // Read tinting options m_PrimaryImage.ReadOptions(parser, section); } else { m_PrimaryImage.ClearOptionFlags(); } m_SecondaryImageName = parser.ReadString(section, L"SecondaryImage", L""); if (!m_SecondaryImageName.empty()) { m_MeterWindow->MakePathAbsolute(m_SecondaryImageName); // Read tinting options m_SecondaryImage.ReadOptions(parser, section); } else { m_SecondaryImage.ClearOptionFlags(); } m_OverlapImageName = parser.ReadString(section, L"BothImage", L""); if (!m_OverlapImageName.empty()) { m_MeterWindow->MakePathAbsolute(m_OverlapImageName); // Read tinting options m_OverlapImage.ReadOptions(parser, section); } else { m_OverlapImage.ClearOptionFlags(); } m_Autoscale = 0!=parser.ReadInt(section, L"AutoScale", 0); m_Flip = 0!=parser.ReadInt(section, L"Flip", 0); const WCHAR* graph = parser.ReadString(section, L"GraphStart", L"RIGHT").c_str(); if (_wcsicmp(graph, L"RIGHT") == 0) { m_GraphStartLeft = false; } else if (_wcsicmp(graph, L"LEFT") == 0) { m_GraphStartLeft = true; } else { LogWithArgs(LOG_ERROR, L"GraphStart=%s is not valid in [%s]", graph, m_Name.c_str()); } graph = parser.ReadString(section, L"GraphOrientation", L"VERTICAL").c_str(); if (_wcsicmp(graph, L"VERTICAL") == 0) { m_GraphHorizontalOrientation = false; } else if (_wcsicmp(graph, L"HORIZONTAL") == 0) { m_GraphHorizontalOrientation = true; } else { LogWithArgs(LOG_ERROR, L"GraphOrientation=%s is not valid in [%s]", graph, m_Name.c_str()); } if (m_Initialized) { if (m_PrimaryImageName.empty()) { int oldSize = oldGraphHorizontalOrientation ? oldH : oldW; int maxSize = m_GraphHorizontalOrientation ? m_H : m_W; if (oldSize != maxSize || oldGraphHorizontalOrientation != m_GraphHorizontalOrientation) { m_SizeChanged = true; Initialize(); // Reload the image } } else { // Reset to old dimensions m_W = oldW; m_H = oldH; m_PrimaryNeedsReload = (wcscmp(oldPrimaryImageName.c_str(), m_PrimaryImageName.c_str()) != 0); m_SecondaryNeedsReload = (wcscmp(oldSecondaryImageName.c_str(), m_SecondaryImageName.c_str()) != 0); m_OverlapNeedsReload = (wcscmp(oldBothImageName.c_str(), m_OverlapImageName.c_str()) != 0); m_SizeChanged = (oldGraphHorizontalOrientation != m_GraphHorizontalOrientation); if (m_PrimaryNeedsReload || m_SecondaryNeedsReload || m_OverlapNeedsReload || m_PrimaryImage.IsOptionsChanged() || m_SecondaryImage.IsOptionsChanged() || m_OverlapImage.IsOptionsChanged()) { Initialize(); // Reload the image } else if (m_SizeChanged) { CreateBuffer(); } } } }
/* ** Read the options specified in the ini file. ** */ void CMeterString::ReadOptions(CConfigParser& parser, const WCHAR* section) { // Store the current font values so we know if the font needs to be updated std::wstring oldFontFace = m_FontFace; int oldFontSize = m_FontSize; TEXTSTYLE oldStyle = m_Style; CMeter::ReadOptions(parser, section); m_Color = parser.ReadColor(section, L"FontColor", Color::Black); m_EffectColor = parser.ReadColor(section, L"FontEffectColor", Color::Black); m_Prefix = parser.ReadString(section, L"Prefix", L""); m_Postfix = parser.ReadString(section, L"Postfix", L""); m_Text = parser.ReadString(section, L"Text", L""); m_Percentual = 0!=parser.ReadInt(section, L"Percentual", 0); int clipping = parser.ReadInt(section, L"ClipString", 0); switch (clipping) { case 2: m_ClipType = CLIP_AUTO; m_ClipStringW = parser.ReadInt(section, L"ClipStringW", -1); m_ClipStringH = parser.ReadInt(section, L"ClipStringH", -1); break; case 1: m_ClipType = CLIP_ON; break; case 0: m_ClipType = CLIP_OFF; break; default: LogWithArgs(LOG_ERROR, L"ClipString=%s is not valid in [%s]", clipping, m_Name.c_str()); } m_FontFace = parser.ReadString(section, L"FontFace", L"Arial"); if (m_FontFace.empty()) { m_FontFace = L"Arial"; } m_FontSize = parser.ReadInt(section, L"FontSize", 10); if (m_FontSize < 0) { m_FontSize = 10; } m_NumOfDecimals = parser.ReadInt(section, L"NumOfDecimals", -1); m_Angle = (Gdiplus::REAL)parser.ReadFloat(section, L"Angle", 0.0); const std::wstring& autoscale = parser.ReadString(section, L"AutoScale", L"0"); int autoscaleValue = _wtoi(autoscale.c_str()); if (autoscaleValue == 0) { m_AutoScale = AUTOSCALE_OFF; } else { if (autoscale.find_last_of(L"kK") == std::wstring::npos) { m_AutoScale = (autoscaleValue == 2) ? AUTOSCALE_1000 : AUTOSCALE_1024; } else { m_AutoScale = (autoscaleValue == 2) ? AUTOSCALE_1000K : AUTOSCALE_1024K; } } const std::wstring& scale = parser.ReadString(section, L"Scale", L"1"); m_NoDecimals = (scale.find(L'.') == std::wstring::npos); m_Scale = parser.ParseDouble(scale.c_str(), 1); const WCHAR* hAlign = parser.ReadString(section, L"StringAlign", L"LEFT").c_str(); const WCHAR* vAlign = NULL; if (_wcsnicmp(hAlign, L"LEFT", 4) == 0) { m_TextFormat->SetHorizontalAlignment(Gfx::HorizontalAlignment::Left); vAlign = hAlign + 4; } else if (_wcsnicmp(hAlign, L"RIGHT", 5) == 0) { m_TextFormat->SetHorizontalAlignment(Gfx::HorizontalAlignment::Right); vAlign = hAlign + 5; } else if (_wcsnicmp(hAlign, L"CENTER", 6) == 0) { m_TextFormat->SetHorizontalAlignment(Gfx::HorizontalAlignment::Center); vAlign = hAlign + 6; } if (!vAlign || _wcsicmp(vAlign, L"TOP") == 0) { m_TextFormat->SetVerticalAlignment(Gfx::VerticalAlignment::Top); } else if (_wcsicmp(vAlign, L"BOTTOM") == 0) { m_TextFormat->SetVerticalAlignment(Gfx::VerticalAlignment::Bottom); } else if (_wcsicmp(vAlign, L"CENTER") == 0) { m_TextFormat->SetVerticalAlignment(Gfx::VerticalAlignment::Center); } const WCHAR* stringCase = parser.ReadString(section, L"StringCase", L"NONE").c_str(); if (_wcsicmp(stringCase, L"NONE") == 0) { m_Case = TEXTCASE_NONE; } else if (_wcsicmp(stringCase, L"UPPER") == 0) { m_Case = TEXTCASE_UPPER; } else if (_wcsicmp(stringCase, L"LOWER") == 0) { m_Case = TEXTCASE_LOWER; } else if (_wcsicmp(stringCase, L"PROPER") == 0) { m_Case = TEXTCASE_PROPER; } else { LogWithArgs(LOG_ERROR, L"StringCase=%s is not valid in [%s]", stringCase, m_Name.c_str()); } const WCHAR* style = parser.ReadString(section, L"StringStyle", L"NORMAL").c_str(); if (_wcsicmp(style, L"NORMAL") == 0) { m_Style = NORMAL; } else if (_wcsicmp(style, L"BOLD") == 0) { m_Style = BOLD; } else if (_wcsicmp(style, L"ITALIC") == 0) { m_Style = ITALIC; } else if (_wcsicmp(style, L"BOLDITALIC") == 0) { m_Style = BOLDITALIC; } else { LogWithArgs(LOG_ERROR, L"StringStyle=%s is not valid in [%s]", style, m_Name.c_str()); } const WCHAR* effect = parser.ReadString(section, L"StringEffect", L"NONE").c_str(); if (_wcsicmp(effect, L"NONE") == 0) { m_Effect = EFFECT_NONE; } else if (_wcsicmp(effect, L"SHADOW") == 0) { m_Effect = EFFECT_SHADOW; } else if (_wcsicmp(effect, L"BORDER") == 0) { m_Effect = EFFECT_BORDER; } else { LogWithArgs(LOG_ERROR, L"StringEffect=%s is not valid in [%s]", effect, m_Name.c_str()); } if (m_Initialized && (wcscmp(oldFontFace.c_str(), m_FontFace.c_str()) != 0 || oldFontSize != m_FontSize || oldStyle != m_Style)) { Initialize(); // Recreate the font } }
/* ** Read the options specified in the ini file. ** */ void CMeterString::ReadOptions(CConfigParser& parser, const WCHAR* section) { // Store the current font values so we know if the font needs to be updated std::wstring oldFontFace = m_FontFace; int oldFontSize = m_FontSize; TEXTSTYLE oldStyle = m_Style; CMeter::ReadOptions(parser, section); m_Color = parser.ReadColor(section, L"FontColor", Color::Black); m_EffectColor = parser.ReadColor(section, L"FontEffectColor", Color::Black); m_Prefix = parser.ReadString(section, L"Prefix", L""); m_Postfix = parser.ReadString(section, L"Postfix", L""); m_Text = parser.ReadString(section, L"Text", L""); m_Percentual = 0!=parser.ReadInt(section, L"Percentual", 0); m_ClipString = 0!=parser.ReadInt(section, L"ClipString", 0); m_FontFace = parser.ReadString(section, L"FontFace", L"Arial"); if (m_FontFace.empty()) { m_FontFace = L"Arial"; } m_FontSize = (int)parser.ReadFloat(section, L"FontSize", 10); if (m_FontSize < 0) { m_FontSize = 10; } m_NumOfDecimals = parser.ReadInt(section, L"NumOfDecimals", -1); m_Angle = (Gdiplus::REAL)parser.ReadFloat(section, L"Angle", 0.0); const std::wstring& autoscale = parser.ReadString(section, L"AutoScale", L"0"); int autoscaleValue = _wtoi(autoscale.c_str()); if (autoscaleValue == 0) { m_AutoScale = AUTOSCALE_OFF; } else { if (autoscale.find_last_of(L"kK") == std::wstring::npos) { m_AutoScale = (autoscaleValue == 2) ? AUTOSCALE_1000 : AUTOSCALE_1024; } else { m_AutoScale = (autoscaleValue == 2) ? AUTOSCALE_1000K : AUTOSCALE_1024K; } } const std::wstring& scale = parser.ReadString(section, L"Scale", L"1"); m_NoDecimals = (scale.find(L'.') == std::wstring::npos); m_Scale = parser.ParseDouble(scale.c_str(), 1); const WCHAR* align = parser.ReadString(section, L"StringAlign", L"LEFT").c_str(); if (_wcsicmp(align, L"LEFT") == 0 || _wcsicmp(align, L"LEFTTOP") == 0) { m_Align = ALIGN_LEFT; } else if (_wcsicmp(align, L"RIGHT") == 0 || _wcsicmp(align, L"RIGHTTOP") == 0) { m_Align = ALIGN_RIGHT; } else if (_wcsicmp(align, L"CENTER") == 0 || _wcsicmp(align, L"CENTERTOP") == 0) { m_Align = ALIGN_CENTER; } else if (_wcsicmp(align, L"LEFTBOTTOM") == 0) { m_Align = ALIGN_LEFTBOTTOM; } else if (_wcsicmp(align, L"RIGHTBOTTOM") == 0) { m_Align = ALIGN_RIGHTBOTTOM; } else if (_wcsicmp(align, L"CENTERBOTTOM") == 0) { m_Align = ALIGN_CENTERBOTTOM; } else if (_wcsicmp(align, L"LEFTCENTER") == 0) { m_Align = ALIGN_LEFTCENTER; } else if (_wcsicmp(align, L"RIGHTCENTER") == 0) { m_Align = ALIGN_RIGHTCENTER; } else if (_wcsicmp(align, L"CENTERCENTER") == 0) { m_Align = ALIGN_CENTERCENTER; } else { LogWithArgs(LOG_ERROR, L"StringAlign=%s is not valid in [%s]", align, m_Name.c_str()); } const WCHAR* stringCase = parser.ReadString(section, L"StringCase", L"NONE").c_str(); if (_wcsicmp(stringCase, L"NONE") == 0) { m_Case = TEXTCASE_NONE; } else if (_wcsicmp(stringCase, L"UPPER") == 0) { m_Case = TEXTCASE_UPPER; } else if (_wcsicmp(stringCase, L"LOWER") == 0) { m_Case = TEXTCASE_LOWER; } else if (_wcsicmp(stringCase, L"PROPER") == 0) { m_Case = TEXTCASE_PROPER; } else { LogWithArgs(LOG_ERROR, L"StringCase=%s is not valid in [%s]", stringCase, m_Name.c_str()); } const WCHAR* style = parser.ReadString(section, L"StringStyle", L"NORMAL").c_str(); if (_wcsicmp(style, L"NORMAL") == 0) { m_Style = NORMAL; } else if (_wcsicmp(style, L"BOLD") == 0) { m_Style = BOLD; } else if (_wcsicmp(style, L"ITALIC") == 0) { m_Style = ITALIC; } else if (_wcsicmp(style, L"BOLDITALIC") == 0) { m_Style = BOLDITALIC; } else { LogWithArgs(LOG_ERROR, L"StringStyle=%s is not valid in [%s]", style, m_Name.c_str()); } const WCHAR* effect = parser.ReadString(section, L"StringEffect", L"NONE").c_str(); if (_wcsicmp(effect, L"NONE") == 0) { m_Effect = EFFECT_NONE; } else if (_wcsicmp(effect, L"SHADOW") == 0) { m_Effect = EFFECT_SHADOW; } else if (_wcsicmp(effect, L"BORDER") == 0) { m_Effect = EFFECT_BORDER; } else { LogWithArgs(LOG_ERROR, L"StringEffect=%s is not valid in [%s]", effect, m_Name.c_str()); } if (m_Initialized && (wcscmp(oldFontFace.c_str(), m_FontFace.c_str()) != 0 || oldFontSize != m_FontSize || oldStyle != m_Style)) { Initialize(); // Recreate the font } }
/* ** Read the options specified in the ini file. ** */ void CMeterBitmap::ReadOptions(CConfigParser& parser, const WCHAR* section) { // Store the current values so we know if the image needs to be updated std::wstring oldImageName = m_ImageName; int oldW = m_W; int oldH = m_H; CMeter::ReadOptions(parser, section); m_ImageName = parser.ReadString(section, L"BitmapImage", L""); if (!m_ImageName.empty()) { m_MeterWindow->MakePathAbsolute(m_ImageName); // Read tinting options m_Image.ReadOptions(parser, section); } else { m_Image.ClearOptionFlags(); } m_FrameCount = parser.ReadInt(section, L"BitmapFrames", 1); m_ZeroFrame = 0!=parser.ReadInt(section, L"BitmapZeroFrame", 0); m_Separation = parser.ReadInt(section, L"BitmapSeparation", 0); m_Extend = 0!=parser.ReadInt(section, L"BitmapExtend", 0); m_Digits = parser.ReadInt(section, L"BitmapDigits", 0); m_TransitionFrameCount = parser.ReadInt(section, L"BitmapTransitionFrames", 0); const WCHAR* align = parser.ReadString(section, L"BitmapAlign", L"LEFT").c_str(); if (_wcsicmp(align, L"LEFT") == 0) { m_Align = ALIGN_LEFT; } else if (_wcsicmp(align, L"RIGHT") == 0) { m_Align = ALIGN_RIGHT; } else if (_wcsicmp(align, L"CENTER") == 0) { m_Align = ALIGN_CENTER; } else { LogWithArgs(LOG_ERROR, L"BitmapAlign=%s is not valid in [%s]", align, m_Name.c_str()); } if (m_Initialized) { m_NeedsReload = (wcscmp(oldImageName.c_str(), m_ImageName.c_str()) != 0); if (m_NeedsReload || m_Image.IsOptionsChanged()) { Initialize(); // Reload the image } else { // Reset to old dimensions m_W = oldW; m_H = oldH; } } }
/* ** Read the options specified in the ini file. ** */ void CMeasureDiskSpace::ReadOptions(CConfigParser& parser, const WCHAR* section) { double oldMaxValue = m_MaxValue; CMeasure::ReadOptions(parser, section); m_Drive = parser.ReadString(section, L"Drive", L"C:\\"); if (m_Drive.empty()) { Log(LOG_WARNING, L"FreeDiskSpace: Drive= empty"); m_Value = 0.0; m_MaxValue = 0.0; m_OldTotalBytes = 0; m_DriveInfo.clear(); } else if (!CSystem::IsPathSeparator(m_Drive[m_Drive.length() - 1])) // E.g. "C:" { m_Drive += L'\\'; // A trailing backslash is required. } m_Type = (1 == parser.ReadInt(section, L"Type", 0)); m_Total = (1 == parser.ReadInt(section, L"Total", 0)); m_Label = (1 == parser.ReadInt(section, L"Label", 0)); m_IgnoreRemovable = (1 == parser.ReadInt(section, L"IgnoreRemovable", 1)); m_DiskQuota = (1 == parser.ReadInt(section, L"DiskQuota", 1)); // Set the m_MaxValue if (!m_Initialized) { BOOL result = FALSE; ULONGLONG i64TotalBytes; if (!m_Drive.empty()) { const WCHAR* drive = m_Drive.c_str(); UINT type = GetDriveType(drive); if (type != DRIVE_NO_ROOT_DIR && type != DRIVE_CDROM && (!m_IgnoreRemovable || type != DRIVE_REMOVABLE)) // Ignore CD-ROMS and removable drives { UINT oldMode = SetErrorMode(0); SetErrorMode(oldMode | SEM_FAILCRITICALERRORS); // Prevent the system from displaying message box result = GetDiskFreeSpaceEx(drive, NULL, (PULARGE_INTEGER)&i64TotalBytes, NULL); SetErrorMode(oldMode); // Reset } } if (result) { m_MaxValue = (double)(__int64)i64TotalBytes; m_OldTotalBytes = i64TotalBytes; } else { m_MaxValue = 0.0; m_OldTotalBytes = 0; } } else { if (m_Type) { m_MaxValue = DRIVETYPE_MAX; m_OldTotalBytes = 0; } else { m_MaxValue = oldMaxValue; } } }
/* ** Read the common options specified in the ini file. The inherited classes must ** call this base implementation if they overwrite this method. ** */ void CMeter::ReadOptions(CConfigParser& parser, const WCHAR* section) { // The MeterStyle defines a template where the values are read if the meter doesn't have it itself const std::wstring& style = parser.ReadString(section, L"MeterStyle", L""); if (!style.empty()) { parser.SetStyleTemplate(style); } CSection::ReadOptions(parser, section); BindMeasures(parser, section); int oldX = m_X; std::wstring& x = (std::wstring&)parser.ReadString(section, L"X", L"0"); if (!x.empty()) { WCHAR lastChar = x[x.size() - 1]; if (lastChar == L'r') { m_RelativeX = POSITION_RELATIVE_TL; x.pop_back(); } else if (lastChar == L'R') { m_RelativeX = POSITION_RELATIVE_BR; x.pop_back(); } else { m_RelativeX = POSITION_ABSOLUTE; } m_X = parser.ParseInt(x.c_str(), 0); } else { m_X = 0; m_RelativeX = POSITION_ABSOLUTE; } int oldY = m_Y; std::wstring& y = (std::wstring&)parser.ReadString(section, L"Y", L"0"); if (!y.empty()) { WCHAR lastChar = y[y.size() - 1]; if (lastChar == L'r') { m_RelativeY = POSITION_RELATIVE_TL; y.pop_back(); } else if (lastChar == L'R') { m_RelativeY = POSITION_RELATIVE_BR; y.pop_back(); } else { m_RelativeY = POSITION_ABSOLUTE; } m_Y = parser.ParseInt(y.c_str(), 0); } else { m_Y = 0; m_RelativeY = POSITION_ABSOLUTE; } bool oldWDefined = m_WDefined; int w = parser.ReadInt(section, L"W", m_W); m_WDefined = parser.GetLastValueDefined(); if (IsFixedSize(true)) m_W = w; if (!m_WDefined && oldWDefined && IsFixedSize()) { m_W = 0; } bool oldHDefined = m_HDefined; int h = parser.ReadInt(section, L"H", m_H); m_HDefined = parser.GetLastValueDefined(); if (IsFixedSize(true)) m_H = h; if (!m_HDefined && oldHDefined && IsFixedSize()) { m_H = 0; } bool oldHidden = m_Hidden; m_Hidden = 0!=parser.ReadInt(section, L"Hidden", 0); if (oldX != m_X || oldY != m_Y || oldHidden != m_Hidden) { m_MeterWindow->SetResizeWindowMode(RESIZEMODE_CHECK); // Need to recalculate the window size } m_SolidBevel = (BEVELTYPE)parser.ReadInt(section, L"BevelType", BEVELTYPE_NONE); m_SolidColor = parser.ReadColor(section, L"SolidColor", Color::MakeARGB(0, 0, 0, 0)); m_SolidColor2 = parser.ReadColor(section, L"SolidColor2", m_SolidColor.GetValue()); m_SolidAngle = (Gdiplus::REAL)parser.ReadFloat(section, L"GradientAngle", 0.0); m_Mouse.ReadOptions(parser, section); m_HasMouseAction = m_Mouse.HasButtonAction() || m_Mouse.HasScrollAction(); m_ToolTipText = parser.ReadString(section, L"ToolTipText", L""); m_ToolTipTitle = parser.ReadString(section, L"ToolTipTitle", L""); m_ToolTipIcon = parser.ReadString(section, L"ToolTipIcon", L""); m_ToolTipWidth = parser.ReadInt(section, L"ToolTipWidth", 1000); m_ToolTipType = 0!=parser.ReadInt(section, L"ToolTipType", 0); m_ToolTipHidden = 0!=parser.ReadInt(section, L"ToolTipHidden", m_MeterWindow->GetMeterToolTipHidden()); m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0); std::vector<Gdiplus::REAL> matrix = parser.ReadFloats(section, L"TransformationMatrix"); if (matrix.size() == 6) { if (m_Transformation) { m_Transformation->SetElements(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); } else { m_Transformation = new Matrix(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); } } else if (!matrix.empty()) { delete m_Transformation; m_Transformation = NULL; LogWithArgs(LOG_ERROR, L"Meter: Incorrect number of values in TransformationMatrix=%s", parser.ReadString(section, L"TransformationMatrix", L"").c_str()); } }
/* ** Reads the common configs for all Measures. The inherited classes ** must call the base implementation if they overwrite this method. ** */ void CMeasure::ReadConfig(CConfigParser& parser, const WCHAR* section) { // Clear substitutes to prevent from being added more than once. if (!m_Substitute.empty()) { m_Substitute.clear(); } m_Invert = 0!=parser.ReadInt(section, L"InvertMeasure", 0); if (!m_Initialized) { m_Disabled = 0!=parser.ReadInt(section, L"Disabled", 0); } else { const std::wstring& result = parser.ReadString(section, L"Disabled", L"0"); if (parser.GetLastReplaced()) { m_Disabled = 0!=parser.ParseInt(result.c_str(), 0); } } int updateDivider = parser.ReadInt(section, L"UpdateDivider", 1); if (updateDivider != m_UpdateDivider) { m_UpdateCounter = m_UpdateDivider = updateDivider; } m_MinValue = parser.ReadFormula(section, L"MinValue", m_MinValue); m_MaxValue = parser.ReadFormula(section, L"MaxValue", m_MaxValue); // The ifabove/ifbelow define actions that are ran when the value goes above/below the given number. m_IfAboveValue = parser.ReadFormula(section, L"IfAboveValue", 0.0); m_IfAboveAction = parser.ReadString(section, L"IfAboveAction", L"", false); m_IfBelowValue = parser.ReadFormula(section, L"IfBelowValue", 0.0); m_IfBelowAction = parser.ReadString(section, L"IfBelowAction", L"", false); m_IfEqualValue = parser.ReadFormula(section, L"IfEqualValue", 0.0); m_IfEqualAction = parser.ReadString(section, L"IfEqualAction", L"", false); m_AverageSize = parser.ReadUInt(section, L"AverageSize", 0); m_DynamicVariables = 0!=parser.ReadInt(section, L"DynamicVariables", 0); m_RegExpSubstitute = 0!=parser.ReadInt(section, L"RegExpSubstitute", 0); std::wstring subs = parser.ReadString(section, L"Substitute", L""); if (!subs.empty()) { if ((subs[0] != L'"' || subs[subs.length() - 1] != L'\'') && (subs[0] != L'\'' || subs[subs.length() - 1] != L'"')) { // Add quotes since they are removed by the GetProfileString subs.insert(0, 1, L'"'); subs += L'"'; } if (!ParseSubstitute(subs)) { LogWithArgs(LOG_ERROR, L"Measure: Invalid Substitute=%s", subs.c_str()); } } const std::wstring& group = parser.ReadString(section, L"Group", L""); InitializeGroup(group); }
/* ** Read the common options specified in the ini file. The inherited classes must ** call this base implementation if they overwrite this method. ** */ void CMeter::ReadOptions(CConfigParser& parser, const WCHAR* section) { // The MeterStyle defines a template where the values are read if the meter doesn't have it itself const std::wstring& style = parser.ReadString(section, L"MeterStyle", L""); if (!style.empty()) { parser.SetStyleTemplate(style); } std::wstring oldStyleX = m_StyleX; std::wstring oldStyleY = m_StyleY; std::wstring oldStyleHidden = m_StyleHidden; std::wstring coord = parser.ReadString(section, L"X", L"0"); m_StyleX = parser.GetLastUsedStyle(); if (!m_Initialized || parser.GetLastReplaced() || wcscmp(m_StyleX.c_str(), oldStyleX.c_str()) != 0) { if (!coord.empty()) { size_t len = coord.size(); if (coord[len - 1] == L'r') { m_RelativeX = POSITION_RELATIVE_TL; coord.erase(--len); } else if (coord[len - 1] == L'R') { m_RelativeX = POSITION_RELATIVE_BR; coord.erase(--len); } else { m_RelativeX = POSITION_ABSOLUTE; } m_X = parser.ParseInt(coord.c_str(), 0); } else { m_X = 0; m_RelativeX = POSITION_ABSOLUTE; } } coord = parser.ReadString(section, L"Y", L"0"); m_StyleY = parser.GetLastUsedStyle(); if (!m_Initialized || parser.GetLastReplaced() || wcscmp(m_StyleY.c_str(), oldStyleY.c_str()) != 0) { if (!coord.empty()) { size_t len = coord.size(); if (coord[len - 1] == L'r') { m_RelativeY = POSITION_RELATIVE_TL; coord.erase(--len); } else if (coord[len - 1] == L'R') { m_RelativeY = POSITION_RELATIVE_BR; coord.erase(--len); } else { m_RelativeY = POSITION_ABSOLUTE; } m_Y = parser.ParseInt(coord.c_str(), 0); } else { m_Y = 0; m_RelativeY = POSITION_ABSOLUTE; } } m_W = parser.ReadInt(section, L"W", 1); m_WDefined = parser.GetLastValueDefined(); m_H = parser.ReadInt(section, L"H", 1); m_HDefined = parser.GetLastValueDefined(); const std::wstring& hidden = parser.ReadString(section, L"Hidden", L"0"); m_StyleHidden = parser.GetLastUsedStyle(); if (!m_Initialized || parser.GetLastReplaced() || wcscmp(m_StyleHidden.c_str(), oldStyleHidden.c_str()) != 0) { m_Hidden = 0!=parser.ParseInt(hidden.c_str(), 0); } if (!m_Initialized) { m_MeasureName = parser.ReadString(section, L"MeasureName", L""); } m_SolidBevel = (BEVELTYPE)parser.ReadInt(section, L"BevelType", BEVELTYPE_NONE); m_SolidColor = parser.ReadColor(section, L"SolidColor", Color::MakeARGB(0, 0, 0, 0)); m_SolidColor2 = parser.ReadColor(section, L"SolidColor2", m_SolidColor.GetValue()); m_SolidAngle = (Gdiplus::REAL)parser.ReadFloat(section, L"GradientAngle", 0.0); m_Mouse.ReadOptions(parser, section, m_MeterWindow); m_HasMouseAction = !(m_Mouse.GetLeftUpAction().empty() && m_Mouse.GetLeftDownAction().empty() && m_Mouse.GetLeftDoubleClickAction().empty() && m_Mouse.GetMiddleUpAction().empty() && m_Mouse.GetMiddleDownAction().empty() && m_Mouse.GetMiddleDoubleClickAction().empty() && m_Mouse.GetRightUpAction().empty() && m_Mouse.GetRightDownAction().empty() && m_Mouse.GetRightDoubleClickAction().empty()); m_ToolTipText = parser.ReadString(section, L"ToolTipText", L""); m_ToolTipTitle = parser.ReadString(section, L"ToolTipTitle", L""); m_ToolTipIcon = parser.ReadString(section, L"ToolTipIcon", L""); m_ToolTipWidth = (int)parser.ReadFloat(section, L"ToolTipWidth", 1000); m_ToolTipType = 0!=parser.ReadInt(section, L"ToolTipType", 0); m_ToolTipHidden = 0!=parser.ReadInt(section, L"ToolTipHidden", m_MeterWindow->GetMeterToolTipHidden()); int updateDivider = parser.ReadInt(section, L"UpdateDivider", 1); if (updateDivider != m_UpdateDivider) { m_UpdateCounter = m_UpdateDivider = updateDivider; } m_AntiAlias = 0!=parser.ReadInt(section, L"AntiAlias", 0); m_DynamicVariables = 0!=parser.ReadInt(section, L"DynamicVariables", 0); std::vector<Gdiplus::REAL> matrix = parser.ReadFloats(section, L"TransformationMatrix"); if (matrix.size() == 6) { if (m_Transformation) { m_Transformation->SetElements(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); } else { m_Transformation = new Matrix(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); } } else if (!matrix.empty()) { delete m_Transformation; m_Transformation = NULL; LogWithArgs(LOG_ERROR, L"Meter: Incorrect number of values in TransformationMatrix=%s", parser.ReadString(section, L"TransformationMatrix", L"").c_str()); } const std::wstring& group = parser.ReadString(section, L"Group", L""); InitializeGroup(group); }