38 lines
1.6 KiB
C#
38 lines
1.6 KiB
C#
using System.ComponentModel;
|
|
|
|
namespace CoreUnit.Scanner.UserControl.ScannerCanvas
|
|
{
|
|
public class ScannerParamConverter : ExpandableObjectConverter
|
|
{
|
|
public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType)
|
|
{
|
|
if (sourceType == typeof(string)) return true;
|
|
return base.CanConvertFrom(context, sourceType);
|
|
}
|
|
|
|
public override bool CanConvertTo(ITypeDescriptorContext context, System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(ScannerParam)) return true;
|
|
return base.CanConvertTo(context, destinationType);
|
|
}
|
|
|
|
public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
|
|
{
|
|
return base.ConvertFrom(context, culture, value);
|
|
}
|
|
|
|
public override object ConvertTo(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value, System.Type destinationType)
|
|
{
|
|
if (destinationType == typeof(System.String) && ((int)value != -1)) {
|
|
// 이 부분이 Property Grid의 Title value를 지정하는 곳 입니다.
|
|
ScannerParam item = ScannerCanvasUserCtrl.ScannerParams[(int)value];
|
|
value = string.Format(" {0:D3} {1}", item.No + 1, item.Description);
|
|
} else {
|
|
if ((int)value == -1) value = null; //ScannerParamNo의 초기값이 -1이므로, -1값이 표시되지 않도록 구성함.
|
|
}
|
|
|
|
return base.ConvertTo(context, culture, value, destinationType);
|
|
}
|
|
}
|
|
}
|