230 lines
6.0 KiB
C++
230 lines
6.0 KiB
C++
#include "stdafx.h"
|
|
#include "resource.h"
|
|
#include "TJSZDlg.h"
|
|
#include "UITools.h"
|
|
#include "EWCheckerData.h"
|
|
|
|
IMPLEMENT_DYNAMIC(CTJSZDlg, CDialog)
|
|
|
|
#define DEF_DIST 200.
|
|
#define DEF_VENNUM 1.
|
|
|
|
CTJSZDlg::CTJSZDlg(const MK_DIM::NodeDim::ENodeType &type
|
|
, const std::vector<CString> &tanks
|
|
, CWnd* pParent)
|
|
: CDialog(IDD_TJSZ_DLG, pParent)
|
|
, m_type(type)
|
|
, m_tanks(tanks)
|
|
, m_sEditLable(_T(""))
|
|
{ }
|
|
|
|
CTJSZDlg::~CTJSZDlg() { }
|
|
|
|
void CTJSZDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_LIST1, m_lstCtrl);
|
|
DDX_Control(pDX, IDC_LIST1, m_lstCtrl);
|
|
DDX_Text(pDX, IDC_EDIT1, m_sEditLable);
|
|
DDX_Control(pDX, IDC_EDIT1, m_editLable);
|
|
}
|
|
|
|
BOOL CTJSZDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
DWORD dwStyle = m_lstCtrl.GetExtendedStyle();
|
|
dwStyle |= LVS_EX_FULLROWSELECT;
|
|
dwStyle |= LVS_EX_GRIDLINES;
|
|
m_lstCtrl.SetExtendedStyle(dwStyle); //设置扩展风格
|
|
|
|
m_lstCtrl.InsertColumn(0, _T("舱室名称"), LVCFMT_CENTER, 80);
|
|
CString nodeName(getNodeName(m_type)), strDist(_T("最大间距(米)"));
|
|
SetWindowText(_T("设置") + nodeName + _T("统计参数"));
|
|
switch (m_type)
|
|
{
|
|
case MK_DIM::NodeDim::eDrainWell:
|
|
m_lstCtrl.InsertColumn(1, nodeName + strDist, LVCFMT_CENTER, 130);
|
|
break;
|
|
case MK_DIM::NodeDim::eDoghouse:
|
|
m_lstCtrl.InsertColumn(1, nodeName + strDist, LVCFMT_CENTER, 130);
|
|
break;
|
|
case MK_DIM::NodeDim::eVenDoghouse:
|
|
m_lstCtrl.InsertColumn(1, nodeName + strDist, LVCFMT_CENTER, 130);
|
|
m_lstCtrl.InsertColumn(2, _T("通风次数(次)"), LVCFMT_CENTER, 100);
|
|
break;
|
|
case MK_DIM::NodeDim::eFireWall:
|
|
m_lstCtrl.InsertColumn(1, nodeName + strDist, LVCFMT_CENTER, 130);
|
|
break;
|
|
case MK_DIM::NodeDim::eEscapeHatch:
|
|
m_lstCtrl.InsertColumn(1, nodeName + strDist, LVCFMT_CENTER, 130);
|
|
break;
|
|
case MK_DIM::NodeDim::eOutlet:
|
|
m_lstCtrl.InsertColumn(1, nodeName + strDist, LVCFMT_CENTER, 160);
|
|
break;
|
|
case MK_DIM::NodeDim::eNone:
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
GLStatistics::TJConfig config;
|
|
GLStatistics::readConfig(config);
|
|
|
|
double dDefDist(DEF_DIST), dVenNum(DEF_VENNUM);
|
|
|
|
CString typeName(_T("")), typeValue(_T("")), venNum(_T(""));
|
|
for (size_t i = 0; i < m_tanks.size(); ++i)
|
|
{
|
|
CString &tank(m_tanks[i]);
|
|
int nRow = m_lstCtrl.InsertItem(0, m_tanks[i]);
|
|
//m_lstCtrl.SetItemText(nRow, 1, _T("200"));
|
|
|
|
bool bHasConfig(false);
|
|
GLStatistics::TJConfig::const_iterator it = config.find(tank);
|
|
|
|
if (it != config.end()) // 说明存在这个舱体的配置
|
|
{
|
|
bHasConfig = true;
|
|
typeName = MK_DIM::getNodeName(m_type);
|
|
|
|
std::map<CString, double>::const_iterator itSub = it->second.find(typeName);
|
|
if (itSub != it->second.end()) // 存在这个类型的配置
|
|
typeValue.Format(_T("%.3f"), itSub->second);
|
|
else
|
|
typeValue.Format(_T("%.3f"), dDefDist);
|
|
|
|
if (m_type == MK_DIM::NodeDim::eVenDoghouse)
|
|
{
|
|
itSub = it->second.find(VEN_NUM);
|
|
if (itSub != it->second.end())
|
|
venNum.Format(_T("%.3f"), itSub->second);
|
|
else
|
|
venNum.Format(_T("%.3f"), dVenNum);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
typeValue.Format(_T("%.3f"), dDefDist);
|
|
if (m_type == MK_DIM::NodeDim::eVenDoghouse)
|
|
venNum.Format(_T("%.1f"), dVenNum);
|
|
}
|
|
|
|
m_lstCtrl.SetItemText(nRow, 1, typeValue);
|
|
if (m_type == MK_DIM::NodeDim::eVenDoghouse)
|
|
m_lstCtrl.SetItemText(nRow, 2, venNum);
|
|
}
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CTJSZDlg, CDialog)
|
|
ON_BN_CLICKED(IDOK, &CTJSZDlg::OnBnClickedOk)
|
|
ON_BN_CLICKED(IDCANCLE, &CTJSZDlg::OnBnClickedCancle)
|
|
ON_NOTIFY(NM_DBLCLK, IDC_LIST1, &CTJSZDlg::OnNMDblclkList1)
|
|
ON_EN_KILLFOCUS(IDC_EDIT1, &CTJSZDlg::OnEnKillfocusEdit1)
|
|
END_MESSAGE_MAP()
|
|
|
|
void CTJSZDlg::OnBnClickedOk()
|
|
{
|
|
CString path = GLStatistics::getConfigFilePath();
|
|
|
|
// 文件不存在,新建
|
|
CString sTmp(_T("")), sSec(_T("")), sKey(_T("")), sValue(_T(""));
|
|
if (_taccess(path, 0x0) != 0x0)
|
|
{
|
|
CStdioFile file(path, CFile::modeCreate | CFile::modeWrite);
|
|
if (!file.m_hFile)
|
|
{
|
|
AfxMessageBox(_T("管廊统计配置文件创建失败。"));
|
|
return;
|
|
}
|
|
file.Close();
|
|
}
|
|
for (int i = 0; i < m_lstCtrl.GetItemCount(); ++i)
|
|
{
|
|
sSec = m_lstCtrl.GetItemText(i, 0);
|
|
sKey = MK_DIM::getNodeName(m_type);
|
|
sValue = m_lstCtrl.GetItemText(i, 1);
|
|
::WritePrivateProfileString(sSec, sKey, sValue, path);
|
|
if (m_type == MK_DIM::NodeDim::eVenDoghouse)
|
|
{
|
|
sKey = VEN_NUM;
|
|
sValue = m_lstCtrl.GetItemText(i, 2);
|
|
::WritePrivateProfileString(sSec, sKey, sValue, path);
|
|
}
|
|
}
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
void CTJSZDlg::OnBnClickedCancle()
|
|
{
|
|
CDialog::OnCancel();
|
|
}
|
|
|
|
void CTJSZDlg::OnNMDblclkList1(NMHDR *pNMHDR, LRESULT *pResult)
|
|
{
|
|
//LPNMITEMACTIVATE pNMItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pNMHDR);
|
|
NM_LISTVIEW *pNMListCtrl = (NM_LISTVIEW *)pNMHDR;
|
|
*pResult = 0;
|
|
if (pNMListCtrl->iItem == -1) return;
|
|
if (pNMListCtrl->iSubItem <= 0) return;
|
|
|
|
m_Idx = pNMListCtrl->iItem;
|
|
m_subIdx = pNMListCtrl->iSubItem;
|
|
|
|
CString str = m_lstCtrl.GetItemText(m_Idx, m_subIdx);
|
|
|
|
CRect rect, dlgRect;
|
|
int width = m_lstCtrl.GetColumnWidth(pNMListCtrl->iSubItem);
|
|
m_lstCtrl.GetSubItemRect(pNMListCtrl->iItem, pNMListCtrl->iSubItem, LVIR_BOUNDS, rect);
|
|
m_lstCtrl.GetWindowRect(&dlgRect);
|
|
ScreenToClient(&dlgRect);
|
|
int height = rect.Height();
|
|
rect.top += (dlgRect.top + 1);
|
|
rect.left += (dlgRect.left + 1);
|
|
rect.bottom = rect.top + height + 2;
|
|
rect.right = rect.left + width + 2;
|
|
m_editLable.MoveWindow(&rect);
|
|
m_editLable.ShowWindow(SW_SHOW);
|
|
m_editLable.SetWindowText(str);
|
|
m_editLable.SetFocus();
|
|
}
|
|
|
|
|
|
void CTJSZDlg::OnEnKillfocusEdit1()
|
|
{
|
|
UpdateData(TRUE);
|
|
|
|
if (!StakeTools::IsDoubleString(m_sEditLable))
|
|
AfxMessageBox(_T("请输入一个数字。"));
|
|
else
|
|
m_lstCtrl.SetItemText(m_Idx, m_subIdx, m_sEditLable);
|
|
m_editLable.SetWindowText(_T(""));
|
|
m_editLable.ShowWindow(SW_HIDE);
|
|
m_Idx = m_subIdx = -1;
|
|
m_lstCtrl.Invalidate();
|
|
}
|
|
|
|
|
|
BOOL CTJSZDlg::PreTranslateMessage(MSG* pMsg)
|
|
{
|
|
if (pMsg->message == WM_KEYDOWN && pMsg->wParam == VK_RETURN)
|
|
{
|
|
if (GetFocus() == &m_editLable)
|
|
m_lstCtrl.SetFocus();
|
|
return TRUE;
|
|
}
|
|
if (pMsg->message == WM_LBUTTONDOWN && GetFocus() == &m_editLable)
|
|
{
|
|
CRect rect;
|
|
m_editLable.GetWindowRect(rect);
|
|
if (rect.PtInRect(pMsg->pt))
|
|
{
|
|
m_editLable.PostMessage(WM_LBUTTONDOWN, pMsg->wParam, pMsg->lParam);
|
|
return TRUE;
|
|
}
|
|
}
|
|
return CDialog::PreTranslateMessage(pMsg);
|
|
}
|