示例#1
0
CHotKey::~CHotKey()
{
	delete [] m_pszEventName;
	delete [] m_pszDescription;

	ResetEvents();
}
示例#2
0
// Отписываемся от набора событий
void __fastcall TdmConnect::UnRegisterEvent(TEventAlert Alert, const TStrList &EventName) {
  std::list<TEventIt> EventList;
  for(TStrIt i=EventName.begin(); i!=EventName.end(); ++i)
    for(TEventIt j=_event.lower_bound(*i); j!=_event.upper_bound(*i); ++j)
      if(j->second==Alert)
        EventList.push_back(j);
  for(std::list<TEventIt>::const_iterator i=EventList.begin(); i!=EventList.end(); ++i)
    _event.erase(*i);
  ResetEvents();
}
示例#3
0
// Подписываемся на набор событий
void __fastcall TdmConnect::RegisterEvent(TEventAlert Alert, const TStrList &EventName) {
  for(TStrIt i=EventName.begin(); i!=EventName.end(); ++i) {
    try {
      for(TEventIt j=_event.lower_bound(*i); j!=_event.upper_bound(*i); ++j)
        if(j->second==Alert)
          throw Exception("");
      _event.insert(std::make_pair(*i, Alert));
    }
    catch(Exception&) {}
  }
  ResetEvents();
}
示例#4
0
//assignment operator
const CHotKey& CHotKey::operator=(const CHotKey& rhs)
{
	ResetEvents();

	if(SetEventName(rhs.GetEventName()) && SetDescription(rhs.GetDescription()))
	{
		//run through both lists and create clones of each hotkey, then
		//add them into this new list
		for(UINT32 nCurrStart = 0; nCurrStart < rhs.m_StartEventList.GetSize(); nCurrStart++)
		{
			m_StartEventList.Add(rhs.m_StartEventList[nCurrStart]->Clone());
		}
		for(UINT32 nCurrEnd = 0; nCurrEnd < rhs.m_EndEventList.GetSize(); nCurrEnd++)
		{
			m_EndEventList.Add(rhs.m_EndEventList[nCurrEnd]->Clone());
		}

		SetUserChangable(rhs.IsUserChangable());
	}

	return *this;
}
示例#5
0
//loads the key from the registry
bool CHotKey::LoadFromRegistry(CGenRegMgr& RegMgr, const char* pszRegDir, const char* pszName)
{
	
	ResetEvents();

	CString sKeyName;


	static const uint32 nBuffSize = 512;
	char pszTextBuff[nBuffSize];

	//read in the name of this hotkey
	sKeyName.Format("%sName", pszName);
	if(RegMgr.GetValue(pszRegDir, sKeyName, pszTextBuff, nBuffSize))
	{
		SetEventName(pszTextBuff);
	}

	//read in the description
	sKeyName.Format("%sDescription", pszName);
	if(RegMgr.GetValue(pszRegDir, sKeyName, pszTextBuff, nBuffSize))
	{
		SetDescription(pszTextBuff);
	}

	//write if it is changable or not
	BOOL bChangable;
	sKeyName.Format("%sChangable", pszName);
	if(RegMgr.GetStringBoolValue(pszRegDir, sKeyName, &bChangable))
	{
		SetUserChangable((bChangable) ? true : false);
	}


	//lists that we need to load
	CUIEventList* pLists[] = {&m_StartEventList, &m_EndEventList};

	for(uint32 nCurrList = 0; nCurrList < sizeof(pLists) / sizeof(pLists[0]); nCurrList++)
	{
		//get the number of events for this hotkey
		uint32 nNumEvents;
		sKeyName.Format("%sList%dNumEvents", pszName, nCurrList);
		if(RegMgr.GetDwordValue(pszRegDir, sKeyName, &nNumEvents) == false)
		{
			return false;
		}
		
		//read in all the events
		for(uint32 nCurrEvent = 0; nCurrEvent < nNumEvents; nCurrEvent++)
		{

			//read in the type of the event
			uint32 nType;
			sKeyName.Format("%sList%dEvent%dType", pszName, nCurrList, nCurrEvent);
			if(RegMgr.GetDwordValue(pszRegDir, sKeyName, &nType) == false)
			{
				ResetEvents();
				return false;
			}

			//read in the extra value for the event
			uint32 nValue;
			sKeyName.Format("%sList%dEvent%dValue", pszName, nCurrList, nCurrEvent);
			if(RegMgr.GetDwordValue(pszRegDir, sKeyName, &nValue) == false)
			{
				ResetEvents();
				return false;
			}

			//now create the item and add it to the list
			CUIEvent* pEvent = CreateEvent(nType, nValue);
			if(pEvent)
			{
				pLists[nCurrList]->Add(pEvent);
			}			
		}
	}

	return true;
}
示例#6
0
bool CHotKey::Load(istream& InFile, const char* pszName)
#endif
{
	ResetEvents();

	uint32 nCurrChar;

	if(ResizeString(strlen(pszName) + 1, &m_pszEventName) == false)
	{
		return false;
	}
	strcpy(m_pszEventName, pszName);


	//read in the description
	uint32 nDescriptionLen;
	InFile >> nDescriptionLen;

	//skip past the newline
	InFile.get();

	if(ResizeString(nDescriptionLen + 1, &m_pszDescription) == false)
	{
		return false;
	}

	//read in the specified number of characters
	for(nCurrChar = 0; nCurrChar < nDescriptionLen; nCurrChar++)
	{
		m_pszDescription[nCurrChar] = InFile.get();
	}
	m_pszDescription[nDescriptionLen] = '\0';

	//read in if it is user changable
	uint32 nChangable;
	InFile >> nChangable;
	SetUserChangable((nChangable) ? true : false);

	//lists that we need to load
	CUIEventList* pLists[] = {&m_StartEventList, &m_EndEventList};

	for(uint32 nCurrList = 0; nCurrList < sizeof(pLists) / sizeof(pLists[0]); nCurrList++)
	{
		//get the number of keys
		uint32 nNumEvents;
		InFile >> nNumEvents;

		//read in all the keys
		for(uint32 nCurrEvent = 0; nCurrEvent < nNumEvents; nCurrEvent++)
		{
			uint32 nType;
			uint32 nCode;

			//read in the type and code
			InFile >> nType >> nCode;
			
			//create the event
			CUIEvent* pEvent = CreateEvent(nType, nCode);

			//add it to the list if it is valid
			if(pEvent)
			{
				pLists[nCurrList]->Add(pEvent);
			}
		}
	}

	return true;
}