Fore forms and Fore.NET forms or assemblies created in a repository, can be started from the developed code. To enable this feature, links to the following assemblies should be added to the project:
Assemblies required to start all the forms and assemblies:
Prognoz.Fore
Prognoz.Platform.Forms.Net
Prognoz.Platform.Interop.ForeSystem
Prognoz.Platform.Interop.Metabase
Prognoz.Platform.Interop.Ui
Prognoz.Platform.WinForms.Utils
To start Fore.NET assemblies:
Prognoz.Platform.Interop.ForeNet
The following assemblies are also required to start Fore.NET forms separately from Fore.NET assemblies:
Prognoz.Platform.Interop.Fore
Prognoz.Platform.Interop.Forms
The following method need to be executed before starting assemblies in the code:
Prognoz.P5.Interop.Ui.IUiWinApplication.CheckAfxState: this method initializes system variable of the analytical platform required to ensure correct performance of objects.
Prognoz.P5.Forms.Net.ForeNetFormVS.SetActiveMetabase: this method defines the repository within which the objects are to be started.
These methods need to be executed once before some form is started for the first time:
IUiWinApplication WinAppCls = new UiWinApplicationClass();
WinAppCls.CheckAfxState();
ForeNetFormVS.SetActiveMetabase(Mb);
By finishing all work it is recommended to reset a reference to the repository for enforced releasing of resources used to store connection with the repository:
ForeNetFormVS.SetActiveMetabase(Null);
To start a Fore form, the user needs to execute the following method for the respective repository object: Open or OpenWithParam:
IMetabaseObjectDescriptor ForeForm = Mb.ItemById["TestForm"];
ForeForm.Open(ForeForm.Params.CreateEmptyValues());
To start a Fore.NET assembly, the user needs to execute the following method for the respective repository object: Run:
IMetabaseObjectDescriptor MObj = Mb.ItemById["TestAssm"];
((IForeNETAssembly)MObj.Bind()).Run();
To start a Fore.NET form, the user needs to execute the following method for the respective repository object: Show or ShowDialog:
IForeServices Svc = (IForeServices)Mb;
IForeRuntime ForeRun = Svc.GetRuntime();
IForeNETAssemblyClass RuntimeClass = new ForeNETAssemblyClassClass();
IForeNETRuntime Run = RuntimeClass.Runtime;
IForeNETRuntimeAssembly Asm = Run.Assembly[(Mb.ItemById["TestAssm"].Bind() as IForeNETAssembly), ForeRun.Context];
IForeNETRuntimeForm RuntimeForm = Asm.Form["TestAssm.MAINForm"];
RuntimeForm.Show();
See also:
Using Foresight Analytics Platform Resources in Third-Party Applications