Esempio n. 1
0
 protected override void OnPropertyChanged(DependencyPropertyChangedEventArgs e)
 {
     if (e.Property == SelectedFamilyProperty)
     {
         Typefaces.Clear();
         foreach (Typeface typeface in SelectedFamily.GetTypefaces())
         {
             TypefaceListItem item = new TypefaceListItem(typeface);
             Typefaces.Add(item);
         }
         SelectedTypeface = Typefaces[0].Typeface;
     }
     else if (e.Property == IsUnderlineProperty ||
              e.Property == IsBaselineProperty ||
              e.Property == IsOverlineProperty ||
              e.Property == IsStrikethroughProperty)
     {
         UpdateSelectedDecorations();
     }
     else if (e.Property == SelectedDecorationsProperty)
     {
         UpdateDecorationProperties();
     }
     base.OnPropertyChanged(e);
 }
Esempio n. 2
0
        public static ImageSource ToImageSource(this IconChar iconChar,
                                                Brush foregroundBrush = null, double size = DefaultSize)
        {
            var typeFace = Typefaces.Find(iconChar, out var gt, out var glyphIndex);

            return(typeFace == null ? null : ToImageSource(foregroundBrush, size, gt, glyphIndex));
        }
        internal static Typeface TypefaceFor(IconChar iconChar, IconFont iconFont)
        {
            if (iconFont == IconFont.Auto)
            {
                return(TypefaceFor(iconChar));
            }
            var key = (int)iconFont;

            if (TypefaceForStyle.TryGetValue(key, out var typeFace))
            {
                return(typeFace);
            }
            if (!FontTitles.TryGetValue(key, out var name))
            {
                return(Throw($"No font loaded for style: {iconFont}"));
            }

            typeFace = Typefaces.FirstOrDefault(t => t.FontFamily.Source.EndsWith(name));
            if (typeFace == null)
            {
                return(Throw($"No font loaded for '{name}'"));
            }

            TypefaceForStyle.Add(key, typeFace);
            return(typeFace);
        }
Esempio n. 4
0
        private void Init()
        {
            base.RemoveAllViews();

            Orientation = Orientation.Vertical;

            View view = Inflate(Context, Resource.Layout.avs, null);

            AddView(view);

            //get the arrays of values from Strings
            postcodeText = Resources.GetStringArray(Resource.Array.avs_countries_postcode_label_text);

            countrySpinner    = view.FindViewById <Spinner> (Resource.Id.countrySpinner);
            postCodeContainer = view.FindViewById(Resource.Id.postCodeContainer);
            postCodeEditText  = view.FindViewById <EditText> (Resource.Id.postCodeEditText);
            postCodeTitleText = view.FindViewById <TextView> (Resource.Id.postCodeTitleText);
            avsMsgText        = view.FindViewById <TextView> (Resource.Id.avsMsgText);

            Typeface type = Typefaces.LoadTypefaceFromRaw(Context, Resource.Raw.courier);

            postCodeEditText.Typeface = type;

            List <string> countries = new List <string> ();

            foreach (BillingCountryOptions option in Enum.GetValues(typeof(BillingCountryOptions)))
            {
                countries.Add(option.ToDescriptionString());
            }

            // Populate country spinner
            ArrayAdapter <string> dataAdapter = new CountryArrayAdapter(Context,
                                                                        Android.Resource.Layout.SimpleSpinnerItem, countries.ToArray(), type);

            dataAdapter.SetDropDownViewResource(Resource.Layout.country_spinner_dropdown_item);
            countrySpinner.Adapter = dataAdapter;

            countrySpinner.ItemSelected += (sender, args) => {
                postCodeTitleText.Text = postcodeText [args.Position];
                postCodeEditText.Hint  = postcodeText [args.Position];
                if (args.Position == 3)
                {
                    postCodeContainer.Visibility = ViewStates.Invisible;
                    avsMsgText.Visibility        = ViewStates.Visible;
                    avsMsgText.BringToFront();
                }
                else
                {
                    postCodeContainer.Visibility = ViewStates.Visible;
                    postCodeContainer.BringToFront();
                    avsMsgText.Visibility = ViewStates.Invisible;
                    if (!Volatile.Read(ref ignoreFocus))
                    {
                        postCodeEditText.RequestFocus();
                    }
                }
            };
        }
Esempio n. 5
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            base.OnCreateView(inflater, container, savedInstanceState);
            var view = this.BindingInflate(FragmentId, null);

            _tvTitle = view.FindViewById <TextView>(Resource.Id.text_view_toolbar_title);
            Typefaces.SetBold(_tvTitle, Fonts.QUICKSAND_REGULAR);
            return(view);
        }
