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

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: PhoneDlg.cpp
  9. // AUTHOR: Sergey Chizhevskiy
  10. // OVERVIEW
  11. // ~~~~~~~~
  12. // Source file of PhoneDlg.cpp
  13. //----------------------------------------------------------------------------
  14. #include "stdafx.h"
  15. #include "chicago.h"
  16. #include "PhoneDlg.h"
  17. #include "PhoneEditDlg.h"
  18. #include "..\..\LgLib\Version.h"
  19. CPhoneDlg::CPhoneDlg(CWnd* pParent /*=NULL*/)
  20. : CDialog(CPhoneDlg::IDD, pParent)
  21. {
  22. //{{AFX_DATA_INIT(CPhoneDlg)
  23. //}}AFX_DATA_INIT
  24. m_pSensorArray = NULL;
  25. LGLOG( LOG_LEVEL_MEDIUM, LOG_TYPE_INFO, this, _T("CPhoneDlg::CPhoneDlg") );
  26. }
  27. void CPhoneDlg::DoDataExchange(CDataExchange* pDX)
  28. {
  29. CDialog::DoDataExchange(pDX);
  30. //{{AFX_DATA_MAP(CPhoneDlg)
  31. DDX_Control(pDX, IDC_LIST, m_List);
  32. //}}AFX_DATA_MAP
  33. }
  34. BEGIN_MESSAGE_MAP(CPhoneDlg, CDialog)
  35. //{{AFX_MSG_MAP(CPhoneDlg)
  36. ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
  37. ON_BN_CLICKED(IDC_BUTTON_DELETE, OnButtonDelete)
  38. ON_BN_CLICKED(IDC_BUTTON_EDIT, OnButtonEdit)
  39. //}}AFX_MSG_MAP
  40. END_MESSAGE_MAP()
  41. UINT CPhoneDlg::DoModal(CSensorArray *pSensorArray)
  42. {
  43. m_pSensorArray = pSensorArray;
  44. return CDialog::DoModal();
  45. }
  46. BOOL CPhoneDlg::OnInitDialog()
  47. {
  48. CDialog::OnInitDialog();
  49. // add existing items
  50. for( INT i = 0; i < m_pSensorArray->GetPhoneCallCenter().GetCommandArray().GetCount(); i++ )
  51. m_List.AddString( m_pSensorArray->GetPhoneCallCenter().GetCommandArray()[i]->command.pPhoneNumber );
  52. return TRUE; // return TRUE unless you set the focus to a control
  53. // EXCEPTION: OCX Property Pages should return FALSE
  54. }
  55. void CPhoneDlg::OnButtonAdd()
  56. {
  57. // prepare default rule
  58. CPhoneCallCenter::PPHONE_COMMAND_EX pPhoneCommand = (CPhoneCallCenter::PPHONE_COMMAND_EX)malloc( sizeof(CPhoneCallCenter::PHONE_COMMAND_EX) );
  59. if( !pPhoneCommand )
  60. return;
  61. memset( pPhoneCommand, 0, sizeof(CPhoneCallCenter::PHONE_COMMAND_EX) );
  62. // set defaults
  63. pPhoneCommand->command.dwPhoneDialTime = 20000;
  64. pPhoneCommand->command.dwPhoneDropTime = 10000;
  65. pPhoneCommand->command.nPhoneRedialCount = 3;
  66. pPhoneCommand->command.nPhoneMessageRepeatCount = 1;
  67. // display edit dialog
  68. CPhoneEditDlg dlg;
  69. if( dlg.DoModal( m_pSensorArray, pPhoneCommand ) == IDOK )
  70. {
  71. // mark as incompletted
  72. pPhoneCommand->bComplete = FALSE;
  73. // add new rule
  74. m_pSensorArray->GetPhoneCallCenter().GetCommandArray().Add( pPhoneCommand );
  75. // reassign datas
  76. SendDlgItemMessage( IDC_LIST, LB_RESETCONTENT, 0, 0 );
  77. for( INT i = 0; i < m_pSensorArray->GetPhoneCallCenter().GetCommandArray().GetCount(); i++ )
  78. SendDlgItemMessage( IDC_LIST, LB_ADDSTRING, 0, (LPARAM)&m_pSensorArray->GetPhoneCallCenter().GetCommandArray()[i]->command.pPhoneNumber );
  79. }
  80. else
  81. delete pPhoneCommand;
  82. }
  83. void CPhoneDlg::OnButtonDelete()
  84. {
  85. INT nIndex = SendDlgItemMessage( IDC_LIST, LB_GETCURSEL, 0, 0 );
  86. if( nIndex == LB_ERR )
  87. return;
  88. // notify about apdate
  89. free( m_pSensorArray->GetPhoneCallCenter().GetCommandArray()[nIndex] );
  90. m_pSensorArray->GetPhoneCallCenter().GetCommandArray().Remove( nIndex );
  91. // reassign datas
  92. SendDlgItemMessage( IDC_LIST, LB_RESETCONTENT, 0, 0 );
  93. for( INT i = 0; i < m_pSensorArray->GetPhoneCallCenter().GetCommandArray().GetCount(); i++ )
  94. SendDlgItemMessage( IDC_LIST, LB_ADDSTRING, 0, (LPARAM)&m_pSensorArray->GetPhoneCallCenter().GetCommandArray()[i]->command.pPhoneNumber );
  95. }
  96. void CPhoneDlg::OnButtonEdit()
  97. {
  98. INT nIndex = SendDlgItemMessage( IDC_LIST, LB_GETCURSEL, 0, 0 );
  99. if( nIndex == LB_ERR )
  100. return;
  101. CPhoneCallCenter::PPHONE_COMMAND_EX pPhoneCommand = m_pSensorArray->GetPhoneCallCenter().GetCommandArray()[nIndex];
  102. // display edit dialog
  103. CPhoneEditDlg dlg;
  104. if( dlg.DoModal( m_pSensorArray, pPhoneCommand ) == IDOK )
  105. {
  106. // mark as incompletted
  107. pPhoneCommand->bComplete = FALSE;
  108. // update item pointer
  109. m_pSensorArray->GetPhoneCallCenter().GetCommandArray()[nIndex] = pPhoneCommand;
  110. // reassign datas
  111. SendDlgItemMessage( IDC_LIST, LB_RESETCONTENT, 0, 0 );
  112. for( INT i = 0; i < m_pSensorArray->GetPhoneCallCenter().GetCommandArray().GetCount(); i++ )
  113. SendDlgItemMessage( IDC_LIST, LB_ADDSTRING, 0, (LPARAM)&m_pSensorArray->GetPhoneCallCenter().GetCommandArray()[i]->command.pPhoneNumber );
  114. }
  115. }