// TraversalProgressDlg.cpp : implementation file
//

#include "stdafx.h"
#include "SKOKO.h"
#include "Traversal.h"
#include "TraversalProgressDlg.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTraversalProgressDlg dialog


CTraversalProgressDlg::CTraversalProgressDlg(
  CFileSystemTraversal* pTraversal, CWnd* pParent /*=NULL*/) :
    CDialog(CTraversalProgressDlg::IDD, pParent),
    m_pTraversal(pTraversal)
{
  //{{AFX_DATA_INIT(CTraversalProgressDlg)
  //}}AFX_DATA_INIT
}


void CTraversalProgressDlg::DoDataExchange(CDataExchange* pDX)
{
  CDialog::DoDataExchange(pDX);
  //{{AFX_DATA_MAP(CTraversalProgressDlg)
  //}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CTraversalProgressDlg, CDialog)
  //{{AFX_MSG_MAP(CTraversalProgressDlg)
  ON_WM_TIMER()
  //}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTraversalProgressDlg message handlers

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

  Update();

  CRect rc;
  GetClientRect(rc);
  rc.left = rc.right - 50;
  rc.top += 10;

  VERIFY(m_aniCtrl.Create(
    WS_CHILD | WS_VISIBLE | ACS_TRANSPARENT | ACS_AUTOPLAY,
    rc, this, 666));
  VERIFY(m_aniCtrl.Open(IDR_AVI_SEARCH));

  SetTimer(1, 100, NULL);
  
  return TRUE;  // return TRUE unless you set the focus to a control
                // EXCEPTION: OCX Property Pages should return FALSE
}

void CTraversalProgressDlg::OnCancel() 
{
  CWaitCursor wc;
  m_pTraversal->stop();
  
  CDialog::OnCancel();
}

void CTraversalProgressDlg::OnOK()
{
  CWaitCursor wc;
  m_pTraversal->stop();
  
  CDialog::OnOK();
}

void CTraversalProgressDlg::OnTimer(UINT nIDEvent) 
{
  Update();
  CDialog::OnTimer(nIDEvent);
}

void CTraversalProgressDlg::Update( void )
{
  SetDlgItemInt(IDC_STATIC_DIR_COUNT, m_pTraversal->dirCount(), FALSE);
  SetDlgItemInt(IDC_STATIC_FILE_COUNT, m_pTraversal->fileCount(), FALSE);
  SetDlgItemInt(IDC_STATIC_ERR_COUNT, m_pTraversal->errCount(), FALSE);
  SetDlgItemText(IDC_STATIC_CUR_DIR, m_pTraversal->curDir());
}
