public void SetTypeface(TextView target, Typeface t)
 {
     if (t == null) return;
     PaintFlags flags = target.PaintFlags | PaintFlags.SubpixelText;
     target.PaintFlags = flags;
     target.Typeface = t;
 }
        private static void ApplyCustomTypeFace(Paint paint, Typeface tf, Android.Graphics.Color color)
        {
            int oldStyle;
            Typeface old = paint.Typeface;
            if (old == null)
            {
                oldStyle = 0;
            }
            else
            {
                oldStyle = (int)old.Style;
            }

            int fake = oldStyle & ~(int)tf.Style;
            if ((fake & (int)TypefaceStyle.Bold) != 0)
            {
                paint.FakeBoldText = true;
            }

            if ((fake & (int)TypefaceStyle.Italic) != 0)
            {
                paint.TextSkewX = -0.25f;
            }



            paint.SetARGB(color.A, color.R, color.G, color.B);

            paint.SetTypeface(tf);
        }
 public override void SetTypeface(Typeface tf, TypefaceStyle style)
 {
     base.SetTypeface (tf, style);
     RefitText(Text, tf);
     SetWillNotDraw(false);
     PostInvalidate();
 }
 public CustomTypefaceSpan(string family, Typeface type, TypefaceStyle style, int size)
     : base(family)
 {
     newType = type;
     this.style = style;
     this.size = size;
 }
        public CustomTypefaceSpan(String family, Typeface type, Android.Graphics.Color color)
            : base(family)
        {

            newType = type;
            fontColor = color;
        }
示例#6
0
 private void SetButton(int resorceId, Type activityOnClick, Typeface font)
 {
     var startGameButton = FindViewById<Button>(resorceId);
     startGameButton.Touch += (sender, e) => this.OnTouchButtonDarker(startGameButton, e);
     startGameButton.Click += (sender, e) => StartActivity (new Intent (this, activityOnClick));
     startGameButton.SetTypeface (font, TypefaceStyle.Normal);
 }
示例#7
0
        protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);
            try
            {
                CustomEntry element = Element as CustomEntry;

                if (element.IsCustomPassword == true)
                {
                    Control.TransformationMethod = PasswordTransformationMethod.Instance;

                    //Control.InputType = InputTypes.TextVariationPassword;
                    //Control.InputType = InputTypes.TextVariationPassword | InputTypes.ClassText;
                }
                else
                {
                    Control.TransformationMethod = HideReturnsTransformationMethod.Instance;                     //PasswordTransformationMethod.Instance;
                }
                if (Control != null)
                {
                    //var element = Element as CustomEntry;

                    GradientDrawable gd = new GradientDrawable();
                    //gd.SetCornerRadius(45); // increase or decrease to changes the corner look
                    gd.SetColor(global::Android.Graphics.Color.Transparent);
                    //gd.SetStroke(2, global::Android.Graphics.Color.Gray);
                    this.Control.SetBackgroundDrawable(gd);
                    this.Control.SetRawInputType(InputTypes.TextFlagNoSuggestions);
                    //Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.Black));//for placeholder
                    //this.Control.InputType = InputTypes.TextVariationPassword;

                    //Control.FocusChange += EntryFocusChanged;

                    if (element.CustomFontSize != 0.0)
                    {
                        Control.SetTextSize(ComplexUnitType.Dip, element.CustomFontSize);
                    }
                    if (element.CustomFontFamily == "MontserratBold")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat-Bold.ttf");
                        Control.Typeface = font;
                    }
                    else if (element.CustomFontFamily == "MontserratLight")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat-Light.ttf");
                        Control.Typeface = font;
                    }
                    else
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat-Regular.ttf");
                        Control.Typeface = font;
                    }
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
        }
示例#8
0
        protected override void OnElementChanged(ElementChangedEventArgs <DatePicker> e)
        {
            base.OnElementChanged(e);

            try
            {
                CustomDatePicker element = Element as CustomDatePicker;
                if (e.NewElement != null)
                {
                    element = Element as CustomDatePicker;
                }
                else
                {
                    element = e.OldElement as CustomDatePicker;
                }

                if (Control != null)
                {
                    //var element = Element as CustomDatePicker;
                    GradientDrawable gd = new GradientDrawable();
                    //gd.SetCornerRadius(45); // increase or decrease to changes the corner look
                    gd.SetColor(global::Android.Graphics.Color.Transparent);
                    //gd.SetStroke(2, global::Android.Graphics.Color.Gray);
                    this.Control.SetBackgroundDrawable(gd);
                    this.Control.SetRawInputType(InputTypes.TextFlagNoSuggestions);
                    if (!string.IsNullOrWhiteSpace(element.EnterText))
                    {
                        Control.Text = element.EnterText;
                    }
                    Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.Black));                    //for placeholder
                    if (element.CustomFontSize != 0.0)
                    {
                        Control.SetTextSize(ComplexUnitType.Dip, element.CustomFontSize);
                        //Control.SetTextSize(Android.Util.ComplexUnitType.Dip, element.CustomFontSize);
                    }

                    if (element.CustomFontFamily == "MontserratBold")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat-Bold.ttf");
                        Control.Typeface = font;
                    }
                    else if (element.CustomFontFamily == "MontserratLight")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat-Light.ttf");
                        Control.Typeface = font;
                    }
                    else
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat-Regular.ttf");
                        Control.Typeface = font;
                    }
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
            //this.Control.InputType = InputTypes.TextVariationPassword;
        }
示例#9
0
 public XeListViewAdapter(Activity context, List<Connection> connections)
 {
     this.context = context;
     this.connections = connections;
     colorList = new List<Color> ();
     kalinga = Typeface.CreateFromAsset (context.Assets, "fonts/kalinga.ttf");
     kalingab = Typeface.CreateFromAsset (context.Assets, "fonts/kalingab.ttf");
 }
示例#10
0
 public XListViewAdapter(Activity context, List<Connection> items)
     : base()
 {
     this.context = context;
     this.Items = items;
     kalinga = Typeface.CreateFromAsset (context.Assets, "fonts/kalinga.ttf");
     kalingab = Typeface.CreateFromAsset (context.Assets, "fonts/kalingab.ttf");
 }
