Beispiel #1
0
        public string CalculaTextLenguages(string value)
        {
            TranslateExtension Translate = new TranslateExtension();

            Translate.Text = value;
            return(Convert.ToString(Translate.ProvideValue(null)));
        }
        /// <summary>
        /// Invoked when the Log In button is clicked.
        /// https://docs.microsoft.com/en-us/xamarin/essentials/geolocation?tabs=android
        /// </summary>
        /// <param name="obj">The Object</param>
        private async void LoginClicked(object obj)
        {
            var location = await Geolocation.GetLastKnownLocationAsync();

            var outcome = await authService.LoginAsync(new Backend.DataTransferObjects.UserLogin {
                Email = this.Email, Password = this.Password, Latitude = location?.Latitude.ToString(), Longitude = location?.Longitude.ToString()
            });

            if (outcome.IsSuccess == false)
            {
                var translationKey = "LoginFailure";
                var translator     = new TranslateExtension {
                    Text = translationKey
                };
                var message = translator.ProvideValue(null).ToString();

                //App.DisplayMessage(message);
                //return;
            }

            ////todo
            //await App.SetAsRoot(Core.Routes.HomeMenu); //.ConfigureAwait(false);
            await App.ReplaceRootContent(Core.Routes.HomeMenu);

            //await App.AppendToSection(Core.Routes.HomeMenu);
        }
Beispiel #3
0
        public string GetResource(string resourceKey)
        {
            var translation = new TranslateExtension();

            translation.Text = resourceKey;
            return(translation.ProvideValue(null)?.ToString() ?? "");
        }
Beispiel #4
0
        /// <summary>
        /// Validates data.
        /// </summary>
        /// <returns>Was validation successful</returns>
        bool Validate()
        {
            // Check if user set starting and ending stations
            var placeholder = new TranslateExtension {
                Text = "ClickTo"
            }.ProvideValue() as string;

            if (fromLabel.Text == placeholder || toLabel.Text == placeholder)
            {
                var translator = new TranslateExtension {
                    Text = "SelectStations"
                };
                DisplayAlert("", (string)translator.ProvideValue(), "OK");
                return(false);
            }

            // Check if we entered same stations in both fields
            if (fromLabel.Text == toLabel.Text)
            {
                var translator = new TranslateExtension {
                    Text = "SelectDiffStations"
                };
                DisplayAlert("", (string)translator.ProvideValue(), "OK");
                return(false);
            }

            return(true);
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var translator = new TranslateExtension();

            translator.Text = "GenderFemale";

            var gender = (Gender)value;


            if (gender == Gender.Female)
            {
                return(translator.ProvideValue(null));
            }

            translator.Text = "GenderMale";
            return(translator.ProvideValue(null));
        }
 public LandingViewModel()
 {
     this.synchedPhysicalContacts = new ObservableCollection <SynchedPhysicalContacts>();
     this.translator            = new TranslateExtension();
     this.translator.Text       = physicallyNearKey;
     this.translatedNearKeyText = translator.ProvideValue(null).ToString();
     ConstructContactsTypes();
     CreateDummy();
 }
Beispiel #7
0
        private void ResetPickerButtonText()
        {
            var translator = new TranslateExtension();

            translator.Text = "SelectContactType";
            var translation = translator.ProvideValue(null).ToString();

            pickerBtn.Text = translation;
        }
Beispiel #8
0
        private void configureRegistration()
        {
            if (genderConfigured == true)
            {
                return;
            }

            var collection = new List <string>();
            var translator = new TranslateExtension();

            translator.Text = "GenderMale";
            collection.Add((string)translator.ProvideValue(null));
            translator.Text = "GenderFemale";
            collection.Add((string)translator.ProvideValue(null));

            genderCb.ComboBoxSource = collection;
            genderConfigured        = true;
        }
