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; }
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; }