You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
132 lines
3.1 KiB
132 lines
3.1 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: GuardDlg.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of GuardDlg.cpp
|
|
//----------------------------------------------------------------------------
|
|
// GuardDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "chicago.h"
|
|
#include "GuardDlg.h"
|
|
#include "..\..\LgLib\Version.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CGuardDlg dialog
|
|
|
|
|
|
CGuardDlg::CGuardDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CGuardDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CGuardDlg)
|
|
m_strGuardNew = _T("");
|
|
m_strGuardOld = _T("");
|
|
//}}AFX_DATA_INIT
|
|
m_bOldGuard = FALSE;
|
|
m_pSensorArray = NULL;
|
|
|
|
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CGuardDlg::CGuardDlg") );
|
|
}
|
|
|
|
|
|
void CGuardDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CGuardDlg)
|
|
DDX_Control(pDX, IDC_EDIT_GUARD_OLD, m_GuardOld);
|
|
DDX_Control(pDX, IDC_EDIT_GUARD_NEW, m_GuardNew);
|
|
DDX_Text(pDX, IDC_EDIT_GUARD_NEW, m_strGuardNew);
|
|
DDX_Text(pDX, IDC_EDIT_GUARD_OLD, m_strGuardOld);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CGuardDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CGuardDlg)
|
|
ON_WM_TIMER()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CGuardDlg message handlers
|
|
|
|
int CGuardDlg::DoModal( BOOL bOld )
|
|
{
|
|
m_dwStartTime = ::GetTickCount() + 60000UL;
|
|
m_bOldGuard = bOld;
|
|
int iResult = CDialog::DoModal();
|
|
if( iResult == IDOK )
|
|
{
|
|
if( m_pSensorArray->CheckGuard( (LPSTR)(LPCTSTR)m_strGuardNew ) )
|
|
{
|
|
CString str;
|
|
|
|
if( m_bOldGuard )
|
|
{
|
|
if( m_strGuardOld != m_LastGuard )
|
|
{
|
|
m_ErrorString = "it needs to enter right old guard's name";
|
|
return IDRETRY;
|
|
}
|
|
str.Format( "guard \"%s\" changed by \"%s\"", m_LastGuard, m_strGuardNew );
|
|
}
|
|
else str.Format( "guard \"%s\"", m_strGuardNew );
|
|
|
|
m_pSensorArray->GetEventQueue()->PostEvent( LGS_EVENT_GUARD, 0, 0, 0, RGB(0xFF,0xFF,0xFF), (LPSTR)(LPCTSTR)str );
|
|
|
|
m_LastGuard = m_strGuardNew;
|
|
|
|
return iResult;
|
|
}
|
|
else
|
|
{
|
|
m_ErrorString = "Guard with this name does not exist";
|
|
return IDRETRY;
|
|
}
|
|
}
|
|
return iResult;
|
|
}
|
|
|
|
BOOL CGuardDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
if( m_bOldGuard ) m_GuardOld.EnableWindow( TRUE );
|
|
else m_GuardOld.EnableWindow( FALSE );
|
|
|
|
m_GuardNew.SetWindowText( "" );
|
|
m_GuardOld.SetWindowText( "" );
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CGuardDlg::OnTimer(UINT nIDEvent)
|
|
{
|
|
if( ::GetTickCount() >= m_dwStartTime )
|
|
EndDialog( IDCANCEL );
|
|
else CDialog::OnTimer(nIDEvent);
|
|
}
|
|
|
|
void CGuardDlg::SetSensorArray(CSensorArray *pSensorArray)
|
|
{
|
|
m_pSensorArray = pSensorArray;
|
|
}
|
|
|
|
CString& CGuardDlg::GetErrorString()
|
|
{
|
|
return m_ErrorString;
|
|
}
|