/// <summary> /// Sets the color of the placeholder text. /// </summary> /// <param name="view">The view.</param> private void SetPlaceholderTextColor(ImprovedEntry view) { if (view.PlaceholderTextColor != Color.Default) { Control.SetHintTextColor(view.PlaceholderTextColor.ToAndroid()); } }
/// <summary> /// Sets the font. /// </summary> /// <param name="view">The view.</param> private void SetFont(ImprovedEntry view) { if (view.Font != Font.Default) { Control.TextSize = view.Font.ToScaledPixel(); Control.Typeface = view.Font.ToExtendedTypeface(Context); } }
private void NotifyTextPosition() { int iSelectionStart = Control.SelectionStart; int iSelectionEnd = Control.SelectionEnd; ImprovedEntry improvedEntry = Element as ImprovedEntry; if (improvedEntry != null) { improvedEntry.TextPosition = iSelectionStart; } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); if (e.PropertyName == ImprovedEntry.TextPositionProperty.PropertyName) { ImprovedEntry improvedEntry = Element as ImprovedEntry; if ((improvedEntry != null) && (improvedEntry.TextPosition != null)) { int iTextPosition = improvedEntry.TextPosition ?? 0; if (iTextPosition > Control.Text.Length) { iTextPosition = Control.Text.Length; } else if (iTextPosition < 0) { iTextPosition = 0; } if (iTextPosition != Control.SelectionStart) { Control.SetSelection(iTextPosition); } } } if (e.PropertyName == ImprovedEntry.TextToInsertProperty.PropertyName) { ImprovedEntry improvedEntry = Element as ImprovedEntry; if ((improvedEntry != null) && (improvedEntry.TextToInsert?.Length > 0)) { int iSelectionStart = Control.SelectionStart; bool bAtEnd = (iSelectionStart == Control.Text.Length); string sText = Control.Text.Substring(0, iSelectionStart) + improvedEntry.TextToInsert + Control.Text.Substring(iSelectionStart); Control.Text = sText; //if (!bAtEnd) //{ Control.SetSelection(iSelectionStart + improvedEntry.TextToInsert.Length); //} improvedEntry.TextToInsert = null; } } XLabs_OnElementPropertyChanged(sender, e); }
///// <summary> ///// Sets the border. ///// </summary> ///// <param name="view">The view.</param> private void SetBorder(ImprovedEntry view) { if (view.HasBorder == false) { var shape = new ShapeDrawable(new RectShape()); shape.Paint.Alpha = 0; shape.Paint.SetStyle(Paint.Style.Stroke); Control.SetBackgroundDrawable(shape); } else { Control.SetBackground(originalBackground); } }
/// <summary> /// Sets the text alignment. /// </summary> /// <param name="view">The view.</param> private void SetTextAlignment(ImprovedEntry view) { switch (view.XAlign) { case Xamarin.Forms.TextAlignment.Center: Control.Gravity = GravityFlags.CenterHorizontal; break; case Xamarin.Forms.TextAlignment.End: Control.Gravity = GravityFlags.End; break; case Xamarin.Forms.TextAlignment.Start: Control.Gravity = GravityFlags.Start; break; } }
/// <summary> /// Sets the MaxLength characteres. /// </summary> /// <param name="view">The view.</param> private void SetMaxLength(ImprovedEntry view) { Control.SetFilters(new IInputFilter[] { new InputFilterLengthFilter(view.MaxLength) }); }