Beispiel #9
0
        /// <summary>
        /// Invoked when the Sign Up button is clicked.
        /// </summary>
        /// <param name="obj">The Object</param>
        private async void SignUpClicked(object obj)
        {
            // vALIDATE model
            //if error let user know

            //use service to send request.
            var results = await this.authService.RegisterNewUserAsync(registrationModel);

            var translationKey = results.IsSuccess == true ? "RegistratationSuccess" : "RegistrationFailure";
            var translator     = new TranslateExtension {
                Text = translationKey
            };
            var message = translator.ProvideValue(null).ToString();

            App.DisplayMessage(message);
        }
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var key = "GenderFemale";

            if (String.IsNullOrEmpty(value.ToString()))
            {
                return(Gender.Female);
            }

            var translator = new TranslateExtension();

            translator.Text = key;

            var val = translator.ProvideValue(null);

            if (val == value)
            {
                return(Gender.Female);
            }

            return(Gender.Male);
        }
Beispiel #11
0
        private void ConstructContactsTypes()
        {
            //ContactsKeyTranslation
            var enumType   = typeof(PhysicalContacts);
            var members    = Enum.GetNames(enumType);
            var translator = new TranslateExtension();

            foreach (var member in members)
            {
                var key                 = member;
                var memberInfos         = enumType.GetMember(member);
                var enumValueMemberInfo = memberInfos.FirstOrDefault(m => m.DeclaringType == enumType);

                var valueAttribute =
                    enumValueMemberInfo.GetCustomAttribute(typeof(EnumLangualKeyAttribute), false);
                var languageKey = ((EnumLangualKeyAttribute)valueAttribute).LanguageKey;

                translator.Text = languageKey;
                var enumPickerValue = translator.ProvideValue(null).ToString();

                ContactsKeyTranslation.Add(key, enumPickerValue);
            }
        }
Beispiel #12
0
        private void configureMarital()
        {
            if (maritalConfigured == true)
            {
                return;
            }

            var groupKey = new SfRadioGroupKey();

            var translator = new TranslateExtension();

            translator.Text = "EnumMaritalSingle";

            this.singleRadio = new SfRadioButton {
                Text = (string)translator.ProvideValue(null)
            };
            singleRadio.GroupKey = groupKey;

            translator.Text   = "EnumMaritalMarried";
            this.marriedRadio = new SfRadioButton {
                Text = (string)translator.ProvideValue(null)
            };
            marriedRadio.GroupKey = groupKey;

            translator.Text    = "EnumMaritalDivorced";
            this.divorcedRadio = new SfRadioButton {
                Text = (string)translator.ProvideValue(null)
            };
            divorcedRadio.GroupKey = groupKey;

            translator.Text = "EnumMaritaWidow";
            this.widowRadio = new SfRadioButton {
                Text = (string)translator.ProvideValue(null)
            };
            widowRadio.GroupKey = groupKey;


            //var flex = new FlexLayout();
            flex.Wrap           = FlexWrap.Wrap;
            flex.Direction      = FlexDirection.Row;
            flex.JustifyContent = FlexJustify.SpaceBetween;

            flex.Children.Add(singleRadio);
            flex.Children.Add(marriedRadio);
            flex.Children.Add(divorcedRadio);
            flex.Children.Add(widowRadio);

            var context = registerTbView.BindingContext as SignUpPageViewModel;

            maritalConfigured = true;

            if (context == null)
            {
                return;
            }

            widowRadio.IsChecked     = context.Marital == Backend.Core.Types.MaritalStatus.Widow;
            widowRadio.StateChanged += (src, arg) =>
            {
                if (widowRadio.IsChecked == true)
                {
                    context.Marital = Backend.Core.Types.MaritalStatus.Widow;
                }
            };

            divorcedRadio.IsChecked     = context.Marital == Backend.Core.Types.MaritalStatus.Divorced;
            divorcedRadio.StateChanged += (src, arg) =>
            {
                if (divorcedRadio.IsChecked == true)
                {
                    context.Marital = Backend.Core.Types.MaritalStatus.Divorced;
                }
            };

            marriedRadio.IsChecked     = context.Marital == Backend.Core.Types.MaritalStatus.Married;
            marriedRadio.StateChanged += (src, arg) =>
            {
                if (marriedRadio.IsChecked == true)
                {
                    context.Marital = Backend.Core.Types.MaritalStatus.Married;
                }
            };

            singleRadio.IsChecked     = context.Marital == Backend.Core.Types.MaritalStatus.Single;
            singleRadio.StateChanged += (src, arg) =>
            {
                if (singleRadio.IsChecked == true)
                {
                    context.Marital = Backend.Core.Types.MaritalStatus.Single;
                }
            };
        }