//---------------------------------------------------------------------------
void  TDemoBasicMainForm::CreateEventObject(bool AAllDayEvent, bool ARandomResource, TcxCustomSchedulerStorage *AStorage,
  TColor AColor)
{
  TcxSchedulerEvent *AEvent = AStorage->createEvent();
  TDateTime ADate = GetRandomDate();
  AEvent->Start = ADate;
  if (!AAllDayEvent)
  {
	AEvent->Finish = ADate + (double)((random(180) + 30) * MinuteToTime);
  }
  else
  {
	AEvent->Finish = ADate + 1;
	AEvent->AllDayEvent = True;
  };
  AEvent->State = GetRandomState();
  if (AColor == Graphics::clDefault)
	AEvent->LabelColor = EventLabelColors[random(11)];
  else
	AEvent->LabelColor = AColor;
  int AIndex = random(22);
  AEvent->Caption = SportEvents[StartIndexes[AIndex] + random(EventsCount[AIndex])];
  if (ARandomResource) {
	AEvent->ResourceID = GetRandomResourceID(); }
  OnNewEvent(AEvent, AIndex);
}
bool	CMultiXWSStream::DoWork()
{
	WaitEventReturnCodes	ReturnCode;
	ReturnCode	=	Wait(1);
	if(ReturnCode	==	NoEventPending)
	{
		try
		{
			if(OnIdle())
				return	true;
			ReturnCode	=	Wait(5000);
		}	catch	(CMultiXException	&e)
		{
			return	OnMultiXException(e);
		}
	}

	try	
	{
		switch(ReturnCode)
		{
			case	MultiXEventPending	:
			{
				CMultiXEvent	*Event	=	Dequeue();
				if(Event)
				{
					OnNewEvent(Event);
				}
			}
			break;
#ifdef	WindowsOs
			case	WindowsMessagePending	:
			{
				MSG	Msg;
				PeekMessage(&Msg, NULL, 0, 0, PM_NOREMOVE);
			}
			break;
#endif
		}
	}	catch	(CMultiXException	&e)
	{
		return	OnMultiXException(e);
	}
	return	true;
}