projects/wms-framework/src/lib/regionsframework/adapters/AdapterForTabControl.ts
Adapter for TabControl region
Properties |
Methods |
|
Public
constructor(regionBehaviorFactory: IRegionBehaviorFactory)
|
||||||
Parameters :
|
RegionBehaviorFactory |
Type : IRegionBehaviorFactory
|
Inherited from
RegionAdapterBase
|
Defined in
RegionAdapterBase:41
|
Public Adapt | |||||||||
Adapt(region: IRegion, regionTarget: TabControlModel)
|
|||||||||
Inherited from
RegionAdapterBase
|
|||||||||
Defined in
RegionAdapterBase:50
|
|||||||||
Adapt the region to the target
Parameters :
Returns :
void
|
Public AttachBehaviors | |||||||||
AttachBehaviors(region: IRegion, regionTarget: TabControlModel)
|
|||||||||
Inherited from
RegionAdapterBaseUnTyped
|
|||||||||
Defined in
RegionAdapterBaseUnTyped:66
|
|||||||||
Attach the behavior to the region target element
Parameters :
Returns :
void
|
Public CreateRegion |
CreateRegion()
|
Inherited from
RegionAdapterBase
|
Defined in
RegionAdapterBase:89
|
Creates the target region for the adapted TabControl
Returns :
IRegion
|
Protected AttachDefaultBehaviors | |||||||||
AttachDefaultBehaviors(region: IRegion, regionTarget: T)
|
|||||||||
Inherited from
RegionAdapterBase
|
|||||||||
Defined in
RegionAdapterBase:71
|
|||||||||
Attach defaults behavior to region
Parameters :
Returns :
void
|
Initialize |
Initialize(regionTarget: object, regionName: string)
|
Inherited from
RegionAdapterBase
|
Defined in
RegionAdapterBase:48
|
Returns :
IRegion
|
import { inject, injectable } from 'tsyringe';
import { TabControlModel } from '../../models';
import { regionBehaviorFactoryInjectionToken } from '../injectionTokens';
import { IRegion } from '../IRegion';
import { IRegionBehaviorFactory } from '../IRegionBehaviorFactory';
import { RegionAdapterBase } from '../RegionAdapterBase';
import { SingleActiveRegion } from '../SingleActiveRegion';
import { InvalidOperationException } from '../../baseframework';
import { TabControlRegionSyncBehavior } from './behaviors/TabControlRegionSyncBehavior';
/**
* Adapter for TabControl region
*
* @export
* @class AdapterForTabControl
* @extends {RegionAdapterBase<TabControlModel>}
* @wType Microsoft.Practices.Prism.Regions.TabControlRegionAdapter
*/
@injectable()
export class AdapterForTabControl extends RegionAdapterBase<TabControlModel> {
public constructor(
@inject(regionBehaviorFactoryInjectionToken)
regionBehaviorFactory: IRegionBehaviorFactory
) {
super(regionBehaviorFactory);
}
/**
* Adapt the region to the target
*
* @param {IRegion} region
* @param {TabControlModel} regionTarget
* @memberof AdapterForTabControl
*/
public Adapt(region: IRegion, regionTarget: TabControlModel): void {
let itemsSourceIsSet: boolean = regionTarget.ItemsSource != null;
if (itemsSourceIsSet) {
throw new InvalidOperationException(
'ItemsControl property must not be set when using regions with tabControls'
);
}
}
/**
* Attach the behavior to the region target element
*
* @param {IRegion} region
* @param {TabControlModel} regionTarget
* @memberof AdapterForTabControl
*/
public AttachBehaviors(region: IRegion, regionTarget: TabControlModel): void {
if (region == null) {
throw new Error('Null value for region argument');
}
super.AttachBehaviors(region, regionTarget);
if (
!region.Behaviors.ContainsKey(TabControlRegionSyncBehavior.BehaviorKey)
) {
region.Behaviors.Add(
TabControlRegionSyncBehavior.BehaviorKey,
Object.assign(new TabControlRegionSyncBehavior(), {
HostControl: regionTarget,
})
);
}
}
/**
* Creates the target region for the adapted TabControl
*
* @returns {IRegion}
* @memberof AdapterForTabControl
*/
public CreateRegion(): IRegion {
return new SingleActiveRegion();
}
}