本文整理汇总了C#中System.Windows.Forms.ConvertEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# ConvertEventArgs类的具体用法?C# ConvertEventArgs怎么用?C# ConvertEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ConvertEventArgs类属于System.Windows.Forms命名空间,在下文中一共展示了ConvertEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnKeyModifierBindingConvert
private static void OnKeyModifierBindingConvert(object sender, ConvertEventArgs e)
{
if (e.Value is XKeys && e.DesiredType == typeof (ModifierFlags))
{
ModifierFlags result = ModifierFlags.None;
XKeys value = (XKeys) e.Value;
if ((value & XKeys.Control) == XKeys.Control)
result = result | ModifierFlags.Control;
if ((value & XKeys.Alt) == XKeys.Alt)
result = result | ModifierFlags.Alt;
if ((value & XKeys.Shift) == XKeys.Shift)
result = result | ModifierFlags.Shift;
e.Value = result;
}
else if (e.Value is ModifierFlags && e.DesiredType == typeof (XKeys))
{
XKeys result = XKeys.None;
ModifierFlags value = (ModifierFlags) e.Value;
if ((value & ModifierFlags.Control) == ModifierFlags.Control)
result = result | XKeys.Control;
if ((value & ModifierFlags.Alt) == ModifierFlags.Alt)
result = result | XKeys.Alt;
if ((value & ModifierFlags.Shift) == ModifierFlags.Shift)
result = result | XKeys.Shift;
e.Value = result;
}
}
示例2: Invert
private static void Invert(object sender, ConvertEventArgs e)
{
if (e.DesiredType == typeof(bool))
{
e.Value = !((bool)e.Value);
}
}
示例3: OnFormatQuality
private void OnFormatQuality(object sender, ConvertEventArgs e)
{
if (e.DesiredType != typeof(string))
return;
e.Value = String.Format("({0})", (int)e.Value);
}
示例4: ImageToFile
private void ImageToFile(object sender, ConvertEventArgs e)
{
if (e.DesiredType == typeof(string))
{
// Substitute the filename.
e.Value = picProduct.Tag;
}
}
示例5: DecimalToFloatString
public static void DecimalToFloatString(object sender, ConvertEventArgs cevent)
{
// The method converts only to string type. Test this using the DesiredType.
if (cevent.DesiredType != typeof(string)) return;
if(!string.IsNullOrEmpty(cevent.Value.ToString()))
cevent.Value = ((decimal)cevent.Value).ToString("###,###,###.00");
}
示例6: DecimalToCurrencyString
private void DecimalToCurrencyString(object sender, ConvertEventArgs e)
{
if (e.DesiredType == typeof(string))
{
// Use the ToString method to format the value as currency ("c").
e.Value = ((decimal)e.Value).ToString("c");
}
}
示例7: CheckBoxNeverEnd_Format
void CheckBoxNeverEnd_Format(object sender, ConvertEventArgs e)
{
// from object to control
// Never Ending should be checked when there is no end date
if (e.DesiredType == typeof(bool))
e.Value = (e.Value == null);
}
示例8: DecimalToCurrencyString
public static void DecimalToCurrencyString(object sender, ConvertEventArgs cevent)
{
// The method converts only to string type. Test this using the DesiredType.
if (cevent.DesiredType != typeof(string)) return;
// Use the ToString method to format the value as currency ("c").
if (!string.IsNullOrEmpty(cevent.Value.ToString()))
cevent.Value = ((decimal)cevent.Value).ToString("c");
}
示例9: DateFormat
public static void DateFormat(object sender, ConvertEventArgs e)
{
if (e.Value is System.DBNull)
{
return;
}
e.Value = Convert.ToDateTime(e.Value).ToShortDateString();
}
示例10: CurrencyFormat
public static void CurrencyFormat(object sender, ConvertEventArgs e)
{
if (e.Value is System.DBNull)
{
return;
}
e.Value = (Convert.ToDouble(e.Value)).ToString("C");
}
示例11: FloatStringToDecimal
public static void FloatStringToDecimal(object sender, ConvertEventArgs cevent)
{
// The method converts back to decimal type only.
if (cevent.DesiredType != typeof(decimal)) return;
// Converts the string back to decimal using the static Parse method.
cevent.Value = Decimal.Parse(cevent.Value.ToString(),
NumberStyles.Any, null);
}
示例12: CurrencyStringToDecimal
public static void CurrencyStringToDecimal(object sender, ConvertEventArgs cevent)
{
// The method converts back to decimal type only.
if (cevent.DesiredType != typeof(decimal)) return;
if (!string.IsNullOrEmpty(cevent.Value.ToString()))
// Converts the string back to decimal using the static Parse method.
cevent.Value = Decimal.Parse(cevent.Value.ToString(),
NumberStyles.Currency, null);
}
示例13: OnFormat
protected override void OnFormat(ConvertEventArgs cevent)
{
if (this._converter != null)
{
var converterdValue = this._converter.Convert(cevent.Value, cevent.DesiredType, _converterParameter,
_converterCulture);
cevent.Value = converterdValue;
}
else base.OnFormat(cevent);
}
示例14: OnPortBindingFormat
void OnPortBindingFormat(object sender, ConvertEventArgs e)
{
if (e.DesiredType != typeof(string))
return;
if ((int)e.Value <= 0)
e.Value = "";
else
e.Value = e.Value.ToString();
}
示例15: IsShredHostRunningFormat
void IsShredHostRunningFormat(object sender, ConvertEventArgs e)
{
// The method converts only to string type. Test this using the DesiredType.
if (e.DesiredType != typeof(string)) return;
// Use the ToString method to format the value as currency ("c").
if (true == ((bool)e.Value))
e.Value = (string)"ShredHost is Running";
else
e.Value = (string)"ShredHost is Stopped";
}