Occurs when an injector is mounted or unmounted inside LEADVIEW.
Object.defineProperty(InjectionManager.prototype, 'inject',
get: function(),
set: function(value)
)
A valid function defined by:
To receive injection information from LEADVIEW, pass a valid callback to the inject property.
The inject event will then be raised every time an injector is created, and will be fired again whenever the injector is going to be removed. For more information about the injector event's data structure, refer to InjectionArgs.
Similar to the BindingManager, an inject callback should be provided before calling Viewer.run.
export class InjectionManagerExample {
public constructor() {
if (lt.RasterSupport.kernelExpired)
lt.RasterSupport.setLicenseUri("https://demo.leadtools.com/licenses/js/LEADTOOLSEVAL.txt", "EVAL", null);
lt.LEADVIEW.InjectionManager.Instance.inject = this.inject;
}
public run = (divID: string): void => {
const lv = new lt.LEADVIEW.Viewer();
lv.run(null, {
'rootDivId': divID
});
}
private inject = (e: lt.LEADVIEW.InjectionArgs) => {
/**
* Simple example for showcasinbg injection functionality.
* We will inject a red square in every area that is capable of being injected.
*
* Since we are not wiring up any callbacks -- we don't need to perform any
* cleanup actions, so we can ignore all unmounting calls.
*/
if (e.state === lt.LEADVIEW.InjectionState.unmounting) return;
switch (e.type) {
case lt.LEADVIEW.InjectionType.toolbar:
this.injectToolbar(e.data);
break;
case lt.LEADVIEW.InjectionType.menu:
this.injectMenu(e.data);
break;
case lt.LEADVIEW.InjectionType.annToolbar:
this.injectAnnToolbar(e.data)
break;
}
}
private injectToolbar = (obj: any) => {
const injector = obj as lt.LEADVIEW.ToolbarInjector;
document.getElementById(injector.start).appendChild(this.getRedSquare());
document.getElementById(injector.end).appendChild(this.getRedSquare());
}
private injectMenu = (obj: any) => {
const injector = obj as lt.LEADVIEW.MenuInjector;
document.getElementById(injector.start).appendChild(this.getRedSquare());
document.getElementById(injector.end).appendChild(this.getRedSquare());
document.getElementById(injector.tabStart).appendChild(this.getRedSquare());
document.getElementById(injector.tabEnd).appendChild(this.getRedSquare());
document.getElementById(injector.content).appendChild(this.getRedSquare());
}
private injectAnnToolbar = (obj: any) => {
const injector = obj as lt.LEADVIEW.AnnPanelInjector;
document.getElementById(injector.start).appendChild(this.getRedSquare());
document.getElementById(injector.end).appendChild(this.getRedSquare());
}
private getRedSquare = () => {
const ele = document.createElement('div');
ele.style.width = '10px';
ele.style.height = '10px';
ele.style.backgroundColor = 'red';
return ele;
}
}