Esempio n. 1
0
        /// Modify this method for adding other examples.
        public FocusIndicatorTest() : base()
        {
            focusmanager = FocusManager.Instance;

            WidthSpecification  = LayoutParamPolicies.MatchParent;
            HeightSpecification = LayoutParamPolicies.MatchParent;

            // Navigator bar title is added here.
            AppBar = new AppBar()
            {
                Title = "Focus Indicator Test",
            };

            // Example root content view.
            // you can decorate, add children on this view.
            rootContent = new View()
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,

                Layout = new LinearLayout()
                {
                    LinearOrientation   = LinearLayout.Orientation.Vertical,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    VerticalAlignment   = VerticalAlignment.Center,
                    CellPadding         = new Size2D(10, 20),
                },
            };

            buttonSetNewIndi = new Button
            {
                WidthSpecification = LayoutParamPolicies.MatchParent,
                Text = "Set New Focus Indicator",
            };
            rootContent.Add(buttonSetNewIndi);

            buttonSetNewIndi.Clicked += (s, e) =>
            {
                focusmanager.FocusIndicator = new View()
                {
                    PositionUsesPivotPoint = true,
                    PivotPoint             = new Position(0, 0, 0),
                    WidthResizePolicy      = ResizePolicyType.FillToParent,
                    HeightResizePolicy     = ResizePolicyType.FillToParent,
                    BorderlineColor        = Color.Orange,
                    BorderlineWidth        = 4.0f,
                    BorderlineOffset       = -1f,
                    BackgroundColor        = new Color(0.2f, 0.2f, 0.2f, 0.2f),
                };
            };

            buttonSetNull = new Button
            {
                WidthSpecification = LayoutParamPolicies.MatchParent,
                Text = "Set null Focus Indicator",
            };
            rootContent.Add(buttonSetNull);

            buttonSetNull.Clicked += (s, e) =>
            {
                focusmanager.FocusIndicator = null;
            };

            buttonRestoreIndi = new Button
            {
                WidthSpecification = LayoutParamPolicies.MatchParent,
                Text = "Restore default Focus Indicator",
            };
            rootContent.Add(buttonRestoreIndi);

            buttonRestoreIndi.Clicked += (s, e) =>
            {
                focusmanager.FocusIndicator = focusmanager.GetDefaultFocusIndicator();
            };

            Content = rootContent;
        }