protected override void SetBindingContext() { typePicker = ControlFactory.CreatePicker(); typePicker.SelectedIndexChanged += TypePicker_SelectedIndexChanged; typePicker.SelectedItemChanged += Picker_SelectedItemChanged; projectPicker = ControlFactory.CreatePicker(); projectPicker.HorizontalOptions = LayoutOptions.FillAndExpand; projectPicker.SelectedItemChanged += Picker_SelectedItemChanged; // Create a filter for showing projects only if the time entry can be edited. if (this.ViewModel.CanEdit()) { filterIcon = ControlFactory.CreateIcon(LabelHandler.FILTER_SYMBOL, ControlFactory.Small_Label_Icon); } projectTaskPicker = ControlFactory.CreatePicker(); projectTaskPicker.HorizontalOptions = LayoutOptions.FillAndExpand; projectTaskPicker.SelectedItemChanged += Picker_SelectedItemChanged; transactionDatePicker = ControlFactory.CreateDatePicker("Time.msdyn_date_utc", DateTime.MaxValue, "D"); // Use a one-way binding from view model to view because of the custom formatting that we have. We want the user to be able to type anything in the text box // but on losing focus from the field, we validate and store the duration in the view model. durationEntry = ControlFactory.CreateEntry("Time.msdyn_duration", BindingMode.OneWay, Keyboard.Default, null, "", new DurationTo24HourStringConverter()); durationEntry.Unfocused += DurationEntry_Unfocused; internalDescriptionEditor = ControlFactory.CreateEditor("Time.msdyn_description"); internalDescriptionEditor.TextChanged += this.createEditorTextChangedHandler(msdyn_timeentry.DescriptionLength); externalDescriptionEditor = ControlFactory.CreateEditor("Time.msdyn_externalDescription"); externalDescriptionEditor.TextChanged += this.createEditorTextChangedHandler(msdyn_timeentry.DescriptionLength); this.BindingContext = ViewModel; }
void ValidatePassword(EntryEx targetEntry, ImageEx targetImage) { var pass = targetEntry.Text; if (string.IsNullOrEmpty(pass)) { _passModel.Reset(); } else { _passModel.Validate(pass); } targetImage.IsVisible = _passModel.AllCriteriaMet; if (EntryPasswordNew.IsFocused) { GridPassConditions.IsVisible = !_passModel.AllCriteriaMet; } if (InputValidator.IsValidPassword(EntryPasswordCurrent.Text) && InputValidator.IsValidPassword(EntryPasswordNew.Text)) { _model.NotReadyToSave = false; } }
protected override void SetBindingContext() { projectPicker = ControlFactory.CreatePicker(null, ViewModel.OnProjectSelected); categoryPicker = ControlFactory.CreatePicker(null, ViewModel.OnCategorySelected); currencyPicker = ControlFactory.CreatePicker(null, ViewModel.OnCurrencySelected); transactionDatePicker = ControlFactory.CreateDatePicker("Expense.msdyn_TransactionDate_utc", DateTime.Today, "D"); descriptionEditor = ControlFactory.CreateEditor("Expense.msdyn_name"); descriptionEditor.TextChanged += this.createEditorTextChangedHandler(msdyn_timeentry.DescriptionLength); amountEntry = ControlFactory.CreateEntry("Expense.TransactionAmount", BindingMode.TwoWay, Keyboard.Numeric, "{0:N2}", String.Format("{0:N2}", 0)); amountEntry.Focused += (s, e) => { if (amountEntry.Text.Equals("0.00") || amountEntry.Text.Equals("0")) { amountEntry.Text = String.Empty; } }; salesTaxEntry = ControlFactory.CreateEntry("Expense.SalesTaxAmount", BindingMode.TwoWay, Keyboard.Numeric, "{0:N2}", String.Format("{0:N2}", 0)); salesTaxEntry.Focused += (s, e) => { if (salesTaxEntry.Text.Equals("0.00") || salesTaxEntry.Text.Equals("0")) { salesTaxEntry.Text = String.Empty; } }; this.BindingContext = ViewModel; }
protected override void OnElementChanged(ElementChangedEventArgs <Entry> e) { base.OnElementChanged(e); if (e.OldElement == null) { _entry = (EntryEx)this.Element; } if (Control != null) { Control.SetBackgroundColor(global::Android.Graphics.Color.Transparent); Control.SetPadding(0, 0, 0, 0); } if (Control != null && _entry != null && _entry.IsTimeDurationInput) { //Control.SetRawInputType(InputTypes.DatetimeVariationTime | InputTypes.ClassNumber); } if (Control != null && _entry != null && _entry.IsSeparateKb) { Control.FocusChange += OnControlFocusChange; } if (Control != null && _entry != null && _entry.CustomCursorColor != null) { // No validway except read value from android styles } }
private void UpdateBackground(EntryEx entryEx) { if (_renderer != null) { _renderer.Dispose(); _renderer = null; } _renderer = new BorderRenderer(); Control.Background = _renderer.GetBorderBackground(entryEx.BorderColor, entryEx.BackgroundColor, entryEx.BorderWidth, entryEx.BorderRadius); }
public static EntryEx CreateEntry(string path, BindingMode mode, Keyboard keyboard, string format = null, string placeHolder = null, IValueConverter valueConverter = null, object converterParameter = null) { EntryEx entry = new EntryEx { Keyboard = keyboard, Placeholder = placeHolder }; if (path != null) { entry.SetBinding(EntryEx.TextProperty, new Binding(path, mode, valueConverter, converterParameter, format)); } return(entry); }
public PasswordRecoveryPage() { InitializeComponent(); SubmitLink.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)); DescriptionLabel.FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)); Logo.Source = ImageSource.FromResource("Tulsi.Images.logo.png"); //Taps TapGestureRecognizer tapGestureRecognizer1 = new TapGestureRecognizer(); tapGestureRecognizer1.Tapped += (s, e) => { DisplayAlert("Navigation", "Password recovery action", "OK"); //DashboardPage dp = new DashboardPage(); //Application.Current.MainPage = new NavigationPage(dp); }; SubmitLink.GestureRecognizers.Add(tapGestureRecognizer1); EntryEx EmailEntry = new EntryEx() { BorderWidth = 2, BorderRadius = 50, BorderColor = Color.FromHex("#d9d9d9"), PlaceholderColor = Color.FromHex("#d9d9d9"), Placeholder = "Email", HeightRequest = 20, LeftPadding = 30, RightPadding = 30, Margin = 10, FontSize = 18, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Keyboard = Keyboard.Email, }; LoginGrid.Children.Add(EmailEntry); Grid.SetRow(EmailEntry, 4); Grid.SetColumn(EmailEntry, 1); }
private void UpdateTextAlighnment(EntryEx 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; }
public LoginPage() { InitializeComponent(); LoginLink.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)); SignupLink.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)); ForgotPasswordLink.FontSize = Device.GetNamedSize(NamedSize.Medium, typeof(Label)); Logo.Source = ImageSource.FromResource("Tulsi.Images.logo.png"); //Taps TapGestureRecognizer loginTapGestureRecognizer = new TapGestureRecognizer(); loginTapGestureRecognizer.Tapped += (s, e) => { // remove that //DashboardPage dp = new DashboardPage(); //Application.Current.MainPage = new NavigationPage(dp); BaseSingleton <ViewSwitchingLogic> .Instance.BuildNavigationStack(ViewType.DashboardPage); }; LoginLink.GestureRecognizers.Add(loginTapGestureRecognizer); TapGestureRecognizer tapGestureRecognizer2 = new TapGestureRecognizer(); tapGestureRecognizer2.Tapped += (s, e) => { DisplayAlert("Navigation", "Sign up action", "OK"); }; SignupLink.GestureRecognizers.Add(tapGestureRecognizer2); TapGestureRecognizer forgotPasswordTapGestureRecognizer = new TapGestureRecognizer(); forgotPasswordTapGestureRecognizer.Tapped += (s, e) => { // remove that //PasswordRecoveryPage prp = new PasswordRecoveryPage(); //Application.Current.MainPage = new NavigationPage(prp); BaseSingleton <ViewSwitchingLogic> .Instance.NavigateTo(ViewType.PasswordRecoveryPage); }; ForgotPasswordLink.GestureRecognizers.Add(forgotPasswordTapGestureRecognizer); EntryEx EmailEntry = new EntryEx() { BorderWidth = 2, BorderRadius = 50, BorderColor = Color.FromHex("#d9d9d9"), PlaceholderColor = Color.FromHex("#d9d9d9"), Placeholder = "Email", HeightRequest = 20, LeftPadding = 30, RightPadding = 30, Margin = 10, FontSize = 18, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, Keyboard = Keyboard.Email, }; LoginGrid.Children.Add(EmailEntry); Grid.SetRow(EmailEntry, 3); Grid.SetColumn(EmailEntry, 1); EntryEx PasswordEntry = new EntryEx() { BorderWidth = 2, BorderRadius = 50, BorderColor = Color.FromHex("#d9d9d9"), PlaceholderColor = Color.FromHex("#d9d9d9"), Placeholder = "Password", HeightRequest = 20, LeftPadding = 30, RightPadding = 30, Margin = 10, FontSize = 18, HorizontalOptions = LayoutOptions.FillAndExpand, VerticalOptions = LayoutOptions.FillAndExpand, IsPassword = true, }; LoginGrid.Children.Add(PasswordEntry); Grid.SetRow(PasswordEntry, 4); Grid.SetColumn(PasswordEntry, 1); }
private void UpdatePadding(EntryEx entryEx) { Control.SetPadding((int)Forms.Context.ToPixels(entryEx.LeftPadding), 0, (int)Forms.Context.ToPixels(entryEx.RightPadding), 0); }
/// <summary> /// Copies the duration value of the current time entry to the view model (manually binding the value). /// </summary> /// <param name="entryCell">The duration entry cell object.</param> /// <returns>True if the duration can be binded, false otherwise.</returns> private bool BindDurationToViewModel(EntryEx entryCell) { bool result = false; if (entryCell != null) { string stringValue = entryCell.Text; if (stringValue.Length > 0) { string[] stringDuration = stringValue.Split(':'); int? previousTime = this.ViewModel.Time.msdyn_duration; int hours, minutes; // Throw error for an invalid input format string. // We allow numbers in the format HH:mm or HH. if (stringDuration.Length == 2) { // Throw an error to user if a non-integer or a negative number is entered and reset to the last valid data. if (!int.TryParse(stringDuration[0], out hours) || !int.TryParse(stringDuration[1], out minutes)) { MessageCenter.ShowDialog(AppResources.InvalidDuration, null, null).DoNotAwait(); entryCell.Text = ConvertDurationToStringFormat(previousTime); result = false; } // Throw an error if the string format is not a 24-hour system duration and reset to the last valid data. else if ((hours > 23 || minutes > 59) && !(hours == 24 && minutes == 0)) { MessageCenter.ShowDialog(AppResources.InvalidDuration, null, null).DoNotAwait(); entryCell.Text = ConvertDurationToStringFormat(previousTime); result = false; } else { this.ViewModel.Time.msdyn_duration = hours * 60 + minutes; result = true; } } else if (stringDuration.Length == 1) { // Throw an error to user if a non-integer or a negative number is entered and reset to the last valid data. if (!int.TryParse(stringDuration[0], out hours)) { MessageCenter.ShowDialog(AppResources.InvalidDuration, null, null).DoNotAwait(); entryCell.Text = ConvertDurationToStringFormat(previousTime); result = false; } // Throw an error if the string format is not a 24-hour system duration and reset to the last valid data. else if (hours > 24) { MessageCenter.ShowDialog(AppResources.InvalidDuration, null, null).DoNotAwait(); entryCell.Text = ConvertDurationToStringFormat(previousTime); result = false; } else { this.ViewModel.Time.msdyn_duration = hours * 60; result = true; } } // If the format of the entry is incorrect, throw an error message and reset to the last valid data. else { MessageCenter.ShowDialog(AppResources.InvalidDuration, null, null).DoNotAwait(); entryCell.Text = ConvertDurationToStringFormat(previousTime); result = false; } } } return(result); }
private void DurationEntry_Unfocused(object sender, FocusEventArgs e) { EntryEx entryCell = sender as EntryEx; BindDurationToViewModel(entryCell); }