All the controls missing in WPF. Over 1 million downloads.
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.

71 lines
2.2 KiB

using System.Linq;
using System.Collections.Generic;
using System.Windows;
using System.Windows.Media;
namespace Microsoft.Windows.Controls.PropertyGrid.Editors
{
public class FontComboBoxEditor : ComboBoxEditor
{
protected override IList<object> CreateItemsSource(PropertyItem propertyItem)
{
if (propertyItem.PropertyType == typeof(FontFamily))
return GetFontFamilies();
else if (propertyItem.PropertyType == typeof(FontWeight))
return GetFontWeights();
else if (propertyItem.PropertyType == typeof(FontStyle))
return GetFontStyles();
else if (propertyItem.PropertyType == typeof(FontStretch))
return GetFontStretches();
return null;
}
private static IList<object> GetFontFamilies()
{
return Fonts.SystemFontFamilies.ToList<object>();
}
private static IList<object> GetFontWeights()
{
return new List<object>()
{
FontWeights.Black,
FontWeights.Bold,
FontWeights.ExtraBlack,
FontWeights.ExtraBold,
FontWeights.ExtraLight,
FontWeights.Light,
FontWeights.Medium,
FontWeights.Normal,
FontWeights.SemiBold,
FontWeights.Thin
};
}
private static IList<object> GetFontStyles()
{
return new List<object>()
{
FontStyles.Italic,
FontStyles.Normal
};
}
private static IList<object> GetFontStretches()
{
return new List<object>()
{
FontStretches.Condensed,
FontStretches.Expanded,
FontStretches.ExtraCondensed,
FontStretches.ExtraExpanded,
FontStretches.Normal,
FontStretches.SemiCondensed,
FontStretches.SemiExpanded,
FontStretches.UltraCondensed,
FontStretches.UltraExpanded
};
}
}
}