- // VlanView.cpp : implementation file
- //
- #include "stdafx.h"
- #include "NetMapDoc.h"
- #include "NetMap.h"
- #include "VlanView.h"
- #include "Mainfrm.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CVlanView
- IMPLEMENT_DYNCREATE(CVlanView, CFormView)
- CVlanView::CVlanView()
- : CFormView(CVlanView::IDD)
- {
- //{{AFX_DATA_INIT(CVlanView)
- // NOTE: the ClassWizard will add member initialization here
- //}}AFX_DATA_INIT
- }
- CVlanView::~CVlanView()
- {
- }
- void CVlanView::DoDataExchange(CDataExchange* pDX)
- {
- CFormView::DoDataExchange(pDX);
- //{{AFX_DATA_MAP(CVlanView)
- // NOTE: the ClassWizard will add DDX and DDV calls here
- //}}AFX_DATA_MAP
- }
- void CVlanView::OnInitialUpdate()
- {
- CFormView::OnInitialUpdate();
- GetParentFrame()->RecalcLayout();
- ResizeParentToFit();
- CMainFrame *pMain=(CMainFrame *)AfxGetApp()->m_pMainWnd;
- pMain->pVlanView=this;
- paint=false;
- }
- BEGIN_MESSAGE_MAP(CVlanView, CFormView)
- //{{AFX_MSG_MAP(CVlanView)
- ON_WM_DESTROY()
- ON_WM_PAINT()
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CVlanView diagnostics
- #ifdef _DEBUG
- void CVlanView::AssertValid() const
- {
- CFormView::AssertValid();
- }
- void CVlanView::Dump(CDumpContext& dc) const
- {
- CFormView::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CVlanView message handlers
- void CVlanView::OnDestroy()
- {
- CFormView::OnDestroy();
- // TODO: Add your message handler code here
- CMainFrame *pMain=(CMainFrame *)AfxGetApp()->m_pMainWnd;
- for (int i=0;i<pMain->SwitchPortArray.GetSize();i++)
- {
- if (pMain->SwitchPortArray[i]->pPortImage!=NULL)
- delete pMain->SwitchPortArray[i]->pPortImage;
- if (pMain->SwitchPortArray[i]->pHostImage!=NULL)
- delete pMain->SwitchPortArray[i]->pHostImage;
- delete pMain->SwitchPortArray[i];
- }
- }
- void CVlanView::OnPaint()
- {
- CPaintDC dc(this); // device context for painting
- if (paint==true)
- {
- CMainFrame *pMain;
- pMain=(CMainFrame *)AfxGetApp()->m_pMainWnd;
- CWnd *pWnd;
- CRect rc;
- for (int i=0;i<pMain->SwitchPortArray.GetSize();i++)
- {
- if (pMain->SwitchPortArray[i]->HostAdd.GetSize()>=1)
- {
- pWnd=GetDlgItem(IDC_MYIMAGE+1000+i);
- pWnd->GetWindowRect(rc);
- ScreenToClient(rc);
- pMain->SwitchPortArray[i]->pPortImage->MyPos.x=rc.left+16;
- pMain->SwitchPortArray[i]->pPortImage->MyPos.y=rc.top+16;
- pWnd=GetDlgItem(IDC_MYIMAGE+2000+i);
- pWnd->GetWindowRect(rc);
- ScreenToClient(rc);
- pMain->SwitchPortArray[i]->pHostImage->MyPos.x=rc.left+16;
- pMain->SwitchPortArray[i]->pHostImage->MyPos.y=rc.top+16;
- }
- }
- for (i=0;i<pMain->SwitchPortArray.GetSize();i++)
- {
- if (pMain->SwitchPortArray[i]->HostAdd.GetSize()>=1)
- {
- int x1=pMain->SwitchPortArray[i]->pPortImage->MyPos.x;
- int y1=pMain->SwitchPortArray[i]->pPortImage->MyPos.y;
- int x2=pMain->SwitchPortArray[i]->pHostImage->MyPos.x;
- int y2=pMain->SwitchPortArray[i]->pHostImage->MyPos.y;
- dc.MoveTo(x1,y1);
- dc.LineTo(x2,y2);
- }
- }
- }
- // Do not call CFormView::OnPaint() for painting messages
- }