|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows.Data;
using Microsoft.Practices.Unity;
namespace Wide.Interfaces.Converters
{
public class PercentToFontSizeConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
//For now lets assume 12.00 to be 100%
double? fsize = value as double?;
if(fsize != null)
{
return ((fsize/12.00)*100) + " %";
}
return "100 %";
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
double rValue = 12.0;
if (value != null)
{
string final = value as string;
final = final.Replace("%", "");
if (double.TryParse(final, out rValue))
{
rValue = (rValue/100.0)*12;
}
else
{
rValue = 12.0;
value = "100 %";
}
}
return rValue;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Hello! I'm a 26 year old, WPF/C# self-learned software developer, musician from India with a Master's degree in Computer science. I believe that every piece of software and information/knowledge is available for free for those who seek it.
My projects are available in
my Webpage hosted on Github. I am eager to learn new things everyday, explore new technologies and solve problems.