Exemple #1
0
    };
    for (int i=0; i<sizeof(arr)/sizeof(arr[0]); i++)
    {
        if (InlineIsEqualGUID(*arr[i],riid))
            return S_OK;
    }
    return S_FALSE;
}

STDMETHODIMP CCTFExContext::get_Description(BSTR * pVal)
{
    AFX_MANAGE_STATE(AfxGetStaticModuleState())
    if (NULL == pVal)
        return E_POINTER;

    CString str;

    VERIFY(str.LoadString (IDS_EXCONTEXT_DESC));
    if (str.IsEmpty())
        return Error (g_cbNoMemory, E_OUTOFMEMORY);

    CComBSTR bstr (str);

    if (!bstr)
        return Error (g_cbNoMemory, E_OUTOFMEMORY);

    *pVal = bstr.Detach();
    return S_OK;
}

STDMETHODIMP CCTFExContext::get_Meridian(int * pVal)
void CIconStatic::SetIcon(LPCTSTR pszIconID)
{
	m_strIconID = pszIconID;

	// If this function is called for the first time and we did not yet call 'SetWindowText', we take
	// the window label which is already specified for the window (the label which comes from the resource)
	CString strText;
	CStatic::GetWindowText(strText);
	CStatic::SetWindowText(_T(""));
	if (!strText.IsEmpty() && m_strText.IsEmpty())
		m_strText = strText;

	CRect rRect;
	GetClientRect(rRect);

	CDC *pDC = GetDC();
	CDC MemDC;
	CBitmap *pOldBMP;
	
	VERIFY( MemDC.CreateCompatibleDC(pDC) );

	CFont *pOldFont = MemDC.SelectObject(GetFont());

	CRect rCaption(0,0,0,0);
	MemDC.DrawText(m_strText, rCaption, DT_CALCRECT);
	ASSERT( rCaption.Width() >= 0 );
	ASSERT( rCaption.Height() >= 0 );
	if (rCaption.Height() < 16)
		rCaption.bottom = rCaption.top + 16;
	rCaption.right += 25;
	if (rRect.Width() >= 16 && rCaption.Width() > rRect.Width() - 16)
		rCaption.right = rCaption.left + rRect.Width() - 16;

	if (m_MemBMP.m_hObject)
		VERIFY( m_MemBMP.DeleteObject() );
	VERIFY( m_MemBMP.CreateCompatibleBitmap(pDC, rCaption.Width(), rCaption.Height()) );
	pOldBMP = MemDC.SelectObject(&m_MemBMP);

	// Get the background color from the parent window. This way the controls which are
	// embedded in a dialog window can get painted with the same background color as
	// the dialog window.
	HBRUSH hbr = (HBRUSH)GetParent()->SendMessage(WM_CTLCOLORSTATIC, (WPARAM)MemDC.m_hDC, (LPARAM)m_hWnd);
	FillRect(MemDC, &rCaption, hbr);

	if (!m_strIconID.IsEmpty())
		VERIFY( DrawState( MemDC.m_hDC, NULL, NULL, (LPARAM)(HICON)CTempIconLoader(m_strIconID, 16, 16), NULL, 3, 0, 16, 16, DST_ICON | DSS_NORMAL) );

	// clear all alpha channel data
	BITMAP bmMem;
	if (m_MemBMP.GetObject(sizeof bmMem, &bmMem) >= sizeof bmMem && bmMem.bmBitsPixel == 32)
	{
		DWORD dwSize = m_MemBMP.GetBitmapBits(0, NULL);
		if (dwSize)
		{
			LPBYTE pPixels = (LPBYTE)malloc(dwSize);
			if (pPixels)
			{
				if (m_MemBMP.GetBitmapBits(dwSize, pPixels) == dwSize)
				{
					LPBYTE pLine = pPixels;
					int iLines = bmMem.bmHeight;
					while (iLines-- > 0)
					{
						LPDWORD pdwPixel = (LPDWORD)pLine;
						for (int x = 0; x < bmMem.bmWidth; x++)
							*pdwPixel++ &= 0x00FFFFFF;
						pLine += bmMem.bmWidthBytes;
					}
					m_MemBMP.SetBitmapBits(dwSize, pPixels);
				}
				free(pPixels);
			}
		}
	}

	rCaption.left += 22;
	
	if(g_xpStyle.IsThemeActive() && g_xpStyle.IsAppThemed())
    {
		HTHEME hTheme = g_xpStyle.OpenThemeData(NULL, L"BUTTON"); 
		g_xpStyle.DrawThemeText(hTheme, MemDC.m_hDC, BP_GROUPBOX, GBS_NORMAL, m_strText, m_strText.GetLength(), 
			DT_WORDBREAK | DT_CENTER | DT_WORD_ELLIPSIS, NULL, &rCaption); 
		g_xpStyle.CloseThemeData(hTheme);
	}
	else
	{
		MemDC.SetTextColor(GetSysColor(COLOR_WINDOWTEXT));
		MemDC.DrawText(m_strText, rCaption, DT_SINGLELINE | DT_LEFT | DT_END_ELLIPSIS);
	}

	ReleaseDC(pDC);

	MemDC.SelectObject(pOldBMP);
	MemDC.SelectObject(pOldFont);
	
	if (m_wndPicture.m_hWnd == NULL)
		m_wndPicture.Create(NULL, WS_CHILD | WS_VISIBLE | SS_BITMAP, CRect(0,0,0,0), this);
	m_wndPicture.SetWindowPos(NULL, rRect.left+8, rRect.top, rCaption.Width()+22, rCaption.Height(), SWP_SHOWWINDOW);
	m_wndPicture.SetBitmap(m_MemBMP);

	CRect r;
	GetWindowRect(r);
	r.bottom = r.top + 20;
	GetParent()->ScreenToClient(&r);
	GetParent()->RedrawWindow(r);
}
BOOL CSMTP::transmit_message(MailHeader* msg)
{
	CString sFrom;
	CString sTo;
	CString sTemp;
	CString sEmail;

	ASSERT( msg != NULL );
	if( !m_Connected )
	{
		m_Error = _T( "Must be connected" );
		AfxMessageBox(_T(m_Error));
		return FALSE;
	}

	// gui MAIL 
	sFrom.Format( "MAIL From: <%s>\r\n", (LPCTSTR)msg->From );
	m_Server.Send( (LPCTSTR)sFrom, sFrom.GetLength() );
	Sleep(300);
	if( !get_response( GENERIC_SUCCESS ) )
		return FALSE;
	
	// gui RCPT
	sFrom.Format( "RCPT To: <%s>\r\n", (LPCTSTR)msg->To );
	m_Server.Send( (LPCTSTR)sFrom, sFrom.GetLength() );
	Sleep(300);
		if( !get_response( GENERIC_SUCCESS ) )
			return FALSE;

	// gui DATA 
	sTemp = "DATA\r\n";
	m_Server.Send( (LPCTSTR)sTemp, sTemp.GetLength() );
	/*if( !get_response( INPUT_DATA ) )
	{
		return FALSE;
	}*/
	// Send the header
	Sleep(300);
	CString _messageFormat;
	_messageFormat.Format("Message-ID: %s\r\nFrom: %s\r\nTo: %s\r\nCc: %s\r\nDate: %s\r\nSubject: %s\r\nMime-Version: %s\r\nContent-Type: %s\r\n\n%s",
		msg->MessageID,
		msg->From,
		msg->To,
		msg->Cc,
		msg->Date,
		msg->Subject,
		msg->MimeVersion,
		msg->ContentType,
		msg->TextBody);
	m_Server.Send(_messageFormat,_messageFormat.GetLength());
	//Sleep(300);
	//m_Server.Send( (LPCTSTR)msg->Subject, msg->Subject.GetLength() );
	// Send the body
	//sTemp = prepare_body( msg );
	//m_Server.Send( (LPCTSTR)sTemp, sTemp.GetLength() );

	Sleep(300);

	// Them dau . de ket thuc mail
	sTemp = "\r\n.\r\n";
	m_Server.Send( (LPCTSTR)sTemp, sTemp.GetLength() );
	if( !get_response( GENERIC_SUCCESS ) )
	{
		return FALSE;
	}

	//send mail to Cc
	if (!msg->Cc.IsEmpty())
	{
		sFrom.Format( "MAIL From: <%s>\r\n", (LPCTSTR)msg->From );
		m_Server.Send( (LPCTSTR)sFrom, sFrom.GetLength() );
		Sleep(300);
		if( !get_response( GENERIC_SUCCESS ) )
			return FALSE;
		
		// gui RCPT
		sFrom.Format( "RCPT To: <%s>\r\n", (LPCTSTR)msg->Cc );
		m_Server.Send( (LPCTSTR)sFrom, sFrom.GetLength() );
		Sleep(300);
			if( !get_response( GENERIC_SUCCESS ) )
				return FALSE;

		// gui DATA 
		sTemp = "DATA\r\n";
		m_Server.Send( (LPCTSTR)sTemp, sTemp.GetLength() );
		/*if( !get_response( INPUT_DATA ) )
		{
			return FALSE;
		}*/
		// Send the header
		Sleep(300);
		m_Server.Send(_messageFormat,_messageFormat.GetLength());
		//Sleep(300);
		//m_Server.Send( (LPCTSTR)msg->Subject, msg->Subject.GetLength() );
		// Send the body
		//sTemp = prepare_body( msg );
		//m_Server.Send( (LPCTSTR)sTemp, sTemp.GetLength() );

		Sleep(300);

		// Them dau . de ket thuc mail
		sTemp = "\r\n.\r\n";
		m_Server.Send( (LPCTSTR)sTemp, sTemp.GetLength() );
		if( !get_response( GENERIC_SUCCESS ) )
		{
			return FALSE;
		}
	}

	CMailHeaderServices* mailHeadrService = new CMailHeaderServices();
	msg->UserId = globalUser.UserId();
	msg->GroupId = 3;
	mailHeadrService->InsertNewMail(msg);

	if (mailHeadrService != NULL) delete mailHeadrService;

	return TRUE;
}
BOOL CSMTP::transmit_message( MailHeader* msg, CMimeMessage* mime )
{
	CString sFrom;
	CString sTo;
	CString sTemp;
	CString sEmail;

	ASSERT( msg != NULL );
	if( !m_Connected )
	{
		m_Error = _T( "Must be connected" );
		AfxMessageBox(_T(m_Error));
		return FALSE;
	}

	sFrom.Format( "MAIL From: <%s>\r\n", (LPCTSTR)msg->From );
	m_Server.Send( (LPCTSTR)sFrom, sFrom.GetLength() );
	Sleep(300);
	if( !get_response( GENERIC_SUCCESS ) )
		return FALSE;

	sFrom.Format( "RCPT To: <%s>\r\n", (LPCTSTR)msg->To );
	m_Server.Send( (LPCTSTR)sFrom, sFrom.GetLength() );
	Sleep(300);
		if( !get_response( GENERIC_SUCCESS ) )
			return FALSE;

	sTemp = "DATA\r\n";
	m_Server.Send( (LPCTSTR)sTemp, sTemp.GetLength() );
	/*if( !get_response( INPUT_DATA ) )
	{
		return FALSE;
	}*/
	// Send the header
	Sleep(300);
	CString _mailMessage(mime->ConvertToString());
	m_Server.Send(_mailMessage,_mailMessage.GetLength());
	//AfxMessageBox(_T(_mailMessage));
	//m_Server.Send( (LPCTSTR)msg->Subject, msg->Subject.GetLength() );
	// Send the body
	//sTemp = prepare_body( msg );
	//m_Server.Send( (LPCTSTR)sTemp, sTemp.GetLength() );

	Sleep(300);

	sTemp = "\r\n.\r\n";
	m_Server.Send( (LPCTSTR)sTemp, sTemp.GetLength() );
	if( !get_response( GENERIC_SUCCESS ) )
	{
		return FALSE;
	}
	if (!msg->Cc.IsEmpty())
	{
		sFrom.Format( "MAIL From: <%s>\r\n", (LPCTSTR)msg->From );
		m_Server.Send( (LPCTSTR)sFrom, sFrom.GetLength() );
		Sleep(300);
		if( !get_response( GENERIC_SUCCESS ) )
			return FALSE;
		
		// gui RCPT
		sFrom.Format( "RCPT To: <%s>\r\n", (LPCTSTR)msg->Cc );
		m_Server.Send( (LPCTSTR)sFrom, sFrom.GetLength() );
		Sleep(300);
			if( !get_response( GENERIC_SUCCESS ) )
				return FALSE;

		// gui DATA 
		sTemp = "DATA\r\n";
		m_Server.Send( (LPCTSTR)sTemp, sTemp.GetLength() );
		/*if( !get_response( INPUT_DATA ) )
		{
			return FALSE;
		}*/
		// Send the header
		Sleep(300);
		m_Server.Send(_mailMessage,_mailMessage.GetLength());
		//Sleep(300);
		//m_Server.Send( (LPCTSTR)msg->Subject, msg->Subject.GetLength() );
		// Send the body
		//sTemp = prepare_body( msg );
		//m_Server.Send( (LPCTSTR)sTemp, sTemp.GetLength() );

		Sleep(300);

		// Them dau . de ket thuc mail
		sTemp = "\r\n.\r\n";
		m_Server.Send( (LPCTSTR)sTemp, sTemp.GetLength() );
		if( !get_response( GENERIC_SUCCESS ) )
		{
			return FALSE;
		}
	}

	CMailHeaderServices* mailHeadrService = new CMailHeaderServices();
	msg->UserId = globalUser.UserId();
	msg->GroupId = 3;
	msg->TextBody = _mailMessage;
	mailHeadrService->InsertNewMail(msg);
	if (mailHeadrService != NULL) delete mailHeadrService;

	return TRUE;
}
Exemple #5
0
void CConanGlueDlg::OnBnClickedButton4()
{
	ProgressBar.ShowWindow(SW_SHOW);
	ProgressBar.SetPos(0);
	ProgressBar.SetStep(1);

	CString path;
	SettingsFile.GetWindowText(path);
	FILE *stream;
	TCHAR line[500];
	if (_wfopen_s(&stream, path, _T("r")) == 0)
	{
		while (fgetws(line, 500, stream))
		{
			///int s=strlen(line);
			//char* l=new char[s+1];
			//strcpy_s(l,s+1,line);
			FileRecord* f = new FileRecord(line);
			if (f->Fname == NULL)
				delete(f);
			else
				FileRecords.push_back(f);
		}
		fclose(stream);
	}
	else
	{
		MessageBox(_T("Не удалось прочитать файл спецификации склейки!"), _T("Ошибка"), MB_OK);
		return;
	}
	CString info;
	CString fname;
	int nRec = FileRecords.size();
	info.Format(_T("%d элементов для обработки"), nRec);
	AddLog(&Log, info);
	//begin reading conan
	ProgressBar.SetRange(0, 3 + nRec);
	ProgressBar.StepIt();

	AddLog(&Log, _T("создаём файл заголовка"));
	filedir.GetWindowText(fname);
	fname.Append(_T("\\"));
	fname.Append(FileRecords.at(0)->Fname);
	ConanData* Conan = ReadConanFile(fname.GetBuffer(), &Log);
	//first one.
	//Make header structure for all the eeg later.
	//remove all extra info from object
	for (int i = 0; i < Conan->Header->nRec; i++)
	{
		for (int j = 0; j < Conan->Header->nChan; j++)
		{
			delete[] Conan->Eeg[i][j];
			delete[] Conan->NotCalibrated[i][j];
		}
		delete[] Conan->Eeg[i];
		delete[] Conan->NotCalibrated[i];
		delete[] Conan->Discr[i];
	}
	delete[] Conan->Eeg;
	delete[] Conan->TimeCreating;
	delete[] Conan->NDataReal2;
	delete[] Conan->NDataReal;
	delete[] Conan->NDataRaw;
	delete[] Conan->Discr;
	delete[] Conan->NotCalibrated;

	//create structure for new object
	Conan->Header->nRec = nRec;
	Conan->Eeg = new float**[nRec];
	Conan->NotCalibrated = new __int16**[nRec];
	Conan->TimeCreating = new __int32[nRec];
	Conan->NDataReal2 = new unsigned __int16[nRec];
	Conan->NDataReal = new unsigned __int16[nRec];
	Conan->NDataRaw = new unsigned __int16[nRec];
	Conan->Discr = new StimulSignal*[nRec];
	//now - fill records!
	ProgressBar.StepIt();
	CString fnameNew;
	for (int CurrentRecNum = 0; CurrentRecNum < nRec; CurrentRecNum++)
	{
		filedir.GetWindowText(fnameNew);
		fnameNew.Append(_T("\\"));
		fnameNew.Append(FileRecords.at(CurrentRecNum)->Fname);
		info = _T("Переписываем файл ") + fnameNew;
		AddLog(&Log, info);
		ConanData* NewConan = ReadConanFile(fnameNew.GetBuffer(), &Log);
		if (NewConan == NULL)
		{
			info = _T("Не удалось прочитать файл ") + fnameNew;
			info.Append(_T(" Склейка не может быть завершена"));
			MessageBox(info);
			ProgressBar.ShowWindow(SW_HIDE);
			return;
		}

		if (NewConan->Header->isNewVersion() && !Conan->Header->isNewVersion())
		{
			info = _T("Версия файла ") + fnameNew + _T(" новее, чем файла ") + fname;
			info.Append(_T(" Склейка не может быть завершена"));
			MessageBox(info);
			delete(NewConan);
			ProgressBar.ShowWindow(SW_HIDE);
			return;
		}

		if (!NewConan->Header->isNewVersion() && Conan->Header->isNewVersion())
		{
			info = _T("Версия файла ") + fnameNew + _T(" старее, чем файла ") + fname;
			info.Append(_T(" Склейка не может быть завершена"));
			MessageBox(info);
			delete(NewConan);
			ProgressBar.ShowWindow(SW_HIDE);
			return;
		}

		int CurrentCopyingRecord = FileRecords.at(CurrentRecNum)->RecNum - 1;//not 1 but 0-based index
		memcpy_s(&Conan->NDataRaw[CurrentRecNum], sizeof(__int16), &NewConan->NDataRaw[CurrentCopyingRecord], sizeof(__int16));
		memcpy_s(&Conan->NDataReal[CurrentRecNum], sizeof(__int16), &NewConan->NDataReal[CurrentCopyingRecord], sizeof(__int16));

		Conan->Eeg[CurrentRecNum] = new float*[NewConan->Header->nChan];
		for (int j = 0; j < NewConan->Header->nChan; j++)
		{
			Conan->Eeg[CurrentRecNum][j] = new float[NewConan->NDataReal[CurrentCopyingRecord]];
			for (int k = 0; k < NewConan->NDataReal[CurrentCopyingRecord]; k++)
			{
				memcpy_s(&Conan->Eeg[CurrentRecNum][j][k], sizeof(float), &NewConan->Eeg[CurrentCopyingRecord][j][k], sizeof(float));
			}
		}

		Conan->NotCalibrated[CurrentRecNum] = new __int16*[NewConan->Header->nChan];
		for (int j = 0; j < NewConan->Header->nChan; j++)
		{
			Conan->NotCalibrated[CurrentRecNum][j] = new __int16[NewConan->NDataReal[CurrentCopyingRecord]];
			for (int k = 0; k < NewConan->NDataReal[CurrentCopyingRecord]; k++)
			{
				memcpy_s(&Conan->NotCalibrated[CurrentRecNum][j][k], sizeof(__int16), &NewConan->NotCalibrated[CurrentCopyingRecord][j][k], sizeof(__int16));
			}
		}

		if (NewConan->Header->discrExist == 1)
		{
			Conan->Discr[CurrentRecNum] = new StimulSignal[NewConan->NDataReal[CurrentCopyingRecord]];
			for (int k = 0; k < NewConan->NDataReal[CurrentCopyingRecord]; k++)
			{
				memcpy_s(&Conan->Discr[CurrentRecNum][k].Elder, sizeof(__int8), &NewConan->Discr[CurrentCopyingRecord][k].Elder, sizeof(__int8));
				memcpy_s(&Conan->Discr[CurrentRecNum][k].Littler, sizeof(__int8), &NewConan->Discr[CurrentCopyingRecord][k].Littler, sizeof(__int8));
			}
		}
		else
		{
			Conan->Discr[CurrentRecNum] = new StimulSignal[NewConan->Header->nChan];
			for (unsigned int k = 0; k < NewConan->Header->nChan; k++)
			{
				Conan->Discr[CurrentRecNum][k].Littler = 0;
				Conan->Discr[CurrentRecNum][k].Elder = 0;
			}
		}

		memcpy_s(&Conan->TimeCreating[CurrentRecNum], sizeof(__int32), &NewConan->TimeCreating[CurrentCopyingRecord], sizeof(__int32));

		memcpy_s(&Conan->NDataReal2[CurrentRecNum], sizeof(__int16), &NewConan->NDataReal2[CurrentCopyingRecord], sizeof(__int16));


		delete(NewConan);
		ProgressBar.StepIt();
	}

	///cleanup
	for (unsigned int i = 0; i < FileRecords.size(); i++)
	{
		delete (FileRecords.at(i));
	}
	FileRecords.erase(FileRecords.begin(), FileRecords.end());

	// Now - save new conan file.
	OutputFile.GetWindowText(fname);
	if (WriteConanFile(fname.GetBuffer(), Conan, &Log) == 0)
	{
		MessageBox(_T("Не удалось записать склеенный файл!"));
	}
	//clear
	delete(Conan);
	ProgressBar.StepIt();
	AddLog(&Log, _T("запись окончена"));
	ProgressBar.ShowWindow(SW_HIDE);
}
Exemple #6
0
void EnumerateSerialPorts(CUIntArray& ports)
{
  //Make sure we clear out any elements which may already be in the array
  ports.RemoveAll();

  //Determine what OS we are running on
  OSVERSIONINFO osvi;
  osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  BOOL bGetVer = GetVersionEx(&osvi);

  //On NT use the QueryDosDevice API
  if (bGetVer && (osvi.dwPlatformId == VER_PLATFORM_WIN32_NT))
  {
    //Use QueryDosDevice to look for all devices of the form COMx. This is a better
    //solution as it means that no ports have to be opened at all.
    TCHAR szDevices[65535];
    DWORD dwChars = QueryDosDevice(NULL, szDevices, 65535);
    if (dwChars)
    {
      int i=0;

      for (;;)
      {
        //Get the current device name
        TCHAR* pszCurrentDevice = &szDevices[i];

        //If it looks like "COMX" then
        //add it to the array which will be returned
        int nLen = _tcslen(pszCurrentDevice);
        if (nLen > 3 && _tcsnicmp(pszCurrentDevice, _T("COM"), 3) == 0)
        {
          //Work out the port number
          int nPort = _ttoi(&pszCurrentDevice[3]);
          ports.Add(nPort);
        }

        // Go to next NULL character
        while(szDevices[i] != _T('\0'))
          i++;

        // Bump pointer to the next string
        i++;

        // The list is double-NULL terminated, so if the character is
        // now NULL, we're at the end
        if (szDevices[i] == _T('\0'))
          break;
      }
    }
    else
      TRACE(_T("Failed in call to QueryDosDevice, GetLastError:%d\n"), GetLastError());
  }
  else
  {
    //On 95/98 open up each port to determine their existence

    //Up to 255 COM ports are supported so we iterate through all of them seeing
    //if we can open them or if we fail to open them, get an access denied or general error error.
    //Both of these cases indicate that there is a COM port at that number. 
    for (UINT i=1; i<256; i++)
    {
      //Form the Raw device name
      CString sPort;
      sPort.Format(_T("\\\\.\\COM%d"), i);

      //Try to open the port
      BOOL bSuccess = FALSE;
      HANDLE hPort = ::CreateFile(sPort, GENERIC_READ | GENERIC_WRITE, 0, 0, OPEN_EXISTING, 0, 0);
      if (hPort == INVALID_HANDLE_VALUE)
      {
        DWORD dwError = GetLastError();

        //Check to see if the error was because some other app had the port open or a general failure
        if (dwError == ERROR_ACCESS_DENIED || dwError == ERROR_GEN_FAILURE)
          bSuccess = TRUE;
      }
      else
      {
        //The port was opened successfully
        bSuccess = TRUE;

        //Don't forget to close the port, since we are going to do nothing with it anyway
        CloseHandle(hPort);
      }

      //Add the port number to the array which will be returned
      if (bSuccess)
        ports.Add(i);
    }
  }
}
void ElectricModelingDLGMoreElastic::OnTcnSelchangeTabMoreElastic(NMHDR *pNMHDR, LRESULT *pResult)
{
	// TODO: Add your control notification handler code here
	/*
	switch (m_TabMoreElastic.GetCurSel())
	{
	case 0:
		m_electricModelingDLGElastic[0].ShowWindow(SW_SHOW);
		m_electricModelingDLGElastic[1].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[2].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[3].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[4].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[5].ShowWindow(SW_HIDE);
		break;
	case 1:
		m_electricModelingDLGElastic[0].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[1].ShowWindow(SW_SHOW);
		m_electricModelingDLGElastic[2].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[3].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[4].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[5].ShowWindow(SW_HIDE);
		break;
	case 2:
		m_electricModelingDLGElastic[0].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[1].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[2].ShowWindow(SW_SHOW);
		m_electricModelingDLGElastic[3].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[4].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[5].ShowWindow(SW_HIDE);
		break;
	case 3:
		m_electricModelingDLGElastic[0].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[1].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[2].ShowWindow(SW_SHOW);
		m_electricModelingDLGElastic[3].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[4].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[5].ShowWindow(SW_HIDE);
		break;
	case 4:
		m_electricModelingDLGElastic[0].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[1].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[2].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[3].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[4].ShowWindow(SW_SHOW);
		m_electricModelingDLGElastic[5].ShowWindow(SW_HIDE);
		break;
	case 5:
		m_electricModelingDLGElastic[0].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[1].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[2].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[3].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[4].ShowWindow(SW_HIDE);
		m_electricModelingDLGElastic[5].ShowWindow(SW_SHOW);
		break;
	}
	*/
	int cur = m_TabMoreElastic.GetCurSel();
	CString curstr;
	curstr.Format("%d",cur);
	//::MessageBox(NULL,curstr,_T("OKOK"),MB_OK);
	if (cur >=0 && cur <m_PhaseCount){
		for (int i=0;i<this->m_PhaseCount;i++)
		{
			if (i==cur){
				m_pelectricModelingDLGElastic[cur]->ShowWindow(SW_SHOW);
			}else{
				m_pelectricModelingDLGElastic[i]->ShowWindow(SW_HIDE);
			}
		}
		// 
		if (m_simulationType == 1){
			m_pelectricModelingDLGMechanical->ShowWindow(SW_HIDE);
		}
	}
	else if (cur==this->m_PhaseCount){
		for (int i=0;i<this->m_PhaseCount;i++)
		{
			m_pelectricModelingDLGElastic[i]->ShowWindow(SW_HIDE);
		}
		m_pelectricModelingDLGMechanical->ShowWindow(SW_SHOW);
	}

	*pResult = 0;
}
BOOL ElectricModelingDLGMoreElastic::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here

	// 是构造函数先被调用吗?(是的)
	/*
	CString temp;
	temp.Format("%d",this->m_PhaseCount);
	::MessageBox(NULL,_T("进入OnInitDialog"+temp),_T("OKOK"),MB_OK);
	*/
	CString str;
	TCITEM temp[6];
	CRect tabRect;
	m_TabMoreElastic.GetClientRect(&tabRect);
	// 定位选项卡位置
	tabRect.bottom -=8;
	tabRect.left +=8;
	tabRect.top +=20;
	tabRect.right-=8;
	for (int i=0;i<this->m_PhaseCount;i++)
	{
		temp[i].mask=TCIF_TEXT;
		str.Format("%s%d","Phase No.",i+1);
		temp[i].pszText=_T((LPSTR)(LPCTSTR)str);
		m_TabMoreElastic.InsertItem(i,&temp[i]);
		// 利用一个模版创建多个子对话框
		// 确保创建一次并持有对象
		if (m_pelectricModelingDLGElastic[i] ==  NULL){
			// 很矛盾,如果没有则创建
			//::MessageBox(NULL,_T("DLGElastic分配内存"),_T("OKOK"),MB_OK);
			m_pelectricModelingDLGElastic[i] = new ElectricModelingDLGElastic();
		}
		m_pelectricModelingDLGElastic[i]->Create(IDD_MODELING_DLG_ELASTIC,GetDlgItem(IDC_TAB_MORE_ELASTIC));
		//m_electricModelingDLGElastic[i].SetParent(GetDlgItem(IDC_TAB_MORE_ELASTIC));
		m_pelectricModelingDLGElastic[i]->m_StaticPropertisPHNox.SetWindowTextA(str);
		// 将子对话框移动到指定的位置
		m_pelectricModelingDLGElastic[i]->MoveWindow(&tabRect);

	}
	// simulation type 选择了Material response to an external field时加入相应的选项
	if (this->m_simulationType == 1){
		//::MessageBox(NULL,_T("选择了Material response to an external field"),_T("OKOK"),MB_OK);
		TCITEM mechanical;
		mechanical.mask = TCIF_TEXT;
		mechanical.pszText = "External Field mechanical";
		// 确保创建一次,并持有对象
		if (m_pelectricModelingDLGMechanical == NULL){
			m_pelectricModelingDLGMechanical = new ElectricModelingDLGMechanical();
		}
		m_pelectricModelingDLGMechanical->Create(IDD_MODELING_DLG_MECHANICAL,GetDlgItem(IDC_TAB_MORE_ELASTIC));
		m_TabMoreElastic.InsertItem(m_PhaseCount,&mechanical);
		m_pelectricModelingDLGMechanical->MoveWindow(&tabRect);
		m_pelectricModelingDLGMechanical->ShowWindow(SW_HIDE);
	}
	m_pelectricModelingDLGElastic[0]->ShowWindow(SW_SHOW);
	for (int i =1;i<m_PhaseCount;i++)
	{
		m_pelectricModelingDLGElastic[i]->ShowWindow(SW_HIDE);
	}
	/*
	if (m_pelectricModelingDLGMechanical != NULL){
		m_pelectricModelingDLGMechanical->Create(IDD_MODELING_DLG_MECHANICAL,GetDlgItem(IDC_TAB_MORE_ELASTIC));
		m_pelectricModelingDLGMechanical->ShowWindow(SW_HIDE);
	}
	*/



	// 给对话框设置标题
	this->SetWindowTextA(m_caption);


	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Exemple #9