示例#11
0
 public static FontData ToXwt(this AG.Typeface backend)
 {
     if (backend == null)
     {
         return(null);
     }
     return(new FontData(backend));
 }
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            try
            {
                CustomEntry element = Element as CustomEntry;
                if (e.NewElement != null)
                {
                    element = Element as CustomEntry;
                }
                else
                {
                    element = e.OldElement as CustomEntry;
                }
                if (element.IsCustomPassword == true)
                {
                    Control.TransformationMethod = PasswordTransformationMethod.Instance;
                    //Control.InputType = InputTypes.TextVariationPassword;
                    //Control.InputType = InputTypes.TextVariationPassword | InputTypes.ClassText;
                }
                if (Control != null)
                {
                    //var element = Element as CustomEntry;

                    GradientDrawable gd = new GradientDrawable();
                    //gd.SetCornerRadius(45); // increase or decrease to changes the corner look
                    gd.SetColor(global::Android.Graphics.Color.Transparent);
                    //gd.SetStroke(2, global::Android.Graphics.Color.Gray);
                    this.Control.SetBackgroundDrawable(gd);
                    this.Control.SetRawInputType(InputTypes.TextFlagNoSuggestions);
                    //Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.Black));//for placeholder
                    //this.Control.InputType = InputTypes.TextVariationPassword;
                    if (element.CustomFontSize != 0.0)
                    {
                        Control.SetTextSize(ComplexUnitType.Dip, element.CustomFontSize);
                    }
                    if (element.CustomFontFamily == "Avenir65")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "AvenirLTStd-Medium.ttf");
                        Control.Typeface = font;
                    }
                    else if (element.CustomFontFamily == "Avenir45")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "AvenirLTStd-Book.ttf");
                        Control.Typeface = font;
                    }
                    else
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
        }
 public Typeface GetTypeface(Context context)
 {
     lock (_locker)
     {
         if (cachedTypeface != null) return cachedTypeface;
         cachedTypeface = Typeface.CreateFromAsset(context.Assets, IconFontDescriptor.TTFileName);
         return cachedTypeface;
     }
 }
示例#14
0
 static void replaceFont(string staticTypefaceFieldName,Typeface newTypeface)
 {
     try {
         IntPtr cls = JNIEnv.FindClass("android/graphics/Typeface");
         IntPtr fld = JNIEnv.GetStaticFieldID(cls, staticTypefaceFieldName, "Landroid/graphics/Typeface;");
         JNIEnv.SetStaticField(cls, fld, newTypeface.Handle);
     } catch {
     }
 }
示例#15
0
        private static void ApplyCustomTypeface(Paint paint, Typeface tf, TypefaceStyle style, int size)
        {
            if (style == TypefaceStyle.Italic)
                paint.TextSkewX = -0.25f;

            if(size > 0)
                paint.TextSize = size;

            paint.SetTypeface (tf);
        }
示例#16
0
 public void DrawText(string text, string fontName, float size, SolidColor color, Rectangle rect, ReoGridHorAlign halign, ReoGridVerAlign valign)
 {
     using (var p = new Paint())
     {
         using (var font = Typeface.Create(fontName, Android.Graphics.TypefaceStyle.Normal))
         {
             this.DrawText(text, p, font, size, rect, halign, valign);
         }
     }
 }
		public CustomFontSpan(string typefaceName)
		{
			typeFace = (Typeface)typefaceCache.Get(typefaceName);

			if (typeFace == null)
			{
				typeFace = Typeface.CreateFromAsset(Forms.Context.ApplicationContext.Assets, typefaceName);
				typefaceCache.Put(typefaceName, typeFace);
			}
		}
示例#18
0
        public TypefaceSpan(Context context, String typefaceName)
        {
            mTypeface = (Typeface)sTypefaceCache.Get(typefaceName);

            if (mTypeface == null)
            {
                mTypeface = Typeface.CreateFromAsset(context.Assets, string.Format("fonts/{0}", typefaceName));
                sTypefaceCache.Put(typefaceName, mTypeface);
            }
        }
示例#19
0
 public CustomTypefaceSpan(Icon icon, Typeface type, float iconSizePx, float iconSizeRatio, int iconColor,
     bool rotate)
 {
     _rotate = rotate;
     _icon = icon.Character.ToString();
     _typeface = type;
     _iconSizePx = iconSizePx;
     _iconSizeRatio = iconSizeRatio;
     _iconColor = new Color(iconColor);
     _rotationStartTime = DateTimeHelpers.CurrentUnixTimeMillis();
 }
 public CustomTypefaceSpan(IIcon icon, Typeface type, Single iconSizePx, Single iconSizeRatio, Int32 iconColor, System.Boolean rotate, System.Boolean baselineAligned)
 {
     _rotate = rotate;
     _baselineAligned = baselineAligned;
     _icon = icon.Character.ToString();
     _type = type;
     _iconSizePx = iconSizePx;
     _iconSizeRatio = iconSizeRatio;
     _iconColor = iconColor;
     _rotationStartTime = SystemClock.CurrentThreadTimeMillis();
 }
 public CustomTypefaceSpan(IIcon icon, Typeface type,
     float iconSizePx, float iconSizeRatio, int iconColor,
     bool rotate, bool baselineAligned)
 {
     this.rotate = rotate;
     this.baselineAligned = baselineAligned;
     this.icon = icon.Character.ToString();
     this.type = type;
     this.iconSizePx = iconSizePx;
     this.iconSizeRatio = iconSizeRatio;
     this.iconColor = iconColor;
     this.rotationStartTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond;
 }
示例#22
0
        public TextDrawable(String text, Context ctx)
        {
            _text = text;

            if (_iconFont == null)
                _iconFont = Typeface.CreateFromAsset(ctx.Assets, "fontawesome-webfont.ttf");

            _paint = new Paint {Color = (Color.White), TextSize = 22f, AntiAlias = true};
            //_paint.SetTypeface(_iconFont);
            _paint.SetShadowLayer(6f, 0, 0, Color.Black);
            _paint.SetStyle(Paint.Style.Fill);
            _paint.TextAlign = Paint.Align.Left;
        }
        protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);


            try
            {
                CustomDatePicker element = Element as CustomDatePicker;
                if (Control != null)
                {
                    //var element = Element as CustomDatePicker;
                    GradientDrawable gd = new GradientDrawable();
                    //gd.SetCornerRadius(45); // increase or decrease to changes the corner look
                    gd.SetColor(global::Android.Graphics.Color.Transparent);
                    //gd.SetStroke(2, global::Android.Graphics.Color.Gray);
                    this.Control.SetBackgroundDrawable(gd);
                    this.Control.SetRawInputType(InputTypes.TextFlagNoSuggestions);
                    Control.Gravity = global::Android.Views.GravityFlags.CenterVertical;
                    if (!string.IsNullOrWhiteSpace(element.EnterText))
                    {
                        //Control.Text = element.EnterText;
                    }
                    Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.Black));//for placeholder
                    if (element.CustomFontSize != 0.0)
                    {
                        Control.SetTextSize(ComplexUnitType.Dip, element.CustomFontSize);
                        //Control.SetTextSize(Android.Util.ComplexUnitType.Dip, element.CustomFontSize);
                    }

                    if (element.CustomFontFamily == "Avenir65")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "AvenirLTStd-Medium.ttf");
                        Control.Typeface = font;
                    }
                    else if (element.CustomFontFamily == "Avenir45")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "AvenirLTStd-Book.ttf");
                        Control.Typeface = font;
                    }
                    else
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
            //this.Control.InputType = InputTypes.TextVariationPassword;
        }
		private Typeface GetTypeface(string fontName)
		{
			if (fontName == null)
			{
				return Typeface.Default;
			}

			if (textTypeface == null)
			{
				textTypeface = Typeface.Create(fontName, TypefaceStyle.Normal);
			}

			return textTypeface;
		}
		private void Initialize ()
		{
			Focusable = true;

			mPaintFondo = new Paint();
			mPaintFondo.AntiAlias = true;

			mPaintSuperior = new Paint();
			mPaintSuperior.AntiAlias = true;

			mPaintTexto = new Paint();
			mPaintTexto.AntiAlias = true;
			mPaintTexto.TextAlign = Paint.Align.Center;
			mFace =Typeface.CreateFromAsset(Application.Context.Assets , "fonts/Sansation_Light.ttf");
		}
 private void ApplyCustomTypeFace(Paint paint, Typeface tf)
 {
     paint.FakeBoldText = false;
     paint.TextSkewX = 0f;
     paint.SetTypeface(tf);
     if (_rotate)
         paint.ClearShadowLayer();
     if (_iconSizeRatio > 0)
         paint.TextSize = (paint.TextSize * _iconSizeRatio);
     else if (_iconSizePx > 0)
         paint.TextSize = _iconSizePx;
     if (_iconColor < Int32.MaxValue)
         paint.Color = new Color(_iconColor);
     paint.Flags = paint.Flags | PaintFlags.SubpixelText;
 }
 public virtual Typeface GetTypeface(Context context)
 {
     if (_cachedTypeface != null)
     {
         return _cachedTypeface;
     }
     lock (_lck)
     {
         //if (_cachedTypeface != null)
         //{
         //    return _cachedTypeface;
         //}
         _cachedTypeface = CreateTypeface(context);
         return _cachedTypeface;
     }
 }
 protected void UpdateElementWithChanges()
 {
     try
     {
         if (element != null)
         {
             if (Control != null)
             {
                 GradientDrawable gd = new GradientDrawable();
                 //gd.SetCornerRadius(45); // increase or decrease to changes the corner look
                 gd.SetColor(global::Android.Graphics.Color.Transparent);
                 //gd.SetStroke(2, global::Android.Graphics.Color.Gray);
                 this.Control.SetBackgroundDrawable(gd);
                 this.Control.SetRawInputType(InputTypes.TextFlagNoSuggestions);
                 //Control.Text = element.EnterText;
                 Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.Black));//for placeholder
                 //this.Control.InputType = InputTypes.TextVariationPassword;
                 if (element.CustomFontSize != 0.0)
                 {
                     Control.SetTextSize(ComplexUnitType.Dip, element.CustomFontSize);
                 }
                 if (!(string.IsNullOrEmpty(element.FontFamily)))
                 {
                     try
                     {
                         Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, element.FontFamily);
                         Control.Typeface = font;
                     }
                     catch (Exception ex)
                     {
                         var msg = ex.Message + "\n" + ex.StackTrace;
                         System.Diagnostics.Debug.WriteLine(msg);
                     }
                 }
                 else
                 {
                 }
             }
         }
     }
     catch (Exception ex)
     {
         var msg = ex.Message + "\n" + ex.StackTrace;
         System.Diagnostics.Debug.WriteLine(msg);
     }
 }
示例#29
0
        internal void DrawText(string text, Paint p, Typeface font, float size, Rectangle rect, ReoGridHorAlign halign, ReoGridVerAlign valign)
        {
            p.SetTypeface(font);
            p.TextSize = size;

            var measuredRect = new Rect();

            p.GetTextBounds(text, 0, text.Length, measuredRect);

            float x = rect.Left, y = rect.Top;

            switch (halign)
            {
            case ReoGridHorAlign.General:
            case ReoGridHorAlign.Left:
                x = rect.Left;
                break;

            case ReoGridHorAlign.Center:
                x = rect.Left + (rect.Width - measuredRect.Width()) / 2;
                break;

            case ReoGridHorAlign.Right:
                x = rect.Right - measuredRect.Width();
                break;
            }

            switch (valign)
            {
            case ReoGridVerAlign.Top:
                y = rect.Top + measuredRect.Height();
                break;

            case ReoGridVerAlign.Middle:
                y = rect.Bottom - (rect.Height - measuredRect.Height()) / 2;
                break;

            case ReoGridVerAlign.General:
            case ReoGridVerAlign.Bottom:
                y = rect.Bottom;
                break;
            }

            this.canvas.DrawText(text, x, y, p);
        }
示例#30
0
        protected override void OnElementChanged(ElementChangedEventArgs <Label> e)
        {
            base.OnElementChanged(e);

            try
            {
                CustomLabel element = Element as CustomLabel;
                if (e.NewElement != null)
                {
                    element = Element as CustomLabel;
                }
                else
                {
                    element = e.OldElement as CustomLabel;
                }

                if (Control != null)
                {
                    if (!string.IsNullOrWhiteSpace(element.CustomFontColor))
                    {
                        Control.SetTextColor(Graphicss.Color.ParseColor(element.CustomFontColor));
                    }

                    if (element.CustomFontFamily == "MontserratBold")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat-Bold.ttf");
                        Control.Typeface = font;
                    }
                    else if (element.CustomFontFamily == "MontserratLight")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat-Light.ttf");
                        Control.Typeface = font;
                    }
                    else
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "Montserrat-Regular.ttf");
                        Control.Typeface = font;
                    }
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
        }
示例#31
0
 public static string FamilyName(this AG.Typeface typeface)
 {
     if (typeface == AG.Typeface.SansSerif)
     {
         return("sans");
     }
     if (typeface == AG.Typeface.Serif)
     {
         return("serif");
     }
     if (typeface == AG.Typeface.Monospace)
     {
         return("monospace");
     }
     if (typeface == AG.Typeface.Default)
     {
         return("normal");
     }
     return("normal");
 }
        private static void apply(Paint paint, Typeface tf) {
            TypefaceStyle oldStyle;
            var old = paint.Typeface;
            if (old == null) {
                oldStyle = 0;
            } else {
                oldStyle = old.Style;
            }

            var fake = oldStyle & ~tf.Style;
            if ((fake & TypefaceStyle.Bold) == TypefaceStyle.Bold) {
                paint.FakeBoldText = true;
            }

            if ((fake & TypefaceStyle.Italic) == TypefaceStyle.Italic) {
                paint.TextSkewX = -0.25f;
            }

            paint.SetTypeface(tf);
            paint.Flags = paint.Flags | PaintFlags.SubpixelText;
        }
示例#33
0
 public ButtonUI(ButtonUI buttonUI)
 {
     StrokeShade = buttonUI.StrokeShade;
     FillShade = buttonUI.FillShade;
     StrokeColor = buttonUI.StrokeColor;
     FillColor = buttonUI.FillColor;
     IsTextStroked = buttonUI.IsTextStroked;
     IsSquared = buttonUI.IsSquared;
     Typeface = buttonUI.Typeface;
     Gravity = buttonUI.Gravity;
     Shape = buttonUI.Shape;
     Padding = buttonUI.Padding;
     TextSizeRatio = buttonUI.TextSizeRatio;
     StrokeBorderWidthRatio = buttonUI.StrokeBorderWidthRatio;
     StrokeTextWidthRatio = buttonUI.StrokeTextWidthRatio;
     StrokeBorderWidth = buttonUI.StrokeBorderWidth;
     StrokeTextWidth = buttonUI.StrokeTextWidth;
     _textSize = buttonUI._textSize;
     _radiusIn = buttonUI._radiusIn;
     _radiusOut = buttonUI._radiusOut;
 }
        /// <summary>
        /// Handles the Element Changed messages
        /// </summary>
        /// <param name="e">The e.</param>
        protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
        {
            base.OnElementChanged(e);
            if (this.Control != null && e.NewElement != null)
            {
                if (_helper == null)
                    _helper = new TextViewRenderHelper(Context);
                if (_iconSpan == null)
                {
                    _nativeLabel = (Android.Widget.TextView)this.Control;
                    _iconLabel = (IconLabel)e.NewElement;
                    //Set default value
                    if (_iconLabel.IconSize == 0)
                        _iconLabel.IconSize = _iconLabel.FontSize;

                    _iconFont = _helper.TrySetFont("fontawesome-webfont.ttf");
                    _textFont = _iconLabel.Font.ToTypeface();
                }
                SetText();
            }
        }
示例#35
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate (bundle);
            SetContentView (Resource.Layout.view_itinerary);

            kalingab = Typeface.CreateFromAsset (this.Assets, "fonts/kalingab.ttf");

            var _result = Intent.GetStringExtra ("RESULT") ?? "error";
            var result = JsonValue.Parse (_result);
            if (!result.ContainsKey ("error")) {
                var connectionResult = result ["connection"];
                var id_1 = result ["timestamp"];
                connections = new List<Connection> ();
                foreach (var jConnection in connectionResult) {
                    var connection = new Connection (XTool.Decode (id_1), jConnection.ToString ());
                    connections.Add (connection);
                }
                var btn = FindViewById<ImageButton> (Resource.Id.footer);
                btn.Click += MultiChoice;
                Connection cnct = connections [0];
                var fromStation = cnct.Departure ["station"];
                var toStation = cnct.Arrival ["station"];
                var tvFrom = FindViewById<TextView> (Resource.Id.tvFromTitle);
                var tvTo = FindViewById<TextView> (Resource.Id.tvToTitle);
                RunOnUiThread (() => {
                    tvFrom.Text = fromStation;
                    tvTo.Text = toStation;
                    tvFrom.Typeface = kalingab;
                    tvTo.Typeface = kalingab;
                });

                var eListView = FindViewById<ExpandableListView> (Resource.Id.eListView);
                var eListAdapter = new XeListViewAdapter (this, connections);
                eListView.SetAdapter (eListAdapter);
                eListView.GroupClick += GroupClicked;
            } else {
                XTool.ShowToast (this, Resource.String.error);
                Finish ();
            }
        }
        /// <summary>
        /// Handles the Element Changed event messages
        /// </summary>
        /// <param name="e">The e.</param>
        protected override void OnElementChanged(ElementChangedEventArgs<Xamarin.Forms.Button> e)
        {
            base.OnElementChanged(e);
            if (e.NewElement != null && this.Control != null)
            {
                if (_helper == null)
                    _helper = new TextViewRenderHelper(Context);
                if (_iconSpan == null)
                {
                    _nativeBtn = (Android.Widget.Button)this.Control;
                    _iconButton = (IconButton)e.NewElement;

                    _iconFont = _helper.TrySetFont("fontawesome-webfont.ttf");
                    _textFont = _iconButton.Font.ToTypeface();
                    _iconButton.IconSize = _iconButton.IconSize == 0 ? (float)_iconButton.FontSize : _iconButton.IconSize;
                    var computedString = BuildRawTextString();

                    _iconSpan = BuildSpannableString(computedString);
                    if (_iconButton.TextAlignement == Xamarin.Forms.TextAlignment.Center)
                    {
                        _nativeBtn.Gravity = Android.Views.GravityFlags.Center;

                    }
                    else if (_iconButton.TextAlignement == Xamarin.Forms.TextAlignment.End)
                    {
                        _nativeBtn.Gravity = Android.Views.GravityFlags.Right;
                    }
                    else if (_iconButton.TextAlignement == Xamarin.Forms.TextAlignment.Start)
                    {
                        _nativeBtn.Gravity = Android.Views.GravityFlags.Left;
                    }
                    _nativeBtn.TransformationMethod = null;
                    _nativeBtn.SetPadding(0, 0, 0, 0);
                    _nativeBtn.AfterTextChanged += nativeBtn_AfterTextChanged;
                }
            }


        }
示例#37
0
        public TextDrawable(
                string text,
                Typeface font,
                int sizeDpi,
                Color? color,
                bool antiAliased,
                bool fakeBold,
                float shadowRadius,
                float shadowDx,
                float shadowDy,
                Color shadowColor,
                Context context
            ) : base() {

            this.context = context;
            this.text = text;
            this.size = DpToPx(sizeDpi) * PADDING_RATIO;
            this.height = DpToPx(sizeDpi);
            this.width = DpToPx(sizeDpi);
            this.color = color;
            this.antiAliased = antiAliased;
            this.fakeBold = fakeBold;
            this.shadowRadius = shadowRadius;
            this.shadowDx = shadowDx;
            this.shadowDy = shadowDy;
            this.shadowColor = shadowColor;
            this.paint = new Paint();

            this.paint.SetStyle(Paint.Style.Fill);
            this.paint.TextAlign = Paint.Align.Center;
            if (this.color.HasValue)
                this.paint.Color = this.color.Value;
            this.paint.TextSize = this.size;
            //var font = Typeface.CreateFromAsset(context.Assets, "fontawesome-webfont.ttf");
            this.paint.SetTypeface(font);
            this.paint.AntiAlias = this.antiAliased;
            this.paint.FakeBoldText = this.fakeBold;
            this.paint.SetShadowLayer(this.shadowRadius, this.shadowDx, this.shadowDy, this.shadowColor);
        }
        protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
        {
 	        base.OnElementChanged(e);
            if (this.Control != null && e.NewElement != null)
            {
                if (iconSpan == null)
                {
                    nativeLabel = (Android.Widget.TextView)this.Control;
                    iconLabel = (IconLabel)e.NewElement;
                    //Set default value
                    if (iconLabel.IconSize == 0)
                        iconLabel.IconSize = iconLabel.FontSize;



                    iconFont = TrySetFont("fontawesome-webfont.ttf");
                    textFont = iconLabel.Font.ToTypeface();
                    SetText();


                }
            }
        }
示例#39
0
 public void StoreTypeface(string key, Typeface typeface)
 {
     _cacheDict[key] = typeface;
 }
示例#40
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.raceSchedule);
            circuitImage  = FindViewById <ImageView>(Resource.Id.cktImage);
            circuitImage2 = FindViewById <ImageView>(Resource.Id.raceScheduleBanner);
            //circuitImage2.Visibility = ViewStates.Gone;
            cktName        = FindViewById <TextView>(Resource.Id.textViewCktName);
            raceRound      = FindViewById <TextView>(Resource.Id.textViewRound);
            raceDay        = FindViewById <TextView>(Resource.Id.textViewDay);
            raceDate       = FindViewById <TextView>(Resource.Id.textViewDate);
            eRace          = FindViewById <TextView>(Resource.Id.textViewErace);
            raceQualifying = FindViewById <TextView>(Resource.Id.textViewQualifying);
            racePractice1  = FindViewById <TextView>(Resource.Id.textViewPractice1);
            racePractice2  = FindViewById <TextView>(Resource.Id.textViewPractice2);
            Android.Graphics.Typeface tf1 = Android.Graphics.Typeface.CreateFromAsset(Assets, "Khula-Regular.ttf");
            Android.Graphics.Typeface tf3 = Android.Graphics.Typeface.CreateFromAsset(Assets, "Khula-SemiBold.ttf");
            Android.Graphics.Typeface tf  = Android.Graphics.Typeface.CreateFromAsset(Assets, "PoppinsMedium.ttf");
            Android.Graphics.Typeface tf2 = Android.Graphics.Typeface.CreateFromAsset(Assets, "Khula-Light.ttf");
            cktName.SetTypeface(tf, Android.Graphics.TypefaceStyle.Bold);
            raceRound.SetTypeface(tf, Android.Graphics.TypefaceStyle.Bold);
            raceDay.SetTypeface(tf1, Android.Graphics.TypefaceStyle.Bold);
            raceDate.SetTypeface(tf2, Android.Graphics.TypefaceStyle.Normal);
            eRace.SetTypeface(tf3, Android.Graphics.TypefaceStyle.Normal);
            raceQualifying.SetTypeface(tf3, Android.Graphics.TypefaceStyle.Normal);
            racePractice1.SetTypeface(tf3, Android.Graphics.TypefaceStyle.Normal);
            racePractice2.SetTypeface(tf3, Android.Graphics.TypefaceStyle.Normal);
            await Task.Run(() => CountryListFetcher());

            //cktImage = FindViewById<ImageView>(Resource.Id.cktImage1);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            toolbar.Title = "Race Schedule";
            SetSupportActionBar(toolbar);
            if (SupportActionBar != null)
            {
                SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            }

            InitItemsAsync();
            spinner = FindViewById <MaterialSpinner>(Resource.Id.spinnerCountrySelect);
            adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, listItems);
            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleDropDownItem1Line);
            spinner.Adapter       = adapter;
            spinner.ItemSelected += async(s, e) =>
            {
                if (e.Position != -1)
                {
                    long selected = spinner.GetItemIdAtPosition(e.Position);
                    Console.WriteLine("Selected : " + selected);
                    await getRaceSchedule(selected);

                    //switch (selected)
                    //{
                    //    case 0:
                    //        Console.WriteLine("Cases {0}", selected);
                    //        await getRaceSchedule(selected);
                    //        break;

                    //    case 1:
                    //        Console.WriteLine("Cases {0}", selected);
                    //        await getRaceSchedule(selected);
                    //        break;

                    //    case 2:
                    //        Console.WriteLine("Cases {0}", selected);
                    //        await getRaceSchedule(selected);
                    //        break;

                    //    case 3:
                    //        Console.WriteLine("Cases {0}", selected);
                    //        await getRaceSchedule(selected);
                    //        break;
                    //}
                }
            };
        }
示例#41
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            if (container == null)
            {
                // Currently in a layout without a container, so no reason to create our view.
                return(null);
            }

            Point displaySize = new Point( );

            Activity.WindowManager.DefaultDisplay.GetSize(displaySize);
            ScreenSize = new System.Drawing.SizeF(displaySize.X, displaySize.Y);

            // scale the image to match the view's width
            ScreenToImageScalar = (float)SourceImage.Width / (float)ScreenSize.Width;

            // get the scaled dimensions, maintaining aspect ratio
            float scaledWidth  = (float)SourceImage.Width * (1.0f / ScreenToImageScalar);
            float scaledHeight = (float)SourceImage.Height * (1.0f / ScreenToImageScalar);

            // now, if the scaled height is too large, re-calc with Height is the dominant,
            // so we guarantee a fit within the view.
            if (scaledHeight > ScreenSize.Height)
            {
                ScreenToImageScalar = (float)SourceImage.Height / (float)ScreenSize.Height;

                scaledWidth  = (float)SourceImage.Width * (1.0f / ScreenToImageScalar);
                scaledHeight = (float)SourceImage.Height * (1.0f / ScreenToImageScalar);
            }

            ScaledSourceImage = Bitmap.CreateScaledBitmap(SourceImage, (int)scaledWidth, (int)scaledHeight, false);


            // setup our layout for touch input
            RelativeLayout view = inflater.Inflate(Resource.Layout.ImageCrop, container, false) as RelativeLayout;

            view.SetOnTouchListener(this);


            // create the view that will display the image to crop
            ImageView = new AspectScaledImageView(Rock.Mobile.PlatformSpecific.Android.Core.Context);
            ImageView.LayoutParameters        = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
            ImageView.LayoutParameters.Width  = ScaledSourceImage.Width;
            ImageView.LayoutParameters.Height = ScaledSourceImage.Height;

            // center the image
            ImageView.SetX((ScreenSize.Width - ImageView.LayoutParameters.Width) / 2);
            ImageView.SetY((ScreenSize.Height - ImageView.LayoutParameters.Height) / 2);

            view.AddView(ImageView);

            // create the draggable crop view that will let the user pic which part of the image to use.
            CropView = new View(Rock.Mobile.PlatformSpecific.Android.Core.Context);
            CropView.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);

            // the crop view's dimensions should be based on what the user wanted to crop to. We'll do width, and then height as a scale of width.
            CropView.LayoutParameters.Width  = (int)(scaledWidth < scaledHeight ? scaledWidth : scaledHeight);
            CropView.LayoutParameters.Height = (int)((float)CropView.LayoutParameters.Width * CropAspectRatio);

            // the crop view should be a nice outlined rounded rect
            float          _Radius   = 3.0f;
            RoundRectShape rectShape = new RoundRectShape(new float[] { _Radius,
                                                                        _Radius,
                                                                        _Radius,
                                                                        _Radius,
                                                                        _Radius,
                                                                        _Radius,
                                                                        _Radius,
                                                                        _Radius }, null, null);
            // configure its paint
            ShapeDrawable border = new ShapeDrawable(rectShape);

            border.Paint.SetStyle(Paint.Style.Stroke);
            border.Paint.StrokeWidth = 8;
            border.Paint.Color       = Color.WhiteSmoke;
            CropView.Background      = border;


            // set our clamp values
            CropViewMinPos = new PointF((ScreenSize.Width - scaledWidth) / 2,
                                        (ScreenSize.Height - scaledHeight) / 2);

            CropViewMaxPos = new PointF(CropViewMinPos.X + (scaledWidth - CropView.LayoutParameters.Width),
                                        CropViewMinPos.Y + (scaledHeight - CropView.LayoutParameters.Height));
            view.AddView(CropView);

            // create a mask layer that will block out the parts of the image that will be cropped
            MaskLayer = new Rock.Mobile.PlatformSpecific.Android.Graphics.MaskLayer((int)ScreenSize.Width, (int)ScreenSize.Height, CropView.LayoutParameters.Width, CropView.LayoutParameters.Height, Rock.Mobile.PlatformSpecific.Android.Core.Context);
            MaskLayer.LayoutParameters = new RelativeLayout.LayoutParams((int)ScreenSize.Width, (int)ScreenSize.Height);
            MaskLayer.Opacity          = 0.00f;
            view.AddView(MaskLayer);

            // Now setup our bottom area with cancel, crop, and text to explain
            RelativeLayout bottomBarLayout = new RelativeLayout(Rock.Mobile.PlatformSpecific.Android.Core.Context);

            bottomBarLayout.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            ((RelativeLayout.LayoutParams)bottomBarLayout.LayoutParameters).AddRule(LayoutRules.AlignParentBottom);

            // set the nav subBar color (including opacity)
            Color navColor = Rock.Mobile.UI.Util.GetUIColor(PrivateSubNavToolbarConfig.BackgroundColor);

            navColor.A = (Byte)((float)navColor.A * PrivateSubNavToolbarConfig.Opacity);
            bottomBarLayout.SetBackgroundColor(navColor);
            view.AddView(bottomBarLayout);

            // setup the cancel button (which will undo cropping or take you back to the picture taker)
            CancelButton = new Button(Rock.Mobile.PlatformSpecific.Android.Core.Context);
            CancelButton.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
            CancelButton.Gravity          = GravityFlags.Left;
            ((RelativeLayout.LayoutParams)CancelButton.LayoutParameters).AddRule(LayoutRules.AlignParentLeft);

            // set the crop button's font
            Android.Graphics.Typeface fontFace = Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(PrivateControlStylingConfig.Icon_Font_Secondary);
            CancelButton.SetTypeface(fontFace, Android.Graphics.TypefaceStyle.Normal);
            CancelButton.SetTextSize(Android.Util.ComplexUnitType.Dip, PrivateImageCropConfig.CropCancelButton_Size);
            CancelButton.Text = PrivateImageCropConfig.CropCancelButton_Text;

            CancelButton.Click += (object sender, EventArgs e) =>
            {
                // don't allow button presses while animations are going on
                if (Animating == false)
                {
                    // if they hit cancel while previewing, go back to editing
                    if (Mode == CropMode.Previewing)
                    {
                        SetMode(CropMode.Editing);
                    }
                    else
                    {
                        // they pressed it while they're in editing mode, so go back to camera mode
                        Activity.OnBackPressed( );
                    }
                }
            };

            bottomBarLayout.AddView(CancelButton);

            // setup the Confirm button, which will use a font to display its graphic
            ConfirmButton = new Button(Rock.Mobile.PlatformSpecific.Android.Core.Context);
            ConfirmButton.LayoutParameters = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
            ConfirmButton.Gravity          = GravityFlags.Right;
            ((RelativeLayout.LayoutParams)ConfirmButton.LayoutParameters).AddRule(LayoutRules.AlignParentRight);

            // set the crop button's font
            fontFace = Rock.Mobile.PlatformSpecific.Android.Graphics.FontManager.Instance.GetFont(PrivateControlStylingConfig.Icon_Font_Secondary);
            ConfirmButton.SetTypeface(fontFace, Android.Graphics.TypefaceStyle.Normal);
            ConfirmButton.SetTextSize(Android.Util.ComplexUnitType.Dip, PrivateImageCropConfig.CropOkButton_Size);
            ConfirmButton.Text = PrivateImageCropConfig.CropOkButton_Text;

            // when clicked, we should crop the image.
            ConfirmButton.Click += (object sender, EventArgs e) =>
            {
                // don't allow button presses while animations are going on
                if (Animating == false)
                {
                    // if they pressed confirm while editing, go to preview
                    if (Mode == CropMode.Editing)
                    {
                        SetMode(CropMode.Previewing);
                    }
                    else
                    {
                        // notify the caller
                        SpringboardParent.ModalFragmentDone(CroppedImage);
                    }
                }
            };

            bottomBarLayout.AddView(ConfirmButton);

            // start in editing mode (obviously)
            SetMode(CropMode.Editing);

            // start the cropper centered
            MoveCropView(new PointF((ScreenSize.Width - CropView.LayoutParameters.Width) / 2, (ScreenSize.Height - CropView.LayoutParameters.Height) / 2));

            MaskLayer.Position = new PointF(CropView.GetX( ), CropView.GetY( ));

            return(view);
        }
示例#42
0
 public static Font ToEto(this ag.Typeface typeface)
 {
     return(new Font(new FontHandler(typeface)));
 }
示例#43
0
        protected override void OnElementChanged(ElementChangedEventArgs <Entry> e)
        {
            base.OnElementChanged(e);

            try
            {
                element = Element as CustomEntry;
                if (e.NewElement != null)
                {
                    element = Element as CustomEntry;
                }
                else
                {
                    element = e.OldElement as CustomEntry;
                }

                if (Control != null)
                {
                    //var element = Element as CustomEntry;


                    GradientDrawable gradientDrawable = new GradientDrawable();
                    gradientDrawable.SetColor(global::Android.Graphics.Color.Transparent);
                    if (element.BorderColors != null)
                    {
                        gradientDrawable.SetStroke(2, global::Android.Graphics.Color.ParseColor(element.BorderColors));
                    }
                    //gradientDrawable.SetCornerRadius(45); // increase or decrease to changes the corner look
                    this.Control.SetBackgroundDrawable(gradientDrawable);
                    this.Control.SetRawInputType(InputTypes.TextFlagNoSuggestions);
                    //Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.Black));//for placeholder
                    //this.Control.InputType = InputTypes.TextVariationPassword;
                    Control.Gravity = global::Android.Views.GravityFlags.CenterVertical;
                    Control.SetPadding(30, 0, 30, 0);

                    //Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.Black));//for placeholder

                    if (element.CustomFontSize != 0.0)
                    {
                        Control.SetTextSize(ComplexUnitType.Dip, element.CustomFontSize);
                    }
                    if (element.CustomFontFamily == "Avenir65")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "AvenirLTStd-Medium.ttf");
                        Control.Typeface = font;
                    }
                    else if (element.CustomFontFamily == "Avenir45")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "AvenirLTStd-Book.ttf");
                        Control.Typeface = font;
                    }
                    else
                    {
                    }

                    if (element.IsPhoneNumber == true)
                    {
                        Control.SetRawInputType(global::Android.Text.InputTypes.ClassPhone);
                    }
                    else if (element.IsNumeric == true)
                    {
                        Control.SetRawInputType(global::Android.Text.InputTypes.ClassNumber);
                    }
                    else if (element.IsEmail == true)
                    {
                        Control.SetRawInputType(global::Android.Text.InputTypes.TextVariationEmailAddress);
                    }
                    else if (element.IsPassword == true)
                    {
                        Control.SetPadding(30, Control.PaddingTop, Control.PaddingRight, Control.PaddingBottom);
                    }
                    else
                    {
                    }

                    if (element.IsPassword == true)
                    {
                        Control.TransformationMethod = PasswordTransformationMethod.Instance;
                        //Control.InputType = InputTypes.TextVariationPassword;
                        //Control.InputType = InputTypes.TextVariationPassword | InputTypes.ClassText;
                    }
                    else
                    {
                        Control.TransformationMethod = HideReturnsTransformationMethod.Instance; //PasswordTransformationMethod.Instance;
                    }
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
        }
        protected void UpdateElementWithChanges()
        {
            try
            {
                if (element != null)
                {
                    if (Control != null)
                    {
                        //var element = Element as CustomEntry;

                        GradientDrawable gradientDrawable = new GradientDrawable();
                        gradientDrawable.SetColor(global::Android.Graphics.Color.Transparent);
                        if (element.BorderColor != null)
                        {
                            //gradientDrawable.SetStroke(2, global::Android.Graphics.Color.ParseColor(element.BorderColor));
                            gradientDrawable.SetStroke(2, element.BorderColor.ToAndroid());
                        }
                        //gradientDrawable.SetCornerRadius(45); // increase or decrease to changes the corner look
                        this.Control.SetBackgroundDrawable(gradientDrawable);
                        this.Control.SetRawInputType(InputTypes.TextFlagNoSuggestions);
                        //Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.Black));//for placeholder
                        //this.Control.InputType = InputTypes.TextVariationPassword;
                        Control.Gravity = global::Android.Views.GravityFlags.CenterVertical;
                        Control.SetPadding(30, 0, 30, 0);

                        //Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.Black));//for placeholder

                        /*
                         * try
                         * {
                         *  if (element.CustomFontSize != 0.0)
                         *  {
                         *      Control.SetTextSize(ComplexUnitType.Dip, element.CustomFontSize);
                         *  }
                         *  if (element.FontSize != 0)
                         *  {
                         *      Control.SetTextSize(ComplexUnitType.Dip, (float)element.FontSize);
                         *  }
                         * }
                         * catch (Exception ex)
                         * {
                         *  var msg = ex.Message;
                         * }
                         */
                        if (element.CustomFontSize != 0.0)
                        {
                            Control.SetTextSize(ComplexUnitType.Dip, element.CustomFontSize);
                        }

                        if (!(string.IsNullOrEmpty(element.CustomFontFamily)))
                        {
                            try
                            {
                                Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, element.CustomFontFamily);
                                Control.Typeface = font;
                            }
                            catch (Exception ex)
                            {
                                var msg = ex.Message + "\n" + ex.StackTrace;
                                System.Diagnostics.Debug.WriteLine(msg);
                            }
                        }
                        else
                        {
                        }

                        if (element.IsPhoneNumber == true)
                        {
                            Control.SetRawInputType(global::Android.Text.InputTypes.ClassPhone);
                        }
                        else if (element.IsNumeric == true)
                        {
                            Control.SetRawInputType(global::Android.Text.InputTypes.ClassNumber);
                        }
                        else if (element.IsEmail == true)
                        {
                            Control.SetRawInputType(global::Android.Text.InputTypes.TextVariationEmailAddress);
                        }
                        else if (element.IsPassword == true)
                        {
                            Control.SetPadding(30, Control.PaddingTop, Control.PaddingRight, Control.PaddingBottom);
                        }
                        else
                        {
                        }

                        if (element.IsPassword == true)
                        {
                            Control.TransformationMethod = PasswordTransformationMethod.Instance;
                            //Control.InputType = InputTypes.TextVariationPassword;
                            //Control.InputType = InputTypes.TextVariationPassword | InputTypes.ClassText;
                        }
                        else
                        {
                            Control.TransformationMethod = HideReturnsTransformationMethod.Instance; //PasswordTransformationMethod.Instance;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message + "\n" + ex.StackTrace;
                System.Diagnostics.Debug.WriteLine(msg);
            }
        }
示例#45
0
        protected override void OnElementChanged(ElementChangedEventArgs <Label> e)
        {
            base.OnElementChanged(e);

            try
            {
                CustomLabel element;// = Element as CustomLabel;
                if (e.NewElement != null)
                {
                    element = Element as CustomLabel;
                }
                else
                {
                    element = e.OldElement as CustomLabel;
                }

                if (Control != null)
                {
                    var label = (TextView)Control;


                    if (!string.IsNullOrWhiteSpace(element.CustomFontColor))
                    {
                        //Control.SetTextColor(Graphicss.Color.ParseColor(element.CustomFontColor));
                        label.SetTextColor(Graphicss.Color.ParseColor(element.CustomFontColor));
                    }



                    // to under line a label
                    if (element.ShallUnderLine == true)
                    {
                        int charLength = 0;
                        //var label = (TextView)Control;
                        var text = element.Text;
                        if (element.NoOfChar == 0 && element.EndIndex == 0)
                        {
                            charLength = text.Length;
                        }
                        else if (element.EndIndex != 0 && element.NoOfChar != 0)
                        {
                            charLength = element.NoOfChar;
                        }
                        else if (element.EndIndex == 0)
                        {
                            charLength = element.NoOfChar;
                        }
                        else if (element.NoOfChar == 0)
                        {
                            charLength = element.EndIndex - element.StartIndex;
                        }
                        else
                        {
                            charLength = text.Length;
                        }
                        var string1 = element.Text.Substring(0, element.StartIndex);
                        if (string1 == "<")
                        {
                            string1 = "&lt;";
                        }
                        else
                        {
                        }
                        var string2 = element.Text.Substring(element.StartIndex, charLength);
                        var string3 = element.Text.Substring(element.StartIndex + charLength, (element.Text.Length - (element.StartIndex + charLength)));

                        string finalText = "";
                        if (element.ShallMoveTop == true)
                        {
                            finalText = "<center><p valign=\"center\">" + string1 + "<u>" + string2 + "</u>" + string3 + "</p></center>";
                            label.LayoutParameters = new LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);
                            label.Gravity          = global::Android.Views.GravityFlags.Left;
                        }
                        else
                        {
                            finalText = "<table><tr><td>" + string1 + "<u>" + string2 + "</u>" + string3 + "</td></tr></table>";
                            label.LayoutParameters = new LayoutParams(LayoutParams.MatchParent, LayoutParams.MatchParent);
                            label.Gravity          = global::Android.Views.GravityFlags.Center | global::Android.Views.GravityFlags.Left;
                        }
#pragma warning disable CS0618 // Type or member is obsolete
                        label.TextFormatted = Html.FromHtml(finalText);
#pragma warning restore CS0618 // Type or member is obsolete
                    }
                    else if (element.ShallUnderLine == true && element.ShallUseHTMLOnly == false)
                    {
                    }
                    else
                    {
                    }



                    //for font family
                    if (element.FontFamily == "Avenir65")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "AvenirLTStd-Medium.ttf");
                        label.Typeface = font;
                        //Control.Typeface = font;
                    }
                    else if (element.FontFamily == "Avenir45")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "AvenirLTStd-Book.ttf");
                        label.Typeface = font;
                        //Control.Typeface = font;
                    }
                    else
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
        }
