Exemple #1
0
        public ShellNavBar(IMauiContext context) : base(context?.GetPlatformParent())
        {
            MauiContext = context;

            SetLayoutCallback(OnLayout);

            _menuButton          = new TButton(PlatformParent);
            _menuButton.Clicked += OnMenuClicked;
            _menuIcon            = new MaterialIcon(PlatformParent)
            {
                Color = _foregroundColor.ToCommon()
            };
            UpdateMenuIcon();

            _title = new TLabel(PlatformParent)
            {
                FontSize = this.GetDefaultTitleFontSize(),
                VerticalTextAlignment = (global::Tizen.UIExtensions.Common.TextAlignment)TextAlignment.Center,
                TextColor             = _titleColor.ToCommon(),
                FontAttributes        = Tizen.UIExtensions.Common.FontAttributes.Bold,
            };
            _title.Show();

            BackgroundColor             = _backgroudColor;
            _menuButton.BackgroundColor = _backgroudColor;
            PackEnd(_menuButton);
            PackEnd(_title);
        }
Exemple #2
0
        public ShellNavBar(IMauiContext context) : base(context?.GetNativeParent())
        {
            MauiContext = context;

            _ = NativeParent ?? throw new ArgumentNullException(nameof(NativeParent));

            SetLayoutCallback(OnLayout);

            _menuButton          = new TButton(NativeParent);
            _menuButton.Clicked += OnMenuClicked;

            _menuIcon = new TImage(NativeParent);
            UpdateMenuIcon();

            _title = new TLabel(NativeParent)
            {
                FontSize = this.GetDefaultTitleFontSize(),
                VerticalTextAlignment = (global::Tizen.UIExtensions.Common.TextAlignment)TextAlignment.Center,
                TextColor             = _titleColor.ToCommon(),
                FontAttributes        = Tizen.UIExtensions.Common.FontAttributes.Bold,
            };
            _title.Show();

            BackgroundColor             = _backgroudColor;
            _menuButton.BackgroundColor = _backgroudColor;
            PackEnd(_menuButton);
            PackEnd(_title);
        }
Exemple #3
0
        public MauiImageButton(EvasObject parent) : base(parent)
        {
            _image  = new TImage(parent);
            _button = new TButton(parent);

            _button.Clicked  += OnClicked;
            _button.Pressed  += OnPressed;
            _button.Released += OnReleased;
            _button.SetTransparentStyle();

            Children.Add(_image);
            _image.RaiseTop();

            Children.Add(_button);
            _button.SetTransparentStyle();
            _button.RaiseTop();

            LayoutUpdated += OnLayout;
        }
Exemple #4
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);
        }
Exemple #5
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);
        }