Old fashion design for PC-104
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

4 years ago
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
​
  1. //----------------------------------------------------------------------------
  2. // Laser Guard Ltd.
  3. // Copyright � 2000-2002. All Rights Reserved.
  4. // Version 1.0 01/01/2000
  5. // Last modification: 08/10/2003
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: GuardDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of GuardDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // GuardDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "chicago.h"
  18. #include "GuardDlg.h"
  19. #include "..\..\LgLib\Version.h"
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CGuardDlg dialog
  27. CGuardDlg::CGuardDlg(CWnd* pParent /*=NULL*/)
  28. : CDialog(CGuardDlg::IDD, pParent)
  29. {
  30. //{{AFX_DATA_INIT(CGuardDlg)
  31. m_strGuardNew = _T("");
  32. m_strGuardOld = _T("");
  33. //}}AFX_DATA_INIT
  34. m_bOldGuard = FALSE;
  35. m_pSensorArray = NULL;
  36. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CGuardDlg::CGuardDlg") );
  37. }
  38. void CGuardDlg::DoDataExchange(CDataExchange* pDX)
  39. {
  40. CDialog::DoDataExchange(pDX);
  41. //{{AFX_DATA_MAP(CGuardDlg)
  42. DDX_Control(pDX, IDC_EDIT_GUARD_OLD, m_GuardOld);
  43. DDX_Control(pDX, IDC_EDIT_GUARD_NEW, m_GuardNew);
  44. DDX_Text(pDX, IDC_EDIT_GUARD_NEW, m_strGuardNew);
  45. DDX_Text(pDX, IDC_EDIT_GUARD_OLD, m_strGuardOld);
  46. //}}AFX_DATA_MAP
  47. }
  48. BEGIN_MESSAGE_MAP(CGuardDlg, CDialog)
  49. //{{AFX_MSG_MAP(CGuardDlg)
  50. ON_WM_TIMER()
  51. //}}AFX_MSG_MAP
  52. END_MESSAGE_MAP()
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CGuardDlg message handlers
  55. int CGuardDlg::DoModal( BOOL bOld )
  56. {
  57. m_dwStartTime = ::GetTickCount() + 60000UL;
  58. m_bOldGuard = bOld;
  59. int iResult = CDialog::DoModal();
  60. if( iResult == IDOK )
  61. {
  62. if( m_pSensorArray->CheckGuard( (LPSTR)(LPCTSTR)m_strGuardNew ) )
  63. {
  64. CString str;
  65. if( m_bOldGuard )
  66. {
  67. if( m_strGuardOld != m_LastGuard )
  68. {
  69. m_ErrorString = "it needs to enter right old guard's name";
  70. return IDRETRY;
  71. }
  72. str.Format( "guard \"%s\" changed by \"%s\"", m_LastGuard, m_strGuardNew );
  73. }
  74. else str.Format( "guard \"%s\"", m_strGuardNew );
  75. m_pSensorArray->GetEventQueue()->PostEvent( LGS_EVENT_GUARD, 0, 0, 0, RGB(0xFF,0xFF,0xFF), (LPSTR)(LPCTSTR)str );
  76. m_LastGuard = m_strGuardNew;
  77. return iResult;
  78. }
  79. else
  80. {
  81. m_ErrorString = "Guard with this name does not exist";
  82. return IDRETRY;
  83. }
  84. }
  85. return iResult;
  86. }
  87. BOOL CGuardDlg::OnInitDialog()
  88. {
  89. CDialog::OnInitDialog();
  90. if( m_bOldGuard ) m_GuardOld.EnableWindow( TRUE );
  91. else m_GuardOld.EnableWindow( FALSE );
  92. m_GuardNew.SetWindowText( "" );
  93. m_GuardOld.SetWindowText( "" );
  94. return TRUE;
  95. }
  96. void CGuardDlg::OnTimer(UINT nIDEvent)
  97. {
  98. if( ::GetTickCount() >= m_dwStartTime )
  99. EndDialog( IDCANCEL );
  100. else CDialog::OnTimer(nIDEvent);
  101. }
  102. void CGuardDlg::SetSensorArray(CSensorArray *pSensorArray)
  103. {
  104. m_pSensorArray = pSensorArray;
  105. }
  106. CString& CGuardDlg::GetErrorString()
  107. {
  108. return m_ErrorString;
  109. }