?? b2007dlg.cpp
字號:
// B2007Dlg.cpp : implementation file
//
#include "stdafx.h"
#include "B2007.h"
#include "B2007Dlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CB2007Dlg dialog
CB2007Dlg::CB2007Dlg(CWnd* pParent /*=NULL*/)
: CDialog(CB2007Dlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CB2007Dlg)
m_nBegin = 0;
m_nEnd = 0;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CB2007Dlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CB2007Dlg)
DDX_Text(pDX, IDC_BEGIN, m_nBegin);
DDX_Text(pDX, IDC_END, m_nEnd);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CB2007Dlg, CDialog)
//{{AFX_MSG_MAP(CB2007Dlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_INIT, OnInit)
ON_BN_CLICKED(IDC_QUERY, OnQuery)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CB2007Dlg message handlers
BOOL CB2007Dlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
return TRUE; // return TRUE unless you set the focus to a control
}
void CB2007Dlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CB2007Dlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CB2007Dlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CB2007Dlg::OnInit()
{
// TODO: Add your control notification handler code here
CString strBusLine = "1.1 公汽線路信息.txt";
CString strSubLine="1.2 地鐵線路信息.txt";
CString strT1 = "2.1 地鐵T1線換乘公汽信息.txt";
CString strT2 = "2.2 地鐵T2線換乘公汽信息.txt";
CString strPath = GetPath();
CString strFile = strPath + strBusLine;
CStdioFile f;
if(f.Open(strFile,CFile::modeRead|CFile::shareDenyWrite)!=TRUE)
{
MessageBox("文件打開錯誤!",strFile);
return;
}
BeginWaitCursor();
do
{
WORD curLine = 0;
// L001
// 分段計價。
// S0619-S1914-S0388-S0348-S0392
//
// L002
// 分段計價。
// 上行:S3748-S2160-S1223-S1404
// 下行:S0004-S1968-S0012-S2636
// L003
// 單一票制1元。
// S0417-S0272-S1973-S3425-S1433
CString strLine;
VERIFY(f.ReadString(strLine));
if(strLine.Left(3) == "END")break;
//Read LineNum
VERIFY(strLine[0] == 'L');
curLine = atoi(strLine.Mid(1));
//Read Fee
VERIFY(f.ReadString(strLine));
if(strLine.Left(4) == "分段")
{
m_Lines[curLine*2].m_FeeType = fe_Float;
m_Lines[curLine*2].m_Fee.Section = SECTION_PER_YUAN;
m_Lines[curLine*2+1].m_FeeType = fe_Float;
m_Lines[curLine*2+1].m_Fee.Section = SECTION_PER_YUAN;
}
else
{
ASSERT(strLine.Left(4) == "單一");
m_Lines[curLine*2].m_FeeType = fe_Fix;
m_Lines[curLine*2].m_Fee.Yuan = strLine[8] - '0';
m_Lines[curLine*2+1].m_FeeType = fe_Fix;
m_Lines[curLine*2+1].m_Fee.Yuan = strLine[8] - '0';
}
//兩行
for(int nnn = 0; nnn < 2; nnn ++)
{
VERIFY(f.ReadString(strLine));
Station station;
WORD * pStations = new WORD[MAX_STAION];
int nCount;
if(strLine.Left(4) == "環行")
{
strLine = strLine.Mid(6);
nCount = ParseLine(strLine,pStations,curLine);
//First
station.m_wSeq = 1;
station.m_wNext = pStations[1];
station.m_wLast = pStations[nCount -2];
//0
m_Lines[curLine*2].m_pSations[pStations[0]] = station;
for(int i = 1; i<nCount -1; i++)
{
memset(&station,0,sizeof(station));
station.m_wSeq = i+1;
station.m_wNext = pStations[i+1];
station.m_wLast = pStations[i-1];
m_Lines[curLine*2].m_pSations[pStations[i]] = station;
}
}
else if(strLine.Left(4) == "上行")
{
strLine = strLine.Mid(6);
nCount = ParseLine(strLine,pStations,curLine);
//First
station.m_wSeq = 1;
station.m_wNext = pStations[1];
station.m_wLast = 0;
//0
m_Lines[curLine*2].m_pSations[pStations[0]] = station;
for(int i = 1; i<nCount -1; i++)
{
memset(&station,0,sizeof(station));
station.m_wSeq = i+1;
station.m_wNext = pStations[i+1];
station.m_wLast = pStations[i-1];
m_Lines[curLine*2].m_pSations[pStations[i]] = station;
}
//Last
station.m_wSeq = nCount;
station.m_wNext = 0;
station.m_wLast = pStations[i-1];
//0
m_Lines[curLine*2].m_pSations[pStations[i]] = station;
}
else if(strLine.Left(4) == "下行")
{
strLine = strLine.Mid(6);
nCount = ParseLine(strLine,pStations,curLine);
//First
station.m_wSeq = 1;
station.m_wNext = pStations[1];
station.m_wLast = 0;
//0
m_Lines[curLine*2+1].m_pSations[pStations[0]] = station;
for(int i = 1; i<nCount -1; i++)
{
memset(&station,0,sizeof(station));
station.m_wSeq = i+1;
station.m_wNext = pStations[i+1];
station.m_wLast = pStations[i-1];
m_Lines[curLine*2+1].m_pSations[pStations[i]] = station;
}
//Last
station.m_wSeq = nCount;
station.m_wNext = 0;
station.m_wLast = pStations[i-1];
//0
m_Lines[curLine*2+1].m_pSations[pStations[i]] = station;
}
else if(strLine.GetLength() < 4)//空行
{
int m;
m = 3;
}
else//上下行一致
{
nCount = ParseLine(strLine,pStations,curLine);
//First
station.m_wSeq = 1;
station.m_wNext = pStations[1];
station.m_wLast = 0;
//0
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -