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.

216 lines
5.7 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: 13/04/2001
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: SensorPropertyDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of SensorPropertyDlg.cpp
  13. //----------------------------------------------------------------------------
  14. // SensorPropertyDlg.cpp : implementation file
  15. //
  16. #include "stdafx.h"
  17. #include "chicago.h"
  18. #include "SensorSPRU.h"
  19. #include "Zone.h"
  20. #include "SensorPropertyDlg.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CSensorPropertyDlg dialog
  28. CSensorPropertyDlg::CSensorPropertyDlg(CWnd* pParent /*=NULL*/)
  29. : CDialog(CSensorPropertyDlg::IDD, pParent)
  30. {
  31. //{{AFX_DATA_INIT(CSensorPropertyDlg)
  32. m_iSensorAddress = 0;
  33. m_strSensorName = _T("");
  34. m_strSensorState = _T("");
  35. m_strSensorType = _T("");
  36. //}}AFX_DATA_INIT
  37. m_pSensor = NULL;
  38. }
  39. void CSensorPropertyDlg::DoDataExchange(CDataExchange* pDX)
  40. {
  41. CDialog::DoDataExchange(pDX);
  42. //{{AFX_DATA_MAP(CSensorPropertyDlg)
  43. DDX_Control(pDX, IDC_STATIC_IMAGE, m_StaticImage);
  44. DDX_Control(pDX, IDC_BUTTON_SENSOR_ENABLE, m_ButtonSensorEnable);
  45. DDX_Text(pDX, IDC_EDIT_SENSOR_ADDRESS, m_iSensorAddress);
  46. DDX_Text(pDX, IDC_EDIT_SENSOR_NAME, m_strSensorName);
  47. DDX_Text(pDX, IDC_EDIT_SENSOR_STATE, m_strSensorState);
  48. DDX_Text(pDX, IDC_EDIT_SENSOR_TYPE, m_strSensorType);
  49. //}}AFX_DATA_MAP
  50. }
  51. BEGIN_MESSAGE_MAP(CSensorPropertyDlg, CDialog)
  52. //{{AFX_MSG_MAP(CSensorPropertyDlg)
  53. ON_WM_MOVING()
  54. ON_BN_CLICKED(IDC_BUTTON_SENSOR_ENABLE, OnButtonSensorEnable)
  55. ON_WM_SIZING()
  56. ON_WM_TIMER()
  57. //}}AFX_MSG_MAP
  58. END_MESSAGE_MAP()
  59. /////////////////////////////////////////////////////////////////////////////
  60. // CSensorPropertyDlg message handlers
  61. void CSensorPropertyDlg::OnMoving(UINT fwSide, LPRECT pRect)
  62. {
  63. CRect rect;
  64. GetParent()->GetClientRect( &rect );
  65. GetParent()->ClientToScreen( &rect );
  66. if( pRect->left < rect.left )
  67. {
  68. pRect->right += rect.left - pRect->left;
  69. pRect->left = rect.left;
  70. }
  71. if( pRect->top < rect.top )
  72. {
  73. pRect->bottom += rect.top - pRect->top;
  74. pRect->top = rect.top;
  75. }
  76. if( pRect->right > rect.right )
  77. {
  78. pRect->left -= pRect->right - rect.right;
  79. pRect->right = rect.right;
  80. }
  81. if( pRect->bottom > rect.bottom )
  82. {
  83. pRect->top -= pRect->bottom - rect.bottom;
  84. pRect->bottom = rect.bottom;
  85. }
  86. CDialog::OnMoving( fwSide, pRect );
  87. }
  88. void CSensorPropertyDlg::SetSensor(CSensor *pSensor)
  89. {
  90. m_pSensor = pSensor;
  91. m_bUpdate = TRUE;
  92. }
  93. void CSensorPropertyDlg::OnButtonSensorEnable()
  94. {
  95. if( m_pSensor->GetState() == CSensor::DISABLE )
  96. m_pSensor->Enable( TRUE );
  97. else m_pSensor->Enable( FALSE );
  98. m_pSensor->GetZone()->UpdateState();
  99. GetParent()->SendMessage( WM_SENSOR_UPDATE, 0, (LONG)m_pSensor );
  100. }
  101. void CSensorPropertyDlg::UpdateSensor()
  102. {
  103. if( m_pSensor )
  104. {
  105. m_bUpdate = TRUE;
  106. // SetSensor( m_pSensor );
  107. }
  108. }
  109. void CSensorPropertyDlg::OnSizing(UINT fwSide, LPRECT pRect)
  110. {
  111. CRect rect;
  112. GetParent()->GetClientRect( &rect );
  113. GetParent()->ClientToScreen( &rect );
  114. if( pRect->left < rect.left ) pRect->left = rect.left;
  115. if( pRect->right > rect.right ) pRect->right = rect.right;
  116. if( pRect->top < rect.top ) pRect->top = rect.top;
  117. if( pRect->bottom > rect.bottom ) pRect->bottom = rect.bottom;
  118. CDialog::OnSizing( fwSide, pRect );
  119. }
  120. void CSensorPropertyDlg::OnTimer(UINT nIDEvent)
  121. {
  122. m_bInverse = nIDEvent;
  123. if( m_bUpdate && m_pSensor )
  124. {
  125. m_strSensorName = m_pSensor->GetName();
  126. switch( m_pSensor->GetType() )
  127. {
  128. case CSensor::LGS: m_strSensorType = "LGS"; break;
  129. case CSensor::DTR: m_strSensorType = "DTR"; break;
  130. }
  131. m_pSensor->GetStateString( m_strSensorState );
  132. if( m_pSensor->GetState() == CSensor::DISABLE )
  133. m_ButtonSensorEnable.SetWindowText( "Enable" );
  134. else
  135. m_ButtonSensorEnable.SetWindowText( "Disable" );
  136. m_iSensorAddress = m_pSensor->GetAddress();
  137. if( m_pSensor->GetType()==CSensor::DTR )
  138. {
  139. CSensorSPRU *pSensorSPRU = (CSensorSPRU *)m_pSensor;
  140. CRect rect;
  141. m_StaticImage.GetClientRect( &rect );
  142. CBitmap *pBitmap = m_pSensor->GetBitmap();
  143. CBitmap *pBitmapBackgroundOld = m_OverlayDCBackground.SelectObject( pBitmap );
  144. CBitmap *pBitmapOld = m_OverlayDC.SelectObject( &m_OverlayBitmap );
  145. m_OverlayDC.BitBlt( 0,0, rect.Width(), rect.Height(),
  146. &m_OverlayDCBackground, 0, 0, SRCCOPY );
  147. pSensorSPRU->PaintBits( &m_OverlayDC, rect, m_bInverse );
  148. m_OverlayDC.SelectObject( pBitmapOld );
  149. m_OverlayDCBackground.SelectObject( pBitmapBackgroundOld );
  150. m_StaticImage.SetBitmap( m_OverlayBitmap );
  151. }
  152. UpdateData( FALSE );
  153. m_bUpdate = m_pSensor->GetBlinkState();
  154. }
  155. CDialog::OnTimer(nIDEvent);
  156. }
  157. BOOL CSensorPropertyDlg::OnInitDialog()
  158. {
  159. CDialog::OnInitDialog();
  160. m_bUpdate = TRUE;
  161. CRect rect;
  162. m_StaticImage.GetClientRect( rect );
  163. CDC *pDC = m_StaticImage.GetDC();
  164. m_OverlayDC.CreateCompatibleDC( pDC );
  165. m_OverlayDCBackground.CreateCompatibleDC( pDC );
  166. m_OverlayBitmap.CreateCompatibleBitmap( pDC, rect.Width(), rect.Height() );
  167. m_StaticImage.ReleaseDC( pDC );
  168. CBitmap *pBitmapOld = m_OverlayDC.SelectObject( &m_OverlayBitmap );
  169. m_OverlayDC.FillSolidRect( &rect, 0x000000 );
  170. m_OverlayDC.SelectObject( pBitmapOld );
  171. m_StaticImage.SetBitmap( m_OverlayBitmap );
  172. return TRUE; // return TRUE unless you set the focus to a control
  173. // EXCEPTION: OCX Property Pages should return FALSE
  174. }