You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

309 lines
12 KiB
C++

#include "stdafx.h"
#include "LaiPuLaser.h"
#include "afxdialogex.h"
#include "DlgRecipeCompare.h"
#include "GlobalFunction.h"
IMPLEMENT_DYNAMIC(CDlgRecipeCompare, CDialogEx)
BEGIN_MESSAGE_MAP(CDlgRecipeCompare, CDialogEx)
ON_CBN_SELCHANGE(NEW_RECIPE_GROUP_COMBO, &CDlgRecipeCompare::OnCbnSelchangeSelGroupCombo)
ON_CBN_SELCHANGE(NEW_RECIPE_NAME_COMBO, &CDlgRecipeCompare::OnCbnSelchangeSelRecipeCombo)
ON_NOTIFY(NM_CLICK, NEW_SUB_RECIPE_LIST, &CDlgRecipeCompare::OnNMClickEditSubRecipeList)
ON_CBN_SELCHANGE(NEW_RECIPE_GROUP_COMBO2, &CDlgRecipeCompare::OnCbnSelchangeSelGroupCombo2)
ON_CBN_SELCHANGE(NEW_RECIPE_NAME_COMBO2, &CDlgRecipeCompare::OnCbnSelchangeSelRecipeCombo2)
ON_NOTIFY(NM_CLICK, NEW_SUB_RECIPE_LIST2, &CDlgRecipeCompare::OnNMClickEditSubRecipeList2)
ON_NOTIFY(NM_CUSTOMDRAW, NEW_EDIT_RECIPE_LIST, &CDlgRecipeCompare::OnDrawRecipeList)
ON_NOTIFY(NM_CUSTOMDRAW, NEW_EDIT_RECIPE_INFO_LIST, &CDlgRecipeCompare::OnDrawRecipeInfoList)
ON_NOTIFY(NM_CUSTOMDRAW, NEW_EDIT_RECIPE_LIST2, &CDlgRecipeCompare::OnDrawRecipeList2)
ON_NOTIFY(NM_CUSTOMDRAW, NEW_EDIT_RECIPE_INFO_LIST2, &CDlgRecipeCompare::OnDrawRecipeInfoList2)
END_MESSAGE_MAP()
CDlgRecipeCompare::CDlgRecipeCompare(CWnd* pParent /*=NULL*/)
: CDialogEx(CDlgRecipeCompare::IDD, pParent)
{
}
CDlgRecipeCompare::~CDlgRecipeCompare()
{
}
void CDlgRecipeCompare::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, NEW_RECIPE_GROUP_COMBO, m_SelRecipeGroupComb);
DDX_Control(pDX, NEW_RECIPE_NAME_COMBO, m_SelRecipeComb);
DDX_Control(pDX, NEW_EDIT_RECIPE_LIST, m_EditRecipeList);
DDX_Control(pDX, NEW_SUB_RECIPE_LIST, m_EditSubRecipeList);
DDX_Control(pDX, NEW_EDIT_RECIPE_INFO_LIST, m_EditRecipeInfoList);
DDX_Control(pDX, NEW_RECIPE_GROUP_COMBO2, m_SelRecipeGroupComb2);
DDX_Control(pDX, NEW_RECIPE_NAME_COMBO2, m_SelRecipeComb2);
DDX_Control(pDX, NEW_EDIT_RECIPE_LIST2, m_EditRecipeList2);
DDX_Control(pDX, NEW_SUB_RECIPE_LIST2, m_EditSubRecipeList2);
DDX_Control(pDX, NEW_EDIT_RECIPE_INFO_LIST2, m_EditRecipeInfoList2);
}
BOOL CDlgRecipeCompare::OnInitDialog()
{
CDialogEx::OnInitDialog();
//<2F><><EFBFBD><EFBFBD>recipe <20><><EFBFBD><EFBFBD>Ϣ
gRecipeMgr->UpdateRecipeGroupVec();
//Recipe1
gRecipeMgr->UpdateRecipeGroupComb(&m_SelRecipeGroupComb);
m_SelRecipeGroupComb.SetCurSel(-1);
gRecipeMgr->InitEditRecipeList(m_EditRecipeList,false);
gRecipeMgr->InitEditRecipeList(m_EditRecipeInfoList,false);
gRecipeMgr->InitEditSubRecipeList(m_EditSubRecipeList);
//Recipe2
gRecipeMgr->UpdateRecipeGroupComb(&m_SelRecipeGroupComb2);
m_SelRecipeGroupComb2.SetCurSel(-1);
gRecipeMgr->InitEditRecipeList(m_EditRecipeList2,false);
gRecipeMgr->InitEditRecipeList(m_EditRecipeInfoList2,false);
gRecipeMgr->InitEditSubRecipeList(m_EditSubRecipeList2);
UpdateData(FALSE);
return TRUE;
}
#if 1
void CDlgRecipeCompare::OnDrawRecipeList( NMHDR* pNMHDR, LRESULT* pResult )
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = CDRF_DODEFAULT;
if( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if((CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
COLORREF crText, crBkgnd;
crText = RGB_BLACK;
crBkgnd = RGB_WHITE;
int iRow = pLVCD->nmcd.dwItemSpec;//<2F>к<EFBFBD>
int iCol = 4;
if(iCol == pLVCD->iSubItem)//<2F>к<EFBFBD>
{
CString Text1 = m_EditRecipeList.GetItemText(iRow,iCol);
CString Text2 = m_EditRecipeList2.GetItemText(iRow,iCol);
if(m_CurRecipe.IsValid()&&m_CurRecipe2.IsValid()&&Text1!=Text2)
crBkgnd = RGB_BLUE2;
}
pLVCD->clrText = crText;
pLVCD->clrTextBk = crBkgnd;
*pResult = CDRF_DODEFAULT;
}
}
void CDlgRecipeCompare::OnDrawRecipeInfoList( NMHDR* pNMHDR, LRESULT* pResult)
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = CDRF_DODEFAULT;
if( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if((CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
COLORREF crText, crBkgnd;
crText = RGB_BLACK;
crBkgnd = RGB_WHITE;
int iRow = pLVCD->nmcd.dwItemSpec;//<2F>к<EFBFBD>
int iCol = 4;
if(iCol == pLVCD->iSubItem)//<2F>к<EFBFBD>
{
CString Text1 = m_EditRecipeInfoList.GetItemText(iRow,iCol);
CString Text2 = m_EditRecipeInfoList2.GetItemText(iRow,iCol);
if(m_CurRecipe.IsValid()&&m_CurRecipe2.IsValid()&&Text1!=Text2)
crBkgnd = RGB_BLUE2;
}
pLVCD->clrText = crText;
pLVCD->clrTextBk = crBkgnd;
*pResult = CDRF_DODEFAULT;
}
}
void CDlgRecipeCompare::OnDrawRecipeList2( NMHDR* pNMHDR, LRESULT* pResult )
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = CDRF_DODEFAULT;
if( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if((CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
COLORREF crText, crBkgnd;
crText = RGB_BLACK;
crBkgnd = RGB_WHITE;
int iRow = pLVCD->nmcd.dwItemSpec;//<2F>к<EFBFBD>
int iCol = 4;
if(iCol == pLVCD->iSubItem)//<2F>к<EFBFBD>
{
CString Text1 = m_EditRecipeList.GetItemText(iRow,iCol);
CString Text2 = m_EditRecipeList2.GetItemText(iRow,iCol);
if(m_CurRecipe.IsValid()&&m_CurRecipe2.IsValid()&&Text1!=Text2)
crBkgnd = RGB_YELLOW;
}
pLVCD->clrText = crText;
pLVCD->clrTextBk = crBkgnd;
*pResult = CDRF_DODEFAULT;
}
}
void CDlgRecipeCompare::OnDrawRecipeInfoList2( NMHDR* pNMHDR, LRESULT* pResult)
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = CDRF_DODEFAULT;
if( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if((CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
{
COLORREF crText, crBkgnd;
crText = RGB_BLACK;
crBkgnd = RGB_WHITE;
int iRow = pLVCD->nmcd.dwItemSpec;//<2F>к<EFBFBD>
int iCol = 4;
if(iCol == pLVCD->iSubItem)//<2F>к<EFBFBD>
{
CString Text1 = m_EditRecipeInfoList.GetItemText(iRow,iCol);
CString Text2 = m_EditRecipeInfoList2.GetItemText(iRow,iCol);
if(m_CurRecipe.IsValid()&&m_CurRecipe2.IsValid()&&Text1!=Text2)
crBkgnd = RGB_YELLOW;
}
pLVCD->clrText = crText;
pLVCD->clrTextBk = crBkgnd;
*pResult = CDRF_DODEFAULT;
}
}
#endif
#if 1
void CDlgRecipeCompare::OnCbnSelchangeSelGroupCombo()
{
int SelGroupIdx = m_SelRecipeGroupComb.GetCurSel();
gRecipeMgr->SetCurSelGourpIdx(SelGroupIdx);
gRecipeMgr->UpdateSelRecipeComb(m_SelRecipeComb,m_SelGroupRecipeNameVec);
m_CurSelRecipeName = "";
}
void CDlgRecipeCompare::OnCbnSelchangeSelRecipeCombo()
{
int SelGroupIdx = m_SelRecipeGroupComb.GetCurSel();
CString GroupName;
GetDlgItem(NEW_RECIPE_GROUP_COMBO)->GetWindowText(GroupName);
int SelRecipeIdx = m_SelRecipeComb.GetCurSel();
int size = m_SelGroupRecipeNameVec.size();
if(SelRecipeIdx>=0 && SelRecipeIdx<size)
{
m_CurSelRecipeName = m_SelGroupRecipeNameVec[SelRecipeIdx];
CRecipe Recipe;
if(gRecipeMgr->ReadEditRecipeFromFile(Recipe,SelGroupIdx,m_CurSelRecipeName))
{
Recipe.SetCurSubRecipeIdx(0);//Ĭ<>ϵ<EFBFBD>һ<EFBFBD><D2BB>sub recipe
m_CurRecipe = Recipe;
gRecipeMgr->UpdateEditSubRecipeListExt(Recipe,m_EditSubRecipeList);
gRecipeMgr->UpdateEditRecipeListExt(Recipe,m_EditRecipeList,m_EditRecipeInfoList);
//ˢ<><CBA2>һ<EFBFBD><D2BB>
gRecipeMgr->UpdateEditRecipeListExt(m_CurRecipe2,m_EditRecipeList2,m_EditRecipeInfoList2);
}
}
//Ĭ<><C4AC>ѡ<EFBFBD><D1A1><EFBFBD>Լ<EFBFBD>
{
int SelGroupIdx = m_SelRecipeGroupComb2.GetCurSel();
if(SelGroupIdx<0)
{
SelGroupIdx = m_SelRecipeGroupComb.GetCurSel();
m_SelRecipeGroupComb2.SetCurSel(SelGroupIdx);
OnCbnSelchangeSelGroupCombo2();
int SelRecipeIdx = m_SelRecipeComb.GetCurSel();
m_SelRecipeComb2.SetCurSel(SelRecipeIdx);
OnCbnSelchangeSelRecipeCombo2();
}
}
}
void CDlgRecipeCompare::OnNMClickEditSubRecipeList(NMHDR *pNMHDR, LRESULT *pResult)
{
*pResult = 0;
int Idx = GetCurListIdx(m_EditSubRecipeList);
if(Idx>=0 && m_CurRecipe.IsValid())
{
m_CurRecipe.SetCurSubRecipeIdx(Idx);
gRecipeMgr->UpdateEditRecipeListExt(m_CurRecipe,m_EditRecipeList,m_EditRecipeInfoList);
//ˢ<><CBA2>һ<EFBFBD><D2BB>
gRecipeMgr->UpdateEditRecipeListExt(m_CurRecipe2,m_EditRecipeList2,m_EditRecipeInfoList2);
}
}
#endif
#if 1
void CDlgRecipeCompare::OnCbnSelchangeSelGroupCombo2()
{
int SelGroupIdx = m_SelRecipeGroupComb2.GetCurSel();
gRecipeMgr->SetCurSelGourpIdx(SelGroupIdx);
gRecipeMgr->UpdateSelRecipeComb(m_SelRecipeComb2,m_SelGroupRecipeNameVec2);
m_CurSelRecipeName2 = "";
}
void CDlgRecipeCompare::OnCbnSelchangeSelRecipeCombo2()
{
int SelGroupIdx = m_SelRecipeGroupComb2.GetCurSel();
CString GroupName;
GetDlgItem(NEW_RECIPE_GROUP_COMBO2)->GetWindowText(GroupName);
int SelRecipeIdx = m_SelRecipeComb2.GetCurSel();
int size = m_SelGroupRecipeNameVec2.size();
if(SelRecipeIdx>=0 && SelRecipeIdx<size)
{
m_CurSelRecipeName2 = m_SelGroupRecipeNameVec2[SelRecipeIdx];
CRecipe Recipe;
if(gRecipeMgr->ReadEditRecipeFromFile(Recipe,SelGroupIdx,m_CurSelRecipeName2))
{
Recipe.SetCurSubRecipeIdx(0);//Ĭ<>ϵ<EFBFBD>һ<EFBFBD><D2BB>sub recipe
m_CurRecipe2 = Recipe;
gRecipeMgr->UpdateEditSubRecipeListExt(Recipe,m_EditSubRecipeList2);
gRecipeMgr->UpdateEditRecipeListExt(Recipe,m_EditRecipeList2,m_EditRecipeInfoList2);
gRecipeMgr->UpdateEditRecipeListExt(m_CurRecipe,m_EditRecipeList,m_EditRecipeInfoList);
}
}
}
void CDlgRecipeCompare::OnNMClickEditSubRecipeList2(NMHDR *pNMHDR, LRESULT *pResult)
{
*pResult = 0;
int Idx = GetCurListIdx(m_EditSubRecipeList2);
if(Idx>=0 && m_CurRecipe2.IsValid())
{
m_CurRecipe2.SetCurSubRecipeIdx(Idx);
gRecipeMgr->UpdateEditRecipeListExt(m_CurRecipe2,m_EditRecipeList2,m_EditRecipeInfoList2);
gRecipeMgr->UpdateEditRecipeListExt(m_CurRecipe,m_EditRecipeList,m_EditRecipeInfoList);
}
}
#endif