projects/wms-framework/src/lib/regionsframework/adapters/AdapterForContentControl.ts
Adapter for content control Allows the use of content control to host regions
Properties |
Methods |
|
constructor(factory: IRegionBehaviorFactory)
|
||||||
Creates an instance of AdapterForContentControl.
Parameters :
|
RegionBehaviorFactory |
Type : IRegionBehaviorFactory
|
Inherited from
RegionAdapterBase
|
Defined in
RegionAdapterBase:41
|
Protected Adapt | ||||||||||||
Adapt(region: IRegion, regionTarget: ContentControlModel)
|
||||||||||||
Inherited from
RegionAdapterBase
|
||||||||||||
Defined in
RegionAdapterBase:61
|
||||||||||||
Adapts the content control with the specific region
Parameters :
Returns :
void
|
Protected CreateRegion |
CreateRegion()
|
Inherited from
RegionAdapterBase
|
Defined in
RegionAdapterBase:77
|
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
|
Public AttachBehaviors |
AttachBehaviors(region: IRegion, target: any)
|
Inherited from
RegionAdapterBaseUnTyped
|
Defined in
RegionAdapterBaseUnTyped:23
|
Returns :
void
|
import { ContentControlModel } from '../../models/controls/ContentControlModel';
import { IRegion } from '../IRegion';
import { Region } from '../Region';
import { RegionAdapterBase } from '../RegionAdapterBase';
import { IRegionBehaviorFactory } from '../IRegionBehaviorFactory';
import { injectable, inject } from 'tsyringe';
import { regionBehaviorFactoryInjectionToken } from '../injectionTokens';
import {
CollectionChangeAction,
iuCount,
iuFirstOrDefault,
} from '../../baseframework/collections';
import { SingleActiveRegion } from '../SingleActiveRegion';
/**
* Adapter for content control
* Allows the use of content control to host regions
*
* @export
* @class AdapterForContentControl
* @extends {RegionAdapterBase<ContentControlModel>}
* @wType Microsoft.Practices.Prism.Regions.ContentControlRegionAdapter
*/
@injectable()
export class AdapterForContentControl extends RegionAdapterBase<ContentControlModel> {
/**
* Creates an instance of AdapterForContentControl.
* @param {IRegionBehaviorFactory} factory
* @memberof AdapterForContentControl
*/
constructor(
@inject(regionBehaviorFactoryInjectionToken) factory: IRegionBehaviorFactory
) {
super(factory);
}
/**
* Adapts the content control with the specific region
*
* @protected
* @param {IRegion} region region to adapt
* @param {ContentControlModel} regionTarget content control to adapt
* @memberof AdapterForContentControl
*/
protected Adapt(region: IRegion, regionTarget: ContentControlModel): void {
region.ActiveViews.CollectionChanged.addHandler((e, a) => {
regionTarget.Content = iuFirstOrDefault(region.ActiveViews);
});
region.Views.CollectionChanged.addHandler((sender, e) => {
if (
e.action != CollectionChangeAction.Add ||
iuCount(region.ActiveViews) != 0
)
return;
region.Activate(e.NewItems.getItem(0));
});
}
protected CreateRegion(): IRegion {
return new SingleActiveRegion();
}
}