using System;
using System.Data;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using AAL;
namespace AAL
{
public class BootstrapLoader
{
static ICore.IComponentManager icm;
static void Main(string[] args)
{
Dbg.Initialize();
Dbg.Problems.Add(
new DbgKey("NullValueError"),
"",
new String[] {"A null value was encountered."});
MethodInfo mi=Lib.Methods.GetMethodInfo("ComponentManager.dll/AAL.ComponentManager/Init1");
icm=mi.Invoke(null, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.InvokeMethod | BindingFlags.Static, null, null, null) as ICore.IComponentManager;
icm.InitializeComponents();
// typical application functions
icm.RegisterInterfacePoint("App", "Exit", new InterfacePoint(AppExit));
// test workflow domain and data set creation
//***
icm.Invoke("TestComponent.Test", null);
ICore.IWorkflowManager iwm=icm.GetInterface("WorkflowManager") as ICore.IWorkflowManager;
ICore.IDataHub idh=icm.GetInterface("DataHub") as ICore.IDataHub;
idh.LoadDomainSpecifications("dataDomain.xml");
idh.CreateWorkflowDomain("SingleItemSaleOrder");
idh.LoadInitialLoadSet("SingleItemSaleOrder", "RetailPrice");
//***
// Application Initialization
DataTable dt=Lib.Xml.GetTable("appInfo.xsd", args[0], "//AppInfo");
string formListFile=dt.Rows[0]["FormFile"] as string;
string mainFormName=dt.Rows[0]["MainFormName"] as string;
string menuFile=dt.Rows[0]["MenuFile"] as string;
string appType=dt.Rows[0]["AppType"] as string;
string appIcon=dt.Rows[0]["AppIcon"] as string;
EventData ev=EventData.Marshal(new MED[] {new MED("FormList", formListFile)});
icm.Invoke("WindowFormManager.LoadForms", ev);
ev=EventData.Marshal(new MED[] {new MED("MenuDefFile", menuFile)});
icm.Invoke("MenuMgr.LoadMenus", ev);
ev=EventData.Marshal(new MED[] {new MED("FormName", mainFormName), new MED("AppIcon", appIcon)});
switch(appType)
{
case "Dialog":
icm.Invoke("FormMgr.CreateDlgApp", ev);
break;
case "Single Document":
icm.Invoke("FormMgr.CreateSDIApp", ev);
break;
case "Multi Document":
icm.Invoke("FormMgr.CreateMDIApp", ev);
break;
}
icm.Invoke("FormMgr.ShowForm", ev);
ev=EventData.Marshal(new MED[] {new MED("FormName", mainFormName), new MED("MenuName", "MainMenu")});
icm.Invoke("MenuMgr.AssignMenu", ev);
// create child forms
// ******************* Window selection of child forms is broken **********************
ev=EventData.Marshal(new MED[] {new MED("ParentFormName", "MDI1"), new MED("FormName", "MDIChild1")});
icm.Invoke("FormMgr.AddMDIChild", ev);
icm.Invoke("FormMgr.ShowForm", ev);
ev=EventData.Marshal(new MED[] {new MED("ParentFormName", "MDI1"), new MED("FormName", "MDIChild2")});
icm.Invoke("FormMgr.AddMDIChild", ev);
icm.Invoke("FormMgr.ShowForm", ev);
// ******************** Menu State Test ******************
ev=EventData.Marshal(new MED[] {new MED("MenuItemName", "TileH"), new MED("State", false)});
icm.Invoke("MenuMgr.SetState", ev);
// Testing
// ev=EventData.Marshal(new MED[] {new MED("FormName", "MainPanelForm"), new MED("ControlSetName", "CheckInCS")});
// icm.Invoke("FormMgr.LoadControlSet", ev);
/*
// simple MDI test
EventData ev=EventData.Marshal(new MED[] {new MED("FormList", "TestFormList.xml")});
icm.Invoke("WindowFormManager.LoadForms", ev);
ev=EventData.Marshal(new MED[] {new MED("MenuDefFile", "menus.xml")});
icm.Invoke("MenuMgr.LoadMenus", ev);
ev=EventData.Marshal(new MED[] {new MED("FormName", "MDI1"), new MED("AppIcon", "ka.ico")});
icm.Invoke("FormMgr.CreateMDIApp", ev);
icm.Invoke("FormMgr.ShowForm", ev);
ev=EventData.Marshal(new MED[] {new MED("ParentFormName", "MDI1"), new MED("FormName", "MDIChild1")});
icm.Invoke("FormMgr.AddMDIChild", ev);
icm.Invoke("FormMgr.ShowForm", ev);
ev=EventData.Marshal(new MED[] {new MED("ParentFormName", "MDI1"), new MED("FormName", "MDIChild2")});
icm.Invoke("FormMgr.AddMDIChild", ev);
icm.Invoke("FormMgr.ShowForm", ev);
ev=EventData.Marshal(new MED[] {new MED("FormName", "MDI1"), new MED("MenuName", "MainMenu")});
icm.Invoke("MenuMgr.AssignMenu", ev);
*/
// DBY example
/*
EventData ev=EventData.Marshal(new MED[] {new MED("FormList", "BoatYardFormList.xml")});
icm.Invoke("WindowFormManager.LoadForms", ev);
ev=EventData.Marshal(new MED[] {new MED("MenuDefFile", "menus.xml")});
icm.Invoke("MenuMgr.LoadMenus", ev);
ev=EventData.Marshal(new MED[] {new MED("FormName", "MainForm")});
icm.Invoke("FormMgr.CreateSDIApp", ev);
icm.Invoke("FormMgr.ShowForm", ev);
ev=EventData.Marshal(new MED[] {new MED("FormName", "MainForm"), new MED("MenuName", "MainMenu")});
icm.Invoke("MenuMgr.AssignMenu", ev);
*/
Application.Run();
}
static object AppExit(EventData ev)
{
icm.Invoke("FormMgr.CloseAll", null);
Application.Exit();
return null;
}
}
}