You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
45 lines
1.2 KiB
45 lines
1.2 KiB
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) |
|
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) |
|
|
|
using System; |
|
using System.Globalization; |
|
using System.Windows; |
|
using System.Windows.Data; |
|
|
|
namespace ICSharpCode.PackageManagement |
|
{ |
|
[ValueConversion(typeof(Boolean), typeof(FontWeight))] |
|
public class BooleanToFontWeightConverter : IValueConverter |
|
{ |
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
|
{ |
|
if (value is Boolean) { |
|
Boolean fontIsBold = (Boolean)value; |
|
return ConvertToFontWeight(fontIsBold); |
|
} |
|
return DependencyProperty.UnsetValue; |
|
} |
|
|
|
FontWeight ConvertToFontWeight(Boolean bold) |
|
{ |
|
if (bold) { |
|
return FontWeights.Bold; |
|
} |
|
return FontWeights.Normal; |
|
} |
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
|
{ |
|
if (value is FontWeight) { |
|
FontWeight fontWeight = (FontWeight)value; |
|
return ConvertToBoolean(fontWeight); |
|
} |
|
return DependencyProperty.UnsetValue; |
|
} |
|
|
|
bool ConvertToBoolean(FontWeight fontWeight) |
|
{ |
|
return fontWeight == FontWeights.Bold; |
|
} |
|
} |
|
}
|
|
|