示例#1
0
CLiveItem* CGraphListDlg::PrepareItem(CGraphItem* pItem)
{
	CLiveItem* pLive = new CLiveItem( LIST_COLUMNS, reinterpret_cast< DWORD_PTR>( pItem ) );
	pLive->SetImage( 0, I_IMAGECALLBACK );

	pLive->Set( 0, pItem->m_sName );

	return pLive;
}
示例#2
0
BOOL CDownloadReviewDlg::OnInitDialog() 
{
	CSkinDialog::OnInitDialog();

	CRect rcList;
	m_wndReviews.GetClientRect( &rcList );
	rcList.right -= GetSystemMetrics( SM_CXVSCROLL );

	CoolInterface.SetImageListTo( m_wndReviews, LVSIL_SMALL );
	m_wndReviews.InsertColumn( 0, _T("User"), LVCFMT_LEFT, 100, -1 );
	m_wndReviews.InsertColumn( 1, _T("Rating"), LVCFMT_CENTER, 90, 0 );
	m_wndReviews.InsertColumn( 2, _T("Comments"), LVCFMT_CENTER, rcList.right- 100 - 80, 1 );
	m_wndReviews.InsertColumn( 3, _T("Order"), LVCFMT_CENTER, 0, 2 );
	Skin.Translate( _T("CReviewList"), m_wndReviews.GetHeaderCtrl() );
	
	m_wndReviews.SendMessage( LVM_SETEXTENDEDLISTVIEWSTYLE,
		LVS_EX_FULLROWSELECT|LVS_EX_LABELTIP, LVS_EX_FULLROWSELECT|LVS_EX_LABELTIP );
	m_wndReviews.EnableToolTips();
	
	// Sort by order added- first at the top
	CLiveList::Sort( &m_wndReviews, 3, FALSE );
	CLiveList::Sort( &m_wndReviews, 3, FALSE );


	CLiveList pReviews( 4 );
	int nIndex = 1;
	// Lock while we're loading the list. (In case the download is destroyed)
	CSingleLock pLock( &Transfers.m_pSection, TRUE );
	
	if ( ! m_pDownload ) return FALSE;

	m_sReviewFileName = m_pDownload->m_sName;

	CDownloadReview* pReview = m_pDownload->GetFirstReview();

	while ( pReview )
	{
		CLiveItem* pItem = pReviews.Add( pReview );
	
		// Client picture
		// Note: We don't have pictures yet. Currently, it uses a star for a G2 
		// review, and a little person for everyone else
		switch ( pReview->m_nUserPicture )
		{
		case 0:
			pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_WIZARD ) );
			break;
		case 1:
			pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_PROFILE ) );
			break;
		case 2:
			pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_WIZARD ) );
			break;
		case 3:
			pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_PROFILE ) );
			break;
		default:
			pItem->SetImage( 0, CoolInterface.ImageForID( ID_TOOLS_PROFILE ) );
		}
		
		pItem->Set( 0, pReview->m_sUserName );

		int nRating = min( pReview->m_nFileRating, 6 );
		nRating = max ( nRating, 0 );
		CString strRating;
		LoadString( strRating, IDS_RATING_NORATING + nRating );
		pItem->Set( 1, strRating );

		
		pItem->Set( 2, pReview->m_sFileComments );
		pItem->Format( 3, _T("%i"), nIndex );
		

		nIndex++;
		pReview = pReview->m_pNext;
	}

	pLock.Unlock();

	//m_wndReviews.SetFont( &theApp.m_gdiFontBold );

	pReviews.Apply( &m_wndReviews, TRUE );

	// Set window icon
	SkinMe( NULL, IDR_MEDIAFRAME );

	UpdateData( FALSE );
	
	return TRUE;
}
示例#3
0
void CSchedulerWnd::Update(int nColumn, BOOL bSort)
{
	HRESULT hr;

	CComPtr< IEnumWorkItems > pEnum;
	hr = m_pScheduler->Enum( &pEnum );
	if ( FAILED( hr ) )
		return;

	CLiveList pLiveList( 6 );

	int nCount = 1;
	for ( ; ; )
	{
		LPWSTR* pszTaskName = NULL;
		hr = pEnum->Next( 1, &pszTaskName, NULL );
		if ( hr != S_OK )
			// No tasks left
			break;
		CString sTaskName = *pszTaskName;
		CoTaskMemFree( pszTaskName );

		CString sVendor = sTaskName.SpanExcluding( _T(".") );
		if ( sVendor.Compare( CLIENT_NAME_T ) != 0 )
			// Wrong name
			continue;
		DWORD_PTR nNumber = _tstoi( sTaskName.Mid( sVendor.GetLength() + 1 ) );

		CComPtr< ITask > pTask;
		hr = m_pScheduler->Activate( sTaskName, IID_ITask, (IUnknown**)&pTask );
		if ( FAILED( hr ) )
			// Can't open task
			continue;

		DWORD nFlags = 0;
		hr = pTask->GetFlags( &nFlags );
		BOOL bActive = ( ( nFlags & TASK_FLAG_DISABLED ) != TASK_FLAG_DISABLED );

		HRESULT hrStatus = S_OK;
		hr = pTask->GetStatus( &hrStatus );

		CString sTriggerString;
		LPWSTR szTriggerString = NULL;
		hr = pTask->GetTriggerString( 0, &szTriggerString );
		if ( hr == S_OK )
		{
			sTriggerString = szTriggerString;
			CoTaskMemFree( szTriggerString );
		}

		CString strDate, strTime;
		SYSTEMTIME pTime = {};
		hr = pTask->GetNextRunTime( &pTime );
		if ( hr == S_OK )
		{
			GetDateFormat( LOCALE_USER_DEFAULT, DATE_SHORTDATE, &pTime, NULL, strDate.GetBuffer( 64 ), 64 );
			GetTimeFormat( LOCALE_USER_DEFAULT, TIME_NOSECONDS, &pTime, NULL, strTime.GetBuffer( 64 ), 64 );
			strDate.ReleaseBuffer();
			strTime.ReleaseBuffer();
		}
		else if ( hr == SCHED_S_TASK_DISABLED )
			bActive = FALSE;

		CString sStatus;
		DWORD nExitCode = 0;
		hr = pTask->GetExitCode( &nExitCode );
		if ( SUCCEEDED( hr ) )
		{
			sStatus.Format( _T("0x%08X"), nExitCode );
		}

		int nAction = -1;
		LPWSTR szParams = NULL;
		hr = pTask->GetParameters( &szParams );
		if ( SUCCEEDED( hr ) )
		{
			CString sParams = szParams;
			CoTaskMemFree( szParams );

			int nPos = sParams.Find( _T("task") );
			if ( nPos != -1 )
				nAction = _tstoi( sParams.Mid( nPos + 4 ) );
			else
				nAction = SYSTEM_START;
		}

		CString sComment;
		LPWSTR szComment = NULL;
		hr = pTask->GetComment( &szComment );
		if ( SUCCEEDED( hr ) )
		{
			sComment = szComment;
			CoTaskMemFree( szComment );
		}

		//Adding tasks we got from Scheduler to temp list and getting a handle
		//to modify their properties according to scheduler item.
		CLiveItem* pItem = pLiveList.Add( nNumber );

		if ( ( nFlags & TASK_FLAG_DISABLED ) != TASK_FLAG_DISABLED )
			pItem->SetImage( 0, SCHEDULE_ITEM_ACTIVE );
		else 
			pItem->SetImage( 0, SCHEDULE_ITEM_INACTIVE );

		//Action column
		switch ( nAction )
		{
		case BANDWIDTH_FULLSPEED:
			pItem->Set( 0, LoadString( IDS_SCHEDULER_BANDWIDTH_FULLSPEED ) );
			break;
		case BANDWIDTH_REDUCEDSPEED:
			pItem->Set( 0, LoadString( IDS_SCHEDULER_BANDWIDTH_REDUCEDSPEED ) );
			break;
		case BANDWIDTH_STOP:
			pItem->Set( 0, LoadString( IDS_SCHEDULER_BANDWIDTH_STOP ) );
			break;
		case SYSTEM_DIALUP_DC:
			pItem->Set( 0, LoadString( IDS_SCHEDULER_SYSTEM_DIALUP_DC ) );
			break;
		case SYSTEM_EXIT:
			pItem->Set( 0, LoadString( IDS_SCHEDULER_SYSTEM_EXIT ) );
			break;
		case SYSTEM_SHUTDOWN:
			pItem->Set( 0, LoadString( IDS_SCHEDULER_SYSTEM_SHUTDOWN ) );
			break;
		case SYSTEM_START:
			pItem->Set( 0, LoadString( IDS_SCHEDULER_SYSTEM_START ) );
			break;
		}

		// Date column
		pItem->Set( 1, sTriggerString );

		// Time column
		pItem->Set( 2, strDate + _T(" ") + strTime );

		// Active column
		if ( bActive )
		{
			switch ( hrStatus )
			{
			case SCHED_S_TASK_NO_MORE_RUNS:
				pItem->Set( 3, LoadString( IDS_SCHEDULER_TASK_DONE ) );
				break;
			case SCHED_S_TASK_RUNNING:
				pItem->Set( 3, LoadString( IDS_SCHEDULER_TASK_ACTIVE ) );
				break;
			default:
				pItem->Set( 3, LoadString( IDS_SCHEDULER_TASK_WAITING ) );
			}
		}
		else
			pItem->Set( 3, LoadString( IDS_SCHEDULER_TASK_INACTIVE ) );

		// Status column 
		pItem->Set( 4, sStatus );

		//Description column
		pItem->Set( 5, sComment );

		++nCount;
	}

	// In case scheduler gave nothing
	if ( nCount == 1 )
	{
		CLiveItem* pDefault = pLiveList.Add( (DWORD_PTR)0 );
		pDefault->Set( 0, LoadString( IDS_SCHEDULER_NOTASK ) );
		pDefault->SetImage( 0, SCHEDULE_NO_ITEM );
	}

	if ( nColumn >= 0 )
	{
		SetWindowLongPtr( m_wndList.GetSafeHwnd(), GWLP_USERDATA, 0 - nColumn - 1 );
	}

	pLiveList.Apply( &m_wndList, bSort );	//Putting items in the main list

	tLastUpdate = GetTickCount();	// Update time after it's done doing its work
}