Пример #1
0
//--------------------------------------------------------------------------------
void ArrangeWindowsInWindow (CWnd * pParentWnd, CObArray & arrWnd, DWORD dwOrient)
// Arranges the windows within the rectangle of another window.
//--------------------------------------------------------------------------------
{
	if (arrWnd.GetSize() == 0)			// no windows to size.. do nothing
		return;

	CRect ClientRect;
	pParentWnd->GetClientRect(&ClientRect);
	
	CSize ParentSize = ClientRect.Size();
	if (ParentSize.cy == 0)
		return;							// no height => not much we can do	
	
	CObList SpcList;					// list used to keep track of window spacing
	
	// add initial Arrange rectangle to the list;	
	CWndSpaceElt * pSpcElt = new CWndSpaceElt;
	pSpcElt->wd = 0;
	pSpcElt->ht = ClientRect.Height();
	SpcList.AddTail(pSpcElt); 


	// sort array of window positions by size so that we position the largest windows first.
	// this improves the results quite a bit
	CObject ** pArrData = arrWnd.GetData();
	ASSERT(pArrData != NULL);		// shouldn't be NULL as array is non-empty, but check anyway	
	qsort(pArrData, arrWnd.GetSize(), sizeof(CObject *), CompareWndRect); 	
	
	
	HDWP hDWP = BeginDeferWindowPos(arrWnd.GetSize());	   // defer window moves to save on refresh

	// iterate thru all the windows in the list looking for a position to put it
	for (int nWndNo = 0; nWndNo < arrWnd.GetSize(); nWndNo++)
	{
		CWnd * pWnd = (CWnd *)arrWnd[nWndNo];
		ASSERT(pWnd != NULL);
		ASSERT_VALID(pWnd);
		PositionInSpcList(pWnd, SpcList, dwOrient, pParentWnd, ParentSize, hDWP);
	} 

	if (hDWP != NULL)
		::EndDeferWindowPos(hDWP);		// move the windows

	// Remove elements from the SpcList;
	while (!SpcList.IsEmpty())
	{
		CWndSpaceElt * pElt = (CWndSpaceElt *) SpcList.GetTail();
		delete pElt;
		SpcList.RemoveTail();
	}
}
Пример #2
0
void CObBinTree::GetArray( CObArray& array )
{
	array.SetSize( 0 );
	WalkTree( StoreInArray, (LPVOID)&array, TV_INORDER );

	ASSERT( array.GetSize()==GetCount() );
}
// 算法2.4:链条扩展算法
void CFaceIdentification::ExtendLoopByPriority()
{
	CObArray extdLoopArr;
	m_pFLPool->GetExtendLoopsByPriority(extdLoopArr);
	
	if (extdLoopArr.GetSize() == 0) {
		// Do partition
		CFaceClipping::BodyPartition(&(m_pFLPool->m_faceLoopArray), m_pAsmbBody);
		CFaceClipping::BodyRestCopy(&(m_pFLPool->m_loopArray), m_pAsmbBody);

		return;
	}

	// 搜索得到所有扩展对的类型:Merg1,Thrd2和Math3
	CP_ParaLoopsGroupsArr * plgArr = m_pFLPool->GetExtendLoopPair(extdLoopArr);
	extdLoopArr.RemoveAll();
	if(plgArr == NULL) 
		return TopologyDeduce();
	

	CP_ParallelLoopsGroup * bestParaGroup = *(std::max_element(plgArr->begin(), plgArr->end(), CP_ParallelLoopsGroup::CompareTo));
	m_pFLPool->ConnectLoop((CP_LoopExt *&)bestParaGroup->loopExtd,
		(CP_LoopExt *&)bestParaGroup->loopNext, (CP_LoopExt *&)bestParaGroup->loopRest, m_pAsmbBody);
	DeleteParaLoopsGroupsArr(plgArr);

	TopologyDeduce();

}
// 合并之后重新计算loop的邻接优先级
void CP_LoopExt::CalcLoopAdjFaceNum()
{
	CObArray tmpAdjLoopArr;

	int halfSize = GetHalfNumber();
	for(int i = 0; i < halfSize; i++)
	{
		CP_LoopExt * adjLoop = (CP_LoopExt *)GetHalf(i)->m_pTwin->m_pLoop;
		if(adjLoop->m_adjFaceNum != -1) continue;
		int j;
		for (j = 0; j < tmpAdjLoopArr.GetSize(); ++j) {
			if (tmpAdjLoopArr[j] == adjLoop)
				break;
		}
		if (j == tmpAdjLoopArr.GetSize()) tmpAdjLoopArr.Add(adjLoop);
	}
	m_adjFaceNum = tmpAdjLoopArr.GetSize();
	tmpAdjLoopArr.RemoveAll();
}
Пример #5
0
/**
* SyncServerConnections
*
*/
void CFtpManager::SyncServerConnections()
{
	CConnectionManager connectionManager;
	connectionManager.Load();
	CObArray * listOfConnections;
	listOfConnections = connectionManager.GetConnections();
	int i = 0;
	for(i = 0; i <  listOfConnections->GetSize(); i++){
		CConnection * con = (CConnection *)listOfConnections->GetAt(i);
		if(con->host.GetLength() > 0)
		{
			SyncServerConnection(con);
		}
	}
}
Пример #6
0
LRESULT CSessionWnd::OnExecuteComplete(WPARAM wParam, LPARAM lParam)
{
	WFSRESULT *pResult = (WFSRESULT *)lParam;
	// finding serviceBasic
	CServiceBasic *pServiceBasic = 0;
	for(long i=0; i<g_arrayService.GetSize(); i++)
	{
		pServiceBasic = (CServiceBasic *)g_arrayService.GetAt(i);
		if(pServiceBasic->m_nRequestedID == pResult->RequestID)
		{
			pServiceBasic->m_hResult = pResult->hResult;
			*pServiceBasic->m_lppResult = pResult;
			break;
		}
		pServiceBasic = 0;
	}
	if(pServiceBasic) pServiceBasic->m_nRequestedID = 0;
	if(pServiceBasic) pServiceBasic->m_eventExecute.SetEvent();
	return 0;
}
Пример #7
0
         CObArray arr;
         CAge* pa1;
         CAge* pa2;

         arr.Add(pa1 = new CAge(21)); // Element 0
         arr.Add(pa2 = new CAge(40)); // Element 1
         ASSERT(arr.GetSize() == 2);
         arr.RemoveAll(); // Pointers removed but objects not deleted.
         ASSERT(arr.GetSize() == 0);
         delete pa1;
         delete pa2;  // Cleans up memory.      
