projects/i-components/src/lib/components/solid-color-brush/solid-color-brush.component.ts
Angular Component for the SolidColorBrush Control.
changeDetection | ChangeDetectionStrategy.OnPush |
selector | wm-solid-color-brush |
styleUrls | ./solid-color-brush.component.scss |
templateUrl | ./solid-color-brush.component.html |
Properties |
|
Methods |
|
Inputs |
Accessors |
Public
constructor(injector: Injector, injectedModel: SolidColorBrushModel)
|
||||||||||||
Creates an instance of SolidColorBrushComponent.
Parameters :
|
color | |
Type : any
|
|
Sets a value indicating whether ther user can interact with the control |
model | |
Type : SolidColorBrushModel
|
|
Object with properties and events for the SolidColorBrush. |
getBrush |
getBrush()
|
Returns a SolidColorBrush object with the color assigned
Returns :
SolidColorBrush
SolidColorBrush |
ngOnInit |
ngOnInit()
|
Angular lifeCycle hook
Returns :
void
|
Protected applyPendingResourceAssignment | ||||||
applyPendingResourceAssignment(model: DependencyObject)
|
||||||
Inherited from
BaseWrapperComponent
|
||||||
Defined in
BaseWrapperComponent:85
|
||||||
Apply pending resource assignments
Parameters :
Returns :
void
|
Protected checkForStaticResourceReference | ||||||||||||
checkForStaticResourceReference(property: DependencyProperty, obj: any)
|
||||||||||||
Inherited from
BaseWrapperComponent
|
||||||||||||
Defined in
BaseWrapperComponent:62
|
||||||||||||
Verifies if the given value is a resource value
Parameters :
Returns :
boolean
{boolean} true if the value was assigned |
Protected resolveResource | ||||||
resolveResource(key: any)
|
||||||
Inherited from
BaseWrapperComponent
|
||||||
Defined in
BaseWrapperComponent:112
|
||||||
Resolve the resource in the current context
Parameters :
Returns :
any
|
model |
Type : SolidColorBrushModel
|
Decorators :
@Input()
|
Object with properties and events for the SolidColorBrush. |
Private modelProxy |
Type : SolidColorBrushModel
|
Default value : ModelProxy.create<SolidColorBrushModel>()
|
ModelProxy is a copy of the model, used on the component initial building to prevent crashes with external bindings. |
Protected pendingResourceValues |
Type : Array<>
|
Inherited from
BaseWrapperComponent
|
Defined in
BaseWrapperComponent:42
|
Pending resource assignments These assignments are performed when the model is available |
Protected pendingSetValuesColumns |
Type : Array<>
|
Default value : []
|
Inherited from
BaseWrapperComponent
|
Defined in
BaseWrapperComponent:51
|
A collection of pending values to assign to the model |
color | ||||||
getcolor()
|
||||||
Gets the color of the brush
Returns :
any
|
||||||
setcolor(value: any)
|
||||||
Sets a value indicating whether ther user can interact with the control
Parameters :
Returns :
void
|
import {
Component,
OnInit,
Input,
Optional,
Injector,
ChangeDetectionStrategy,
} from '@angular/core';
import {
SmColor,
SolidColorBrushModel,
SolidColorBrush,
ModelProxy,
ComponentId,
AngularComponentId,
} from '@mobilize/wms-framework';
import { Utils } from '../../utils/utilities';
import { BaseWrapperComponent } from '../basewrapper/basewrapper.component';
/**
* Angular Component for the SolidColorBrush Control.
*
* @export
* @class SolidColorBrushComponent
* @implements {OnInit}
*/
@Component({
selector: 'wm-solid-color-brush',
templateUrl: './solid-color-brush.component.html',
styleUrls: ['./solid-color-brush.component.scss'],
changeDetection: ChangeDetectionStrategy.OnPush,
})
@ComponentId([AngularComponentId.solidColorBrush])
export class SolidColorBrushComponent
extends BaseWrapperComponent
implements OnInit
{
/**
* Object with properties and events for the SolidColorBrush.
*
* @type {SolidColorBrushModel}
* @memberof SolidColorBrushComponent
*/
@Input() model: SolidColorBrushModel;
/**
* Sets a value indicating whether ther user can interact with the control
*
* @memberof SolidColorBrushComponent
*/
@Input() set color(value: any) {
if (
!this.checkForStaticResourceReference(
SolidColorBrushModel.ColorProperty,
value
)
) {
this.modelProxy.Color =
value instanceof SmColor ? value : Utils.createSmColor(value);
}
}
/**
* Gets the color of the brush
*
* @readonly
* @type {any}
* @memberof SolidColorBrushComponent
*/
get color(): any {
return this.model.Color ? this.model.Color : undefined;
}
/**
* ModelProxy is a copy of the model, used on the component initial building to prevent crashes with external bindings.
*
* @private
* @type {SolidColorBrushModel}
* @memberof SolidColorBrushComponent
*/
private modelProxy: SolidColorBrushModel =
ModelProxy.create<SolidColorBrushModel>();
/**
* Creates an instance of SolidColorBrushComponent.
*
* @param {Injector} injector - Angular Injector
* @param {SolidColorBrushModel} [injectedModel=null] - SolidColorBrush model for the current Angular Component
* @memberof SolidColorBrushComponent
*/
/* istanbul ignore next */
public constructor(
private injector: Injector,
@Optional() protected injectedModel: SolidColorBrushModel = null
) {
super();
this.model = injectedModel;
}
/**
* Angular lifeCycle hook
*
* @memberof SolidColorBrushComponent
*/
ngOnInit(): void {
this.model = this.model || this.injectedModel || new SolidColorBrushModel();
ModelProxy.copy(this.modelProxy, this.model);
this.modelProxy = this.model;
this.applyPendingResourceAssignment(this.model);
}
/**
* Returns a SolidColorBrush object with the color assigned
*
* @returns SolidColorBrush
*/
getBrush(): SolidColorBrush {
const brush = new SolidColorBrush(this.color);
return brush;
}
}
<ng-container></ng-container>
./solid-color-brush.component.scss