Ejemplo n.º 1
0
void CurrentPreviewModels::OnAddButtonClick(wxCommandEvent& event)
{
    wxTextEntryDialog dlg(this, "Enter name for new group", "Enter name for new group");
    if (dlg.ShowModal() == wxID_OK) {
        wxString name = dlg.GetValue();
        while (mModels.GetModel(name.ToStdString()) != nullptr) {
            wxTextEntryDialog dlg2(this, "Model of name " + name + " already exists. Enter name for new group", "Enter name for new group");
            if (dlg2.ShowModal() == wxID_OK) {
                name = dlg2.GetValue();
            } else {
                return;
            }
        }
        wxXmlNode *node = new wxXmlNode(wxXML_ELEMENT_NODE, "modelGroup");
        mModelGroups->AddChild(node);
        node->AddAttribute("selected", "0");
        node->AddAttribute("name", name);
        node->AddAttribute("models", "");
        node->AddAttribute("layout", "minimalGrid");
        node->AddAttribute("GridSize", "400");

        mModels.AddModel(mModels.CreateModel(node));
        PopulateModelGroups();
    }
}
Ejemplo n.º 2
0
void MainWindow::on_treeView_doubleClicked()
{
    //QMessageBox::information(this, "info"," datasaved")	;

    QModelIndex ixcont = ui.treeView->currentIndex();
    int rowcont = ixcont.row();
    QSqlRecord recordcont = model->record ( rowcont );
    QString idcont = recordcont.value ( "id" ).toString();
    QSqlQuery query ( "SELECT * FROM contacts WHERE id = "+ idcont +"" );
    query.next();
    QString name = query.record().value ( "name" ).toString();
    QString phone = query.record().value ( "phone" ).toString();
    QString mail = query.record().value ( "mail" ).toString();
    QString adress = query.record().value ( "adress" ).toString();
    QString notes = query.record().value ( "notes" ).toString();
    QString id = query.record().value ( "id" ).toString();
    QString idgrload = query.record().value ( "idgroup" ).toString();
    QString title = ( "Contact" );

    AddDialog dlg2 ( title,idgrload,this );

    dlg2.id = id;

    dlg2.lineEdname->setText ( name );
    dlg2.lineEdmail->setText ( mail );
    dlg2.lineEdph->setText ( phone );
    dlg2.textNotes->setText ( notes );
    dlg2.textAdress->setText ( adress );


    if ( dlg2.exec() == QDialog::Accepted ){

        model->setQuery ( "SELECT * FROM contacts WHERE idgroup = "+ dlg2.group +"" );

        ui.treeView->hideColumn ( 3 );
        ui.treeView->hideColumn ( 4 );
        ui.treeView->hideColumn ( 5 );
        ui.treeView->hideColumn ( 6 );


    }
    else
    {

    }

}
Ejemplo n.º 3
0
RMDialogChoice::RMDialogChoice() {
	RMResRaw dlg1(RES_I_DLGTEXT);
	RMResRaw dlg2(RES_I_DLGTEXTLINE);
	RMRes dlgpal(RES_I_DLGTEXTPAL);

	_dlgText.init(dlg1, dlg1.width(), dlg1.height());
	_dlgTextLine.init(dlg2, dlg2.width(), dlg2.height());

	_dlgText.loadPaletteWA(dlgpal);
	_dlgTextLine.loadPaletteWA(dlgpal);

	_hUnreg = CoroScheduler.createEvent(false, false);
	_bRemoveFromOT = false;

	_curAdded = 0;
	_bShow = false;
}
void main()
  {
  MyDialogHandler
    myHandler;
  DialogWindow
   dlg1( IC_DEFAULT_FRAME_ID,
         IWindow::desktopWindow(),
         myHandler,
         "myHandler" );
  DialogWindow
    dlg2( IC_DEFAULT_FRAME_ID,
          IWindow::desktopWindow(),
          myDlgProc,
          "myDlgProc" );
  dlg1.show();
  dlg2.show().setFocus();
  IThread::current().processMsgs();
  }
