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
216 lines
5.7 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 13/04/2001
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: SensorPropertyDlg.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of SensorPropertyDlg.cpp
|
|
//----------------------------------------------------------------------------
|
|
// SensorPropertyDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "chicago.h"
|
|
#include "SensorSPRU.h"
|
|
#include "Zone.h"
|
|
#include "SensorPropertyDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSensorPropertyDlg dialog
|
|
|
|
|
|
CSensorPropertyDlg::CSensorPropertyDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CSensorPropertyDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CSensorPropertyDlg)
|
|
m_iSensorAddress = 0;
|
|
m_strSensorName = _T("");
|
|
m_strSensorState = _T("");
|
|
m_strSensorType = _T("");
|
|
//}}AFX_DATA_INIT
|
|
m_pSensor = NULL;
|
|
}
|
|
|
|
|
|
void CSensorPropertyDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CSensorPropertyDlg)
|
|
DDX_Control(pDX, IDC_STATIC_IMAGE, m_StaticImage);
|
|
DDX_Control(pDX, IDC_BUTTON_SENSOR_ENABLE, m_ButtonSensorEnable);
|
|
DDX_Text(pDX, IDC_EDIT_SENSOR_ADDRESS, m_iSensorAddress);
|
|
DDX_Text(pDX, IDC_EDIT_SENSOR_NAME, m_strSensorName);
|
|
DDX_Text(pDX, IDC_EDIT_SENSOR_STATE, m_strSensorState);
|
|
DDX_Text(pDX, IDC_EDIT_SENSOR_TYPE, m_strSensorType);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CSensorPropertyDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CSensorPropertyDlg)
|
|
ON_WM_MOVING()
|
|
ON_BN_CLICKED(IDC_BUTTON_SENSOR_ENABLE, OnButtonSensorEnable)
|
|
ON_WM_SIZING()
|
|
ON_WM_TIMER()
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CSensorPropertyDlg message handlers
|
|
|
|
void CSensorPropertyDlg::OnMoving(UINT fwSide, LPRECT pRect)
|
|
{
|
|
CRect rect;
|
|
GetParent()->GetClientRect( &rect );
|
|
GetParent()->ClientToScreen( &rect );
|
|
|
|
if( pRect->left < rect.left )
|
|
{
|
|
pRect->right += rect.left - pRect->left;
|
|
pRect->left = rect.left;
|
|
}
|
|
|
|
if( pRect->top < rect.top )
|
|
{
|
|
pRect->bottom += rect.top - pRect->top;
|
|
pRect->top = rect.top;
|
|
}
|
|
|
|
if( pRect->right > rect.right )
|
|
{
|
|
pRect->left -= pRect->right - rect.right;
|
|
pRect->right = rect.right;
|
|
}
|
|
|
|
if( pRect->bottom > rect.bottom )
|
|
{
|
|
pRect->top -= pRect->bottom - rect.bottom;
|
|
pRect->bottom = rect.bottom;
|
|
}
|
|
|
|
CDialog::OnMoving( fwSide, pRect );
|
|
}
|
|
|
|
void CSensorPropertyDlg::SetSensor(CSensor *pSensor)
|
|
{
|
|
m_pSensor = pSensor;
|
|
m_bUpdate = TRUE;
|
|
}
|
|
|
|
void CSensorPropertyDlg::OnButtonSensorEnable()
|
|
{
|
|
if( m_pSensor->GetState() == CSensor::DISABLE )
|
|
m_pSensor->Enable( TRUE );
|
|
else m_pSensor->Enable( FALSE );
|
|
m_pSensor->GetZone()->UpdateState();
|
|
GetParent()->SendMessage( WM_SENSOR_UPDATE, 0, (LONG)m_pSensor );
|
|
}
|
|
|
|
void CSensorPropertyDlg::UpdateSensor()
|
|
{
|
|
if( m_pSensor )
|
|
{
|
|
m_bUpdate = TRUE;
|
|
// SetSensor( m_pSensor );
|
|
}
|
|
}
|
|
|
|
void CSensorPropertyDlg::OnSizing(UINT fwSide, LPRECT pRect)
|
|
{
|
|
CRect rect;
|
|
GetParent()->GetClientRect( &rect );
|
|
GetParent()->ClientToScreen( &rect );
|
|
|
|
if( pRect->left < rect.left ) pRect->left = rect.left;
|
|
if( pRect->right > rect.right ) pRect->right = rect.right;
|
|
if( pRect->top < rect.top ) pRect->top = rect.top;
|
|
if( pRect->bottom > rect.bottom ) pRect->bottom = rect.bottom;
|
|
|
|
CDialog::OnSizing( fwSide, pRect );
|
|
}
|
|
|
|
void CSensorPropertyDlg::OnTimer(UINT nIDEvent)
|
|
{
|
|
m_bInverse = nIDEvent;
|
|
|
|
if( m_bUpdate && m_pSensor )
|
|
{
|
|
m_strSensorName = m_pSensor->GetName();
|
|
switch( m_pSensor->GetType() )
|
|
{
|
|
case CSensor::LGS: m_strSensorType = "LGS"; break;
|
|
case CSensor::DTR: m_strSensorType = "DTR"; break;
|
|
}
|
|
|
|
m_pSensor->GetStateString( m_strSensorState );
|
|
|
|
if( m_pSensor->GetState() == CSensor::DISABLE )
|
|
m_ButtonSensorEnable.SetWindowText( "Enable" );
|
|
else
|
|
m_ButtonSensorEnable.SetWindowText( "Disable" );
|
|
|
|
m_iSensorAddress = m_pSensor->GetAddress();
|
|
|
|
if( m_pSensor->GetType()==CSensor::DTR )
|
|
{
|
|
CSensorSPRU *pSensorSPRU = (CSensorSPRU *)m_pSensor;
|
|
|
|
CRect rect;
|
|
m_StaticImage.GetClientRect( &rect );
|
|
|
|
CBitmap *pBitmap = m_pSensor->GetBitmap();
|
|
CBitmap *pBitmapBackgroundOld = m_OverlayDCBackground.SelectObject( pBitmap );
|
|
CBitmap *pBitmapOld = m_OverlayDC.SelectObject( &m_OverlayBitmap );
|
|
|
|
m_OverlayDC.BitBlt( 0,0, rect.Width(), rect.Height(),
|
|
&m_OverlayDCBackground, 0, 0, SRCCOPY );
|
|
pSensorSPRU->PaintBits( &m_OverlayDC, rect, m_bInverse );
|
|
|
|
m_OverlayDC.SelectObject( pBitmapOld );
|
|
m_OverlayDCBackground.SelectObject( pBitmapBackgroundOld );
|
|
|
|
m_StaticImage.SetBitmap( m_OverlayBitmap );
|
|
}
|
|
|
|
UpdateData( FALSE );
|
|
|
|
m_bUpdate = m_pSensor->GetBlinkState();
|
|
}
|
|
|
|
CDialog::OnTimer(nIDEvent);
|
|
}
|
|
|
|
BOOL CSensorPropertyDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
m_bUpdate = TRUE;
|
|
|
|
CRect rect;
|
|
m_StaticImage.GetClientRect( rect );
|
|
|
|
CDC *pDC = m_StaticImage.GetDC();
|
|
m_OverlayDC.CreateCompatibleDC( pDC );
|
|
m_OverlayDCBackground.CreateCompatibleDC( pDC );
|
|
m_OverlayBitmap.CreateCompatibleBitmap( pDC, rect.Width(), rect.Height() );
|
|
m_StaticImage.ReleaseDC( pDC );
|
|
|
|
CBitmap *pBitmapOld = m_OverlayDC.SelectObject( &m_OverlayBitmap );
|
|
m_OverlayDC.FillSolidRect( &rect, 0x000000 );
|
|
m_OverlayDC.SelectObject( pBitmapOld );
|
|
m_StaticImage.SetBitmap( m_OverlayBitmap );
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|