-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMainDlg.cpp
133 lines (114 loc) · 5.3 KB
/
MainDlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// MainDlg.cpp : implementation of the CMainDlg class
//
/////////////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "MainDlg.h"
#include "FileHelper.h"
#include "probeseldlg.h"
CMainDlg::CMainDlg()
: SHostWnd(_T("LAYOUT:XML_MAINWND"))
, m_pCadCanvas(NULL)
{
m_bLayoutInited = FALSE;
}
CMainDlg::~CMainDlg()
{
}
int CMainDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
SetMsgHandled(FALSE);
return 0;
}
BOOL CMainDlg::OnInitDialog(HWND hWnd, LPARAM lParam)
{
m_bLayoutInited = TRUE;
m_pCadCanvas = FindChildByName2<SCadCanvas>(L"cc_test");
m_pCadCanvas->LoadFile(L"d:\\test.xml");
m_pCadCanvas->SetFocus();
return 0;
}
//TODO:消息映射
void CMainDlg::OnClose()
{
SNativeWnd::DestroyWindow();
}
void CMainDlg::OnMaximize()
{
SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE);
}
void CMainDlg::OnRestore()
{
SendMessage(WM_SYSCOMMAND, SC_RESTORE);
}
void CMainDlg::OnMinimize()
{
SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);
}
void CMainDlg::OnSize(UINT nType, CSize size)
{
SetMsgHandled(FALSE);
if (!m_bLayoutInited) return;
SWindow *pBtnMax = FindChildByName(L"btn_max");
SWindow *pBtnRestore = FindChildByName(L"btn_restore");
if(!pBtnMax || !pBtnRestore) return;
if (nType == SIZE_MAXIMIZED)
{
pBtnRestore->SetVisible(TRUE);
pBtnMax->SetVisible(FALSE);
}
else if (nType == SIZE_RESTORED)
{
pBtnRestore->SetVisible(FALSE);
pBtnMax->SetVisible(TRUE);
}
}
void CMainDlg::OnBtnZoomin()
{
m_pCadCanvas->SetZoom(m_pCadCanvas->GetZoom()/1.1f);
}
void CMainDlg::OnBtnZoomout()
{
m_pCadCanvas->SetZoom(m_pCadCanvas->GetZoom()*1.1f);
}
void CMainDlg::OnBtnZoomfit()
{
m_pCadCanvas->Zoomfit();
}
void CMainDlg::OnCanvasRectSel(IEvtArgs * e)
{
SCadCanvas *cadCanvas = sobj_cast<SCadCanvas>(e->Sender());
//if (cadCanvas->GetSelectedCount() > 0)
//{
// CProbeSelDlg selDlg;
// selDlg.DoModal();
//}
}
void CMainDlg::OnLoadDxf()
{
CFileDialogEx openDlg (TRUE,_T("dxf"),0,6,_T("dxf file(*.dxf)\0*.dxf\0\0"));
if (openDlg.DoModal() == IDOK)
{
m_pCadCanvas->LoadDXFFile(openDlg.m_szFileName);
}
}
void CMainDlg::OnDraw_Line()
{
m_pCadCanvas->SetFocus();
m_pCadCanvas->m_IsDrawLine = true;
}
void CMainDlg::OnBtnLoadFile()
{
CFileDialogEx openDlg (TRUE,_T("xml"),0,6,_T("xml file(*.xml)\0*.xml\0\0"));
if (openDlg.DoModal() == IDOK)
{
m_pCadCanvas->LoadFile(openDlg.m_szFileName);
}
}
void CMainDlg::OnBtnSaveFile()
{
CFileDialogEx saveDlg(FALSE, _T("xml"), 0, 6, _T("xml file(*.xml)\0*.xml\0\0"));
if (saveDlg.DoModal() == IDOK)
{
m_pCadCanvas->SaveFile(saveDlg.m_szFileName);
}
}