//void Control_Touch(object sender, Android.Views.View.TouchEventArgs e) //{ // Control.Focusable = true; // Control.RequestFocus(); // Control.RequestFocusFromTouch(); // Control.SetSelection(Control.Text.Length); // InputMethodManager inputMethodManager = this.Context.GetSystemService(Context.InputMethodService) as InputMethodManager; // inputMethodManager.ShowSoftInput(Control, ShowFlags.Forced); // inputMethodManager.ToggleSoftInput(ShowFlags.Forced, HideSoftInputFlags.ImplicitOnly); //} //override appl void HideSoftKeyBoardOnTextChanged(MvvmAspire.Controls.Entry element) { if (element.IsFocused && BaseElement.SuppressKeyboard) { UIHelper.CloseSoftKeyboard(Control); } }
void SetTypeface(MvvmAspire.Controls.Entry element) { if (!string.IsNullOrEmpty(element.FontFamily)) { Control.Typeface = FontCache.GetTypeFace(element.FontFamily); } }
void SetGravity(MvvmAspire.Controls.Entry element) { if (element.IsRightToLeft) { base.Control.TextDirection = TextDirection.Rtl; } }
void SetIsRightToLeft(MvvmAspire.Controls.Entry element) { if (element.IsRightToLeft) { Control.TextAlignment = UITextAlignment.Right; } }
private void SetDisabledTextColor(MvvmAspire.Controls.Entry element) { Control.TextColor = element.DisabledTextColor.ToUIColor(); Control.AttributedPlaceholder = new NSAttributedString(element.Placeholder, new UIStringAttributes { ForegroundColor = element.DisabledTextColor.ToUIColor() }); }
void SetAccesibilityFocus(MvvmAspire.Controls.Entry element) { if (UIAccessibility.IsVoiceOverRunning && element.AccesibilitySetFocus) { UIAccessibility.PostNotification(UIAccessibilityPostNotification.ScreenChanged, Control); element.AccesibilitySetFocus = false; } }
void SetIsReadOnly(MvvmAspire.Controls.Entry element) { if (element.IsReadOnly) { base.Control.KeyListener = null; element.SuppressKeyboard = true; Control.ShowSoftInputOnFocus = false; } else { base.Control.KeyListener = DefaultKeyListener; } }
void SetAccesibilityLabel(MvvmAspire.Controls.Entry element) { if (UIAccessibility.IsVoiceOverRunning) { if (Control.Placeholder != null && Control.Text != string.Empty && !element.AccesibilityIgnoreNameWhenNotEmpty) { Control.AccessibilityLabel = string.Concat("required, ", Control.Placeholder); } else { Control.AccessibilityLabel = "required, "; } } }
void SetFont(MvvmAspire.Controls.Entry element) { //if (Control.Font == null // || Control.Font.FamilyName != element.FontFamily // || Control.Font.PointSize != (nfloat)element.FontSize) { // Control.Font = UIFont.FromName (element.FontFamily, (nfloat)element.FontSize); //} if (Control.Font == null || Control.Font.PointSize != (nfloat)element.FontSize) { Control.Font = UIFont.FromName(Control.Font.FamilyName, (nfloat)element.FontSize); } }
void SetIsReadOnly(MvvmAspire.Controls.Entry element) { if (UIAccessibility.IsVoiceOverRunning) { Control.UserInteractionEnabled = !element.IsReadOnly; if (element.IsReadOnly) { Control.AccessibilityTraits = UIAccessibilityTrait.StaticText; } else { Control.AccessibilityTraits = UIAccessibilityTrait.None; } } else { Control.Enabled = !element.IsReadOnly; } }
void SetTextInputTypes(MvvmAspire.Controls.Entry element) { switch (element.TextInputType) { case TextInputType.Normal: Control.InputType = InputTypes.TextVariationNormal; Control.InputType = InputTypes.TextFlagNoSuggestions; break; case TextInputType.EmailAddress: Control.InputType = InputTypes.ClassText | InputTypes.TextVariationEmailAddress; break; case TextInputType.Password: Control.InputType = InputTypes.TextVariationPassword; break; case TextInputType.Phone: Control.InputType = InputTypes.ClassPhone; break; case TextInputType.Number: Control.InputType = InputTypes.ClassNumber; break; case TextInputType.PersonName: Control.InputType = InputTypes.TextVariationPersonName | InputTypes.TextFlagCapSentences; break; case TextInputType.Decimal: Control.InputType = InputTypes.NumberFlagDecimal; break; } }
void SetReturnKeyType(MvvmAspire.Controls.Entry element) { if (element.ReturnKeyType == ReturnKeyType.Automatic) { if (element.NextElement != null) { Control.ReturnKeyType = UIReturnKeyType.Next; } else if (element.Command != null) { Control.ReturnKeyType = UIReturnKeyType.Done; } } else if (element.ReturnKeyType == ReturnKeyType.Default) { Control.ReturnKeyType = UIReturnKeyType.Default; } else if (element.ReturnKeyType == ReturnKeyType.Go) { Control.ReturnKeyType = UIReturnKeyType.Go; } else if (element.ReturnKeyType == ReturnKeyType.Search) { Control.ReturnKeyType = UIReturnKeyType.Search; } else if (element.ReturnKeyType == ReturnKeyType.Next) { Control.ReturnKeyType = UIReturnKeyType.Next; } else if (element.ReturnKeyType == ReturnKeyType.Done) { Control.ReturnKeyType = UIReturnKeyType.Done; } else if (element.ReturnKeyType == ReturnKeyType.Search) { Control.ReturnKeyType = UIReturnKeyType.Search; } else if (element.ReturnKeyType == ReturnKeyType.Send) { Control.ReturnKeyType = UIReturnKeyType.Send; } }
void SetBackground(MvvmAspire.Controls.Entry element) { if (Control == null) { return; } bool hasSetOriginal = false; if (originalBackground == null) { originalBackground = Control.Background; hasSetOriginal = true; } if (element.BackgroundImage != null) { var resourceId = UIHelper.GetDrawableResource(element.BackgroundImage); if (resourceId > 0) { Control.SetBackgroundResource(resourceId); } else { if (!hasSetOriginal) { Control.Background = originalBackground; } } } else { if (!hasSetOriginal) { Control.Background = originalBackground; } } }
void SetTextColor(MvvmAspire.Controls.Entry element) { Control.TextColor = element.TextColor.ToUIColor(UIColor.DarkTextColor); }
void SetImages(MvvmAspire.Controls.Entry element) { int leftResourceId = 0, topResourceId = 0, rightResourceId = 0, bottomResourceId = 0; if (element.ImageLeft != null && element.ImageLeft.File != null) { leftResourceId = UIHelper.GetDrawableResource(element.ImageLeft); } if (element.ImageTop != null && element.ImageTop.File != null) { topResourceId = UIHelper.GetDrawableResource(element.ImageTop); } if (element.ImageRight != null && element.ImageRight.File != null) { rightResourceId = UIHelper.GetDrawableResource(element.ImageRight); } if (element.ImageBottom != null && element.ImageBottom.File != null) { bottomResourceId = UIHelper.GetDrawableResource(element.ImageBottom); } bool hasResource = leftResourceId > 0 || rightResourceId > 0 || topResourceId > 0 || bottomResourceId > 0; if (hasCompoundDrawable || hasResource) { hasCompoundDrawable = true; //Android.Graphics.Drawables.Drawable leftDrawable = leftResourceId > 0 ? Resources.GetDrawable(leftResourceId) : null; //if (leftDrawable != null) // leftDrawable.SetBounds(0, 0, leftDrawable.IntrinsicWidth, leftDrawable.IntrinsicHeight); //Android.Graphics.Drawables.Drawable topDrawable = topResourceId > 0 ? Resources.GetDrawable(topResourceId) : null; //if (topDrawable != null) // topDrawable.SetBounds(0, 0, topDrawable.IntrinsicWidth, topDrawable.IntrinsicHeight); //Android.Graphics.Drawables.Drawable rightDrawable = rightResourceId > 0 ? Resources.GetDrawable(rightResourceId) : null; //if (rightDrawable != null) // rightDrawable.SetBounds(0, 0, rightDrawable.IntrinsicWidth, rightDrawable.IntrinsicHeight); //Android.Graphics.Drawables.Drawable bottomDrawable = bottomResourceId > 0 ? Resources.GetDrawable(bottomResourceId) : null; //if (bottomDrawable != null) // bottomDrawable.SetBounds(0, 0, bottomDrawable.IntrinsicWidth, bottomDrawable.IntrinsicHeight); //Control.SetCompoundDrawablesRelative(leftDrawable, topDrawable, rightDrawable, bottomDrawable); //Control.SetCompoundDrawables(leftDrawable, topDrawable, rightDrawable, bottomDrawable); var leftDrawable = (leftResourceId > 0) ? Resources.GetDrawable(leftResourceId) : null; if (leftDrawable != null) { if (element.ImageLeftWidth > 0) { leftDrawable = ResizeImage(leftDrawable, BaseUIHelper.ConvertDPToPixels(element.ImageLeftWidth), BaseUIHelper.ConvertDPToPixels(element.ImageLeftWidth)); } else { Resources.GetDrawable(leftResourceId); } } var topDrawable = (topResourceId > 0) ? Resources.GetDrawable(topResourceId) : null; var rightDrawable = (rightResourceId > 0) ? Resources.GetDrawable(rightResourceId) : null; var bottomDrawable = (bottomResourceId > 0) ? Resources.GetDrawable(bottomResourceId) : null; //Control.SetCompoundDrawablesRelativeWithIntrinsicBounds(leftDrawable, topResourceId, rightResourceId, bottomResourceId); Control.SetCompoundDrawablesRelativeWithIntrinsicBounds(leftDrawable, topDrawable, rightDrawable, bottomDrawable); Control.CompoundDrawablePadding = 20; if (!hasResource) { hasCompoundDrawable = false; } } if (element.ImageCenter != null) { Control.SetCompoundDrawablesRelativeWithIntrinsicBounds(base.Resources.GetDrawable(UIHelper.GetDrawableResource(element.ImageCenter)), null, null, null); Control.Gravity = GravityFlags.Center; } }
void SetShowSoftInputOnFocus(MvvmAspire.Controls.Entry element) { Control.ShowSoftInputOnFocus = !BaseElement.SuppressKeyboard; }
void SetTextSize(MvvmAspire.Controls.Entry element) { Control.TextSize = (float)element.FontSize; }
void SetHintColor(MvvmAspire.Controls.Entry element) { //base.Control.SetHintTextColor(element.HintColor.ToAndroid ()); }