The state of the injector.
Object.defineProperty(InjectionArgs.prototype, 'state',
get: function(),
set: function(value)
)
Describes the current state of the injector.
Inject or remove custom UI components based on the value of state.
If the value is InjectionState.mounting, then the injector has been mounted into the DOM.
If the value is InjectionState.unmounting, then the injector is about to be removed from the DOM. Any cleanup needed for custom components should be called here to prevent memory leaks.
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;
}
}