- // MiniCADDoc.cpp : implementation of the CMiniCADDoc class
- //
- #include "stdafx.h"
- #include "MiniCADDoc.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CMiniCADDoc
- IMPLEMENT_DYNCREATE(CMiniCADDoc, CDocument)
- BEGIN_MESSAGE_MAP(CMiniCADDoc, CDocument)
- //{{AFX_MSG_MAP(CMiniCADDoc)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- // CMiniCADDoc construction/destruction
- CMiniCADDoc::CMiniCADDoc()
- {
- // TODO: add one-time construction code here
- pApp = (CMiniCADApp*)AfxGetApp();
- DocumentIndex = 0;
- }
- CMiniCADDoc::~CMiniCADDoc()
- {
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMiniCADDoc serialization
- void CMiniCADDoc::Serialize(CArchive& ar)
- {
- if (ar.IsStoring())
- {
- // TODO: add storing code here
- }
- else
- {
- // TODO: add loading code here
- }
- FileInfo.Serialize(ar);
- MyOperate.Serialize(ar);
- }
- /////////////////////////////////////////////////////////////////////////////
- // CMiniCADDoc diagnostics
- #ifdef _DEBUG
- void CMiniCADDoc::AssertValid() const
- {
- CDocument::AssertValid();
- }
- void CMiniCADDoc::Dump(CDumpContext& dc) const
- {
- CDocument::Dump(dc);
- }
- #endif //_DEBUG
- /////////////////////////////////////////////////////////////////////////////
- // CMiniCADDoc commands
- BOOL CMiniCADDoc::OnNewDocument()
- {
- if (!CDocument::OnNewDocument())
- return FALSE;
- //获取新建文档的信息
- FileInfo = pApp->NewFileInfo;
- //改写最近文件列表
- pApp->pRecentFileList->Add((LPCTSTR)(FileInfo.FilePath + "\" + FileInfo.FileName));
- pApp->pRecentFileList->WriteList();
- return TRUE;
- }
- BOOL CMiniCADDoc::OnOpenDocument(LPCTSTR lpszPathName)
- {
- if (!CDocument::OnOpenDocument(lpszPathName))
- return FALSE;
- pApp->pRecentFileList->Add((LPCTSTR)(FileInfo.FilePath + "\" + FileInfo.FileName));
- pApp->pRecentFileList->WriteList();
- return TRUE;
- }
- void CMiniCADDoc::OnCloseDocument()
- {
- CDocument::OnCloseDocument();
- }
- BOOL CMiniCADDoc::SaveDocument()
- {
- // TODO: Add your specialized code here and/or call the base class
- /*
- int index;
- CMyObjectInfo* pLineInfo;
- CMyObjectInfo* pRectInfo;
- CMyObjectInfo* pCircleInfo;
- CMyObjectInfo* pArcInfo;
- index = 0;
- while(index < MyOperate.m_LineInfoArray.GetSize())
- {
- pLineInfo = (CMyObjectInfo*)MyOperate.m_LineInfoArray.GetAt(index);
- if(pLineInfo->m_del == TRUE)
- {
- delete (CMyLine*)MyOperate.m_LineArray.GetAt(index);
- MyOperate.m_LineArray.RemoveAt(index);
- delete (CMyObjectInfo*)MyOperate.m_LineInfoArray.GetAt(index);
- MyOperate.m_LineInfoArray.RemoveAt(index);
- }
- else
- index++;
- }
- index = 0;
- while(index < MyOperate.m_RectInfoArray.GetSize())
- {
- pRectInfo = (CMyObjectInfo*)MyOperate.m_RectInfoArray.GetAt(index);
- if(pRectInfo->m_del == TRUE)
- {
- delete (CMyRect*)MyOperate.m_RectArray.GetAt(index);
- MyOperate.m_RectArray.RemoveAt(index);
- delete (CMyObjectInfo*)MyOperate.m_RectInfoArray.GetAt(index);
- MyOperate.m_RectInfoArray.RemoveAt(index);
- }
- else
- index++;
- }
- index = 0;
- while(index < MyOperate.m_CircleInfoArray.GetSize())
- {
- pCircleInfo = (CMyObjectInfo*)MyOperate.m_CircleInfoArray.GetAt(index);
- if(pCircleInfo->m_del == TRUE)
- {
- delete (CMyCircle*)MyOperate.m_CircleArray.GetAt(index);
- MyOperate.m_CircleArray.RemoveAt(index);
- delete (CMyObjectInfo*)MyOperate.m_CircleInfoArray.GetAt(index);
- MyOperate.m_CircleInfoArray.RemoveAt(index);
- }
- else
- index++;
- }
- index = 0;
- while(index < MyOperate.m_ArcInfoArray.GetSize())
- {
- pArcInfo = (CMyObjectInfo*)MyOperate.m_ArcInfoArray.GetAt(index);
- if(pArcInfo->m_del == TRUE)
- {
- delete (CMyArc*)MyOperate.m_ArcArray.GetAt(index);
- MyOperate.m_ArcArray.RemoveAt(index);
- delete (CMyObjectInfo*)MyOperate.m_ArcInfoArray.GetAt(index);
- MyOperate.m_ArcInfoArray.RemoveAt(index);
- }
- else
- index++;
- }
- for(index = 0; index < MyCommand.m_CommandArray.GetSize(); index++)
- delete (CMyCommandStruct*)MyCommand.m_CommandArray.GetAt(index);
- MyCommand.m_CommandArray.RemoveAll();
- MyCommand.CommandPointer = -1;
- */
- CString PathName = FileInfo.FilePath + "\" + FileInfo.FileName;
- return CDocument::OnSaveDocument(PathName);
- }