void wxGISToolExecuteView::OnSelected(wxListEvent& event)
{
    m_pSelection->Clear(NOTFIRESELID);
    long nItem = wxNOT_FOUND;
    size_t nCount(0);
    for ( ;; )
    {
        nItem = GetNextItem(nItem, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if ( nItem == wxNOT_FOUND )
            break;
        wxGxObject* pObject = m_pCatalog->GetRegisterObject(GetItemData(nItem));
        if(!pObject)
            continue;
        nCount++;
        m_pSelection->Select(pObject->GetId(), true, NOTFIRESELID);
    }

    wxGISStatusBar* pStatusBar = m_pApp->GetStatusBar();
    if(pStatusBar)
    {
        if(nCount > 1)
        {
            pStatusBar->SetMessage(wxString::Format(_("%ld objects selected"), nCount));
        }
        else
        {
            pStatusBar->SetMessage(wxEmptyString);
        }
    }
}
示例#2
0
/////////////////////////////////////////////////////////////////////////////
// Populates the list using PsApi functions
DWORD CProcessApi::ProcessesPopulatePsApi(tProcessesData* pd)
{
	DWORD nProcess, // number of processes returned
				nCount(4096); // maximum number of processes (defined by me)

	// Dynamic array for storing returned processes IDs
	DWORD* processes = new DWORD[nCount];

	// enum all processes
	if (!psapi_EnumProcesses(processes, nCount * sizeof(DWORD), &nProcess))
	{
		delete processes;
		return paeNoSnap;
	}

	// convert fron bytes count to items count
	nProcess /= 4;

	tProcessInfo pi = {0};

	// walk in process list
	for (DWORD i=0; i < nProcess; i++)
	{
		// open process for querying only
		HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, processes[i]);
		if (!hProcess)
			continue;

		// get the process's image name by getting first module
		DWORD nmod;
		HMODULE mod1;
	  
		if (!psapi_EnumProcessModules(hProcess, &mod1, sizeof(mod1), &nmod))
			_tcscpy_s(pi.FileName, MAX_PATH, _T("-"));
		else
		{
			psapi_GetModuleFileNameEx(hProcess, mod1, pi.FileName, sizeof(pi.FileName));
			FixPath(pi.FileName);
		}

		// get the process ID
		pi.pid = processes[i];

		// store in the list
		pd->pl->push_back(pi);
	    
		CloseHandle(hProcess);
	}

	// reposition list to 0
	pd->Pos = 0;
	delete processes;
	return paeSuccess;
}
示例#3
0
bool wxGISDecimalDataObject::SetData(size_t len, const void *buf)
{
    m_oaDecimals.Empty();

    unsigned char * pbuf = (unsigned char*)buf;
    size_t nCount(0);

    BUF2VALMEMCOPY(&nCount, pbuf, sizeOfsize_t);

    for (size_t n = 0; n < nCount; ++n )
    {
        long nValue;
        BUF2VALMEMCOPY(&nValue, pbuf, sizeOfLong);

        m_oaDecimals.Add(nValue);
    }
    return true;
}
示例#4
0
eaio::size_type eaio::readString(IStream* pIS, char8_t* pBuffer, size_type nMaxCount, eaio::Endian endianSource)
{
    const off_type ninitialPosition(pIS->getPosition());

    char8_t   cCurrent;
    uint32_t  nLength(0);
    size_type nCount(0); // Number of chars returned to user.
    size_type nResult;

    if(!readUint32(pIS, nLength, endianSource))
        return kSizeTypeError;

    // If no buffer has been provided, just reset the stream and return the length.
    if(!pBuffer)
    {
        pIS->setPosition(ninitialPosition);
        return (size_type)nLength;
    }

    // Determine how many characters we'll actually read into the buffer.
    // 'nMaxCount - 1' because we want to leave room for terminating NUL.
    size_type nreadLength = (nLength < nMaxCount - 1) ? nLength : nMaxCount - 1;

    while(pBuffer && (nCount < nreadLength)) 
    {
        nResult = pIS->read(&cCurrent, sizeof(cCurrent));

        if(nResult != sizeof(cCurrent))
            break;

        *pBuffer++ = cCurrent;
        ++nCount;
    }

    // We may not have been able to read the entire string out of the stream
    // due to the nMaxCount limit, but we still want to advance the stream's
    // position to the end of the string.
    pIS->setPosition(ninitialPosition + (off_type)sizeof(uint32_t) + (off_type)nLength);

    if(pBuffer)
        *pBuffer = '\0';

    return nLength; // Note that we return nLength and not nCount.
}
示例#5
0
bool wxGISStringDataObject::SetData(size_t len, const void *buf)
{
    m_oaStrings.Empty();

    unsigned char * pbuf = (unsigned char*)buf;
    size_t nCount(0);

    BUF2VALMEMCOPY(&nCount, pbuf, sizeOfsize_t);

    size_t nStrLen(0), nStrSize(0);
    for (size_t n = 0; n < nCount; ++n )
    {
        BUF2VALMEMCOPY(&nStrLen, pbuf, sizeOfsize_t);

        wxString str((const wxChar*) pbuf, nStrLen);
        m_oaStrings.Add(str);

        nStrSize = nStrLen * sizeOfChar;
        pbuf += nStrSize;
    }
    return true;
}
void wxGxContentView::OnSelected(wxListEvent& event)
{
	//event.Skip();
    m_pSelection->Clear(NOTFIRESELID);
    long nItem = wxNOT_FOUND;
	size_t nCount(0);
    for ( ;; )
    {
        nItem = GetNextItem(nItem, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        if ( nItem == wxNOT_FOUND )
            break;
        LPITEMDATA pItemData = (LPITEMDATA)GetItemData(nItem);
	    if(pItemData == NULL)
            continue;
		nCount++;
        m_pSelection->Select(pItemData->nObjectID, true, NOTFIRESELID);
    }

    if (m_pGxApp != NULL)
    {
        if(nCount <= 0)
	    	m_pSelection->SetInitiator(TREECTRLID);
        m_pGxApp->UpdateNewMenu(m_pSelection);
	}

    wxGISStatusBar* pStatusBar = m_pApp->GetStatusBar();
    if(pStatusBar)
    {
        if(nCount > 1)
        {
            pStatusBar->SetMessage(wxString::Format(_("%ld objects selected"), nCount));
        }
        else
        {
            pStatusBar->SetMessage(wxEmptyString);
        }
    }
}
示例#7
0
bool wxGISTaskDataObject::SetData(size_t len, const void *buf)
{
    m_oaDecimals.Empty();
    m_nParentPointer = wxNOT_FOUND;

    unsigned char * pbuf = (unsigned char*)buf;

    size_t nStrLen(0);
    BUF2VALMEMCOPY(&m_nParentPointer, pbuf, sizeOfLong);

    size_t nCount(0);

    BUF2VALMEMCOPY(&nCount, pbuf, sizeOfsize_t);

    for (size_t n = 0; n < nCount; ++n )
    {
        long nValue;
        BUF2VALMEMCOPY(&nValue, pbuf, sizeOfLong);

        m_oaDecimals.Add(nValue);
    }
    return true;
}
示例#8
0
eaio::size_type eaio::readLine(IStream* pIS, char16_t* pLine, size_type nMaxCount, Endian endianSource)
{
    char16_t  cCurrent;
    size_type nCount(0); // Number of chars in the line, not including the line end characters(s).
    size_type nread(0);  // Number of chars successfully read from stream. Will be >= nCount (due to presence of newlines).
    size_type nResult;
    off_type  ninitialPosition(0);
    char16_t  cr, lf;

    if(!pLine)
        ninitialPosition = pIS->getPosition();

    if(endianSource == kEndianLocal)
    {
        cr = '\r';
        lf = '\n';
    }
    else
    {
        cr = SwizzleUint16('\r');
        lf = SwizzleUint16('\n');
    }

    for(;;)
    {
        // We are reading one character at a time, which can be slow if the stream is 
        // not buffered. We read one character at a time because we don't want to read
        // past the end of the line and thus trigger seeks, which may not even be possible
        // for some streams.
        nResult = pIS->read(&cCurrent, sizeof(cCurrent));

        if(nResult == sizeof(cCurrent))
        {
            ++nread;

            if((cCurrent == cr) || (cCurrent == lf))
            {
                // It's possible that we have a "\n" or "\r\n" sequence, and we want 
                // to read past the sequence, but not past anything else. This code here takes
                // care not to read past the first "\n" in a "\n\n" sequence, but is smart 
                // enough to read past the just first "\r\n" in a "\r\n\r\n" sequence.
                char16_t cNext = cCurrent;

                if(cCurrent == cr) // If we have a "\r", then we read again, expecting a "\n".
                    nResult = (size_type)pIS->read(&cNext, sizeof(cNext));

                if(cNext != lf)
                {
                    // We have encountered an unexpected sequence: We have a "\rx" instead of "\n" or "\r\n".
                    // This call requires a stream that can back up.
                    pIS->setPosition(-(off_type)sizeof(cNext), kPositionTypeCurrent);
                }

                break;
            }
            else
            {
                if(pLine && (nCount < (nMaxCount - 1))) // '- 1' because we want to leave room for terminating null.
                {
                    if(endianSource != kEndianLocal)
                        cCurrent = SwizzleUint16(cCurrent);

                    *pLine++ = cCurrent;
                }

                ++nCount;
            }
        }
        else
        {
            // In this case, there was nothing left to read in the file.
            // We need to differentiate between an empty line vs. nothing 
            // left to read in the file. To deal with that we return kSizeTypeDone.
            if(nread == 0)
                nCount = kSizeTypeDone;

            break;
        }
    }

    if(pLine)
        *pLine = 0;
    else
        pIS->setPosition(ninitialPosition);

    return nCount;
}