Esempio n. 6
0
        internal static FontFamily FontFor(IconChar iconChar)
        {
            if (Orphans.Contains(iconChar))
            {
                return(null);
            }
            var typeFace = Typefaces.Find(iconChar.UniCode(), out _, out _);

            return(typeFace?.FontFamily);
        }
Esempio n. 7
0
        public void AddFixedText(string text)
        {
            EditText fixedText = new EditText(Context);

            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(LayoutParams.WrapContent, LayoutParams.WrapContent);
            layoutParams.Gravity = GravityFlags.CenterVertical;
            fixedText.SetTextAppearance(Context, Resource.Style.judo_payments_CardText);
            fixedText.LayoutParameters = layoutParams;
            fixedText.Enabled          = false;
            fixedText.Focusable        = false;
            fixedText.Text             = text;
            fixedText.SetBackgroundColor(Resources.GetColor(Android.Resource.Color.Transparent));
            fixedText.SetPadding(0, 0, 0, 0);
            Typeface type = Typefaces.LoadTypefaceFromRaw(Context, Resource.Raw.courier);

            fixedText.Typeface = type;

            if (linearLayout.ChildCount > 1)
            {
                linearLayout.RemoveViewAt(0);
            }
            linearLayout.AddView(fixedText, 0);
        }
Esempio n. 8
0
 private void SetupFonts()
 {
     Typefaces.SetNormal(_tvTotalCash, Fonts.QUICKSAND_BOLD);
     Typefaces.SetNormal(_tvCashValuta, Fonts.QUICKSAND_LIGHT);
 }