0
CString CMissile::DebugCrashInfo (void)

//	DebugCrashInfo
//
//	Dump debug information

	{
	CString sResult;

	if (m_fDestroyed)
		sResult.Append(CONSTLIT("m_fDestroyed: true\r\n"));
	sResult.Append(strPatternSubst(CONSTLIT("m_pDesc: %s\r\n"), m_pDesc->m_sUNID.GetPointer()));
	sResult.Append(strPatternSubst(CONSTLIT("m_Source: %s\r\n"), CSpaceObject::DebugDescribe(m_Source.GetObj()).GetPointer()));
	sResult.Append(strPatternSubst(CONSTLIT("m_pHit: %s\r\n"), CSpaceObject::DebugDescribe(m_pHit).GetPointer()));
	sResult.Append(strPatternSubst(CONSTLIT("m_iHitDir: %d\r\n"), m_iHitDir));
	sResult.Append(strPatternSubst(CONSTLIT("m_pTarget: %s\r\n"), CSpaceObject::DebugDescribe(m_pTarget).GetASCIIZPointer()));
	sResult.Append(strPatternSubst(CONSTLIT("m_iDestiny: %d\r\n"), GetDestiny()));
	sResult.Append(strPatternSubst(CONSTLIT("m_iTick: %d\r\n"), m_iTick));
	sResult.Append(strPatternSubst(CONSTLIT("m_iLifeLeft: %d\r\n"), m_iLifeLeft));

	//	m_pExhaust

	try
		{
		if (m_pExhaust)
			{
			int iExhaustCount = m_pExhaust->GetCount();
			sResult.Append(strPatternSubst(CONSTLIT("m_pExhaust: %d\r\n"), iExhaustCount));
			}
		else
			sResult.Append(CONSTLIT("m_pExhaust: none\r\n"));
		}
	catch (...)
		{
		sResult.Append(strPatternSubst(CONSTLIT("m_pExhaust: %x [invalid]\r\n"), (DWORD)m_pExhaust));
		}

	return sResult;
	}
