Ejemplo n.º 1
0
 private static void OnStyleSelectorPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
 {
     if (d is ContentControl cc)
     {
         cc.FontFamily = StyleSelectorBaseImplementation.GetSelectedFontFamily(e.NewValue);
     }
 }
Ejemplo n.º 2
0
        private static void OnIconPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
#if NET40
            d.SetValue(TextOptions.TextRenderingModeProperty, TextRenderingMode.ClearType);
#endif
            if (d is FontAwesome fa)
            {
                FontFamily selectedStyle = StyleSelectorBaseImplementation.GetSelectedFontFamily(fa.StyleSelector);
                d.SetValue(FontFamilyProperty, selectedStyle);
            }

            d.SetValue(TextAlignmentProperty, TextAlignment.Center);
            d.SetValue(TextProperty, char.ConvertFromUtf32((int)e.NewValue));
        }
Ejemplo n.º 3
0
        private static void ContentChanged(DependencyObject sender, DependencyPropertyChangedEventArgs evt)
        {
            // If target is not a ContenControl just ignore: Awesome.Content property can only be set on a ContentControl element
            if (!(sender is ContentControl))
            {
                return;
            }

            ContentControl target = (ContentControl)sender;

            // If value is not a FontAwesomeIcon just ignore: Awesome.Content property can only be set to a FontAwesomeIcon value
            if (!(evt.NewValue is FontAwesomeIcon))
            {
                return;
            }

            FontAwesomeIcon symbolIcon = (FontAwesomeIcon)evt.NewValue;
            int             symbolCode = (int)symbolIcon;
            char            symbolChar = (char)symbolCode;

            target.FontFamily = StyleSelectorBaseImplementation.GetSelectedFontFamily(GetStyleSelector(sender));
            target.Content    = symbolChar;
        }
Ejemplo n.º 4
0
 private static Typeface GetTypeFace(StyleSelector styleSelector)
 {
     return(new Typeface(StyleSelectorBaseImplementation.GetSelectedFontFamily(styleSelector), FontStyles.Normal,
                         FontWeights.Normal, FontStretches.Normal));
 }