415 lines
8.4 KiB
C++
415 lines
8.4 KiB
C++
#include "stdafx.h"
|
|
#include "EarThwormDef.h"
|
|
#include "KTDimScriptDlg.h"
|
|
|
|
#ifdef _DEBUG
|
|
#define new DEBUG_NEW
|
|
#undef THIS_FILE
|
|
static char THIS_FILE[] = __FILE__;
|
|
#endif
|
|
|
|
KTDimScriptDlg::KTDimScriptDlg(CWnd* pParent /*=NULL*/)
|
|
: CDialog(KTDimScriptDlg::IDD, pParent)
|
|
{
|
|
//{{AFX_DATA_INIT(KTDimScriptDlg)
|
|
//}}AFX_DATA_INIT
|
|
}
|
|
|
|
void KTDimScriptDlg::DoDataExchange(CDataExchange* pDX)
|
|
{
|
|
CDialog::DoDataExchange(pDX);
|
|
//{{AFX_DATA_MAP(KTDimScriptDlg)
|
|
DDX_Control(pDX, IDC_BTNULLSEL, m_wndBtUnAllSel);
|
|
DDX_Control(pDX, IDC_BTONEUNSEL, m_wndBtUnSel);
|
|
DDX_Control(pDX, IDC_BTALLSEL, m_wndBtAllSel);
|
|
DDX_Control(pDX, IDC_BTONESEL, m_wndBtSel);
|
|
DDX_Control(pDX, IDC_LISTRESULT, m_wndResultList);
|
|
DDX_Control(pDX, IDC_LISTSELITEMS, m_wndSelList);
|
|
DDX_Control(pDX, IDC_LISTSRCITEMS, m_wndSrcList);
|
|
//}}AFX_DATA_MAP
|
|
}
|
|
|
|
BEGIN_MESSAGE_MAP(KTDimScriptDlg, CDialog)
|
|
//{{AFX_MSG_MAP(KTDimScriptDlg)
|
|
ON_BN_CLICKED(IDC_BTONESEL, OnBtonesel)
|
|
ON_BN_CLICKED(IDC_BTONEUNSEL, OnBtoneunsel)
|
|
ON_BN_CLICKED(IDC_BTALLSEL, OnBtallsel)
|
|
ON_BN_CLICKED(IDC_BTNULLSEL, OnBtnullsel)
|
|
ON_BN_CLICKED(IDC_BTMOVEUP, OnBtmoveup)
|
|
ON_BN_CLICKED(IDC_BTMOVEDOWN, OnBtmovedown)
|
|
//}}AFX_MSG_MAP
|
|
END_MESSAGE_MAP()
|
|
|
|
void KTDimScriptDlg::SetPipeDimScript(CString& sScript)
|
|
{
|
|
m_sDimScript = sScript;
|
|
}
|
|
|
|
void KTDimScriptDlg::GetPipeDimScript(CString& sScript)
|
|
{
|
|
sScript = m_sDimScript;
|
|
}
|
|
|
|
BOOL KTDimScriptDlg::OnInitDialog()
|
|
{
|
|
CDialog::OnInitDialog();
|
|
|
|
m_ImageList.Create(IDB_BITMAPH,1,1,ILC_COLOR16);
|
|
m_wndResultList.SetImageList(&m_ImageList,LVSIL_SMALL);
|
|
m_wndResultList.SetExtendedStyle(LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT);
|
|
|
|
InitSpecSet();
|
|
|
|
return TRUE;
|
|
}
|
|
|
|
void KTDimScriptDlg::OnBtonesel()
|
|
{
|
|
int nCount = m_wndSrcList.GetSelCount();
|
|
CArray<int,int> arIntsSel;
|
|
arIntsSel.SetSize(nCount);
|
|
m_wndSrcList.GetSelItems(nCount, arIntsSel.GetData());
|
|
|
|
int nIndex = 0;
|
|
CString sText;
|
|
CStringArray arTexts;
|
|
|
|
for(int i = 0;i < nCount;i++)
|
|
{
|
|
nIndex = arIntsSel.GetAt(i);
|
|
m_wndSrcList.GetText(nIndex,sText);
|
|
m_wndSelList.AddString(sText);
|
|
arTexts.Add(sText);
|
|
}
|
|
|
|
for(i = 0;i<nCount;i++)
|
|
{
|
|
sText = arTexts.GetAt(i);
|
|
nIndex = m_wndSrcList.FindString(0,sText);
|
|
if(nIndex != LB_ERR )
|
|
{
|
|
m_wndSrcList.DeleteString(nIndex);
|
|
}
|
|
}
|
|
|
|
nCount = m_wndSrcList.GetCount();
|
|
if(nCount == 0)
|
|
{
|
|
m_wndBtSel.EnableWindow(FALSE);
|
|
m_wndBtAllSel.EnableWindow(FALSE);
|
|
}
|
|
else
|
|
{
|
|
m_wndSrcList.SetSel(nCount - 1,TRUE);
|
|
}
|
|
m_wndBtUnSel.EnableWindow(TRUE);
|
|
m_wndBtUnAllSel.EnableWindow(TRUE);
|
|
|
|
UpdateResultList();
|
|
}
|
|
|
|
void KTDimScriptDlg::OnBtoneunsel()
|
|
{
|
|
int nCount = m_wndSelList.GetSelCount();
|
|
CArray<int,int> arIntsSel;
|
|
arIntsSel.SetSize(nCount);
|
|
m_wndSelList.GetSelItems(nCount, arIntsSel.GetData());
|
|
|
|
int nIndex = 0;
|
|
CString sText;
|
|
CStringArray arTexts;
|
|
|
|
for(int i = 0;i < nCount;i++)
|
|
{
|
|
nIndex = arIntsSel.GetAt(i);
|
|
m_wndSelList.GetText(nIndex,sText);
|
|
m_wndSrcList.AddString(sText);
|
|
arTexts.Add(sText);
|
|
}
|
|
|
|
for(i = 0;i<nCount;i++)
|
|
{
|
|
sText = arTexts.GetAt(i);
|
|
nIndex = m_wndSelList.FindString(0,sText);
|
|
if(nIndex != LB_ERR )
|
|
{
|
|
m_wndSelList.DeleteString(nIndex);
|
|
}
|
|
}
|
|
|
|
nCount = m_wndSelList.GetCount();
|
|
if(nCount == 0)
|
|
{
|
|
m_wndBtUnSel.EnableWindow(FALSE);
|
|
m_wndBtUnAllSel.EnableWindow(FALSE);
|
|
}
|
|
else
|
|
{
|
|
m_wndSrcList.SetSel(nCount - 1,TRUE);
|
|
}
|
|
m_wndBtSel.EnableWindow(TRUE);
|
|
m_wndBtAllSel.EnableWindow(TRUE);
|
|
|
|
UpdateResultList();
|
|
}
|
|
|
|
void KTDimScriptDlg::OnBtallsel()
|
|
{
|
|
int nCount = m_wndSrcList.GetCount();
|
|
|
|
CString sText;
|
|
for(int i = 0;i < nCount;i++)
|
|
{
|
|
m_wndSrcList.GetText(i,sText);
|
|
m_wndSelList.AddString(sText);
|
|
}
|
|
m_wndSrcList.ResetContent();
|
|
|
|
m_wndBtSel.EnableWindow(FALSE);
|
|
m_wndBtAllSel.EnableWindow(FALSE);
|
|
m_wndBtUnSel.EnableWindow(TRUE);
|
|
m_wndBtUnAllSel.EnableWindow(TRUE);
|
|
|
|
UpdateResultList();
|
|
}
|
|
|
|
void KTDimScriptDlg::OnBtnullsel()
|
|
{
|
|
int nCount = m_wndSelList.GetCount();
|
|
|
|
CString sText;
|
|
for(int i = 0;i < nCount;i++)
|
|
{
|
|
m_wndSelList.GetText(i,sText);
|
|
m_wndSrcList.AddString(sText);
|
|
}
|
|
m_wndSelList.ResetContent();
|
|
|
|
m_wndBtSel.EnableWindow(TRUE);
|
|
m_wndBtAllSel.EnableWindow(TRUE);
|
|
m_wndBtUnSel.EnableWindow(FALSE);
|
|
m_wndBtUnAllSel.EnableWindow(FALSE);
|
|
|
|
UpdateResultList();
|
|
}
|
|
|
|
void KTDimScriptDlg::OnBtmoveup()
|
|
{
|
|
CStringArray arText;
|
|
int i = 0;
|
|
CString sTemp;
|
|
int nCount = m_wndSelList.GetCount();
|
|
for(i = 0;i<nCount;i++)
|
|
{
|
|
m_wndSelList.GetText(i,sTemp);
|
|
arText.Add(sTemp);
|
|
}
|
|
|
|
int nCursel = m_wndSelList.GetCurSel();
|
|
if(nCursel > 0)
|
|
{
|
|
CString sCurText,sUpText;
|
|
m_wndSelList.GetText(nCursel,sCurText);
|
|
m_wndSelList.GetText(nCursel - 1,sUpText);
|
|
|
|
arText.SetAt(nCursel,sUpText);
|
|
arText.SetAt(nCursel - 1,sCurText);
|
|
m_wndSelList.ResetContent();
|
|
|
|
for(i = 0;i<nCount;i++)
|
|
{
|
|
sTemp = arText.GetAt(i);
|
|
m_wndSelList.AddString(sTemp);
|
|
}
|
|
int nPos = m_wndSelList.FindString(0,sCurText);
|
|
if(nPos != LB_ERR);
|
|
m_wndSelList.SetSel(nPos,TRUE);
|
|
}
|
|
UpdateResultList();
|
|
}
|
|
|
|
void KTDimScriptDlg::OnBtmovedown()
|
|
{
|
|
CStringArray arText;
|
|
int i = 0;
|
|
CString sTemp;
|
|
int nCount = m_wndSelList.GetCount();
|
|
for(i = 0;i<nCount;i++)
|
|
{
|
|
m_wndSelList.GetText(i,sTemp);
|
|
arText.Add(sTemp);
|
|
}
|
|
|
|
int nCursel = m_wndSelList.GetCurSel();
|
|
if(nCursel < nCount - 1)
|
|
{
|
|
CString sCurText,sDownText;
|
|
m_wndSelList.GetText(nCursel,sCurText);
|
|
m_wndSelList.GetText(nCursel + 1,sDownText);
|
|
|
|
arText.SetAt(nCursel,sDownText);
|
|
arText.SetAt(nCursel + 1,sCurText);
|
|
|
|
m_wndSelList.ResetContent();
|
|
|
|
for(i = 0;i<nCount;i++)
|
|
{
|
|
sTemp = arText.GetAt(i);
|
|
m_wndSelList.AddString(sTemp);
|
|
}
|
|
int nPos = m_wndSelList.FindString(0,sCurText);
|
|
if(nPos != LB_ERR)
|
|
m_wndSelList.SetSel(nPos,TRUE);
|
|
}
|
|
UpdateResultList();
|
|
}
|
|
|
|
void KTDimScriptDlg::OnOK()
|
|
{
|
|
if (!FormatDimScript())
|
|
{
|
|
AfxMessageBox(IDS_NODIMITEMSEL);
|
|
return;
|
|
}
|
|
CDialog::OnOK();
|
|
}
|
|
|
|
void KTDimScriptDlg::InitSpecSet()
|
|
{
|
|
int nIndex = 0;
|
|
for(int i = 0;i < 200;i++)
|
|
{
|
|
if (g_pszPipeDim[i] != NULL)
|
|
{
|
|
m_wndSrcList.AddString(g_pszPipeDim[i]);
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
//{公称直径}{-}{介质}{-}{管号}{-}{管道等级}
|
|
CString sItem = m_sDimScript,sText;
|
|
int nIndex1 = 0,nIndex2 = 0,nFind = 0;
|
|
|
|
CStringArray arItems,arSpaces;
|
|
|
|
while(TRUE)
|
|
{
|
|
nIndex1 = sItem.Find('{',0);
|
|
nIndex2 = sItem.Find('}',0);
|
|
|
|
if (nIndex1 != -1 && nIndex2 != -1)
|
|
{
|
|
sText = sItem.Mid(nIndex1 + 1,nIndex2 - nIndex1 - 1);
|
|
if ( (nFind = m_wndSrcList.FindString(0,sText)) != LB_ERR)
|
|
{
|
|
arItems.Add(sText);
|
|
m_wndSrcList.DeleteString(nFind);
|
|
}
|
|
else
|
|
{
|
|
if (nIndex2 - nIndex1 == 1)
|
|
sText = "";
|
|
arSpaces.Add(sText);
|
|
}
|
|
if (nIndex2 + 1 < sItem.GetLength())
|
|
{
|
|
sText = sItem.Mid(nIndex2 + 1);
|
|
sItem = sText;
|
|
}
|
|
else
|
|
break;
|
|
}
|
|
else
|
|
{
|
|
break;
|
|
}
|
|
}
|
|
|
|
int nSize = arItems.GetSize();
|
|
for(i = 0;i < nSize;i++)
|
|
{
|
|
sItem = arItems.GetAt(i);
|
|
m_wndSelList.AddString(sItem);
|
|
}
|
|
|
|
int nCount = 0;
|
|
for(int j = 0;j < arItems.GetSize();j++)
|
|
{
|
|
nCount = m_wndResultList.GetHeaderCtrl()->GetItemCount();
|
|
m_wndResultList.InsertColumn(nCount,_T("条目"),LVCFMT_LEFT,60);
|
|
if (j < arItems.GetSize() - 1)
|
|
{
|
|
m_wndResultList.InsertColumn(nCount + 1,_T("间隔"),LVCFMT_CENTER,40);
|
|
m_wndResultList.SetColumnItemData(nCount + 1,NULL,ET_Edit);
|
|
}
|
|
}
|
|
|
|
if (nSize > 0)
|
|
{
|
|
m_wndResultList.InsertItem(0,arItems.GetAt(0),0);
|
|
for(i = 1;i < nSize;i++)
|
|
{
|
|
m_wndResultList.SetItemText(0, 2 * i,arItems.GetAt(i));
|
|
}
|
|
|
|
nSize = arSpaces.GetSize();
|
|
for(j = 0;j < nSize;j++)
|
|
{
|
|
m_wndResultList.SetItemText(0,2 * j + 1,arSpaces.GetAt(j));
|
|
}
|
|
}
|
|
}
|
|
|
|
void KTDimScriptDlg::UpdateResultList()
|
|
{
|
|
m_wndResultList.DeleteAllItems();
|
|
while(m_wndResultList.DeleteColumn(0));
|
|
|
|
int nCount = m_wndSelList.GetCount();
|
|
if (nCount == 0) return;
|
|
|
|
int nItems = 0;
|
|
for(int i = 0;i < nCount;i++)
|
|
{
|
|
nItems = m_wndResultList.GetHeaderCtrl()->GetItemCount();
|
|
m_wndResultList.InsertColumn(nItems,_T("条目"),LVCFMT_LEFT,60);
|
|
if (i < nCount - 1)
|
|
{
|
|
m_wndResultList.InsertColumn(nItems + 1,_T("间隔"),LVCFMT_CENTER,40);
|
|
m_wndResultList.SetColumnItemData(nItems + 1,NULL,ET_Edit);
|
|
}
|
|
}
|
|
|
|
CString sText;
|
|
m_wndSelList.GetText(0,sText);
|
|
m_wndResultList.InsertItem(0,sText,0);
|
|
|
|
for(i = 1;i < nCount;i++)
|
|
{
|
|
m_wndSelList.GetText(i,sText);
|
|
m_wndResultList.SetItemText(0,2*i,sText);
|
|
m_wndResultList.SetItemText(0,2*i - 1,_T("-"));
|
|
}
|
|
}
|
|
|
|
BOOL KTDimScriptDlg::FormatDimScript()
|
|
{
|
|
//{公称直径}{-}{介质}{-}{管号}{-}{管道等级}
|
|
CString sText,sItem = "";
|
|
int nCount = m_wndResultList.GetHeaderCtrl()->GetItemCount();
|
|
for(int i = 0;i < nCount;i++)
|
|
{
|
|
sText = m_wndResultList.GetItemText(0,i);
|
|
if (sText.IsEmpty())
|
|
sText = _T("-");
|
|
|
|
sItem += "{";
|
|
sItem += sText;
|
|
sItem += "}";
|
|
}
|
|
m_sDimScript = sItem;
|
|
return nCount > 0;
|
|
} |