Esempio n. 9
0
        private void Init()
        {
            base.RemoveAllViews();

            hintTextView = new EditText(Context);
            textTextView = new NoCursorMovingEditText(Context, BackKeyPressed);

            linearLayout = new LinearLayout(Context);
            linearLayout.LayoutParameters = new ViewGroup.LayoutParams(LinearLayout.LayoutParams.MatchParent, (int)GetContainerHeight());

            textLayout = new RelativeLayout(Context);
            textLayout.LayoutParameters = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MatchParent, 1);
            textLayout.SetGravity(GravityFlags.Center);

            linearLayout.AddView(textLayout);

            textTextView.SetTextAppearance(Context, Resource.Style.judo_payments_CardText);
            hintTextView.SetTextAppearance(Context, Resource.Style.judo_payments_HintText);

            LayoutParams lp = new LayoutParams(LinearLayout.LayoutParams.MatchParent,
                                               LinearLayout.LayoutParams.WrapContent);

            lp.AddRule(LayoutRules.CenterVertical);

            hintTextView.LayoutParameters = lp;
            textTextView.LayoutParameters = lp;
            hintTextView.Enabled          = false;
            hintTextView.Focusable        = false;

            textTextView.InputType = InputTypes.ClassNumber | InputTypes.TextFlagNoSuggestions;
            hintTextView.InputType = InputTypes.ClassNumber | InputTypes.TextFlagNoSuggestions;

            hintTextView.SetBackgroundColor(Resources.GetColor(Android.Resource.Color.Transparent));
            textTextView.SetBackgroundColor(Resources.GetColor(Android.Resource.Color.Transparent));
            int horizontalPadding =
                Resources.GetDimensionPixelOffset(Resource.Dimension.backgroundhinttextview_horizontal_padding);

            hintTextView.SetPadding(horizontalPadding, 0, horizontalPadding, 0);
            textTextView.SetPadding(horizontalPadding, 0, horizontalPadding, 0);

            textErrorView = new EditText(Context);
            RelativeLayout.LayoutParams errorLP = new RelativeLayout.LayoutParams(LayoutParams.MatchParent,
                                                                                  LayoutParams.WrapContent);
            errorLP.AddRule(LayoutRules.CenterVertical);

            int margin = UiUtils.ToPixels(Context, 2);

            errorLP.SetMargins(margin, 0, margin, 0);

            textErrorView.LayoutParameters = errorLP;
            textErrorView.Enabled          = false;
            textErrorView.Focusable        = false;
            textErrorView.Visibility       = ViewStates.Gone;
            textErrorView.SetBackgroundColor(Color.Red);
            int errorVerticalPadding =
                Context.Resources.GetDimensionPixelOffset(
                    Resource.Dimension.backgroundhinttextview_error_vertical_padding);

            textErrorView.SetPadding(horizontalPadding, errorVerticalPadding, horizontalPadding, errorVerticalPadding);
            textErrorView.Text = errorText;
            textErrorView.SetSingleLine(true);
            textErrorView.Gravity = GravityFlags.Center;
            textErrorView.SetTextAppearance(Context, Resource.Style.judo_payments_ErrorText);

            //set courier font
            Typeface type = Typefaces.LoadTypefaceFromRaw(Context, Resource.Raw.courier);

            hintTextView.SetTypeface(Typeface.Monospace, TypefaceStyle.Normal);
            textTextView.SetTypeface(Typeface.Monospace, TypefaceStyle.Normal);
            textErrorView.Typeface = type;


            textLayout.AddView(hintTextView);
            textLayout.AddView(textTextView);

            AddView(linearLayout);

            IEnumerable <char> previousCharSequence;
            EventHandler <TextChangedEventArgs> beforeTextChanged = (sender, args) => {
                previousCharSequence = args.Text;
            };

            EventHandler <TextChangedEventArgs> textChanged = (sender, args) => {
                beforeTextSize = args.BeforeCount;
            };

            EventHandler <AfterTextChangedEventArgs> afterTextChanged = null;


            Action <string> updateTextView = newText => {
                textTextView.TextChanged       -= textChanged;
                textTextView.BeforeTextChanged -= beforeTextChanged;
                textTextView.AfterTextChanged  -= afterTextChanged;

                textTextView.Text = newText;

                textTextView.TextChanged       += textChanged;
                textTextView.BeforeTextChanged += beforeTextChanged;
                textTextView.AfterTextChanged  += afterTextChanged;
            };

            afterTextChanged = (sender, args) => {
                var length   = args.Editable.ToString().Length;
                var deleting = beforeTextSize == 1;

                if (deleting)
                {
                    nextMustBeDeleted = false;
                }
                else
                {
                    if (nextMustBeDeleted && length > 0)
                    {
                        updateTextView(args.Editable.SubSequence(0, length - 1));
                        UpdateHintTextForCurrentTextEntry();
                        return;
                    }
                }

                // If we are deleting (we've just removed a space char, so delete another char please:
                // Or if we've pressed space don't allow it!
                if ((deleting && skipCharsAtPositions.Contains(length)) ||
                    (length > 0 && IsCharInFilter(args.Editable.CharAt(length - 1)) &&
                     !skipCharsAtPositions.Contains(length - 1)))
                {
                    updateTextView(length == 0 ? "" : args.Editable.SubSequence(0, length - 1));
                    textTextView.SetSelection(length == 0 ? 0 : length - 1);
                    UpdateHintTextForCurrentTextEntry();
                    return;
                }

                // Adds a non numeric char at positions needed
                for (int i = 0; i < skipCharsAtPositions.Count; ++i)
                {
                    // We rescan all letters recursively to catch when a users pastes into the edittext
                    int charPosition = skipCharsAtPositions [i];
                    if (length > charPosition)
                    {
                        if (hintText [charPosition] != args.Editable.ToString() [charPosition])
                        {
                            updateTextView(args.Editable.SubSequence(0, charPosition) + "" + hintText [charPosition] +
                                           args.Editable.SubSequence(charPosition, args.Editable.Length()));
                            UpdateHintTextForCurrentTextEntry();
                            return;
                        }
                    }
                    else
                    {
                        if (length == charPosition)
                        {
                            updateTextView(textTextView.Text + "" + hintText [charPosition]);
                        }
                    }
                }

                UpdateHintTextForCurrentTextEntry();

                // We've got all the chars we need, fire off our listener
                if (length >= LengthToStartValidation())
                {
                    try {
                        ValidateInput(args.Editable.ToString());
                        if (OnEntryComplete != null)
                        {
                            OnEntryComplete(args.Editable.ToString());
                        }
                        return;
                    } catch (Exception exception) {
                        Log.Error(JudoSDKManager.DEBUG_TAG, exception.Message, exception);
                    }

                    ShowInvalid();
                }
                else
                {
                    if (OnProgress != null)
                    {
                        OnProgress(length);
                    }
                }
            };

            textTextView.BeforeTextChanged += beforeTextChanged;

            textTextView.TextChanged += textChanged;

            textTextView.AfterTextChanged += afterTextChanged;
        }
Esempio n. 10
0
 internal static Typeface TypefaceFor(IconChar iconChar)
 {
     return(Orphans.Contains(iconChar) ? null : Typefaces.Find(iconChar.UniCode(), out _, out _));
 }