119 lines
3.7 KiB
C++
119 lines
3.7 KiB
C++
// CSelectTankDLG.cpp : implementation file
|
|
//
|
|
|
|
#include "stdafx.h"
|
|
//#include "pch.h"
|
|
#include "CSelectTankDLG.h"
|
|
#include "afxdialogex.h"
|
|
|
|
// CSelectTankDLG dialog
|
|
|
|
IMPLEMENT_DYNAMIC(CSelectTankDLG, CDialog)
|
|
|
|
std::vector<CSelectTankDLG::CircleTank> CSelectTankDLG::g_CircleTanks;
|
|
std::vector<CSelectTankDLG::RectTank> CSelectTankDLG::g_RectTanks;
|
|
|
|
CSelectTankDLG::CSelectTankDLG(const std::vector<RectTank> &rect, const std::vector<CircleTank>& circle,bool bRect, CWnd* pParent /*=NULL*/)
|
|
: CDialog(IDD_SX_DLG, pParent), m_rectTank(rect), m_circleTank(circle), m_bRect(bRect)
|
|
{
|
|
|
|
}
|
|
|
|
CSelectTankDLG::~CSelectTankDLG()
|
|
{
|
|
}
|
|
|
|
void CSelectTankDLG::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_LIST1, m_listCtrl);
|
|
}
|
|
|
|
BOOL CSelectTankDLG::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
if (m_bRect)
|
|
{
|
|
m_listCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_SINGLEROW);
|
|
m_listCtrl.InsertColumn(0, _T("容积(m^3)"), LVCFMT_CENTER, 80);
|
|
m_listCtrl.InsertColumn(1, _T("长度(mm)"), LVCFMT_CENTER, 80);
|
|
m_listCtrl.InsertColumn(2, _T("宽度(mm)"), LVCFMT_CENTER, 80);
|
|
m_listCtrl.InsertColumn(3, _T("高度(mm)"), LVCFMT_CENTER, 80);
|
|
m_listCtrl.InsertColumn(4, _T("重量(KG)"), LVCFMT_CENTER, 80);
|
|
m_listCtrl.InsertColumn(5, _T("名称"), LVCFMT_CENTER, 160);
|
|
m_listCtrl.InsertColumn(6, _T("页码"), LVCFMT_CENTER, 100);
|
|
}
|
|
else
|
|
{
|
|
m_listCtrl.SetExtendedStyle(LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES | LVS_EX_SINGLEROW);
|
|
m_listCtrl.InsertColumn(0, _T("容积(m^3)"), LVCFMT_CENTER, 80);
|
|
m_listCtrl.InsertColumn(1, _T("直径(mm)"), LVCFMT_CENTER, 80);
|
|
m_listCtrl.InsertColumn(2, _T("高度(mm)"), LVCFMT_CENTER, 80);
|
|
m_listCtrl.InsertColumn(3, _T("支架边距(mm)"), LVCFMT_CENTER, 80);
|
|
m_listCtrl.InsertColumn(4, _T("支架间距(mm)"), LVCFMT_CENTER, 80);
|
|
m_listCtrl.InsertColumn(5, _T("重量(KG)"), LVCFMT_CENTER, 80);
|
|
m_listCtrl.InsertColumn(6, _T("所在页码"), LVCFMT_CENTER, 100);
|
|
}
|
|
|
|
initListCtrls();
|
|
return 0;
|
|
}
|
|
|
|
void CSelectTankDLG::initListCtrls()
|
|
{
|
|
m_listCtrl.DeleteAllItems();
|
|
if (m_bRect)
|
|
{
|
|
for (int i = 0; i < m_rectTank.size(); i++)
|
|
{
|
|
CString strV(_T("")), strL(_T("")), strB(_T("")), strH(_T("")), strW(_T(""));
|
|
strV.Format(_T("%.2f"), m_rectTank.at(i)._v);
|
|
strL.Format(_T("%.0f"), m_rectTank.at(i)._l);
|
|
strB.Format(_T("%.0f"), m_rectTank.at(i)._b);
|
|
strH.Format(_T("%.0f"), m_rectTank.at(i)._h);
|
|
strW.Format(_T("%.0f"), m_rectTank.at(i)._w);
|
|
m_listCtrl.InsertItem(i, strV);
|
|
m_listCtrl.SetItemText(i, 1, strL);
|
|
m_listCtrl.SetItemText(i, 2, strB);
|
|
m_listCtrl.SetItemText(i, 3, strH);
|
|
m_listCtrl.SetItemText(i, 4, strW);
|
|
m_listCtrl.SetItemText(i, 5, m_rectTank.at(i)._name);
|
|
m_listCtrl.SetItemText(i, 6, m_rectTank.at(i)._page);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
for (int i = 0; i < m_circleTank.size(); i++)
|
|
{
|
|
CString strV(_T("")), strL(_T("")), strH(_T("")), strB(_T("")), strS(_T("")), strW(_T(""));
|
|
strV.Format(_T("%.2f"), m_circleTank.at(i)._v);
|
|
strL.Format(_T("%.2f"), m_circleTank.at(i)._l);
|
|
strH.Format(_T("%.2f"), m_circleTank.at(i)._h);
|
|
strB.Format(_T("%.2f"), m_circleTank.at(i)._b);
|
|
strS.Format(_T("%.2f"), m_circleTank.at(i)._s);
|
|
strW.Format(_T("%.2f"), m_circleTank.at(i)._w);
|
|
m_listCtrl.InsertItem(i, strV);
|
|
m_listCtrl.SetItemText(i, 1, strL);
|
|
m_listCtrl.SetItemText(i, 2, strH);
|
|
m_listCtrl.SetItemText(i, 3, strB);
|
|
m_listCtrl.SetItemText(i, 4, strS);
|
|
m_listCtrl.SetItemText(i, 5, strW);
|
|
m_listCtrl.SetItemText(i, 6, m_circleTank.at(i)._page);
|
|
}
|
|
}
|
|
}
|
|
|
|
void CSelectTankDLG::OnBnClickedOk()
|
|
{
|
|
m_nSelectIdx = m_listCtrl.GetSelectionMark();
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CSelectTankDLG, CDialog)
|
|
ON_BN_CLICKED(IDOK, &CSelectTankDLG::OnBnClickedOk)
|
|
END_MESSAGE_MAP()
|
|
|
|
|
|
// CSelectTankDLG message handlers
|