Пример #8
0
void CHTMLFont::DeleteArray(CObArray & arrArray)
{
    for ( int nObj=0; nObj < arrArray.GetSize(); nObj++)
        delete (CHTMLFont *) arrArray[nObj];
    arrArray.RemoveAll();
}
Пример #9
0
/**
* OnCreate
*
* Description: App crete event. Initalize threads and objects.
*/
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWndEx::OnCreate(lpCreateStruct) == -1)
		return -1;

	HICON icon=LoadIcon(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_MAINFRAME));
	SetIcon(icon, FALSE);

	BOOL bNameValid;
	// set the visual manager and style based on persisted value
	//OnApplicationLook(theApp.m_nAppLook);
	CMFCVisualManager::SetDefaultManager(RUNTIME_CLASS(CMyVisualManager)); // CMyVisualManager CMFCVisualManagerVS2008
	CDockingManager::SetDockingMode(DT_SMART);
	if (!m_wndMenuBar.Create(this))
	{
		TRACE0("Failed to create menubar\n");
		return -1;      // fail to create
	}
	m_wndMenuBar.SetPaneStyle(m_wndMenuBar.GetPaneStyle() | CBRS_SIZE_DYNAMIC | CBRS_TOOLTIPS | CBRS_FLYBY);

	// prevent the menu bar from taking the focus on activation
	CMFCPopupMenu::SetForceMenuFocus(FALSE);

	// Replaced with split view
	// create a view to occupy the client area of the frame 
	/*
	if (!m_wndView.Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, CRect(0, 0, 10, 10), this, AFX_IDW_PANE_FIRST, NULL))
	{
		TRACE0("Failed to create view window\n");
		return -1;
	}
	*/

	
	/*
	//theApp.m_bHiColorIcons = 0;
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) 
			||
		!m_wndToolBar.LoadToolBar( IDR_MAINFRAME )) // theApp.m_bHiColorIcons ? IDR_MAINFRAME_256 : IDR_MAINFRAME
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}
	
	CString strToolBarName;
	bNameValid = strToolBarName.LoadString(IDS_TOOLBAR_STANDARD);
	ASSERT(bNameValid);
	m_wndToolBar.SetWindowText(strToolBarName);

	CString strCustomize;
	bNameValid = strCustomize.LoadString(IDS_TOOLBAR_CUSTOMIZE);
	ASSERT(bNameValid);
	//m_wndToolBar.EnableCustomizeButton(TRUE, ID_VIEW_CUSTOMIZE, strCustomize);

	// Allow user-defined toolbars operations:
	InitUserToolbars(NULL, uiFirstUserToolBarId, uiLastUserToolBarId);
	*/
	
	if (!m_headerDoc.Create(_T("test"), 
							this, 
							CSize(400, 40), 
							false, // gripper
							4,   // nID child win id (kinda works with 0)
							WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_TOP | CBRS_FLOAT_MULTI,  // WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_HIDE_INPLACE
							AFX_CBRS_REGULAR_TABS, 
							AFX_DEFAULT_DOCKING_PANE_STYLE) )
	{
		TRACE0("Failed to create Header Bar \n");
		return -1;      // fail to create
	}
