155 lines
3.9 KiB
C++
155 lines
3.9 KiB
C++
// SpaceNameClassDlg.h: interface for the CSpaceNameClassDlg class.
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
#ifndef __SPACENAMECLASSDLG_H__
|
|
#define __SPACENAMECLASSDLG_H__
|
|
|
|
#if _MSC_VER > 1000
|
|
#pragma once
|
|
#endif // _MSC_VER > 1000
|
|
|
|
#include "resource.h"
|
|
|
|
|
|
// 数据结果类。读出来的数据放到这里
|
|
class CSpaceDataTable
|
|
{
|
|
public:
|
|
// 注意此处的顺序不可妄动!
|
|
enum EKeyWord{eHall = 0, eRoom, eToilet, eOther, eNum};
|
|
|
|
public:
|
|
// 非关键字则返回FALSE.其他 返回TRUE
|
|
BOOL TestKeyWord(CString sKey);
|
|
|
|
// 清空原有数据,添加新数据
|
|
void SetNameAry(CString sKey, const CStringArray &arName);
|
|
void SetNameAry(EKeyWord eKey, const CStringArray &arName);
|
|
|
|
// 追加,原有不变
|
|
void AppendNameAry(CString sKey, const CStringArray &arName);
|
|
void AppendNameAry(EKeyWord eKey, const CStringArray &arName);
|
|
void AddName(EKeyWord eKey, CString sName);
|
|
|
|
// 获取
|
|
int GetNameAry(EKeyWord key, CStringArray &ary) const;
|
|
|
|
// 根据当前DataTab中的内容,检测sName(非关键字)的类型
|
|
EKeyWord GetNameType(CString sName) const;
|
|
|
|
void Clear(EKeyWord eKey = eNum); // 清空名字数据
|
|
|
|
// 根据key获取对应的关键字名字,[**],无匹配,则返回其他
|
|
CString GetKeyName(EKeyWord eKey) const;
|
|
|
|
// 初始化关键字
|
|
static void InitKeyWords();
|
|
|
|
public:
|
|
// 文件关键字数组
|
|
static CStringArray m_arSKeyWord;
|
|
|
|
private:
|
|
// 根据key获取对应的数组,无匹配,则返回其他
|
|
const CStringArray& NameAry(EKeyWord eKey) const;
|
|
|
|
CStringArray& NameAry(EKeyWord eKey);
|
|
|
|
// 关键字名字 -> 关键字对应的枚举值,无匹配,则返回其他
|
|
EKeyWord Key(CString sName) const;
|
|
|
|
private:
|
|
CStringArray m_arNames[eNum];
|
|
};
|
|
|
|
|
|
|
|
// 房间名称文件处理器基类(spacenam.txt)
|
|
class CSpaceFileOperator
|
|
{
|
|
public:
|
|
CSpaceFileOperator(LPCTSTR szFileName);
|
|
~CSpaceFileOperator() {};
|
|
|
|
virtual BOOL ReadFile(CSpaceDataTable &dataTable) const;
|
|
virtual BOOL WriteFile(const CSpaceDataTable &dataTable) const;
|
|
|
|
static int SplitString(CString sAllName, CStringArray &arSName);
|
|
|
|
// 获得房间名称文件中,指定类型的数据,返回数组长度
|
|
int GetTypeNameAry(CSpaceDataTable::EKeyWord eNameType, CStringArray &arName) const;
|
|
|
|
protected:
|
|
CString m_sFileName;
|
|
|
|
private:
|
|
void Write(CStdioFile &txtFile, CString sKey, CStringArray &arSName) const;
|
|
};
|
|
|
|
|
|
// 房间名称对话框界面
|
|
class CSpaceNameClassDlg : public CModelessDialog
|
|
{
|
|
public:
|
|
// bHideParent表示屏幕取词时,是否需要关闭父类对话框
|
|
CSpaceNameClassDlg(bool bHideParent = true, CWnd* pParent = NULL);
|
|
virtual ~CSpaceNameClassDlg();
|
|
|
|
public:
|
|
//{{AFX_DATA(CSpaceNameClassDlg)
|
|
enum { IDD = IDD_DLG_SPACE_NAME };
|
|
// tab控件
|
|
CTabCtrl m_tab;
|
|
// tab中内嵌的List控件数组(3个)
|
|
CEdit m_arList[3];
|
|
//}}AFX_DATA
|
|
|
|
const UINT m_uLstNum;
|
|
|
|
public:
|
|
enum ECommandState {ePickName, eNone};
|
|
|
|
int GetTypeNameAry(CSpaceDataTable::EKeyWord eNameType, CStringArray &arName) const;
|
|
void AddStringToEdit(CSpaceDataTable::EKeyWord eIndex, CString sName);
|
|
void AddStringSToCurrEdit(CStringArray &sNames);
|
|
|
|
static void HideDialog(CWnd *pDlg, bool bHide);
|
|
|
|
static int DealNameSelectResult(PickSet &ssArea, CStringArray &arSArea);
|
|
static BOOL PickName(CSpaceNameClassDlg &dlg, CStringArray &arSName);
|
|
|
|
protected:
|
|
//{{AFX_VIRTUAL(CSpaceNameClassDlg)
|
|
virtual void DoDataExchange(CDataExchange* pDX);
|
|
//}}AFX_VIRTUAL
|
|
|
|
//{{AFX_MSG(CSpaceNameClassDlg)
|
|
virtual BOOL OnInitDialog();
|
|
|
|
afx_msg void OnBnClickedBtnQuery();
|
|
afx_msg void OnTcnSelchangeTabNameClass(NMHDR *pNMHDR, LRESULT *pResult);
|
|
afx_msg void OnBnClickedOk();
|
|
//}}AFX_MSG
|
|
DECLARE_MESSAGE_MAP()
|
|
|
|
protected:
|
|
void ShowEdit(CSpaceDataTable::EKeyWord eIndex);
|
|
|
|
void SetEditString(CSpaceDataTable::EKeyWord eType, const CStringArray &ary);
|
|
int GetEditString(CSpaceDataTable::EKeyWord eType, CStringArray &ary)const;
|
|
|
|
CSpaceDataTable::EKeyWord TabIndexToKey(int index) const;
|
|
|
|
protected:
|
|
// 数据表,文件中的数据,按照这个格式保存这里
|
|
CSpaceDataTable m_dataTable;
|
|
// 文件读取器
|
|
CSpaceFileOperator *m_pFileBase;
|
|
|
|
// 记录屏幕取词时,是否需要隐藏父类对话框
|
|
bool m_bHideParent;
|
|
};
|
|
|
|
#endif // !defined(__SPACENAMECLASSDLG_H__)
|