UINT VirtuaWinMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
{
	std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T("")));
	std::map<std::wstring, MeasureType>::iterator i = StringToType.find(TypeString);
	if (i != StringToType.end())
	{
		Type = i->second;
	}
	else
	{
		Type = Unknown;
	}

	switch(Type)
	{
	case VDMActive:
		return 1;

	case DesktopCountTotal:
		{
			LPCTSTR CountType = ReadConfigString(section, _T("VDDesktopCount"), _T(""));
			if (_tcsicmp(CountType, _T("X")) == 0) Type = DesktopCountColumns;
			else if (_tcsicmp(CountType, _T("Y")) == 0) Type = DesktopCountRows;
			if (FindVirtuaWinWindow())
			{
				return (UINT) SendMessage(vwHandle, VW_DESKTOP_SIZE, 0, 0);
			}
			break;
		}
	}

	return 0;
}
UINT DexpotVDMActiveMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
{
	OnActivate = ReadConfigString(section, _T("VDOnActivate"), _T(""));
	OnDeactivate = ReadConfigString(section, _T("VDOnDeactivate"), _T(""));

	DexpotMeasure::Initialize(iniFile, section);
	return 1;
}
UINT DexpotScreenshotMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
{
	OutputFile = ReadConfigString(section, _T("VDOutputFile"), _T(""));
	DesktopNumber = _ttoi(ReadConfigString(section, _T("VDDesktop"), _T("0")));
	Width = _ttoi(ReadConfigString(section, _T("VDWidth"), _T("0")));
	Height = _ttoi(ReadConfigString(section, _T("VDHeight"), _T("0")));
	RefreshOnUpdate = _ttoi(ReadConfigString(section, _T("VDRefreshOnUpdate"), _T("0")));

	DexpotMeasure::Initialize(iniFile, section);
	return 0;
}
UINT DexpotDesktopCountMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
{
	DesktopCount = 0;
	OnChange = ReadConfigString(section, _T("VDOnChange"), _T(""));

	CountType = Total;
	LPCTSTR TypeString = ReadConfigString(section, _T("VDDesktopCount"), _T(""));
	if (_tcsicmp(TypeString, _T("X")) == 0) CountType = Columns;
	else if (_tcsicmp(TypeString, _T("Y")) == 0) CountType = Rows;

	DexpotMeasure::Initialize(iniFile, section);
	return 20;
}
UINT DexpotCurrentDesktopMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
{
	OnChange = ReadConfigString(section, _T("VDOnChange"), _T(""));

	DexpotMeasure::Initialize(iniFile, section);
	return 0;
}
示例#6
0
/*
This function is called when the measure is initialized.
The function must return the maximum value that can be measured.
The return value can also be 0, which means that Rainmeter will
track the maximum value automatically. The parameters for this
function are:

instance  The instance of this DLL
iniFile   The name of the ini-file (usually Rainmeter.ini)
section   The name of the section in the ini-file for this measure
id		The identifier for the measure. This is used to identify the measures that use the same plugin.
*/
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
{
	if (!CoInitialized)
	{
		::CoInitialize(nullptr);
		wcsncpy(BaseDir, iniFile, MAX_PATH);
		BaseDir[MAX_PATH - 1] = 0;
		wchar_t* lastBackslash = wcsrchr(BaseDir, L'\\');
		if (lastBackslash)
			lastBackslash[1] = 0;
		CoInitialized = true;
	}

	if (CoInitialized && !InstanceCreated && (FindWindow(L"iTunesApp", L"iTunes") || FindWindow(L"iTunes", L"iTunes")))
	{
		if (SUCCEEDED(iTunes.CreateInstance(CLSID_iTunesApp, nullptr, CLSCTX_LOCAL_SERVER)))
		{
			InstanceCreated = true;
			initEventHandler();
		}
		else
		{
			LSLog(LOG_ERROR, nullptr, L"iTunesPlugin.dll: Unable to create instance");
		}
	}

	const wchar_t* type = ReadConfigString(section, L"Command", L"");
	for (int i = 0; i < COMMAND_COUNT; i++)
	{
		if (CommandName[i] && type && _wcsicmp(CommandName[i], type) == 0)
		{
			CommandIdMap[id] = (COMMAND_TYPE)i;

			if (COMMAND_GETCURRENTTRACK_ARTWORK == (COMMAND_TYPE)i)
			{
				const wchar_t* defaultArtwork = ReadConfigString(section, L"DefaultArtwork", L"");
				wcscpy(DefaultTrackArtworkPath, defaultArtwork);
			}
		}
	}

	return 0;
}
DexpotMeasure* DexpotMeasure::CreateMeasure(HMODULE instance, UINT id, LPCTSTR iniFile, LPCTSTR section)
{
	std::wstring TypeString(ReadConfigString(section, _T("VDMeasureType"), _T("")));

	if (TypeString == _T("VDMActive")) return new DexpotVDMActiveMeasure(instance, id);
	else if (TypeString == _T("DesktopCount")) return new DexpotDesktopCountMeasure(instance, id);
	else if (TypeString == _T("CurrentDesktop")) return new DexpotCurrentDesktopMeasure(instance, id);
	else if (TypeString == _T("SwitchDesktop")) return new DexpotSwitchDesktopMeasure(instance, id);
	else if (TypeString == _T("Screenshot")) return new DexpotScreenshotMeasure(instance, id);
	else if (TypeString == _T("DesktopName")) return new DexpotDesktopNameMeasure(instance, id);
	else if (TypeString == _T("DesktopWallpaper")) return new DexpotDesktopWallpaperMeasure(instance, id);
	else if (TypeString == _T("Command")) return new DexpotCommandMeasure(instance, id);

	return nullptr;
}
示例#8
0
UINT Initialize(HMODULE instance, LPCTSTR iniFile, LPCTSTR section, UINT id)
{
	VDMeasure *Measure = nullptr;
	LPCTSTR VDManager = ReadConfigString(section, _T("VDManager"), _T(""));

	if (_tcsicmp(VDManager, _T("Dexpot")) == 0)
	{
		Measure = DexpotMeasure::CreateMeasure(instance, id, iniFile, section);
	}
	else if (_tcsicmp(VDManager, _T("VirtuaWin")) == 0)
	{
		Measure = new VirtuaWinMeasure(instance, id);
	}

	if (Measure)
	{
		Measures.insert(std::make_pair(id, Measure));
		return Measure->Initialize(iniFile, section);
	}

	return 0;
}
UINT DexpotDesktopWallpaperMeasure::Initialize(LPCTSTR iniFile, LPCTSTR section)
{
	DesktopNumber = _ttoi(ReadConfigString(section, _T("VDDesktop"), _T("0")));
	return DexpotMeasure::Initialize(iniFile, section);
}