Esempio n. 1
0
        protected override void OnElementChanged(ElementChangedEventArgs <TabbedPage> e)
        {
            base.OnElementChanged(e);

            if (e.NewElement == null || e.OldElement != null)
            {
                return;
            }

            TabLayout tablayout = (TabLayout)ViewGroup.GetChildAt(1);

            Android.Views.ViewGroup vgroup = (Android.Views.ViewGroup)tablayout.GetChildAt(0);
            for (int i = 0; i < vgroup.ChildCount; i++)
            {
                Android.Views.ViewGroup vvgroup = (Android.Views.ViewGroup)vgroup.GetChildAt(i);
                Typeface fontFace = Typeface.CreateFromAsset(this.Context.Assets, "IranSans.ttf");
                for (int j = 0; j < vvgroup.ChildCount; j++)
                {
                    Android.Views.View vView = (Android.Views.View)vvgroup.GetChildAt(j);
                    if (vView.GetType() == typeof(Android.Support.V7.Widget.AppCompatTextView) || vView.GetType() == typeof(Android.Widget.TextView))
                    {
                        //here change textview style
                        TextView txtView = (TextView)vView;
                        txtView.TextSize = 14f;
                        txtView.SetTypeface(fontFace, TypefaceStyle.Normal);
                    }
                }
            }
        }
Esempio n. 2
0
        internal static IEnumerable <T> GetChildrenOfType <T>(this AViewGroup self)
            where T : AView
        {
            for (int i = 0; i < self.ChildCount; i++)
            {
                AView?child = self.GetChildAt(i);
                if (child == null)
                {
                    continue;
                }


                if (child is T typedChild)
                {
                    yield return(typedChild);
                }

                if (child is AViewGroup childAsViewGroup)
                {
                    IEnumerable <T> myChildren = childAsViewGroup.GetChildrenOfType <T>();
                    foreach (T nextChild in myChildren)
                    {
                        yield return(nextChild);
                    }
                }
            }
        }
 /// <summary>
 /// Traverses document tree to attach listeners to view items marked with "Number" or "Operation" tags.
 /// </summary>
 /// <param name="view"></param>
 private void AttachListeners(Android.Views.View view)
 {
     Android.Views.ViewGroup group = view as Android.Views.ViewGroup;
     if (group != null)
     {
         for (int i = 0; i < group.ChildCount; i++)
         {
             var child      = group.GetChildAt(i);
             var childGroup = child as Android.Views.ViewGroup;
             if (childGroup != null)
             {
                 AttachListeners(childGroup);
             }
             else
             {
                 if (child.Tag != null)
                 {
                     string tag = child.Tag.ToString();
                     if (tag.CompareTo(Globals.CALC_NUMBER) == 0)
                     {
                         child.Click += Number_Click;
                     }
                     else if (tag.CompareTo(Globals.CALC_OPERATION) == 0)
                     {
                         child.Click += Operation_Click;
                     }
                 }
             }
         }
     }
 }
Esempio n. 4
0
        internal static IEnumerable <T> GetChildrenOfType <T>(this AViewGroup self) where T : AView
        {
            for (var i = 0; i < self.ChildCount; i++)
            {
                AView child      = self.GetChildAt(i);
                var   typedChild = child as T;
                if (typedChild != null)
                {
                    yield return(typedChild);
                }

                if (child is AViewGroup)
                {
                    IEnumerable <T> myChildren = (child as AViewGroup).GetChildrenOfType <T>();
                    foreach (T nextChild in myChildren)
                    {
                        yield return(nextChild);
                    }
                }
            }
        }
Esempio n. 5
0
        internal static IEnumerable <T> GetChildrenOfType <T>(this AViewGroup self) where T : AView
        {
            for (var i = 0; i < self.ChildCount; i++)
            {
                var child = self.GetChildAt(i);
                if (child is T typedChild)
                {
                    yield return(typedChild);
                }

                if (!(child is AViewGroup))
                {
                    continue;
                }
                var myChildren = (child as AViewGroup).GetChildrenOfType <T>();
                foreach (var nextChild in myChildren)
                {
                    yield return(nextChild);
                }
            }
        }
Esempio n. 6
0
        public static T?GetFirstChildOfType <T>(this AViewGroup viewGroup) where T : AView
        {
            for (var i = 0; i < viewGroup.ChildCount; i++)
            {
                AView?child = viewGroup.GetChildAt(i);

                if (child is T typedChild)
                {
                    return(typedChild);
                }

                if (child is AViewGroup vg)
                {
                    var descendant = vg.GetFirstChildOfType <T>();
                    if (descendant != null)
                    {
                        return(descendant);
                    }
                }
            }

            return(null);
        }
Esempio n. 7
0
        public static IEnumerable <T> GetChildrenOfType <T>(this AViewGroup viewGroup) where T : AView
        {
            for (var i = 0; i < viewGroup.ChildCount; i++)
            {
                AView?child = viewGroup.GetChildAt(i);

                if (child is T typedChild)
                {
                    yield return(typedChild);
                }

                if (child is AViewGroup)
                {
                    IEnumerable <T>?myChildren = (child as AViewGroup)?.GetChildrenOfType <T>();
                    if (myChildren != null)
                    {
                        foreach (T nextChild in myChildren)
                        {
                            yield return(nextChild);
                        }
                    }
                }
            }
        }