📄 mainfrm.cpp
字号:
void CMainFrame::OnAliFileSave()
{
// TODO: Add your command handler code here
if( m_strFilePathName.IsEmpty() || m_strFileExtName.IsEmpty() )
return;
SaveFile(m_strFilePathName);
}
void CMainFrame::OnUpdateAliFileSaveAs(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if( m_strFilePathName.IsEmpty() )
pCmdUI->Enable(FALSE);
else
pCmdUI->Enable(TRUE);
}
void CMainFrame::OnAliFileSaveAs()
{
// TODO: Add your command handler code here
if( m_strFilePathName.IsEmpty() )
return;
CString strCurrentExt = m_strFilePathName.Right(4);
int nCount = m_strFilePathName.GetLength() - 4;
CString strInit = m_strFilePathName.Left(nCount) + ".abs";
CFileDlg fd(FALSE, NULL, strInit, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_CREATEPROMPT,
"Only Default Database(*.ddf)|Open Bin File(*.abs)");
if(fd.DoModal() != IDOK) return;
CString strFilePathName = fd.GetPathName();
CString strExt = strFilePathName.Right(4);
WIN32_FIND_DATA FindFileData;
HANDLE hFind = FindFirstFile(strFilePathName, &FindFileData);
CString strResult;
if( !strExt.CompareNoCase(".abs") )
{
if( hFind == INVALID_HANDLE_VALUE )
{
if( !strCurrentExt.CompareNoCase(".abs") )
{
CopyFile(m_strFilePathName, strFilePathName, TRUE);
}
else
{
strResult.Format("Not Support Save \"%s\" As \"%s\" File", strCurrentExt, strExt);
AfxMessageBox(strResult);
return;
}
}
}
else if( !strExt.CompareNoCase(".ddf") )
{
;//nothing to do
}
else
{
strResult.Format("Not Support Save as \"%s\" File", strExt);
AfxMessageBox(strResult);
return;
}
SaveFile(strFilePathName);
}
BOOL CMainFrame::SaveFile(CString &strFilePathName)
{
if( strFilePathName.GetLength() < 4 )
return FALSE;
CString fext = strFilePathName.Right(3);
if( !fext.CompareNoCase("abs") )
{
CDlgDbTypeSelect dlg;
dlg.DoModal();
if( dlg.m_bDbType == 0)
{
m_dbParser.SaveAsBinDdb(strFilePathName);
}
else
{
m_dbParser.SaveAsBinUdb(strFilePathName);
}
}
else if(!fext.CompareNoCase("udf"))
{
m_dbParser.SaveAsUdf(strFilePathName);
}
else if(!fext.CompareNoCase("ddf"))
{
m_dbParser.SaveAsDdf(strFilePathName);
}
else if(!fext.CompareNoCase("df2"))
{
}
else
{
ASSERT(FALSE);
return FALSE;
}
g_bModifyed = false;
return TRUE;
}
CNavigator *CMainFrame::GetNavigator()
{
return (CNavigator *)m_split.GetPane(0, 0);
}
//CBackDropView *CMainFrame::GetBackDropView()
//{
// CRightPane *pRightPane = (CRightPane *)m_split.GetPane(0, 1);
// if(!pRightPane) return NULL;
//
// return pRightPane->GetBackDropView();
//}
CAliEditorView *CMainFrame::GetEditorView()
{
CRightPane *pRightPane = (CRightPane *)m_split.GetPane(0, 1);
if(!pRightPane) return NULL;
return pRightPane->GetEditorView();
}
CSwitchView *CMainFrame::GetSwitchView()
{
CRightPane *pRightPane = (CRightPane *)m_split.GetPane(0, 1);
if(!pRightPane) return NULL;
return pRightPane->GetSwitchView();
}
void CMainFrame::OnUpdateDataUpload(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
void CMainFrame::OnDataUpload()
{
// TODO: Add your command handler code here
CUploadDlg dlg;
dlg.m_Port = m_com_port;
dlg.m_Baud = m_bits_rate;
CFileDlg fd(FALSE, NULL, "", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "Save Bin File(*.abs)");
if(fd.DoModal() != IDOK) return;
//close current file
if( !m_strFilePathName.IsEmpty() )
{
CloseFile();
}
dlg.m_Path = fd.GetPathName();
if(dlg.DoModal() != IDOK) return;
//open
::SetCursor(g_hCSBusy);
::SetClassLong(GetSafeHwnd(), GCL_HCURSOR, NULL);
m_strFilePathName = fd.GetPathName();
m_strFileExtName = fd.GetFileExt();
g_bModifyed = false;
CDlgDbTypeSelect dlgSelect;
dlgSelect.DoModal();
if( dlgSelect.m_bDbType == 0)
{
if( !m_dbParser.GenDdbFromBin(m_strFilePathName) )
{
m_strFilePathName.Empty();
::SetCursor(g_hCSNormal);
::SetClassLong(GetSafeHwnd(), GCL_HCURSOR, NULL);
return;
}
}
else
{
if( !m_dbParser.GenUdbFromBin(m_strFilePathName) )
{
m_strFilePathName.Empty();
::SetCursor(g_hCSNormal);
::SetClassLong(GetSafeHwnd(), GCL_HCURSOR, NULL);
return;
}
}
GetNavigator()->InitTreeNode();
::SetCursor(g_hCSNormal);
::SetClassLong(GetSafeHwnd(), GCL_HCURSOR, NULL);
SetWindowText("AliEditor - "+ m_strFilePathName);
// m_upgrade_bin = dlg.m_Path;
// UpdateDataBase(m_upgrade_bin);
// SetWindowText("AliEditor - " + fd.GetFileName());
}
void CMainFrame::OnUpdateDataDownload(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
if( m_strFilePathName.IsEmpty() ||
( strcmp(m_strFilePathName.Right(3), "abs") != 0) )
pCmdUI->Enable(FALSE);
else
pCmdUI->Enable(TRUE);
}
void CMainFrame::OnDataDownload()
{
// TODO: Add your command handler code here
CAliEditorView *pListView = GetEditorView();
if(!pListView) return;
// SaveDataNotice();
CString m_upgrade_bin = m_strFilePathName;
if(m_upgrade_bin.IsEmpty())
{
AfxMessageBox("No File opened");
return;
}
if( g_bModifyed )//&& AfxMessageBox("Save File?",MB_YESNO) == IDYES )
{
SaveFile(m_strFilePathName);
}
CDownLoad dlg;
dlg.m_Port = m_com_port;
dlg.m_Baud = m_bits_rate;
dlg.m_Path = m_strFilePathName;
dlg.m_bootloader = 0;//m_bootload_check;
dlg.m_bDownLoadDdb = m_bDownLoadDdb;
dlg.m_bDownLoadUdb = m_bDownLoadUdb;
// pListView->m_dirty_flag = 1;
// pListView->SaveDataBase();
// pListView->m_dirty_flag = 0;
dlg.DoModal();
}
void CMainFrame::OnUpdateOtherBinDownload(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
}
void CMainFrame::OnOtherBinDownload()
{
// TODO: Add your command handler code here
CFileDlg fdlg(TRUE, NULL, "", OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, "ABS File(*.abs)");
if(fdlg.DoModal() != IDOK) return;
CDownLoad dlg;
dlg.m_Port = m_com_port;
dlg.m_Baud = m_bits_rate;
dlg.m_Path = fdlg.GetPathName();
dlg.m_bootloader = 0;//m_bootload_check;
dlg.m_bDownLoadDdb = m_bDownLoadDdb;
dlg.m_bDownLoadUdb = m_bDownLoadUdb;
if( strcmp(dlg.m_Path.Right(3), "abs") == 0 )
{
dlg.DoModal();
}
else
{
AfxMessageBox("Only whole abs file could be downloaded.");
}
}
void CMainFrame::OnSerialPort()
{
// TODO: Add your command handler code here
CSerialPort dlg;
dlg.m_com_port_val = m_com_port;
if(dlg.DoModal() != IDOK) return;
m_com_port = dlg.m_com_port_val;
m_bits_rate = dlg.m_bits_rate_val;
m_data_parity = dlg.m_data_parity_val;
m_data_bits = dlg.m_data_bits_val;
m_stop_bits = dlg.m_stop_bits_val;
}
void CMainFrame::OnDownloadSetting()
{
// TODO: Add your command handler code here
CDlgDownLoadSet dlg;
dlg.m_bDdbCheck = m_bDownLoadDdb;
dlg.m_bUdbCheck = m_bDownLoadUdb;
if( dlg.DoModal() != IDOK )
return;
m_bDownLoadDdb = dlg.m_bDdbCheck;
m_bDownLoadUdb = dlg.m_bUdbCheck;
}
void CMainFrame::OnDestroy()
{
CFrameWnd::OnDestroy();
// TODO: Add your message handler code here
CloseFile();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -