Beispiel #1
0
        void OnActionSheetRequest(Page sender, ActionSheetArguments arguments)
        {
            // Verify that the page making the request is child of this platform
            if (!PageIsInThisContext(sender))
            {
                return;
            }

            var alert = Dialog.CreateDialog(MauiContext.GetPlatformParent());

            alert.Title = arguments.Title;
            var box = new EBox(alert);

            if (null != arguments.Destruction)
            {
                var destruction = new TButton(alert)
                {
                    Text       = arguments.Destruction,
                    AlignmentX = -1
                };
                //TextColor should be set after applying style
                destruction.TextColor = TColor.Red;

                destruction.Clicked += (s, evt) =>
                {
                    arguments.SetResult(arguments.Destruction);
                    alert.Dismiss();
                };
                destruction.Show();
                box.PackEnd(destruction);
            }

            foreach (string buttonName in arguments.Buttons)
            {
                var button = new TButton(alert)
                {
                    Text       = buttonName,
                    AlignmentX = -1
                };

                button.Clicked += (s, evt) =>
                {
                    arguments.SetResult(buttonName);
                    alert.Dismiss();
                };
                button.Show();
                box.PackEnd(button);
            }

            box.Show();
            alert.Content = box;

            if (null != arguments.Cancel)
            {
                var cancel = new TButton(alert)
                {
                    Text = arguments.Cancel
                };
                alert.NegativeButton = cancel;
                cancel.Clicked      += (s, evt) =>
                {
                    alert.Dismiss();
                };
            }

            alert.BackButtonPressed += (s, evt) =>
            {
                alert.Dismiss();
            };

            alert.Show();

            _alerts.Add(alert);
            alert.Dismissed += (s, e) => _alerts.Remove(alert);
        }
Beispiel #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Tizen.UIExtensions.ElmSharp.TVNavigationDrawer"/> class.
        /// </summary>
        /// <param name="parent"></param>
        public TVNavigationDrawer(EvasObject parent) : base(parent)
        {
            SetLayoutCallback(OnLayout);

            _drawerBox = new EBox(parent);
            _drawerBox.Show();
            PackEnd(_drawerBox);

            _mainBox = new EBox(parent);
            _mainBox.SetLayoutCallback(OnMainBoxLayout);
            _mainBox.Show();
            PackEnd(_mainBox);

            _focusControlArea = new Button(parent)
            {
                Color           = EColor.Transparent,
                BackgroundColor = EColor.Transparent
            };
            _focusControlArea.SetEffectColor(EColor.Transparent);
            _focusControlArea.Show();
            _mainBox.PackEnd(_focusControlArea);

            _behavior = Common.DrawerBehavior.Drawer;

            _drawerBox.KeyUp += (s, e) =>
            {
                if (e.KeyName == "Return" || e.KeyName == "Right")
                {
                    IsOpen = false;
                }
            };

            _mainBox.KeyUp += (s, e) =>
            {
                if (e.KeyName == "Left")
                {
                    if (_focusControlArea.IsFocused)
                    {
                        IsOpen = true;
                    }
                }
                else
                {
                    // Workaround to prevent unexpected movement of the focus to drawer during page pushing.
                    if (_behavior == DrawerBehavior.Locked)
                    {
                        _drawerBox.AllowTreeFocus = true;
                    }
                }
            };

            _mainBox.KeyDown += (s, e) =>
            {
                if (e.KeyName != "Left")
                {
                    // Workaround to prevent unexpected movement of the focus to drawer during page pushing.
                    if (_behavior == DrawerBehavior.Locked)
                    {
                        _drawerBox.AllowTreeFocus = false;
                    }
                }
            };

            UpdateFocusPolicy();
        }
Beispiel #3
0
        public override void Run(ElmSharp.Box parent)
        {
            var scrollView = new ScrollView(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
                VerticalScrollBarVisibility = ScrollBarVisibility.Always,
            };

            scrollView.Show();

            var content = new ElmSharp.Box(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
            };

            scrollView.SetScrollCanvas(content);
            parent.PackEnd(scrollView);

            var ellipseText1 = new ElmSharp.Label(parent)
            {
                WeightX = 1,
                WeightY = 1,
                Text    = "EllipseView with SolidBrush"
            };

            ellipseText1.Show();
            var ellipse1 = new EllipseView(parent)
            {
                WeightX         = 1,
                WeightY         = 1,
                AlignmentY      = -1,
                AlignmentX      = -1,
                Stroke          = new SolidColorBrush(Color.Maroon),
                StrokeThickness = 5,
                Fill            = new SolidColorBrush(Color.Lavender),
                Aspect          = Stretch.Uniform,
            };

            ellipse1.Show();

            content.PackEnd(ellipseText1);
            content.PackEnd(ellipse1);

            var ellipseText2 = new ElmSharp.Label(parent)
            {
                WeightX = 1,
                WeightY = 1,
                Text    = "EllipseView with GradientBrush"
            };

            ellipseText2.Show();
            var ellipse2 = new EllipseView(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
                Stroke     = new LinearGradientBrush(new System.Collections.Generic.List <GradientStop>()
                {
                    new GradientStop(Color.Lavender, 0.2f),
                    new GradientStop(Color.LightSkyBlue, 0.4f),
                    new GradientStop(Color.LightCyan, 0.6f),
                    new GradientStop(Color.LightPink, 0.8f),
                    new GradientStop(Color.YellowGreen, 1.0f),
                }),
                Fill = new RadialGradientBrush(new System.Collections.Generic.List <GradientStop>()
                {
                    new GradientStop(Color.YellowGreen, 0.2f),
                    new GradientStop(Color.LightPink, 0.4f),
                    new GradientStop(Color.LightCyan, 0.6f),
                    new GradientStop(Color.LightSkyBlue, 0.8f),
                    new GradientStop(Color.Lavender, 1.0f),
                }),
                StrokeThickness = 15,
                Aspect          = Stretch.Fill,
            };

            ellipse2.Show();
            content.PackEnd(ellipseText2);
            content.PackEnd(ellipse2);

            var ellipseText3 = new ElmSharp.Label(parent)
            {
                WeightX = 1,
                WeightY = 1,
                Text    = "EllipseView Aspect Test"
            };

            ellipseText3.Show();
            var ellipse3 = new EllipseView(parent)
            {
                WeightX         = 1,
                WeightY         = 1,
                AlignmentY      = -1,
                AlignmentX      = -1,
                Stroke          = new SolidColorBrush(Color.PaleGoldenrod),
                StrokeThickness = 5,
                Fill            = new SolidColorBrush(Color.MediumPurple),
                Aspect          = Stretch.Fill
            };

            ellipse3.Show();
            var aspectButton = new Button(parent)
            {
                Text       = "Change Aspect",
                WeightX    = 0.5,
                WeightY    = 0.5,
                AlignmentY = -1,
                AlignmentX = -1,
            };

            aspectButton.Show();
            aspectButton.Clicked += (s, e) =>
            {
                switch (ellipse3.Aspect)
                {
                case (Stretch.Fill):
                    ellipse3.Aspect = Stretch.Uniform;
                    break;

                case (Stretch.Uniform):
                    ellipse3.Aspect = Stretch.UniformToFill;
                    break;

                case (Stretch.UniformToFill):
                    ellipse3.Aspect = Stretch.Fill;
                    break;
                }
            };

            content.PackEnd(ellipseText3);
            content.PackEnd(ellipse3);
            content.PackEnd(aspectButton);
        }
        public override void Run(ElmSharp.Box parent)
        {
            var scrollBox = new ElmSharp.Box(parent)
            {
                IsHorizontal  = true,
                WeightX       = 1,
                AlignmentX    = -1,
                MinimumHeight = 100,
            };

            scrollBox.Show();
            var menuScroll = new ScrollView(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
                HorizontalScrollBarVisibility = ScrollBarVisibility.Default,
            };

            menuScroll.Show();
            scrollBox.PackEnd(menuScroll);
            var menu = new ElmSharp.Box(parent)
            {
                IsHorizontal  = true,
                WeightX       = 1,
                AlignmentX    = -1,
                MinimumHeight = 100,
            };

            menu.Show();
            menuScroll.SetScrollCanvas(menu);
            menuScroll.SetContentSize(200 * 5, 100);
            parent.PackEnd(scrollBox);

            var scrollview = new ScrollView(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
            };

            scrollview.Show();
            scrollview.ScrollOrientation             = ScrollOrientation.Both;
            scrollview.VerticalScrollBarVisibility   = ScrollBarVisibility.Always;
            scrollview.HorizontalScrollBarVisibility = ScrollBarVisibility.Always;

            var scrollCanvas = new ElmSharp.Box(parent)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };

            scrollCanvas.Show();
            scrollview.SetScrollCanvas(scrollCanvas);

            int itemWidth  = 500;
            int itemHeight = 500;

            int itemCols = 5;
            int itemRows = 5;

            scrollview.SetContentSize(itemWidth * itemCols, itemHeight * itemRows);

            for (int i = 0; i < itemRows; i++)
            {
                var innerContainer = new ElmSharp.Box(parent)
                {
                    IsHorizontal = true,
                    AlignmentX   = -1,
                    AlignmentY   = -1,
                    WeightX      = 1,
                    WeightY      = 1,
                };
                innerContainer.Show();
                for (int j = 0; j < itemCols; j++)
                {
                    var rnd  = new Random();
                    var item = new Rectangle(parent)
                    {
                        MinimumHeight = itemHeight,
                        MinimumWidth  = itemWidth,
                        Color         = ElmSharp.Color.FromRgb(rnd.Next(10, 255), rnd.Next(10, 255), rnd.Next(10, 255))
                    };
                    item.Show();
                    innerContainer.PackEnd(item);
                }
                scrollCanvas.PackEnd(innerContainer);
            }
            parent.PackEnd(scrollview);

            // menu button
            var scrollToBtn = new Button(parent)
            {
                AlignmentY   = -1,
                WeightX      = 1,
                FontSize     = 30,
                Text         = "Scroll(rnd)",
                MinimumWidth = 200,
            };

            scrollToBtn.Show();
            scrollToBtn.Clicked += (s, e) =>
            {
                var rnd = new Random();
                scrollview.ScrollToAsync(new Rect(rnd.Next(0, itemCols * itemWidth), rnd.Next(0, itemRows * itemHeight), itemWidth, itemHeight), true);
            };
            menu.PackEnd(scrollToBtn);

            var vBar = new Button(parent)
            {
                AlignmentY   = -1,
                WeightX      = 1,
                FontSize     = 30,
                Text         = "V-bar(O)",
                MinimumWidth = 200,
            };

            vBar.Show();
            vBar.Clicked += (s, e) =>
            {
                if (scrollview.VerticalScrollBarVisibility == ScrollBarVisibility.Always)
                {
                    vBar.Text = "V-bar(X)";
                    scrollview.VerticalScrollBarVisibility = ScrollBarVisibility.Never;
                }
                else
                {
                    vBar.Text = "V-bar(O)";
                    scrollview.VerticalScrollBarVisibility = ScrollBarVisibility.Always;
                }
            };
            menu.PackEnd(vBar);

            var hBar = new Button(parent)
            {
                AlignmentY   = -1,
                WeightX      = 1,
                FontSize     = 30,
                Text         = "H-bar(O)",
                MinimumWidth = 200,
            };

            hBar.Show();
            hBar.Clicked += (s, e) =>
            {
                if (scrollview.HorizontalScrollBarVisibility == ScrollBarVisibility.Always)
                {
                    hBar.Text = "H-bar(X)";
                    scrollview.HorizontalScrollBarVisibility = ScrollBarVisibility.Never;
                }
                else
                {
                    hBar.Text = "H-bar(O)";
                    scrollview.HorizontalScrollBarVisibility = ScrollBarVisibility.Always;
                }
            };
            menu.PackEnd(hBar);


            var vScroll = new Button(parent)
            {
                AlignmentY   = -1,
                WeightX      = 1,
                FontSize     = 30,
                Text         = "V-Scroll(O)",
                MinimumWidth = 200,
            };

            vScroll.Show();
            vScroll.Clicked += (s, e) =>
            {
                if (scrollview.ScrollOrientation == ScrollOrientation.Horizontal || scrollview.ScrollOrientation == ScrollOrientation.Neither)
                {
                    vScroll.Text = "V-Scroll(O)";
                    scrollview.ScrollOrientation = scrollview.ScrollOrientation == ScrollOrientation.Horizontal ? ScrollOrientation.Both : ScrollOrientation.Vertical;
                }
                else
                {
                    vScroll.Text = "V-Scroll(X)";
                    scrollview.ScrollOrientation = scrollview.ScrollOrientation == ScrollOrientation.Both ? ScrollOrientation.Horizontal : ScrollOrientation.Neither;
                }
            };
            menu.PackEnd(vScroll);

            var hScroll = new Button(parent)
            {
                AlignmentY   = -1,
                WeightX      = 1,
                FontSize     = 30,
                Text         = "H-Scroll(O)",
                MinimumWidth = 200,
            };

            hScroll.Show();
            hScroll.Clicked += (s, e) =>
            {
                if (scrollview.ScrollOrientation == ScrollOrientation.Vertical || scrollview.ScrollOrientation == ScrollOrientation.Neither)
                {
                    hScroll.Text = "H-Scroll(O)";
                    scrollview.ScrollOrientation = scrollview.ScrollOrientation == ScrollOrientation.Vertical ? ScrollOrientation.Both : ScrollOrientation.Horizontal;
                }
                else
                {
                    hScroll.Text = "H-Scroll(X)";
                    scrollview.ScrollOrientation = scrollview.ScrollOrientation == ScrollOrientation.Both ? ScrollOrientation.Vertical : ScrollOrientation.Neither;
                }
            };
            menu.PackEnd(hScroll);
        }