// ColorItem.cpp : implementation file
//

#include "stdafx.h"
#include "CgDemoBy5000asi.h"
#include "ColorItem.h"
#include "mydemo.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CColorItem dialog


CColorItem::CColorItem(CWnd* pParent /*=NULL*/)
	: CDialog(CColorItem::IDD, pParent)
{
	//{{AFX_DATA_INIT(CColorItem)
		// NOTE: the ClassWizard will add member initialization here
	//}}AFX_DATA_INIT
}


void CColorItem::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CColorItem)
		// NOTE: the ClassWizard will add DDX and DDV calls here
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CColorItem, CDialog)
	//{{AFX_MSG_MAP(CColorItem)
	ON_BN_CLICKED(IDC_ZERO_RADIO, OnZeroRadio)
	ON_BN_CLICKED(IDC_TWENTYFIVE_RADIO, OnTwentyfiveRadio)
	ON_BN_CLICKED(IDC_SEVENTYFIVE_RADIO, OnSeventyfiveRadio)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CColorItem message handlers

BOOL CColorItem::OnInitDialog() 
{
	CDialog::OnInitDialog();


	// TODO: Add extra initialization here
	CButton *pButton = (CButton*)( GetDlgItem( IDC_SEVENTYFIVE_RADIO ) );
	pButton ->SetCheck( 1 );

	OnSeventyfiveRadio();


	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CColorItem::OnZeroRadio() 
{
	// TODO: Add your control notification handler code here

	ULONG *pwrLong = new ULONG[ BURST_LENGTH*BURST_NO ];
	ULONG ulItemWidth = BURST_LENGTH / 8;
	int i,j;

	for( i=0;i<BURST_NO;i++ )
		for( j=0;j<BURST_LENGTH;j++ )
		{
			switch( j / ulItemWidth )
			{
			case 0 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_ZERO_WHITE;
				break;
			case 1 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_ZERO_YELLOW;
				break;
			case 2 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_ZERO_CYAN;
				break;
			case 3 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_ZERO_GREEN;
				break;
			case 4 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_ZERO_PINK;
				break;
			case 5 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_ZERO_RED;
				break;
			case 6 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_ZERO_BLUE;
				break;
			case 7 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_ZERO_BLACK;
				break;
			}
		}

		for( j=0;j<BURST_NO;j++ )
			Seekfit_By5000asiplay_CgSetRectangle(0,j,720,1,&pwrLong[ j*BURST_LENGTH ], m_uCardNum);

		while (!Seekfit_By5000asiplay_CgUpdateOneFrame(m_uCardNum))
			Sleep(5);

	delete pwrLong;
	
}

void CColorItem::OnTwentyfiveRadio() 
{
	// TODO: Add your control notification handler code here
	ULONG *pwrLong = new ULONG[ BURST_LENGTH*BURST_NO ];
	ULONG ulItemWidth = BURST_LENGTH / 8;
	int i,j;

	for( i=0;i<BURST_NO;i++ )
		for( j=0;j<BURST_LENGTH;j++ )
		{
			switch( j / ulItemWidth )
			{
			case 0 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_25_WHITE;
				break;
			case 1 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_25_YELLOW;
				break;
			case 2 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_25_CYAN;
				break;
			case 3 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_25_GREEN;
				break;
			case 4 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_25_PINK;
				break;
			case 5 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_25_RED;
				break;
			case 6 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_25_BLUE;
				break;
			case 7 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_25_BLACK;
				break;
			}
		}

		for( j=0;j<BURST_NO;j++ )
			Seekfit_By5000asiplay_CgSetRectangle(0,j,720,1,&pwrLong[ j*BURST_LENGTH ], m_uCardNum);
		while (!Seekfit_By5000asiplay_CgUpdateOneFrame(m_uCardNum))
			Sleep(5);

	delete pwrLong;
	
}

void CColorItem::OnSeventyfiveRadio() 
{
	// TODO: Add your control notification handler code here
	ULONG *pwrLong = new ULONG[ BURST_LENGTH*BURST_NO ];
	ULONG ulItemWidth = BURST_LENGTH / 8;
	int i,j;

	for( i=0;i<BURST_NO;i++ )
		for( j=0;j<BURST_LENGTH;j++ )
		{
			switch( j / ulItemWidth )
			{
			case 0 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_75_WHITE;
				break;
			case 1 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_75_YELLOW;
				break;
			case 2 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_75_CYAN;
				break;
			case 3 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_75_GREEN;
				break;
			case 4 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_75_PINK;
				break;
			case 5 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_75_RED;
				break;
			case 6 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_75_BLUE;
				break;
			case 7 :
				pwrLong[ i*BURST_LENGTH + j ] = COLORITEM_75_BLACK;
				break;
			}
		}

		for( j=0;j<BURST_NO;j++ )
			Seekfit_By5000asiplay_CgSetRectangle(0,j,720,1,&pwrLong[ j*BURST_LENGTH ], m_uCardNum);
		while (!Seekfit_By5000asiplay_CgUpdateOneFrame(m_uCardNum))
			Sleep(5);

	delete pwrLong;
	
}
