
#include "ExportEngineerpch.h"
#include "EngineerDialogHook.h"
#include <algorithm>
#include <functional>
#include <iostream>
#include <fstream>
#include "DialogResource.h"
#include "ExportEngineerCmd.h"
#include "ExportDoorHook.h"
#include "ExportEngineerStruct.h"

BindingValue g_binding;

using namespace std;
using namespace Bentley::MstnPlatform::Element;



DialogHookInfo uHooks[] =
{
	{ HOOKID_ListEngineer,(PFDialogHook)CellListlingHook },
	{ HOOKITEMID_Text,(PFDialogHook)EditCellHook },
	{ HOOKBTNID_Export,(PFDialogHook)ExportHook},
	{ HOOKID_ToggleBtnDeleteBlank ,(PFDialogHook)ToggleBtnDeleteBlank },
	{HOOKBTNID_ExportDoor,(PFDialogHook)ExportDoorHook},
	{HOOKID_ListDoor,(PFDialogHook)ExportDoorListHook},
	{ HOOKITEMID_Text_ExportDoor ,(PFDialogHook)EditListBox_Door_Hook }
};
void ExportData(WCharCP unparsed)
{
	MSDialogP dlgBox = mdlDialog_find(DIALOGID_ExportEngineer, NULL);
	if (dlgBox)
		mdlDialog_show(dlgBox);
	else
		dlgBox = mdlDialog_open(NULL, DIALOGID_ExportEngineer);

}
void ExportDoor(WCharCP unparsed)
{
	MSDialogP dlgBox = mdlDialog_find(DIALOGID_ExportDoor, NULL);
	if (dlgBox)
		mdlDialog_show(dlgBox);
	else
		dlgBox = mdlDialog_open(NULL, DIALOGID_ExportDoor);
}
RscFileHandle  g_rscFileH;

extern "C" DLLEXPORT void MdlMain(int argc, WCharCP argv[])
{
	mdlResource_openFile(&g_rscFileH, NULL, RSC_READONLY);


	mdlParse_loadCommandTable(NULL);
	MdlCommandNumber commandNumbers[] =
	{
		{ExportData,CMD_EXPORTS_ENGINEER},
		{ExportDoor,CMD_EXPORTS_DOOR},
		0
	};
	mdlSystem_registerCommandNumbers(commandNumbers);
	SymbolSet* setP = mdlCExpression_initializeSet(VISIBILITY_DIALOG_BOX, 0, 0);
	mdlDialog_publishComplexVariable(setP, "BindingValue", "g_binding", &g_binding);

	mdlDialog_hookPublish(sizeof uHooks / sizeof DialogHookInfo, uHooks);

}