projects/wms-framework/src/lib/baseframework/SmColorToBrushConverter.ts
Helper for manipulating Color to Brush conversion
Methods |
Convert | |||||||||||||||
Convert(value: any, targetType: RuntimeTypeInfo, parameter: any, culture: any)
|
|||||||||||||||
Converts the SmColor value to SolidColorBrush
Parameters :
Returns :
any
|
ConvertBack | |||||||||||||||
ConvertBack(value: any, targetType: RuntimeTypeInfo, parameter: any, culture: any)
|
|||||||||||||||
Converts the SolidColorBrush value to the respective SmColor value
Parameters :
Returns :
any
|
import { IValueConverter } from '../basecomponentmodel/IValueConverter';
import { SmColor } from '../media/color';
import { SolidColorBrush } from '../media/SolidColorBrush';
import { RuntimeTypeInfo } from './ReflectionSupport';
/**
* Helper for manipulating Color to Brush conversion
*
* @export
* @class SmEnumHelper
* @wType Telerik.Windows.Controls.ColorToBrushConverter
*/
export class SmColorToBrushConverter implements IValueConverter {
/**
* Converts the SmColor value to SolidColorBrush
*
* @param {*} value
* @param {RuntimeTypeInfo} targetType
* @param {*} parameter
* @param {*} culture
* @returns
* @memberof SmColorToBrushConverter
*/
Convert(
value: any,
targetType: RuntimeTypeInfo,
parameter: any,
culture: any
) {
var solidColorBrush = new SolidColorBrush();
if (value != null) solidColorBrush.Color = value as SmColor;
return solidColorBrush;
}
/**
* Converts the SolidColorBrush value to the respective SmColor value
*
* @param {*} value
* @param {RuntimeTypeInfo} targetType
* @param {*} parameter
* @param {*} culture
* @returns
* @memberof SmColorToBrushConverter
*/
ConvertBack(
value: any,
targetType: RuntimeTypeInfo,
parameter: any,
culture: any
) {
return value instanceof SolidColorBrush ? value.Color : null;
}
}