首次提交:添加src文件夹代码
This commit is contained in:
36
Cowain.Bake.Common/Converter/ScaleConverter.cs
Normal file
36
Cowain.Bake.Common/Converter/ScaleConverter.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace Cowain.Bake.Common.Converter
|
||||
{
|
||||
public class ScaleConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
|
||||
if (parameter == null)
|
||||
throw new ArgumentNullException("value can not be null");
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value can not be null");
|
||||
double c = System.Convert.ToDouble(parameter);
|
||||
double index = System.Convert.ToDouble(value);
|
||||
return index / c;
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
if (parameter == null)
|
||||
throw new ArgumentNullException("value can not be null");
|
||||
if (value == null)
|
||||
throw new ArgumentNullException("value can not be null");
|
||||
double c = System.Convert.ToDouble(parameter);
|
||||
double index = System.Convert.ToDouble(value);
|
||||
return System.Convert.ToInt32(index * c);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user