Exemple #10
0
void CMissile::OnReadFromStream (SLoadCtx &Ctx)

//	OnReadFromStream
//
//	Read object data from a stream
//
//	CString		CWeaponFireDesc UNID
//	DWORD		m_iBonus
//	DWORD		m_iCause
//	DWORD		m_iHitPoints
//	DWORD		m_iLifeLeft
//	DWORD		m_Source (CSpaceObject ref)
//	DWORD		m_pSovereign (CSovereign ref)
//	DWORD		m_pHit (CSpaceObject ref)
//	Vector		m_vHitPos
//	DWORD		m_iHitDir
//	DWORD		m_iRotation
//	DWORD		m_pTarget (CSpaceObject ref)
//	DWORD		m_iTick
//
//	IEffectPainter	m_pPainter
//
//	DWORD		Number of exhaust particles
//	Vector		exhaust: vPos
//	Vector		exhaust: vVel
//
//	-- version > 0 -----------------------
//	DWORD		flags
//	DWORD		Number of saved rotations
//	DWORD		rotation[]

	{
	DWORD dwLoad;

#ifdef DEBUG_LOAD
	::OutputDebugString("CMissile::OnReadFromStream\n");
#endif
	//	Load descriptor

	CString sDescUNID;
	sDescUNID.ReadFromStream(Ctx.pStream);
	m_pDesc = g_pUniverse->FindWeaponFireDesc(sDescUNID);

	//	Load other stuff

	Ctx.pStream->Read((char *)&m_iBonus, sizeof(m_iBonus));
	if (Ctx.dwVersion >= 18)
		{
		Ctx.pStream->Read((char *)&dwLoad, sizeof(DWORD));
		m_iCause = (DestructionTypes)dwLoad;
		}
	else
		m_iCause = killedByDamage;

	if (Ctx.dwVersion >= 28)
		Ctx.pStream->Read((char *)&m_iHitPoints, sizeof(DWORD));
	else
		m_iHitPoints = 0;

	Ctx.pStream->Read((char *)&m_iLifeLeft, sizeof(DWORD));
	m_Source.ReadFromStream(Ctx);
	Ctx.pSystem->ReadSovereignRefFromStream(Ctx, &m_pSovereign);
	Ctx.pSystem->ReadObjRefFromStream(Ctx, &m_pHit);
	Ctx.pStream->Read((char *)&m_vHitPos, sizeof(CVector));
	Ctx.pStream->Read((char *)&m_iHitDir, sizeof(DWORD));
	Ctx.pStream->Read((char *)&m_iRotation, sizeof(DWORD));
	Ctx.pSystem->ReadObjRefFromStream(Ctx, &m_pTarget);
	Ctx.pStream->Read((char *)&m_iTick, sizeof(DWORD));

	//	Load painter

	if (m_pDesc->m_pEffect)
		m_pPainter = m_pDesc->m_pEffect->CreatePainterFromStreamAndCreator(Ctx);

	//	Load exhaust

	if (m_pDesc->m_iExhaustRate > 0)
		{
		int iCount = (m_pDesc->m_iExhaustLifetime / m_pDesc->m_iExhaustRate) + 1;
		m_pExhaust = new TQueue<SExhaustParticle>(iCount);
		}

	Ctx.pStream->Read((char *)&dwLoad, sizeof(DWORD));
	for (int i = 0; i < (int)dwLoad; i++)
		{
		CVector vPos;
		CVector vVel;
		Ctx.pStream->Read((char *)&vPos, sizeof(CVector));
		Ctx.pStream->Read((char *)&vVel, sizeof(CVector));

		if (m_pExhaust && i < m_pExhaust->GetMaxCount())
			{
			SExhaustParticle &Particle = m_pExhaust->GetAt(m_pExhaust->Queue());
			Particle.vPos = vPos;
			Particle.vVel = vVel;
			}
		}

	//	Load saved rotations

	if (Ctx.dwVersion >= 1)
		{
		Ctx.pStream->Read((char *)&dwLoad, sizeof(DWORD));
		m_fDestroyed =		((dwLoad & 0x00000001) ? true : false);
		m_fReflection =		((dwLoad & 0x00000002) ? true : false);
		m_fDetonate =		((dwLoad & 0x00000004) ? true : false);

		Ctx.pStream->Read((char *)&m_iSavedRotationsCount, sizeof(DWORD));
		if (m_iSavedRotationsCount > 0)
			{
			m_pSavedRotations = new int [m_pDesc->m_iVaporTrailLength];
			Ctx.pStream->Read((char *)m_pSavedRotations, sizeof(DWORD) * m_iSavedRotationsCount);
			}
		else
			m_iSavedRotationsCount = 0;
		}
	}