Ejemplo n.º 5
0
void CurrentPreviewModels::OnRenameButtonClick(wxCommandEvent& event)
{
    wxString sel = CheckListBoxCurrentGroups->GetStringSelection();
    wxTextEntryDialog dlg(this, "Enter new name for group " + sel, "Rename " + sel, sel);
    while (dlg.ShowModal() == wxID_OK) {
        wxString name = dlg.GetValue();

        while (mModels.GetModel(name.ToStdString()) != nullptr) {
            wxTextEntryDialog dlg2(this, "Model or Group of name " + name + " already exists. Enter new name for group", "Enter new name for group");
            if (dlg2.ShowModal() == wxID_OK) {
                name = dlg2.GetValue();
            } else {
                return;
            }
        }

        mModels.Rename(sel.ToStdString(), name.ToStdString());
        PopulateModelGroups();
    }
}
Ejemplo n.º 6
0
int main(int argc, char *argv[]) {
    int w = WIDTH/2, h = HEIGHT/2;
    SDL_Rect window_rect = {(WIDTH - w) / 2, (HEIGHT - h) / 2, w, h};
	Application *app = Application::getInstance();

    char dir[513] = {0x00};
    getcwd(dir, 512);
    LOGD("DIR: %s", dir);
	Window      win2(std::string("uuuuu hello world"), WIDTH , HEIGHT , SDL_WINDOW_SHOWN); 
    Layout dlg2("Hello, world!", window_rect);
	win2.addChild(&dlg2);
	LOGD("create win2 end");	

	std::string title("hello");
	Window      win(title, WIDTH, HEIGHT, SDL_WINDOW_SHOWN); 
	//Window      win(std::string("hello"), WIDTH, HEIGHT); 

    Layout dlg("Hello, world!", window_rect);
    //Label label(renderer, (SDL_Rect){0,0,w,h}, "Hello!");
    Label label((SDL_Rect){0,0, 64,28}, "Hello!");
    dlg.addChild(&label);

    Input input((SDL_Rect){64 + 4, 0, 128,28});
    dlg.addChild(&input);

    Button button((SDL_Rect){w / 2,h / 2,w / 2 ,h / 2}, "OK");
    dlg.addChild(&button);

	win.addChild(&dlg);

    LOGD("app addChild 1");
    app->addChild(&win);
    LOGD("app addChild 2");
    //app->addChild(&win2);
    LOGD("app run");
    //sleep(1000 * 30);
	app->run();
    return 0;
}
Ejemplo n.º 7
0
KNDdeTorusCollocation::KNDdeTorusCollocation(KNExprSystem& sys_, size_t ndeg1_, size_t ndeg2_, size_t nint1_, size_t nint2_) :
    sys(&sys_),
    ndim(sys_.ndim()), ntau(sys_.ntau()), npar(sys_.npar()),
    ndeg1(ndeg1_), ndeg2(ndeg2_), nint1(nint1_), nint2(nint2_),
    col1(ndeg1_),    col2(ndeg2_),
    mesh1(ndeg1_ + 1), mesh2(ndeg2_ + 1),
    lgr1(ndeg1_ + 1, ndeg1_ + 1), lgr2(ndeg2_ + 1, ndeg2_ + 1),
    dlg1(ndeg1_ + 1, ndeg1_ + 1), dlg2(ndeg2_ + 1, ndeg2_ + 1),
    I1((ndeg1_ + 1), (ndeg1_ + 1)),
    ID1((ndeg1_ + 1), (ndeg1_ + 1)),
    I2((ndeg2_ + 1), (ndeg2_ + 1)),
    ID2((ndeg2_ + 1), (ndeg2_ + 1)),
    mlg1((ndeg1_ + 1)*(ndeg1_ + 1)),
    mlg2((ndeg2_ + 1)*(ndeg2_ + 1)),
    mlgd1((ndeg1_ + 1)*(ndeg1_ + 1)),
    mlgd2((ndeg2_ + 1)*(ndeg2_ + 1)),
    ilg1((ndeg1_ + 1)*(ndeg1_ + 1) + 1),
    ilg2((ndeg2_ + 1)*(ndeg2_ + 1) + 1),
    ilgd1((ndeg1_ + 1)*(ndeg1_ + 1) + 1),
    ilgd2((ndeg2_ + 1)*(ndeg2_ + 1) + 1),
    time1(ndeg1*ndeg2*nint1*nint2), time2(ndeg1*ndeg2*nint1*nint2),
    kk((ntau+1)*(ndeg1+1)*(ndeg2+1), ndeg1*ndeg2*nint1*nint2),
    ee((ntau+1)*(ndeg1+1)*(ndeg2+1), ndeg1*ndeg2*nint1*nint2),
    rr((ntau+1)*(ndeg1+1)*(ndeg2+1), ndeg1*ndeg2*nint1*nint2),
    p_tau(ntau, ndeg1*ndeg2*nint1*nint2), p_dtau(ntau, ndeg1*ndeg2*nint1*nint2),
    p_xx(ndim, ntau+2*(ntau+1), ndeg1*ndeg2*nint1*nint2),
    p_fx(ndim, ndeg1*ndeg2*nint1*nint2),
    p_dfp(ndim, 1, ndeg1*ndeg2*nint1*nint2),
    p_dfx(ndim, ndim, ndeg1*ndeg2*nint1*nint2),
    p_dummy(0, 0, ndeg1*ndeg2*nint1*nint2)
{
  lobatto(mesh1);
  lobatto(mesh2);
  gauss(col1);
  gauss(col2);
  for (size_t i = 0; i < mesh1.size(); i++)
  {
    poly_coeff_lgr(lgr1(i), mesh1, i);
    poly_coeff_diff(dlg1(i), lgr1(i));
  }
  for (size_t i = 0; i < mesh2.size(); i++)
  {
    poly_coeff_lgr(lgr2(i), mesh2, i);
    poly_coeff_diff(dlg2(i), lgr2(i));
  }

  // here comes the phase condition for par(OMEGA0) and par(OMEGA1)
  // the integration in the bottom border
  // construct the diffint matrix
  for (size_t i = 0; i < ndeg1 + 1; i++)
  {
    for (size_t k = 0; k < ndeg1 + 1; k++)
    {
      mlg1.clear();
      mlgd1.clear();
      ilg1.clear();
      ilgd1.clear();
      poly_coeff_mul(mlg1,  lgr1(i), lgr1(k));
      poly_coeff_mul(mlgd1, dlg1(i), lgr1(k));
      poly_coeff_int(ilg1,  mlg1);
      poly_coeff_int(ilgd1,  mlgd1);
      I1(i, k) = (poly_eval(ilg1, 1.0)-poly_eval(ilg1, 0.0)) / nint1;
      ID1(i, k) = poly_eval(ilgd1, 1.0);
    }
  }
  for (size_t j = 0; j < ndeg2 + 1; j++)
  {
    for (size_t l = 0; l < ndeg2 + 1; l++)
    {
      mlg2.clear();
      mlgd2.clear();
      ilg2.clear();
      ilgd2.clear();
      poly_coeff_mul(mlg2,  lgr2(j), lgr2(l));
      poly_coeff_mul(mlgd2, dlg2(j), lgr2(l));
      poly_coeff_int(ilg2,  mlg2);
      poly_coeff_int(ilgd2,  mlgd2);
      I2(j, l) = (poly_eval(ilg2, 1.0) - poly_eval(ilg2, 0.0))/ nint2;
      ID2(j, l) = poly_eval(ilgd2, 1.0);
    }
  }
}
Ejemplo n.º 8
0
bool CAsyncRequestQueue::ProcessFileExistsNotification(t_queueEntry &entry)
{
	auto & notification = static_cast<CFileExistsNotification&>(*entry.pNotification.get());

	// Get the action, go up the hierarchy till one is found
	enum CFileExistsNotification::OverwriteAction action = notification.overwriteAction;
	if (action == CFileExistsNotification::unknown)
		action = CDefaultFileExistsDlg::GetDefault(notification.download);
	if (action == CFileExistsNotification::unknown) {
		int option = COptions::Get()->GetOptionVal(notification.download ? OPTION_FILEEXISTS_DOWNLOAD : OPTION_FILEEXISTS_UPLOAD);
		if (option <= CFileExistsNotification::unknown || option >= CFileExistsNotification::ACTION_COUNT)
			action = CFileExistsNotification::ask;
		else
			action = (enum CFileExistsNotification::OverwriteAction)option;
	}

	if (action == CFileExistsNotification::ask) {
		if (!CheckWindowState())
			return false;

		CFileExistsDlg dlg(&notification);
		dlg.Create(m_pMainFrame);
		int res = dlg.ShowModal();

		if (res == wxID_OK) {
			action = dlg.GetAction();

			bool directionOnly, queueOnly;
			if (dlg.Always(directionOnly, queueOnly)) {
				if (!queueOnly) {
					if (notification.download || !directionOnly)
						CDefaultFileExistsDlg::SetDefault(true, action);

					if (!notification.download || !directionOnly)
						CDefaultFileExistsDlg::SetDefault(false, action);
				}
				else {
					// For the notifications already in the request queue, we have to set the queue action directly
					for (auto iter = ++m_requestList.begin(); iter != m_requestList.end(); ++iter) {
						if (!iter->pNotification || iter->pNotification->GetRequestID() != reqId_fileexists)
							continue;
						auto & p = static_cast<CFileExistsNotification&>(*iter->pNotification.get());

						if (!directionOnly || notification.download == p.download)
							p.overwriteAction = CFileExistsNotification::OverwriteAction(action);
					}

					TransferDirection direction;
					if (directionOnly) {
						if (notification.download)
							direction = TransferDirection::download;
						else
							direction = TransferDirection::upload;
					}
					else
						direction = TransferDirection::both;

					if (m_pQueueView)
						m_pQueueView->SetDefaultFileExistsAction(action, direction);
				}
			}
		}
		else
			action = CFileExistsNotification::skip;
	}

	if (action == CFileExistsNotification::unknown || action == CFileExistsNotification::ask)
		action = CFileExistsNotification::skip;

	if (action == CFileExistsNotification::resume && notification.ascii) {
		// Check if resuming ascii files is allowed
		if (!COptions::Get()->GetOptionVal(OPTION_ASCIIRESUME))
			// Overwrite instead
			action = CFileExistsNotification::overwrite;
	}

	switch (action)
	{
		case CFileExistsNotification::rename:
		{
			if (!CheckWindowState())
				return false;

			wxString msg;
			wxString defaultName;
			if (notification.download) {
				msg.Printf(_("The file %s already exists.\nPlease enter a new name:"), notification.localFile);
				wxFileName fn = notification.localFile;
				defaultName = fn.GetFullName();
			}
			else {
				wxString fullName = notification.remotePath.GetPath() + notification.remoteFile;
				msg.Printf(_("The file %s already exists.\nPlease enter a new name:"), fullName);
				defaultName = notification.remoteFile;
			}
			wxTextEntryDialog dlg(m_pMainFrame, msg, _("Rename file"), defaultName);

			// Repeat until user cancels or enters a new name
			for (;;) {
				int res = dlg.ShowModal();
				if (res == wxID_OK) {
					if (dlg.GetValue().empty())
						continue; // Disallow empty names
					if (dlg.GetValue() == defaultName) {
						wxMessageDialog dlg2(m_pMainFrame, _("You did not enter a new name for the file. Overwrite the file instead?"), _("Filename unchanged"),
							wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION | wxCANCEL);
						int res = dlg2.ShowModal();

						if (res == wxID_CANCEL)
							notification.overwriteAction = CFileExistsNotification::skip;
						else if (res == wxID_NO)
							continue;
						else
							notification.overwriteAction = CFileExistsNotification::skip;
					}
					else {
						notification.overwriteAction = CFileExistsNotification::rename;
						notification.newName = dlg.GetValue();

						// If request got processed successfully, notify queue about filename change
						if (entry.pEngine->SetAsyncRequestReply(std::move(entry.pNotification)) && m_pQueueView)
							m_pQueueView->RenameFileInTransfer(entry.pEngine, dlg.GetValue(), notification.download);
						return true;
					}
				}
				else
					notification.overwriteAction = CFileExistsNotification::skip;
				break;
			}
		}
		break;
		default:
			notification.overwriteAction = action;
			break;
	}

	entry.pEngine->SetAsyncRequestReply(std::move(entry.pNotification));
	return true;
}
Ejemplo n.º 9
0
void CAsyncRequestQueue::ProcessNextRequest()
{
	if (m_requestList.empty())
		return;

	t_queueEntry &entry = m_requestList.front();

	if (!entry.pEngine->IsPendingAsyncRequestReply(entry.pNotification))
	{
		delete entry.pNotification;
		m_requestList.pop_front();
		return;
	}
		
	if (entry.pNotification->GetRequestID() == reqId_fileexists)
	{
		CFileExistsNotification *pNotification = reinterpret_cast<CFileExistsNotification *>(entry.pNotification);

		// Get the action, go up the hierarchy till one is found
		int action = pNotification->overwriteAction;
		if (action == -1)
			action = CDefaultFileExistsDlg::GetDefault(pNotification->download);
		if (action == -1)
			action = COptions::Get()->GetOptionVal(pNotification->download ? OPTION_FILEEXISTS_DOWNLOAD : OPTION_FILEEXISTS_UPLOAD);

		if (!action)
		{
			CFileExistsDlg dlg(pNotification);
			dlg.Create(m_pMainFrame);
			int res = dlg.ShowModal();

			if (res == wxID_OK)
			{
				action = dlg.GetAction() + 1;

				bool directionOnly, queueOnly;
				if (dlg.Always(directionOnly, queueOnly))
				{
					if (!queueOnly)
					{
						if (pNotification->download || !directionOnly)
							CDefaultFileExistsDlg::SetDefault(true, action);

						if (!pNotification->download || !directionOnly)
							CDefaultFileExistsDlg::SetDefault(false, action);
					}
					else
					{
						// For the notifications already in the request queue, we have to set the queue action directly
						for (std::list<t_queueEntry>::iterator iter = ++m_requestList.begin(); iter != m_requestList.end(); iter++)
						{
							if (pNotification->GetRequestID() != reqId_fileexists)
								continue;

							CFileExistsNotification* p = reinterpret_cast<CFileExistsNotification *>(iter->pNotification);

							if (!directionOnly || pNotification->download == p->download)
								p->overwriteAction = CFileExistsNotification::OverwriteAction(action);
						}

						enum TransferDirection direction;
						if (directionOnly)
						{
							if (pNotification->download)
								direction = download;
							else
								direction = upload;
						}
						else
							direction = both;

						if (m_pQueueView)
							m_pQueueView->SetDefaultFileExistsAction(action, direction);
					}
				}
			}
			else
				action = 5;
		}

		if (action < 1 || action > 5)
			action = 5;

		if (action == 3 && pNotification->ascii)
		{
			// Check if resuming ascii files is allowed
			if (!COptions::Get()->GetOptionVal(OPTION_ASCIIRESUME))
				// Overwrite instead
				action = 1;
		}

		switch (action)
		{
		case 4:
			{
				wxString msg;
				wxString defaultName;
				if (pNotification->download)
				{
					msg.Printf(_("The file %s already exists.\nPlease enter a new name:"), pNotification->localFile.c_str());
					wxFileName fn = pNotification->localFile;
					defaultName = fn.GetFullName();
				}
				else
				{
					wxString fullName = pNotification->remotePath.GetPath() + pNotification->remoteFile;
					msg.Printf(_("The file %s already exists.\nPlease enter a new name:"), fullName.c_str());
					defaultName = pNotification->remoteFile;
				}
				wxTextEntryDialog dlg(m_pMainFrame, msg, _("Rename file"), defaultName);

				// Repeat until user cancels or enters a new name
				while (1)
				{
					int res = dlg.ShowModal();
					if (res == wxID_OK)
					{
						if (dlg.GetValue() == _T(""))
							continue; // Disallow empty names
						if (dlg.GetValue() == defaultName)
						{
							wxMessageDialog dlg2(m_pMainFrame, _("You did not enter a new name for the file. Overwrite the file instead?"), _("Filename unchanged"), 
								wxYES_NO | wxNO_DEFAULT | wxICON_QUESTION | wxCANCEL);
							int res = dlg2.ShowModal();

							if (res == wxID_CANCEL)
								pNotification->overwriteAction = CFileExistsNotification::skip;
							else if (res == wxID_NO)
								continue;
							else
								pNotification->overwriteAction = CFileExistsNotification::skip;
						}
						else
						{
							pNotification->overwriteAction = CFileExistsNotification::rename;
							pNotification->newName = dlg.GetValue();
						}
					}
					else
						pNotification->overwriteAction = CFileExistsNotification::skip;
					break;
				}
			}
			break;
		default:
			pNotification->overwriteAction = (enum CFileExistsNotification::OverwriteAction)action;
			break;
		}

		entry.pEngine->SetAsyncRequestReply(entry.pNotification);
		delete pNotification;
	}
	else if (entry.pNotification->GetRequestID() == reqId_interactiveLogin)
	{
		CInteractiveLoginNotification* pNotification = reinterpret_cast<CInteractiveLoginNotification*>(entry.pNotification);

		if (CLoginManager::Get().GetPassword(pNotification->server, false, _T(""), pNotification->GetChallenge()))
			pNotification->passwordSet = true;

		entry.pEngine->SetAsyncRequestReply(pNotification);
		delete pNotification;
	}
	else if (entry.pNotification->GetRequestID() == reqId_hostkey || entry.pNotification->GetRequestID() == reqId_hostkeyChanged)
	{
		CHostKeyNotification *pNotification = reinterpret_cast<CHostKeyNotification *>(entry.pNotification);

		wxDialogEx* pDlg = new wxDialogEx;
		if (pNotification->GetRequestID() == reqId_hostkey)
			pDlg->Load(m_pMainFrame, _T("ID_HOSTKEY"));
		else
			pDlg->Load(m_pMainFrame, _T("ID_HOSTKEYCHANGED"));

		pDlg->WrapText(pDlg, XRCID("ID_DESC"), 400);

		pDlg->SetLabel(XRCID("ID_HOST"), wxString::Format(_T("%s:%d"), pNotification->GetHost().c_str(), pNotification->GetPort()));
		pDlg->SetLabel(XRCID("ID_FINGERPRINT"), pNotification->GetFingerprint());

		pDlg->GetSizer()->Fit(pDlg);
		pDlg->GetSizer()->SetSizeHints(pDlg);

		int res = pDlg->ShowModal();

		if (res == wxID_OK)
		{
			pNotification->m_trust = true;
			pNotification->m_alwaysTrust = XRCCTRL(*pDlg, "ID_ALWAYS", wxCheckBox)->GetValue();
		}

		entry.pEngine->SetAsyncRequestReply(pNotification);
		delete pNotification;
	}
	else if (entry.pNotification->GetRequestID() == reqId_certificate)
	{
		CCertificateNotification* pNotification = reinterpret_cast<CCertificateNotification *>(entry.pNotification);

		m_pVerifyCertDlg->ShowVerificationDialog(pNotification);

		entry.pEngine->SetAsyncRequestReply(entry.pNotification);
		delete entry.pNotification;
	}
	else
	{
		entry.pEngine->SetAsyncRequestReply(entry.pNotification);
		delete entry.pNotification;
	}

	RecheckDefaults();
	m_requestList.pop_front();
}
Ejemplo n.º 10
0
//任务列表
void CTaoFlowDlg::OnDblclkListTasklist(NMHDR *pNMHDR, LRESULT *pResult)
{
	LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
	// TODO: 在此添加控件通知处理程序代码
	NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
	if (pNMListView->iItem < 0)
	{
		return;
	}
	TTaskAttribute &task = tasks.at(pNMListView->iItem);
	int nRet;
	CDlgTaoFlowSettings dlg(task);
	CDlgOptimizeKeyWord dlg1(task);
	CDlgTaoAlexaSetting dlg2(task);
	CDlgTaoQSpaceSettings dlg3(task);
	switch (task.eType)
	{
	default:
		nRet = dlg.DoModal();
		break;
	case Alexa:
		nRet = dlg2.DoModal();
		break;
	case KeyWord:
		nRet = dlg1.DoModal();
		break;
	case QSpace:
		nRet = dlg3.DoModal();
		break;
	}
	if (IDOK == nRet)
	{
		CString str, str1;
		CString strPathName = _T(".\\wkdata");
		int nTaskCount = 0;
		unsigned int i = 0;
		switch (task.eAction)
		{
		default:
			break;
		case StartTask:
			m_ListTask.SetItemText(pNMListView->iItem, 2, _T("运行中"));
			CloseProgram(_T("wk.exe"));
			str1.Format(_T("%d"), 1);
			str.Format(_T("%s%d"), _T("Task"), pNMListView->iItem + 1);
			WritePrivateProfileString(str, _T("stat"), str1, strPathName);
			WinExec(".\\wk.exe",SW_HIDE);
			break;
		case StopTask:
			m_ListTask.SetItemText(pNMListView->iItem, 2, _T("已停止"));
			CloseProgram(_T("wk.exe"));
			str1.Format(_T("%d"), 0);
			str.Format(_T("%s%d"), _T("Task"), pNMListView->iItem + 1);
			WritePrivateProfileString(str, _T("stat"), str1, strPathName);
			WinExec(".\\wk.exe",SW_HIDE);
			break;
		case DelTask:
			tasks.erase(tasks.begin() + pNMListView->iItem);			
			CloseProgram(_T("wk.exe"));
			nTaskCount = GetPrivateProfileInt(_T("TaskCount"), _T("Value"), 0, strPathName);
			str.Format(_T("%d"), nTaskCount - 1);
			WritePrivateProfileString(_T("TaskCount"), _T("Value"), str, strPathName);
			DelAllTaskDataF();
			for (size_t i = 1; i <= tasks.size(); ++i)
			{
				SetFlowDataF(i);
			}
			m_ListTask.DeleteItem(pNMListView->iItem);
			WinExec(".\\wk.exe",SW_HIDE);
			break;
		case ModTask:
			CloseProgram(_T("wk.exe"));
			switch (task.eType)
			{
			default:
				m_ListTask.SetItemText(pNMListView->iItem, 1, task.strNetAddr);
				str.Format(_T("%s%d"), _T("Task"), pNMListView->iItem + 1);
				str += _T("Source");
				WritePrivateProfileString(str, NULL, NULL, strPathName);
				str.Format(_T("%s%d"), _T("Task"), pNMListView->iItem + 1);
				str += _T("Click");
				WritePrivateProfileString(str, NULL, NULL, strPathName);
				SetFlowDataF(pNMListView->iItem + 1);
				break;
			case KeyWord:
				m_ListTask.SetItemText(pNMListView->iItem, 1, task.strNetAddr);
				SetKeyWordDataF(pNMListView->iItem + 1);
				break;
			case Alexa:
				m_ListTask.SetItemText(pNMListView->iItem, 1, task.strNetAddr);
				SetAlexaDataF(pNMListView->iItem + 1);
				break;
			case QSpace:
				CString str = _T("user.qzone.qq.com/");
				str += task.strQNumber;
				m_ListTask.SetItemText(pNMListView->iItem, 1, str);
				SetQSpaceDataF(pNMListView->iItem + 1);
				break;
			}		
			WinExec(".\\wk.exe",SW_HIDE);
			break;
		}
	}
	
	*pResult = 0;
}
Ejemplo n.º 11
0
void CTLiteDoc::OnToolsExporttoHistDatabase()
{
	CWaitCursor wc;

	CFileDialog dlg(TRUE, 0, 0, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		_T("Single-day file (*.csv)|*.csv|"));
	if(dlg.DoModal() == IDOK)
	{
		bool bFormatFlag = true;
		FILE* st = NULL;
		fopen_s(&st,dlg.GetPathName(),"w");
		if(st!=NULL)
			{
			fprintf(st,"parameter arcs(i,j,t_e,t_l) link travel time /\n");
			std::list<DTALink*>::iterator iLink;

			for (iLink = m_LinkSet.begin(); iLink != m_LinkSet.end(); iLink++)
			{

				int day = 0;

						int beg_time_index = 0;
						int end_time_index =  16;
				   
						for(int t= beg_time_index+1; t< end_time_index; t++)
					{

							fprintf(st,"%d. %d. ", (*iLink)->m_FromNodeNumber, (*iLink)->m_ToNodeNumber );
							float travel_time = int((*iLink)->m_Length /300*60/15+0.5);

							int time_index_from = t- beg_time_index;
							int time_index_to = t+ travel_time - beg_time_index;
							fprintf(st,"%d. %d %4.1f\n", time_index_from,time_index_to,travel_time);

					}

				
				}

				fprintf(st,"/;\n");

//	capacity

				fprintf(st,"parameter TDcapacity(i,j,t_e) capacity /\n");

			for (iLink = m_LinkSet.begin(); iLink != m_LinkSet.end(); iLink++)
			{

				int beg_time_index = 0;
				int end_time_index =  20;
				   
				for(int t= beg_time_index+1; t< end_time_index; t++)
					{
							fprintf(st,"%d. %d. %d  6\n", (*iLink)->m_FromNodeNumber, (*iLink)->m_ToNodeNumber,t );

					}

				
			}

		fprintf(st,"/;\n");

		
		fclose(st);

	}
	}



	CFileDialog dlg2(TRUE, 0, 0, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		_T("Multi-day file (*.csv)|*.csv|"));
	if(dlg2.DoModal() == IDOK)
	{
		bool bFormatFlag = true;
		FILE* st = NULL;
		fopen_s(&st,dlg2.GetPathName(),"w");
			fprintf(st,"parameter arcs(i,j,sc,t_e,t_l) link travel time /\n");
			std::list<DTALink*>::iterator iLink;

			for (iLink = m_LinkSet.begin(); iLink != m_LinkSet.end(); iLink++)
			{

				for( int day = 1; day <= 10; day ++)
				{

						int beg_time_index = 0;
						int end_time_index =  100;
				   
						for(int t= beg_time_index+1; t< end_time_index; t++)
					{

							fprintf(st,"%d. %d. %d.", (*iLink)->m_FromNodeNumber, (*iLink)->m_ToNodeNumber, day );
							float travel_time = (*iLink)->m_FreeFlowTravelTime * (1 + g_GetRandomRatio());

							int time_index_from = t- beg_time_index;
							int time_index_to = t+ travel_time - beg_time_index;
							fprintf(st,"%d. %d %4.1f\n", time_index_from,time_index_to,travel_time);

					}


				}
				
				}

				fprintf(st,"/;");
		fclose(st);

	}

}