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.

161 lines
6.3 KiB
C++

#include "stdafx.h"
#include "LaiPuLaser.h"
#include "afxdialogex.h"
#include "DlgRecipeCtrl.h"
#include "RecipeMgr.h"
#include "MsgBox.h"
IMPLEMENT_DYNAMIC(CDlgRecipeCtrl, CDialogEx)
BEGIN_MESSAGE_MAP(CDlgRecipeCtrl, CDialogEx)
ON_BN_CLICKED(IDOK,OnBnClickedOk)
END_MESSAGE_MAP()
CDlgRecipeCtrl::CDlgRecipeCtrl(CWnd* pParent /*=NULL*/)
: CDialogEx(CDlgRecipeCtrl::IDD, pParent)
{
}
CDlgRecipeCtrl::~CDlgRecipeCtrl()
{
}
void CDlgRecipeCtrl::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Text(pDX, IDC_NAME_EDIT1, m_EditName1);
DDX_Text(pDX, IDC_NAME_EDIT2, m_EditName2);
DDX_Text(pDX, IDC_STATIC_EDIT1, m_StaticName1);
DDX_Text(pDX, IDC_STATIC_EDIT2, m_StaticName2);
DDX_Control(pDX, IDC_SEL_GROUP_COMBO, m_RecipeCtrlGroupComb);
}
BOOL CDlgRecipeCtrl::OnInitDialog()
{
CDialogEx::OnInitDialog();
CRecipeCtrlItem CtrlItem;
CtrlItem.m_EditName1 = &m_EditName1;
CtrlItem.m_EditName2 = &m_EditName2;
CtrlItem.m_RecipeCtrlGroupComb = &m_RecipeCtrlGroupComb;
gRecipeMgr->RecipeCtrlInit(CtrlItem);
//ÉèÖöԻ°¿òµÄ±êÌâ
this->SetWindowText(CtrlItem.m_DlgTitle);
ERecipeCtrlType RecipeCtrlType = gRecipeMgr->GetCurRecipeCtrlType();
switch(RecipeCtrlType)
{
case _RecipeCtrl_AddGroup:
GetDlgItem(IDC_NAME_EDIT1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_NAME_EDIT1)->EnableWindow(true);
GetDlgItem(IDC_NAME_EDIT2)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT2)->EnableWindow(true);
m_StaticName2 = "Add Group Name";
break;
case _RecipeCtrl_DelGroup:
GetDlgItem(IDC_NAME_EDIT1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_NAME_EDIT1)->EnableWindow(false);
GetDlgItem(IDC_NAME_EDIT2)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT2)->EnableWindow(false);
m_StaticName2 = "Delete Group Name";
break;
case _RecipeCtrl_GroupName:
GetDlgItem(IDC_NAME_EDIT1)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT2)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT2)->EnableWindow(true);
m_StaticName1 = "Old Group Name";
m_StaticName2 = "New Group Name";
break;
case _RecipeCtrl_AddRecipe:
GetDlgItem(IDC_NAME_EDIT1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_SEL_GROUP_COMBO)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_SEL_GROUP_COMBO)->EnableWindow(true);
GetDlgItem(IDC_NAME_EDIT2)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT2)->EnableWindow(true);
m_StaticName1 = "Add to Group";
m_StaticName2 = "Recipe Name";
break;
case _RecipeCtrl_DelRecipe:
GetDlgItem(IDC_NAME_EDIT1)->ShowWindow((SW_SHOW));
GetDlgItem(IDC_NAME_EDIT1)->EnableWindow(false);
GetDlgItem(IDC_SEL_GROUP_COMBO)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_NAME_EDIT2)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT2)->EnableWindow(false);
m_StaticName1 = "Group Name";
m_StaticName2 = "Delete Recipe Name";
break;
case _RecipeCtrl_CopyRecipe:
GetDlgItem(IDC_NAME_EDIT1)->ShowWindow((SW_SHOW));
GetDlgItem(IDC_NAME_EDIT1)->EnableWindow(false);
GetDlgItem(IDC_SEL_GROUP_COMBO)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_NAME_EDIT2)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT2)->EnableWindow(true);
m_StaticName1 = "Copy Recipe Name";
m_StaticName2 = "New Recipe Name";
break;
case _RecipeCtrl_MoveRecipe:
GetDlgItem(IDC_NAME_EDIT1)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_SEL_GROUP_COMBO)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_SEL_GROUP_COMBO)->EnableWindow(true);
GetDlgItem(IDC_NAME_EDIT2)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT2)->EnableWindow(false);
m_StaticName1 = "Move to Group";
m_StaticName2 = "Recipe Name";
break;
case _RecipeCtrl_RecipeName:
GetDlgItem(IDC_NAME_EDIT1)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT2)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT2)->EnableWindow(true);
m_StaticName1 = "Old Recipe Name";
m_StaticName2 = "New Recipe Name";
break;
case _RecipeCtrl_AddSubRecipe:
GetDlgItem(IDC_NAME_EDIT1)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT1)->EnableWindow(false);
GetDlgItem(IDC_SEL_GROUP_COMBO)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_NAME_EDIT2)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT2)->EnableWindow(true);
m_StaticName1 = "Add to Recipe";
m_StaticName2 = "Sub Recipe Name";
break;
case _RecipeCtrl_DelSubRecipe:
GetDlgItem(IDC_NAME_EDIT1)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT1)->EnableWindow(false);
GetDlgItem(IDC_SEL_GROUP_COMBO)->ShowWindow(SW_HIDE);
GetDlgItem(IDC_NAME_EDIT2)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT2)->EnableWindow(false);
m_StaticName1 = "From Recipe";
m_StaticName2 = "Sub Recipe Name";
break;
case _RecipeCtrl_SubRecipeName:
GetDlgItem(IDC_NAME_EDIT1)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT2)->ShowWindow(SW_SHOW);
GetDlgItem(IDC_NAME_EDIT2)->EnableWindow(true);
m_StaticName1 = "Old SubRecipe Name";
m_StaticName2 = "New SubRecipe Name";
break;
default:
break;
}
UpdateData(FALSE);
return TRUE;
}
void CDlgRecipeCtrl::OnBnClickedOk()
{
UpdateData(TRUE);
CRecipeCtrlItem CtrlItem;
CtrlItem.m_EditName1 = &m_EditName1;
CtrlItem.m_EditName2 = &m_EditName2;
GetDlgItem(IDC_SEL_GROUP_COMBO)->GetWindowText(CtrlItem.m_SelGroupName);
CString Msg = gRecipeMgr->RecipeCtrlExcute(CtrlItem);
if(Msg != "")
{
CMsgBox MsgBox;
MsgBox.Show(Msg);
return;
}
OnOK();
}