protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (Control != null) { DisableNativeBorder(); } if (Element != null) { UpdatePadding(); if (e.NewElement != null) { _element = e.NewElement as EntryExtended; SetupLayer((int)_element.BorderWidth, _element.BorderRadius); } } if (e.OldElement != null) { // Unsubscribe from event handlers and cleanup any resources } if (e.NewElement != null) { // Configure the control and subscribe to event handlers } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); try { if (Element == null) { return; } EntryExtended entryEx = Element as EntryExtended; if (e.PropertyName == EntryExtended.BorderWidthProperty.PropertyName || e.PropertyName == EntryExtended.BorderColorProperty.PropertyName || e.PropertyName == EntryExtended.BorderRadiusProperty.PropertyName || e.PropertyName == EntryExtended.BackgroundColorProperty.PropertyName) { UpdateBackground(entryEx); } else if (e.PropertyName == EntryExtended.LeftPaddingProperty.PropertyName || e.PropertyName == EntryExtended.RightPaddingProperty.PropertyName) { UpdatePadding(entryEx); } else if (e.PropertyName == Entry.HorizontalTextAlignmentProperty.PropertyName) { UpdateTextAlighnment(entryEx); } } catch (Exception ex) { Crashes.TrackError(ex); Debugger.Break(); } }
private void UpdateTextAlighnment(EntryExtended entryEx) { try { GravityFlags gravity = DefaultGravity; switch (entryEx.HorizontalTextAlignment) { case Xamarin.Forms.TextAlignment.Start: gravity |= GravityFlags.Start; break; case Xamarin.Forms.TextAlignment.Center: gravity |= GravityFlags.CenterHorizontal; break; case Xamarin.Forms.TextAlignment.End: gravity |= GravityFlags.End; break; } Control.Gravity = gravity; } catch (Exception ex) { Debugger.Break(); System.Diagnostics.Debug.WriteLine($"ERROR: {ex.Message}"); } }
void UpdateTextAlighnment(EntryExtended entryEx) { try { GravityFlags gravity = DefaultGravity; switch (entryEx.HorizontalTextAlignment) { case Xamarin.Forms.TextAlignment.Start: gravity |= GravityFlags.Start; break; case Xamarin.Forms.TextAlignment.Center: gravity |= GravityFlags.CenterHorizontal; break; case Xamarin.Forms.TextAlignment.End: gravity |= GravityFlags.End; break; } Control.Gravity = gravity; } catch (Exception ex) { Crashes.TrackError(ex); Debugger.Break(); } }
void UpdatePadding(EntryExtended entryEx) { try { Control.SetPadding((int)Context.ToPixels(entryEx.LeftPadding), 0, (int)Context.ToPixels(entryEx.RightPadding), 0); } catch (Exception ex) { Crashes.TrackError(ex); Debugger.Break(); System.Diagnostics.Debug.WriteLine($"ERROR: {ex.Message}"); } }
private void UpdateBackground(EntryExtended entryEx) { if (_renderer != null) { _renderer.Dispose(); _renderer = null; } _renderer = new BorderRenderer(); Control.Background = _renderer.GetBorderBackground(entryEx.BorderColor, entryEx.BackgroundColor, entryEx.BorderWidth, entryEx.BorderRadius); }
private void UpdateBackground(EntryExtended entryEx) { if (_renderer != null) { _renderer.Dispose(); _renderer = null; } _renderer = new BorderRenderer(); Control.Background = _renderer.GetBorderBackground(entryEx.BorderColor, entryEx.BackgroundColor, entryEx.BorderWidth, entryEx.BorderRadius); //Control.Background = new Android.Graphics.Drawables.ColorDrawable(BaseSingleton<ValuesResolver>.Instance.ResolveNativeColor(entryEx.BackgroundColor)); //Control.Background.SetColorFilter(BaseSingleton<ValuesResolver>.Instance.ResolveNativeColor(entryEx.BackgroundColor), PorterDuff.Mode.SrcAtop); //Control.Background.SetColorFilter(Android.Graphics.Color.ParseColor("#fefefe"), PorterDuff.Mode.SrcAtop); }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e.OldElement != null || this.Element == null) { return; } Control.Gravity = DefaultGravity; EntryExtended entryExtended = Element as EntryExtended; UpdateBackground(entryExtended); UpdatePadding(entryExtended); UpdateTextAlighnment(entryExtended); }
private void UpdateLetterSpacing(EntryExtended entryEx) { try { if (entryEx == null) { return; } Control.LetterSpacing = ((EntryExtended)Element).LetterSpacing; } catch (Exception ex) { Debugger.Break(); System.Diagnostics.Debug.WriteLine($"ERROR: {ex.Message}"); } }
void UpdateBackground(EntryExtended entryEx) { try { _renderer = new BorderRenderer(); Control.Background = _renderer.GetBorderBackground(entryEx.BorderColor, entryEx.BackgroundColor, entryEx.BorderWidth, entryEx.BorderRadius); } catch (Exception ex) { Crashes.TrackError(ex); Debugger.Break(); } if (_renderer != null) { _renderer.Dispose(); _renderer = null; } }
protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); try { if (Element == null) { return; } EntryExtended entryEx = Element as EntryExtended; if (e.PropertyName == EntryExtended.BorderWidthProperty.PropertyName || e.PropertyName == EntryExtended.BorderColorProperty.PropertyName || e.PropertyName == EntryExtended.BorderRadiusProperty.PropertyName || e.PropertyName == EntryExtended.BackgroundColorProperty.PropertyName) { UpdateBackground(entryEx); } else if (e.PropertyName == EntryExtended.LeftPaddingProperty.PropertyName || e.PropertyName == EntryExtended.RightPaddingProperty.PropertyName) { UpdatePadding(entryEx); } else if (e.PropertyName == Entry.HorizontalTextAlignmentProperty.PropertyName) { UpdateTextAlighnment(entryEx); } else if (e.PropertyName == Entry.TextProperty.PropertyName) { UpdateLetterSpacing(entryEx); if (string.IsNullOrEmpty(entryEx.Text)) { UpdateLetterSpacingPlaceholder(entryEx); } } else if (e.PropertyName == EntryExtended.LetterSpacingPlaceholderProperty.PropertyName) { UpdateLetterSpacingPlaceholder(entryEx); } } catch (Exception ex) { Debugger.Break(); System.Diagnostics.Debug.WriteLine($"ERROR: {ex.Message}"); } }
private void UpdateTextAlighnment(EntryExtended entryEx) { var gravity = DefaultGravity; switch (entryEx.HorizontalTextAlignment) { case Xamarin.Forms.TextAlignment.Start: gravity |= GravityFlags.Start; break; case Xamarin.Forms.TextAlignment.Center: gravity |= GravityFlags.CenterHorizontal; break; case Xamarin.Forms.TextAlignment.End: gravity |= GravityFlags.End; break; } Control.Gravity = gravity; }
private void UpdateBackground(EntryExtended entryEx) { try { _renderer = new BorderRenderer(); Control.Background = _renderer.GetBorderBackground(entryEx.BorderColor, entryEx.BackgroundColor, entryEx.BorderWidth, entryEx.BorderRadius); } catch (Exception ex) { Debugger.Break(); System.Diagnostics.Debug.WriteLine($"ERROR: {ex.Message}"); } if (_renderer != null) { _renderer.Dispose(); _renderer = null; } //Control.Background = new Android.Graphics.Drawables.ColorDrawable(BaseSingleton<ValuesResolver>.Instance.ResolveNativeColor(entryEx.BackgroundColor)); //Control.Background.SetColorFilter(BaseSingleton<ValuesResolver>.Instance.ResolveNativeColor(entryEx.BackgroundColor), PorterDuff.Mode.SrcAtop); //Control.Background.SetColorFilter(Android.Graphics.Color.ParseColor("#fefefe"), PorterDuff.Mode.SrcAtop); }
private void UpdatePadding(EntryExtended entryEx) { Control.SetPadding((int)Context.ToPixels(entryEx.LeftPadding), 0, (int)Context.ToPixels(entryEx.RightPadding), 0); }