// Advnext.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "tutorial.h"
#include "tmouse.h"
#include "mainfrm.h"
#include "time.h"
#include "TrcDlg.h"
                    
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif                       

extern BOOL g_mbCanDoNext;

extern void PopupMenu(CMenu &menu);
extern void Delay(int nDelay,BOOL bShow=0);
/*-------------------------------------------------------*/
/*               Trace Next                              */
/*-------------------------------------------------------*/  
void CMainFrame::AdvanceTrace()
{ 
 switch(m_uNextAction){
    case 1:                     
        Trace_Control();
        break;
    case 2:   
        m_pMsgWnd->SetContent("TRCTRCF.TXT");
        SetArrow(2,1,60);
        break;
    case 3:                    
        Trace_Switch();
        break;         
    case 4:      
        Trace_Timer();
        break; 
    case 5:
    case 6:
    case 7:
    case 8:
        Trace_Pre(m_uNextAction-4);          
        if(m_uNextAction==8)
          {m_uNextCaseID=ID_ADVANCE_TRIGGER;
           m_uNextAction=0;}
        break;
    default:
        m_uNextCaseID=ID_ADVANCE_TRIGGER;
        m_uNextAction=0;
        break;
    }  
}

/*---------------------------------------------------------*/
/*              Trace Action                               */
/*---------------------------------------------------------*/

void CMainFrame::Trace_Pre(int nIdx)
{                    
   Delay(100);
   char lpFile[50];                     
   int  nOffset;
   switch(nIdx){
      case 1:
         nOffset=200+50;
         lstrcpy(lpFile,"TRCPRE.TXT");
         break;
      case 2:        
         nOffset=180+50;
         lstrcpy(lpFile,"TRCCENT.TXT");
         break;
      case 3:       
         nOffset=160+50;
         lstrcpy(lpFile,"TRCPOST.TXT");
         break;
      case 4:       
         nOffset=140+50;
         lstrcpy(lpFile,"TRCDELAY.TXT");
         break;
      default:
         return;
   }
   m_pMsgWnd->SetContent(lpFile);
   SetArrow(2,0,nOffset);

/*   
   CRect rect;  
   m_pMsgWnd->GetWindowRect(&rect); 
   rect.left-=210;
   rect.top+=nOffset;
   rect.right=rect.left+200;
   rect.bottom=rect.top+50;
   CWindowDC dc(m_pDlg);
   MoveArrow( dc,rect,2,0);  
   m_bDC=1;
*/   
} 

void CMainFrame::Trace_Timer()
{                     
  Delay(100);
  m_pMsgWnd->SetTitle("TRACE - CONTROL");
  CRect rect(200,160,430,260);
  CArrowMsgDlg *pADlg=new CArrowMsgDlg(rect,IDS_ADVANCE_TRC_TIMER
                                           ,1,m_pDlg);
  pADlg->ShowWindow(SW_SHOW); 
  m_pDlg->SetFocus();

}  

void CMainFrame::Trace_Switch()
{
  m_pMsgWnd->SetTitle("TRACE - CONTROL");
  CRect rect(200,130,400,230);
  CArrowMsgDlg *pADlg=new CArrowMsgDlg(rect,IDS_ADVANCE_TRC_SWITCH
                                           ,1,m_pDlg);
  pADlg->ShowWindow(SW_SHOW); 
  m_pDlg->SetFocus();

}  

void CMainFrame::Trace_Control()
{
  ((CTrcDlg *)m_pDlg)->SelTrace();
  m_pMsgWnd->SetTitleFont(24,10,1600);
  //int nHeight=36,int nWidth=18,int nWeight=1600);
  m_pMsgWnd->SetTitle("TRACE - FEATURE");
  m_pMsgWnd->SetContent("TRCTRCI.TXT");
} 