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.

92 lines
1.9 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: 25/11/2001
  6. // PROJECT:
  7. // SUBSYSTEM:
  8. // FILE: AreaSensorWnd.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of AreaSensorWnd.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "chicago.h"
  16. #include "AreaSensorWnd.h"
  17. #ifdef _DEBUG
  18. #undef THIS_FILE
  19. static char THIS_FILE[]=__FILE__;
  20. #define new DEBUG_NEW
  21. #endif
  22. BEGIN_MESSAGE_MAP(CAreaSensorWnd, CAreaWnd )
  23. //{{AFX_MSG_MAP(CAreaSensorWnd)
  24. //}}AFX_MSG_MAP
  25. END_MESSAGE_MAP()
  26. CAreaSensorWnd::CAreaSensorWnd()
  27. {
  28. m_pSensorArray = NULL;
  29. m_pActiveSensor = NULL;
  30. m_bOddUpdate = FALSE;
  31. }
  32. CAreaSensorWnd::~CAreaSensorWnd()
  33. {
  34. }
  35. BOOL CAreaSensorWnd::SetActiveSensor( CSensor *pActiveSensor )
  36. {
  37. if( pActiveSensor != m_pActiveSensor )
  38. {
  39. m_pActiveSensor = pActiveSensor;
  40. InvalidateRect( NULL );
  41. return TRUE;
  42. }
  43. return FALSE;
  44. }
  45. void CAreaSensorWnd::UpdateInfo( BOOL bOdd )
  46. {
  47. m_bOddUpdate = bOdd;
  48. if( GetSafeHwnd() )
  49. {
  50. CClientDC dc( this );
  51. OnDrawTimer( &dc );
  52. }
  53. }
  54. void CAreaSensorWnd::OnDraw(CDC *pDC)
  55. {
  56. CAreaWnd::OnDraw( pDC );
  57. OnDrawTimer( pDC );
  58. }
  59. void CAreaSensorWnd::OnDrawTimer( CDC *pDC )
  60. {
  61. for( int i = 0; i < m_pSensorArray->GetSensorCount(); i++ )
  62. {
  63. CSensor *pSensor = m_pSensorArray->GetSensor( i );
  64. ASSERT( pSensor );
  65. SDPOINT dPoint = pSensor->GetPosition();
  66. CLgDPoint dp( dPoint.x, dPoint.y );
  67. CPoint p = AreaToWindow( &dp );
  68. CRect rect;
  69. if( pSensor == m_pActiveSensor && !m_bOddUpdate )
  70. rect.SetRect( p.x - 4, p.y - 4, p.x + 4, p.y + 4 );
  71. else
  72. rect.SetRect( p.x - 2, p.y - 2, p.x + 2, p.y + 2 );
  73. pDC->FillSolidRect( &rect, pSensor->GetStateColor( m_bOddUpdate ) );
  74. }
  75. }