📄 rectview.cpp
字号:
EndPt.y=point.y;
CString strReadLine;
if(CRectView::bCrash)
{
//////////////////////////////////////////////////////////////////////////
CRect rectedge(StartPt.x,StartPt.y,EndPt.x,EndPt.y);
CBrush brush;
brush.CreateSolidBrush(HGLI);
dc.FillRect(rectedge,&brush);
//////////////////////////////////////////////////////////////////////////
CStringArray straLine;
if(stfile.Open(strPath,CFile::modeReadWrite))
{
while(stfile.ReadString(strReadLine) )
{
if(strReadLine.Find(",")>0)
{
int pos1,pos2;
pos1=strReadLine.Find(",");
left=atol((LPCTSTR)strReadLine.Left(pos1));
pos1++;
pos2=strReadLine.Find(",",pos1);
top =atol((LPCTSTR)(strReadLine.Mid(pos1,pos2-pos1)));
pos1=pos2+1;
pos2=strReadLine.Find(",",pos1);
right =atol((LPCTSTR)(strReadLine.Mid(pos1,pos2-pos1)));
pos1=pos2+1;
bottom =atol((LPCTSTR)(strReadLine.Mid(pos1,strReadLine.GetLength()-pos1)));
nCount=0;
if(abs(min(left,right)-min(StartPt.x,EndPt.x))>40 || abs(max(top,bottom)-max(EndPt.y,StartPt.x)>40))
{
straLine.Add(strReadLine);
}
else
{
CPen penG;
penG.CreatePen(PS_SOLID,1,HGLI);
dc.SelectObject(&penG);
dc.MoveTo(left,top);
dc.LineTo(right,bottom);
}
}
}
stfile.Close();
stfile.Open(strPath,CFile::modeCreate|CFile::modeReadWrite);
stfile.Seek(0,CFile::end);
int nSize= straLine.GetSize();
for(int j=0;j<nSize;j++)
{
stfile.WriteString(straLine.GetAt(j)+"\r\n");
}
}
StartPt.x=-1;
}
else
{
if(StartPt.x>=0)
{
pLastpoint.x=-1;
dc.MoveTo(StartPt.x,StartPt.y);
dc.LineTo(EndPt);
if(stfile.Open(strPath,CFile::modeReadWrite))
{
stfile.SeekToEnd();
stfile.WriteString("\r\n");
strPoint.Format("%d,%d,%d,%d",StartPt.x,StartPt.y,EndPt.x,EndPt.y);
stfile.WriteString(strPoint);
}
stfile.Close();
StartPt.x=-1;
}
}
}
CView::OnLButtonUp(nFlags, point);
}
void CRectView::DrawLine()
{
CStdioFile stdfile;
CDlgAllStaSet dlgalstaset;
CString strPath;
dlgalstaset.GetModulePath(strPath,NULL);
strPath+="Line.txt";
if(stdfile.Open(strPath,CFile::modeRead|CFile::shareDenyNone))
{
CString strLine;
while(stdfile.ReadString(strLine))
{
if(strLine.GetLength()>10)
{
int pos1,pos2;
pos1=strLine.Find(",");
left=atol((LPCTSTR)strLine.Left(pos1));
pos1++;
pos2=strLine.Find(",",pos1);
top =atol((LPCTSTR)(strLine.Mid(pos1,pos2-pos1)));
pos1=pos2+1;
pos2=strLine.Find(",",pos1);
right =atol((LPCTSTR)(strLine.Mid(pos1,pos2-pos1)));
pos1=pos2+1;
bottom =atol((LPCTSTR)(strLine.Mid(pos1,strLine.GetLength()-pos1)));
CClientDC dc(this);
dc.MoveTo(left,top);
dc.LineTo(right,bottom);
}
}
}
stdfile.Close();
}
void CRectView::DrawPic()
{
CString strGetColor;
ReadConfigStaCnt(iStaCnt);
if(ReadConfigStaName(saStaNameAll))
{
CRect rcBut(0,0,80,80);
//CString strGetColor;
strGetColor=CCheckState::strColorbefore;
CStringArray staGetcolor;
int iGetColorLen=strGetColor.GetLength();
if(iGetColorLen==0)//如果strColor的长度为0,则说明设备都没有正常工作都置0
{
for(int im=0;im<iStaCnt;im++)
{
staGetcolor.Add("0");
}
}
for(int i =0;i<iGetColorLen;i++)//strColor中的每一位代表着一个设备的状态情况,2表示都工作,1代表部分工作,0表示都没工作;
{
CString str;
str=strGetColor.Mid(i,1);
staGetcolor.Add(strGetColor.Mid(i,1));
}
CDlgAllStaSet dlgalstaset;
CString strPath;
dlgalstaset.GetModulePath(strPath,NULL);
strPath+="PCM120networksetup.ini";
char Get[255];
int x,y,p,q;
for(int iIdxSta=0;iIdxSta<iStaCnt;iIdxSta++)
{
CString strSect;
strSect.Format("station%d",iIdxSta+1);
GetPrivateProfileString(strSect,"posionx","100",Get,255,strPath);
x =atoi(Get);
GetPrivateProfileString(strSect,"posiony","100",Get,255,strPath);
y =atoi(Get);
GetPrivateProfileString(strSect,"posionp","100",Get,255,strPath);
p =atoi(Get);
GetPrivateProfileString(strSect,"posionq","100",Get,255,strPath);
q =atoi(Get);
CRectButton *pButton=new CRectButton;
CRect rect2(x,y,p,q);
if(staGetcolor.GetAt(iIdxSta)=="2")
{
pButton->Create(saStaNameAll.GetAt(iIdxSta),rect2,GREEN,this,1001+iIdxSta+1);
m_aRect.InsertAt(iIdxSta,pButton);
}
if(staGetcolor.GetAt(iIdxSta)=="0")
{
pButton->Create(saStaNameAll.GetAt(iIdxSta),rect2,GRAY,this,1001+iIdxSta+1);
m_aRect.InsertAt(iIdxSta,pButton);
}
if(staGetcolor.GetAt(iIdxSta)=="1")
{
pButton->Create(saStaNameAll.GetAt(iIdxSta),rect2,RED,this,1001+iIdxSta+1);
m_aRect.InsertAt(iIdxSta,pButton);
}
}
}
CRectView::bFresh=false;
}
void CRectView::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(CMainFrame::bSet==1)
{
if(CRectView::bCrash==0)
{
if(StartPt.x>0)
{
CClientDC dc(this);
if(pLastpoint.x<0)
{
pLastpoint=StartPt;
}
CPen penG,PenB;
penG.CreatePen(PS_SOLID,1,HGLI);
dc.SelectObject(&penG);
dc.MoveTo(StartPt.x,StartPt.y);
dc.LineTo(pLastpoint);
PenB.CreatePen(PS_SOLID,1,RGB(0,0,0));
dc.SelectObject(&PenB);
dc.MoveTo(StartPt.x,StartPt.y);
dc.LineTo(point);
pLastpoint=point;
}
}
}
CView::OnMouseMove(nFlags, point);
}
DROPEFFECT CRectView::OnDragEnter(COleDataObject* pDataObject, DWORD dwKeyState, CPoint point)
{
// TODO: Add your specialized code here and/or call the base class
return CView::OnDragEnter(pDataObject, dwKeyState, point);
}
void CRectView::Redraw()
{
// CRect rectedge(CRectView::LCx,CRectView::LCy,CRectView::LCx+80,CRectView::LCy+80);
CRect rectedge(0,0,1280,1024);
CBrush brush;
CClientDC dc(this);
brush.CreateSolidBrush(HGLI);
dc.FillRect(rectedge,&brush);
Mydraw();
}
void CRectView::Serialize(CArchive& ar)
{
if (ar.IsStoring())
{ // storing code
}
else
{ // loading code
}
}
void CRectView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
// TODO: Add your specialized code here and/or call the base class
}
void CRectView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// TODO: Add your message handler code here
}
void CRectView::DoDataExchange(CDataExchange* pDX)
{
// TODO: Add your specialized code here and/or call the base class
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
GetClientRect(rect);
dc.FillSolidRect(rect,HGLI);
if(nFirst<=1)
{
Mydraw();
}
DrawLine();
CView::DoDataExchange(pDX);
}
void CRectView::OnShowWindow(BOOL bShow, UINT nStatus)
{
CView::OnShowWindow(bShow, nStatus);
// TODO: Add your message handler code here
}
BOOL CRectView::IsSelected(const CObject* pDocItem) const
{
// TODO: Add your specialized code here and/or call the base class
return CView::IsSelected(pDocItem);
}
void CRectView::OnPrint(CDC* pDC, CPrintInfo* pInfo)
{
// TODO: Add your specialized code here and/or call the base class
CView::OnPrint(pDC, pInfo);
}
void CRectView::OnPaint()
{
CPaintDC dc(this); // device context for painting
// TODO: Add your message handler code here
GetClientRect(rect);
dc.FillSolidRect(rect,HGLI);
if(nFirst<=1)
{
Mydraw();
}
DrawLine();
::SendMessage(::AfxGetApp()->m_pMainWnd->GetSafeHwnd(),WM_SYSCOMMAND,(WPARAM)SC_MAXIMIZE,NULL);
// Do not call CView::OnPaint() for painting messages
}
void CRectView::OnSetFocus(CWnd* pOldWnd)
{
CView::OnSetFocus(pOldWnd);
// TODO: Add your message handler code here
nFirst=0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -