Esempio n. 1
0
void CRectangle::DrawSquare(Graphics& graph,CRect rc)
{
	Pen penDraw(m_crColor,(float)m_nWidth);
	if(m_bFinish)
	{
		graph.DrawRectangle(&penDraw,rc.left,rc.top,rc.Width(),rc.Height());
	}
	else
	{
		float fWidth = (float)min(rc.Width(),rc.Height());
		float fleft = 0,ftop = 0;
		if(m_ptary[0].X <= m_ptary[1].X)
		{
			fleft = m_ptary[0].X;
		}
		else 
		{
			fleft = m_ptary[0].X - fWidth;
		}
		if(m_ptary[0].Y <= m_ptary[1].Y)
		{
			ftop = m_ptary[0].Y;
		}
		else
		{
			ftop = m_ptary[0].Y - fWidth;
		}
		graph.DrawRectangle(&penDraw,fleft,ftop,fWidth,fWidth);
	}
}
Esempio n. 2
0
HRESULT CIGFrameControl::OnDraw(ATL_DRAWINFO& di)
{
	if (!m_spFrame)
		return S_OK;
	m_spFrame->Render (di.hdcDraw);
	RECT& rc = *(RECT*)di.prcBounds;
	Graphics graphics (di.hdcDraw);
	int nFramePosX = 0;
	int nFramePosY = 0;
	int nFramePosWidth = 0;
	int nFramePosHeight = 0;
	m_spFrame->GetFramePos (nFramePosX, nFramePosY, nFramePosWidth, nFramePosHeight);
	SolidBrush brushFrameOut (m_spFrame->GetSelected() ? IGFRAME_FRAMEOUT_SELECTED : IGFRAME_FRAMEOUT);
	graphics.FillRectangle (&brushFrameOut, Rect (2, 2,
											rc.right - rc.left - 4, nFramePosY - 2));
	graphics.FillRectangle (&brushFrameOut, Rect (2, nFramePosY,
											nFramePosX - 2, rc.bottom - rc.top - nFramePosY - 2));
	graphics.FillRectangle (&brushFrameOut, Rect (nFramePosX, nFramePosY + nFramePosHeight,
											nFramePosWidth, rc.bottom - rc.top - (nFramePosY + nFramePosHeight) - 2));
	graphics.FillRectangle (&brushFrameOut, Rect (nFramePosX + nFramePosWidth, nFramePosY,
											rc.right - rc.left - (nFramePosX + nFramePosWidth) - 2, rc.bottom - rc.top - nFramePosY - 2));
	Pen penFrameBorder (IGFRAME_FRAMEBORDER, 1);	
	graphics.DrawRectangle (&penFrameBorder, Rect (nFramePosX - 1, nFramePosY - 1,
											nFramePosWidth + 1, nFramePosHeight + 1));
	Pen penIn (m_spFrame->GetSelected() ? IGFRAME_BORDER_SELECTED : IGFRAME_BORDER_INCOLOR, 1);
	Pen penOut (m_spFrame->GetSelected() ? IGFRAME_BORDER_SELECTED : IGFRAME_BORDER_OUTCOLOR, 1);	
	graphics.DrawRectangle (&penOut, Rect (0, 0,
											rc.right - rc.left - 1, rc.bottom - rc.top - 1));
	graphics.DrawRectangle (&penIn, Rect (1, 1,
											rc.right - rc.left - 3, rc.bottom - rc.top - 3));
	return S_OK;
}
void CIGWorkspaceButtonPanel::drawButton (HWND hWnd, HDC hDC, IGLibrary::IGFrame *pCxButtonIcon)
{
	if (pCxButtonIcon)
	{
		pCxButtonIcon->LayerDrawAllInClearedCache (hDC, 0, 0, -1, -1, 0, false, false, false, RGB (0, 0, 0));

		// test if mouse is over the current button
		if ((m_eButtonState == IGBUTTON_MOUSEOVER)
			&& (hWnd == m_hOverButton))
		{
			Graphics graphics (hDC);
			int nButtonSize = pCxButtonIcon->GetWidth();
			Rect rcGdiButton = Rect (0, 0,
									nButtonSize - 1,
									nButtonSize - 1);
			// draw blue square in mouseover mode
			SolidBrush solBrushButton (IGWORKSPACE_COLOR_BUTTON);
			graphics.FillRectangle (&solBrushButton, rcGdiButton);
			Pen penButtonBorder (IGWORKSPACE_COLOR_BUTTONBORDER);
			graphics.DrawRectangle (&penButtonBorder, rcGdiButton);
		}

		// draw button icon
		if (m_eButtonState == IGBUTTON_MOUSEOVER)
			pCxButtonIcon->LayerDrawAllFromCache (hDC, 0, 0, IGWORKSPACEBUTTONPANEL_ALPHAOVER, RGB (0, 0, 0));
		else
			pCxButtonIcon->LayerDrawAllFromCache (hDC, 0, 0, IGWORKSPACEBUTTONPANEL_ALPHANORMAL, RGB (0, 0, 0));
	}
}
Esempio n. 4
0
void CAguraDlgBlue::gradationCenter(Graphics& g, CRect rt, Color& color1, Color& color2, BOOL bLine, Color& color3)
{
	GraphicsPath gPath;

	int iHeight = rt.Width() / 4;
	int iWidth = rt.Width() / 4;

	RectF rtF((REAL)rt.left - iWidth, (REAL)rt.top - iHeight, (REAL)rt.Width() + iWidth * 2, (REAL)rt.Height() + iHeight * 2);
	gPath.AddEllipse(rtF);
	gPath.CloseFigure();

	PathGradientBrush PGB(&gPath);
	PGB.SetCenterColor(color1); //would be some shade of blue, following your example
	int colCount = 1;
	PGB.SetSurroundColors(&color2, &colCount); //same as your center color, but with the alpha channel set to 0

	//play with these numbers to get the glow effect you want
	REAL blendFactors[] = {0.0f, 0.1f, 0.3f, 1.0f};
	REAL blendPos[] = {0.0f, 0.4f, 0.6f, 1.0f};
	//sets how transition toward the center is shaped
	PGB.SetBlend(blendFactors, blendPos, 4);
	//sets the scaling on the center. you may want to have it elongated in the x-direction
	PGB.SetFocusScales(0.2f, 0.2f);

	RectF rtDraw((REAL)rt.left, (REAL)rt.top, (REAL)rt.Width(), (REAL)rt.Height());
	g.FillRectangle(&PGB, rtDraw);

	if (bLine == TRUE)
	{
		Pen pen(color3, 1);
		g.DrawRectangle(&pen, rtDraw);
	}
}
Esempio n. 5
0
void Component::paint( Graphics& g )
{
	if ( needsOwnerDraw() == FALSE ) return; 

	if ( isLightWeight() == FALSE )
	
		mSize = getSize();

	// default paiting code for leight-weight components

	wxBrush br( wxColour( 255, 255, 255 ), wxSOLID );
	wxPen pen ( wxColour( 255,   0,   0 ), 1, wxSOLID );

	g.SetBrush( br );
	g.SetPen( pen );

	g.DrawRectangle( 0,0, mSize.width, mSize.height );

	if ( mName != "" ) 
	{
		g.SetClippingRegion( 2,2, mSize.width-4, mSize.height-4 );

		long w = 0, h = 0;
		g.GetTextExtent( mName, &w, &h );

		g.DrawText( mName, ( mSize.width  - w ) / 2, 
						   ( mSize.height - h ) / 2  );

		g.DestroyClippingRegion();
	}
}
Esempio n. 6
0
void
MFCInstanceView::Draw(Graphics &dc, CRect &clipBox)
{
// !!!??? need to clip properly for short instances with long names
	Pen			blackPen(AlphaColor(250, rgb_black), 1);
	Pen			redPen(AlphaColor(250, rgb_red), 1);
	SolidBrush	blueBrush(AlphaColor(100, rgb_blue));
	SolidBrush	blackBrush(AlphaColor(100, rgb_black));

	CRect		clipBounds = bounds;
	if (clipBox.left > bounds.left) clipBounds.left = clipBox.left-1;
	if (clipBox.right < bounds.right) clipBounds.right = clipBox.right+1;

	cerr << "ondraw instance view " << clipBox.left << ", " << clipBox.right << endl;
	dc.FillRectangle(&blueBrush,
			bounds.left, bounds.top, bounds.right-bounds.left, bounds.bottom-bounds.top);
	dc.DrawRectangle(selected?&redPen:&blackPen,
			bounds.left, bounds.top, clipBounds.right-bounds.left, bounds.bottom-bounds.top);
	Font	labelFont(L"Arial", 8.0, FontStyleRegular, UnitPoint, NULL);
	wstring nm;
	const char *cp = instance->sym->uniqueName();
	while (*cp) { nm.push_back(*cp++); }
	float lbx = bounds.left+2;
#define LBLSEP 200
	if (clipBox.left > lbx) {
		int nld = clipBox.left - lbx;
		nld = nld/LBLSEP;
//		if (nld > 2) lbx += (nld-2)*LBLSEP;
	}
	PointF	p(lbx, clipBounds.top);
	do {
		dc.DrawString(nm.c_str(), -1, &labelFont, p, &blackBrush);
		p.X += LBLSEP;
	} while (p.X < clipBounds.right);
}
void CIGPropertyManager::DrawBackground (const RECT& rcWnd, Graphics& graphics)
{
	static SolidBrush backgroundBrush (IGPROPERTYMANAGER_COLOR_BACKGROUND);
	Rect rectBackgroundItem (0, 0,
		rcWnd.right - rcWnd.left - 1, rcWnd.bottom - rcWnd.top - 1);
	graphics.FillRectangle (&backgroundBrush, rectBackgroundItem);
	Pen penBorder (IGPROPERTYMANAGER_COLOR_BORDER);
	graphics.DrawRectangle (&penBorder, rectBackgroundItem);
}
Esempio n. 8
0
void CRectView::Draw(CDC* pDC, const std::vector<CElement*>& selection, CElement* highlight)
{
	Pen pen(ColorToDraw(selection, highlight), penWidth);
	SolidBrush brush(fillColor);

	Graphics g = pDC->GetSafeHdc();
	g.FillRectangle(&brush, *this);
	g.DrawRectangle(&pen, *this);
}
Esempio n. 9
0
void CZoneView::DrawZone(CDC* pDC, const std::vector<CElement*>& selection, CElement* highlight) const
{
	Graphics g = pDC->GetSafeHdc();
	Pen pen(ColorToDraw(selection, highlight), 1);
	//Arrondir les angles avec GDI+, possible ?
	SolidBrush brush(Color::MakeARGB(100, fillColor.GetR(), fillColor.GetG(), fillColor.GetB()));
	Rect visibleRect(*this);
	visibleRect.Inflate(-3, -3);
	g.FillRectangle(&brush, visibleRect);
	g.DrawRectangle(&pen, visibleRect);
}
Esempio n. 10
0
void
MFCEditorItemView::Draw(Graphics &dc, CRect &clipBox)
{
// !!!??? need to clip properly for short instances with long names
	Pen			blackPen(Color(250, 0,0,0), 1);
	Pen			redPen(Color(250, 160, 10, 10), 1);
	SolidBrush	blueBrush(Color(100, 10, 10, 160));
	SolidBrush	blackBrush(Color(100, 0,0,0));

//	fprintf(stderr, "drawing instance view %d\n", bounds.right-bounds.left);
	dc.FillRectangle(&blueBrush, bounds.left, bounds.top, bounds.right-bounds.left, bounds.bottom-bounds.top);
	dc.DrawRectangle(selected?&redPen:&blackPen, bounds.left, bounds.top, bounds.right-bounds.left, bounds.bottom-bounds.top);
}
Esempio n. 11
0
void UIButton::onPaintFrame(Graphics& graphics, Rect rect)
{
    Pen pen(m_button.m_frameColor, m_button.m_frameWidth);
    switch (m_buttonType)
    {
    case UITYPE_BUTTON_RECTANGLE:
        graphics.DrawRectangle(&pen, rect);
        break;
    case UITYPE_BUTTON_CIRCLE:
        graphics.DrawEllipse(&pen, rect);
        break;
    default:
        break;
    }
}
void CIGImageLibrary::drawListBoxItem (HDC hDC, int nItemId)
{
	RECT rcItem;
	::ZeroMemory (&rcItem, sizeof (RECT));
	::SendMessageW (m_hListBox, (UINT)LB_GETITEMRECT, (WPARAM)nItemId, (LPARAM)&rcItem);  
	if ((rcItem.right > 0) && (rcItem.left < IGIMAGELIBRARY_LISTBOXWIDTH))
	{
		HBITMAP hBmp = (HBITMAP)::SendMessageW (m_hListBox, (UINT)LB_GETITEMDATA, (WPARAM)nItemId, 0);  
		if (!hBmp)
			return;
		BITMAP bitmapInfo;
		::ZeroMemory (&bitmapInfo, sizeof (BITMAP));
		::GetObject (hBmp, sizeof (BITMAP), &bitmapInfo);
		HBITMAP hBmpItem = ::CreateCompatibleBitmap (hDC, 
														bitmapInfo.bmWidth, 
														bitmapInfo.bmHeight); 
		HBITMAP hOldBmp = (HBITMAP)::SelectObject (hDC, hBmpItem);

		HDC hdcCompatible = ::CreateCompatibleDC (hDC); 
		::SelectObject (hdcCompatible, hBmp);
		int nItemPosX = (IGIMAGELIBRARY_ITEMWIDTH - bitmapInfo.bmWidth) / 2;
		int nItemPosY = (IGIMAGELIBRARY_ITEMHEIGHT - bitmapInfo.bmHeight) / 2;

		::BitBlt (hDC, 
				   rcItem.left + nItemPosX, rcItem.top + nItemPosY, 
				   bitmapInfo.bmWidth, bitmapInfo.bmHeight, 
				   hdcCompatible, 
				   0, 0, 
				   SRCCOPY);
		::SelectObject (hDC, hOldBmp);
		::DeleteDC (hdcCompatible);
		::DeleteObject (hBmpItem);

		int nIsSelected = (int)::SendMessageW (m_hListBox, (UINT)LB_GETSEL, (WPARAM)nItemId, 0);  
		if (nIsSelected > 0)
		{
			Graphics graphics (hDC);
			SolidBrush selectItemBrush (IGIMAGELIBRARY_COLOR_SELECTITEM);
			int nBmpMaxSize = bitmapInfo.bmWidth > bitmapInfo.bmHeight ? bitmapInfo.bmWidth : bitmapInfo.bmHeight;
			Rect rectItem (rcItem.left + (IGIMAGELIBRARY_ITEMHEIGHTSEPARATOR) / 2
							, rcItem.top + (IGIMAGELIBRARY_ITEMHEIGHTSEPARATOR) / 2
							, nBmpMaxSize, nBmpMaxSize);
			graphics.FillRectangle (&selectItemBrush, rectItem);
			Pen penBorder (IGIMAGELIBRARY_COLOR_BORDERSELECTITEM);
			graphics.DrawRectangle (&penBorder, rectItem);			
		}
	}
}
Esempio n. 13
0
LRESULT CIGHistoryManager::OnBackgroundPaint (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	RECT rcWnd;
	GetWindowRect (&rcWnd);
	PAINTSTRUCT ps;
	HDC hDC = ::BeginPaint (m_hWnd, &ps);
	Graphics graphics (hDC);	
	static SolidBrush backgroundBrush (IGHISTORYMANAGER_COLOR_BACKGROUND);
	Rect rectBackgroundItem (0, 0,
							rcWnd.right - rcWnd.left - 1, rcWnd.bottom - rcWnd.top - 1);
	graphics.FillRectangle (&backgroundBrush, rectBackgroundItem);
	static Pen penBorder (IGHISTORYMANAGER_COLOR_BORDER);
	graphics.DrawRectangle (&penBorder, rectBackgroundItem);
	::EndPaint (m_hWnd, &ps);
	bHandled = TRUE;
	return 0L;
}
void CToolRegularRuler::DrawHotShape(Graphics& graph)
{
	SolidBrush sbrush(Color::Green);
	Pen penDraw(Color::Blue, 2);
	penDraw.SetDashStyle(DashStyleDot);

	PointF pt((m_ptary[0].X + m_ptary[1].X) / 2, m_ptary[0].Y);
	
	graph.DrawLine(&penDraw, pt, m_HotPts.ptRotate);
	graph.FillEllipse(&sbrush, m_HotPts.ptRotate.X - HOTINTERVAL,
					  m_HotPts.ptRotate.Y - HOTINTERVAL,
					  2.0 * HOTINTERVAL, 2.0 * HOTINTERVAL);

	penDraw.SetDashStyle(DashStyleDash);
	penDraw.SetColor(Color::Red);

	graph.DrawRectangle(&penDraw, m_rcGrip.left, m_rcGrip.top, m_rcGrip.Width(), m_rcGrip.Height());
}
Esempio n. 15
0
void DrawRect(LPRECT prc, HDC hdcPaint, DashStyle dashStyle, Color clr, REAL width)
{
    Pen*         myPen;
    Graphics*    myGraphics;
    myPen = new Pen(clr, width);
    if(myPen)
    {
        myPen->SetDashStyle(dashStyle);
        myGraphics = new Graphics(hdcPaint);
        if(myGraphics)
        {
            myGraphics->DrawRectangle(myPen, prc->left, prc->top, 
                prc->right - 1 - prc->left, prc->bottom - 1 - prc->top);
            delete myGraphics;
        }
        delete myPen;
    }
}
Esempio n. 16
0
void CDrawWarn::Draw(CDC* pDC)
{
	ASSERT_VALID(this);
	CRect rect = m_position;
	rect.NormalizeRect();

	if(rect.Width() < 10 || rect.Height()<10)
		return;

	Rect GdiRect (rect.TopLeft().x,rect.TopLeft().y,rect.Size().cx,rect.Size().cy); 

	Color crBackColor,crTitleColor,crLineColor,crTextColor ;
	crBackColor.SetFromCOLORREF(m_ctlBackColor);
	crTitleColor.SetFromCOLORREF(m_ctlTitleColor );
	crLineColor.SetFromCOLORREF(m_ctlLineColor);
	crTextColor.SetFromCOLORREF(m_ctlTextColor);

	Graphics graphics (pDC->m_hDC);
	graphics.SetSmoothingMode (SmoothingModeHighSpeed);
	Graphics Textgraphics (pDC->m_hDC);
	SolidBrush  solidBrush(crBackColor);
	SolidBrush  TitleBrush(crTitleColor);
	SolidBrush  TextBrush(crTextColor);
	Pen pen(crLineColor,1);
	
	graphics.FillRectangle(&solidBrush,GdiRect);

        		BSTR bstr = m_fontName.AllocSysString();
///	BSTR bstr = _com_util::ConvertStringToBSTR(m_fontName);
	FontFamily  fontFamily(bstr);
   	SysFreeString(bstr);
	Font font(&fontFamily, m_fontSize, m_fontStyle, UnitPoint);

	for(int j =1; j<= m_nColCount; j++)
	{
		m_nCellWidth = 0;
		for(int i=1; i<= m_nRowCount; i++)
		{
			CRect rc = rect;
			if(m_bIsAutoSize)
			{
				m_nCellWidth = rect.Width()/m_nRowCount;
				m_nCellHeight = rect.Height()/m_nColCount;
				rc.TopLeft().x += (i-1)*m_nCellWidth;
				rc.TopLeft().y += (j-1)*m_nCellHeight;
				m_CellRect = CRect(rc.TopLeft(),CSize(m_nCellWidth,m_nCellHeight));
				m_CellRect.NormalizeRect();
			}
			else
			{
				rc.TopLeft().x += m_nCellWidth;
				m_nCellWidth += rect.Width()*m_nPercent[i-1]/100;
				m_nCellHeight = rect.Height()/m_nColCount;
				rc.TopLeft().y += (j-1)*m_nCellHeight;	
				m_CellRect = CRect(rc.TopLeft(),CSize(rect.Width()*m_nPercent[i-1]/100,m_nCellHeight));
				m_CellRect.NormalizeRect();
			}

			Rect CellRect(m_CellRect.TopLeft().x,m_CellRect.TopLeft().y,m_CellRect.Size().cx,m_CellRect.Size().cy);

			graphics.DrawRectangle(&pen,CellRect);
			
			if(j == m_nColCount)	//画标题
			{
				StringFormat stringFormat;
				stringFormat.SetAlignment(StringAlignmentCenter);
				stringFormat.SetLineAlignment(StringAlignmentCenter);
				stringFormat.SetFormatFlags(StringFormatFlagsDirectionRightToLeft);
				stringFormat.SetTrimming(m_trimmingSyle);

				CString m_strButton;
				if(i == 1)
					m_strButton = "点号";
				if(i == 2)
					m_strButton = "数据";
				if(i == 3)
					m_strButton = "说明";
				if(i == 4)
					m_strButton = "报警原因";
				if(i == 5)
					m_strButton = "时间";

				m_strButton.TrimRight();
        		bstr = m_strButton.AllocSysString();
///				bstr = _com_util::ConvertStringToBSTR(m_strButton);
				RectF theRect (m_CellRect.TopLeft().x,m_CellRect.TopLeft().y,m_CellRect.Size().cx,m_CellRect.Size().cy);
				Matrix matrix(1,0,0,-1,0,0);
				Textgraphics.SetTransform(&matrix);
				
				theRect.Y *=-1;
				theRect.Height*=-1;
				Normallize (theRect);	
				Textgraphics.FillRectangle(&TitleBrush,theRect);
				Textgraphics.DrawString(bstr,-1,&font, theRect,&stringFormat, &TextBrush);
            	SysFreeString(bstr);
			}
			else 
			{					//画文字  m_CStrWarn      pStrWarn
				StringFormat stringFormat;
				stringFormat.SetAlignment(StringAlignmentNear);
				stringFormat.SetLineAlignment(StringAlignmentNear);

            	CString  strWarn;
/*				if(i == 1)
					strWarn = m_CStrWarn[j].strPoint;
				if(i == 2)
					strWarn = m_CStrWarn[j].strDate;
				if(i == 3)
					strWarn = m_CStrWarn[j].strTime;
				if(i == 4)
					strWarn = m_CStrWarn[j].strText;
				if(i == 5)
					strWarn = m_CStrWarn[j].strWarn;
*/
				strWarn.TrimRight();
        		bstr = strWarn.AllocSysString();
///				bstr = _com_util::ConvertStringToBSTR(strWarn);

				RectF theRect (m_CellRect.TopLeft().x,m_CellRect.TopLeft().y,m_CellRect.Size().cx,m_CellRect.Size().cy);
				Matrix matrix(1,0,0,-1,0,0);
				Textgraphics.SetTransform(&matrix);
				
				theRect.Y *=-1;
				theRect.Height*=-1;
				Normallize (theRect);	
				Textgraphics.DrawString(bstr,-1,&font, theRect,&stringFormat, &TextBrush);
             	SysFreeString(bstr);
			}			
		}
	}
	graphics.ReleaseHDC(pDC->m_hDC);
}
void MyPaint_Mem(HDC my_hdc)
{
	Graphics *mygraphics;
	mygraphics = new Graphics(my_hdc);
	mygraphics->SetSmoothingMode(SmoothingModeAntiAlias);
	Pen *myRectangle_pen;
	Pen * my_inline_pen;

	Pen * CurePen;

	SolidBrush *BlackBrush;
	

	myRectangle_pen = new Pen(Color(255,0,255,255));
	my_inline_pen = new Pen(Color(255,220,220,220));

	REAL dashValues[2] = {5, 5};
	//Pen blackPen(Color(255, 0, 0, 0), 5);
	my_inline_pen->SetDashPattern(dashValues, 2);


	CurePen = new Pen(Graphic_Color[1],3.0f);
	PointF      pointF(0, 0);

	BlackBrush =new SolidBrush(Color(255,0,0,0));
	mygraphics->FillRectangle(BlackBrush,X_ORIGIN,Y_ORIGIN,X_WIDTH,Y_HIGHT);
	mygraphics->DrawRectangle(myRectangle_pen,X_ORIGIN,Y_ORIGIN,X_WIDTH,Y_HIGHT);

	SolidBrush *Static_blackground_Brush;
	Pen *mystaticRectangle_pen;
	mystaticRectangle_pen = new Pen(Color(255,0,0,0),2.0f);
	Static_blackground_Brush =new SolidBrush(Color(255,187,187,187));
	mygraphics->FillRectangle(Static_blackground_Brush,0,window_hight - 120,window_width,120);
	mygraphics->DrawRectangle(mystaticRectangle_pen,2,window_hight - 110,window_width-15,110 -30);

	SolidBrush  time_brush(Color(255, 225, 225, 225));
	FontFamily  fontFamily(_T("Times New Roman"));
	Gdiplus::Font        time_font(&fontFamily, 18, FontStyleRegular, UnitPixel);
	for(int i=0;i<x_line_scale;i++)				//画网格线
	{
		mygraphics->DrawLine(my_inline_pen,X_ORIGIN+(X_WIDTH/x_line_scale)*(i+1),Y_ORIGIN,X_ORIGIN+(X_WIDTH/x_line_scale)*(i+1),Y_ORIGIN + Y_HIGHT);
		CString strTime ;
		wchar_t temp_char[200];
		//time_t test = old_early_time;
		//CTime timeTest(test);
		time_t test ;
		CTime timeTest;

		switch(scale_type)
		{
		case _6_min:
			break;
		case _1_hour:
			test = old_early_time + i*600;

			timeTest = test ;

			strTime = timeTest.Format("%Y/%m/%d\r\n %H:%M:%S");
			pointF.X = X_ORIGIN - 40 + i*(X_WIDTH/x_line_scale);
			pointF.Y = Y_ORIGIN+Y_HIGHT + 10;
			mygraphics->DrawString(strTime, -1, &time_font, pointF, &time_brush);
			//old_early_time
			break;
		case _4_hour:
			break;
		case _12_hour:
			break;
		case _1_day:
			break;
		}

	}
	SolidBrush  unit_brush(Graphic_Color[1]);
	FontFamily  UnitfontFamily(_T("Times New Roman"));
	Gdiplus::Font        unitfont(&UnitfontFamily, 18, FontStyleRegular, UnitPixel);
	for(int i=0;i<=y_line_scale;i++)				//画网格线
	{
		CString Unit_value;
		if(i!=y_line_scale)
		mygraphics->DrawLine(my_inline_pen,X_ORIGIN,Y_ORIGIN+(Y_HIGHT/y_line_scale)*(1+i),X_WIDTH + X_ORIGIN,Y_ORIGIN+(Y_HIGHT/y_line_scale)*(1+i));

		if(i!=y_line_scale)
		Unit_value.Format(_T("%d"),(Total_SCALE/y_line_scale)*(y_line_scale-i));// = timeTest.Format("%Y/%m/%d\r\n %H:%M:%S");
		else
		Unit_value.Format(_T("%d"),Min_Scale_value);
		pointF.X = X_ORIGIN - 30;
		pointF.Y = Y_ORIGIN+ i*(Y_HIGHT/y_line_scale);
		mygraphics->DrawString(Unit_value, -1, &unitfont, pointF, &unit_brush);
		//swprintf_s(temp_char,200,L"%d",i*5);
		//mygraphics->DrawString(temp_char, -1, &font, pointF, &brush);

	}
	for (int i=1;i<=14;i++)
	{
		CString temp_item;
		temp_item.Format(_T("%x"),i);
		temp_item = temp_item.MakeUpper();

		SolidBrush  static_item_brush(Graphic_Color[i]);
		FontFamily  UnitfontFamily(_T("Arial Black"));
		Gdiplus::Font        unitfont(&UnitfontFamily, 22, FontStyleRegular, UnitPixel);
		pointF.X = Static_Num_Rect[i].left;
		pointF.Y = Static_Num_Rect[i].top;
		mygraphics->DrawString(temp_item, -1, &unitfont, pointF, &static_item_brush);
	}
	

	CPointItem *first_item=NULL,*second_item=NULL,*third_item=NULL;
	first_item = m_pFirstItem;
	//********************************************
	//直线
	for (int i=0;i<60;i=i+1)
	{
		second_item=first_item->GetNext();
		if(second_item==NULL)
			break;
		CurePen->SetStartCap(LineCapArrowAnchor);
		CurePen->SetEndCap(LineCapRoundAnchor);
		mygraphics->DrawLine(CurePen,first_item->GetPoint().x,first_item->GetPoint().y,second_item->GetPoint().x,second_item->GetPoint().y);
		first_item = second_item;

	}
	//********************************************

#if 0
	for (int i=0;i<60;i=i+2)
	//for (int i=0;i<m_monitor_block.index - 1;i=i+2)	//画贝塞尔曲线,使得线条平滑;3个点一画;		TEST
	//for (int i=0;i<Total_count-1;i=i+2)	//画贝塞尔曲线,使得线条平滑;3个点一画;
	{
		second_item=first_item->GetNext();
		third_item = second_item->GetNext();
		if(second_item==NULL)
			break;
		if(third_item == NULL)
		{
			first_item = second_item;
			break;
		}
		//mygraphics->DrawCurve(CurePen,, 3, 1.5f);
		//取3个点给画曲线的GDI函数;
		Point myPointArray[] =
		{Point(first_item->GetPoint().x,first_item->GetPoint().y),
		Point(second_item->GetPoint().x,second_item->GetPoint().y),
		Point(third_item->GetPoint().x,third_item->GetPoint().y)};

		CurePen->SetStartCap(LineCapArrowAnchor);
		CurePen->SetEndCap(LineCapRoundAnchor);


			mygraphics->DrawCurve(CurePen,myPointArray, 3, 1.0f);
			first_item = third_item;

		
	}
#endif

	delete CurePen;
	delete mygraphics;
	delete myRectangle_pen;
	delete my_inline_pen;
	delete BlackBrush;
}
void MyPaint_Mem(HDC my_hdc)
{

	Graphics *mygraphics;
	mygraphics = new Graphics(my_hdc);
	mygraphics->SetSmoothingMode(SmoothingModeAntiAlias);
	Pen *myRectangle_pen;
	Pen * my_inline_pen;

	Pen * CurePen;

	SolidBrush *BlackBrush;


	myRectangle_pen = new Pen(Color(255,0,255,255));
	my_inline_pen = new Pen(Color(255,0,128,64));

	CurePen = new Pen(Color(255,0,255,0));

	m_interval = (m_interval++)%5;	//让其向左平移;


	if(runonce < 2)				//初始化时画背景图案;
	{
		runonce ++;
		//Image myImage(L"texture.BMP");
		//TextureBrush myTextureBrush(&myImage);
		//RECT newrect_now;
		//GetWindowRect(myhWnd,&newrect_now);
		//mygraphics->FillRectangle(&myTextureBrush, 0, 0, newrect_now.right, newrect_now.bottom);


		SolidBrush  brush(Color(255, 0, 0, 255));
		FontFamily  fontFamily(_T("Times New Roman"));
		Gdiplus::Font        font(&fontFamily, 24, FontStyleRegular, UnitPixel);
		PointF      pointF(40.0f, 600.0f);
		for(int i=0;i<=20;i=i+2)				//增加文字 %;
		{
			pointF.Y = 600;
			pointF.Y = pointF.Y - i*30;
			wchar_t temp_char[200];
			//swprintf_s(temp_char,200,L"%d%%",i*5);
			swprintf_s(temp_char,200,L"%d",i*5);
			mygraphics->DrawString(temp_char, -1, &font, pointF, &brush);
		}
		pointF.X = 200;
		pointF.Y = 650;
		//mygraphics->DrawString(L"CPU 使用率", -1, &font, pointF, &brush);

	}


	//BlackBrush =new SolidBrush(Color(255,0,0,0));
	BlackBrush =new SolidBrush(Color(255,0,0,0));
	mygraphics->FillRectangle(BlackBrush,100,10,1200,600);
	mygraphics->DrawRectangle(myRectangle_pen,100,10,1200,600);



	for(int i=0;i<=39;i++)				//画网格线
		mygraphics->DrawLine(my_inline_pen,100+line_interval*(i+1)-m_interval*6,10,100+line_interval*(i+1)-m_interval*6,610);

	for(int i=0;i<19;i++)				//画网格线
		mygraphics->DrawLine(my_inline_pen,100,10+line_interval*(1+i),1300,10+line_interval*(1+i));
#if 0
	CPointItem *first_item=NULL,*second_item=NULL;
	first_item = m_pFirstItem;
	for (int i=0;i<Total_count-1;i++)
	{
		second_item=first_item->GetNext();
		if(second_item==NULL)
			break;
		//mygraphics->DrawCurve(CurePen,, 3, 1.5f);
		//Point myPointArray[] =
		//{Point(first_item->GetPoint().x,first_item->GetPoint().y),Point(second_item->GetPoint().x,second_item->GetPoint().y)};
		//mygraphics->DrawCurve(CurePen,myPointArray, 2, 1.0f);
		//mygraphics->DrawLine(CurePen,first_item->GetPoint().x,first_item->GetPoint().y,second_item->GetPoint().x,second_item->GetPoint().y);
		first_item = second_item;
	}
#endif
#if 1
	CPointItem *first_item=NULL,*second_item=NULL,*third_item=NULL;
	first_item = m_pFirstItem;

	for (int i=0;i<Total_count-1;i=i+2)	//画贝塞尔曲线,使得线条平滑;3个点一画;
	{
		second_item=first_item->GetNext();
		third_item = second_item->GetNext();
		if(second_item==NULL)
			break;
		if(third_item == NULL)
		{
			first_item = second_item;
			break;
		}
		//mygraphics->DrawCurve(CurePen,, 3, 1.5f);
		//取3个点给画曲线的GDI函数;
		Point myPointArray[] =
		{Point(first_item->GetPoint().x,first_item->GetPoint().y),
		Point(second_item->GetPoint().x,second_item->GetPoint().y),
		Point(third_item->GetPoint().x,third_item->GetPoint().y)};
		mygraphics->DrawCurve(CurePen,myPointArray, 3, 1.0f);
		//mygraphics->DrawLine(CurePen,first_item->GetPoint().x,first_item->GetPoint().y,second_item->GetPoint().x,second_item->GetPoint().y);

		first_item = third_item;
	}
#endif
	//	mygraphics->DrawLine(CurePen,)


	delete CurePen;
	delete mygraphics;
	delete myRectangle_pen;
	delete my_inline_pen;
	delete BlackBrush;
}
Esempio n. 19
0
void Thumblay::subrender()
{
	Graphics *gfx = Graphics::FromImage(this->image);
	gfx->Clear(CLR_WHITE);

	Cacher *cacher = this->core->getCacher();
	if( cacher != NULL ){
		Image *thumb = NULL;
		Cell *cell = NULL;
		int i, x, y, mx, my, count;
		bool top, bot, left, right;

		right = false;
		left = false;
		top = false;
		bot = false;

		mx = OVL_MARGIN + 2 * (THB_SMSIZE + THB_SPACE);
		my = mx;

		x = y = OVL_MARGIN;
		count = 0;

		for( i = -THB_COUNT - this->picker; i <= THB_COUNT - this->picker; i++ ){
			cacher->lockCache();

			if( cacher->getCache() != NULL ){
				cell = cacher->getCache()->gettoThat(i);
				if( cell != NULL ){
					thumb = cell->getImageThumb();
					if( thumb != NULL ){
						if( i != 0 ){
							gfx->DrawImage(thumb,x,y,THB_SMSIZE,THB_SMSIZE);
							gfx->DrawRectangle(this->Pen_Border,
											   x,
											   y,
											   THB_SMSIZE,
											   THB_SMSIZE);
						}	
						else {
							mx = x + (int)((THB_SIZE - THB_SMSIZE)/4);
							my = y + (int)((THB_SIZE - THB_SMSIZE)/4);
						}
					}
					if( i == -THB_ROW )
						top = true;
					if( i == THB_ROW )
						bot = true;
					if( i == -1 && cacher->getCache()->isThatHead() == false )
						left = true;
					if( i == 1 && cacher->getCache()->isThatTail() == false )
						right = true;
				}
			}
			count++;
			x += THB_SMSIZE + THB_SPACE;
			if( count >= THB_ROW ){
				x = OVL_MARGIN;
				y += THB_SMSIZE + THB_SPACE;
				count = 0;
			}
			cacher->unlockCache();
		}
		int frame = 2;
		cacher->lockCache();
		if( cacher->getCache() != NULL ){
			cell = cacher->getThat();
			if( cell != NULL ){
				thumb = cell->getImageThumb();
				if( thumb != NULL ){
					gfx->FillRectangle(this->Brush_Back,
									   mx - THB_SIZE/4,
									   my - THB_SIZE/4,
									   THB_SIZE,
									   THB_SIZE);
					gfx->DrawImage(thumb,
								   mx - THB_SIZE/4,
								   my - THB_SIZE/4,
								   THB_SIZE,
								   THB_SIZE);
					gfx->DrawRectangle(this->Pen_Border,
									   mx - THB_SIZE/4,
									   my - THB_SIZE/4,
									   THB_SIZE,
									   THB_SIZE);
					gfx->DrawRectangle( this->Pen_DarkBorder,
										mx - frame - THB_SIZE/4,
										my - frame - THB_SIZE/4,
										THB_SIZE + 2*frame,
										THB_SIZE + 2*frame );
				}
			}
		}
		cacher->unlockCache();

		int size = 3;
		int width = 10;
		int ax = (int)(mx - frame - THB_SIZE/4);
		int ay = (int)(my - frame - THB_SIZE/4);
		int asize = THB_SIZE + 2*frame;
		Point arrow[3];

		if( top == true ){
			arrow[0].X = (int)(ax + (THB_SIZE/2) - width);
			arrow[0].Y = ay;
			arrow[1].X = (int)(ax + (THB_SIZE/2));
			arrow[1].Y = ay - width;
			arrow[2].X = (int)(ax + (THB_SIZE/2) + width);
			arrow[2].Y = ay;
			gfx->FillPolygon(this->Brush_DarkBack,arrow,size);
		}
		if( bot == true ){
			arrow[0].X = (int)(ax + (THB_SIZE/2) - width);
			arrow[0].Y = ay + asize;
			arrow[1].X = (int)(ax + (THB_SIZE/2));
			arrow[1].Y = ay + asize + width;
			arrow[2].X = (int)(ax + (THB_SIZE/2) + width);
			arrow[2].Y = ay + asize;
			gfx->FillPolygon(this->Brush_DarkBack,arrow,size);
		}
		if( left == true ){
			arrow[0].X = ax;
			arrow[0].Y = (int)(ay + (THB_SIZE/2) - width);
			arrow[1].X = ax - width;
			arrow[1].Y = (int)(ay + (THB_SIZE/2));
			arrow[2].X = ax;
			arrow[2].Y = (int)(ay + (THB_SIZE/2) + width);
			gfx->FillPolygon(this->Brush_DarkBack,arrow,size);
		}
		if( right == true ){
			arrow[0].X = ax + asize;
			arrow[0].Y = (int)(ay + (THB_SIZE/2) - width);
			arrow[1].X = ax + asize + width;
			arrow[1].Y = (int)(ay + (THB_SIZE/2));
			arrow[2].X = ax + asize;
			arrow[2].Y = (int)(ay + (THB_SIZE/2) + width);
			gfx->FillPolygon(this->Brush_DarkBack,arrow,size);
		}
	}
	if( this->ticker > TICKER_OFF ){
		int tsize = TICKER_SIZE;
		int tx,ty;
		if( this->ticker == 0 ){
			tx = OVL_SIZE - 2*TICKER_INDENT;
			ty = OVL_SIZE - 2*TICKER_INDENT;
		}
		if( this->ticker == 1 ){
			tx = OVL_SIZE - TICKER_INDENT;
			ty = OVL_SIZE - 2*TICKER_INDENT;
		}
		if( this->ticker == 2 ){
			tx = OVL_SIZE - TICKER_INDENT;
			ty = OVL_SIZE - TICKER_INDENT;
		}
		if( this->ticker == 3 ){
			tx = OVL_SIZE - 2*TICKER_INDENT;
			ty = OVL_SIZE - TICKER_INDENT;
		}
		gfx->FillRectangle(this->Brush_DarkBack,tx,ty,tsize,tsize);
	}
	delete gfx;
}
Esempio n. 20
0
//
//  函数:  WndProc(HWND, UINT, WPARAM, LPARAM)
//
//  目的:    处理主窗口的消息。
//
//  WM_COMMAND	- 处理应用程序菜单
//  WM_PAINT	- 绘制主窗口
//  WM_DESTROY	- 发送退出消息并返回
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
	int wmId, wmEvent;
	PAINTSTRUCT ps;
	HDC hdc;


	switch (message)
	{
	case WM_COMMAND:
		wmId    = LOWORD(wParam);
		wmEvent = HIWORD(wParam);
		// 分析菜单选择: 
		switch (wmId)
		{
		case IDM_ABOUT:
			DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
			break;
		case IDM_EXIT:
			DestroyWindow(hWnd);
			break;
		case ID_HELP_SPLASHSCREEN:
			ghDlg = CreateDialog(hInst, MAKEINTRESOURCE(IDD_SPLASH), 0, Splash);
			ShowWindow(ghDlg, SW_SHOW);
			break;
		case ID_CONTROL_YIELD:
			if (!eval_null()){
				MessageBoxA(0, "You could only yield before a game start.", "Yield", 0);
				break;
			}
			mainboard[7][7] = 1;
			paint_board(hWnd);
			break;
		case ID_CONTROL_RESTART:
			clear_board(hWnd);
			break;
		default:
			return DefWindowProc(hWnd, message, wParam, lParam);
		}
		break;
	case WM_PAINT:{
		Graphics *myGraphics;
		Pen *myPen;
		hdc = BeginPaint(hWnd, &ps);
		// TODO:  在此添加任意绘图代码...
		myGraphics = new Graphics(hdc);
		myPen = new Pen(Color(255, 0, 0, 0), 1);
		myGraphics->DrawRectangle(myPen, Rect(400, 20, 20, 20));
		for (int i = 0; i < 375; i += 25)
			myGraphics->DrawLine(myPen, 20, 20 + i, 370, 20 + i);
		for (int i = 0; i < 375; i += 25)
			myGraphics->DrawLine(myPen, 20 + i, 20, 20 + i, 370);
		delete myGraphics;
		delete myPen;
		EndPaint(hWnd, &ps);
		paint_board(hWnd);
	}
		break;
	case WM_DESTROY:
		GdiplusShutdown(gdiplusToken);
		PostQuitMessage(0);
		break;
	case WM_LBUTTONDOWN:
		board_clicked(hWnd, LOWORD(lParam), HIWORD(lParam));
		break;
	default:
		return DefWindowProc(hWnd, message, wParam, lParam);
	}
	return 0;
}
Esempio n. 21
0
void CRectangle::DrawRectangle(Graphics& graph,CRect rc)
{
	Pen penDraw(m_crColor,(float)m_nWidth);
	graph.DrawRectangle(&penDraw,rc.left,rc.top,rc.Width(),rc.Height());
}
//重绘状态栏 , 状态栏的大小会根据窗体的大小变动;
void CMyStatusbarCtrl::DrawStatusBar(HDC my_hdc)
{
	Graphics *mygraphics;
	mygraphics = new Graphics(status_hMemDC);
	mygraphics->SetSmoothingMode(SmoothingModeAntiAlias);
	Pen *myRectangle_pen;
	SolidBrush *BlackBrush;
	SolidBrush *CharacterblkBrush;
	SolidBrush *ProgressblkBrush;
	SolidBrush *HealthGreenBrush;
	SolidBrush *HealthRedBrush;

	SolidBrush  Font_brush(Color(255,0,0,0));
	FontFamily  StaticfontFamily(_T("Arial"));
	Gdiplus::Font        character_font(&StaticfontFamily, 12, FontStyleRegular, UnitPixel);
	PointF      staticpointF(0, 0);

	HealthGreenBrush = new SolidBrush(Color(255,38,182,69));
	HealthRedBrush = new SolidBrush(Color(255,255,0,0));
	ProgressblkBrush = new SolidBrush(Color(255,0,211,39));
	CharacterblkBrush =new SolidBrush(Color(255,183,183,183));
	BlackBrush =new SolidBrush(Color(255,228,228,228));
	mygraphics->FillRectangle(BlackBrush,0,0,status_myRect.right,status_myRect.bottom);


	myRectangle_pen = new Pen(Color(255,0,0,0),1.0f);
	mygraphics->DrawRectangle(myRectangle_pen,1,0,add_width,window_height);
	mygraphics->DrawRectangle(myRectangle_pen,1,0,STATUS_CHARACTER_WIDTH,window_height);
	mygraphics->FillRectangle(CharacterblkBrush,1,0,STATUS_CHARACTER_WIDTH,window_height);

	mygraphics->DrawRectangle(myRectangle_pen,tx_start_pos,0,tx_width,window_height);
	mygraphics->DrawRectangle(myRectangle_pen,tx_start_pos,0,STATUS_CHARACTER_WIDTH,window_height);
	mygraphics->FillRectangle(CharacterblkBrush,tx_start_pos,0,STATUS_CHARACTER_WIDTH,window_height);

	mygraphics->DrawRectangle(myRectangle_pen,rx_start_pos,0,rx_width,window_height);
	mygraphics->DrawRectangle(myRectangle_pen,rx_start_pos,0,STATUS_CHARACTER_WIDTH,window_height);
	mygraphics->FillRectangle(CharacterblkBrush,rx_start_pos,0,STATUS_CHARACTER_WIDTH,window_height);

	mygraphics->DrawRectangle(myRectangle_pen,err_start_pos,0,err_width,window_height);
	mygraphics->DrawRectangle(myRectangle_pen,err_start_pos,0,STATUS_CHARACTER_WIDTH,window_height);
	mygraphics->FillRectangle(CharacterblkBrush,err_start_pos,0,STATUS_CHARACTER_WIDTH,window_height);

	mygraphics->DrawRectangle(myRectangle_pen,health_start_pos,0,health_width,window_height);
	mygraphics->DrawRectangle(myRectangle_pen,health_start_pos,0,STATUS_HEALTH_CHARACTER_WIDTH,window_height);
	mygraphics->FillRectangle(CharacterblkBrush,health_start_pos,0,STATUS_HEALTH_CHARACTER_WIDTH,window_height);

	mygraphics->DrawRectangle(myRectangle_pen,progress_start_pos,0,progress_width - STATUS_ALARM_ICON_WIDTH,window_height);

	CString temp_value;

	

	staticpointF.X = 1;
	staticpointF.Y = 1 ;
	mygraphics->DrawString(_T("Add"), -1, &character_font, staticpointF,&Font_brush);

	staticpointF.X = add_start_pos + STATUS_CHARACTER_VALUE_OFFSET;
	mygraphics->DrawString(Statuspanel, -1, &character_font, staticpointF,&Font_brush);

	

	staticpointF.X = tx_start_pos + 1;
	mygraphics->DrawString(_T("Tx"), -1, &character_font, staticpointF,&Font_brush);

	staticpointF.X = tx_start_pos + STATUS_CHARACTER_VALUE_OFFSET;
	temp_value.Format(_T("%u"),g_llTxCount);
	mygraphics->DrawString(temp_value, -1, &character_font, staticpointF,&Font_brush);


	staticpointF.X = rx_start_pos + 1;
	mygraphics->DrawString(_T("Rx"), -1, &character_font, staticpointF,&Font_brush);

	staticpointF.X = rx_start_pos + STATUS_CHARACTER_VALUE_OFFSET;
	temp_value.Format(_T("%u"),g_llRxCount);
	mygraphics->DrawString(temp_value, -1, &character_font, staticpointF,&Font_brush);


	staticpointF.X = err_start_pos + 1;
	mygraphics->DrawString(_T("Err"), -1, &character_font, staticpointF,&Font_brush);

	staticpointF.X = err_start_pos + STATUS_CHARACTER_VALUE_OFFSET;

	//这一段主要是处理有些命令是设备多余回复出来的,例如 发一条,设备回复两条,这样就不太好计算 error 的个数;
	static int n_err_show_count = 0;
	if(++n_err_show_count == 50)
	{
		n_err_show_count = 0;
		if(g_llTxCount - g_llRxCount < 0)
		{
			g_llRxCount = g_llTxCount;
			g_llerrCount = 0;
		}
		else if(g_llTxCount  < g_llerrCount + g_llRxCount)
		{
			g_llRxCount = g_llTxCount - g_llerrCount;
		}
		else
		{
			g_llerrCount = g_llTxCount - g_llRxCount;
		}
	}
	temp_value.Format(_T("%u"),g_llerrCount);
	mygraphics->DrawString(temp_value, -1, &character_font, staticpointF,&Font_brush);


	if(bac_select_device_online)
	{
		mygraphics->FillRectangle(HealthGreenBrush,health_start_pos + STATUS_HEALTH_CHARACTER_WIDTH + 1,1,health_width - STATUS_HEALTH_CHARACTER_WIDTH - 2,window_height - 2);
		staticpointF.X = health_start_pos + STATUS_HEALTH_VALUE_OFFSET;
		mygraphics->DrawString(_T("100%"),-1, &character_font,staticpointF,&Font_brush);
	}
	else
	{
		mygraphics->FillRectangle(HealthRedBrush,health_start_pos + STATUS_HEALTH_CHARACTER_WIDTH + 1,1,health_width - STATUS_HEALTH_CHARACTER_WIDTH - 2,window_height - 2);
		staticpointF.X = health_start_pos + STATUS_HEALTH_VALUE_OFFSET;
		mygraphics->DrawString(_T("0%"),-1, &character_font,staticpointF,&Font_brush);
	}

	staticpointF.X = health_start_pos + 1;
	mygraphics->DrawString(_T("Health"), -1, &character_font, staticpointF,&Font_brush);

	if(g_progress_persent != 0)
	{
		unsigned int temp_width = (progress_width - STATUS_ALARM_ICON_WIDTH) * g_progress_persent / 100 ;
		CString temp_persent_value;
		temp_persent_value.Format(_T("%d%%"),g_progress_persent);
		mygraphics->FillRectangle(ProgressblkBrush,progress_start_pos,0,temp_width,window_height);
		staticpointF.X = progress_start_pos + progress_width - 60;
		mygraphics->DrawString(temp_persent_value, -1, &character_font, staticpointF,&Font_brush);
		if( g_progress_persent >= 98)
			g_progress_persent = 0;
		//progress_width
	}
	else
	{
		mygraphics->DrawRectangle(myRectangle_pen,progress_start_pos,0,progress_width - STATUS_ALARM_ICON_WIDTH,window_height);
	}

	if(!cs_show_status_info.IsEmpty())
	{
		staticpointF.X = progress_start_pos + 1;
		mygraphics->DrawString(cs_show_status_info, -1, &character_font, staticpointF,&Font_brush);
	}

	

	delete mygraphics;
	delete myRectangle_pen;

	delete BlackBrush;
	delete CharacterblkBrush;
	delete ProgressblkBrush;
}
Esempio n. 23
0
Bitmap *Layer::render()
{
	this->locate();

	WaitForSingleObject(this->mut_image,INFINITE);

	int frame = FRAME;
	Bitmap *scene = NULL;
	if( this->fulldraw == true )
		scene = new Bitmap(this->cwidth + 2*frame,this->cheight + 2*frame);
	else
		scene = new Bitmap(this->width,this->height);

	Graphics *tmpgfx = Graphics::FromImage(scene);

	Image *tmp = NULL;
	tmpgfx->Clear(CLR_WHITE);

	if( this->fulldraw == true ){
		if( this->image != NULL ){
			double zoom = NULL;
			int width, height;

			if( this->scali == NULL )
				tmp = this->image;
			else
				tmp = this->scali;

			if( this->fullscreen == false )
				tmpgfx->DrawRectangle(this->Pen_Border,
									  this->x - frame,
									  this->y - frame,
									  this->width + frame + 1,
									  this->height + frame + 1);

			tmpgfx->DrawImage(tmp,
							  Rect(this->x,
								   this->y,
								   this->width,
								   this->height),
							  0,
							  0,
							  tmp->GetWidth(),
							  tmp->GetHeight(),
							  UnitPixel);

			if( this->prev != NULL && this->sidedraw == true ){
				if( this->scalp == NULL )
					tmp = this->prev;
				else 
					tmp = this->scalp;
				width = tmp->GetWidth();
				height = tmp->GetHeight();
				if( this->scalp == NULL )
					zoom = this->getZoom(width,height,this->cwidth,this->cheight);
				else 
					zoom = ZOOMINIT;

				int pwidth = (int)(zoom * width);
				int pheight = (int)(zoom * height);
				int px = (int)((this->cwidth - pwidth)/2);
				if( this->sidemode == LEFT && px < 0 )
					px = 0;
				else if( this->sidemode == RIGHT && px < 0 )
					px = this->cwidth - pwidth;

				int py = this->y - pheight - MARGIN - this->offrollVer;

				if( this->fullscreen == false )
					tmpgfx->DrawRectangle(this->Pen_Border,
										  px - frame,
										  py - frame,
										  pwidth + frame + 1,
										  pheight + frame + 1);

				tmpgfx->DrawImage(tmp,Rect(px,py,pwidth,pheight),0,0,
								  tmp->GetWidth(),tmp->GetHeight(),UnitPixel);
			}
			if( this->next != NULL && this->sidedraw == true ){
				if( this->scaln == NULL )
					tmp = this->next;
				else
					tmp = this->scaln;
				width = tmp->GetWidth();
				height = tmp->GetHeight();
				if( this->scaln == NULL )
					zoom = this->getZoom(width,height,this->cwidth,this->cheight);
				else
					zoom = ZOOMINIT;

				int nwidth = (int)(zoom * width);
				int nheight = (int)(zoom * height);
				int nx = (int)((this->cwidth - nwidth)/2);
				if( this->sidemode == LEFT && nx < 0 )
					nx = 0;
				else if( this->sidemode == RIGHT && nx < 0 )
					nx = this->cwidth - nwidth;

				int ny = this->y + this->height + MARGIN + this->offrollVer;

				if( this->fullscreen == false )
					tmpgfx->DrawRectangle(this->Pen_Border,
										  nx - frame,
										  ny - frame,
										  nwidth + frame + 1,
										  nheight + frame + 1);

				tmpgfx->DrawImage(tmp,Rect(nx,ny,nwidth,nheight),0,0,
								  tmp->GetWidth(),tmp->GetHeight(),UnitPixel);
			}
		}
		this->x = 0;
		this->y = 0;
		this->width = scene->GetWidth();
		this->height = scene->GetHeight();
	}
	else {
		if( this->scali == NULL )
			tmp = this->image;
		else 
			tmp = this->scali;

		tmpgfx->DrawImage(tmp,
						  Rect(0,0,this->width,this->height),
						  0,0,tmp->GetWidth(),tmp->GetHeight(),
						  UnitPixel);
	}
	ReleaseMutex(this->mut_image);

	this->fulldraw = true;
	this->animate();

	delete tmpgfx;

	return scene;
}
Esempio n. 24
0
void CDrawWarn::Draw(CDC* pDC)
{
	ASSERT_VALID(this);
	CRect rect = m_position;
	rect.NormalizeRect();

	if(rect.Width() < 10 || rect.Height()<10)
		return;

	pStrWarn = new STRWARN[m_nColCount];
	AddWarn("1","2004/12/12","12:00","高报警","电压过低");
	AddWarn("2","2004/12/12","12:00","高报警","电压过低");
	AddWarn("3","2004/12/12","12:00","高报警","电压过低");
	AddWarn("4","2004/12/12","12:00","高报警","电压过低");
	AddWarn("5","2004/12/12","12:00","高报警","电压过低");
	AddWarn("6","2004/12/12","12:00","高报警","电压过低");
	AddWarn("7","2004/12/12","12:00","高报警","电压过低");
	AddWarn("8","2004/12/12","12:00","高报警","电压过低");
	AddWarn("9","2004/12/12","12:00","高报警","电压过低");
	AddWarn("10","2004/12/12","12:00","高报警","电压过低");
	AddWarn("11","2004/12/12","12:00","高报警","电压过低");
	AddWarn("12","2004/12/12","12:00","高报警","电压过低");

	Rect GdiRect (rect.TopLeft().x,rect.TopLeft().y,rect.Size().cx,rect.Size().cy); 

	Color crBackColor,crTitleColor,crLineColor,crTextColor ;
	crBackColor.SetFromCOLORREF(m_ctlBackColor);
	crTitleColor.SetFromCOLORREF(m_ctlTitleColor );
	crLineColor.SetFromCOLORREF(m_ctlLineColor);
	crTextColor.SetFromCOLORREF(m_ctlTextColor);

	Graphics graphics (pDC->m_hDC);
	Graphics Textgraphics (pDC->m_hDC);
	SolidBrush  solidBrush(crBackColor);
	SolidBrush  TitleBrush(crTitleColor);
	SolidBrush  TextBrush(crTextColor);
	Pen pen(crLineColor,1);
	
	graphics.FillRectangle(&solidBrush,GdiRect);

	BSTR bstr = _com_util::ConvertStringToBSTR(m_fontName);
///	WCHAR *fn = new unsigned short[m_fontName.GetLength()+1];;
///	wcscpy(fn,bstr);
				
	FontFamily  fontFamily(bstr);
	Font font(&fontFamily, m_fontSize, m_fontStyle, UnitPoint);

	for(int j =1; j<= m_nColCount; j++)
	{
		m_nCellWidth = 0;
		for(int i=1; i<= m_nRowCount; i++)
		{
			CRect rc = rect;
			if(m_bIsAutoSize)
			{
				m_nCellWidth = rect.Width()/m_nRowCount;
				m_nCellHeight = rect.Height()/m_nColCount;
				rc.TopLeft().x += (i-1)*m_nCellWidth;
				rc.TopLeft().y += (j-1)*m_nCellHeight;
				m_CellRect = CRect(rc.TopLeft(),CSize(m_nCellWidth,m_nCellHeight));
				m_CellRect.NormalizeRect();
			}
			else
			{
				rc.TopLeft().x += m_nCellWidth;
				m_nCellWidth += rect.Width()*m_nPercent[i-1]/100;
				m_nCellHeight = rect.Height()/m_nColCount;
				rc.TopLeft().y += (j-1)*m_nCellHeight;	
				m_CellRect = CRect(rc.TopLeft(),CSize(rect.Width()*m_nPercent[i-1]/100,m_nCellHeight));
				m_CellRect.NormalizeRect();
				
			}

			Rect CellRect(m_CellRect.TopLeft().x,m_CellRect.TopLeft().y,m_CellRect.Size().cx,m_CellRect.Size().cy);

			graphics.DrawRectangle(&pen,CellRect);
			
			if(j == m_nColCount)	//画标题
			{
				
				StringFormat stringFormat;
				stringFormat.SetAlignment(StringAlignmentCenter);
				stringFormat.SetLineAlignment(StringAlignmentCenter);
				stringFormat.SetFormatFlags(StringFormatFlagsDirectionRightToLeft);
				stringFormat.SetTrimming(m_trimmingSyle);

				CString m_strButton;
				if(i == 1)
					m_strButton = "点号";
				if(i == 2)
					m_strButton = "数据";
				if(i == 3)
					m_strButton = "说明";
				if(i == 4)
					m_strButton = "报警原因";
				if(i == 5)
					m_strButton = "时间";

				m_strButton.TrimRight();
///				int len = m_strButton.GetLength();
				bstr = _com_util::ConvertStringToBSTR(m_strButton);
///				WCHAR *strButton = new unsigned short[len];
///				wcscpy(strButton,bstr);
				RectF theRect (m_CellRect.TopLeft().x,m_CellRect.TopLeft().y,m_CellRect.Size().cx,m_CellRect.Size().cy);
				Matrix matrix(1,0,0,-1,0,0);
				Textgraphics.SetTransform(&matrix);
				
				theRect.Y *=-1;
				theRect.Height*=-1;
				Normallize (theRect);	
				Textgraphics.FillRectangle(&TitleBrush,theRect);
				Textgraphics.DrawString(bstr,-1,&font, theRect,&stringFormat, &TextBrush);
			}
			else					//画文字
			{
				StringFormat stringFormat;
				stringFormat.SetAlignment(StringAlignmentNear);
				stringFormat.SetLineAlignment(StringAlignmentNear);

				CString strWarn;
				if(i == 1)
					strWarn = pStrWarn[j].strPoint;
				if(i == 2)
					strWarn = pStrWarn[j].strDate;
				if(i == 3)
					strWarn = pStrWarn[j].strTime;
				if(i == 4)
					strWarn = pStrWarn[j].strText;
				if(i == 5)
					strWarn = pStrWarn[j].strWarn;

				strWarn.TrimRight();
///				int len = strWarn.GetLength();
				bstr = _com_util::ConvertStringToBSTR(strWarn);
///				WCHAR *strButton = new unsigned short[len];
///				wcscpy(strButton,bstr);
				RectF theRect (m_CellRect.TopLeft().x,m_CellRect.TopLeft().y,m_CellRect.Size().cx,m_CellRect.Size().cy);
				Matrix matrix(1,0,0,-1,0,0);
				Textgraphics.SetTransform(&matrix);
				
				theRect.Y *=-1;
				theRect.Height*=-1;
				Normallize (theRect);	
				Textgraphics.DrawString(bstr,-1,&font, theRect,&stringFormat, &TextBrush);
			}
		}
	}
	graphics.ReleaseHDC(pDC->m_hDC);
}