MyCADInfo.cpp
上传用户:netltd
上传日期:2013-02-12
资源大小:7234k
文件大小:5k
- // MyCADInfo.cpp : implementation file
- //////////////////////////////////////////////////////////////////////////////////////////////
- // CCADInfo
- #include "stdafx.h"
- #include "MyCADInfo.h"
- //////////////////////////////////////////////////////////////////////////////////////////////
- CCADInfo::CCADInfo()
- {
- char pDir[_MAX_PATH];
- //获取当前路径
- ::GetCurrentDirectory(_MAX_PATH,pDir);
- //省缺的项目文件路径为当前路径
- ProjectPath = pDir;
- //省缺的图纸文件路径为当前路径
- FilePath = pDir;
-
- IsEmpty = TRUE;
- KindofNew = NEW_NONE;
-
- PenColor = RGB(0, 0, 0); //缺省画笔颜色为黑色
- LineStyle = PS_SOLID; //缺省画笔线形
- //BackColor = RGB (200, 255, 255); //缺省背景色为淡青色
- BackColor = RGB (200, 200, 200); //缺省背景色为淡青色
-
- }
- CCADInfo::~CCADInfo()
- {
- }
- //////////////////////////////////////////////////////////////////////////////////////////////
- //CFileInfo
- IMPLEMENT_SERIAL(CFileInfo, CObject, 1)
- CFileInfo::CFileInfo(CString name, CString filename, CString filepath, CSize size,
- COLORREF pencolor, int linestyle, COLORREF backcolor)
- {
- m_Name = name;
- m_FileName = filename;
- m_FilePath = filepath;
- m_Size = size;
- m_PenColor = pencolor;
- m_LineStyle = linestyle;
- m_BackColor = backcolor;
- }
- CFileInfo::CFileInfo(const CFileInfo& Info)
- {
- m_Name = Info.m_Name;
- m_FileName = Info.m_FileName;
- m_FilePath = Info.m_FilePath;
- m_Size.cx = Info.m_Size.cx;
- m_Size.cy = Info.m_Size.cy;
- m_PenColor = Info.m_PenColor;
- m_BackColor = Info.m_BackColor;
- m_LineStyle = Info.m_LineStyle;
- }
- CFileInfo::operator =(const CFileInfo& Info)
- {
- m_Name = Info.m_Name;
- m_FileName = Info.m_FileName;
- m_FilePath = Info.m_FilePath;
- m_Size.cx = Info.m_Size.cx;
- m_Size.cy = Info.m_Size.cy;
- m_PenColor = Info.m_PenColor;
- m_BackColor = Info.m_BackColor;
- m_LineStyle = Info.m_LineStyle;
- }
- CFileInfo::~CFileInfo()
- {
- }
- void CFileInfo::Serialize(CArchive& ar)
- {
- if(ar.IsStoring())
- {
- ar << m_Name << m_FilePath << m_FileName << m_Size << m_PenColor
- << m_BackColor << m_LineStyle;
- }
- else
- {
- ar >> m_Name >> m_FilePath >> m_FileName >> m_Size >> m_PenColor
- >> m_BackColor >> m_LineStyle;
- }
- }
- //////////////////////////////////////////////////////////////////////////////////////////////
- IMPLEMENT_SERIAL(CFileIndex, CObject, 1)
- CFileIndex::CFileIndex(CString name, CString filename, CString filepath)
- {
- m_name = name;
- m_filename = filename;
- m_filepath = filepath;
- }
- CString CFileIndex::GetName()
- {
- return m_name;
- }
- CString CFileIndex::GetFileName()
- {
- return m_filename;
- }
- CString CFileIndex::GetFilePath()
- {
- return m_filepath;
- }
- void CFileIndex::SetFileIndex(CString name, CString filename, CString filepath)
- {
- m_name = name;
- m_filename = filename;
- m_filepath = filepath;
- }
- void CFileIndex::Serialize(CArchive &ar)
- {
- if(ar.IsStoring())
- {
- ar << m_name << m_filename << m_filepath;
- }
- else
- {
- ar >> m_name >> m_filename >> m_filepath;
- }
- }
- //////////////////////////////////////////////////////////////////////////////////////////////
- // CProjectInfo
- IMPLEMENT_SERIAL(CProjectInfo, CObject, 1)
- CProjectInfo::CProjectInfo()
- {
- }
- CProjectInfo::~CProjectInfo()
- {
- for(int i = 0; i < m_FileIndexArray.GetSize(); i++)
- delete (CFileIndex*)m_FileIndexArray.GetAt(i);
- m_FileIndexArray.RemoveAll();
- }
- void CProjectInfo::AddFileIndex(CString name, CString filename, CString filepath)
- {
- CFileIndex* pFileIndex = new CFileIndex(name, filename, filepath);
- m_FileIndexArray.Add(pFileIndex);
- }
- void CProjectInfo::DelFileIndex(CString name)
- {
- for(int i = 0; i < m_FileIndexArray.GetSize(); i++)
- {
- CFileIndex* pFileIndex = (CFileIndex*)m_FileIndexArray.GetAt(i);
- if(pFileIndex->GetFileName() == name)
- {
- delete pFileIndex;
- m_FileIndexArray.RemoveAt(i);
- }
- }
- }
- int CProjectInfo::GetFileIndexNum()
- {
- return m_FileIndexArray.GetSize();
- }
- CFileIndex* CProjectInfo::GetFileIndex(int index)
- {
- ASSERT(index >= 0 && index < m_FileIndexArray.GetSize());
- return (CFileIndex*)m_FileIndexArray.GetAt(index);
- }
- CFileIndex* CProjectInfo::FindFileIndex(CString name)
- {
- //name是图纸名
- for(int i = 0; i < m_FileIndexArray.GetSize(); i++)
- {
- CFileIndex* pFileIndex = (CFileIndex*)m_FileIndexArray.GetAt(i);
- if(pFileIndex->GetName() == name)
- return pFileIndex;
- }
- return NULL;
- }
- void CProjectInfo::Serialize(CArchive& ar)
- {
- if(ar.IsStoring())
- {
- ar << Name << FileName << FilePath;
- }
- else
- {
- ar >> Name >> FileName >> FilePath;
- }
- m_FileIndexArray.Serialize(ar);
- }