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.
 
 
 
 
 

140 lines
4.4 KiB

//----------------------------------------------------------------------------
// Laser Guard Ltd.
// Copyright © 2000-2002. All Rights Reserved.
// Version 1.0 01/01/2000
// Last modification: 08/10/2003
// PROJECT:
// SUBSYSTEM:
// FILE: PhoneDlg.cpp
// AUTHOR: Sergey Chizhevskiy
// OVERVIEW
// ~~~~~~~~
// Source file of PhoneDlg.cpp
//----------------------------------------------------------------------------
#include "stdafx.h"
#include "chicago.h"
#include "PhoneDlg.h"
#include "PhoneEditDlg.h"
#include "..\..\LgLib\Version.h"
CPhoneDlg::CPhoneDlg(CWnd* pParent /*=NULL*/)
: CDialog(CPhoneDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CPhoneDlg)
//}}AFX_DATA_INIT
m_pSensorArray = NULL;
LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPhoneDlg::CPhoneDlg") );
}
void CPhoneDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CPhoneDlg)
DDX_Control(pDX, IDC_LIST, m_List);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CPhoneDlg, CDialog)
//{{AFX_MSG_MAP(CPhoneDlg)
ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
ON_BN_CLICKED(IDC_BUTTON_EDIT, OnButtonEdit)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
UINT CPhoneDlg::DoModal(CSensorArray *pSensorArray)
{
m_pSensorArray = pSensorArray;
return CDialog::DoModal();
}
BOOL CPhoneDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// add existing items
for( INT i = 0; i < m_pSensorArray->GetPhoneCallCenter().GetCommandArray().GetCount(); i++ )
m_List.AddString( m_pSensorArray->GetPhoneCallCenter().GetCommandArray()[i]->command.pPhoneNumber );
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CPhoneDlg::OnButtonAdd()
{
// prepare default rule
CPhoneCallCenter::PPHONE_COMMAND_EX pPhoneCommand = (CPhoneCallCenter::PPHONE_COMMAND_EX)malloc( sizeof(CPhoneCallCenter::PHONE_COMMAND_EX) );
if( !pPhoneCommand )
return;
memset( pPhoneCommand, 0, sizeof(CPhoneCallCenter::PHONE_COMMAND_EX) );
// set defaults
pPhoneCommand->command.dwPhoneDialTime = 20000;
pPhoneCommand->command.dwPhoneDropTime = 10000;
pPhoneCommand->command.nPhoneRedialCount = 3;
pPhoneCommand->command.nPhoneMessageRepeatCount = 1;
// display edit dialog
CPhoneEditDlg dlg;
if( dlg.DoModal( m_pSensorArray, pPhoneCommand ) == IDOK )
{
// mark as incompletted
pPhoneCommand->bComplete = FALSE;
// add new rule
m_pSensorArray->GetPhoneCallCenter().GetCommandArray().Add( pPhoneCommand );
// reassign datas
SendDlgItemMessage( IDC_LIST, LB_RESETCONTENT, 0, 0 );
for( INT i = 0; i < m_pSensorArray->GetPhoneCallCenter().GetCommandArray().GetCount(); i++ )
SendDlgItemMessage( IDC_LIST, LB_ADDSTRING, 0, (LPARAM)&m_pSensorArray->GetPhoneCallCenter().GetCommandArray()[i]->command.pPhoneNumber );
}
else
delete pPhoneCommand;
}
void CPhoneDlg::OnButtonDelete()
{
INT nIndex = SendDlgItemMessage( IDC_LIST, LB_GETCURSEL, 0, 0 );
if( nIndex == LB_ERR )
return;
// notify about apdate
free( m_pSensorArray->GetPhoneCallCenter().GetCommandArray()[nIndex] );
m_pSensorArray->GetPhoneCallCenter().GetCommandArray().Remove( nIndex );
// reassign datas
SendDlgItemMessage( IDC_LIST, LB_RESETCONTENT, 0, 0 );
for( INT i = 0; i < m_pSensorArray->GetPhoneCallCenter().GetCommandArray().GetCount(); i++ )
SendDlgItemMessage( IDC_LIST, LB_ADDSTRING, 0, (LPARAM)&m_pSensorArray->GetPhoneCallCenter().GetCommandArray()[i]->command.pPhoneNumber );
}
void CPhoneDlg::OnButtonEdit()
{
INT nIndex = SendDlgItemMessage( IDC_LIST, LB_GETCURSEL, 0, 0 );
if( nIndex == LB_ERR )
return;
CPhoneCallCenter::PPHONE_COMMAND_EX pPhoneCommand = m_pSensorArray->GetPhoneCallCenter().GetCommandArray()[nIndex];
// display edit dialog
CPhoneEditDlg dlg;
if( dlg.DoModal( m_pSensorArray, pPhoneCommand ) == IDOK )
{
// mark as incompletted
pPhoneCommand->bComplete = FALSE;
// update item pointer
m_pSensorArray->GetPhoneCallCenter().GetCommandArray()[nIndex] = pPhoneCommand;
// reassign datas
SendDlgItemMessage( IDC_LIST, LB_RESETCONTENT, 0, 0 );
for( INT i = 0; i < m_pSensorArray->GetPhoneCallCenter().GetCommandArray().GetCount(); i++ )
SendDlgItemMessage( IDC_LIST, LB_ADDSTRING, 0, (LPARAM)&m_pSensorArray->GetPhoneCallCenter().GetCommandArray()[i]->command.pPhoneNumber );
}
}