//	m_headerDoc.EnableDocking(CBRS_ALIGN_ANY); 
	//m_headerDoc.SetResizeMode(false);
	m_headerDoc.SetMinSize(CSize(200, 40));
	m_headerDoc.OnInitialUpdate();
	//m_headerDoc.ShowPane(TRUE, FALSE, TRUE);
	m_headerDoc.ShowWindow(SW_SHOW);
	

	// FooterPane
	CRect r = CRect(400, 15, 10, 15);
	m_footerPane.Create(_T("CFooterPane"),  WS_VISIBLE, r, this, 5, AFX_DEFAULT_DOCKING_PANE_STYLE, 0);
	/*
	if (!m_footerPane.Create(_T("footer"), 
							this, 
							CSize(400, 15), 
							false, // gripper
							4,   // nID child win id (kinda works with 0)
							WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_BOTTOM | CBRS_FLOAT_MULTI,  // WS_CHILD|WS_VISIBLE|CBRS_TOP|CBRS_HIDE_INPLACE
							AFX_CBRS_REGULAR_TABS, 
							AFX_DEFAULT_DOCKING_PANE_STYLE) )
	{
		TRACE0("Failed to create Header Bar \n");
		return -1;      // fail to create
	}
	*/
	m_footerPane.SetMinSize(CSize(200, 15));
	m_footerPane.OnInitialUpdate();
	//m_footerPane.ShowWindow(SW_SHOW);


	//CDockBar *pTop = (CDockBar *)::AfxGetMainWnd()->GetControlBar(AFX_IDW_DOCKBAR_TOP);
	
	//DWORD x = m_headerDoc.GetEnabledAlignment();
	//DWORD y = CBRS_ALIGN_ANY;

	
	//m_wndStatusBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_BOTTOM, AFX_IDW_STATUS_BAR);
	//if (!m_wndStatusBar.Create(this))
	//{
	//	TRACE0("Failed to create status bar\n");
	//	return -1;      // fail to create
	//}
	//m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT));
	

	// TODO: Delete these five lines if you don't want the toolbar and menubar to be dockable
	//m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
	//m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);   // required or won't show toolbar
	DockPane(&m_wndMenuBar);
	//DockPane(&m_wndToolBar);
	DockPane(&m_headerDoc);

	// Bottom pane
	//m_footerPane.EnableDocking(CBRS_ALIGN_BOTTOM);
	//DockPane(&m_footerPane, AFX_IDW_DOCKBAR_BOTTOM);

	//m_wndToolBar.ShowPane(SW_SHOW,0,0);
	//m_wndToolBar.SetWi

	// enable Visual Studio 2005 style docking window behavior
	//CDockingManager::SetDockingMode(DT_SMART);
	// enable Visual Studio 2005 style docking window auto-hide behavior
	EnableAutoHidePanes(CBRS_ALIGN_ANY);

	// Enable toolbar and docking window menu replacement
	//EnablePaneMenu(TRUE, ID_VIEW_CUSTOMIZE, strCustomize, ID_VIEW_TOOLBAR);

	// enable quick (Alt+drag) toolbar customization
	//CMFCToolBar::EnableQuickCustomization();

	if (CMFCToolBar::GetUserImages() == NULL)
	{
		// load user-defined toolbar images
		if (m_UserImages.Load(_T(".\\UserImages.bmp")))
		{
			CMFCToolBar::SetUserImages(&m_UserImages);
		}
	}

	// enable menu personalization (most-recently used commands)
	// TODO: define your own basic commands, ensuring that each pulldown menu has at least one basic command.
	CList<UINT, UINT> lstBasicCommands;

	lstBasicCommands.AddTail(ID_APP_EXIT);
	lstBasicCommands.AddTail(ID_EDIT_CUT);
	lstBasicCommands.AddTail(ID_EDIT_PASTE);
	lstBasicCommands.AddTail(ID_EDIT_UNDO);
	lstBasicCommands.AddTail(ID_APP_ABOUT);
	lstBasicCommands.AddTail(ID_VIEW_STATUS_BAR);
	//CMFCToolBar::SetBasicCommands(lstBasicCommands);


	// Display New Connection Dialog if no connections exist
	m_connectionManager.Load();
	CObArray * listOfConnections;
	listOfConnections = m_connectionManager.GetConnections();
	int connectionCount = listOfConnections->GetSize();
	if(connectionCount == 0)
	{
		PostMessage( WM_COMMAND, ID_NEW_CONNECTION_MENU_ITEM, 0 );
	}

	// Start sync thread
	//
	//m_ftpManager.SyncServerConnections();
	THREADPARAM * _param = new THREADPARAM;
	_param->m = this;
	// THREAD_PRIORITY_IDLE   THREAD_PRIORITY_LOWEST
	m_pFtpSyncThread = AfxBeginThread(CMainFrame::FtpSyncWorker, &_param, THREAD_PRIORITY_LOWEST); //, THREAD_PRIORITY_NORMAL, 0, CREATE_SUSPENDED);
	if (m_pFtpSyncThread != NULL)
	{
		//TRACE(_T("AfxBeginThread: 0x%08lX\n"), m_pFtpSyncThread->m_nThreadID);
	}


	// Start Ad manager
	//m_wndMenuBar.m_ad = m_ad;
	//m_ad.Start();
	

	// Create tray icon.
	LoadTrayIcon();

	// Check for an update
	CUpgrade update;
	update.CheckForUpgrade();

	// Hostory
	m_historyDlg = new CHistoryDialog(this);
	m_historyDlg->Create(CHistoryDialog::IDD, GetDesktopWindow());
	
	// Registry - GUID
	//CRegistry reg;
	//bool p = reg.IsPurchased();
	//reg.Purchase();
	//p = reg.IsPurchased();
	//CString guid(_T(""));
	//reg.GetGUID(guid);

	return 0;
}
Пример #10
0
/**
* OnLoadUrl
*
* Description: Load a url into the view
*
* Parameters:	wparam: - 0 = no callback, 1 = yes callback
*				lparam: CString url path
*/
LRESULT CMainFrame::OnLoadUrl(WPARAM wParam, LPARAM lParam)
{
	CConnectionListView * connectionView = (CConnectionListView *)m_mainSplitter.GetPane(0,0);
	CFileListView * fileListView = (CFileListView *)m_mainSplitter.GetPane(0,1);

	CString * urlArg = (CString*)lParam;
	if(urlArg){
		TRACE1(" Load url: %s \n", urlArg->AllocSysString());
		CString url(urlArg->AllocSysString());
		delete urlArg;

		CString host(_T(""));
		CString dir(_T(""));
		// Parse
		if(url.Find(_T("ftp://")) != -1){
			url = url.Mid(url.Find(_T("ftp://")) + 6, url.GetLength() - url.Find(_T("ftp://")));
		}
		int pos = url.Find('/');
		if(pos != -1){
			host = url.Mid(0, pos);
			dir = url.Mid(pos, url.GetLength() - pos);
		} else {
			host = CString(url);
			dir = CString(_T("/"));
		}

		// select connection
		int connection_id = -1;
		CObArray * listOfConnections;
		listOfConnections = m_connectionManager.GetConnections();
		int i = 0;
		for(i = 0; i < listOfConnections->GetSize(); i++){
			CConnection * con = (CConnection *)listOfConnections->GetAt(i);
			if(con->host.Compare(host) == 0){
				connection_id = i;
				connectionView->SelectConnection(connection_id);
			}
		}

		// Prompt for new connection information
		if(connection_id < 0){
			CConnectionDialog dlg;
			dlg.SetHost(host); // prefill in host
			dlg.DoModal();
	
			// Update view with updated connections
			connectionView->UpdateConnections();

			// Re check host in connections
			m_connectionManager.Load();
			listOfConnections = m_connectionManager.GetConnections();
			int i = 0;
			for(i = 0; i < listOfConnections->GetSize(); i++){
				CConnection * con = (CConnection *)listOfConnections->GetAt(i);
				if(con->host.Compare(host) == 0){
					connection_id = i;
					connectionView->SelectConnection(connection_id);
				}
			}
			if(connection_id < 0){
				return 1; // No connection entered, abort
			}
		}

		// Load file list view
		fileListView->LoadServerConnection(connection_id);
		fileListView->LoadDirectory(dir);

		// Load url in header history.
		if(m_headerDoc && ((int)wParam) == 1){
			m_headerDoc.SetUrl( CString(host + dir) );
			m_headerDoc.SetConnectionID(connection_id); 
			m_headerDoc.m_path = CString(dir);          // This needs work
			CFileListView * v = (CFileListView *)m_mainSplitter.GetPane(0,1);
			m_headerDoc.m_path = CString(v->GetPath());
		}

		// Cleanup
		delete urlArg;
	}
	return 1;
}
Пример #11
0
// **************************************************************************
// WorkerThread ()
//
// Description:
//	Worker thread function.
//
// Parameters:
//	void		*pvArgs		Pointer to a WORKERTHREADARG structure which
//							  describes task to be performed.
//
// Returns:
//  unsigned int - 0
// **************************************************************************
unsigned _stdcall CKDocument::WorkerThread (void *pvArgs)
	{
	// Cast argument to proper type so we can extract the required data
	// about the task we are to perform:
	WORKERTHREADARG *pWTA = (WORKERTHREADARG *)pvArgs;
	ASSERT (pWTA);

	// Execute specified task:
	switch (pWTA->eTask)
		{
		case WORKERTHREADARG::START_SINGLE_SERVER:
		case WORKERTHREADARG::STOP_SINGLE_SERVER:
			{
			// Extract pointer to server we are to start or stop from
			// argument structure:
			CKServer *pServer = (CKServer *)pWTA->pvObjectA;
			ASSERT (pServer);

			// Start or stop the server as the case may be:
			if (pWTA->eTask == WORKERTHREADARG::START_SINGLE_SERVER)
				pServer->Start ();
			else
				pServer->Stop ();
			}
			break;

		case WORKERTHREADARG::START_MULTIPLE_SERVER:
		case WORKERTHREADARG::STOP_MULTIPLE_SERVER:
			{
			// Extract the list (object array) of servers to start or stop 
			// from argument structure:
			CObArray *pList = (CObArray *)pWTA->pvObjectA;
			ASSERT (pList);

			// Get the number of server in the list:
			int cnServers = pList->GetSize ();
			CKServer *pServer = NULL;

			// Loop over the servers in the list:
			while (--cnServers >= 0)
				{
				// Get pointer to next server in list:
				pServer = (CKServer *) pList->GetAt (cnServers);
				ASSERT (pServer);

				// Start or stop that server as the case may be:
				if (pWTA->eTask == WORKERTHREADARG::START_MULTIPLE_SERVER)
					pServer->Start ();
				else
					pServer->Stop ();
				}
			}
			break;

		case WORKERTHREADARG::ADD_ITEMS:
			{
			// Extract the list (object array) of items to add from
			// argument structure:
			CObArray *pList = (CObArray *)pWTA->pvObjectA;
			ASSERT (pList);

			// Extract the number of items from the argument structure:
			int cnItems = *(int *)pWTA->pvObjectB;

			// Get pointer to first item from list.  We will use it to
			// get the group object these items will be added to:
			CKItem *pItem = (CKItem *)pList->GetAt (0);
			ASSERT (pItem);

			// Get group that we are adding the items to:
			CKGroup *pGroup = pItem->GetParentGroup ();
			ASSERT (pGroup);

			// Add the items to this group:
			pGroup->AddItems (*pList, cnItems);
			}
			break;

		default:
			// unhandled task ?
			ASSERT (FALSE);
			break;
		}

	return (0);
	}
