157 lines
3.3 KiB
C++
157 lines
3.3 KiB
C++
#include "stdafx.h"
|
|
#include "CFFTMDlg.h"
|
|
|
|
static const Adesk::UInt16 kColorByLayer = 256;
|
|
|
|
IMPLEMENT_DYNAMIC(CFFTMDlg, CDialog)
|
|
|
|
CFFTMDlg::CFFTMDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(IDD_FFTM_DLG, pParent)
|
|
{
|
|
m_sSelCoating = _T("");
|
|
m_nColorIndex = 6;
|
|
m_dPer = 100;
|
|
m_dArea = 0.0;
|
|
}
|
|
|
|
CFFTMDlg::~CFFTMDlg()
|
|
{
|
|
}
|
|
|
|
void CFFTMDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
DDX_Control(pDX, IDC_LIST1, m_wndLstCtrl);
|
|
DDX_Text(pDX, IDC_EDIT1, m_dArea);
|
|
DDX_Text(pDX, IDC_EDIT2, m_dPer);
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(CFFTMDlg, CDialog)
|
|
ON_BN_CLICKED(IDOK, &CFFTMDlg::OnBnClickedOk)
|
|
ON_BN_CLICKED(IDC_BUTTON3, &CFFTMDlg::OnBnClickedButton3)
|
|
ON_STN_CLICKED(IDC_STATIC_CR, &CFFTMDlg::OnStnClickedStaticColor)
|
|
ON_WM_CTLCOLOR()
|
|
END_MESSAGE_MAP()
|
|
|
|
BOOL CFFTMDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
m_wndLstCtrl.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_SINGLEROW);
|
|
m_wndLstCtrl.InsertColumn(0, _T("防腐方案"), LVCFMT_LEFT, 400, 0);
|
|
|
|
ShowCoatings();
|
|
|
|
UpdateData(FALSE);
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void CFFTMDlg::SetAreaShow(double dArea,double dPer)
|
|
{
|
|
m_dArea = dArea;
|
|
m_dArea /= 1.e6;
|
|
|
|
m_dPer = dPer;
|
|
}
|
|
|
|
void CFFTMDlg::ShowCoatings()
|
|
{
|
|
CString sLstFile = FilePath::GetSysDir() + _T("\\Coatings.lst");
|
|
CString sLine;
|
|
int nSel = -1;
|
|
CStdioFile file;
|
|
if (file.Open(sLstFile, CFile::modeRead | CFile::typeText))
|
|
{
|
|
while (file.ReadString(sLine))
|
|
{
|
|
m_wndLstCtrl.InsertItem(m_wndLstCtrl.GetItemCount(), sLine);
|
|
if (m_sSelCoating.CompareNoCase(sLine) == 0)
|
|
{
|
|
nSel = m_wndLstCtrl.GetItemCount();
|
|
}
|
|
}
|
|
file.Close();
|
|
}
|
|
if (nSel != -1) m_wndLstCtrl.SetItemState(nSel, LVIS_SELECTED, LVIS_SELECTED);
|
|
}
|
|
|
|
void CFFTMDlg::SetSelCoating(CString &sSelCoating, Adesk::UInt16 nColorIndex)
|
|
{
|
|
m_sSelCoating = sSelCoating;
|
|
m_nColorIndex = nColorIndex;
|
|
}
|
|
|
|
double CFFTMDlg::GetSelCoating(CString &sSelCoating, Adesk::UInt16 &nColorIndex) const
|
|
{
|
|
sSelCoating = m_sSelCoating;
|
|
nColorIndex = m_nColorIndex;
|
|
return m_dPer;
|
|
}
|
|
|
|
void CFFTMDlg::OnBnClickedOk()
|
|
{
|
|
int nItem = -1;
|
|
POSITION ps = m_wndLstCtrl.GetFirstSelectedItemPosition();
|
|
if (ps != NULL)
|
|
{
|
|
nItem = m_wndLstCtrl.GetNextSelectedItem(ps);
|
|
}
|
|
|
|
if (nItem == -1)
|
|
{
|
|
AfxMessageBox(_T("请选择防腐涂料条目!"));
|
|
return;
|
|
}
|
|
|
|
if (m_dPer < 1.e-3 || m_dPer > 100.00001)
|
|
{
|
|
AfxMessageBox(_T("请确认喷涂比率是否合适!要求在(1-100)之间!"));
|
|
return;
|
|
}
|
|
|
|
m_sSelCoating = m_wndLstCtrl.GetItemText(nItem, 0);
|
|
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
void CFFTMDlg::OnBnClickedButton3()
|
|
{
|
|
CString sLstFile = FilePath::GetSysDir() + _T("\\Coatings.lst");
|
|
ShellExecute(acedGetAcadFrame()->m_hWnd, _T("open"), sLstFile, NULL, FilePath::GetSysDir(), SW_SHOWNORMAL);
|
|
}
|
|
|
|
HBRUSH CFFTMDlg::OnCtlColor(CDC *pDC, CWnd *pWnd, UINT nCtlColor)
|
|
{
|
|
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
|
|
if (nCtlColor == CTLCOLOR_STATIC)
|
|
{
|
|
if (pWnd != NULL && pWnd->GetDlgCtrlID() == IDC_STATIC_CR)
|
|
{
|
|
COLORREF crColor = RGB(255, 255, 255);
|
|
if (m_nColorIndex == kColorByLayer)
|
|
{
|
|
crColor = RGB(255, 255, 255);
|
|
}
|
|
else
|
|
{
|
|
crColor = acedGetRGB(m_nColorIndex);
|
|
}
|
|
|
|
CRect rc;
|
|
pWnd->GetClientRect(rc);
|
|
pDC->FillSolidRect(rc, crColor);
|
|
}
|
|
}
|
|
return hbr;
|
|
}
|
|
|
|
void CFFTMDlg::OnStnClickedStaticColor()
|
|
{
|
|
int nColor = m_nColorIndex;
|
|
acedSetColorDialog(nColor, Adesk::kFalse, nColor);
|
|
m_nColorIndex = (Adesk::UInt16)nColor;
|
|
|
|
Invalidate();
|
|
}
|