📄 editdialog.cpp
字号:
// EditDialog.cpp : implementation file
//
#include "stdafx.h"
#include "map.h"
#include "EditDialog.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CEditDialog dialog
CEditDialog::CEditDialog(CWnd* pParent /*=NULL*/)
: CDialog(CEditDialog::IDD, pParent),m_algraph(0)
{
//{{AFX_DATA_INIT(CEditDialog)
m_selectchange = -1;
m_selectcity = -1;
//}}AFX_DATA_INIT
}
void CEditDialog::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CEditDialog)
DDX_Radio(pDX, IDC_CHANGE, m_selectchange);
DDX_Radio(pDX, IDC_CITY_RADIO, m_selectcity);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CEditDialog, CDialog)
//{{AFX_MSG_MAP(CEditDialog)
ON_BN_CLICKED(IDC_CHANGE, OnChange)
ON_BN_CLICKED(IDC_INSERT, OnInsert)
ON_BN_CLICKED(IDC_DELETE, OnDelete)
ON_BN_CLICKED(IDC_CITY_RADIO, OnCityRadio)
ON_BN_CLICKED(IDC_INFO_RADIO, OnInfoRadio)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CEditDialog message handlers
//DEL ALGraph * & CEditDialog::GetALGraph()
//DEL {
//DEL return m_algraph;
//DEL }
void CEditDialog::OnChangRadio()
{
// TODO: Add your control notification handler code here
}
void CEditDialog::SetGraph(ALGraph * temp)
{
m_algraph=temp;
}
void CEditDialog::OnOK()
{
// TODO: Add extra validation here
if(m_selectchange==-1||m_selectcity==-1)
{
AfxMessageBox("你必须先选择才能继续!");
return;
}
CDialog::OnOK();
//根据m_selectchange和m_selectcity的值执行不同的窗口
//写入下一个窗口的信息!
switch(m_selectchange)
{
case 0:
{
switch(m_selectcity)
{
case 0://修改城市名
{
CChangeNameDialog m_changenamedialog;
if(m_algraph->m_vexnum==0) break;//当地图是空时,
//则不能进行修改
m_changenamedialog.SetALGraph(m_algraph);
m_changenamedialog.DoModal();
break;
}
case 1://修改城市间的信息
{
if(m_algraph->m_vexnum==0||m_algraph->m_arcnum==0)
{
AfxMessageBox("目前地图无信息可编辑!");
return;
}
CChangeinfoDialog m_changeinfodialog;
m_changeinfodialog.SetGraph(m_algraph);
m_changeinfodialog.DoModal();
break;
}
}
break;
}
case 1:
{
switch(m_selectcity)
{
case 0://插入城市
{
if(m_algraph==NULL) return;
CInsertnameDialog m_insertdialog;
m_insertdialog.SetALGraph(m_algraph);
m_insertdialog.DoModal();//插入城市
break;
}
case 1://插入城市信息
{
if(m_algraph==NULL) {AfxMessageBox("请先建立一个地图!");return;}
CInsertinfoDialog m_insertdialog;
m_insertdialog.SetGraph(m_algraph);
m_insertdialog.DoModal();
break;
}
}
break;
}
case 2:
{
switch(m_selectcity)
{
case 0://删除城市
{
if(m_algraph==NULL||m_algraph->m_vexnum==0)
{
AfxMessageBox("你还未输入地图或你的地图是空的");
return;
}
CDeletenameDialog m_deletedialog;
m_deletedialog.SetGraph(m_algraph);
m_deletedialog.DoModal();
break;
}
case 1://删除城市信息
{
if(m_algraph==NULL||m_algraph->m_vexnum==0||m_algraph->m_arcnum==0)
{
AfxMessageBox("没有信息可删除!");
return;
}
CDeleteinfoDialog m_deleteinfodialog;
m_deleteinfodialog.SetGraph(m_algraph);
m_deleteinfodialog.DoModal();
break;
}
}
break;
}
}
}
void CEditDialog::OnChange()
{
// TODO: Add your control notification handler code here
m_selectchange=0;
}
void CEditDialog::OnInsert()
{
// TODO: Add your control notification handler code here
m_selectchange=1;
}
void CEditDialog::OnDelete()
{
// TODO: Add your control notification handler code here
m_selectchange=2;
}
void CEditDialog::OnCityRadio()
{
// TODO: Add your control notification handler code here
m_selectcity=0;
}
void CEditDialog::OnInfoRadio()
{
// TODO: Add your control notification handler code here
m_selectcity=1;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -