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.
298 lines
7.5 KiB
298 lines
7.5 KiB
//----------------------------------------------------------------------------
|
|
// Laser Guard Ltd.
|
|
// Copyright © 2000-2002. All Rights Reserved.
|
|
// Version 1.0 01/01/2000
|
|
// Last modification: 08/10/2003
|
|
// PROJECT:
|
|
// SUBSYSTEM:
|
|
// FILE: ConnectionDlg.cpp
|
|
// AUTHOR: Sergey Chizhevskiy
|
|
// OVERVIEW
|
|
// ~~~~~~~~
|
|
// Source file of ConnectionDlg.cpp
|
|
//----------------------------------------------------------------------------
|
|
// ConnectionDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "setuplgs.h"
|
|
#include "ConnectionDlg.h"
|
|
//#include "PropDCLinkDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CConnectionDlg dialog
|
|
|
|
|
|
CConnectionDlg::CConnectionDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CConnectionDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CConnectionDlg)
|
|
// NOTE: the ClassWizard will add member initialization here
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
|
|
void CConnectionDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CConnectionDlg)
|
|
DDX_Control(pDX, IDC_LIST_LINK, m_ListLink);
|
|
DDX_Control(pDX, IDC_BUTTON_DEL_ALL, m_ButtonDelAll);
|
|
DDX_Control(pDX, IDC_BUTTON_DEL, m_ButtonDel);
|
|
DDX_Control(pDX, IDC_BUTTON_ADD_ALL, m_ButtonAddAll);
|
|
DDX_Control(pDX, IDC_BUTTON_ADD, m_ButtonAdd);
|
|
DDX_Control(pDX, IDOK, m_Ok);
|
|
DDX_Control(pDX, IDC_LIST_SOURCE, m_Src);
|
|
DDX_Control(pDX, IDC_LIST_DESTINATION, m_Dest);
|
|
DDX_Control(pDX, IDC_STATIC_DESTINATION, m_sDest);
|
|
DDX_Control(pDX, IDC_STATIC_SOURCE, m_sSrc);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CConnectionDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CConnectionDlg)
|
|
ON_BN_CLICKED(IDC_BUTTON_ADD, OnButtonAdd)
|
|
ON_BN_CLICKED(IDC_BUTTON_ADD_ALL, OnButtonAddAll)
|
|
ON_BN_CLICKED(IDC_BUTTON_DEL, OnButtonDel)
|
|
ON_BN_CLICKED(IDC_BUTTON_DEL_ALL, OnButtonDelAll)
|
|
ON_LBN_SELCHANGE(IDC_LIST_LINK, OnSelchangeList)
|
|
ON_LBN_SELCHANGE(IDC_LIST_DESTINATION, OnSelchangeList)
|
|
ON_LBN_SELCHANGE(IDC_LIST_SOURCE, OnSelchangeList)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CConnectionDlg message handlers
|
|
|
|
BOOL CConnectionDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
FillControls();
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
int CConnectionDlg::DoModal( COFDevice *pSrc, COFDevice *pDest )
|
|
{
|
|
m_pSrc = pSrc;
|
|
m_pDest = pDest;
|
|
return CDialog::DoModal();
|
|
}
|
|
|
|
void CConnectionDlg::OnOK()
|
|
{
|
|
CObjectFactory *pOF = m_pDest->GetOF();
|
|
|
|
BOOL bChanged = FALSE;
|
|
|
|
#ifndef SETUP_DEMO_VERSION
|
|
for( int i = 0; i < m_LinkArray.GetSize(); i++ )
|
|
{
|
|
DATAPTR dp = m_LinkArray[i];
|
|
if( dp.bConnected )
|
|
dp.dataS->Connect( dp.dataD );
|
|
else
|
|
{
|
|
dp.dataS->Disconnect( dp.dataD );
|
|
dp.dataD->Disconnect( dp.dataS );
|
|
}
|
|
|
|
bChanged = TRUE;
|
|
}
|
|
#endif
|
|
|
|
if( bChanged )
|
|
CDialog::OnOK();
|
|
else
|
|
CDialog::OnCancel();
|
|
}
|
|
|
|
void CConnectionDlg::OnButtonAdd()
|
|
{
|
|
#ifndef SETUP_DEMO_VERSION
|
|
int nIndexS = m_Src.GetCurSel();
|
|
int nIndexD = m_Dest.GetCurSel();
|
|
if( nIndexS >= 0 && nIndexD >= 0 )
|
|
{
|
|
PDATAPTR pDataPtr = new DATAPTR;
|
|
|
|
pDataPtr->dataS = (COFPin*)m_Src.GetItemDataPtr( nIndexS );
|
|
pDataPtr->dataD = (COFPin*)m_Dest.GetItemDataPtr( nIndexD );
|
|
pDataPtr->bConnected = TRUE;
|
|
|
|
CString linkname;
|
|
linkname.Format( _T("%s <-> %s"), ((COFPin*)pDataPtr->dataS)->GetName(), ((COFPin*)pDataPtr->dataD)->GetName() );
|
|
|
|
int nIndex = m_ListLink.AddString( linkname );
|
|
m_ListLink.SetItemDataPtr( nIndex, pDataPtr );
|
|
|
|
m_Src.DeleteString( nIndexS );
|
|
m_Dest.DeleteString( nIndexD );
|
|
|
|
BOOL bFound = FALSE;
|
|
for( int i = 0; i < m_LinkArray.GetSize(); i++ )
|
|
{
|
|
DATAPTR dp = m_LinkArray[i];
|
|
if( dp.dataS == pDataPtr->dataS &&
|
|
dp.dataD == pDataPtr->dataD )
|
|
{
|
|
ASSERT( dp.bConnected == FALSE );
|
|
bFound = TRUE;
|
|
m_LinkArray.RemoveAt(i);
|
|
break;
|
|
}
|
|
}
|
|
if( !bFound )
|
|
m_LinkArray.Add( *pDataPtr );
|
|
}
|
|
|
|
OnSelchangeList();
|
|
#endif
|
|
}
|
|
|
|
void CConnectionDlg::OnButtonAddAll()
|
|
{
|
|
}
|
|
|
|
void CConnectionDlg::OnButtonDel()
|
|
{
|
|
#ifndef SETUP_DEMO_VERSION
|
|
int nIndex = m_ListLink.GetCurSel();
|
|
if( nIndex >= 0 )
|
|
{
|
|
PDATAPTR pDataPtr = (PDATAPTR)m_ListLink.GetItemData( nIndex );
|
|
|
|
CString sname;
|
|
sname.Format( _T("%s"), ((COFPin*)pDataPtr->dataS)->GetName() );
|
|
int nIndexS = m_Src.AddString( sname );
|
|
m_Src.SetItemDataPtr( nIndexS, pDataPtr->dataS );
|
|
|
|
CString dname;
|
|
dname.Format( _T("%s"), ((COFPin*)pDataPtr->dataD)->GetName() );
|
|
int nIndexD = m_Dest.AddString( dname );
|
|
m_Dest.SetItemDataPtr( nIndexD, pDataPtr->dataD );
|
|
|
|
m_ListLink.DeleteString( nIndex );
|
|
|
|
BOOL bFound = FALSE;
|
|
for( int i = 0; i < m_LinkArray.GetSize(); i++ )
|
|
{
|
|
DATAPTR dp = m_LinkArray[i];
|
|
if( dp.dataS == pDataPtr->dataS &&
|
|
dp.dataD == pDataPtr->dataD )
|
|
{
|
|
ASSERT( dp.bConnected == TRUE );
|
|
bFound = TRUE;
|
|
m_LinkArray.RemoveAt(i);
|
|
break;
|
|
}
|
|
}
|
|
if( !bFound )
|
|
{
|
|
pDataPtr->bConnected = FALSE;
|
|
m_LinkArray.Add( *pDataPtr );
|
|
}
|
|
|
|
delete pDataPtr;
|
|
}
|
|
|
|
OnSelchangeList();
|
|
#endif
|
|
}
|
|
|
|
void CConnectionDlg::OnButtonDelAll()
|
|
{
|
|
#ifndef SETUP_DEMO_VERSION
|
|
while( m_ListLink.GetCount() )
|
|
{
|
|
m_ListLink.SetCurSel( 0 );
|
|
OnButtonDel();
|
|
}
|
|
#endif
|
|
}
|
|
|
|
void CConnectionDlg::OnSelchangeList()
|
|
{
|
|
COFPin *pSrc = m_Src.GetCurSel() >= 0 ? (COFPin*)m_Src.GetItemDataPtr( m_Src.GetCurSel() ) : NULL;
|
|
COFPin *pDest = m_Dest.GetCurSel() >= 0 ? (COFPin*)m_Dest.GetItemDataPtr( m_Dest.GetCurSel() ) : NULL;
|
|
|
|
if( !pSrc || !pDest )
|
|
m_ButtonAdd.EnableWindow( FALSE );
|
|
else
|
|
m_ButtonAdd.EnableWindow( pSrc->GetTrueType() == pDest->GetType() );
|
|
|
|
m_ButtonDel.EnableWindow( m_ListLink.GetCurSel() >= 0 );
|
|
m_ButtonDelAll.EnableWindow( m_ListLink.GetCount() );
|
|
}
|
|
|
|
void CConnectionDlg::FillControls()
|
|
{
|
|
m_sDest.SetWindowText( m_pDest->GetName() );
|
|
m_sSrc.SetWindowText( m_pSrc->GetName() );
|
|
|
|
for( int i = 0; i < m_pSrc->GetPinCount(); i++ )
|
|
{
|
|
BOOL bAdded = FALSE;
|
|
|
|
for( int j = 0; j < m_pSrc->GetPin(i)->m_nDeviceCount; j++ )
|
|
{
|
|
if( m_pSrc->GetPin(i)->m_pDevice[j].nIndex == m_pDest->GetIndex() &&
|
|
m_pSrc->GetPin(i)->m_pDevice[j].nType == m_pDest->GetType() )
|
|
{
|
|
CString link;
|
|
link.Format( _T("%s <-> %s"),
|
|
(const char*)m_pSrc->GetPin(i)->GetName(),
|
|
(const char*)m_pDest->GetPin( m_pSrc->GetPin(i)->m_pDevice[j].nPin )->GetName() );
|
|
|
|
PDATAPTR pData = new DATAPTR;
|
|
pData->dataS = m_pSrc->GetPin(i);
|
|
pData->dataD = m_pDest->GetPin( m_pSrc->GetPin(i)->m_pDevice[j].nPin );
|
|
|
|
int nIndex = m_ListLink.AddString( link );
|
|
m_ListLink.SetItemDataPtr( nIndex, pData );
|
|
|
|
bAdded = TRUE;
|
|
}
|
|
}
|
|
|
|
if( !bAdded )
|
|
{
|
|
if( m_pSrc->GetPin(i)->IsFree() )
|
|
{
|
|
int nIndex = m_Src.AddString( m_pSrc->GetPin(i)->GetName() );
|
|
m_Src.SetItemDataPtr( nIndex, m_pSrc->GetPin(i) );
|
|
}
|
|
}
|
|
}
|
|
|
|
for( i = 0; i < m_pDest->GetPinCount(); i++ )
|
|
{
|
|
if( m_pDest->GetPin(i)->IsFree() )
|
|
{
|
|
int nIndex = m_Dest.AddString( m_pDest->GetPin(i)->GetName() );
|
|
m_Dest.SetItemDataPtr( nIndex, m_pDest->GetPin(i) );
|
|
}
|
|
}
|
|
|
|
OnSelchangeList();
|
|
}
|
|
|
|
BOOL CConnectionDlg::DestroyWindow()
|
|
{
|
|
while( m_ListLink.GetCount() )
|
|
{
|
|
delete (PDATAPTR)m_ListLink.GetItemData( 0 );
|
|
m_ListLink.DeleteString( 0 );
|
|
}
|
|
|
|
return CDialog::DestroyWindow();
|
|
}
|