示例#1
0
/*******************************************************************************
  Function Name  : vHandleConnectionStatusChange
  Input(s)       : bConnectionStatus - Status of the tool connection. TRUE if
                   the tool is going to connected state
  Output         : -
  Functionality  : This function will handle connect event. Will advise sink class
                    on connect and unadvise on disconnect.
  Member of      : CGraphRightView
  Author(s)      : Arunkumar Karri
  Date Created   : 10/12/2012
*******************************************************************************/
void CGraphRightView::vHandleConnectionStatusChange(BOOL bConnectStatus)
{
    if ( bConnectStatus == TRUE )
    {
        if ( m_pGraphSink == nullptr )
        {
            //Create Sink object
            m_pGraphSink = new CGraphSink();

            //Share the Parent window pointer
            m_pGraphSink->m_pParentWnd = m_pParentWnd;

            //Get a pointer to sinks IUnknown, no AddRef. CMySink implements only
            //dispinterface and the IUnknown and IDispatch pointers will be same.
            LPUNKNOWN pUnkSink = m_pGraphSink->GetIDispatch(FALSE);

            CWnd* pWnd = nullptr;
            pWnd = GetDlgItem(IDC_DMGRAPH_CTRL);
            LPUNKNOWN pUnk = pWnd->GetControlUnknown();

            //Establish a connection between source and sink.
            //m_pUnkSrc is IUnknown of server obtained by CoCreateInstance().
            //m_dwCookie is a cookie identifying the connection, and is needed
            //to terminate the connection.
            AfxConnectionAdvise(pUnk, DIID__IDMGraphCtrlEvents, pUnkSink, FALSE,&m_dwCookie);
        }
        //Set element point size to 0

        CComPtr<IDMGraphCollection> spGraphCollection;
        HRESULT hr = m_pDMGraphCtrl->get_Elements(&spGraphCollection);
        if(FAILED(hr))
        {
            return;
        }
        long lngCount;
        spGraphCollection->get_Count(&lngCount);
        // Add items to the list
        for ( long lngIndex = 0; lngIndex < lngCount; lngIndex++ )
        {
            CComPtr<IDispatch> spDispatch;
            CComPtr<IDMGraphElement> spGraphElement;
            //Get item at index lngIndex
            spGraphCollection->get_Item(lngIndex, &spDispatch);
            spDispatch.QueryInterface(&spGraphElement);
            spGraphElement->put_PointSize(0);
        }
    }
    else
    {
        //Set element point size to 2

        CComPtr<IDMGraphCollection> spGraphCollection;
        HRESULT hr = m_pDMGraphCtrl->get_Elements(&spGraphCollection);
        if(FAILED(hr))
        {
            return;
        }

        long lngCount;
        spGraphCollection->get_Count(&lngCount);
        // Add items to the list
        for ( long lngIndex = 0; lngIndex < lngCount; lngIndex++ )
        {
            CComPtr<IDispatch> spDispatch;
            CComPtr<IDMGraphElement> spGraphElement;
            //Get item at index lngIndex
            spGraphCollection->get_Item(lngIndex, &spDispatch);
            spDispatch.QueryInterface(&spGraphElement);
            spGraphElement->put_PointSize(2);
        }
    }
}
示例#2
0
void CGnucleusDoc::ConnectCore()
{
	m_autCore = new CAutCore;
	if(!m_autCore->CreateDispatch("GnucCOM.Core"))
	{
		AfxMessageBox("Could not load GnucDNA");
		return;
	}

	// Make sure version of core is same or newer than what we built with
	CString CoreVersion = m_autCore->GetCoreVersion();
	CoreVersion.Remove('.');

	CString BuildVersion = BUILD_CORE_VERSION;
	BuildVersion.Remove('.');

	if(atoi(CoreVersion) < atoi(BuildVersion))
	{
		AfxMessageBox("GnucDNA " + CString(BUILD_CORE_VERSION) + " or higher needed, please update");
		return;
	}

	// Attach prefs object
	m_autPrefs = new CAutPrefs;
	m_autPrefs->AttachDispatch( m_autCore->GetIPrefs(), false );

	// Attach network object
	m_autNetwork = new CAutNetwork;
	m_autNetwork->AttachDispatch( m_autCore->GetINetwork(), false );

	// Attach cache object
	m_autCache = new CAutCache;
	m_autCache->AttachDispatch( m_autCore->GetICache(), false );

	// Attach meta object
	m_autMeta = new CAutMeta;
	m_autMeta->AttachDispatch( m_autCore->GetIMeta(), false );

	// Attach share object
	m_autShare = new CAutShare;
	m_autShare->AttachDispatch( m_autCore->GetIShare(), false );

	// Attach share object
	m_autSearch = new CAutSearch;
	m_autSearch->AttachDispatch( m_autCore->GetISearch(), false );

	// Attach download object
	m_autDownload = new CAutDownload;
	m_autDownload->AttachDispatch( m_autCore->GetIDownload(), false );

	// Attach upload object
	m_autUpload = new CAutUpload;
	m_autUpload->AttachDispatch( m_autCore->GetIUpload(), false );

	// Attach update object
	m_autUpdate = new CAutUpdate;
	m_autUpdate->AttachDispatch( m_autCore->GetIUpdate(), false );

	// Attach chat object
	m_autChat = new CAutChat;
	m_autChat->AttachDispatch( m_autCore->GetIChat(), false );


	// Network event object and establish a connection between source and sink.
	m_autNetworkSink = new CAutNetworkSink(this);
	AfxConnectionAdvise(m_autNetwork->m_lpDispatch, IID_INetworkEvent, m_autNetworkSink->GetIDispatch(false), false, &m_NetEventCookie);

	// Share event object and establish a connection between source and sink.
	m_autShareSink = new CAutShareSink(this);
	AfxConnectionAdvise(m_autShare->m_lpDispatch, IID_IShareEvent, m_autShareSink->GetIDispatch(false), false, &m_ShareEventCookie);

	// Share event object and establish a connection between source and sink.
	m_autSearchSink = new CAutSearchSink(this);
	AfxConnectionAdvise(m_autSearch->m_lpDispatch, IID_ISearchEvent, m_autSearchSink->GetIDispatch(false), false, &m_SearchEventCookie);

	// Download event object and establish a connection between source and sink.
	m_autDownloadSink = new CAutDownloadSink(this);
	AfxConnectionAdvise(m_autDownload->m_lpDispatch, IID_IDownloadEvent, m_autDownloadSink->GetIDispatch(false), false, &m_DownloadEventCookie);

	// Upload event object and establish a connection between source and sink.
	m_autUploadSink = new CAutUploadSink(this);
	AfxConnectionAdvise(m_autUpload->m_lpDispatch, IID_IUploadEvent, m_autUploadSink->GetIDispatch(false), false, &m_UploadEventCookie);

	// Update event object and establish a connection between source and sink.
	m_autUpdateSink = new CAutUpdateSink(this);
	AfxConnectionAdvise(m_autUpdate->m_lpDispatch, IID_IUpdateEvent, m_autUpdateSink->GetIDispatch(false), false, &m_UpdateEventCookie);

	// Chat event object and establish a connection between source and sink.
	m_autChatSink = new CAutChatSink(this);
	AfxConnectionAdvise(m_autChat->m_lpDispatch, IID_IChatEvent, m_autChatSink->GetIDispatch(false), false, &m_ChatEventCookie);

}