// SetAlarm.cpp : implementation file
//

#include "stdafx.h"
#include "YtvAlarm.h"
#include "YtvSetAlarm.h"

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

/////////////////////////////////////////////////////////////////////////////
// YtvSetAlarm dialog


YtvSetAlarm::YtvSetAlarm(CWnd* pParent /*=NULL*/)
	: CDialog(YtvSetAlarm::IDD, pParent)
{
	//{{AFX_DATA_INIT(YtvSetAlarm)
	m_strAlarmName = _T("");
	m_bDeleteAlarm = FALSE;
	m_bDeleteAlarmGroup = FALSE;
	m_bDeleteAllAlarms = FALSE;
	m_bActivateAlarm = TRUE;
	m_uAlarmNumber = 0;
	m_bMaxTimeIntervalAlarm = FALSE;	
	//}}AFX_DATA_INIT
	struct tm t;
	long l;
	time(&l);
	t=*localtime(&l);
	t.tm_hour=0;
	t.tm_min=0;
	t.tm_sec=0;
	m_ictimeinterval = mktime(&t);
	m_ctimeinterval=m_ictimeinterval;
	m_vHour.vt=VT_I4;
	m_vMinute.vt=VT_I4;
	m_vSecond.vt=VT_I4;
	m_vHour.intVal=0;
	m_vMinute.intVal=0;
	m_vSecond.intVal=0;


}


void YtvSetAlarm::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(YtvSetAlarm)
	DDX_Control(pDX, IDC_TIMEINTERVALPIC, m_timeinterval);
	DDX_Text(pDX, IDC_ALARM_NAME, m_strAlarmName);
	DDX_Check(pDX, IDC_DELETE_ALARM, m_bDeleteAlarm);
	DDX_Check(pDX, IDC_DELETE_ALARM_GROUP, m_bDeleteAlarmGroup);
	DDX_Check(pDX, IDC_DELETE_ALL_ALARMS, m_bDeleteAllAlarms);
	DDX_Check(pDX, IDC_ACTIVATE_ALARM, m_bActivateAlarm);
	DDX_Text(pDX, IDC_ALARM_NUMBER, m_uAlarmNumber);
	DDX_Control(pDX, IDC_TIMEPICKER, m_ctrlTimePicker);
	DDX_Check(pDX, IDC_MAX_TIME_ALARM, m_bMaxTimeIntervalAlarm);
	DDX_DateTimeCtrl(pDX, IDC_TIMEINTERVALPIC, m_ctimeinterval);
	//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(YtvSetAlarm, CDialog)
	//{{AFX_MSG_MAP(YtvSetAlarm)
	ON_BN_CLICKED(IDC_MAX_TIME_ALARM, OnMaxTimeAlarm)
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// YtvSetAlarm message handlers

void YtvSetAlarm::OnOK() 
{
	// TODO: Add extra validation here
	//CTime timeDest;
	m_vHour=m_ctrlTimePicker.GetHour();
	m_vMinute=m_ctrlTimePicker.GetMinute();
	m_vSecond=m_ctrlTimePicker.GetSecond();
	CDialog::OnOK();
}
void YtvSetAlarm::OnCancel() 
{
	// TODO: Add extra validation here
	CDialog::OnCancel();
}
BOOL YtvSetAlarm::OnInitDialog() 
{
	CDialog::OnInitDialog();
	
	// TODO: Add extra initialization here	
	m_ctrlTimePicker.SetHour(m_vHour);
	m_ctrlTimePicker.SetMinute(m_vMinute);
	m_ctrlTimePicker.SetSecond(m_vSecond);
	m_timeinterval.SetFormat("HH:mm:ss");
    m_ctimeinterval=m_ictimeinterval;
    m_timeinterval.SetTime(&m_ictimeinterval);
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void YtvSetAlarm::OnMaxTimeAlarm() 
{
	// TODO: Add your control notification handler code here

}

void YtvSetAlarm::OnTimer(UINT nIDEvent) 
{
	// TODO: Add your message handler code here and/or call default
	CDialog::OnTimer(nIDEvent);
}
