private async void TapGestureRecognizer_OnTapped(object sender, EventArgs e) { await Task.Delay(300); var imageSender = (CachedImage)sender; if (imageSender.ClassId == "plus") { NumberOfPlayers++; var ent = new MyEntry { Placeholder = "Player" + NumberOfPlayers, TextColor = Color.LightCyan, PlaceholderColor = Color.LightCyan }; ent.TextChanged += Ent_TextChanged; StkContent.Children.Add(ent); } else { if (NumberOfPlayers <= 2) { return; } StkContent.Children.RemoveAt(NumberOfPlayers - 1); NumberOfPlayers--; } }
public MainPage() { var editTextUsuario = new MyEntry(); editTextUsuario.Text = ""; editTextUsuario.Mask = "XXX.XXX.XXX-XX"; var editTextUsuario2 = new MyEntry(); editTextUsuario2.Text = ""; editTextUsuario2.Mask = "(XX) X XXXX-XXXX"; this.Content = new StackLayout { Children = { new Label { Text = "editTextUsuario" }, editTextUsuario, new Label { Text = "editTextUsuario2" }, editTextUsuario2, } }; }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e.NewElement != null) { myEntry = e.NewElement as MyEntry; } if (Control != null) { EditText textField = (EditText)Control; //textField.Typeface = Android.Graphics.Typeface.Monospace; var color = Android.Graphics.Color.ParseColor(myEntry == null ? "#c8c8c8" : myEntry.PlaceholderColorText); var colorWhite = Android.Graphics.Color.ParseColor("#ffffff"); var colorBlack = Android.Graphics.Color.ParseColor("#000000"); textField.SetHintTextColor(color); //var shape = new ShapeDrawable(new RectShape()); //shape.Paint.Color = colorWhite; //shape.Paint.SetStyle(Paint.Style.FillAndStroke); //textField.Background = shape; GradientDrawable gradientDrawable = new GradientDrawable(); gradientDrawable.SetShape(ShapeType.Rectangle); gradientDrawable.SetColor(colorWhite); gradientDrawable.SetStroke(4, colorBlack); gradientDrawable.SetCornerRadius(10.0f); textField.Background = gradientDrawable; } }
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); element = (MyEntry)this.Element; if (e.PropertyName == MyEntry.BorderColorProperty.PropertyName) { var editText = this.Control; //Control.Background.SetColorFilter(element.CustomBorderColor.ToAndroid(), PorterDuff.Mode.SrcAtop); GetDesign(element.CustomBorderColor.ToAndroid()); if (!string.IsNullOrEmpty(element.ErrorImageName)) { switch (element.ErrorImageAlignment) { case ImageAlignment.Left: editText.SetCompoundDrawablesWithIntrinsicBounds(GetDrawable(element.ErrorImageName), null, null, null); break; case ImageAlignment.Right: editText.SetCompoundDrawablesWithIntrinsicBounds(null, null, GetDrawable(element.ErrorImageName), null); break; } } //editText.CompoundDrawablePadding = 25; } if (e.PropertyName == MyEntry.ImageProperty.PropertyName) { if (string.IsNullOrEmpty(element.ImageName)) { //editText.SetCompoundDrawablesWithIntrinsicBounds(GetDrawable(element.ErrorImageName), null, null, null); } } }
void SetFontSize (MyEntry view) { if (view.FontSize != Font.Default.FontSize) Control.Font = UIFont.SystemFontOfSize ((System.nfloat)view.FontSize); else if (view.FontSize == Font.Default.FontSize) Control.Font = UIFont.SystemFontOfSize (17f); }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (this.Element is MyEntry && Control != null) { if (Control == null) { return; } MyEntry myEntry = this.Element as MyEntry; if (myEntry.BackgroundColor != Color.Transparent) { this.Control.SetBackgroundColor(myEntry.CustomBackgroundColor.ToAndroid()); } Control.SetBackgroundResource(Resource.Drawable.RoundedCornerEntry); DisplayMetrics metrics = this.Resources.DisplayMetrics; var left = (int)((myEntry.CustomPadding.Left) * Resources.DisplayMetrics.Density); var top = (int)((myEntry.CustomPadding.Top) * Resources.DisplayMetrics.Density); var right = (int)((myEntry.CustomPadding.Right) * Resources.DisplayMetrics.Density); var bottom = (int)((myEntry.CustomPadding.Bottom) * Resources.DisplayMetrics.Density); Control.SetPadding(left, top, right, bottom); } }
public RecuperarContrasenaViewModel(Page page, ref MyEntry txtUser, ref Button btnRecuperarContrasena, ref MyEntry txtValidacion, ref Button btnCambiarContrasena) : this(page) { this.txtUser = txtUser; this.btnRecuperarContrasena = btnRecuperarContrasena; this.txtValidacion = txtValidacion; this.btnCambiarContrasena = btnCambiarContrasena; }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (this.Element is MyEntry && Control != null) { MyEntry myEntry = this.Element as MyEntry; if (myEntry.BackgroundColor != Color.Transparent) { this.Control.BackgroundColor = myEntry.CustomBackgroundColor.ToUIColor(); } Control.SizeToFit(); Control.VerticalAlignment = UIControlContentVerticalAlignment.Center; Control.BackgroundColor = Color.Transparent.ToUIColor(); Control.BorderStyle = UITextBorderStyle.RoundedRect; if (Control.Layer != null) { Control.Layer.CornerRadius = 0; Control.Layer.BorderColor = Color.Transparent.ToCGColor(); DrawBorder(); } //this.Control.LeftView = new UIView(); //Control.SetBackgroundResource(Resource.Drawable.RoundedCornerEntry); //this.Control.ContentEdgeInsets = new UIKit.UIEdgeInsets((int)myEntry.CustomPadding.Left, (int)myEntry.CustomPadding.Top, (int)myEntry.CustomPadding.Right, (int)myEntry.CustomPadding.Bottom); //Control.SetPadding((int)myEntry.CustomPadding.Left, (int)myEntry.CustomPadding.Top, (int)myEntry.CustomPadding.Right, (int)myEntry.CustomPadding.Bottom); } }
public MaskValidatePage() { var rules = new List <Validation> (); rules.Add(new Validation(Validators.MAX, "10", "Max length is 10")); maxLength = new MyEntry(); maxLength.Text = ""; maxLength.FormatCharacters = "-"; maxLength.ValidationRules = rules; var rules2 = new List <Validation> (); rules2.Add(new Validation(Validators.ONLYCHARS, "[1-9]", "Only enter 1,2,3,4,5,6,7,8,9")); maxOnlyChars = new MyEntry(); maxOnlyChars.Text = ""; maxOnlyChars.FormatCharacters = "-"; maxOnlyChars.ValidationRules = rules2; // validation of a mask. beta. // maskValidation = new MyEntry (); // maskValidation.Text = "Asasd"; // maskValidation.FormatCharacters = "-"; // maskValidation.ValidCharacters = "[A-Za-z]"; // maskValidation.Mask = new System.Collections.Generic.List<MaskRules> ( // new[] { // new MaskRules { // Start = 0, // End = 5, // Mask = "", // startC = "ABC", // startCCase = false, // endC = "bC", // endCase = false // }, // new MaskRules { Start = 5, End = 9, Mask = "{0:5}-{5:}"}, // }); // add event handler. // in production code, make sure you unsubscribe to this event maxLength.OnValidationError += MaxLength_OnValidationError; maxOnlyChars.OnValidationError += MaxLength_OnValidationError; this.Content = new StackLayout { Children = { new Label { Text = "Max Length = 10", TextColor = Device.OnPlatform(Color.Blue, Color.Default, Color.Default) }, maxLength, new Label { Text = "Max Length = 10, Only [1-9]", TextColor = Device.OnPlatform(Color.Blue, Color.Default, Color.Default) }, maxOnlyChars, } }; }
void SetPlaceholderTextColor (MyEntry view) { if (string.IsNullOrEmpty (view.Placeholder) == false && view.PlaceholderColor != Color.Default) { var placeholderString = new NSAttributedString (view.Placeholder, new UIStringAttributes { ForegroundColor = view.PlaceholderColor.ToUIColor () }); Control.AttributedPlaceholder = placeholderString; } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e.NewElement != null) { MyEntry Content = e.NewElement as MyEntry; SetCornerRadius(Content); } }
private void MyEntry_TextChanged(object sender, TextChangedEventArgs e) { if (MyEntry.Text.Length > 0) { Pictogram.Text = MyEntry.Text; MyEntry.Text = ""; MyEntry.Unfocus(); } }
void DrawBorder (MyEntry view) { var borderLayer = new CALayer (); borderLayer.MasksToBounds = true; borderLayer.Frame = new CoreGraphics.CGRect (0f, Frame.Height / 2, Frame.Width, 1f); borderLayer.BorderColor = view.BorderColor.ToCGColor (); borderLayer.BorderWidth = 1.0f; Control.Layer.AddSublayer (borderLayer); Control.BorderStyle = UITextBorderStyle.None; }
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); MyEntry Content = sender as MyEntry; if (e.PropertyName == MyEntry.BorderColorProperty.PropertyName) { SetCornerRadius(Content); } }
private void SetCornerRadius(MyEntry Content) { GradientDrawable gd = new GradientDrawable(); gd.SetColor(Content.BackgroundColor.ToAndroid()); gd.SetCornerRadius(Content.BorderRadius); if (Content.BorderWidth > 0) { gd.SetStroke(Content.BorderWidth, Content.BorderColor.ToAndroid()); } this.Control.SetBackground(gd); }
private void SetFont(MyEntry view) { UIFont uiFont; if (view.Font != Font.Default && (uiFont = view.Font.ToUIFont()) != null) { Control.Font = uiFont; } else if (view.Font == Font.Default) { Control.Font = UIFont.SystemFontOfSize(17f); } }
public KeyValueItemBar() { this.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) }); this.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(2, GridUnitType.Star) }); this.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(40, GridUnitType.Absolute) }); { ETkey = new MyEntry(); ETkey.SetBinding(MyEntry.TextProperty, "Key", BindingMode.TwoWay); this.Children.Add(ETkey, 0, 0); } { ETvalue = new MyEntry(); ETvalue.SetBinding(MyEntry.TextProperty, "Value", BindingMode.TwoWay); this.Children.Add(ETvalue, 1, 0); } { BTNcancel = new MyButton("\u2716");//✖ BTNcancel.Clicked += async delegate { if (this.BindingContext != null) // && await MyLogger.Ask($"Remove this item?\r\nKey: {ETkey.Text}\r\nValue: {ETvalue.Text}")) { await(this.BindingContext as MyControls.BarsListPanel.MyDisposable).OnDisposed(); } }; this.Children.Add(BTNcancel, 2, 0); } System.Threading.SemaphoreSlim semaphoreSlim = new System.Threading.SemaphoreSlim(1, 1); this.Appeared += async(sender) => { this.Opacity = 0; await semaphoreSlim.WaitAsync(); //this.Opacity = 1; await this.FadeTo(1, 500); lock (semaphoreSlim) semaphoreSlim.Release(); }; this.Disappearing = new Func <Task>(async() => { await semaphoreSlim.WaitAsync(); //this.Opacity = 0; await this.FadeTo(0, 500); lock (semaphoreSlim) semaphoreSlim.Release(); }); }
protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { base.OnElementPropertyChanged(sender, e); MyEntry Content = sender as MyEntry; Control.BorderStyle = UITextBorderStyle.None; Control.Layer.BorderWidth = 1; Control.Layer.BorderColor = Content.BackgroundColor.ToCGColor(); if (e.PropertyName == MyEntry.BorderRadiusProperty.PropertyName) { SetCornerRadius(Content); } }
//protected override void OnElementPropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) //{ // base.OnElementPropertyChanged(sender, e); // if (Control == null) return; // TintCustomization(Control, sender as MyEntry); //} private void TintCustomization(UITextField Control, MyEntry customEntry) { if (Control == null) { return; } if (customEntry != null) { UITextField textField = Control; textField.BorderStyle = UITextBorderStyle.None; textField.TintColor = customEntry.MyHandleColor.ToUIColor(); } }
void SetPlaceholderTextColor(MyEntry view) { /* * UIColor *color = [UIColor lightTextColor]; * YOURTEXTFIELD.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"PlaceHolder Text" attributes:@{NSForegroundColorAttributeName: color}]; */ if (string.IsNullOrEmpty(view.Placeholder) == false && view.PlaceholderTextColor != Xamarin.Forms.Color.Default) { NSAttributedString placeholderString = new NSAttributedString(view.Placeholder, new UIStringAttributes() { ForegroundColor = view.PlaceholderTextColor.ToUIColor() }); Control.AttributedPlaceholder = placeholderString; } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (native == null) { source = e.NewElement as MyEntry; native = this.Control as FormsEditText; native.AfterTextChanged += Native_AfterTextChanged; native.KeyPress += Native_KeyPress; native.BeforeTextChanged += Native_BeforeTextChanged; SetNativeControl(native); } }
private void SetTextAlignment(MyEntry view) { switch (view.XAlign) { case TextAlignment.Center: Control.TextAlignment = UITextAlignment.Center; break; case TextAlignment.End: Control.TextAlignment = UITextAlignment.Right; break; case TextAlignment.Start: Control.TextAlignment = UITextAlignment.Left; break; } }
async void ShakeClicked(object sender, EventArgs e) { uint timeout = 50; await MyEntry.TranslateTo(-15, 0, timeout); await MyEntry.TranslateTo(15, 0, timeout); await MyEntry.TranslateTo(-10, 0, timeout); await MyEntry.TranslateTo(10, 0, timeout); await MyEntry.TranslateTo(-5, 0, timeout); await MyEntry.TranslateTo(5, 0, timeout); MyEntry.TranslationX = 0; }
void SetReturnType(MyEntry entry) { var type = entry.ReturnType; switch (type) { case ReturnType.Next: Control.ImeOptions = ImeAction.Next; Control.SetImeActionLabel("Next", ImeAction.Next); break; default: Control.ImeOptions = ImeAction.Done; Control.SetImeActionLabel("Done", ImeAction.Done); break; } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (Control == null || e.NewElement == null) { return; } MyEntry entry = Element as MyEntry; /* * if (entry.BorderWidth > 0) * DrawBorder(Control, entry); */ DrawLine(Control, entry.LineColor.ToAndroid()); SetDisabledColors(Control, entry.DisabledColor.ToAndroid()); }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (native == null) { source = e.NewElement as MyEntry; var control = (MyEntry)this.Element; native = this.Control as UITextField; if (source.FormatCharacters != null && String.IsNullOrEmpty(source.Text) == false) { ApplyDefaultRule(); } native.ShouldChangeCharacters += TextShouldChangeCharacters; } }
public static void ExampleCode1() { MyEntry <int, string> entry = new MyEntry <int, string>(); entry.Key = 1; entry.Value = "Dog"; List <MyEntry <int, string> > listMyEntries = new List <MyEntry <int, string> >(); listMyEntries.Add(new MyEntry <int, string>(1, "First")); listMyEntries.Add(new MyEntry <int, string>(2, "Second")); listMyEntries.Add(new MyEntry <int, string>(3, "Third")); listMyEntries.Add(new MyEntry <int, string>(4, "Fourth")); listMyEntries.Add(new MyEntry <int, string>(5, "Fifth")); foreach (var item in listMyEntries) { item.DisplayEntry(); } }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (Control == null) { return; } MyEntry myEntry = (MyEntry)Element; var shape = new ShapeDrawable(new RectShape()); //shape.Paint.Color = Android.Graphics.Color.Red; shape.Paint.Color = myEntry.BorderColor.ToAndroid(); shape.Paint.SetStyle(Paint.Style.Stroke); //shape.Paint.StrokeWidth = 10; shape.Paint.StrokeWidth = myEntry.BorderWidth; Control.Background = shape; }
protected override void OnElementChanged(ElementChangedEventArgs <Xamarin.Forms.Entry> e) { base.OnElementChanged(e); if (e.OldElement != null || e.NewElement == null) { return; } if (Control != null) { // do whatever you want to the UITextField here! //Control.BorderStyle = UITextBorderStyle.Line; //Control.Layer.BorderWidth = 2; //Control.Layer.CornerRadius = 10; //Control.Background.SetColorFilter(element.CustomBorderColor.ToAndroid(), PorterDuff.Mode.SrcAtop); //Control. Control.SetBackgroundResource(Resource.Drawable.EntryStyle); } element = (MyEntry)this.Element; var editText = this.Control; if (!string.IsNullOrEmpty(element.ImageName)) { switch (element.ImageAlignment) { case ImageAlignment.Left: editText.SetCompoundDrawablesWithIntrinsicBounds(GetDrawable(element.ImageName), null, null, null); break; case ImageAlignment.Right: editText.SetCompoundDrawablesWithIntrinsicBounds(null, null, GetDrawable(element.ImageName), null); break; } } editText.CompoundDrawablePadding = 25; //Control.Background.SetColorFilter(element.CustomBorderColor.ToAndroid(), PorterDuff.Mode.SrcAtop); GetDesign(element.CustomBorderColor.ToAndroid()); }
//async void backButton1(System.Object sender, System.EventArgs e) //{ // await Navigation.PopAsync(); //} async void ShakeButton_Clicked(System.Object sender, System.EventArgs e) { uint timeout = 50; await MyEntry.TranslateTo(-25, 0, timeout); await MyEntry.TranslateTo(25, 0, timeout); await MyEntry.TranslateTo(-20, 0, timeout); await MyEntry.TranslateTo(20, 0, timeout); await MyEntry.TranslateTo(-15, 0, timeout); await MyEntry.TranslateTo(15, 0, timeout); MyEntry.TranslationX = 0; await Task.Delay(2000); DisplayAlert("Alert", "You WON!!", "OK"); }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (native == null) { source = e.NewElement as MyEntry; native = this.Control as EntryEditText; if (source.FormatCharacters != null && String.IsNullOrEmpty(source.Text) == false) { ApplyDefaultRule(); } native.AfterTextChanged += Native_AfterTextChanged; native.KeyPress += Native_KeyPress; native.BeforeTextChanged += Native_BeforeTextChanged; SetNativeControl(native); } }
public SettingNamesPage() { InitializeComponent(); NavigationPage.SetHasNavigationBar(this, false); ListOfPlayers = new ObservableCollection <Player>(); NumberOfPlayers = 1; var ent = new MyEntry { Placeholder = "Player" + NumberOfPlayers, PlaceholderColor = Color.LightCyan, TextColor = Color.LightCyan }; NumberOfPlayers++; var ent1 = new MyEntry { Placeholder = "Player" + NumberOfPlayers, PlaceholderColor = Color.LightCyan, TextColor = Color.LightCyan }; ent.TextChanged += Ent_TextChanged; ent1.TextChanged += Ent_TextChanged; StkContent.Children.Add(ent); StkContent.Children.Add(ent1); }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { //(Forms.Context as Android.App.Activity).Window.SetSoftInputMode(Android.Views.SoftInput.AdjustNothing ); base.OnElementChanged(e); //(Forms.Context as Android.App.Activity).Window.SetSoftInputMode(Android.Views.SoftInput.AdjustNothing ); if (e.NewElement != null) { MyEntry Content = e.NewElement as MyEntry; SetCornerRadius(Content); Typeface font = Typeface.CreateFromAsset(Forms.Context.Assets, "MyriadProRegular.ttf"); TextView label = (TextView)Control; label.Typeface = font; ShapeDrawable shape = new ShapeDrawable(new RectShape()); shape.Paint.Color = Xamarin.Forms.Color.Transparent.ToAndroid(); shape.Paint.StrokeWidth = 5; shape.Paint.SetStyle(Paint.Style.Stroke); this.Control.SetBackground(shape); int paddingTop = Content.Padding.Top == 0 ? this.Control.PaddingTop : (int)Content.Padding.Top; int paddingBottom = Content.Padding.Bottom == 0 ? this.Control.PaddingBottom : (int)Content.Padding.Bottom; int paddingLeft = Content.Padding.Left == 0 ? this.Control.PaddingLeft : (int)Content.Padding.Left; int paddingRight = Content.Padding.Right == 0 ? this.Control.PaddingRight : (int)Content.Padding.Right; this.Control.SetPadding(paddingLeft, paddingTop, paddingRight, paddingBottom); if (Content != null) { SetCornerRadius(Content); } } }
public override bool DeserializeUserspace(BinaryReader stream) { // no special data uint entrycount=stream.ReadUInt32(); for (uint i=0; i<entrycount; ++i) { MyEntry e=new MyEntry(); e.Deserialize(stream); _list.Add(e); } return true; }
public void Add(MyEntry e) { _list.Add(e); }