Пример #12
0
void CDialogPlacePart::DoImportLibrary()
{
	CDraftDrawDoc *pDoc = theApp.GetActiveDocument();

	std::wstring sFilter = _T("External library file (*.xml)|*.xml||");//All Files (*.*)|*.*||;
	CStringArray saExtensions;
	saExtensions.Add(_T("xml"));

	CFileDialog fdialog(
		TRUE,		//save dialog box
		NULL,
		NULL,
		0,			//no flags
		sFilter.c_str(),
		NULL);

	if (fdialog.DoModal() == IDOK){

		//Get filename from dialog
		int offset = fdialog.m_ofn.nFileExtension;
		CString strFile = fdialog.m_ofn.lpstrFile;
		int nFilterIndex = fdialog.m_ofn.nFilterIndex;
		if ((!offset) || (fdialog.m_ofn.lpstrFile[offset] == 0)){

			strFile += _T(".") + saExtensions[fdialog.m_ofn.nFilterIndex - 1];
			sFilter = saExtensions[fdialog.m_ofn.nFilterIndex - 1];
		}

		//Try to import library
		CImporter *pImporter = new CImporter();
		CObArray *pObArray = new CObArray();
		pImporter->ImportLibrary(strFile, pObArray, pDoc->m_szGrid);

		//Create new library
		CString strLib = strFile.Left(strFile.ReverseFind('.'));
		if (strLib.ReverseFind(_T('\\')) >= 0){
			strLib = strLib.Right(strLib.GetLength() - strLib.ReverseFind(_T('\\')) - 1);
		}
		if (strLib.GetLength() == 0) strLib = strFile;
		DoInsertNewLibrary(strLib, TRUE);

		//Iterate all shapes to bounding rect union
		CRect rectUnion;
		for (int i = 0; i < pObArray->GetSize(); i++){
			CShapeUnit *pSh = (CShapeUnit *)pObArray->GetAt(i);
			CRect rect;
			pSh->GetRectTemp(rect);

			TRACE(_T("Importing part %s.\n"),(LPCTSTR)(pSh->m_sUnitName));

			//rectUnion.UnionRect(rectUnion, rect);
			if (rect.Width()>rectUnion.Width()){
				rectUnion = CRect(CPoint(0, 0), CSize(rect.Width(), rectUnion.Height()));
			}
			if (rect.Height()>rectUnion.Height()){
				rectUnion = CRect(CPoint(0, 0), CSize(rectUnion.Width(), rect.Height()));
			}
		}

		//rectUnion.InflateRect(DCABLE_PADDINGX_DEFAULT << 1, DCABLE_PADDINGY_DEFAULT << 1);
		rectUnion.InflateRect(DCABLE_GRIDX_DEFAULT, DCABLE_GRIDY_DEFAULT);
		CSize size=rectUnion.Size();
		rectUnion = CRect(CPoint(0, 0), rectUnion.Size());

		//Insert/update parts
		for (int i = 0; i<pObArray->GetSize(); i++){

			//Insert part
			CShapeUnit *pSh = (CShapeUnit *)pObArray->GetAt(i);

			//Do insert in librarry
			DoInsertPart(pSh->m_sUnitName);

			//Get bounding rect
			CRect rectTemp;
			pSh->GetRectTemp(rectTemp);
			((CShapeFrmRect*)pSh->m_obarrShapearr[0])->m_Rect = rectUnion;
			CPoint offset = CPoint((rectUnion.Width() - rectTemp.Width()) >> 1, (rectUnion.Height() - rectTemp.Height()) >> 1);

			//Call a method to normalize ShapeUnit from bounding rect TopLeft to (0,0) or any other offset
			//pSh->NormalizeChildShapes(CPoint(DCABLE_PADDINGX_DEFAULT, DCABLE_PADDINGY_DEFAULT));
			pSh->NormalizeChildShapes(offset);

			//Save parts
			//Create new method in CDocument to be called from here and serialize the parts
			CString strFile = pSh->m_sUnitName;
			//Keep previous part edition status
			BOOL bFlagPartEdit = pDoc->m_bFlagPartEdit;
			//Set part edition mode to save the save
			pDoc->m_bFlagPartEdit = TRUE;
			CObArray* prevObArray = pDoc->m_pObArray;
			pDoc->m_pObArray = &pSh->m_obarrShapearr;
			pDoc->OnDatabaseSave(strLib + _T(".") + strFile);
			pDoc->m_pObArray = prevObArray;
			//Restore flag
			pDoc->m_bFlagPartEdit = bFlagPartEdit;
		}

	}//End dialog result OK
Пример #13
0
void CuDlgParameterInstallationExtra::RefreshParameter()
{
	try
	{
		int nTopIndex = m_cListCtrl.GetTopIndex();
		m_cListCtrl.HideProperty(FALSE);
		m_cListCtrl.DeleteAllItems();
		while (!m_listParameter.IsEmpty())
			delete m_listParameter.RemoveHead();

		if (theApp.m_ingresVariable.QueryEnvironment (m_listParameter, FALSE, TRUE))
		{
			//
			// Sort the parameter:
			CaEnvironmentParameter* pParam = NULL;
			CObArray a;
			int i, indx, nCount = 0;
			if (!m_listParameter.IsEmpty())
			{
				a.SetSize(m_listParameter.GetCount());
				POSITION pos = m_listParameter.GetHeadPosition();

				while (pos != NULL)
				{
					pParam = (CaEnvironmentParameter*)m_listParameter.GetNext(pos);
					if (pParam->GetName().CompareNoCase(_T("II_NUM_OF_PROCESSORS"))==0)
						pParam->LoadDescription(IDS_II_NUM_OF_PROCESSORS);
					else
					if (pParam->GetName().CompareNoCase(_T("II_MAX_SEM_LOOPS"))==0)
						pParam->LoadDescription(IDS_II_MAX_SEM_LOOPS);

					a[nCount] = pParam;
					nCount++;
				}
				if (a.GetSize() > 1)
					IVM_DichotomySort(a, CompareSubItem, (LPARAM)&m_sortparam, NULL);
			}
			else
				return;

			for (i=0; i< a.GetSize(); i++)
			{
				pParam = (CaEnvironmentParameter*)a[i];
				nCount = m_cListCtrl.GetItemCount();
				indx = m_cListCtrl.InsertItem (nCount, pParam->GetName(), IM_ENV_SYSTEM);
				if (indx != -1)
				{
					m_cListCtrl.SetItemText (indx, 1, pParam->GetValue());
					m_cListCtrl.SetItemText (indx, 2, pParam->GetDescription());
					m_cListCtrl.SetItemData (indx, (DWORD_PTR)pParam);
				}
			}

			if (nTopIndex != -1)
			{
				CRect r;
				m_cListCtrl.GetItemRect (0, r, LVIR_BOUNDS);
				m_cListCtrl.Scroll (CSize(0, nTopIndex*r.Height()));
			}
		}
	}
	catch (...)
	{
		AfxMessageBox (_T("System error (CuDlgParameterInstallationExtra::RefreshParameter): \nRefresh parameter failed"));
	}
}