Esempio n. 1
0
 protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
 {
     if (args.PropertyName == CustomFontEffect.FontFileNameProperty.PropertyName)
     {
         //Android.Graphics.Typeface font = Android.Graphics.Typeface.CreateFromAsset(Forms.Context.ApplicationContext.Assets, "Fonts/" + CustomFontEffect.GetFontFileName(Element) + ".ttf");
         string fontPath = "Fonts/" + CustomFontEffect.GetFontFileName(Element) + ".ttf";
         Android.Graphics.Typeface font = Android.Graphics.Typeface.CreateFromAsset(context.Assets, fontPath);
         textViewControl.Typeface = font;
     }
 }
Esempio n. 2
0
        protected override void OnAttached()
        {
            try
            {
                control = control as TextView;

                string   fontPath = "Fonts/" + CustomFontEffect.GetFontFileName(Element) + ".ttf";
                Typeface font     = Typeface.CreateFromAsset(Forms.Context.Assets, fontPath);
                control.Typeface = font;
            }
            catch (Exception e)
            {
                Console.WriteLine("Cannot set property on attached control. Error: ", e.Message);
            }
        }
Esempio n. 3
0
        protected override void OnAttached()
        {
            try
            {
                //Xamarin.Forms.PlatformEffect<TContainer, TControl> : Control
                textViewControl = Control as TextView;
                //Xamarin.Forms.Effect : Element
                string fontPath = "Fonts/" + CustomFontEffect.GetFontFileName(Element) + ".ttf";

                //Typeface font = Typeface.CreateFromAsset(Forms.Context.Assets, fontPath);
                Android.Graphics.Typeface font = Android.Graphics.Typeface.CreateFromAsset(context.Assets, fontPath);
                textViewControl.Typeface = font;
            }
            catch (Exception ex)
            {
                Console.WriteLine("Cannot set property on attached control. Error: ", ex.Message);
            }
        }
Esempio n. 4
0
 protected override void OnElementPropertyChanged(PropertyChangedEventArgs args)
 {
     if (args.PropertyName == CustomFontEffect.FontFileNameProperty.PropertyName)
     {
         Typeface font = Typeface.CreateFromAsset(Forms.Context.ApplicationContext.Assets, "Fonts/" + CustomFontEffect.GetFontFileName(Element) + ".ttf");
         control.Typeface = font;
     }
 }