Esempio n. 1
0
void Project::RenameXport(INXPOSITION iconPos, DEP* pDEP, INXString &csNewPortLabel) 
{
	INXString csProjectDir, csOldPortLabel;
	ConData* icon;

	pProjMData->getProjectDir(csProjectDir);
	icon = (ConData*) pDEP->condata->GetAt(iconPos);
	if (icon->m_csIconType.Find("XINPUT") == -1 && icon->m_csIconType.Find("XOUTPUT") == -1 && 
		icon->m_csIconType != "XSTART" && icon->m_csIconType != "XFINISH") {
		AfxMessageBox("Can only rename Xports.");
		return;
	}

	csOldPortLabel = icon->description;
	csNewPortLabel = icon->description;
	// Prompt user for new port name
	CBlockPortLabelDialog dialog(csOldPortLabel, icon, pDEP);
	if (dialog.DoModal() == IDOK) {
		csNewPortLabel = dialog.GetPortLabel();
		csNewPortLabel.MakeLower();
	}

	// Rename Xport
	icon->description = csNewPortLabel;
}
Esempio n. 2
0
void Encapsulate::OnOK() 
{
	bool errorFlag = FALSE;
	INXString strText = "";
	UINT i;
	
	// update attributes such as m_BlockName
	UpdateData(TRUE);
	//get the text from the textboxes
	for (i=1; i<=inNum; i++) {
		strText = "";
		int len = inEdit[i]->LineLength(inEdit[i]->LineIndex(0));
		if (len) {
			inEdit[i]->GetLine(0, strText.GetBuffer(len), len);
			strText.ReleaseBuffer(len);
		}
		INXString x(strText.MakeLower());
		inNames[i] = strText.MakeLower();
	}
	for (i=1; i<=outNum; i++) {
		strText = "";
		int len = outEdit[i]->LineLength(outEdit[i]->LineIndex(0));
		if (len) {
			outEdit[i]->GetLine(0, strText.GetBuffer(len), len);
			strText.ReleaseBuffer(len);
		}
		outNames[i] = (INXString)strText.MakeLower();
	}
	for (i=1; i<=startNum; i++) {
		strText = "";
		int len = startEdit[i]->LineLength(startEdit[i]->LineIndex(0));
		if (len) {
			startEdit[i]->GetLine(0, strText.GetBuffer(len), len);
			strText.ReleaseBuffer(len);
		}
		startNames[i] = strText.MakeLower();
	}
	for (i=1; i<=finishNum; i++) {
		strText = "";
		int len = finishEdit[i]->LineLength(finishEdit[i]->LineIndex(0));
		if (len) {
			finishEdit[i]->GetLine(0, strText.GetBuffer(len), len);
			strText.ReleaseBuffer(len);
		}
		finishNames[i] = strText.MakeLower();
	}

	// Check port names are not empty strings and are unique
	for (i=1; i<=inNum; i++) {
		// check port names
		if (inNames[i] == "") {
			AfxMessageBox("WARNING: Enter a port name for " + inLabels[i]);
			errorFlag = TRUE;
		}
		for (UINT j=1; j<=inNum; j++) {
			if (i!=j && inNames[i] == inNames[j]) {
				AfxMessageBox("WARNING: " + inLabels[i] + " is not unique.");
				errorFlag = TRUE;
			}
		}
	}
			
	if (!errorFlag) {
		for (i=1; i<=outNum; i++) {
			// check port names
			if (outNames[i] == "") {
				AfxMessageBox("WARNING: Enter a port name for " + outLabels[i]);
				errorFlag = TRUE;
			}
			for (UINT j=1; j<=outNum; j++) {
				if (i!=j && outNames[i] == outNames[j]) {
					AfxMessageBox("WARNING: " + outLabels[i] + " is not unique.");
					errorFlag = TRUE;					
				}
			}
		}
	}
			
	if (!errorFlag) {
		for (i=1; i<=startNum; i++) {
			// check port names
			if (startNames[i] == "") {
				AfxMessageBox("WARNING: Enter a port name for " + startLabels[i]);					
				errorFlag = TRUE;
			}
			for (UINT j=1; j<=startNum; j++) {
				if (i!=j && startNames[i] == startNames[j]) {
					AfxMessageBox("WARNING: " + startLabels[i] + " is not unique.");
					errorFlag = TRUE;
				}
			}
		}
	}
			
	if (!errorFlag) {
		for (i=1; i<=finishNum; i++) {
			// check port names
			if (finishNames[i] == "") {
				AfxMessageBox("WARNING: Enter a port name for " + finishLabels[i]);
				errorFlag = TRUE;
			}
			for (UINT j=1; j<=finishNum; j++) {
				if (i!=j && finishNames[i] == finishNames[j]) {
					AfxMessageBox("WARNING: " + finishLabels[i] + " is not unique.");
					errorFlag = TRUE;
				}
			}
		}
	}

	
	if (!errorFlag) {
		CDialog::OnOK();
	}
}