예제 #1
0
LRESULT CBackEndDialog::OnAddTask(WPARAM wParam, LPARAM lParam)
{
	//extract the task
	CTask* pNewTask = (CTask*)wParam;
	ASSERT(pNewTask);

	//see if this task is already in the list
	CTask* pCurr = m_pHeadTask;
	while(pCurr)
	{
		if(stricmp(pCurr->GetName(), pNewTask->GetName()) == 0)
		{
			//already have a task of that name
			delete pNewTask;
			return 0;
		}
		pCurr = pCurr->GetNextTask();
	}

	if(m_pHeadTask == NULL)
	{
		m_pHeadTask = pNewTask;
	}
	else
	{
		//add it onto the end
		CTask* pCurr = m_pHeadTask;
		while(pCurr->GetNextTask())
			pCurr = pCurr->GetNextTask();

		pCurr->SetNextTask(pNewTask);
	}

	//now we can update the list control
	int nIndex = GetTaskList()->AddString(pNewTask->GetName());
	GetTaskList()->SetItemData(nIndex, (DWORD)pNewTask);

	return 0;
}
예제 #2
0
//---------------------------------------------------------------
// Purpose: 
//---------------------------------------------------------------
void CTaskManager::UpdateTasks()
{
	TaskList::iterator it = m_taskList.begin();

	while( it != m_taskList.end() )
	{
		CTask *task = *it;
		task->RunTask();

		if( task->IsTaskDone() )
		{
			CTask *next = task->GetNextTask();
			if( next )
				AddTask(next);
			it = m_taskList.erase(it);

			if( task->GetDeleteOnDone() )
				delete task;
		}
		else
			it++;
	}
}
예제 #3
0
//saves all the messages and tasks to a file of the specified name
bool CBackEndDialog::SaveLogToFile(const char* pszFilename)
{
	//open up the file and write out all the tasks and all their messages
#if _MSC_VER >= 1300
	std::ofstream OutFile(pszFilename);
#else
	ofstream OutFile(pszFilename);
#endif

	if(OutFile.fail())
	{
		return false;
	}

	CTask* pCurrTask = m_pHeadTask;

	while(pCurrTask)
	{
		//write out the task title
		OutFile << "Task: " << pCurrTask->GetName() << "\n\n";

		//write out the messages
		CTaskMessage* pCurrMsg = pCurrTask->GetMessageHead();
		
		while(pCurrMsg)
		{
			OutFile << "\t" << FormatFinalMsg(pCurrMsg);
			pCurrMsg = pCurrMsg->GetNext();
		}

		pCurrTask = pCurrTask->GetNextTask();
	}

	OutFile.close();

	return true;
}
예제 #4
0
LRESULT CBackEndDialog::OnActivateTask(WPARAM wParam, LPARAM lParam)
{
	//get the text
	char* pszTaskName = (char*)wParam;

	//track the old task
	CTask* pOldTask = m_pCurrTask;

	//run through the list and find the task
	CTask* pCurr = m_pHeadTask;

	while(pCurr)
	{
		if(stricmp(pszTaskName, pCurr->GetName()) == 0)
		{
			m_pCurrTask = pCurr;
			break;
		}
		pCurr = pCurr->GetNextTask();
	}

	//clean up the name now
	delete [] pszTaskName;
	pszTaskName = NULL;

	//see if we didn't find the task
	if(pCurr == NULL)
	{
		return false;
	}

	//set the active task name around the progress bar
	CStatic* pTaskName = (CStatic*)GetDlgItem(IDC_STATIC_TASK_NAME);
	CString sText;
	sText.Format("Task: %s", (m_pCurrTask) ? m_pCurrTask->GetName() : "None");
	((CStatic*)GetDlgItem(IDC_STATIC_TASK_NAME))->SetWindowText(sText);

	//also update the progress bar to reflect the change
	SetTaskProgress((m_pCurrTask) ? m_pCurrTask->GetProgress() : 0.0f);

	//if the user was viewing the previous task, then we want to start viewing the new
	//task, the same goes for if the user isn't viewing any tasks
	CTask* pViewedTask = GetViewedTask();
	if((pOldTask == pViewedTask) || (pViewedTask == NULL))
	{
		//find this new task
		for(uint32 nCurrTask = 0; nCurrTask < (uint32)GetTaskList()->GetCount(); nCurrTask++)
		{
			if((CTask*)GetTaskList()->GetItemData(nCurrTask) == m_pCurrTask)
			{
				//this is a match, select it
				GetTaskList()->SetCurSel(nCurrTask);
				ResetMessageList();
				break;
			}
		}
	}

	//save this task as our current subtask
	m_sSubTaskName = (m_pCurrTask) ? m_pCurrTask->GetName() : "";

	//update the title bar
	UpdateTitleNonIconic();	
	
	
	return 0;
}