Esempio n. 1
0
//控件绘制事件处理方法
void CLedCtrl::OnPaint() 
{
	// TODO: Add your message handler code here
	
	// Do not call CStatic::OnPaint() for painting messages
	GetClientRect(&m_recClient);

	CPaintDC dc(this);
	CMemDC memDC(&dc, m_recClient);
	CMemDC* pDC = &memDC;

	CRect clip;
	pDC->GetClipBox(&clip);
	pDC->FillSolidRect(&m_recClient, m_crColorBackground );

	for (int nCount = 0; nCount< m_strNumber.GetLength(); nCount++)
	{
		if (m_bDrawFadedNotches)
			Draw( pDC, STCOUNTERALL, nCount );	// Draw the faded bits

		//CString str = m_strNumber[nCount];
		if ( m_strNumber[nCount] == _T('0') )	Draw( pDC, STCOUNTER0, nCount );
		else if ( m_strNumber[nCount] == _T('1') )	Draw( pDC, STCOUNTER1, nCount );
		else if ( m_strNumber[nCount] == _T('2') )	Draw( pDC, STCOUNTER2, nCount );
		else if ( m_strNumber[nCount] == _T('3') )	Draw( pDC, STCOUNTER3, nCount );
		else if ( m_strNumber[nCount] == _T('4') )	Draw( pDC, STCOUNTER4, nCount );
		else if ( m_strNumber[nCount] == _T('5') )	Draw( pDC, STCOUNTER5, nCount );
		else if ( m_strNumber[nCount] == _T('6') )	Draw( pDC, STCOUNTER6, nCount );
		else if ( m_strNumber[nCount] == _T('7') )	Draw( pDC, STCOUNTER7, nCount );
		else if ( m_strNumber[nCount] == _T('8') )	Draw( pDC, STCOUNTER8, nCount );
		else if ( m_strNumber[nCount] == _T('9') )	Draw( pDC, STCOUNTER9, nCount );
		else if ( m_strNumber[nCount] == _T('-') )	Draw( pDC, STCOUNTER10, nCount );
		else if ( m_strNumber[nCount] == _T(':') )	Draw( pDC, STCOUNTER11, nCount );
	}
}
Esempio n. 2
0
void CScreenViewWnd::OnLButtonDblClk(UINT nFlags, CPoint point)
{
	CDialog::OnLButtonDblClk(nFlags, point);

	if (!valid_camera(_selectCamera)) {
		return;
	}

	_sync_drawing.Lock();

	_frameQueue.clear();	// frame_buffer clear

	CClientDC dc(this);
	CMemDC MemDC;
	MemDC.CreateDC(&dc, &_bmpCanvas);
	MemDC->FillSolidRect(_rectScreen, RGB(0, 0, 0));
	MemDC.DeleteDC();

	UINT32 cameraList = 0;
	if (_fuse1x1Mode == false) {
		// 1x1 mode setting
		_fuse1x1Mode = true;
		setScreenLayout(ScreenFormatter::LAYOUT_1X1, _selectCamera, _rectScreen);

		// watch for only selected camera
		cameraList |= 1 << _selectCamera;
	}
	else {
		_fuse1x1Mode = false;

		setScreenLayout(_countLiveCamera);

		for (int i = 0; i < _countLiveCamera; ++i) {
			CameraView& rcamera = _cameraView[i];
			if (rcamera.is_visible()) {
				cameraList |= 1 << i;
			}
		}
	}

	_sync_drawing.Unlock();

	CWnd* lpParent = GetParent();
	if (lpParent != NULL &&
		lpParent->GetSafeHwnd()) {
		lpParent->PostMessage(UM_SCREEN_DBLCLICK,
							  static_cast<WPARAM>(cameraList),
							  static_cast<LPARAM>(MAX_CAMERA_COUNTS));
	}

	Invalidate(FALSE);
}
Esempio n. 3
0
void CScreenViewWnd::clearScreen()
{
	_sync_drawing.Lock();

	for (int i = 0; i < _countCamera; i++) {
		_cameraView[i].resetCamera();
	}

	_selectCamera = -1;
	_countLiveCamera = __min(_countCamera, 16);

	CDC* pDC = GetDC();
	CMemDC MemDC;
	MemDC.CreateDC(pDC, &_bmpCanvas);
	MemDC->FillSolidRect(_rectScreen, RGB(0, 0, 0));
	MemDC.DeleteDC();
	ReleaseDC(pDC);

	_sync_drawing.Unlock();

	Invalidate(TRUE);
}
Esempio n. 4
0
void CScreenViewWnd::updateStatus(int camera)
{
	if (GetSafeHwnd() == NULL) {
		return;
	}

	_sync_drawing.Lock();

	if (_fuse1x1Mode == true &&
		_selectCamera != camera) {
		_sync_drawing.Unlock();
		return;
	}

	if (!_cameraView[camera].is_visible()) {
		_sync_drawing.Unlock();
		return;
	}

	int camstatus = getCameraState(camera);

	CClientDC dc(this);
	CMemDC MemDC;
	MemDC.CreateDC(&dc, &_bmpCanvas);

	const CRect& rctcamera = _cameraView[camera].rect();
	if (camstatus != CameraView::ENABLED) {
		MemDC->FillSolidRect(rctcamera, (camstatus == CameraView::NO_VIDEO) ? RGB(0, 0, 255) : RGB(0, 0, 0));
	}

	CString strStatus = _T("");
	switch (camstatus)	{
		case CameraView::NO_VIDEO :
			strStatus = _T("No Video");
			break;
		case CameraView::NOT_CONNECTED:
			strStatus = _T("Not Connected");
			break;
		case CameraView::COVERT_LEVEL1 :
			strStatus = _T("Covert");
			break;
		case CameraView::COVERT_LEVEL2 :
			strStatus = _T("");
			break;
	}

	CRect rctosd = rctcamera;
	rctosd.DeflateRect(5, 2, 5, 3);

	CFont* lpFontPrev = MemDC->SelectObject(&_fontText);
	drawText(&MemDC, strStatus, rctosd, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
	drawText(&MemDC, getCameraTitle(camera), rctosd, DT_LEFT | DT_TOP | DT_SINGLELINE);
	MemDC->SelectObject(lpFontPrev);

	MemDC->Draw3dRect(rctcamera, RGB(255, 255, 255), RGB(255, 255, 255));

	dc.BitBlt(rctcamera.left, rctcamera.top,
			  rctcamera.Width(), rctcamera.Height(),
			  &MemDC,
			  rctcamera.left, rctcamera.top,
			  SRCCOPY);

	_sync_drawing.Unlock();
}
Esempio n. 5
0
void CScreenViewWnd::drawImage(int camera,
							   LPBYTE pImage,
							   const CSize& size,
							   SDK_TIME_T time)
{
	CameraView& rcamView = _cameraView[camera];

	_sync_drawing.Lock();

	if (!rcamView.is_visible() ||
		!rcamView.is_enable()) {
		_sync_drawing.Unlock();
		return;
	}

	_bmpInfohead.biWidth     = size.cx;
	_bmpInfohead.biHeight    = size.cy;
	_bmpInfohead.biSizeImage = size.cx * size.cy * _bmpInfohead.biBitCount >> 3;

	CDC* pDC = GetDC();

	if ((size.cx > 0) && (size.cy > 0)) {

		CMemDC MemDC;
		ASSERT(_bmpCanvas.m_hObject);
		MemDC.CreateDC(pDC, &_bmpCanvas);

		CRect rctDest = rcamView.rect();

		CRect rctImage = rctDest;
		if (_fuseAspectRatio) {
			imageAspectRatio(size.cx, size.cy, rctImage, rctImage);
			if (rcamView.rectImage() != rctImage) {
				MemDC->FillSolidRect(rctDest, RGB(0, 0, 0));
			}
			else {
				const int letter_t = rctImage.top    - rctDest.top;
				const int letter_b = rctDest.bottom - rctImage.bottom;
				const int letter_l = rctImage.left   - rctDest.left;
				const int letter_r = rctDest.right  - rctImage.right;

				if (letter_t > 1 || letter_b > 1 ||
					letter_l > 1 || letter_r > 1) {
					if (letter_t > 0) {
						MemDC->FillSolidRect(rctDest.left + 1, rctDest.top,
									rctDest.Width() - 2, letter_t,
									RGB(0, 0, 0));
					}
					if (letter_b > 0) {
						MemDC->FillSolidRect(rctDest.left + 1, rctImage.bottom,
									rctDest.Width() - 2, letter_b,
									RGB(0, 0, 0));
					}
					if (letter_l > 0) {
						MemDC->FillSolidRect(rctDest.left + 1, rctImage.top,
									letter_l, rctImage.Height(), 
									RGB(0, 0, 0));
					}
					if (letter_r > 0) {
						MemDC->FillSolidRect(rctImage.right, rctImage.top,
									letter_r, rctImage.Height(),
									RGB(0, 0, 0));
					}
				}
			}
		}

		rcamView.setRectImage(rctImage);

		::DrawDibDraw(_hDrawDib, MemDC,
					  rctImage.left, rctImage.top,
					  rctImage.Width(), rctImage.Height(),
					  &_bmpInfohead,
					  pImage,
					  0, 0,
					  size.cx, size.cy,
					  0);

		drawReferLines(&MemDC);

		CRect rctOSD = rctDest;
		rctOSD.DeflateRect(5, 2, 5, 3);

		CTime tmFrame(time);
		CString strTime = (rctOSD.Width() < 140) ?
							tmFrame.Format(_T("%H:%M:%S")) :
							tmFrame.Format(_T("%y-%m-%d %H:%M:%S"));

		CString strTitle = getCameraTitle(camera);

		/*
		CFont* lpFontPrev = MemDC->SelectObject(&_fontText);
		drawText(&MemDC, strTitle, rctOSD, DT_TOP | DT_LEFT | DT_SINGLELINE);
		drawText(&MemDC, strTime,  rctOSD, DT_BOTTOM | DT_CENTER | DT_SINGLELINE);
		MemDC->SelectObject(lpFontPrev);
		*/

		COLORREF clrBorder = (_selectCamera == camera) ?
					RGB(0, 255, 0) : RGB(255, 255, 255);

		MemDC->Draw3dRect(rctDest, clrBorder, clrBorder);

		pDC->BitBlt(rctDest.left, rctDest.top,
					rctDest.Width(), rctDest.Height(),
					&MemDC,
					rctDest.left, rctDest.top,
					SRCCOPY);
	}

	ReleaseDC(pDC);

	_sync_drawing.Unlock();
}