// DlgDownload.cpp : implementation file
//

#include "stdafx.h"
#include "netplayx.h"
#include "DlgDownload.h"
#include "NetPlayXCtl.h"

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

/////////////////////////////////////////////////////////////////////////////
// CDlgDownload dialog


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


void CDlgDownload::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CDlgDownload)
	DDX_Control(pDX, IDC_PROGRESS, m_progress);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CDlgDownload, CDialog)
	//{{AFX_MSG_MAP(CDlgDownload)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CDlgDownload message handlers

void CDlgDownload::OnOK() 
{
}

void CDlgDownload::OnCancel() 
{
	m_pParent->CancelDownload();
}

void CDlgDownload::OnFileDownload(float downloadpos)
{
	CString		szInfo;

	if(m_pParent->m_language)
		szInfo.Format(IDS_STRING251,int(downloadpos*100));
	else
		szInfo.Format(IDS_STRING252,int(downloadpos*100));
	GetDlgItem(IDC_STATIC_INFO)->SetWindowText(szInfo);
	m_progress.SetPos(downloadpos*100);
}

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

	CString		szInfo;
	
	if(m_pParent->m_language)
		szInfo.Format(IDS_STRING251,0);
	else
	{
		szInfo.Format(IDS_STRING252,0);
		GetDlgItem(IDCANCEL)->SetWindowText("Cancel");
	}

	GetDlgItem(IDC_STATIC_INFO)->SetWindowText(szInfo);
	m_progress.SetRange(0,100);
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgDownload::OnFileDownloadFinish()
{
	CString		szInfo;

	if(m_pParent->m_language)
		szInfo.Format(IDS_STRING251,100);
	else
		szInfo.Format(IDS_STRING252,100);

	GetDlgItem(IDC_STATIC_INFO)->SetWindowText(szInfo);
	m_progress.SetPos(100);
	Sleep(1000);
	EndDialog(IDOK);
}
