protected override void OnElementChanged(ElementChangedEventArgs <Label> e)
        {
            base.OnElementChanged(e);

            CustomFontLabel label = (CustomFontLabel)Element;

            try{
                if (e.OldElement == null)
                {
                    if (!string.IsNullOrEmpty(label.FontName))
                    {
                        Control.Typeface = Typeface.CreateFromAsset(this.Context.Assets, label.FontName + ".ttf");
                    }
                }
                if (label.FontSize != 0)
                {
                    Control.TextSize = (float)label.FontSize;
                }
                if (label.MarginLeft != 0 || label.MarginRight != 0)
                {
                    Control.SetPadding((int)label.MarginLeft, 0, 0, 0);
                }
            }catch (Exception ex) {
            }
        }
Example #2
0
        public FloatingActionControl()
        {
            Spacing           = 10;
            Orientation       = StackOrientation.Horizontal;
            HorizontalOptions = LayoutOptions.End;

            _floatingActionButton = new FloatingActionButton {
                HorizontalOptions = LayoutOptions.End,
                Source            = FLOATING_BUTTON_IMAGE,
                SizeRequest       = 30
            };
            _tooltipLabel = new CustomFontLabel {
                TextColor = Color.Black, CustomFontSize = NamedSize.Micro
            };

            _tooltipLayout = new Frame {
                BackgroundColor = Color.White,
                Padding         = new Thickness(10, 0),
                HasShadow       = false,
                Content         = _tooltipLabel
            };

            Children.Add(_tooltipLayout);
            Children.Add(_floatingActionButton);
        }
Example #3
0
        protected override void OnElementChanged(ElementChangedEventArgs <Label> elementChangedEventArgs)
        {
            base.OnElementChanged(elementChangedEventArgs);

            CustomFontLabel label = elementChangedEventArgs.NewElement as CustomFontLabel;

            if (label?.FontFamilyName != null)
            {
                Control.Font = UIFont.FromName(label.FontFamilyName, Control.Font.PointSize);
            }
        }
        protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
        {
            base.OnElementChanged(e);

            if(e.NewElement != null)
            {
                _formsElement = (CustomFontLabel)e.NewElement;

                UpdateFont();
            }
        }
        protected override void OnElementChanged(ElementChangedEventArgs <Label> elementChangedEventArgs)
        {
            base.OnElementChanged(elementChangedEventArgs);

            CustomFontLabel label = elementChangedEventArgs.NewElement as CustomFontLabel;

            if (label?.FontFamilyName != null)
            {
                Control.Typeface = Typeface.CreateFromAsset(Context.Assets, $"fonts/{label.FontFamilyName}.ttf");
            }
        }
        public FloatingActionControl()
        {
            Spacing = 10;
            Orientation = StackOrientation.Horizontal;
            HorizontalOptions = LayoutOptions.End;

            _floatingActionButton = new FloatingActionButton {
                HorizontalOptions = LayoutOptions.End,
                Source = FLOATING_BUTTON_IMAGE,
                SizeRequest = 30
            };
            _tooltipLabel = new CustomFontLabel {TextColor = Color.Black, CustomFontSize = NamedSize.Micro};

            _tooltipLayout = new Frame {
                BackgroundColor = Color.White,
                Padding = new Thickness(10, 0),
                HasShadow = false,
                Content = _tooltipLabel
            };

            Children.Add(_tooltipLayout);
            Children.Add(_floatingActionButton);
        }