Functionality22.xaml.cs 2.58 KB
Newer Older
Mattia's avatar
Mattia committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
using System;
using System.Collections.Generic;
using SampleApp.DependencyServices;
using Xamarin.Forms;

namespace SampleApp.Views
{
    public partial class Functionality22 : ContentPage
    {
        IAccessibilityHeading Heading;
        IAccessibilityPane Pane;
        public Functionality22()
        {
            InitializeComponent();


            Heading = DependencyService.Get<IAccessibilityHeading>();
            Pane = DependencyService.Get<IAccessibilityPane>();



            if (Device.RuntimePlatform == Device.iOS)
            {
                labelAv.Text = "NOT AVAILABLE ON iOS";
            }

            AutomationProperties.SetIsInAccessibleTree(label1,true);
            AutomationProperties.SetIsInAccessibleTree(label2,true);
            AutomationProperties.SetIsInAccessibleTree(button1,true);
            AutomationProperties.SetIsInAccessibleTree(button2, true);


        }

        //SHOW HEADER BUTTON CLICKED
        void Button_Clicked(System.Object sender, System.EventArgs e)
        {
            if (Device.RuntimePlatform == Device.Android)
            {
                if (Heading.CheckHeading(label1))
                {
                    string labelValue = label1.Text;
                    label1.Text = "HEADER";

                    //reset label value after 3 seconds
                    Device.StartTimer(TimeSpan.FromMilliseconds(3000.0), () =>
                    {
                        label1.Text = labelValue;
                        return false; // runs again, or false to stop
                    });
                }
            }

        }


        //SHOW PANE BUTTON CLICKED
        void Button_Clicked1(System.Object sender, System.EventArgs e)
        {
            if (Device.RuntimePlatform == Device.Android)
            {
                if (Pane.CheckPane(label2))
                {
                    string labelValue = label2.Text;
                    label2.Text = "PANE";

                    //reset label value after 3 seconds
                    Device.StartTimer(TimeSpan.FromMilliseconds(3000.0), () =>
                    {
                        label2.Text = labelValue;
                        return false; // runs again, or false to stop
                    });
                }
            }

        }


        protected override void OnAppearing()
        {
            base.OnAppearing();

            //only Android has this function
            if (Device.RuntimePlatform == Device.Android)
            {
                Heading.SetHeading(label1);

                Pane.SetPane(label2, "PaneTitle");
            }

        }

    }
}