void SetBackground(MvvmAspire.Controls.Editor element) { 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.SetBackgroundDrawable(originalBackground); } } } else { if (!hasSetOriginal) { Control.SetBackgroundDrawable(originalBackground); } } }
void SetTypeface(MvvmAspire.Controls.Editor element) { if (!string.IsNullOrEmpty(element.FontFamily)) { Control.Typeface = FontCache.GetTypeFace(element.FontFamily); } }
void AddPlaceHolder(MvvmAspire.Controls.Editor element) { Control.ShouldBeginEditing = ((textView) => { if (Control.Tag == 0) { Control.Text = string.Empty; Control.TextColor = element.TextColor.ToUIColor(); Control.Tag = 1; } return(true); }); Control.ShouldEndEditing = ((textView) => { if (Control.Text.Length == 0) { Control.Text = element.Placeholder; Control.TextColor = element.PlaceHolderColor.ToUIColor(); Control.Tag = 0; } return(true); }); if (Control.Text.Length == 0) { Control.Text = element.Placeholder; Control.TextColor = element.PlaceHolderColor.ToUIColor(); Control.Tag = 0; } }
void SetAccesibilityLabel(MvvmAspire.Controls.Editor element) { if (UIAccessibility.IsVoiceOverRunning) { if (element.Placeholder != null && element.Placeholder.ToLower().Contains("optional")) { if (Control.Text != string.Empty) { Control.AccessibilityLabel = element.Placeholder; } else { Control.AccessibilityLabel = ""; } } else { if (element.Placeholder != null && Control.Text != string.Empty) { Control.AccessibilityLabel = string.Concat("required, ", element.Placeholder); } else { Control.AccessibilityLabel = "required, "; } } } }
void SetIsReadOnly(MvvmAspire.Controls.Editor element) { if (element.IsReadOnly) { base.Control.KeyListener = null; } else { base.Control.KeyListener = DefaultKeyListener; } }
void HideSoftKeyBoardOnTextChanged(MvvmAspire.Controls.Editor element) { if (element.IsFocused && BaseElement.SuppressKeyboard) { UIHelper.CloseSoftKeyboard(Control); } //if (string.IsNullOrWhiteSpace(Element.Text)) // Control.Text = ""; //else // Control.Text = element.Text; }
void SetTextAlignment(MvvmAspire.Controls.Editor element) { switch (element.TextAlignment) { case MvvmAspire.TextAlignment.Justified: case MvvmAspire.TextAlignment.Left: Control.Gravity = GravityFlags.AxisPullBefore | GravityFlags.AxisSpecified | GravityFlags.Top | GravityFlags.RelativeLayoutDirection; break; case MvvmAspire.TextAlignment.Center: Control.Gravity = GravityFlags.CenterHorizontal | GravityFlags.Top; break; case MvvmAspire.TextAlignment.Right: Control.Gravity = GravityFlags.Top | GravityFlags.Right; break; } }
void SetFont(MvvmAspire.Controls.Editor 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 SetInputAccessory(MvvmAspire.Controls.Editor element) { UIToolbar toolbar = new UIToolbar(new RectangleF(0.0f, 0.0f, 50.0f, 44.0f)); toolbar.BackgroundColor = element.InputAccessoryBackgroundColor.ToUIColor(); var doneButton = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate { this.Control.ResignFirstResponder(); }); toolbar.Items = new UIBarButtonItem[] { new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace), doneButton }; this.Control.InputAccessoryView = toolbar; }
void SetTextAlignment(MvvmAspire.Controls.Editor element) { if (element.TextAlignment == TextAlignment.Left) { Control.TextAlignment = UITextAlignment.Left; } else if (element.TextAlignment == TextAlignment.Center) { Control.TextAlignment = UITextAlignment.Center; } else if (element.TextAlignment == TextAlignment.Right) { Control.TextAlignment = UITextAlignment.Right; } else if (element.TextAlignment == TextAlignment.Justified) { Control.TextAlignment = UITextAlignment.Justified; } }
void SetTextSize(MvvmAspire.Controls.Editor element) { Control.TextSize = (float)element.FontSize; }
void SetShowSoftInputOnFocus(MvvmAspire.Controls.Editor element) { Control.ShowSoftInputOnFocus = !BaseElement.SuppressKeyboard; }
void SetTextColor(MvvmAspire.Controls.Editor element) { Control.TextColor = element.TextColor.ToUIColor(UIColor.White); }
void SetReadOnly(MvvmAspire.Controls.Editor element) { Control.Editable = !element.IsReadOnly; }
void SetMaxCharacter(MvvmAspire.Controls.Editor element) { Control.ShouldChangeText += ShouldLimit; }