コード例 #1
0
ファイル: DUIButton.cpp プロジェクト: Chingliu/WTLControl
// 绘制按钮
void CDUIButton::DrawButton( Gdiplus::Graphics&  graphics)
{
	// 获取按钮图片信息
	UINT iCount = m_nImageCount;
	int	iButtonIndex = 0;
	if(m_bDisabled && iCount >= 4) iButtonIndex = 3;
	else if(m_bPressed && iCount >= 3)iButtonIndex = 2;
	else if(m_bHovering && iCount >= 2)iButtonIndex = 1;
	else iButtonIndex = 0;

	// 在指定位置绘制按钮
	int iWidth = m_pImage->GetWidth()/iCount;
	int iHeight = m_pImage->GetHeight();
	RectF grect;
	grect.X=(Gdiplus::REAL)m_rcRect.left;
	grect.Y=(Gdiplus::REAL)m_rcRect.top;
	grect.Width = (Gdiplus::REAL)m_rcRect.Width();
	grect.Height = (Gdiplus::REAL)m_rcRect.Height();

	graphics.DrawImage(m_pImage, grect, (Gdiplus::REAL)iWidth*iButtonIndex,0,(Gdiplus::REAL)iWidth,(Gdiplus::REAL)iHeight, UnitPixel);

	StringFormat stringFormat;

	if (m_pIcon)
	{
		PointF ptIcon(m_ptIcon.x,m_ptIcon.y);
		graphics.DrawImage(m_pIcon,ptIcon);

		grect.X=(Gdiplus::REAL)m_ptIcon.x + m_pIcon->GetWidth() + 2;
		grect.Width = (Gdiplus::REAL)m_rcRect.Width() - m_pIcon->GetWidth() - 2;

		stringFormat.SetFormatFlags( StringFormatFlagsDirectionVertical);
		stringFormat.SetAlignment(StringAlignmentCenter);
		stringFormat.SetLineAlignment(StringAlignmentNear);
	}
	else
	{
		//stringFormat.SetFormatFlags( StringFormatFlagsDirectionVertical);
		stringFormat.SetAlignment(StringAlignmentCenter);
		stringFormat.SetLineAlignment(StringAlignmentCenter);
	}

	if (!m_strCaption.IsEmpty())
	{
		//绘制文字
		FontFamily fontFamily(L"宋体");
		Gdiplus::Font font(&fontFamily, 10, FontStyleRegular, UnitPoint);


		CStringW strTitle(m_strCaption);
		SolidBrush brush((ARGB)Color::White);
		if (m_bDisabled)
		{
			brush.SetColor((ARGB)Color::Gray);
		}

		graphics.DrawString(strTitle, strTitle.GetLength(), &font,grect,&stringFormat, &brush);
	}

}
コード例 #2
0
//Save the image names and corresponding labels into a .txt file for Caffe/CNTK/TensorFlow
void QxMainWindow::saveLabelFile(const QString& strFilePath, QxDecodeOptionDlg::ApplicationType appType)
{
	// There's no need to store label files for DIGITS.
	if (appType == QxDecodeOptionDlg::DIGITS)
	{
		return;
	}

	// Use a local file to save path of images and corresponding labels.
	QString strLabelFileName = strFilePath + "/" + g_LabelFileName;
	QFile labelFile(strLabelFileName);
	if (!labelFile.open(QIODevice::WriteOnly | QIODevice::Text))
	{
		QString strTitle("Open file error");
		QString strMessage("Can not open label file:\n");
		strMessage.append(strLabelFileName);
		strMessage.append("\nMaybe you do not have permission to create a new file in the selected folder?");
		strMessage.append("\nOr maybe there is a Read-Only file named \"").append(g_LabelFileName).append("\" in the selected folder?");
		QMessageBox::critical(this, strTitle, strMessage, QMessageBox::Ok);
		return;
	}

	QTextStream textStream(&labelFile);
	for (QMap<QString, quint32>::iterator itr = m_ImageLabelMap.begin(); itr != m_ImageLabelMap.end(); ++itr)
	{
		textStream << getLabelInfo(itr.key(), itr.value(), appType) << "\n";
	}
	labelFile.close();
}
コード例 #3
0
//Decode all the .gnt files in the file list.
void QxMainWindow::decodeAll()
{
	if (m_FileList.isEmpty())
	{
		QString strTitle("No selected files");
		QString strMessage("No files selected yet. Please press \"Open\" to select files first.");
		QMessageBox::information(this, strTitle, strMessage, QMessageBox::Ok);
		return;
	}

	// If user clicks "Cancel" button when selection decoding options, do not decode files.
	QxDecodeOptionDlg dlg(m_FileList, this);
	if (dlg.exec() != QxDecodeOptionDlg::Accepted)
	{
		return;
	}

	// get selected application, image size, as well as image format
	unsigned uImageSize = dlg.imageSize();
	cv::Size imageSize(uImageSize, uImageSize);
	QString strImageFormat = dlg.imageFormat();
	QString strDestinationPath = dlg.filePath();
	QxDecodeOptionDlg::ApplicationType appType = dlg.application();

	//If files are successfully decode, show a messagebox to inform user.
	if (decodeFiles(m_FileList, strDestinationPath, strImageFormat, imageSize, appType))
	{
		QString strMessage("Files successfully decoded.");
		QMessageBox::information(this, "Result", strMessage, QMessageBox::Ok);
	}
}
コード例 #4
0
ファイル: IMEAppDlg.cpp プロジェクト: amitdo/Lipitk
int CIMEAppDlg::loadProject(string& project)
{
	m_ShapeRecognizer.unloadModelData();

	if(FAILURE == m_ShapeRecognizer.loadModelData(project))
	{
		displayMessage(L"Fail to load project!");
		return FAILURE;
	}

	string mapFile;
	m_IsMappingFileFound = false;

	mapFile = m_lipiRoot + PROJECTS_PATH_STRING +
	        project + PROFILE_PATH_STRING + MAPPING_PATH_STRING;
	if(FAILURE == loadMapping(mapFile))
	{
		displayMessage(L"Mapping file not found!");
	}
	
	string strTitle("Lipi Demo : ");
	strTitle += project.c_str();

	TCHAR title[MAX_PATH]={0};
	mbstowcs(title,strTitle.c_str(),MAX_PATH);

	this->SetWindowTextW(title);
	displayMessage(L" ");

	return SUCCESS;
}
コード例 #5
0
BOOL CDlgDcamAbout::OnInitDialog() 
{
	CDialog::OnInitDialog();

	CenterWindow( GetParentFrame() );

	m_lvStrings.InsertColumn( 0, _T("Kind"), 0, 128 );
	m_lvStrings.InsertColumn( 1, _T("Text") );

	LPCTSTR	p;
	for( p = m_strStrings; *p; )
	{
		LPCTSTR	q;
		// find end of line
		for( q = p; *q; q++ )
		{
			if( *q == cr || *q == lf )
				break;
		}

		// find tab
		LPCTSTR	r;
		for( r = p; r < q; r++ )
		{
			if( *r == tab )
				break;
		}

		if( *q && r < q )
		{
			CString	strTitle( p, int(r-p) );

			r++;
			CString	strValue( r, int(q-r) );

			int	nItem = m_lvStrings.InsertItem( m_lvStrings.GetItemCount(), strTitle );
			m_lvStrings.SetItemText( nItem, 1, strValue );
		}
		else
			ASSERT( 0 );

		// prepare next line
		if( *q == cr )	q++;
		if( *q == lf )	q++;
		p = q;
	}

	if( m_lvStrings.GetItemCount() > 0 )
	{
		m_lvStrings.SetColumnWidth( 0, LVSCW_AUTOSIZE );
		m_lvStrings.SetColumnWidth( 1, LVSCW_AUTOSIZE );
	}

	GetDlgItem( IDC_DLGDCAMABOUT_BTNCOPY )->EnableWindow( m_bCopy );

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
コード例 #6
0
ファイル: CallDlg.cpp プロジェクト: eSDK/esdk_elte
void CCallDlg::SetTile()
{
	CString strTitle("Incoming call: ");
	strTitle.Append(m_strResId);
	if(this->GetSafeHwnd())
	{
		SetWindowText(strTitle);
	}
}
コード例 #7
0
ファイル: MainWndCmd.cpp プロジェクト: afriza/GSPlayer
void CMainWnd::SaveMediaFile(HWND hwndParent)
{
	if (m_fShowOpenDlg)
		return;

	BOOL fRet;
	CTempStr strTitle(IDS_TITLE_SAVE_LIST);
	CTempStr strFilter(IDS_FILTER_SAVE_LIST);
	TCHAR szFile[MAX_PATH] = {0};

	m_fShowOpenDlg = TRUE;
#ifdef _WIN32_WCE
	OPENFILENAME ofn;
	memset(&(ofn), 0, sizeof(ofn));
	ofn.lStructSize	= sizeof(ofn);
	ofn.hwndOwner   = hwndParent ? hwndParent : m_hWnd;
	ofn.lpstrFile   = szFile;
	ofn.nMaxFile    = MAX_PATH;	
	ofn.lpstrTitle  = strTitle;
	ofn.lpstrFilter = strFilter;
	ofn.lpstrDefExt = M3U_FILE_EXT;
	ofn.Flags       = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
	ofn.lpstrInitialDir = m_pOptions->m_szLastDir;

	BOOL (*gsGetSaveFileName)(OPENFILENAME*) = NULL;
	HINSTANCE hInst = LoadLibrary(_T("gsgetfile.dll"));
	if (hInst) {
		(FARPROC&)gsGetSaveFileName = GetProcAddress(hInst, _T("gsGetSaveFileName"));
	}

	if (gsGetSaveFileName)
		fRet = gsGetSaveFileName(&ofn);
	else
		fRet = GetSaveFileName(&ofn);

	if (hInst) FreeLibrary(hInst);
#else
	OPENFILENAME ofn;
	memset(&(ofn), 0, sizeof(ofn));
	ofn.lStructSize	= sizeof(ofn);
	ofn.hwndOwner   = m_hWnd;
	ofn.lpstrFile   = szFile;
	ofn.nMaxFile    = MAX_PATH;	
	ofn.lpstrTitle  = strTitle;
	ofn.lpstrFilter = strFilter;
	ofn.lpstrDefExt = M3U_FILE_EXT;
	ofn.Flags       = OFN_EXPLORER | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT;
	ofn.lpstrInitialDir = m_pOptions->m_szLastDir;

	fRet = GetSaveFileName(&ofn);
#endif
	m_fShowOpenDlg = FALSE;
	if (!fRet)
		return;

	SavePlayList(szFile);
}
コード例 #8
0
ファイル: CServer.cpp プロジェクト: Azon099/networked-iv
void CServer::Process()
{
	// Get the current time
	unsigned long ulTime = SharedUtility::GetTime();

	// Is show fps enabled?
	if(m_bShowFPS)
	{
		// Get the amount of time elapsed since the last fps update
		unsigned long ulTimeElapsed = (ulTime - m_ulLastFPSUpdateTime);

		// Update the fps if a second or more has passed
		if(ulTimeElapsed >= 1000)
		{
			// Set the fps
			m_ulFramesPerSecond = m_ulFrameCount;

			// Set the server title
#ifdef WIN32
			String strTitle(SERVER_TITLE " - FPS: %d", m_ulFramesPerSecond);
			SetTitle(strTitle.C_String());
#endif

			// Reset the frame count
			m_ulFrameCount = 0;

			// Set the last fps update tick count
			m_ulLastFPSUpdateTime = ulTime;
		}

		// Increment the frame count
		m_ulFrameCount++;
	}

	// Process the network manager
	m_pNetworkManager->Process();

	// Process the resource manager
	m_pResourceManager->Process(ulTime);

	// Process the server lister
	m_pServerLister->Process();

	// Process the input queue
	ProcessInputQueue();

	/*if(GetAsyncKeyState(VK_F1) & 1)
	{
		MemoryInfo memoryInfo;
		GetMemoryInformation(memoryInfo);
#define BTOMB(bytes) (((bytes) / 1024) / 1024)
		printf("Total memory %dmb, avaiable memory %dmb, used memory %d, process used memory %dmb\n", BTOMB(memoryInfo.ulPhysicalTotalMemory), BTOMB(memoryInfo.ulPhysicalAvaliableMemory), BTOMB(memoryInfo.ulPhysicalUsedMemory), BTOMB(memoryInfo.ulProcessUsedMemory));
	}*/
}
コード例 #9
0
ファイル: GuideDoc.cpp プロジェクト: sandeep-datta/winguide
// Set proper name (just filename w/o extension) in title bar
void CGuideDoc::SetPathName(LPCTSTR lpszPathName,
   BOOL bAddToMRU)
{
	CString strTitle(lpszPathName);
	CDocument::SetPathName(lpszPathName, bAddToMRU);
	strTitle.Replace(L".gde", L"");
	int slashPos = strTitle.ReverseFind(L'\\');
	if (slashPos > 0 && slashPos <= strTitle.GetLength()-1)
		strTitle.Delete(0, slashPos+1);
	SetTitle(strTitle);
}
コード例 #10
0
ファイル: run.cpp プロジェクト: bihai/fbide
void MyFrame::CompilerLog () {
    //wxMessageBox( strCompilerOutput );
    wxString strTitle( "Fbc output" );
    wxDialog * dlg = new wxDialog( this, -1, strTitle,
                                   wxDefaultPosition, wxSize( 400, 200 ),
                                   wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxCLIP_CHILDREN | wxMAXIMIZE_BOX );
    wxBoxSizer * objSizer = new wxBoxSizer( wxVERTICAL );
    wxTextCtrl * output = new wxTextCtrl( dlg, wxID_ANY, "",
                                          wxDefaultPosition, wxDefaultSize,
                                          wxTE_MULTILINE | wxTE_READONLY | wxTE_BESTWRAP | wxTE_RICH2 );
    output->SetFont( wxFont( 10, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ) );
    objSizer->Add( output, 1, wxBOTTOM | wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 0 );

    wxTextAttr myattr=output->GetDefaultStyle();
    wxFont defFont = myattr.GetFont();
    wxFont boldFont = myattr.GetFont();
    boldFont.SetWeight( wxFONTWEIGHT_BOLD );
    bool nesting=false;
    wxString tag="";
    for(int i=0;i<(int)strCompilerOutput.Count();i++) {
        for(int j=0;j<(int)strCompilerOutput[i].Len();j++) {
            char thechar=(char)*strCompilerOutput[i].Mid(j,1);
            if(thechar=='['&&!nesting) {
                nesting=true;
            }
            else if(thechar==']'&&nesting) {
                nesting=false;
                tag=tag.MakeLower();
                if(tag=="bold")
                    myattr.SetFont(boldFont);
                else if(tag=="/bold")
                    myattr.SetFont(defFont);
                output->SetDefaultStyle(myattr);
                tag="";
            }
            else if(nesting) {
                tag+=thechar;
            }
            else {
                output->WriteText(thechar);
            }
        }
        output->WriteText("\r\n");
    }
    output->SetInsertionPoint( output->XYToPosition( 0, 0 ) );


    dlg->SetSizer( objSizer );
    dlg->Show();
}
コード例 #11
0
ファイル: EffectDlg.cpp プロジェクト: afriza/GSPlayer
void CEffectDlg::ShowEffectDlg(HWND hwndParent, HANDLE hMap)
{
	m_hMap = hMap;
	CTempStr strTitle(IDS_TITLE_EFFECT);

	PROPSHEETPAGE psp[4];
	memset(psp, 0, sizeof(psp));
	psp[0].dwSize = sizeof(PROPSHEETPAGE);
	psp[0].dwFlags = PSP_DEFAULT;
	psp[0].pszTemplate = MAKEINTRESOURCE(IDD_PAGE_EQUALIZER);
	psp[0].pfnDlgProc = (DLGPROC)EqualizerProc;
	psp[0].hInstance = GetInst();
	psp[0].pszIcon = NULL;
	psp[0].lParam = (LPARAM)this;
	psp[1].dwSize = sizeof(PROPSHEETPAGE);
	psp[1].dwFlags = PSP_DEFAULT;
	psp[1].pszTemplate = MAKEINTRESOURCE(IDD_PAGE_EFFECT);
	psp[1].pfnDlgProc = (DLGPROC)EffectProc;
	psp[1].hInstance = GetInst();
	psp[1].pszIcon = NULL;
	psp[1].lParam = (LPARAM)this;
	psp[2].dwSize = sizeof(PROPSHEETPAGE);
	psp[2].dwFlags = PSP_DEFAULT;
	psp[2].pszTemplate = MAKEINTRESOURCE(IDD_PAGE_REVERB);
	psp[2].pfnDlgProc = (DLGPROC)ReverbProc;
	psp[2].hInstance = GetInst();
	psp[2].pszIcon = NULL;
	psp[2].lParam = (LPARAM)this;
	psp[3].dwSize = sizeof(PROPSHEETPAGE);
	psp[3].dwFlags = PSP_DEFAULT;
	psp[3].pszTemplate = MAKEINTRESOURCE(IDD_PAGE_EFFECT_SAVE);
	psp[3].pfnDlgProc = (DLGPROC)PresetProc;
	psp[3].hInstance = GetInst();
	psp[3].pszIcon = NULL;
	psp[3].lParam = (LPARAM)this;
	
	PROPSHEETHEADER psh;
	psh.dwSize = sizeof(PROPSHEETHEADER);
	psh.dwFlags = PSH_PROPSHEETPAGE | PSH_NOAPPLYNOW | PSH_USECALLBACK;
	psh.pfnCallback = PropSheetCallback;
	psh.nPages = sizeof(psp) / sizeof(PROPSHEETPAGE);
	psh.nStartPage = 0;
	psh.pszIcon = NULL;
	psh.pszCaption = strTitle;
	psh.hwndParent = hwndParent;
	psh.hInstance = GetInst();
	psh.ppsp = psp;
	PropertySheet(&psh);
}
コード例 #12
0
void StyleHelper::drawListViewItemThumb(QPainter* p, const QRect& rc, int nBadgeType,
                                        const QString& title, const QString& lead, const QString& abs,
                                        bool bFocused, bool bSelected, bool bContainsAttach)
{
    QRect rcd(rc);

    QFont fontTitle = p->font();
    int nFontHeight = Utils::StyleHelper::fontHead(fontTitle);

    if (!title.isEmpty()) {
        QRect rcTitle = Utils::StyleHelper::drawBadgeIcon(p, rcd, nFontHeight, nBadgeType, bFocused, bSelected);

        int nSpace4AttachIcon = 20;
        rcTitle.setCoords(rcTitle.right(), rcTitle.y(), rcd.right() - nSpace4AttachIcon, rcd.bottom());
        QString strTitle(title);
        QColor colorTitle = Utils::StyleHelper::listViewItemTitle(bSelected, bFocused);
        QRect rcAttach = Utils::StyleHelper::drawText(p, rcTitle, strTitle, 1, Qt::AlignVCenter, colorTitle, fontTitle);

        if (bContainsAttach) {
            rcAttach.setCoords(rcAttach.right(), rcd.top(), rcd.right(), rcTitle.bottom());
            rcAttach.setHeight(nFontHeight);
            Utils::StyleHelper::drawAttachIcon(p, rcAttach, bFocused, bSelected);
        }

        rcd.adjust(0, rcAttach.height() + margin(), 0, 0);
    }

    QFont fontThumb;
    nFontHeight = Utils::StyleHelper::fontNormal(fontThumb);

    QRect rcLead;   //排序类型或标签等
    if (!lead.isEmpty()) {
        QString strInfo(lead);
        QColor colorDate = Utils::StyleHelper::listViewItemLead(bSelected, bFocused);
        rcLead = Utils::StyleHelper::drawText(p, rcd, strInfo, 1, Qt::AlignVCenter, colorDate, fontThumb);
    }

    if (!abs.isEmpty()) {          //  笔记内容
        QString strText(abs);
        QRect rcLine1(rcd.adjusted(rcLead.width(), 0, 0, 0));
        QColor colorSummary = Utils::StyleHelper::listViewItemSummary(bSelected, bFocused);
        rcLine1 = Utils::StyleHelper::drawText(p, rcLine1, strText, 1, Qt::AlignVCenter, colorSummary, fontThumb, false);

        if (!strText.isEmpty()) {
            QRect rcLine2(rcd.adjusted(0, rcLine1.height(), 0, 0));
            rcLine2 = Utils::StyleHelper::drawText(p, rcLine2, strText, 2, Qt::AlignVCenter, colorSummary, fontThumb);
        }
    }
}
コード例 #13
0
ファイル: MainWndCmd.cpp プロジェクト: afriza/GSPlayer
void CMainWnd::OnFileFind()
{
	TCHAR szPath[MAX_PATH] = {0};
#ifdef _WIN32_WCE
	CFolderDlg dlg;
	dlg.SetSubFolder(m_pOptions->m_fSearchSubFolders);
	if (dlg.ShowFolderDlg(m_hWnd, szPath, MAX_PATH) == IDCANCEL)
		return;

	m_pOptions->m_fSearchSubFolders = dlg.GetSubFolder();
#else
	CTempStr strTitle(IDS_TITLE_FIND_FILE);

	//フォルダ選択ダイアログの表示
	LPMALLOC pmalloc;
	LPITEMIDLIST lPIDL;
	LPITEMIDLIST pIDL;
	if (SUCCEEDED(SHGetMalloc(&pmalloc))) {
		if (SUCCEEDED(SHGetSpecialFolderLocation(NULL, CSIDL_DESKTOP, &lPIDL)))	{
			TCHAR szBuff[MAX_PATH];
			_tcscpy(szBuff, m_pOptions->m_szLastDir);
			BROWSEINFO binfo = {0};
			binfo.hwndOwner = m_hWnd;
			binfo.lpszTitle = strTitle;
			binfo.pidlRoot = lPIDL;
			binfo.pszDisplayName = szBuff;
			binfo.ulFlags = BIF_RETURNONLYFSDIRS;
			pIDL = SHBrowseForFolder(&binfo);
			if (pIDL)
				SHGetPathFromIDList(pIDL, szPath);
			pmalloc->Free(pIDL);
		}
		pmalloc->Release();
	}

	if (!_tcslen(szPath))
		return;
#endif
	_tcscpy(m_pOptions->m_szLastDir, szPath);
	AddDir(szPath);

	if (m_pPlayListDlg)
		m_pPlayListDlg->UpdatePlayList();
}
コード例 #14
0
void CCoolFormat3Doc::SetTitle(LPCTSTR lpszTitle)
{
	CString strTitle(lpszTitle);

	if (IsModified())
	{
		if (!m_bTitleMark)
		{
			m_bTitleMark = TRUE;
			strTitle += _T(" *");
		}
	} 
	else
	{
		if (m_bTitleMark)
		{
			strTitle.ReleaseBuffer(strTitle.GetLength() - 2);
			m_bTitleMark = FALSE;
		}
	}
	CDocument::SetTitle(strTitle.GetBuffer(0));
}
コード例 #15
0
//Decode selected .gnt file. in the file list.
void QxMainWindow::decodeSelected()
{
	QList<QListWidgetItem*> selectedItems = m_pFileListWidget->selectedItems();
	if (m_FileList.isEmpty() || selectedItems.size()==0)
	{
		QString strTitle("No selected files");
		QString strMessage("No files selected yet. Please select the file you want to decode.\n");
		strMessage.append("If there are no files listed in the file list, please press \"Open\" to select files first.");
		QMessageBox::information(this, strTitle, strMessage, QMessageBox::Ok);
		return;
	}
	QStringList fileList;
	for (QList<QListWidgetItem*>::iterator itr = selectedItems.begin(); itr != selectedItems.end(); ++itr)
	{
		fileList.push_back((*itr)->text());
	}
	QxDecodeOptionDlg dlg(fileList, this);
	if (dlg.exec() != QxDecodeOptionDlg::Accepted)
	{
		return;
	}

	// get selected application, image size, as well as image format
	unsigned uImageSize = dlg.imageSize();
	cv::Size imageSize(uImageSize, uImageSize);
	QString strImageFormat = dlg.imageFormat();
	QString strDestinationPath = dlg.filePath();
	QxDecodeOptionDlg::ApplicationType appType = dlg.application();

	//If files are successfully decode, show a messagebox to inform user.
	if (decodeFiles(fileList, strDestinationPath, strImageFormat, imageSize, appType))
	{
		QString strMessage("Files successfully decoded.");
		QMessageBox::information(this, "Result", strMessage, QMessageBox::Ok);
	}
}
コード例 #16
0
ファイル: CServer.cpp プロジェクト: Rukenshia/IV-Network
void CServer::Process()
{
	m_pNetworkModule->Pulse();


	// Pulse all managers
	// Seems like this slows the server extremely down (we process over 264000 entities) optimize compile?!
	// Do not worry about that some managers dont need to be pulsed its just that its complete and all the same structure
	m_pPlayerManager->Pulse();

	m_pVehicleManager->Pulse();

	m_pActorManager->Pulse();

	m_pObjectManager->Pulse();

	m_pFireManager->Pulse();

	m_pPickupManager->Pulse();

	m_p3DLabelManager->Pulse();

	m_pBlipManager->Pulse();

	m_pCheckpointManager->Pulse();

	// Get the current time
	unsigned long ulTime = SharedUtility::GetTime();

	// Is show fps enabled?
	if (m_bShowFPS)
	{
		// Get the amount of time elapsed since the last fps update
		unsigned long ulTimeElapsed = (ulTime - m_ulLastFPSUpdateTime);

		// Update the fps if a second or more has passed
		if (ulTimeElapsed >= 1000)
		{
			// Set the fps
			m_ulFramesPerSecond = m_ulFrameCount;

			// Set the server title
#ifdef _WIN32
			CString strTitle(" " VERSION_IDENTIFIER " Server"" - FPS: %d", m_ulFramesPerSecond);
			SetConsoleTitle(strTitle.Get());

#endif

			/// Calculate the delay to receive the maximum FPS set in server

			// Reset the frame count
			m_ulFrameCount = 0;

			// Set the last fps update tick count
			m_ulLastFPSUpdateTime = ulTime;
		}

		// Increment the frame count
		m_ulFrameCount++;
	}

	// This only works for 1-1000 but this is good
	delay = (1000.0f / (float)m_uiMaximumFPS) - (float) (ulTime - m_ulLastProcess);
	if (delay > 0)
		std::this_thread::sleep_for(std::chrono::microseconds((long long)(delay*1000)));

	

	m_ulLastProcess = SharedUtility::GetTime();
}
コード例 #17
0
// CSkinFrameWnd 訊息處理常式
void CSkinFrameWnd::OnNcPaint()
{
    // TODO: 在此加入您的訊息處理常式程式碼
    // 不要呼叫圖片訊息的 CFrameWndEx::OnNcPaint()
    CWindowDC dc(this);
    if (m_pBkImage == NULL)
    {
        return;
    }
    CDC MemDC; //記憶體DC
               //獲取位置
    CRect rcWindow;
    GetWindowRect(&rcWindow);
    rcWindow.OffsetRect(-rcWindow.left, -rcWindow.top);

    CRect rcClient;
    GetClientRect(&rcClient);

    //剪除掉客戶區
    rcClient.OffsetRect(m_nFrameWidth, m_nTitleHeight);
    dc.ExcludeClipRect(rcClient.left, rcClient.top,
        rcClient.right, rcClient.bottom);

    MemDC.CreateCompatibleDC(&dc);

    CBitmap bmp;
    bmp.CreateCompatibleBitmap(&dc, rcWindow.Width(), rcWindow.Height());
    MemDC.SelectObject(&bmp);
    MemDC.SetBkMode(TRANSPARENT);

    Gdiplus::Graphics graphics(MemDC.GetSafeHdc());
    RectF destRect;

    //繪製底部和邊框
    destRect.X = 0;
    destRect.Y = rcWindow.Height() - m_nFrameWidth;
    destRect.Width = rcWindow.Width();
    destRect.Height = m_nFrameWidth;
    graphics.DrawImage(m_pBkImage, destRect, m_nTitleHeight, m_pBkImage->GetHeight() - m_nFrameWidth, m_nFrameWidth, m_nFrameWidth, UnitPixel);

    destRect.X = rcWindow.right - m_nTitleHeight;
    destRect.Y = rcWindow.bottom - m_nTitleHeight;
    destRect.Width = m_nTitleHeight;
    destRect.Height = m_nTitleHeight;
    graphics.DrawImage(m_pBkImage, destRect, m_pBkImage->GetWidth() - m_nTitleHeight, m_pBkImage->GetHeight() - m_nTitleHeight, m_nTitleHeight, m_nTitleHeight, UnitPixel);

    destRect.X = 0;
    destRect.Y = rcWindow.Height() - m_nTitleHeight;
    destRect.Width = m_nTitleHeight;
    destRect.Height = m_nTitleHeight;
    graphics.DrawImage(m_pBkImage, destRect, 0, m_pBkImage->GetHeight() - m_nTitleHeight, m_nTitleHeight, m_nTitleHeight, UnitPixel);

    //左邊框
    destRect.X = 0;
    destRect.Y = m_nTitleHeight;
    destRect.Width = m_nFrameWidth;
    destRect.Height = rcWindow.Height() - 2 * m_nTitleHeight;
    graphics.DrawImage(m_pBkImage, destRect, 0, m_nTitleHeight, m_nFrameWidth, m_nFrameWidth, UnitPixel);


    //右邊框
    destRect.X = rcWindow.Width() - m_nFrameWidth;
    destRect.Y = m_nTitleHeight;
    destRect.Width = m_nFrameWidth;
    destRect.Height = rcWindow.Height() - 2 * m_nTitleHeight;
    graphics.DrawImage(m_pBkImage, destRect, m_pBkImage->GetWidth() - m_nFrameWidth, m_nTitleHeight, m_nFrameWidth, m_nFrameWidth, UnitPixel);

    //繪製標題欄
    destRect.X = 0;
    destRect.Y = 0;
    destRect.Width = rcWindow.Width();
    destRect.Height = m_nTitleHeight;
    graphics.DrawImage(m_pBkImage, destRect, 50, 0, 5, m_nTitleHeight, UnitPixel);
    graphics.DrawImage(m_pBkImage, 0, 0, 0, 0, 50, m_nTitleHeight, UnitPixel);
    graphics.DrawImage(m_pBkImage, rcWindow.Width() - 50, 0, m_pBkImage->GetWidth() - 50, 0, 50, m_nTitleHeight, UnitPixel);

    ///*標題列圖標*/
    int xPos = 5;
    int yPos = 5;
    HICON hIcon = (HICON)GetClassLongPtr(m_hWnd, GCLP_HICONSM);
    //HICON hIcon = GetIcon(FALSE);
    if (hIcon)
    {
        DrawIconEx(MemDC, xPos, yPos - 2, hIcon, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);

        xPos += GetSystemMetrics(SM_CXSMICON);
        xPos += 10;
    }

    /*標題列文字*/
    CString strText;
    GetWindowText(strText);
    if (!strText.IsEmpty())
    {
        LOGFONT lfFont;
        memset(&lfFont, 0, sizeof(lfFont));
        lfFont.lfHeight = -12;
        lfFont.lfWeight |= FW_BOLD;
        lstrcpy(lfFont.lfFaceName, _T(" 宋体"));
        Gdiplus::Font font(dc.GetSafeHdc(), &lfFont);

        StringFormat stringFormat;
        stringFormat.SetFormatFlags(StringFormatFlagsNoWrap);
        stringFormat.SetAlignment(StringAlignmentNear);
        stringFormat.SetLineAlignment(StringAlignmentNear);
        CStringW strTitle(strText);
        SolidBrush brush((ARGB)Color::White);
        PointF point;

        point.X = (Gdiplus::REAL)xPos;
        point.Y = (Gdiplus::REAL)yPos;
        graphics.DrawString(strTitle, strTitle.GetLength(), &font, point, &stringFormat, &brush);
    }
    dc.BitBlt(0, 0, rcWindow.Width(), rcWindow.Height(), &MemDC, 0, 0, SRCCOPY);
    dc.SelectClipRgn(NULL);
}
コード例 #18
0
void T3kSoftlogicDlg::init()
{
    QSettings settings( "Habilience", "T3kSoftlogic" );
    settings.beginGroup( "APP_SETTING" );
    bool bCheckInvertDrawing = settings.value( "INVERT_DRAWING", false ).toBool();
    settings.endGroup();
    onInvertDrawing( bCheckInvertDrawing );

    settings.beginGroup( "Windows" );
    QString strPos = settings.value( "Main_Pos" ).toString();
    settings.endGroup();
    if ( !strPos.isEmpty() )
    {
        QRect rcWin;
        QString str;
        int nD;
        do
        {
            nD = strPos.indexOf(',');
            if ( nD <= 0 ) break;
            str = strPos.left(nD); strPos = strPos.mid(nD + 1);
            rcWin.setLeft( str.toLong() );
            nD = strPos.indexOf(',');
            if ( nD <= 0 ) break;
            str = strPos.left(nD); strPos = strPos.mid(nD + 1);
            rcWin.setTop( str.toLong() );
            nD = strPos.indexOf(',');
            if ( nD <= 0 ) break;
            str = strPos.left(nD); strPos = strPos.mid(nD + 1);
            rcWin.setRight( str.toLong() );
            rcWin.setBottom( strPos.toLong() );
            rcWin = rcWin.normalized();

//            QRect rcCaption( rcWin );
//            rcCaption.adjust();  :GetSystemMetrics(SM_CXSIZEFRAME), ::GetSystemMetrics(SM_CYSIZEFRAME));
//            rcCaption.bottom = rcCaption.top + ::GetSystemMetrics(SM_CYCAPTION);
//            rcCaption.left += rcCaption.Height();
//            rcCaption.right -= rcCaption.Height() * 4;

            QDesktopWidget DeskWidget;
            bool bRet = false;
            for( int i=0; i<DeskWidget.screenCount(); i++ )
            {
                if( DeskWidget.screenGeometry( i ).contains( rcWin ) )
                {
                    move( rcWin.x(), rcWin.y() );
                    bRet = true;
                    break;
                }
            }
            if( !bRet )
            {
                QDesktopWidget DeskWidget;
                const QRect rcPrimaryMon = DeskWidget.screenGeometry( DeskWidget.primaryScreen() );
                move( (rcPrimaryMon.width()-width())/2, (rcPrimaryMon.height()-height())/2 );
            }
        }
        while ( false );
    }
    else
    {
        QDesktopWidget DeskWidget;
        const QRect rcPrimaryMon = DeskWidget.screenGeometry( DeskWidget.primaryScreen() );
        move( (rcPrimaryMon.width()-width())/2, (rcPrimaryMon.height()-height())/2 );
    }

    if ( g_bScreenShotMode )
    {
        QString strTitle( windowTitle() + " " );
        strTitle += T3K_VERSION;
        setWindowTitle( strTitle );
    }

    openT3kHandle();

    setAcceptDrops( true );

    ui->TabMainMenu->setCurrentIndex( m_nFirstActiveTab );
}
コード例 #19
0
ファイル: doc_construct.cpp プロジェクト: WillFa/mushclient
BOOL CMUSHclientDoc::OnNewDocument()
{
	if (!CDocument::OnNewDocument())
		return FALSE;

  SetDefaults (false);        // set up numeric/boolean defaults
  SetAlphaDefaults (false);   // set up alpha defaults

  if (App.m_TypeOfNewDocument == App.eNormalNewDocument) // only ask on normal new world
    {
    int i = ::TMessageBox ("Preload world defaults from an existing world?",
           MB_YESNOCANCEL | MB_ICONQUESTION);

    if (i == IDCANCEL)
      return FALSE;

    if (i == IDYES)
      while (TRUE)    // loop until successful read of file, or cancel
      {
	    // Get file
	    CString	strFilter(MAKEINTRESOURCE(IDS_OPEN_WORLD_FILTER));
	    CString	strTitle(MAKEINTRESOURCE(IDS_OPEN_WORLD_TITLE));
	    CFileDialog	dlg(TRUE,						// TRUE for FileOpen
					    NULL,						// default extension
					    NULL,						// no initial file name
					    OFN_HIDEREADONLY|OFN_FILEMUSTEXIST,
					    strFilter);
	    dlg.m_ofn.lpstrTitle = strTitle;

      // use default world file directory
      dlg.m_ofn.lpstrInitialDir = Make_Absolute_Path (App.m_strDefaultWorldFileDirectory);

      ChangeToFileBrowsingDirectory ();
      int nResult = dlg.DoModal();
      ChangeToStartupDirectory ();

      if (nResult != IDOK)
		    break;
	    CString	strFileName = dlg.GetPathName();

		  CWaitCursor	wait;

	    try
	      {

        // Open existing world file
		    CFile	fileWorld(strFileName, CFile::modeRead|CFile::shareDenyWrite);

        CArchive ar(&fileWorld, CArchive::load);

	      try
	        {
		      Serialize (ar);
	        }
	      catch(CException* e)
  	      {
          ::TMessageBox ("Unexpected file format - invalid world file", MB_ICONEXCLAMATION);
		      e->Delete();
          ar.Close();
          continue;
	        }

        ar.Close();

	      }
	    catch(CException* e)
  	    {
        ::TMessageBox ("Unable to open world file", MB_ICONEXCLAMATION);
		    e->Delete();
        continue;
	      }
    
  // if we got here, we successfully loaded the world!

      SetModifiedFlag ();
      m_strWorldID = GetUniqueID ();      // new world ID

      break;

      } // end of preloading defaults
  } // end of normal new world

   // if defaults are wanted, overwrite what we loaded with them :)
             
  if (m_bLoaded)
    OnFileReloaddefaults ();
  else
    {

    if (!App.m_strDefaultColoursFile.IsEmpty ())
      {
      m_bUseDefaultColours = true;
      Load_Set (COLOUR, App.m_strDefaultColoursFile, &Frame);
      }

    if (!App.m_strDefaultTriggersFile.IsEmpty ())
      {
      m_bUseDefaultTriggers = true;
      Load_Set (TRIGGER, App.m_strDefaultTriggersFile, &Frame);
      }

    if (!App.m_strDefaultAliasesFile.IsEmpty ())
      {
      m_bUseDefaultAliases = true;
      Load_Set (ALIAS, App.m_strDefaultAliasesFile, &Frame);
      }

    if (!App.m_strDefaultTimersFile.IsEmpty ())
      {
      m_bUseDefaultTimers = true;
      Load_Set (TIMER, App.m_strDefaultTimersFile, &Frame);
      }

    if (!App.m_strDefaultMacrosFile.IsEmpty ())
      {
      m_bUseDefaultMacros = true;
      Load_Set (MACRO, App.m_strDefaultMacrosFile, &Frame);
      }

    if (!App.m_strDefaultInputFont.IsEmpty ())
      {
      m_bUseDefaultInputFont = true;
      m_input_font_height = App.m_iDefaultInputFontHeight; 
      m_input_font_name = App.m_strDefaultInputFont;   
      m_input_font_italic = App.m_iDefaultInputFontItalic; 
      m_input_font_weight = App.m_iDefaultInputFontWeight;
      m_input_font_charset = App.m_iDefaultInputFontCharset;
      }   // end of input font override

    if (!App.m_strDefaultOutputFont.IsEmpty ())
      {
      m_bUseDefaultOutputFont = true;
      m_font_height = App.m_iDefaultOutputFontHeight; 
      m_font_name = App.m_strDefaultOutputFont;   
      m_font_weight = FW_NORMAL;
      m_font_charset = App.m_iDefaultOutputFontCharset;
    }   // end of output font override
    } // end of not loading an existing world

  m_bLoaded = false;    // not really loaded - effectively a new world

// get name and IP address, give up if cancelled

  if (App.m_TypeOfNewDocument == App.eQuickConnect) // pop up nice simple dialog box
    {
    CQuickConnectDlg dlg;
    dlg.m_iPort = 4000;
    dlg.m_strWorldName = "Untitled world";
    dlg.m_strAddress = "";
    if (dlg.DoModal () != IDOK)
      return FALSE;
    m_server = dlg.m_strAddress;
    m_port = dlg.m_iPort;
    m_mush_name = dlg.m_strWorldName;

    // save auto connect flag, then set to true, to make sure we connect
    unsigned int savebAutoConnectWorlds = App.m_bAutoConnectWorlds;
    App.m_bAutoConnectWorlds = TRUE;
    SetUpOutputWindow ();
    OpenSession ();
    App.m_bAutoConnectWorlds = savebAutoConnectWorlds;
    SetModifiedFlag ();
    return TRUE;
        
    } // end of quick connect

  if (App.m_TypeOfNewDocument == App.eTelnetFromNetscape) // just do it
    {
    // get rid of telnet stuff
    CString strCommandLine = ::Replace (App.m_lpCmdLine, "telnet://", "");
    int iSpace = strCommandLine.FindOneOf (" :");
    if (iSpace == -1)
      {
      m_server = strCommandLine;
      m_mush_name = strCommandLine;
      m_port = 23;
      }
    else
      {
      m_server = strCommandLine.Left (iSpace);
      m_mush_name = m_server;
      m_port = atoi (strCommandLine.Mid (iSpace + 1));
      }

    // save auto connect flag, then set to true, to make sure we connect
    unsigned int savebAutoConnectWorlds = App.m_bAutoConnectWorlds;
    App.m_bAutoConnectWorlds = TRUE;
    SetUpOutputWindow ();
    OpenSession ();
    App.m_bAutoConnectWorlds = savebAutoConnectWorlds;
    SetModifiedFlag ();
    return TRUE;
        
    } // end of telnet called from netscape navigator

  // we have to do this *before* getting the preferences
  SetUpOutputWindow ();

  if (!GamePreferences (ePageGeneral))
    return FALSE;

  if(m_mush_name.IsEmpty ())
    {
    ::TMessageBox("Your world name cannot be blank.", MB_ICONEXCLAMATION);
    return FALSE;
    }

  if(m_server.IsEmpty ())
    {
    ::TMessageBox("The world TCP/IP address cannot be blank.", MB_ICONEXCLAMATION);
    return FALSE;
    }


  OpenSession ();

  return TRUE;

  }
コード例 #20
0
void  CSkinWndHelper::DoNcPaint()
{
	CDC dc;
	HDC hdc = GetWindowDC(m_hWnd);
	dc.Attach(hdc);

	if (m_pBkImage==NULL)
	{
		return;
	}

	CDC MemDC;

	// 获取位置
	CRect rcWindow;
	GetWindowRect(m_hWnd,&rcWindow);
	rcWindow.OffsetRect( -rcWindow.left, -rcWindow.top);


	CRect rcClient;
	GetClientRect(m_hWnd,&rcClient);

	//剪除掉客户区
	rcClient.OffsetRect(m_nFrameWidth, m_nTitleHeight);
	dc.ExcludeClipRect(rcClient.left, rcClient.top,
		rcClient.right, rcClient.bottom);


	MemDC.CreateCompatibleDC(dc);


	CBitmap bmp;
	bmp.CreateCompatibleBitmap(dc,rcWindow.Width(),rcWindow.Height());
	MemDC.SelectBitmap(bmp);
	MemDC.SetBkMode(TRANSPARENT);

	Gdiplus::Graphics graphics(MemDC.m_hDC);
	RectF destRect;

	//绘制底部和边框
	destRect.X = 0;
	destRect.Y = rcWindow.Height() - m_nFrameWidth;
	destRect.Width = rcWindow.Width();
	destRect.Height = m_nFrameWidth;
	graphics.DrawImage(m_pBkImage,destRect,m_nTitleHeight,m_pBkImage->GetHeight()-m_nFrameWidth,m_nFrameWidth,m_nFrameWidth,UnitPixel);

	destRect.X = rcWindow.right-m_nTitleHeight;
	destRect.Y = rcWindow.bottom - m_nTitleHeight;
	destRect.Width = m_nTitleHeight;
	destRect.Height = m_nTitleHeight;
	graphics.DrawImage(m_pBkImage,destRect,m_pBkImage->GetWidth()-m_nTitleHeight,m_pBkImage->GetHeight()-m_nTitleHeight,m_nTitleHeight,m_nTitleHeight,UnitPixel);

	destRect.X = 0;
	destRect.Y = rcWindow.Height() - m_nTitleHeight;
	destRect.Width = m_nTitleHeight;
	destRect.Height = m_nTitleHeight;
	graphics.DrawImage(m_pBkImage,destRect,0,m_pBkImage->GetHeight()-m_nTitleHeight,m_nTitleHeight,m_nTitleHeight,UnitPixel);

	//左边框
	destRect.X = 0;
	destRect.Y = m_nTitleHeight;
	destRect.Width = m_nFrameWidth;
	destRect.Height = rcWindow.Height() - 2*m_nTitleHeight;
	graphics.DrawImage(m_pBkImage,destRect,0,m_nTitleHeight,m_nFrameWidth,m_nFrameWidth,UnitPixel);


	//右边框
	destRect.X = rcWindow.Width() - m_nFrameWidth;
	destRect.Y = m_nTitleHeight;
	destRect.Width = m_nFrameWidth;
	destRect.Height = rcWindow.Height() - 2*m_nTitleHeight;
	graphics.DrawImage(m_pBkImage,destRect,m_pBkImage->GetWidth()-m_nFrameWidth,m_nTitleHeight,m_nFrameWidth,m_nFrameWidth,UnitPixel);

	//绘制标题栏
	destRect.X = 0;
	destRect.Y = 0;
	destRect.Width = rcWindow.Width();
	destRect.Height = m_nTitleHeight;
	graphics.DrawImage(m_pBkImage,destRect,50,0,5,m_nTitleHeight,UnitPixel);
	graphics.DrawImage(m_pBkImage,0,0,0,0,50,m_nTitleHeight,UnitPixel);
	graphics.DrawImage(m_pBkImage,rcWindow.Width() - 50,0,m_pBkImage->GetWidth()-50,0,50,m_nTitleHeight,UnitPixel);


	int xPos = 15;
	int yPos = 15;

	HICON hIcon = (HICON)::SendMessage(m_hWnd, WM_GETICON, ICON_SMALL, 0);
	if (hIcon)
	{
		DrawIconEx(MemDC,xPos, yPos-2,hIcon,GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 0, 0, DI_NORMAL);

		xPos += GetSystemMetrics(SM_CXSMICON);
		xPos += 5;
	}

	CString strText;
	int nLen = ::GetWindowTextLength(m_hWnd);
	::GetWindowText(m_hWnd, strText.GetBufferSetLength(nLen), nLen+1);
	strText.ReleaseBuffer();

	if (!strText.IsEmpty())
	{
		//绘制标题
		LOGFONT lfFont;
		memset(&lfFont, 0, sizeof(lfFont));
		lfFont.lfHeight = -12;
		lfFont.lfWeight |= FW_BOLD;
		lstrcpy(lfFont.lfFaceName, _T("宋体"));
		Gdiplus::Font font(dc.m_hDC, &lfFont);

		StringFormat stringFormat;
		stringFormat.SetFormatFlags( StringFormatFlagsNoWrap);
		stringFormat.SetAlignment(StringAlignmentNear);
		stringFormat.SetLineAlignment(StringAlignmentNear);
		CStringW strTitle(strText);
		SolidBrush brush((ARGB)Color::White);
		PointF point;

		point.X=(Gdiplus::REAL)xPos;
		point.Y=(Gdiplus::REAL)yPos;
		graphics.DrawString(strTitle, strTitle.GetLength(), &font, point,&stringFormat, &brush);

	}

	CRect rcPaint;
	dc.GetClipBox(&rcPaint);
	std::map<int,CDUIButton>::iterator iter;
	for (iter = m_TitleBtn.begin(); iter != m_TitleBtn.end(); iter++)
	{
		CDUIButton& dcControl = iter->second;
		CRect rcControl;
		dcControl.GetRect(&rcControl);

		// 判断当前按钮是否需要重绘
		if(!rcPaint.IsRectEmpty() && !CRect().IntersectRect(&rcControl, rcPaint))
		{
			continue;
		}

		dcControl.DrawButton(graphics);
	}



	dc.BitBlt(0,0,rcWindow.Width(),rcWindow.Height(),MemDC,0,0,SRCCOPY);

	dc.SelectClipRgn(NULL);

	dc.Detach();

	ReleaseDC(m_hWnd,hdc);


}
コード例 #21
0
//Decoded .gnt files based on the parameters. Return true when successfully decoding the files.
bool QxMainWindow::decodeFiles(const QStringList& fileList, const QString& strDestinationPath, const QString& imageFormat, const cv::Size& imageSize, const QxDecodeOptionDlg::ApplicationType appType)
{
	// Create a sub-folder in the selected folder to save the decoded images.
	// If the folder already exists, ask user whether to append decoded images to it.
	QString strImagePath = strDestinationPath + "/" + g_ImageFolderName;
	if (!g_dirManager.exists(strImagePath)) 
	{ 
		g_dirManager.mkdir(strImagePath); 
	}
	else 
	{
		QString strTitle("Folder already exists");
		QString strMessage;
		strMessage.append("There is already a floder named \"").append(g_ImageFolderName).append("\" in the selected folder.\n");
		strMessage.append("Do you still want to save the decoded images to it?");
		QMessageBox::StandardButton button = QMessageBox::question(this, strTitle, strMessage, QMessageBox::Yes | QMessageBox::No);
		if (button != QMessageBox::Yes) { return false;	} 
	}

	// Remove former information, just in case the user does twice or more times decoding without restart the software.
	m_LabelCodeMap.clear();
	m_ImageLabelMap.clear();

	// decode files
	QStringList::size_type uFileAmount = fileList.size();
	QProgressDialog progressDlg("Decoding files...", "Cancel", 0, uFileAmount, this);
	progressDlg.setWindowModality(Qt::WindowModal);
	progressDlg.setMinimumDuration(0);
	for (QStringList::size_type i = 0; i != fileList.size(); ++i)
	{
		//Update progress dialog
		progressDlg.setValue(i);
		QApplication::processEvents();
		if (progressDlg.wasCanceled())
		{
			saveMappingFile(strDestinationPath, appType);
			saveLabelFile(strDestinationPath, appType);
			return false;
		}

		//Error handling
		QString strFileName = fileList.at(i);
		QFile file(strFileName);
		if (!file.open(QIODevice::ReadOnly))
		{
			QString strTitle("Open file error");
			QString strErrorMessage = "Cannot open selected file:\nFile name: " + strFileName + "\nContinue decoding the remaining files? ";
			QMessageBox::StandardButton button = QMessageBox::information(this, strTitle, strErrorMessage, QMessageBox::Yes | QMessageBox::No);
			if (button == QMessageBox::Yes) { continue; }
			else { return false; }
		}

		//Decode .gnt file specified by strFileName.
		QByteArray rawData = file.readAll();
		file.close();
		quint32 uDecodedByteNum = 0;
		const quint32 uTotalByteNum = rawData.size();
		while (uDecodedByteNum != uTotalByteNum)
		{
			quint32 uTagCode = uchar(rawData.at(5 + uDecodedByteNum)) + quint32(uchar(rawData.at(4 + uDecodedByteNum))) * (1 << 8);
			quint32 uWidth = uchar(rawData.at(6 + uDecodedByteNum)) + quint32(uchar(rawData.at(7 + uDecodedByteNum))) * (1 << 8);
			quint32 uHeight = uchar(rawData.at(8 + uDecodedByteNum)) + quint32(uchar(rawData.at(9 + uDecodedByteNum))) * (1 << 8);
			quint32 uArcLen = uWidth > uHeight ? uWidth : uHeight;
			uDecodedByteNum += 10;
			/* A character should be presented in a square. However, decoded images are, in most cases, rectangle.
			  Therefore, a decoded character image is padded to a square whose length of the side is uArcLen (longer edge of the rectangle). 
			  As the background of the decoded images is white (pixel value 255 for 8-bit grayscale images), all the padded pixels are set to be 255.  */
			cv::Mat img = 255 * cv::Mat::ones(uArcLen, uArcLen, CV_8UC1);
			int iHalfPadRowNum = (uArcLen - uHeight) / 2;
			int iHalfPadColNum = (uArcLen - uWidth) / 2;
            for (quint32 row = iHalfPadRowNum; row < uHeight + iHalfPadRowNum; ++row)
			{
				uchar *pRow = img.ptr<uchar>(row);
                for (quint32 col = iHalfPadColNum; col < uWidth + iHalfPadColNum; ++col)
				{
					pRow[col] = uchar(rawData.at(uDecodedByteNum++));
				}
			}
			// update mapping table, because label of the input images should, optimally, start from 0 and be consecutive.
			if (!m_LabelCodeMap.contains(uTagCode))
			{
				quint32 uNewLabel = m_LabelCodeMap.size();
				m_LabelCodeMap[uTagCode] = uNewLabel;
			}
			// image normalization and saving
			QString strSaveFileName = getSaveImageName(strImagePath, uTagCode, i + 1, appType);
			strSaveFileName += "." + imageFormat;
			cv::resize(img, img, imageSize);
			cv::imwrite(strSaveFileName.toStdString(), img);
			m_ImageLabelMap[strSaveFileName] = m_LabelCodeMap[uTagCode];
		}
	}
	// Save the .txt files for different software
	saveMappingFile(strDestinationPath, appType);
	saveLabelFile(strDestinationPath, appType);
	progressDlg.setValue(uFileAmount); 
	return true;
}
コード例 #22
0
/*----------------------------------------------------------------------------------------------
	Check to see if the edit box has valid data.  if so return true.  If not then put up a
	message to the user, then return false.
----------------------------------------------------------------------------------------------*/
bool CleDeFeString::IsOkToClose(bool fWarn)
{
	CleMainWnd * pcmw = dynamic_cast<CleMainWnd *>(m_qadsc->MainWindow());
	Assert(pcmw);

	IVwSelectionPtr qvwsel;
	CheckHr(m_qrootb->get_Selection(&qvwsel));
	if (qvwsel)
	{
		ComBool fOk;
		CheckHr(qvwsel->Commit(&fOk));
	}

	PossListInfoPtr qpli = pcmw->GetPossListInfoPtr();
	int ipss = qpli->GetIndexFromId(m_hvoObj);
	StrUni stuNew;

	const OLECHAR * prgwch;
	int cch;
	ITsStringPtr qtss;
	CustViewDaPtr qcvd;

	GetDataAccess(&qcvd);
	AssertPtr(qcvd);
	int ws = m_qsvc->WritingSystems()[0];

	CheckHr(qcvd->get_MultiStringAlt(m_hvoObj, m_flid, ws, &qtss));
	Assert(qtss);
	qtss->LockText(&prgwch, &cch);
	qtss->UnlockText(prgwch);

	// Trim leading and trailing space characters.
	UnicodeString ust(prgwch, cch);
	ust.trim();
	stuNew.Assign(ust.getBuffer(), ust.length());

	//  Obtain pointer to IOleDbEncap interface.
	IOleDbEncapPtr qode;
	IOleDbCommandPtr qodc;
	StrUni stuSql;
	ComBool fIsNull;
	ComBool fMoreRows;
	AssertPtr(m_qadsc->MainWindow());
	AfLpInfo * plpi = m_qadsc->MainWindow()->GetLpInfo();
	AssertPtr(plpi);
	AfDbInfo * pdbi = plpi->GetDbInfo();
	AssertPtr(pdbi);
	pdbi->GetDbAccess(&qode);
	AssertPtr(qode);
	CheckHr(qode->CreateCommand(&qodc));
	int cpii = qpli->GetCount();

	if ((m_flid == kflidCmPossibility_Name) || (m_flid == kflidCmPossibility_Abbreviation))
	{
		// Make sure it does not have a ":" or a " - " in the string
		int ich = stuNew.FindStr(L":");
		StrUni stuTmp;
		bool fFixed = false;
		while (ich > 0)
		{
			stuNew.Replace(ich,ich + 1,"-");
			fFixed = true;
			ich = stuNew.FindStr(L":");
		}
		ich = stuNew.FindStr(L" - ");
		while (ich > 0)
		{
			stuNew.Replace(ich,ich + 3,"-");
			fFixed = true;
			ich = stuNew.FindStr(L" - ");
		}
		if (fFixed)
		{
			if (fWarn)
			{
				ITsStrFactoryPtr qtsf;
				qtsf.CreateInstance(CLSID_TsStrFactory);
				qtsf->MakeStringRgch(stuNew.Chars(), stuNew.Length(), pcmw->UserWs(), &qtss);
				CheckHr(qcvd->SetMultiStringAlt(m_hvoObj, m_flid, ws, qtss));
				CheckHr(qcvd->PropChanged(NULL, kpctNotifyAll, m_hvoObj, m_flid, 0, 1, 1));
				StrApp strMsg(kstidFixedStr);
				StrApp strTitle(kstidFixedStrTitle);
				::MessageBox(m_hwnd, strMsg.Chars(), strTitle.Chars(),
					MB_OK | MB_ICONINFORMATION);
			}
			return false;
		}
	}

	if (qpli->GetAllowDup())
		return true;

	ILgWritingSystemFactoryPtr qwsf;
	pdbi->GetLgWritingSystemFactory(&qwsf);
	AssertPtr(qwsf);
	switch (m_flid)
	{
		case kflidCmPossibility_Name:
		{
			for (int ipii = 0; ipii < cpii; ipii++)
			{
				if (ipii == ipss)
					continue;
				PossItemInfo * ppii = qpli->GetPssFromIndex(ipii);
				AssertPtr(ppii);
				StrUni stu;
				ppii->GetName(stu, kpntName);
				if (stu == stuNew)
				{
					stuSql.Format(L"select ws from CmPossibility_Name "
						L"where obj = %d and ws = %d",
						ppii->GetPssId(), ws);
					CheckHr(qode->CreateCommand(&qodc));
					CheckHr(qodc->ExecCommand(stuSql.Bstr(), knSqlStmtSelectWithOneRowset));
					CheckHr(qodc->GetRowset(0));
					CheckHr(qodc->NextRow(&fMoreRows));

					if (fMoreRows)
					{
						if (fWarn)
						{
							// this name already exists
							IWritingSystemPtr qws;
							CheckHr(qwsf->get_EngineOrNull(ws, &qws));
							AssertPtr(qws);
							SmartBstr sbstr;
							qws->get_Name(ws, &sbstr);

							StrUni stu(kstidDupItemName);
							StrUni stuMsg;
							stuMsg.Format(stu,sbstr.Chars());
							StrApp str(stuMsg);
							StrApp strTitle(kstidDupItemTitle);
							::MessageBox(m_hwnd, str.Chars(), strTitle.Chars(),
								MB_OK | MB_ICONINFORMATION);
						}
						return false;
					}
				}
			}
			break;
		}
		case kflidCmPossibility_Abbreviation:
		{
			for (int ipii = 0; ipii < cpii; ipii++)
			{
				if (ipii == ipss)
					continue;
				PossItemInfo * ppii = qpli->GetPssFromIndex(ipii);
				AssertPtr(ppii);
				StrUni stu;
				ppii->GetName(stu, kpntAbbreviation);
				if (stu == stuNew)
				{
					stuSql.Format(L"select ws from CmPossibility_Abbreviation "
						L"where obj = %d and ws = %d",
						ppii->GetPssId(), ws);
					CheckHr(qode->CreateCommand(&qodc));
					CheckHr(qodc->ExecCommand(stuSql.Bstr(), knSqlStmtSelectWithOneRowset));
					CheckHr(qodc->GetRowset(0));
					CheckHr(qodc->NextRow(&fMoreRows));

					if (fMoreRows)
					{
						if (fWarn)
						{
							// this abbreviation already exists
							IWritingSystemPtr qws;
							CheckHr(qwsf->get_EngineOrNull(ws, &qws));
							AssertPtr(qws);
							SmartBstr sbstr;
							qws->get_Name(ws, &sbstr);

							StrUni stu(kstidDupItemAbbr);
							StrUni stuMsg;
							stuMsg.Format(stu,sbstr.Chars());
							StrApp str(stuMsg);
							StrApp strTitle(kstidDupItemTitle);
							::MessageBox(m_hwnd, str.Chars(), strTitle.Chars(),
								MB_OK | MB_ICONINFORMATION);
						}
						return false;
					}
				}
			}
			break;
		}
	}
	return true;
}
コード例 #23
0
UINT CheckNotify(LPVOID ps) //检查系统中是否有通知
{
	_RecordsetPtr rec1;
	UINT Flag=0;
	CString strSql,strTitle("");
	if(FAILED(rec1.CreateInstance( __uuidof( Recordset ))))
	{
		AfxMessageBox("初始化 全局线程Recordset失败...");
		return false ;
	}
	CString strFileName;
	strFileName.Format("%s",LoginInformation.path);
	strFileName+="RingIN.wav";

	try{
		while(true){
/***********管理员可以杀死当前登录用户**********************/
			strSql.Format("SELECT count(*) FROM lsq_log_operator WHERE logid='%s' AND killflag='1' ",theApp.strLogID);
			rec1->Open(_bstr_t(strSql),(IDispatch*)HospitalConnect,adOpenDynamic,adLockOptimistic,adCmdText); 
			if(!rec1->adoEOF){
				strSql=(char*)_bstr_t(rec1->GetFields()->GetItem(0L)->Value);
				rec1->Close();
				if( atol(strSql) != 0 ){

					AfxMessageBox("您已被管理人员禁用当前系统!!!如有疑问,请联系管理人员",MB_OK|MB_ICONSTOP);
				//	AfxGetMainWnd()->MessageBox("您已被管理人员禁用当前系统!!!如有疑问,请联系管理人员","test",MB_OK|MB_ICONSTOP);
					::SendMessage(AfxGetMainWnd()->m_hWnd,WM_CLOSE,0,0);
					return false;
				}
			}else
				rec1->Close();
/***********************************************************************/		
			Flag=0;
			strSql.Format("select * from LSQ_NOTIFY_BODY a ,LSQ_NOTIFY_LIST b \
				WHERE a.ID=b.ID and B.RYBM='%s' and B.READTIME is NULL ",\
				LoginInformation.user_code);
			rec1->Open(_bstr_t(strSql),(IDispatch*)HospitalConnect,adOpenDynamic,adLockOptimistic,adCmdText); 
			if(!rec1->adoEOF){

				::sndPlaySound(strFileName,SND_ASYNC|SND_LOOP|SND_NODEFAULT);
				if( MessageBox(NULL,"是否阅读 ????","Hello! You have a Message from your messageBox",MB_OKCANCEL)==IDOK )
				{
					strSql=(char*)_bstr_t(rec1->GetCollect("BODY").vt == VT_NULL ? " ":rec1->GetCollect("BODY"));
					strTitle=(char*)_bstr_t(rec1->GetCollect("TITLE").vt == VT_NULL ? " " :rec1->GetCollect("TITLE"));
					
					
				}
				else strTitle="";
				Flag=1;
				
				::sndPlaySound(NULL,SND_ASYNC|SND_LOOP|SND_NODEFAULT);

			}
			rec1->Close();

			if(! strTitle.IsEmpty() ){
				CDMessageRead read;
				read.DoModal();
				strTitle="";
				
			}
			
			Sleep(30*ONESECOND); //延时20秒
		
			
			
		}
		
	}
	catch(_com_error e)
	{
		rec1->Close();
		AfxMessageBox(strSql);
		return false;
	}



}
コード例 #24
0
ファイル: MainWndCmd.cpp プロジェクト: afriza/GSPlayer
BOOL CMainWnd::OpenMediaFile(BOOL fAdd, HWND hwndParent)
{
	if (m_fShowOpenDlg)
		return FALSE;

	BOOL fRet;

	m_fShowOpenDlg = TRUE;
	CTempStr strTitle(fAdd ? IDS_TITLE_ADD_FILE : IDS_TITLE_OPEN_FILE);
	CTempStr strFilter;
	TCHAR szFile[FILE_BUFF_LEN] = {0};
#ifdef _WIN32_WCE
	OPENFILENAME ofn;
	memset(&(ofn), 0, sizeof(ofn));
	ofn.lStructSize	= sizeof(ofn);
	ofn.hwndOwner   = hwndParent ? hwndParent : m_hWnd;
	ofn.lpstrFile   = szFile;
	ofn.nMaxFile    = FILE_BUFF_LEN;	
	ofn.lpstrTitle  = strTitle;

	BOOL (*gsGetOpenFileName)(OPENFILENAME*) = NULL;
	HINSTANCE hInst = LoadLibrary(_T("gsgetfile.dll"));
	if (hInst) {
		(FARPROC&)gsGetOpenFileName = GetProcAddress(hInst, _T("gsGetOpenFileName"));
	}

	if (gsGetOpenFileName) {
		if (!m_pszOpenFilter) MakeOpenFilter(&m_pszOpenFilter, TRUE);
		ofn.lpstrFilter = m_pszOpenFilter;
		ofn.Flags       = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY;
		ofn.lpstrInitialDir = m_pOptions->m_szLastDir;
		fRet = gsGetOpenFileName(&ofn);
	}
	else {
		if (!m_pszOpenFilter) MakeOpenFilter(&m_pszOpenFilter, FALSE);
		ofn.lpstrFilter = m_pszOpenFilter;
		ofn.Flags       = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
		ofn.lpstrInitialDir = m_pOptions->m_szLastDir;
		fRet = GetOpenFileName(&ofn);
	}

	if (hInst) FreeLibrary(hInst);
#else
	if (!m_pszOpenFilter) MakeOpenFilter(&m_pszOpenFilter, TRUE);

	OPENFILENAME ofn;
	memset(&(ofn), 0, sizeof(ofn));
	ofn.lStructSize	= sizeof(ofn);
	ofn.hwndOwner   = hwndParent ? hwndParent : m_hWnd;
	ofn.lpstrFile   = szFile;
	ofn.nMaxFile    = FILE_BUFF_LEN;	
	ofn.lpstrTitle  = strTitle;
	ofn.lpstrFilter = m_pszOpenFilter;
	ofn.Flags       = OFN_EXPLORER | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_HIDEREADONLY;
	ofn.lpstrInitialDir = m_pOptions->m_szLastDir;

	fRet = GetOpenFileName(&ofn);

#endif
	m_fShowOpenDlg = FALSE;
	if (!fRet)
		return FALSE;

	// 既存のリストを削除
	if (!fAdd) DeleteAllFile();

	// 追加
	DWORD dw = GetFileAttributes(szFile);
	if (dw != 0xFFFFFFFF) {
		if (!(dw & FILE_ATTRIBUTE_DIRECTORY)) {
			// single
			if (IsPlayList(szFile))
				LoadPlayList(szFile);
			else 
				AddFile(szFile);
			LPTSTR psz = _tcsrchr(szFile, _T('\\'));
			if (psz) *psz = _T('\0');
				_tcscpy(m_pOptions->m_szLastDir, szFile);
		}
		else {
			// multi
			TCHAR szPath[MAX_PATH];

			LPTSTR p = szFile;
			_tcscpy(m_pOptions->m_szLastDir, szFile);
			while (TRUE) {
				p += _tcslen(p);
				if (*p != NULL || *(p + 1) == NULL)
					break;

				wsprintf(szPath, _T("%s\\%s"), m_pOptions->m_szLastDir, ++p);
				if (IsPlayList(szPath))
					LoadPlayList(szPath);
				else
					AddFile(szPath);
			}
		}
	}
	return TRUE;
}