Exemple #11
0
/////////////////////////////////////////////////////////////////////////////
// ClientState message handlers
void CClientState::UpdateState()
{
	if (!m_dev)
	{
		return;
	}
	CDevMgr::GetDevMgr().GetAlarmInfo(m_dev->LoginID, &m_myState);
	CString str;
	str.Format("(%s [%s])",m_dev->Name, m_dev->IP);
	CString strTmp;
	CString strDiskError = ConvertString(MSG_CLIENTSTATE_DISKERR);
    for (int i=0; i<32; i++)
    {
     //   if (m_myState.diskerror[i])
		if (m_myState.dError & (0x01<<i))
        {
			strTmp.Format(" %d", i+1);
			strDiskError += strTmp;
        }
    }

	CString strDiskFull = ConvertString(MSG_CLIENTSTATE_DISKFULL);
	//if (m_myState.diskfull)
	if (m_myState.dFull)
	{
		strDiskFull += ConvertString("Full");
	}
	else
	{
		strDiskFull += ConvertString("Not");
	}
	
	CString strShelter = ConvertString(MSG_CLIENTSTATE_SHELTER);
	for (i=0; i<16; i++)
    {
        if (m_myState.shelter[i])
        {
			strTmp.Format(" %d", i+1);
            strShelter += strTmp;
        }
    }

    CString strAlarm = ConvertString(MSG_CLIENTSTATE_ALARM);
    for (i=0; i<m_dev->Info.byAlarmInPortNum; i++)
    {
      //  if (m_myState.alarmout[i])
		if (m_myState.cState.alarm[i])
        {
			strTmp.Format(" %d", i+1);
			strAlarm += strTmp;
        }
    }

    CString strMD = ConvertString(MSG_CLIENTSTATE_MOTION);
    CString strVideoLost = ConvertString(MSG_CLIENTSTATE_VIDEOLOST);
	CString strSD = ConvertString(MSG_CLIENTSTATE_SOUND);
    for (i=0; i<m_dev->Info.byChanNum; i++)
    {
        if (m_myState.cState.motiondection[i])
        {
			strTmp.Format(" %d", i+1);
            strMD += strTmp;
        }
        if (m_myState.cState.videolost[i])
        {
			strTmp.Format(" %d", i+1);
            strVideoLost += strTmp;
        }
        if (m_myState.soundalarm[i])
        {
			strTmp.Format(" %d", i+1);
            strSD += strTmp;
        }
    }

	CString strSerial = ConvertString(MSG_CLIENTSTATE_SERIAL);
	strTmp.Format("%s", m_dev->Info.sSerialNumber);
	strSerial += strTmp;

	CString strAlmDec = ConvertString(MSG_CLIENTSTATE_ALMDEC);
	strAlmDec += ": \n";
	for (i = 0; i < 16; i++)
	{
		for(int j = 0; j < 8; j++)
		{
			if (m_myState.almDecoder[i] & (1<<j))
			{
				strTmp.Format("%d", 1);
			}
			else
			{
				strTmp.Format("%d", 0);
			}
			strAlmDec += strTmp;
		}
		strAlmDec += " ";
	}
	str += ConvertString(MSG_CLIENTSTATE_CLIENTSTATE);
    str = str			+ "\n" + "\n"+
	  	  strDiskError  + "\n" + "\n"+
		  strDiskFull	+ "\n" + "\n"+
		  strShelter	+ "\n" + "\n"+
          strAlarm		+ "\n" + "\n"+
          strMD			+ "\n" + "\n"+
          strVideoLost  + "\n" + "\n"+
		  strSD			+ "\n" + "\n"+
		  strAlmDec		+ "\n" + "\n"+
		  strSerial;

    GetDlgItem(IDC_CLIENT_STATE)->SetWindowText(str);
}
CString MusicGroupBeautify( CString csName, CString csArtist, int nArtistLock, CString csType, CString csSuffix )
{
	CString csResult;
	CString csWord;
	CString csYear;
	int nLen = csName.GetLength();
	int nCount;
	int nNum;
	int nFlag;
	TCHAR *ptOrigin = new TCHAR[nLen+1];

	lstrcpy( ptOrigin, csName.GetBuffer(nLen) );
	csResult.Format( _T("") );
	
	//\u5982\u679C\u672A\u6307\u5B9A\u827A\u672F\u5BB6
	if( csArtist.Compare( _T("") ) == 0 || nArtistLock == 0 )
	{
		nCount = PunctuationGetDashPosition( ptOrigin );
		if( nCount != 0 )
		{
			*( ptOrigin + nCount ) = 0;
			csArtist.Format( _T("%s"), ptOrigin );
			ptOrigin += nCount + 1;
		}
	}

	//\u8BFB\u53D6\u540E\u9762\u5355\u8BCD
	csWord = PunctuationWordGetNext( ptOrigin, &nNum, &nFlag );
	nCount = 0;
	csResult.Format( _T("") );

	while( csWord.Compare( _T("") ) != 0 )
	{
		//\u5904\u7406\u5355\u8BCD
		if( nFlag == 2 || nFlag == -2 )
		{
			//\u5982\u679C\u662F\u5E74\u4EE3
			if( nCount > 0 && WordCheckYear( ptOrigin + nCount - 1 ) == 1 )
			{
				csYear = csWord;
			}
			//\u5982\u679C\u662F\u5531\u7247\u7C7B\u578B
			else if( WordCheckType( csWord ) == 1 )
			{
				csType = csWord;
			}
			//\u5982\u679C\u662F\u6B4C\u66F2\u683C\u5F0F
			else if( WordCheckMusic( csWord ) == 1 )
			{
				csSuffix = WordCap( csWord );
			}
			//\u5176\u4ED6
			else
			{
				csResult.AppendFormat( csWord );
			}
		}
		//\u5904\u7406\u7B26\u53F7
		else if( nFlag == 1 )
			csResult.AppendFormat( csWord );
		//\u5904\u7406\u672B\u5C3E\u7B26\u53F7
		else
		{
			csResult.AppendFormat( csWord );
			break;
		}
		nCount += nNum;
		csWord = PunctuationWordGetNext( ptOrigin + nCount, &nNum, &nFlag );
	}

	//\u5904\u7406\u62EC\u53F7
	csResult = PunctuationDeleteBlankBracket( csResult );
	csResult = PunctuationDeleteHead( csResult );
	csWord = PunctuationDeleteSingleBracket( csResult );

	//\u6574\u4F53\u7ED3\u6784
	csResult.Format( _T("") );
	if( csArtist.Compare( _T("") ) != 0 )
		csResult.AppendFormat( _T("%s-"), csArtist );
	csResult.AppendFormat( _T("[%s"), csWord );
	if( csYear.Compare( _T("") ) != 0 )
		csResult.AppendFormat( _T("(%s)]"), csYear );
	else
		csResult.AppendFormat( _T("]"), csYear );
	if( csType.Compare( _T("") ) != 0 )
		csResult.AppendFormat( _T("%s"), csType );
	else
		csResult.AppendFormat( _T("\u4E13\u8F91"));
	csResult.AppendFormat( _T("(%s)"), csSuffix );

	csName.ReleaseBuffer();

	return csResult;
}
Exemple #13
0
DWORD CHooks::RunScript(CString cmd, LPCTSTR currentDir, CString& error, bool bWait, bool bShow)
{
	DWORD exitcode = 0;
	SECURITY_ATTRIBUTES sa;
	SecureZeroMemory(&sa, sizeof(sa));
	sa.nLength = sizeof(sa);
	sa.bInheritHandle = TRUE;

	CAutoFile hOut ;
	CAutoFile hRedir;
	CAutoFile hErr;

	// clear the error string
	error.Empty();

	// Create Temp File for redirection
	TCHAR szTempPath[MAX_PATH];
	TCHAR szOutput[MAX_PATH];
	TCHAR szErr[MAX_PATH];
	GetTortoiseGitTempPath(_countof(szTempPath), szTempPath);
	GetTempFileName(szTempPath, _T("git"), 0, szErr);

	// setup redirection handles
	// output handle must be WRITE mode, share READ
	// redirect handle must be READ mode, share WRITE
	hErr   = CreateFile(szErr, GENERIC_WRITE, FILE_SHARE_READ, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY,	0);

	if (!hErr)
		return (DWORD)-1;

	hRedir = CreateFile(szErr, GENERIC_READ, FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);

	if (!hRedir)
		return (DWORD)-1;

	GetTempFileName(szTempPath, _T("git"), 0, szOutput);
	hOut   = CreateFile(szOutput, GENERIC_WRITE, FILE_SHARE_READ, &sa, CREATE_ALWAYS, FILE_ATTRIBUTE_TEMPORARY,	0);

	if (!hOut)
		return (DWORD)-1;

	// setup startup info, set std out/err handles
	// hide window
	STARTUPINFO si;
	SecureZeroMemory(&si, sizeof(si));
	si.cb = sizeof(si);
	if (hOut  != INVALID_HANDLE_VALUE)
	{
		si.dwFlags     = STARTF_USESTDHANDLES | STARTF_USESHOWWINDOW;
		si.hStdOutput  = hOut;
		si.hStdError   = hErr;
		si.wShowWindow = bShow ? SW_SHOW : SW_HIDE;
	}

	PROCESS_INFORMATION pi;
	SecureZeroMemory(&pi, sizeof(pi));

	DWORD dwFlags = 0;

	if (!CreateProcess(NULL, cmd.GetBuffer(), NULL, NULL, TRUE, dwFlags, NULL, currentDir, &si, &pi))
	{
			int err = GetLastError();  // preserve the CreateProcess error
			error = CFormatMessageWrapper(err);
			SetLastError(err);
			cmd.ReleaseBuffer();
			return (DWORD)-1;
	}
	cmd.ReleaseBuffer();

	CloseHandle(pi.hThread);

	// wait for process to finish, capture redirection and
	// send it to the parent window/console
	if (bWait)
	{
		DWORD dw;
		char buf[256];
		do
		{
			SecureZeroMemory(&buf,sizeof(buf));
			while (ReadFile(hRedir, &buf, sizeof(buf)-1, &dw, NULL))
			{
				if (dw == 0)
					break;
				error += CString(CStringA(buf,dw));
				SecureZeroMemory(&buf,sizeof(buf));
			}
		} while (WaitForSingleObject(pi.hProcess, 0) != WAIT_OBJECT_0);

		// perform any final flushing
		while (ReadFile(hRedir, &buf, sizeof(buf)-1, &dw, NULL))
		{
			if (dw == 0)
				break;

			error += CString(CStringA(buf, dw));
			SecureZeroMemory(&buf,sizeof(buf));
		}
		WaitForSingleObject(pi.hProcess, INFINITE);
		GetExitCodeProcess(pi.hProcess, &exitcode);
	}
	CloseHandle(pi.hProcess);
	DeleteFile(szOutput);
	DeleteFile(szErr);

	return exitcode;
}
Exemple #14
0
bool CHooks::Create()
{
	if (m_pInstance == NULL)
		m_pInstance = new CHooks();
	CRegString reghooks = CRegString(_T("Software\\TortoiseGit\\hooks"));
	CString strhooks = reghooks;
	// now fill the map with all the hooks defined in the string
	// the string consists of multiple lines, where one hook script is defined
	// as four lines:
	// line 1: the hook type
	// line 2: path to working copy where to apply the hook script
	// line 3: command line to execute
	// line 4: 'true' or 'false' for waiting for the script to finish
	// line 5: 'show' or 'hide' on how to start the hook script
	hookkey key;
	int pos = 0;
	hookcmd cmd;
	while ((pos = strhooks.Find('\n')) >= 0)
	{
		// line 1
		key.htype = GetHookType(strhooks.Mid(0, pos));
		if (pos+1 < strhooks.GetLength())
			strhooks = strhooks.Mid(pos+1);
		else
			strhooks.Empty();
		bool bComplete = false;
		if ((pos = strhooks.Find('\n')) >= 0)
		{
			// line 2
			key.path = CTGitPath(strhooks.Mid(0, pos));
			if (pos+1 < strhooks.GetLength())
				strhooks = strhooks.Mid(pos+1);
			else
				strhooks.Empty();
			if ((pos = strhooks.Find('\n')) >= 0)
			{
				// line 3
				cmd.commandline = strhooks.Mid(0, pos);
				if (pos+1 < strhooks.GetLength())
					strhooks = strhooks.Mid(pos+1);
				else
					strhooks.Empty();
				if ((pos = strhooks.Find('\n')) >= 0)
				{
					// line 4
					cmd.bWait = (strhooks.Mid(0, pos).CompareNoCase(_T("true"))==0);
					if (pos+1 < strhooks.GetLength())
						strhooks = strhooks.Mid(pos+1);
					else
						strhooks.Empty();
					if ((pos = strhooks.Find('\n')) >= 0)
					{
						// line 5
						cmd.bShow = (strhooks.Mid(0, pos).CompareNoCase(_T("show"))==0);
						if (pos+1 < strhooks.GetLength())
							strhooks = strhooks.Mid(pos+1);
						else
							strhooks.Empty();
						bComplete = true;
					}
				}
			}
		}
		if (bComplete)
		{
			m_pInstance->insert(std::pair<hookkey, hookcmd>(key, cmd));
		}
	}
	return true;
}
Exemple #15
0
void CHooks::AddDepthParam(CString& sCmd, git_depth_t depth)
{
	CString sTemp;
	sTemp.Format(_T("%d"), depth);
	AddParam(sCmd, sTemp);
}