401 lines
10 KiB
C++
401 lines
10 KiB
C++
// ManageTKDlg.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
#include "ManageTKDlg.h"
|
|
#include "NewTKWDlg.h"
|
|
#include "TkwFile.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
extern CString GetFileNameByAllName(const TCHAR* szAllFileName);
|
|
extern CString GetPathNameByAllName(const TCHAR* szAllFileName);
|
|
|
|
int TKMgr()
|
|
{
|
|
CManageTKDlg dlg;
|
|
CTemporaryResourceOverride vTmp;
|
|
dlg.DoModal();
|
|
return RTNORM;
|
|
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CManageTKDlg dialog
|
|
|
|
|
|
CManageTKDlg::CManageTKDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(CManageTKDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(CManageTKDlg)
|
|
m_csDwb = _T("");
|
|
m_csDwb3d = _T("");
|
|
m_csSlb = _T("");
|
|
m_csText = _T("");
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
|
|
void CManageTKDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(CManageTKDlg)
|
|
DDX_Text(pDX, IDC_EDIT_ERR, m_csText);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
|
|
BEGIN_MESSAGE_MAP(CManageTKDlg, CDialog)
|
|
//{{AFX_MSG_MAP(CManageTKDlg)
|
|
ON_BN_CLICKED(IDC_BUTTON_DEL, OnButtonDel)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
// CManageTKDlg message handlers
|
|
|
|
void CManageTKDlg::OnOK()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
CNewTKWDlg dlg(_T("打开"), _T("上华图库组文件 (*.TKW) |*.TKW|上华图库文件 (*.TK) |*.tk||"));
|
|
if(dlg.DoModal()!=IDOK)
|
|
return;
|
|
if(!FindFile(dlg.GetPathName())) {
|
|
AfxMessageBox(_T("不存在此文件!请换一文件。"));
|
|
return;
|
|
}
|
|
|
|
m_csTK = _T("");
|
|
m_csTKW = _T("");
|
|
m_csText = _T("");
|
|
|
|
if(dlg.GetFileExt() == _T("tk") || dlg.GetFileExt() == _T("TK")){
|
|
m_csTK = dlg.GetPathName();
|
|
if(dlg.m_iTKType == 0)
|
|
m_bIsJpgShow = TRUE;
|
|
else
|
|
m_bIsJpgShow = FALSE;
|
|
ReadTK(m_csTK);
|
|
}
|
|
else {
|
|
m_csTKW = dlg.GetPathName();
|
|
XStringList lstFiles;
|
|
CTkwFile tkw(m_csTKW);
|
|
m_bIsJpgShow = tkw.m_bIsJpg;
|
|
tkw.GetTKList(lstFiles);
|
|
for(int i=0;i<lstFiles.Length();i++){
|
|
ReadTK(lstFiles[i]);
|
|
}
|
|
}
|
|
|
|
UpdateData(FALSE);
|
|
}
|
|
|
|
|
|
void CManageTKDlg::ReadTK(const TCHAR* szTK)
|
|
{
|
|
CString csTK = szTK;
|
|
CodeBase db;
|
|
XDbfTable *pTable = db.Open(csTK);
|
|
if(!pTable) {
|
|
AfxMessageBox(_T("TK文件只读或损坏!"));
|
|
return;
|
|
}
|
|
m_lstTK.Reset();
|
|
m_lstSlb.Reset();
|
|
m_lstDwb.Reset();
|
|
m_lstJpb.Reset();
|
|
m_lstDwb2d.Reset();
|
|
m_lstDwb3d.Reset();
|
|
m_lstSlb2.Reset();
|
|
m_lstDwb2.Reset();
|
|
m_lstJpb2.Reset();
|
|
m_lstDwb2d2.Reset();
|
|
m_lstDwb3d2.Reset();
|
|
|
|
|
|
CString xsDrawing;
|
|
for(pTable->MoveFirst(); !pTable->IsEOF(); pTable->MoveNext()) {
|
|
GET_FIELD(pTable, _T("Drawing"), xsDrawing);
|
|
if(!!xsDrawing)
|
|
m_lstTK.Append(tstrnew(xsDrawing));
|
|
}
|
|
|
|
XString xsDwb(256), xsDwb3d(256), xsDwb2d(256), xsSlb(256), xsJpb(256);
|
|
if(m_bIsJpgShow){
|
|
xsDwb3d << GetPathNameByAllName(csTK) << GetFileNameByAllName(csTK) << _T("_3d.DWB");
|
|
xsDwb2d << GetPathNameByAllName(csTK) << GetFileNameByAllName(csTK) << _T("_2d.DWB");
|
|
}
|
|
else
|
|
xsDwb << GetPathNameByAllName(csTK) << GetFileNameByAllName(csTK) << _T(".DWB");
|
|
xsSlb << GetPathNameByAllName(csTK) << GetFileNameByAllName(csTK) << _T(".SLB");
|
|
xsJpb << GetPathNameByAllName(csTK) << GetFileNameByAllName(csTK) << _T(".JPB");
|
|
|
|
m_csSlb = (const TCHAR*)xsSlb;
|
|
m_csDwb = (const TCHAR*)xsDwb;
|
|
m_csJpb = (const TCHAR*)xsJpb;
|
|
m_csDwb2d = (const TCHAR*)xsDwb2d;
|
|
m_csDwb3d = (const TCHAR*)xsDwb3d;
|
|
|
|
|
|
if(!m_bIsJpgShow){
|
|
XDrawingLib xDwb(m_csDwb);
|
|
XSlideLib xSlb(m_csSlb);
|
|
xDwb.GetAll(m_lstDwb);
|
|
xSlb.GetAll(m_lstSlb);
|
|
}
|
|
else{
|
|
XDrawingLib xDwb2d(m_csDwb2d);
|
|
XDrawingLib xDwb3d(m_csDwb3d);
|
|
XJpegLib xJpb(m_csJpb);
|
|
xJpb.GetAll(m_lstJpb);
|
|
xDwb2d.GetAll(m_lstDwb2d);
|
|
xDwb3d.GetAll(m_lstDwb3d);
|
|
}
|
|
|
|
|
|
int len = m_lstTK.Length();
|
|
if(!m_bIsJpgShow){
|
|
for(int n=0;n<m_lstDwb.Length();n++){
|
|
int index = -1;
|
|
index = m_lstTK.Index(m_lstDwb[n], FALSE);
|
|
if(index < 0)
|
|
m_lstDwb2.Append(tstrnew(m_lstDwb[n]));
|
|
}
|
|
for(int m=0;m<m_lstSlb.Length();m++){
|
|
int index = -1;
|
|
index = m_lstTK.Index(m_lstSlb[m], FALSE);
|
|
if(index < 0)
|
|
m_lstSlb2.Append(tstrnew(m_lstSlb[m]));
|
|
}
|
|
|
|
}
|
|
else{
|
|
for(int f=0;f<m_lstDwb2d.Length();f++){
|
|
int index = -1;
|
|
index = m_lstTK.Index(m_lstDwb2d[f], FALSE);
|
|
if(index < 0)
|
|
m_lstDwb2d2.Append(tstrnew(m_lstDwb2d[f]));
|
|
|
|
}
|
|
for(int j=0;j<m_lstJpb.Length();j++){
|
|
int index = -1;
|
|
index = m_lstTK.Index(m_lstJpb[j], FALSE);
|
|
if(index < 0)
|
|
m_lstJpb2.Append(tstrnew(m_lstJpb[j]));
|
|
}
|
|
for(int l=0;l<m_lstDwb3d.Length();l++){
|
|
int index = -1;
|
|
index = m_lstTK.Index(m_lstDwb3d[l], FALSE);
|
|
if(index < 0)
|
|
m_lstDwb3d2.Append(tstrnew(m_lstDwb3d[l]));
|
|
}
|
|
}
|
|
CString csTmp;
|
|
csTmp.Format(_T("TK:%s共计%d个记录%c\n"), csTK, len, 13);
|
|
m_csText += csTmp;
|
|
|
|
if(m_bIsJpgShow){
|
|
csTmp.Format(_T("图片库:%s共计 %d 个图片%c\n"), m_csJpb, m_lstJpb.Length(), 13);
|
|
m_csText += csTmp;
|
|
csTmp.Format(_T("2D库:%s共计 %d 个图块%c\n"), m_csDwb2d, m_lstDwb2d.Length(), 13);
|
|
m_csText += csTmp;
|
|
csTmp.Format(_T("3D库:%s共计 %d 个图块%c\n"), m_csDwb3d, m_lstDwb3d.Length(), 13);
|
|
m_csText += csTmp;
|
|
|
|
}
|
|
else{
|
|
csTmp.Format(_T("幻灯库:%s共计 %d 个幻灯%c\n"), m_csSlb, m_lstSlb.Length(), 13);
|
|
m_csText += csTmp;
|
|
csTmp.Format(_T("图库:%s共计 %d 个图块%c\n"), m_csDwb, m_lstDwb.Length(), 13);
|
|
m_csText += csTmp;
|
|
}
|
|
}
|
|
|
|
BOOL CManageTKDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
return TRUE; // return TRUE unless you set the focus to a control
|
|
// EXCEPTION: OCX Property Pages should return FALSE
|
|
}
|
|
|
|
void CManageTKDlg::RemoveJpbTK(const TCHAR* szTK)
|
|
{
|
|
CString csTK = szTK;
|
|
CodeBase db;
|
|
XDbfTable *pTable = db.Open(csTK);
|
|
if(!pTable) {
|
|
AfxMessageBox(_T("TK文件只读或损坏!"));
|
|
return;
|
|
}
|
|
m_lstTK.Reset();;
|
|
m_lstJpb.Reset();
|
|
m_lstDwb2d.Reset();
|
|
m_lstDwb3d.Reset();
|
|
m_lstJpb2.Reset();
|
|
m_lstDwb2d2.Reset();
|
|
m_lstDwb3d2.Reset();
|
|
|
|
|
|
CString xsDrawing;
|
|
for(pTable->MoveFirst(); !pTable->IsEOF(); pTable->MoveNext()) {
|
|
GET_FIELD(pTable, _T("Drawing"), xsDrawing);
|
|
if(!!xsDrawing)
|
|
m_lstTK.Append(tstrnew(xsDrawing));
|
|
}
|
|
|
|
XString xsDwb3d(256), xsDwb2d(256), xsJpb(256);
|
|
xsDwb3d << GetPathNameByAllName(csTK) << GetFileNameByAllName(csTK) << _T("_3d.DWB");
|
|
xsDwb2d << GetPathNameByAllName(csTK) << GetFileNameByAllName(csTK) << _T("_2d.DWB");
|
|
xsJpb << GetPathNameByAllName(csTK) << GetFileNameByAllName(csTK) << _T(".JPB");
|
|
|
|
m_csJpb = (const TCHAR*)xsJpb;
|
|
m_csDwb2d = (const TCHAR*)xsDwb2d;
|
|
m_csDwb3d = (const TCHAR*)xsDwb3d;
|
|
XDrawingLib xDwb2d(m_csDwb2d);
|
|
XDrawingLib xDwb3d(m_csDwb3d);
|
|
XJpegLib xJpb(m_csJpb);
|
|
xJpb.GetAll(m_lstJpb);
|
|
xDwb2d.GetAll(m_lstDwb2d);
|
|
xDwb3d.GetAll(m_lstDwb3d);
|
|
for(int f=0;f<m_lstDwb2d.Length();f++){
|
|
int index = -1;
|
|
index = m_lstTK.Index(m_lstDwb2d[f], FALSE);
|
|
if(index < 0)
|
|
m_lstDwb2d2.Append(tstrnew(m_lstDwb2d[f]));
|
|
|
|
}
|
|
for(int j=0;j<m_lstJpb.Length();j++){
|
|
int index = -1;
|
|
index = m_lstTK.Index(m_lstJpb[j], FALSE);
|
|
if(index < 0)
|
|
m_lstJpb2.Append(tstrnew(m_lstJpb[j]));
|
|
}
|
|
for(int l=0;l<m_lstDwb3d.Length();l++){
|
|
int index = -1;
|
|
index = m_lstTK.Index(m_lstDwb3d[l], FALSE);
|
|
if(index < 0)
|
|
m_lstDwb3d2.Append(tstrnew(m_lstDwb3d[l]));
|
|
}
|
|
acedSetStatusBarProgressMeter(XString(_T("删除%d个图片"), m_lstJpb2.Length()), 0, m_lstJpb2.Length());
|
|
for(int i=0;i<m_lstJpb2.Length();i++){
|
|
acedSetStatusBarProgressMeterPos(i);
|
|
CString s = (const TCHAR*)m_lstJpb2[i];
|
|
xJpb.Remove(s);
|
|
}
|
|
acedRestoreStatusBar();
|
|
acedSetStatusBarProgressMeter(XString(_T("删除%d个2d图块"), m_lstDwb2d2.Length()), 0, m_lstJpb2.Length());
|
|
for(i=0;i<m_lstDwb2d2.Length();i++){
|
|
acedSetStatusBarProgressMeterPos(i);
|
|
CString s = (const TCHAR*)m_lstDwb2d2[i];
|
|
xDwb2d.Remove(s);
|
|
}
|
|
acedRestoreStatusBar();
|
|
acedSetStatusBarProgressMeter(XString(_T("删除%d个3d图块"), m_lstDwb3d2.Length()), 0, m_lstJpb2.Length());
|
|
for(i=0;i<m_lstDwb3d2.Length();i++){
|
|
acedSetStatusBarProgressMeterPos(i);
|
|
CString s = (const TCHAR*)m_lstDwb3d2[i];
|
|
xDwb3d.Remove(s);
|
|
}
|
|
acedRestoreStatusBar();
|
|
|
|
}
|
|
|
|
void CManageTKDlg::RemoveSlbTK(const TCHAR* szTK)
|
|
{
|
|
CString csTK = szTK;
|
|
CodeBase db;
|
|
XDbfTable *pTable = db.Open(csTK);
|
|
if(!pTable) {
|
|
AfxMessageBox(_T("TK文件只读或损坏!"));
|
|
return;
|
|
}
|
|
m_lstTK.Reset();
|
|
m_lstSlb.Reset();
|
|
m_lstDwb.Reset();
|
|
m_lstJpb.Reset();
|
|
m_lstDwb2d.Reset();
|
|
m_lstDwb3d.Reset();
|
|
m_lstSlb2.Reset();
|
|
m_lstDwb2.Reset();
|
|
m_lstJpb2.Reset();
|
|
m_lstDwb2d2.Reset();
|
|
m_lstDwb3d2.Reset();
|
|
|
|
|
|
CString xsDrawing;
|
|
for(pTable->MoveFirst(); !pTable->IsEOF(); pTable->MoveNext()) {
|
|
GET_FIELD(pTable, _T("Drawing"), xsDrawing);
|
|
if(!!xsDrawing)
|
|
m_lstTK.Append(tstrnew(xsDrawing));
|
|
}
|
|
|
|
XString xsDwb(256), xsSlb(256);
|
|
xsDwb << GetPathNameByAllName(csTK) << GetFileNameByAllName(csTK) << _T(".DWB");
|
|
xsSlb << GetPathNameByAllName(csTK) << GetFileNameByAllName(csTK) << _T(".SLB");
|
|
m_csSlb = (const TCHAR*)xsSlb;
|
|
m_csDwb = (const TCHAR*)xsDwb;
|
|
XDrawingLib xDwb(m_csDwb);
|
|
XSlideLib xSlb(m_csSlb);
|
|
xDwb.GetAll(m_lstDwb);
|
|
xSlb.GetAll(m_lstSlb);
|
|
for(int n=0;n<m_lstDwb.Length();n++){
|
|
int index = -1;
|
|
index = m_lstTK.Index(m_lstDwb[n], FALSE);
|
|
if(index < 0)
|
|
m_lstDwb2.Append(tstrnew(m_lstDwb[n]));
|
|
}
|
|
for(int m=0;m<m_lstSlb.Length();m++){
|
|
int index = -1;
|
|
index = m_lstTK.Index(m_lstSlb[m], FALSE);
|
|
if(index < 0)
|
|
m_lstSlb2.Append(tstrnew(m_lstSlb[m]));
|
|
}
|
|
acedSetStatusBarProgressMeter(XString(_T("删除%d个幻灯"), m_lstSlb2.Length()), 0, m_lstJpb2.Length());
|
|
for(int i=0;i<m_lstSlb2.Length();i++){
|
|
acedSetStatusBarProgressMeterPos(i);
|
|
CString s = (const TCHAR*)m_lstSlb2[i];
|
|
xSlb.Remove(s);
|
|
}
|
|
acedRestoreStatusBar();
|
|
acedSetStatusBarProgressMeter(XString(_T("删除%d个图块"), m_lstDwb2.Length()), 0, m_lstJpb2.Length());
|
|
for(i=0;i<m_lstDwb2.Length();i++){
|
|
acedSetStatusBarProgressMeterPos(i);
|
|
CString s = (const TCHAR*)m_lstDwb2[i];
|
|
xDwb.Remove(s);
|
|
}
|
|
acedRestoreStatusBar();
|
|
}
|
|
|
|
void CManageTKDlg::OnButtonDel()
|
|
{
|
|
if(MessageBox(_T("您是否真的删除?"),_T("警告"),MB_OKCANCEL|MB_ICONQUESTION) != IDOK)
|
|
return;
|
|
|
|
if(m_csTK != _T("")){
|
|
if(m_bIsJpgShow)
|
|
RemoveJpbTK(m_csTK);
|
|
else
|
|
RemoveSlbTK(m_csTK);
|
|
}
|
|
else if(m_csTKW != _T("")){
|
|
XStringList lstFiles;
|
|
CTkwFile tkw(m_csTKW);
|
|
m_bIsJpgShow = tkw.m_bIsJpg;
|
|
tkw.GetTKList(lstFiles);
|
|
for(int i=0;i<lstFiles.Length();i++){
|
|
if(m_bIsJpgShow)
|
|
RemoveJpbTK(lstFiles[i]);
|
|
else
|
|
RemoveSlbTK(lstFiles[i]);
|
|
}
|
|
}
|
|
MessageBox(_T("清除完毕!"));
|
|
}
|
|
|