示例#46
0
        protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);
            try
            {
                CustomEntry element = Element as CustomEntry;

                if (element.IsCustomPassword == true)
                {
                    Control.TransformationMethod = PasswordTransformationMethod.Instance;

                    //Control.InputType = InputTypes.TextVariationPassword;
                    //Control.InputType = InputTypes.TextVariationPassword | InputTypes.ClassText;
                }
                else
                {
                    Control.TransformationMethod = HideReturnsTransformationMethod.Instance; //PasswordTransformationMethod.Instance;
                }
                if (Control != null)
                {
                    //var element = Element as CustomEntry;

                    GradientDrawable gd = new GradientDrawable();
                    //gd.SetCornerRadius(45); // increase or decrease to changes the corner look
                    gd.SetColor(global::Android.Graphics.Color.Transparent);
                    //global::Android.Graphics.Color color = ColorExtensions.ToAndroid(element.BorderColors);
                    //var color = global::Android.Graphics.Color.ParseColor(element.BorderColors);
                    //gd.SetStroke(2, color);
                    gd.SetStroke(2, global::Android.Graphics.Color.ParseColor(element.BorderColors));
                    //gd.SetStroke(2, global::Android.Graphics.Color.Gray);
                    this.Control.SetBackgroundDrawable(gd);
                    this.Control.SetRawInputType(InputTypes.TextFlagNoSuggestions);
                    //Control.SetHintTextColor(ColorStateList.ValueOf(global::Android.Graphics.Color.Black));//for placeholder
                    //this.Control.InputType = InputTypes.TextVariationPassword;
                    if (element.CustomFontSize != 0.0)
                    {
                        Control.SetTextSize(ComplexUnitType.Dip, element.CustomFontSize);
                    }
                    if (element.CustomFontFamily == "Avenir65")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "AvenirLTStd-Medium.ttf");
                        Control.Typeface = font;
                    }
                    else if (element.CustomFontFamily == "Avenir45")
                    {
                        Graphicss.Typeface font = Graphicss.Typeface.CreateFromAsset(Forms.Context.Assets, "AvenirLTStd-Book.ttf");
                        Control.Typeface = font;
                    }
                    else
                    {
                    }

                    if (element.IsPhoneNumber == true)
                    {
                        Control.SetRawInputType(global::Android.Text.InputTypes.ClassPhone);
                    }
                    else if (element.IsNumeric == true)
                    {
                        Control.SetRawInputType(global::Android.Text.InputTypes.ClassNumber);
                    }
                    else if (element.IsEmail == true)
                    {
                        Control.SetRawInputType(global::Android.Text.InputTypes.TextVariationEmailAddress);
                    }
                    else
                    {
                    }
                }
            }
            catch (Exception ex)
            {
                var msg = ex.Message;
            }
        }
 private void ApplyCustomTypeFace(Paint paint, Typeface tf)
 {
     paint.FakeBoldText = false;
     paint.TextSkewX = 0f;
     paint.SetTypeface(tf);
     if (rotate) paint.ClearShadowLayer();
     if (iconSizeRatio > 0) paint.TextSize = paint.TextSize * iconSizeRatio;
     else if (iconSizePx > 0) paint.TextSize = iconSizePx;
     if (iconColor < int.MaxValue) paint.Color = new Color(iconColor);
 }
示例#48
0
        public bool TryGetValueTypeless(object key, out object value)
        {
            bool found;

            if (key == DecorKeyConnector.Typeface)
            {
                Graphics.Typeface typefaceFamily;
                if (this.TryGetValue(DecorKeyConnector.TypefaceFamily, out typefaceFamily))
                {
                    Graphics.TypefaceStyle typefaceStyle = this.GetValueOrDefault(DecorKeyConnector.TypefaceStyle);
                    Graphics.Typeface      typeface      = Graphics.Typeface.Create(typefaceFamily, typefaceStyle);
                    value = typeface;
                    return(true);
                }
                else
                {
                    value = null;
                    return(false);
                }
            }
            else if (key == DecorKeyConnector.TypefaceFamily)
            {
                value = decoration.GetValueConnectedTry(DecorationKey.FontFamily, TransformFontFamilyToTypefaceFamily, out found);
            }

            else if (key == DecorKeyConnector.TypefaceStyle)
            {
                Graphics.TypefaceStyle fontStyle;
                bool foundStyle = decoration.TryGetValueConnected(DecorationKey.FontStyle, TransformFontStyle, out fontStyle);

                Graphics.TypefaceStyle fontWeight;
                bool foundWeight = decoration.TryGetValueConnected(DecorationKey.FontWeight, TransformFontWeight, out fontWeight);

                found = foundStyle | foundWeight;
                value = fontStyle | fontWeight;

                value = decoration.GetValueConnectedTry(DecorationKey.FontFamily, TransformFontFamilyToTypefaceFamily, out found);
            }

            else if (key == DecorKeyConnector.FontSize)
            {
                value = decoration.GetValueConnectedTry(DecorationKey.FontSize, DecorationExtensions.IdentityTransformation, out found);
            }

            else if (key == DecorKeyConnector.FontSizeRelativePercent)
            {
                value = decoration.GetValueConnectedTry(DecorationKey.FontSizeRelativePercent, DecorationExtensions.IdentityTransformation, out found);
            }

            else if (key == DecorKeyConnector.Foreground)
            {
                value = decoration.GetValueConnectedTry(DecorationKey.Foreground, TransformColor, out found);
            }

            else if (key == DecorKeyConnector.Background)
            {
                value = decoration.GetValueConnectedTry(DecorationKey.Background, TransformColor, out found);
            }

            else
            {
                found = false;
                value = null;
            }

            return(found);
        }