protected override void SetValueImpl(object target, object value)
        {
            var  tf   = (UITextView)target;
            Font font = value as Font;

            if (font != null)
            {
                try
                {
                    tf.Font = TouchAssetPlugin.GetCachedFont(font);
                    if (font.Color != System.Drawing.Color.Empty)
                    {
                        tf.TextColor = font.Color.ToNativeColor();
                    }

                    if (font.Alignment != TextAlignment.None)
                    {
                        tf.TextAlignment = font.ToNativeAlignment();
                    }
                }
                catch
                {
                    MvxBindingLog.Error("Failed to set font to UITextView. Check if font exists, has a size and filename, and is added to the plist");
                }
            }
        }
Exemple #2
0
        protected override void SetValueImpl(object target, object value)
        {
            var  button = (UIButton)target;
            Font font   = value as Font;

            if (font != null)
            {
                try {
                    button.Font = TouchAssetPlugin.GetCachedFont(font);
                    if (font.Color != System.Drawing.Color.Empty)
                    {
                        button.SetTitleColor(font.Color.ToNativeColor(), UIControlState.Normal);
                    }

                    if (font.SelectedColor != System.Drawing.Color.Empty)
                    {
                        button.SetTitleColor(font.SelectedColor.ToNativeColor(), UIControlState.Selected);
                    }

                    if (font.DisabledColor != System.Drawing.Color.Empty)
                    {
                        button.SetTitleColor(font.DisabledColor.ToNativeColor(), UIControlState.Disabled);
                    }
                }
                catch (Exception e) {
                    MvxBindingLog.Instance.Error("Failed to set font to UIButton. Check if font exists, has a size and filename, and is added to the plist");
                }
            }
        }
Exemple #3
0
        private object ConvertValue(object value, object parameter)
        {
            IMvxLanguageBinder textProvider = value as IMvxLanguageBinder;
            TouchAssetPlugin   assetPlugin  = MvvmCross.Mvx.Resolve <IAssetPlugin>() as TouchAssetPlugin;

            if (value != null && parameter != null)
            {
                try{
                    //split the text and font definition
                    var values = parameter.ToString().Split(';');

                    return(assetPlugin.ParseToAttributedText(textProvider.GetText(values[0]), assetPlugin.GetFontByName(values[1])));
                }catch (Exception e) {
                    MvxBindingLog.Error("Problem parsing binding {0}", e.ToLongString());
                }
            }

            return(null);
        }
Exemple #4
0
        private object ConvertValue(object value, object parameter)
        {
            TouchAssetPlugin assetPlugin = MvvmCross.Mvx.IoCProvider.Resolve <IAssetPlugin>() as TouchAssetPlugin;

            if (value != null && parameter != null)
            {
                try
                {
                    var stringValue = value.ToString();
                    if (string.IsNullOrWhiteSpace(stringValue))
                    {
                        return(string.Empty);
                    }
                    var text = assetPlugin.ParseToAttributedText(value.ToString(), assetPlugin.GetFontByName(parameter.ToString()));
                    return(text);
                }
                catch (Exception e)
                {
                    MvxBindingLog.Error("Problem parsing binding {0}", e.ToLongString());
                }
            }

            return(null);
        }