Ejemplo n.º 1
0
void CXTPRibbonBuilder::LoadIcons(int nId, CUIntArray& arrIcons)
{
	CXTPImageManager* pImageManager = m_pCommandBars->GetImageManager();


	HBITMAP hBitmap = CXTPImageManagerIcon::LoadBitmapFromResource(MAKEINTRESOURCE(nId), NULL);
	if (hBitmap)
	{
		BITMAP bmpInfo;
		::GetObject(hBitmap, sizeof(BITMAP), &bmpInfo);

		CSize szBitmap = CSize(bmpInfo.bmWidth, bmpInfo.bmHeight);

		int nCount = 0;

		if (szBitmap.cy >= 15 && szBitmap.cy <= 16)
		{
			nCount = szBitmap.cx / 16;
		}
		else if (szBitmap.cy == 32)
		{
			nCount = szBitmap.cx / 32;
		}

		while (arrIcons.GetSize() < nCount)
			arrIcons.Add(0);

		DeleteObject(hBitmap);
	}

	pImageManager->SetIcons(nId, arrIcons.GetData(), (int)arrIcons.GetSize(), CSize(0, 0), xtpImageNormal);

}
Ejemplo n.º 2
0
BOOL CExportDB::SetTableColumn( CStringArray & astrColumnName, CUIntArray & anWidth )
{
	ASSERT( astrColumnName.GetSize() == anWidth.GetSize() );
	if( astrColumnName.GetSize() != anWidth.GetSize() )
		return FALSE;

	m_astrColumnName.Copy( astrColumnName );
	m_anColumnWidth.Copy( anWidth );
	ASSERT( m_astrColumnName.GetSize() > 0 );
	return m_astrColumnName.GetSize() > 0;
}
void CDiagramEntityContainer::Reorder( const CUIntArray &order )
{
	if (order.GetSize() != GetSize()) return;

	CObArray temp;
	temp.SetSize( order.GetSize() );

	for (int i = 0; i < order.GetSize(); i++)
		temp[order[i]] = m_objs[i];

	m_objs.Copy( temp );
	SetModified( TRUE);
}
Ejemplo n.º 4
0
void     Essence(CUIntArray& aX,CUIntArray& aY)//loai bo nhung phan tu trung nhau
{
    aY.RemoveAll();
    for(int i=0; i<aX.GetSize(); i++)
        if(FindUInt(aX[i],aY)==-1)//Neu khong tim thay
            aY.Add(aX[i]);
}
Ejemplo n.º 5
0
int  FindUInt(UINT x, CUIntArray& aUInt)
{
    for(int i=0; i<aUInt.GetSize(); i++)
        if(x==aUInt[i])
            return i;
    return -1;
}
Ejemplo n.º 6
0
void     Common(CUIntArray& aX,CUIntArray& aY,CUIntArray& aZ )
{
    CUIntArray aTemp;
    for(int i=0; i<aX.GetSize(); i++)
        if(FindUInt(aX[i],aY)!=-1)//Neu tim thay
            aTemp.Add(aX[i]);
    Essence(aTemp,aZ);
}
Ejemplo n.º 7
0
BOOL CSetupDlg::OnInitDialog()
{
	CDialog::OnInitDialog();

	// TODO:  Add extra initialization here
	m_baudRate.Format("9600");
	c_SetupComPort.ResetContent();
	m_baudRateStatic="9600";
	CUIntArray ports;
	int	ii;
	char buf[20];

	if (CEnumerateSerial::UsingGetDefaultCommConfig(ports))
	{
		for (ii=0; ii<ports.GetSize(); ii++)
		{
			_snprintf(buf,20,"COM%d",ports[ii]);
			c_SetupComPort.AddString(buf);
		}
      
	}

	CRect rect;
	c_listCtrl.GetClientRect(&rect);
	int cw=rect.Width()/3;
	c_listCtrl.InsertColumn(0,_T("Col 1"),0,cw);
	c_listCtrl.InsertColumn(1,_T("Col 2"),0,cw);
	c_listCtrl.InsertColumn(2,_T("Col 3"),0,cw);

	LVITEM lvi;
	CString lvs;

	int jj;

	for (ii=0; ii<3; ii++) {

		lvi.mask = LVIF_TEXT;
		lvi.iItem = ii;

		for (jj=0; jj<3; jj++) {

			// lvs.Format(_T("ii %d jj %d"),ii,jj);
			lvs.Format(_T("%d ii %d jj %d"),rand(),ii,jj);
			lvi.iSubItem = jj;
			lvi.pszText=(LPTSTR)(LPCTSTR)(lvs);
			if (jj==0)
				c_listCtrl.InsertItem(&lvi);
			else
				c_listCtrl.SetItem(&lvi);
		}
	}

	c_listCtrl.SetExtendedStyle(c_listCtrl.GetExtendedStyle() | LVS_EX_FULLROWSELECT);

	UpdateData(FALSE);
	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Ejemplo n.º 8
0
UINT GetFormatTypeIndex(UINT nFormat)
{
	int i; for (i=0;i<arFormatType.GetSize();i++) {
		if (arFormatType.GetAt(i) == nFormat) {
			return i;
		}
	}
	return -1;
}
Ejemplo n.º 9
0
//////////////////
// Refresh all colors, fonts, etc. For WM_SETTINGCHANGE, WM_SYSCOLORCHANGE.
//
void CCoolMenuManager::Refresh()
{
	// first copy list (array) of toolbar IDs now loaded.
	CUIntArray arToolbarID;
	arToolbarID.Copy(m_arToolbarID);

	// destroy everything
	Destroy();

	// re-load toolbars.
	int nToolbars = arToolbarID.GetSize();
	for (int i = 0; i < nToolbars; i++)
		LoadToolbar(arToolbarID[i]);
}
Ejemplo n.º 10
0
void EditSerializer::WriteSimpleArray(DataField field, const CUIntArray& a)
{
	CString result;
	char buf[16];

	for (int i=0; i<a.GetSize(); i++)
	{
		unsigned int val = a.GetAt(i);
		if (i > 0)
			result += ";";

		sprintf(buf, "%d", val);
		result += buf;
	}

	WriteString(field, (LPCTSTR)result);
}
Ejemplo n.º 11
0
int	CUpdateUtil::RealVersionCheck(CUIntArray& unarrayClient, CUIntArray& unarrayServer)
{
	int i = 0;
	int count = 0;

	if(unarrayClient.GetSize() == unarrayServer.GetSize()){
		count = unarrayClient.GetSize();
		for(i=0; i <count; i++){
			if(unarrayClient.ElementAt(i) != unarrayServer.ElementAt(i)){
				if(unarrayClient.ElementAt(i) < unarrayServer.ElementAt(i))			return UPDATE_FLAG_UPDATE;
				else if(unarrayClient.ElementAt(i) > unarrayServer.ElementAt(i))	return UPDATE_FLAG_NORMAL;
			}
		}
	}
	else if(unarrayClient.GetSize() < unarrayServer.GetSize()){	// 1.1 : 1.1.0.1
		count = unarrayClient.GetSize();
		for(i=0; i <count; i++){
			if(unarrayClient.ElementAt(i) != unarrayServer.ElementAt(i)){
				if(unarrayClient.ElementAt(i) < unarrayServer.ElementAt(i))			return UPDATE_FLAG_UPDATE;
				else if(unarrayClient.ElementAt(i) > unarrayServer.ElementAt(i))	return UPDATE_FLAG_NORMAL;
			}
		}
		return UPDATE_FLAG_UPDATE;
	}
	else{	// unarrayClient.GetSize() > unarrayServer.GetSize() // 1.1.0.1 : 1.2
		count = unarrayServer.GetSize();
		for(i=0; i <count; i++){
			if(unarrayClient.ElementAt(i) != unarrayServer.ElementAt(i)){
				if(unarrayClient.ElementAt(i) < unarrayServer.ElementAt(i))			return UPDATE_FLAG_UPDATE;
				else if(unarrayClient.ElementAt(i) > unarrayServer.ElementAt(i))	return UPDATE_FLAG_NORMAL;
			}
		}
	}

	return UPDATE_FLAG_NORMAL;
}
Ejemplo n.º 12
0
void CSListView::ExportList( CListExportDlg * pDlg )
{
	ASSERT( pDlg );
	if( NULL == pDlg )
		return;

	int	nColumnCount	=	m_Grid.GetColumnCount();
	ASSERT( nColumnCount > 0 );
	if( nColumnCount <= 0 )
		return;

	CStockContainer & container = AfxGetSListStockContainer();

	// Get Current StockList Time
	DWORD	dwDate;
	CSPTime	sptime;
	CSPTime	time;
	if( container.GetCurrentType( NULL, NULL, &dwDate )
		&& (-1 != dwDate || container.GetLatestTechDate(&dwDate))
		&& sptime.FromStockTimeDay( dwDate ) )
		time	=	CSPTime( sptime.GetTime() );

	// Set Column
	CStringArray	astrColumn;
	CUIntArray		anWidth;
	CUIntArray		anParams;
	for(int nCol = 0; nCol < nColumnCount; nCol ++ )
	{
		astrColumn.Add( m_Grid.GetItemText(0,nCol) );
		anWidth.Add( m_Grid.GetColumnWidth(nCol) );
		anParams.Add( m_Grid.GetItemData(0,nCol) );
	}
	if( ! pDlg->ExportBegin( astrColumn, anWidth, TRUE )
		|| ! pDlg->ExportOpenTable( time, TRUE ) )
		return;

	container.Lock();

	// set Item
	int	nCount = 0, nTotalCount = 0;
	if( pDlg->m_bItemAll )
	{
		nTotalCount	=	m_Grid.GetRowCount()-1;
		pDlg->SetProgressRange( 0, nTotalCount );
		for( int nRow=1; nRow<m_Grid.GetRowCount(); nRow++ )
		{
			CStringArray	astrItemText;
			astrItemText.SetSize( 0, nColumnCount+1 );
			LPARAM	id	=	m_Grid.GetItemData(nRow,0);
			CStockInfo & info	=	container.GetStockInfoByID(id);
			for(nCol=0; nCol<anParams.GetSize(); nCol++ )
			{
				astrItemText.Add( m_Grid.GetItemText( nRow, nCol ) );
			}
			pDlg->ExportAddItem( astrItemText );

			nCount	++;
			pDlg->SetProgress( nCount );
		}
	}
	else if( pDlg->m_bItemSelected )
	{
		nTotalCount	=	m_Grid.GetSelectedCount();
		pDlg->SetProgressRange( 0, nTotalCount );
		for( int nRow=1; nRow<m_Grid.GetRowCount(); nRow++ )
		{
			BOOL	bSelected	=	FALSE;
			for( nCol=0; nCol<m_Grid.GetColumnCount(); nCol ++ )
				bSelected	|=	( m_Grid.GetItemState(nRow,nCol) & GVIS_SELECTED );
			if( !bSelected )
				continue;

			CStringArray	astrItemText;
			astrItemText.SetSize( 0, nColumnCount+1 );
			LPARAM	id	=	m_Grid.GetItemData(nRow,0);
			CStockInfo & info	=	container.GetStockInfoByID(id);
			for(nCol=0; nCol<anParams.GetSize(); nCol++ )
			{
				astrItemText.Add( m_Grid.GetItemText( nRow, nCol ) );
			}
			pDlg->ExportAddItem( astrItemText );

			nCount	++;
			pDlg->SetProgress( nCount );
		}
	}
	else if( pDlg->m_bItemDefine )
	{
		nTotalCount	=	min(m_Grid.GetRowCount()-1,pDlg->m_nItemEnd) - max(1,pDlg->m_nItemBegin) + 1;
		pDlg->SetProgressRange( 0, nTotalCount );
		for( int nRow=max(1,pDlg->m_nItemBegin); nRow<=min(m_Grid.GetRowCount()-1,pDlg->m_nItemEnd); nRow++ )
		{
			CStringArray	astrItemText;
			astrItemText.SetSize( 0, nColumnCount+1 );
			LPARAM	id	=	m_Grid.GetItemData(nRow,0);
			CStockInfo & info	=	container.GetStockInfoByID(id);
			for(nCol=0; nCol<anParams.GetSize(); nCol++ )
			{
				astrItemText.Add( m_Grid.GetItemText( nRow, nCol ) );
			}
			pDlg->ExportAddItem( astrItemText );

			nCount	++;
			pDlg->SetProgress( nCount );
		}
	}

	container.UnLock();

	pDlg->ExportFinish( );
}
Ejemplo n.º 13
0
void CSListView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint) 
{
	// TODO: Add your specialized code here and/or call the base class
	if( UPDATE_HINT_SLISTVIEW != lHint )
		return;
	if( IsWindowVisible() )
		SetFocus( );
	int	nColumnCount	=	m_Grid.GetColumnCount();
	if( nColumnCount <= 0 )
		return;

	if( GetParentFrame()->GetSafeHwnd() != AfxGetMainFrame()->GetActiveFrame()->GetSafeHwnd() )
	{
		m_bShouldUpdate	=	TRUE;
		return;
	}
	m_bShouldUpdate	=	FALSE;

	CStockContainer & container = AfxGetSListStockContainer();
	container.Lock();

	m_Grid.DeleteNonFixedRows();

	// Progress
	CMainFrame	* pMainFrame = AfxGetMainFrame();
	if( pMainFrame )
	{
		pMainFrame->ShowProgressBar( );
		pMainFrame->SetProgress( 0 );
		pMainFrame->SetMessageText( IDS_MAINFRAME_WAITING );
	}

	CUIntArray	anParams;
	anParams.SetSize( 0, nColumnCount );
	for( int nCol=0; nCol < nColumnCount; nCol ++ )
	{
		LPARAM	lParam	=	m_Grid.GetItemData( 0, nCol );
		anParams.Add( lParam );
	}

	CRect rectClient;
	GetClientRect( &rectClient );
	int nPageCount = 1 + rectClient.Height() / abs(m_Grid.GetFixedRowHeight()) + 1;

	for( int i=0; i<container.GetSize(); i++ )
	{
		CStockInfo & info = container.GetStockInfoByID(i);

		int nRow = m_Grid.InsertRow( info.GetStockName() );
		m_Grid.SetItemData( nRow, 0, i );

		for( int nCol=0; nCol<anParams.GetSize(); nCol++ )
		{
			m_Grid.SetItemFormat( nRow, nCol, DT_CENTER|DT_VCENTER|DT_SINGLELINE );
			m_Grid.SetItemText( nRow, nCol, AfxGetVariantDispString( anParams[nCol], info, &container ) );
			m_Grid.SetItemBkColour( nRow, nCol, AfxGetProfile().GetColor(CColorClass::clrSListBK) );
			m_Grid.SetItemFgColour( nRow, nCol, AfxGetVariantColor( anParams[nCol], info ) );
			if( anParams[nCol] == SLH_DATE )
				m_Grid.SetColumnWidth( nCol, 80 );
			if( anParams[nCol] == SLH_CODE )
				m_Grid.SetColumnWidth( nCol, 60 );
		}

		if( i == nPageCount+5 )
		{
			m_Grid.Invalidate( );
			MSG		msg;
			while (::PeekMessage(&msg, NULL, NULL, NULL, PM_NOREMOVE) )
				AfxGetApp()->PumpMessage();
		}
		if( pMainFrame )
			pMainFrame->SetProgress( 100*i/container.GetSize() );
	}

	// Set Average and Weight Average
//	SetAverageItem( m_Grid, container, FALSE );

	// Sort If Needed
	if( -1 != m_nColSort )
	{
		LPARAM	lParam	=	m_Grid.GetItemData( 0, m_nColSort );
		if( lParam >= 0 )
		{
			CStockContainer::m_pSortContainer	=	&container;
			container.m_nSortVariantID	=	lParam;
			container.m_bSortAscend		=	m_bSortAscend;
			m_Grid.SortItems( ItemCompareFunc, 0, TRUE );
		}
	}

	if( pMainFrame )
	{
		pMainFrame->SetProgress( 100 );
		pMainFrame->HideProgressBar( );
		pMainFrame->SetMessageText( IDS_MAINFRAME_FINISHED );
		pMainFrame->SetMessageText( IDS_HELPTIP_SLIST );
	}

	if( m_bFirstUpdate )
		m_Grid.AutoSizeColumns( );
	else
		m_Grid.SetColumnWidth( 0, 80 );
	m_bFirstUpdate	=	FALSE;
	m_Grid.Invalidate( );

	SendRequestQuote(TRUE);

	container.UnLock();
}
void CXTPReportSelectedRows::SelectBlock(int nBlockBegin, int nEnd, BOOL bControlKey)
{
	CXTPReportRows* pRows;
	switch(m_nRowType)
	{
		case xtpRowTypeHeader : pRows = m_pControl->GetHeaderRows(); break;
		case xtpRowTypeFooter : pRows = m_pControl->GetFooterRows(); break;
		default : pRows = m_pControl->GetRows(); break;
	}
	int nRowsCount(0);
	if (pRows)
		nRowsCount = pRows->GetCount();
	BOOL bGo = (nBlockBegin >= 0 && nBlockBegin < nRowsCount && nEnd < nRowsCount);
	if (!bGo)
	{
		Clear(GetNotifyOnSelectedRowsClear());
		return;
	}

	if (bControlKey == FALSE)
	{
		nBlockBegin = m_nRowBlockBegin != -1 ? m_nRowBlockBegin : nBlockBegin;

		int nBegin = nBlockBegin;

		if (nBegin == -1 || nEnd == -1)
			return;

		if (nBegin > nEnd)
		{
			nBegin = nEnd;
			nEnd = nBlockBegin;
		}

		if (m_arrSelectedBlocks.GetSize() == 1 && m_arrSelectedBlocks[0].nIndexBegin == nBegin &&
			m_arrSelectedBlocks[0].nIndexEnd == nEnd + 1)
		{
			return;
		}

		XTPReportRowType nRowType = m_nRowType;
		Clear(GetNotifyOnSelectedRowsClear());
		m_nRowType = nRowType;
		if (m_nRowBlockBegin == -1) m_nRowBlockBegin = nBlockBegin;


		BOOL bSkipGroupFocus = m_pControl->IsSkipGroupsFocusEnabled();
		BOOL bHasGroups = m_pControl->GetColumns()->GetGroupsOrder()->GetCount() != 0;

		if (!bHasGroups || !bSkipGroupFocus)
		{
			_InsertBlock(0, nBegin, nEnd + 1);
		}
		else
		{
			for (int i = nBegin; i <= nEnd; i++)
			{
				CXTPReportRow* pRow = pRows->GetAt(i);
				if (!pRow)
					continue;

				if (!bSkipGroupFocus || !pRow->IsGroupRow() || !pRow->IsExpanded() || (i == nBegin) || (i == nEnd))
				{
					Add(pRow);
				}
			}
		}

		// notify owner the selection state has changed.
		_NotifyStateChanged(nBegin, nEnd);
	}
	else
	{
		int kSB = (int) m_arrSelectedBlocks.GetSize();
		if (kSB > 0)
		{
			int iMin = m_arrSelectedBlocks[0].nIndexBegin;
			int iMax = m_arrSelectedBlocks[kSB - 1].nIndexEnd;
			if (nEnd >= iMin && nEnd < iMax)
			{
				return;
			}
		}
		BOOL bSkipGroupFocus = FALSE;//m_pControl->IsSkipGroupsFocusEnabled();
		BOOL bHasGroups = m_pControl->GetColumns()->GetGroupsOrder()->GetCount() != 0;
		BOOL bWasShiftKey = m_pControl->m_bWasShiftKey;

		if (m_nRowBlockBegin != -1)
			nBlockBegin = m_nRowBlockBegin;
		int nBegin(nBlockBegin), iB, iE;
		if (nBegin == -1 || nEnd == -1)
		{
			return;
		}
		BOOL bSwap = SwapIfNeed(nBegin, nEnd);
		int nArSz = (int) m_arrSelectedBlocks.GetSize();

		CUIntArray ar;
		if (nArSz > 0)
		{
			for (int k = 0; k < nArSz; k++)
			{
				int iB = m_arrSelectedBlocks[nArSz - 1 - k].nIndexBegin;
				int iE = m_arrSelectedBlocks[nArSz - 1 - k].nIndexEnd;
				if (iE == iB + 1 && iB == 0)
					k++; //this fix a case of initial selection from any row to any row with SHIFT+CONTROL pressed
				if (k < nArSz)
				{
					ar.Add(m_arrSelectedBlocks[k].nIndexBegin);
					ar.Add(m_arrSelectedBlocks[k].nIndexEnd);
				}
			}
		}

		XTPReportRowType nRowType = m_nRowType;
		Clear(GetNotifyOnSelectedRowsClear());
		m_nRowType = nRowType;

		if (m_nRowBlockBegin == -1)
			m_nRowBlockBegin = nBlockBegin;

		if (!bHasGroups || !bSkipGroupFocus) //<<>>
		{
			int k = 0;
			int N = (int) ar.GetSize();
			if (N > 0 && bControlKey && !bWasShiftKey)
			{
				for (k = 0; k < N / 2; k++)
				{
					iB = ar.GetAt(2 * k);
					iE = ar.GetAt(2 * k + 1);
					if (iE < nBegin || iB > nEnd)
					{
						_InsertBlock(k, iB, iE);
					}
					else if (iB >= nBegin && iE <= nEnd) //skip [iB:iE] segment - totally covered
					{
					}
					else if (iB <= nBegin && iE <= nEnd) //skip [iB:iE] segment amd modify new segment
					{
						nBegin = iB;
					}
					else if (iB <= nBegin && iE > nEnd) //skip [iB:iE] segment amd modify new segment
					{
						nBegin = iB;
						nEnd = iE;
					}
					else if (iB >= nBegin && iE > nEnd) //skip [iB:iE] segment amd modify new segment
					{
						nEnd = iE;
					}
					else
					{
					}
				}

				if (bSwap)
				{
					_InsertBlock(0, nBegin, nEnd);
				}
				else
				{
					_InsertBlock(k, nEnd + 1, nBegin);
				}
			}
			else
			{
				_InsertBlock(0, nBegin, nEnd + 1);
			}

			CUIntArray aDel;
			for (int l = 0; l < m_arrSelectedBlocks.GetSize(); l++)
			{
				if (m_arrSelectedBlocks[l].nIndexBegin == m_arrSelectedBlocks[l].nIndexEnd)
					aDel.Add(l);

			}
			for (int ll = 0; ll < aDel.GetSize(); ll++)
				m_arrSelectedBlocks.RemoveAt(aDel.GetAt(ll));
		}
		else
		{
			for (int i = nBegin; i <= nEnd; i++)
			{
				CXTPReportRow* pRow = pRows->GetAt(i);
				if (!pRow)
					continue;

				if (!pRow->IsGroupRow()
					|| !bSkipGroupFocus
					|| !pRow->IsExpanded()
					|| i == nBegin
					|| i == nEnd)
					Add(pRow);
			}
		}

		// notify owner the selection state has changed.
		_NotifyStateChanged(nBegin, nEnd);
	}

	if (m_pControl->m_bSelectionExcludeGroupRows)
		m_pControl->UnselectGroupRows();

	//to show only selected childs under group rows
	//flag - m_bSelectionExcludeGroupRows default = TRUE - this is 12.1 way to show selection
TRACE(_T("return from SelectBlock with Count=%d\n"), GetCount());
}
Ejemplo n.º 15
0
void DVControllerTests::TestInitialiseSaveAsDlgData_DocTypeEffect()
{
	AFX_MANAGE_STATE(AfxGetAppModuleState());

	CStdString sSaveFilters;
	int iFormatCount=0;

	CMDIFrameWnd* pMainFrame = DYNAMIC_DOWNCAST(CMDIFrameWnd, AfxGetMainWnd());
	CChildFrame *pFrame = DYNAMIC_DOWNCAST( CChildFrame, pMainFrame->MDIGetActive() );
	assertTest( pFrame );
	
	CUIntArray aFormats;
	LONG lFormatIndex	= 1;
	LONG lCurrentSaveFormatID = -7;
	LONG lSaveFormatIDDefault = GetApp()->GetDVController(pFrame)->GetComparisonDocController().GetSaveFormatAsDVCode();
//for rtf
	LONG lFlags = 0;
	lFlags |= WSDOCUMENTPROVIDERLib::DF_NEW_DOCUMENT;
	if (lSaveFormatIDDefault !=6)
	{
		lSaveFormatIDDefault=6; //for test rtf
	}
	
	bool origFileFormatValue = Workshare::OptionApi::GetBool(L"AllowFileFormatChange");
	bool origExtSaveFormats = Workshare::OptionApi::GetBool(L"EnableExtendedFileFormats");
	try
	{
		Workshare::OptionApi::SetBool(L"AllowFileFormatChange", false);

		sSaveFilters = GetApp()->GetDVController(pFrame)->GetComparisonDocController().InitialiseSaveAsDlgData(aFormats, lFormatIndex, lCurrentSaveFormatID, lSaveFormatIDDefault, lFlags, docNew);
		int iCount = (x64_int_cast)aFormats.GetSize();
		assertTest(iCount==1);
		CStdString sFormat = _T("Rich Text Format ( *.rtf)|*.rtf||");
		assertTest(sSaveFilters.CompareNoCase(sFormat)==0);	

		sSaveFilters = _T("");
		aFormats.RemoveAll();

		sSaveFilters = GetApp()->GetDVController(pFrame)->GetComparisonDocController().InitialiseSaveAsDlgData(aFormats, lFormatIndex, lCurrentSaveFormatID, lSaveFormatIDDefault, lFlags, docAttachToModified);
		iCount = (x64_int_cast)aFormats.GetSize();
		assertTest(iCount==1);
		sFormat = _T("Rich Text Format ( *.rtf)|*.rtf||");
		assertTest(sSaveFilters.CompareNoCase(sFormat)==0);	

		sSaveFilters = _T("");
		aFormats.RemoveAll();

		Workshare::OptionApi::SetBool(L"EnableExtendedFileFormats", true);

		sSaveFilters = GetApp()->GetDVController(pFrame)->GetComparisonDocController().InitialiseSaveAsDlgData(aFormats, lFormatIndex, lCurrentSaveFormatID, lSaveFormatIDDefault, lFlags, docVersionOfOriginal);
		iCount =(x64_int_cast) aFormats.GetSize();
		assertTest(iCount==1);
		sFormat = _T("Adobe Acrobat File ( *.pdf)|*.pdf||");
		assertTest(sSaveFilters.CompareNoCase(sFormat)==0);	

		Workshare::OptionApi::SetBool(L"AllowFileFormatChange", true);
		Workshare::OptionApi::SetBool(L"EnableExtendedFileFormats", false);
		sSaveFilters = _T("");
		aFormats.RemoveAll();

		sSaveFilters = GetApp()->GetDVController(pFrame)->GetComparisonDocController().InitialiseSaveAsDlgData(aFormats, lFormatIndex, lCurrentSaveFormatID, lSaveFormatIDDefault, lFlags, docNew);
		iCount = (x64_int_cast)aFormats.GetSize();
		sFormat = "Workshare DeltaFile ( *.wdf)|*.wdf|Word 97-2003 Document ( *.doc)|*.doc|Word Document ( *.docx)|*.docx|Text Only ( *.txt)|*.txt|Rich Text Format ( *.rtf)|*.rtf|HTML Document ( *.htm)|*.htm|Adobe Acrobat File ( *.pdf)|*.pdf|Adobe Acrobat PDF/A File (*.pdf)|*.pdf||";
		
		assertMessage(iCount==8,_T("If this fails turn off \"Use Extended File Format\" flag in DMS config to make this work"));
		assertTest(sSaveFilters.CompareNoCase(sFormat) == 0);  

		sSaveFilters = _T("");
		aFormats.RemoveAll();

		sSaveFilters = GetApp()->GetDVController(pFrame)->GetComparisonDocController().InitialiseSaveAsDlgData(aFormats, lFormatIndex, lCurrentSaveFormatID, lSaveFormatIDDefault, lFlags, docAttachToModified);
		iCount = (x64_int_cast)aFormats.GetSize();
		sFormat = "Workshare DeltaFile ( *.wdf)|*.wdf|Word 97-2003 Document ( *.doc)|*.doc|Word Document ( *.docx)|*.docx|Text Only ( *.txt)|*.txt|Rich Text Format ( *.rtf)|*.rtf|HTML Document ( *.htm)|*.htm|Adobe Acrobat File ( *.pdf)|*.pdf|Adobe Acrobat PDF/A File (*.pdf)|*.pdf||";
		
		assertMessage(iCount==8,_T("If this fails turn off \"Use Extended File Format\" flag in DMS config to make this work"));
		assertTest(sSaveFilters.CompareNoCase(sFormat) == 0);  

		sSaveFilters = _T("");
		aFormats.RemoveAll();

		sSaveFilters = GetApp()->GetDVController(pFrame)->GetComparisonDocController().InitialiseSaveAsDlgData(aFormats, lFormatIndex, lCurrentSaveFormatID, lSaveFormatIDDefault, lFlags, docVersionOfOriginal);
		iCount = (x64_int_cast)aFormats.GetSize();
		sFormat = "Workshare DeltaFile ( *.wdf)|*.wdf|Word 97-2003 Document ( *.doc)|*.doc|Word Document ( *.docx)|*.docx|Text Only ( *.txt)|*.txt|Rich Text Format ( *.rtf)|*.rtf|HTML Document ( *.htm)|*.htm|Adobe Acrobat File ( *.pdf)|*.pdf|Adobe Acrobat PDF/A File (*.pdf)|*.pdf||";
		
		assertMessage(iCount==8,_T("If this fails turn off \"Use Extended File Format\" flag in DMS config to make this work"));
		assertTest(sSaveFilters.CompareNoCase(sFormat) == 0);  
	}
	catch(...)
	{
		_ASSERTE(!_T("Catch ... How did we get here?"));
		Workshare::OptionApi::SetBool(L"AllowFileFormatChange", origFileFormatValue);
		Workshare::OptionApi::SetBool(L"EnableExtendedFileFormats", origExtSaveFormats);
		throw;
	}
	Workshare::OptionApi::SetBool(L"AllowFileFormatChange", origFileFormatValue);
	Workshare::OptionApi::SetBool(L"EnableExtendedFileFormats", origExtSaveFormats);
}
Ejemplo n.º 16
0
void ResearchDevices(void)
{
    QueryPerformanceFrequency(&PC_Freq);
    xpidresearching	= true;
    DeviceDetected=0;
    xpid_struct.clear();
    //Scan all xpid interfaces on every available comport
    CArray<SSerInfo,SSerInfo&> asi;
    asi.RemoveAll();
    if (CEnumerateSerial::UsingSetupAPI2(ports, friendlyNames))
    {
        //Convert to asi as best as possible
        for (int i=0; i < ports.GetSize(); i++)
        {
            // Add an entry to the array
            CString pathstr;
            SSerInfo si;
            pathstr.Format("COM%d",ports[i]);
            si.strPortName = pathstr;
            pathstr.Format("\\\\.\\COM%d",ports[i]);
            si.strDevPath = pathstr;
            si.strFriendlyName = friendlyNames[i];
            si.strPortDesc = "";
            si.bUsbDevice = false;
            asi.Add(si);
        }
    }
    else
    {
        // Populate the list of serial ports.
        EnumSerialPorts(asi,FALSE/*include all*/);
    }

    if(asi.GetSize() > 0)
    {
        for (int ii=0; ii < asi.GetSize(); ii++)
        {
            XPIDSTRUCT newxpidstruct= {0};
            //Get short comport suffix like "com1:"
            newxpidstruct.comname = asi[ii].strPortName;
            newxpidstruct.devicepath = asi[ii].strDevPath;
            newxpidstruct.friendlyname = asi[ii].strFriendlyName;
            //Look if a SCN5 is present	on this comport
            //Open comport and set the speed
            HANDLE comhandle=openPort(newxpidstruct.devicepath,CBR_115200);
            if(comhandle)
            {
                CString firmware=GetFirmwareVersion(comhandle);
                //if(firmware==""){Sleep(100); firmware=GetFirmwareVersion(comhandle);}
                if(firmware != "" && firmware[0]=='X' && firmware[1]=='-' && firmware[2]=='P' && firmware[3]=='I' && firmware[4]=='D' && firmware[5]==' ')
                {
                    //Found a xpid on comport, now check if it is working
                    newxpidstruct.comporthandle=comhandle;
                    newxpidstruct.xpidname=firmware+" "+newxpidstruct.comname;
                    newxpidstruct.friendlyname=asi[ii].strFriendlyName;
                    newxpidstruct.devicepath=asi[ii].strDevPath;
                    newxpidstruct.comname=asi[ii].strPortName;
                    newxpidstruct.xpidsetting1.renamename="";
                    newxpidstruct.xpidsetting1.renameport=false;
                    newxpidstruct.xpidpresent=true;
                    //Read out the eeprom
                    ReadXPIDSettings(comhandle,&newxpidstruct);
                    //Check if this XPID has to be renamed
                    ScanExistingRegistryEntry(&newxpidstruct);
                    xpid_struct.push_back(newxpidstruct);
                    DeviceDetected++;
                }
                else
                {
                    CloseHandle(comhandle);
                }
            }
        }
    }
    if (DeviceDetected > 0)
    {
        SetIOsharing();
    }
    else
    {
        ClearIOsharing();
    }
    xpidresearching	=false;
}
Ejemplo n.º 17
0
void CGelView::OnRungel() 
{
	// TODO: Add your control notification handler code here
	CGenedocDoc *pDoc = GetDocument();

//	MakeGel(m_listSequences, m_listEnzymes);
//	pDoc->SetModifiedFlag();

	// CListBox
	int iSeqCount, iEnzCount;

	iSeqCount = m_listSequences.GetSelCount();
	iEnzCount = m_listEnzymes.GetSelCount();

	if ( iSeqCount < 1 || iEnzCount < 1 ) {
		return;
	}

	BeginWaitCursor();

	int *arrSeq = new int[iSeqCount];
	int *arrEnz = new int[iEnzCount];

	m_listSequences.GetSelItems( iSeqCount, arrSeq );
	m_listEnzymes.GetSelItems( iEnzCount, arrEnz );


	POSITION sPos = m_listGel.GetHeadPosition();
	while ( sPos != NULL ) {
		delete (SGel*)m_listGel.GetNext(sPos);
	}
	m_listGel.RemoveAll();

	int s, e;

	for ( s=0; s < iSeqCount; ++s ) {
		POSITION aPos = pDoc->pGSFiller->SegDataList.FindIndex( arrSeq[s] + 2 );
		CGeneSegment *tCGSeg = (CGeneSegment *)pDoc->pGSFiller->SegDataList.GetAt(aPos);

		GeneStor *pGS = (GeneStor *)GlobalLock( tCGSeg->GetTextHandle() );
		// CList
		NewBand(tCGSeg);
		for ( e=0; e < iEnzCount; ++e ) {
			POSITION ePos =  pDoc->m_UserVars.listSearch.FindIndex( arrEnz[e] );
			stcSearch *Enzyme = (stcSearch *)pDoc->m_UserVars.listSearch.GetAt(ePos);

			SearchRebaseGel( Enzyme, pGS, tCGSeg->GetTextLength() );

		}
		GlobalUnlock( tCGSeg->GetTextHandle() );
	}


	CUIntArray arrFrags;

	DWORD MaxLength = 0;
	sPos = m_listGel.GetHeadPosition();
	while ( sPos != NULL ) {
		SGel *pSGel = (SGel *)m_listGel.GetNext(sPos);
		DWORD iLen = pSGel->Sequence->GetLastResidue();
		if ( iLen > MaxLength ) MaxLength = iLen;
	}

	SetYScale ( 0, MaxLength );

	sPos = m_listGel.GetHeadPosition();
	while ( sPos != NULL ) {
		SGel *pSGel = (SGel *)m_listGel.GetNext(sPos);

		int iArr = pSGel->arrCutLoc.GetSize();
		// This code sorts the cut locations
		for ( int ti=0; ti < iArr - 1; ++ti ) {
			for ( int tj=0; tj < iArr - 1; ++tj ) {
				if ( pSGel->arrCutLoc[tj] > pSGel->arrCutLoc[tj+1] ) {
					int t = pSGel->arrCutLoc[tj];
					pSGel->arrCutLoc[tj] = pSGel->arrCutLoc[tj+1];
					pSGel->arrCutLoc[tj+1] = t;
				}
			}
		}
		// Calculate Fragment lengths ..
		DWORD LastCutLoc = 0;
		int i;
		for ( i=0; i < iArr; ++i ) {
			if ( pSGel->arrCutLoc[i] == LastCutLoc ) continue;
			int cl = pSGel->arrCutLoc[i] - LastCutLoc;
			arrFrags.Add( cl );
			LastCutLoc = pSGel->arrCutLoc[i];
		}
		arrFrags.Add( pSGel->Sequence->GetLastResidue() - LastCutLoc );

		// This code sorts the fragment lengths in case that is useful.
//		for ( ti=0; ti < arrFrags.GetSize() - 1; ++ti ) {
//			for ( int tj=0; tj < arrFrags.GetSize()-1; ++tj ) {
//				if ( arrFrags[tj] > arrFrags[tj+1] ) {
//					int t = arrFrags[tj];
//					arrFrags[tj] = arrFrags[tj+1];
//					arrFrags[tj+1] = t;
//				}
//			}
//		}

		iArr = arrFrags.GetSize();
		for ( i=0; i < iArr; ++i ) {
			int iFragLength = arrFrags[i];
			// Normalize fragments to 0 to 1.0
//			double GelLocPerc = 1.0 - (log((double)iFragLength) / log((double)MaxLength));
//			double GelLocPerc = 1.0 - ((double)iFragLength / (double)MaxLength);
			DWORD GelLocPerc = (DWORD)(((double)iFragLength / (double)MaxLength) * 100000000.0);
			// Put Normalized resuls into array for GelObject to draw.
			pSGel->arrGelLoc.Add(GelLocPerc);
		}

		arrFrags.RemoveAll();
	}


	delete arrSeq;
	delete arrEnz;

	EndWaitCursor();
	
	Invalidate();

}
Ejemplo n.º 18
0
BOOL CSListView::SetAverageItem( CGridCtrl &grid, CStockContainer & container, BOOL bRedraw )
{
	if( grid.GetColumnCount() <= 0 )
		return FALSE;

	container.Lock();

	// Get LPARAM
	CUIntArray	anParams;
	anParams.SetSize( 0, grid.GetColumnCount() );
	for( int nCol=0; nCol < grid.GetColumnCount(); nCol ++ )
	{
		LPARAM	lParam	=	grid.GetItemData( 0, nCol );
		anParams.Add( lParam );
	}

	// Set Average
	CStockInfo & infoAve = container.GetAverage( );
	CStockInfo & infoWAve = container.GetWeightAverage( );
	int	iRowAve=0, iRowWAve=0;

	if( grid.GetRowCount() >= 3
		&& grid.GetItemData(grid.GetRowCount()-2,0) == (LPARAM)ID_STOCKCNTN_AVERAGE
		&& grid.GetItemData(grid.GetRowCount()-1,0) == (LPARAM)ID_STOCKCNTN_WEIGHTAVERAGE )
	{
		// get item id
		iRowAve		=	grid.GetRowCount()-2;
		iRowWAve	=	grid.GetRowCount()-1;
	}
	else
	{
		// Insert item
		iRowAve = grid.InsertRow( infoAve.GetStockName() );
		grid.SetItemData( iRowAve, 0, (LPARAM)ID_STOCKCNTN_AVERAGE );
		iRowWAve = grid.InsertRow( infoWAve.GetStockName() );
		grid.SetItemData( iRowWAve, 0, (LPARAM)ID_STOCKCNTN_WEIGHTAVERAGE );
	}

	// Set Average
	for( nCol=0; nCol<anParams.GetSize(); nCol++ )
	{
		grid.SetItemText( iRowAve, nCol, AfxGetVariantDispString(anParams[nCol], infoAve, NULL) );
		grid.SetItemBkColour( iRowAve, nCol, AfxGetProfile().GetColor(CColorClass::clrSListBK) );
		grid.SetItemFgColour( iRowAve, nCol, AfxGetVariantColor( anParams[nCol], infoAve ) );
	}

	// Set Weight Average
	for( nCol=0; nCol<anParams.GetSize(); nCol++ )
	{
		grid.SetItemText( iRowWAve, nCol, AfxGetVariantDispString(anParams[nCol], infoWAve, NULL) );
		grid.SetItemBkColour( iRowWAve, nCol, AfxGetProfile().GetColor(CColorClass::clrSListBK) );
		grid.SetItemFgColour( iRowWAve, nCol, AfxGetVariantColor( anParams[nCol], infoWAve ) );
	}

	//	Set Param which is
	//	SLH_MARKETVALUE, SLH_MARKETVALUEA, SLH_MARKETVALUEB and etc,  and more than SLH_USERDEFINE_BEGIN
	for( nCol=0; nCol < anParams.GetSize(); nCol ++ )
	{
		UINT	lParam	=	anParams[nCol];
		if( SLH_DIFF == lParam || SLH_DIFFPERCENT == lParam || SLH_SCOPE == lParam
			|| SLH_DIFFPERCENT_MIN5 == lParam || SLH_PE == lParam
			|| SLH_PMAININCOME == lParam || SLH_RATIO_PCASH == lParam
			|| SLH_RATIO_CURRENCY == lParam || SLH_RATIO_CHANGEHAND == lParam
			|| SLH_RATIO_VOLUME == lParam || SLH_RS == lParam
			|| SLH_MARKETVALUE == lParam || SLH_MARKETVALUEA == lParam
			|| SLH_MARKETVALUEB == lParam || lParam >= SLH_USERDEFINE_BEGIN )
		{
			double	dc = 0., average = 0.;
			double	wsum = 0.0001, waverage = 0., w = 0.;
			for( int iRow=1; iRow<grid.GetRowCount(); iRow++ )
			{
				if( iRow == iRowAve || iRow == iRowWAve )
					continue;

				int	id	=	grid.GetItemData(iRow,0);
				if( id < 0 || id > container.GetSize() )
					continue;

				CStockInfo	& info = container.ElementAt(id);
				w	=	info.m_fShare_count_total;
				double	dValue	=	0.;
				if( !AfxGetVariantValue( lParam, info, &dValue, &container ) )
					continue;

				average		=	(average * dc + dValue)/(dc+1);
				waverage	=	(waverage * wsum + dValue * w)/(wsum+w);

				dc		+=	1;
				wsum	+=	w;
			}

			CString	strText;
			if( SLH_MARKETVALUE == lParam || SLH_MARKETVALUEA == lParam || SLH_MARKETVALUEB == lParam )
			{
				strText.Format( "%u", (DWORD)average );
				grid.SetItemText( iRowAve, nCol, strText );
				grid.SetItemText( iRowWAve, nCol, "-" );
			}
			else
			{
				strText.Format( "%.2f", average );
				grid.SetItemText( iRowAve, nCol, strText );
				strText.Format( "%.2f", waverage );
				grid.SetItemText( iRowWAve, nCol, strText );
			}
		}
	}

	container.UnLock();

	if( bRedraw )
	{
		grid.RedrawRow( iRowAve );
		grid.RedrawRow( iRowWAve );
	}
	return TRUE;
}