示例#1
0
        public NotClosedPopup()
        {
            BackgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.7f).ToNative();
            Layout          = new LinearLayout
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
            };

            Content = new Label
            {
                TextColor = Tizen.UIExtensions.Common.Color.White,
                Text      = "This Popup is not closed until 5 seconds"
            };
        }
示例#2
0
        public override View CreateNativeView(int index)
        {
            Console.WriteLine($"CreateNativeView... for {index}");

            var rnd  = new Random();
            var view = new View();

            view.UpdateBackgroundColor(Color.FromRgb(rnd.Next(10, 255), rnd.Next(10, 255), rnd.Next(10, 255)));

            view.Add(new TextLabel
            {
                Text = $"Text for{index}"
            });
            return(view);
        }
        public override View Run()
        {
            var view = new View
            {
                Layout = new LinearLayout
                {
                    LinearAlignment   = LinearLayout.Alignment.Center,
                    LinearOrientation = LinearLayout.Orientation.Vertical,
                }
            };
            var menu = new View
            {
                Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Horizontal
                },
                SizeHeight         = 200,
                WidthSpecification = LayoutParamPolicies.MatchParent,
                BackgroundColor    = Color.Green.ToNative()
            };

            view.Add(menu);


            var scrollView = new ScrollView()
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
            };

            int itemWidth  = 300;
            int itemHeight = 300;
            int itemCols   = 10;
            int itemRows   = 10;

            var outterLayout = new View
            {
                Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Vertical,
                },
                SizeWidth  = itemWidth * itemCols,
                SizeHeight = itemHeight * itemRows
            };

            scrollView.Add(outterLayout);

            for (int i = 0; i < itemRows; i++)
            {
                var innerLayout = new View
                {
                    Layout = new LinearLayout
                    {
                        LinearOrientation = LinearLayout.Orientation.Horizontal,
                    },
                    SizeHeight = itemHeight,
                    SizeWidth  = itemWidth * itemCols,
                };
                for (int j = 0; j < itemCols; j++)
                {
                    var rnd  = new Random();
                    var item = new View
                    {
                        SizeWidth       = itemWidth,
                        SizeHeight      = itemHeight,
                        BackgroundColor = Color.FromRgb(rnd.Next(10, 255), rnd.Next(10, 255), rnd.Next(10, 255)).ToNative()
                    };
                    innerLayout.Add(item);
                }
                outterLayout.Add(innerLayout);
            }
            scrollView.ScrollingEventThreshold = 1;
            scrollView.ScrollDragStarted      += (s, e) => Console.WriteLine($"DragStarted");
            scrollView.ScrollDragEnded        += (s, e) => Console.WriteLine("DragEnd");
            scrollView.ScrollAnimationStarted += (s, e) => Console.WriteLine($"ScrollAnimation started");
            scrollView.ScrollAnimationEnded   += (s, e) => Console.WriteLine("$ScrollAnimation ended");
            scrollView.Scrolling += (s, e) =>
            {
                Console.WriteLine($"OnScrolling : Bound : {scrollView.ScrollBound} - {e.Position.X}x{e.Position.Y}");
            };


            var direction = new Button()
            {
                Text       = "direction(V)",
                SizeHeight = 300,
                SizeWidth  = 300,
            };

            direction.Clicked += (s, e) =>
            {
                if (scrollView.ScrollOrientation == ScrollOrientation.Horizontal)
                {
                    scrollView.ScrollOrientation = ScrollOrientation.Vertical;
                    direction.Text = "direction(V)";
                }
                else
                {
                    scrollView.ScrollOrientation = ScrollOrientation.Horizontal;
                    direction.Text = "direction(H)";
                }
            };
            menu.Add(direction);

            var scrollBar = new Button()
            {
                Text       = "Bar(Never)",
                SizeHeight = 300,
                SizeWidth  = 300,
            };

            scrollBar.Clicked += (s, e) =>
            {
                if (scrollView.VerticalScrollBarVisibility == ScrollBarVisibility.Never)
                {
                    scrollView.VerticalScrollBarVisibility = ScrollBarVisibility.Default;
                    scrollBar.Text = "Bar(Default)";
                }
                else if (scrollView.VerticalScrollBarVisibility == ScrollBarVisibility.Default)
                {
                    scrollView.VerticalScrollBarVisibility = ScrollBarVisibility.Always;
                    scrollBar.Text = "Bar(Always)";
                }
                else if (scrollView.VerticalScrollBarVisibility == ScrollBarVisibility.Always)
                {
                    scrollView.VerticalScrollBarVisibility = ScrollBarVisibility.Never;
                    scrollBar.Text = "Bar(Never)";
                }
            };
            menu.Add(scrollBar);


            view.Add(scrollView);
            return(view);
        }
        protected override View CreateContent()
        {
            Layout = new LinearLayout
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
            };

            BackgroundColor = new TColor(0.1f, 0.1f, 0.1f, 0.5f).ToNative();
            var margin1 = (ushort)20d.ToPixel();
            var margin2 = (ushort)10d.ToPixel();
            var radius  = 8d.ToPixel();

            var isHorizontal = Window.Instance.WindowSize.Width > Window.Instance.WindowSize.Height;
            // container
            var content = new View
            {
                CornerRadius = radius,
                BoxShadow    = new Shadow(20d.ToPixel(), TColor.FromHex("#333333").ToNative()),
                Layout       = new LinearLayout
                {
                    VerticalAlignment   = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    LinearOrientation   = LinearLayout.Orientation.Vertical,
                },
                SizeWidth       = Window.Instance.WindowSize.Width * (isHorizontal ? 0.5f : 0.8f),
                BackgroundColor = TColor.White.ToNative(),
            };

            // title
            content.Add(new Label
            {
                Text                    = _title,
                Margin                  = new Extents(margin1, margin1, margin1, margin2),
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
                FontAttributes          = FontAttributes.Bold,
                TextColor               = TColor.FromHex("#000000"),
                PixelSize               = 21d.ToPixel(),
            });

            // message
            content.Add(new Label
            {
                Text               = _message,
                Margin             = new Extents(margin1, margin1, 0, margin2),
                LineBreakMode      = LineBreakMode.CharacterWrap,
                PixelSize          = 16d.ToPixel(),
                WidthSpecification = LayoutParamPolicies.MatchParent,
            });

            var hlayout = new View
            {
                Margin = new Extents(margin1, margin1, 0, margin1),
                Layout = new LinearLayout
                {
                    VerticalAlignment   = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.End,
                    LinearOrientation   = LinearLayout.Orientation.Horizontal,
                },
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.WrapContent
            };

            content.Add(hlayout);

            var cancelButton = new Button
            {
                Text                = _cancel,
                Focusable           = true,
                HeightSpecification = LayoutParamPolicies.WrapContent,
                TextColor           = TColor.Black,
                BackgroundColor     = TColor.Transparent.ToNative(),
            };

            cancelButton.TextLabel.PixelSize = 15d.ToPixel();
            cancelButton.SizeWidth           = cancelButton.TextLabel.NaturalSize.Width + 15d.ToPixel() * 2;
            cancelButton.Clicked            += (s, e) => SendSubmit(false);
            hlayout.Add(cancelButton);

            if (_accept != null)
            {
                var acceptButton = new Button
                {
                    Margin              = new Extents(margin2, 0, 0, 0),
                    Text                = _accept,
                    Focusable           = true,
                    HeightSpecification = LayoutParamPolicies.WrapContent,
                    TextColor           = TColor.Black,
                    BackgroundColor     = TColor.Transparent.ToNative(),
                };
                acceptButton.TextLabel.PixelSize = 15d.ToPixel();
                acceptButton.SizeWidth           = acceptButton.TextLabel.NaturalSize.Width + 15d.ToPixel() * 2;
                acceptButton.Clicked            += (s, e) => SendSubmit(true);
                hlayout.Add(acceptButton);
            }

            Relayout += (s, e) =>
            {
                var isHorizontal = Window.Instance.WindowSize.Width > Window.Instance.WindowSize.Height;
                content.SizeWidth = Window.Instance.WindowSize.Width * (isHorizontal ? 0.5f : 0.8f);
            };

            return(content);
        }
示例#5
0
        public override View Run()
        {
            var view = new View
            {
                Layout = new LinearLayout
                {
                    LinearAlignment   = LinearLayout.Alignment.Center,
                    LinearOrientation = LinearLayout.Orientation.Vertical,
                }
            };
            var menu = new View
            {
                Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Horizontal
                },
                SizeHeight         = 200,
                WidthSpecification = LayoutParamPolicies.MatchParent,
                BackgroundColor    = Color.Green.ToNative()
            };

            view.Add(menu);


            var scrollView = new ScrollView()
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
            };

            int itemWidth  = 300;
            int itemHeight = 300;
            int itemCols   = 10;
            int itemRows   = 10;

            var outterLayout = new View
            {
                Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Vertical,
                },
                SizeWidth  = itemWidth * itemCols,
                SizeHeight = itemHeight * itemRows
            };

            scrollView.Add(outterLayout);

            for (int i = 0; i < itemRows; i++)
            {
                var innerLayout = new View
                {
                    Layout = new LinearLayout
                    {
                        LinearOrientation = LinearLayout.Orientation.Horizontal,
                    },
                    SizeHeight = itemHeight,
                    SizeWidth  = itemWidth * itemCols,
                };
                for (int j = 0; j < itemCols; j++)
                {
                    var rnd  = new Random();
                    var item = new View
                    {
                        SizeWidth       = itemWidth,
                        SizeHeight      = itemHeight,
                        BackgroundColor = Color.FromRgb(rnd.Next(10, 255), rnd.Next(10, 255), rnd.Next(10, 255)).ToNative()
                    };
                    innerLayout.Add(item);
                }
                outterLayout.Add(innerLayout);
            }

            scrollView.Scrolling += (s, e) =>
            {
                Console.WriteLine($"OnScrolling : Bound : {scrollView.ScrollBound}");
            };


            var direction = new Button()
            {
                Text       = "direction(V)",
                SizeHeight = 300,
                SizeWidth  = 300,
            };

            direction.Clicked += (s, e) =>
            {
                if (scrollView.ScrollOrientation == ScrollOrientation.Horizontal)
                {
                    scrollView.ScrollOrientation = ScrollOrientation.Vertical;
                    direction.Text = "direction(V)";
                }
                else
                {
                    scrollView.ScrollOrientation = ScrollOrientation.Horizontal;
                    direction.Text = "direction(H)";
                }
            };
            menu.Add(direction);

            var scrollBar = new Button()
            {
                Text       = "Bar(X)",
                SizeHeight = 300,
                SizeWidth  = 300,
            };

            scrollBar.Clicked += (s, e) =>
            {
                if (scrollView.HideScrollbar)
                {
                    scrollView.HideScrollbar = false;
                    scrollBar.Text           = "Bar(O)";
                }
                else
                {
                    scrollView.HideScrollbar = true;
                    scrollBar.Text           = "Bar(X)";
                }
            };
            menu.Add(scrollBar);


            view.Add(scrollView);
            return(view);
        }
示例#6
0
        public override View Run()
        {
            var view = new View
            {
                BackgroundColor = Color.FromHex("#F9AA33").ToNative(),
                Layout          = new LinearLayout
                {
                    LinearAlignment   = LinearLayout.Alignment.Center,
                    LinearOrientation = LinearLayout.Orientation.Vertical,
                }
            };
            var btn1 = new Button
            {
                Text     = "Open popup",
                FontSize = 10,
            };

            view.Add(btn1);
            btn1.Clicked += (s, e) =>
            {
                Popup popup = MakeSimplePopup();
                popup.Open();

                popup.OutsideClicked += (ss, ee) =>
                {
                    Console.WriteLine($"Popup outside clicked");
                };
                popup.Closed += (_, __) =>
                {
                    Console.WriteLine($"Popup is clsoed");
                };
            };

            var btn2 = new Button
            {
                Text = "Open popup 2"
            };

            view.Add(btn2);

            btn2.Clicked += (s, e) =>
            {
                Popup popup = new Popup
                {
                    BackgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.5f).ToNative(),
                    Layout          = new LinearLayout
                    {
                        LinearAlignment = LinearLayout.Alignment.Center
                    },
                };
                var content = new View
                {
                    Layout = new LinearLayout
                    {
                        LinearOrientation = LinearLayout.Orientation.Vertical,
                    },
                    BackgroundColor     = Color.White.ToNative(),
                    SizeWidth           = 500,
                    HeightSpecification = LayoutParamPolicies.WrapContent
                };

                var title = new Label
                {
                    Text = "Title",
                    WidthSpecification      = LayoutParamPolicies.MatchParent,
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    FontAttributes          = FontAttributes.Bold,
                    TextColor  = Color.White,
                    FontSize   = 12,
                    SizeHeight = 80,
                };
                title.UpdateBackgroundColor(Color.FromHex("#344955"));
                content.Add(title);
                var text = new Label
                {
                    LineBreakMode      = LineBreakMode.CharacterWrap,
                    Margin             = new Extents(10, 10, 10, 10),
                    Text               = "message... message.... ddddd dddccc dccccc",
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                };
                content.Add(text);
                var btn = new Button
                {
                    Margin = new Extents(10, 10, 10, 10),
                    Text   = "Close",
                    HeightSpecification = LayoutParamPolicies.WrapContent,
                };
                btn.Clicked += (ss, ee) =>
                {
                    popup.Close();
                };
                var hlayout = new View
                {
                    Layout = new LinearLayout
                    {
                        LinearAlignment   = LinearLayout.Alignment.Center,
                        LinearOrientation = LinearLayout.Orientation.Horizontal,
                    },
                    WidthSpecification  = LayoutParamPolicies.MatchParent,
                    HeightSpecification = LayoutParamPolicies.WrapContent
                };
                hlayout.Add(btn);
                content.Add(hlayout);

                popup.Content = content;
                popup.Open();

                popup.OutsideClicked += (ss, ee) =>
                {
                    Console.WriteLine($"Popup outside clicked");
                };
            };


            var btn3 = new Button
            {
                Text = "Yes/No"
            };

            view.Add(btn3);

            btn3.Clicked += (s, e) =>
            {
                Popup popup = new Popup
                {
                    BackgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.5f).ToNative(),
                    Layout          = new LinearLayout
                    {
                        LinearAlignment = LinearLayout.Alignment.Center
                    },
                };
                var content = new View
                {
                    Layout = new LinearLayout
                    {
                        LinearOrientation = LinearLayout.Orientation.Vertical,
                    },
                    BackgroundColor     = Color.White.ToNative(),
                    WidthSpecification  = LayoutParamPolicies.WrapContent,
                    HeightSpecification = LayoutParamPolicies.WrapContent
                };

                var title = new Label
                {
                    Text = "Choose",
                    WidthSpecification      = LayoutParamPolicies.MatchParent,
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    FontAttributes          = FontAttributes.Bold,
                    TextColor  = Color.White,
                    FontSize   = 12,
                    SizeHeight = 80,
                };
                title.UpdateBackgroundColor(Color.FromHex("#344955"));
                content.Add(title);
                var text = new Label
                {
                    LineBreakMode      = LineBreakMode.CharacterWrap,
                    Margin             = new Extents(10, 10, 10, 10),
                    Text               = "Do you want exit?",
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                };
                content.Add(text);
                var btn = new Button
                {
                    Margin = new Extents(10, 10, 10, 10),
                    Text   = "Yes",
                    HeightSpecification = LayoutParamPolicies.WrapContent,
                    SizeWidth           = 200,
                };
                btn.Clicked += (ss, ee) =>
                {
                    popup.Close();
                };
                var hlayout = new View
                {
                    Layout = new LinearLayout
                    {
                        LinearAlignment   = LinearLayout.Alignment.Center,
                        LinearOrientation = LinearLayout.Orientation.Horizontal,
                    },
                    WidthSpecification  = LayoutParamPolicies.MatchParent,
                    HeightSpecification = LayoutParamPolicies.WrapContent
                };
                hlayout.Add(btn);

                var no = new Button
                {
                    Margin = new Extents(10, 10, 10, 10),
                    Text   = "No",
                    HeightSpecification = LayoutParamPolicies.WrapContent,
                    SizeWidth           = 200,
                };
                no.Clicked += (ss, ee) =>
                {
                    popup.Close();
                };
                hlayout.Add(no);

                content.Add(hlayout);

                popup.Content = content;
                popup.Open();

                popup.OutsideClicked += (ss, ee) =>
                {
                    Console.WriteLine($"Popup outside clicked");
                };
            };



            var btn4 = new Button
            {
                Text = "Nested popup"
            };

            view.Add(btn4);

            btn4.Clicked += (s, e) =>
            {
                Popup popup = new Popup
                {
                    BackgroundColor = new Color(0.1f, 0.1f, 0.1f, 0.5f).ToNative(),
                    Layout          = new LinearLayout
                    {
                        LinearAlignment = LinearLayout.Alignment.Center
                    },
                };
                var content = new View
                {
                    Layout = new LinearLayout
                    {
                        LinearOrientation = LinearLayout.Orientation.Vertical,
                    },
                    BackgroundColor     = Color.White.ToNative(),
                    SizeWidth           = 500,
                    HeightSpecification = LayoutParamPolicies.WrapContent
                };

                var title = new Label
                {
                    Text = "Nested",
                    WidthSpecification      = LayoutParamPolicies.MatchParent,
                    HorizontalTextAlignment = TextAlignment.Center,
                    VerticalTextAlignment   = TextAlignment.Center,
                    FontAttributes          = FontAttributes.Bold,
                    TextColor  = Color.White,
                    FontSize   = 12,
                    SizeHeight = 80,
                };
                title.UpdateBackgroundColor(Color.FromHex("#344955"));
                content.Add(title);
                var text = new Label
                {
                    LineBreakMode      = LineBreakMode.CharacterWrap,
                    Margin             = new Extents(10, 10, 10, 10),
                    Text               = "first popup ---------------- asfdasfd-asfd- asdfa",
                    SizeHeight         = 600,
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                };
                content.Add(text);
                var btn = new Button
                {
                    Margin = new Extents(10, 10, 10, 10),
                    Text   = "Open second",
                    HeightSpecification = LayoutParamPolicies.WrapContent,
                };
                btn.Clicked += (ss, ee) =>
                {
                    MakeSimplePopup().Open();
                };
                var hlayout = new View
                {
                    Layout = new LinearLayout
                    {
                        LinearAlignment   = LinearLayout.Alignment.Center,
                        LinearOrientation = LinearLayout.Orientation.Horizontal,
                    },
                    WidthSpecification  = LayoutParamPolicies.MatchParent,
                    HeightSpecification = LayoutParamPolicies.WrapContent
                };
                hlayout.Add(btn);
                content.Add(hlayout);

                popup.Content = content;
                popup.Open();

                popup.OutsideClicked += (ss, ee) =>
                {
                    Console.WriteLine($"Popup outside clicked");
                };
            };


            var btn5 = new Button
            {
                Text = "Unclosed pupup"
            };

            view.Add(btn5);
            btn5.Clicked += (s, e) =>
            {
                var popup = new NotClosedPopup();

                popup.Open();
            };
            return(view);
        }
示例#7
0
        protected override View CreateContent()
        {
            Layout = new LinearLayout
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center
            };
            BackgroundColor = new TColor(0.1f, 0.1f, 0.1f, 0.5f).ToNative();
            var margin1 = (ushort)20d.ToPixel();
            var margin2 = (ushort)10d.ToPixel();
            var radius  = 8d.ToPixel();

            var isHorizontal = Window.Instance.WindowSize.Width > Window.Instance.WindowSize.Height;
            // container
            var content = new View
            {
                CornerRadius = radius,
                BoxShadow    = new Shadow(20d.ToPixel(), TColor.Black.ToNative()),
                Layout       = new LinearLayout
                {
                    VerticalAlignment   = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    LinearOrientation   = LinearLayout.Orientation.Vertical,
                },
                SizeWidth       = Window.Instance.WindowSize.Width * (isHorizontal ? 0.5f : 0.8f),
                BackgroundColor = TColor.White.ToNative(),
            };

            // title
            content.Add(new Label
            {
                Text                    = _title,
                Margin                  = new Extents(margin1, margin1, margin1, margin2),
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
                FontAttributes          = FontAttributes.Bold,
                TextColor               = TColor.FromHex("#000000"),
                PixelSize               = 21d.ToPixel(),
            });

            // message
            content.Add(new Label
            {
                Text               = _message,
                Margin             = new Extents(margin1, margin1, 0, margin2),
                LineBreakMode      = LineBreakMode.CharacterWrap,
                PixelSize          = 16d.ToPixel(),
                WidthSpecification = LayoutParamPolicies.MatchParent,
            });

            var entry = new Entry
            {
                Margin                = new Extents(margin1, margin1, 0, margin2),
                Text                  = _initialValue,
                Keyboard              = _keyboard,
                Placeholder           = _placeholder ?? "",
                WidthSpecification    = LayoutParamPolicies.MatchParent,
                PlaceholderColor      = TColor.FromRgb(100, 100, 100),
                VerticalTextAlignment = TextAlignment.Center,
                SizeHeight            = 40d.ToPixel(),
                PixelSize             = 16d.ToPixel(),
                BackgroundColor       = TColor.FromRgb(220, 220, 220).ToNative(),
            };

            if (_maxLength != -1)
            {
                entry.MaxLength = _maxLength;
            }
            content.Add(entry);

            var hlayout = new View
            {
                Margin = new Extents(margin1, margin1, 0, margin1),
                Layout = new LinearLayout
                {
                    HorizontalAlignment = HorizontalAlignment.End,
                    LinearOrientation   = LinearLayout.Orientation.Horizontal,
                },
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.WrapContent
            };

            content.Add(hlayout);

            var cancelButton = new Button
            {
                Text      = _cancel,
                Focusable = true,

                SizeWidth           = (_cancel.Length + 1) * 15d.ToPixel(),
                HeightSpecification = LayoutParamPolicies.WrapContent,

                TextColor       = TColor.Black,
                BackgroundColor = TColor.Transparent.ToNative(),
            };

            cancelButton.TextLabel.PixelSize = 15d.ToPixel();
            cancelButton.SizeWidth           = cancelButton.TextLabel.NaturalSize.Width + 15d.ToPixel() * 2;

            cancelButton.Clicked += (s, e) => SendCancel();
            hlayout.Add(cancelButton);

            var acceptButton = new Button
            {
                Text      = _accept,
                Focusable = true,

                SizeWidth           = (_accept.Length + 1) * 15d.ToPixel(),
                HeightSpecification = LayoutParamPolicies.WrapContent,
                Margin = new Extents(40, 0, 0, 0),

                TextColor       = TColor.Black,
                BackgroundColor = TColor.Transparent.ToNative(),
            };

            acceptButton.TextLabel.PixelSize = 15d.ToPixel();
            acceptButton.SizeWidth           = acceptButton.TextLabel.NaturalSize.Width + 15d.ToPixel() * 2;

            acceptButton.Clicked += (s, e) => SendSubmit(entry.Text);
            hlayout.Add(acceptButton);

            Relayout += (s, e) =>
            {
                var isHorizontal = Window.Instance.WindowSize.Width > Window.Instance.WindowSize.Height;
                content.SizeWidth = Window.Instance.WindowSize.Width * (isHorizontal ? 0.5f : 0.8f);
            };

            return(content);
        }
示例#8
0
        protected override View CreateContent()
        {
            Layout = new LinearLayout
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
            };

            BackgroundColor = new TColor(0.1f, 0.1f, 0.1f, 0.5f).ToNative();
            var margin1 = (ushort)20d.ToPixel();
            var margin2 = (ushort)10d.ToPixel();
            var radius  = 8d.ToPixel();

            var isHorizontal = Window.Instance.WindowSize.Width > Window.Instance.WindowSize.Height;
            // container
            var content = new View
            {
                CornerRadius = radius,
                BoxShadow    = new Shadow(20d.ToPixel(), TColor.Black.ToNative()),
                Layout       = new LinearLayout
                {
                    VerticalAlignment   = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.Center,
                    LinearOrientation   = LinearLayout.Orientation.Vertical,
                },
                SizeWidth       = Window.Instance.WindowSize.Width * (isHorizontal ? 0.5f : 0.8f),
                BackgroundColor = TColor.White.ToNative(),
            };

            // title
            content.Add(new Label
            {
                Text                    = _title,
                Margin                  = new Extents(margin1, margin1, margin1, margin2),
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HorizontalTextAlignment = TextAlignment.Start,
                VerticalTextAlignment   = TextAlignment.Center,
                FontAttributes          = FontAttributes.Bold,
                TextColor               = TColor.FromHex("#000000"),
                PixelSize               = 21d.ToPixel(),
            });

            if (_buttons != null)
            {
                // separator
                content.Add(new View
                {
                    BackgroundColor    = TColor.FromHex("#cccccc").ToNative(),
                    SizeHeight         = 1.5d.ToPixel(),
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                });

                var scrollview = new ScrollView
                {
                    Margin = new Extents(margin1, margin1, 0, 0),
                    VerticalScrollBarVisibility = ScrollBarVisibility.Default,
                    WidthSpecification          = LayoutParamPolicies.MatchParent,
                };
                scrollview.ContentContainer.Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Vertical,
                };
                content.Add(scrollview);

                foreach (var item in _buttons)
                {
                    var itemLabel = new Label
                    {
                        Text      = item,
                        Focusable = true,
                        HorizontalTextAlignment = TextAlignment.Start,
                        PixelSize           = 16d.ToPixel(),
                        WidthSpecification  = LayoutParamPolicies.MatchParent,
                        HeightSpecification = LayoutParamPolicies.WrapContent,
                        Margin = new Extents(0, 0, (ushort)5d.ToPixel(), (ushort)5d.ToPixel()),
                    };
                    itemLabel.TouchEvent += (s, e) =>
                    {
                        var state = e.Touch.GetState(0);
                        if (state == PointStateType.Up && itemLabel.IsInside(e.Touch.GetLocalPosition(0)))
                        {
                            SendSubmit(item);
                            return(true);
                        }
                        return(false);
                    };
                    itemLabel.KeyEvent += (s, e) =>
                    {
                        if (e.Key.IsAcceptKeyEvent())
                        {
                            SendSubmit(item);
                            return(true);
                        }
                        return(false);
                    };
                    scrollview.ContentContainer.Add(itemLabel);
                }
                scrollview.SizeHeight = 30d.ToPixel() * Math.Min(_buttons.Count(), 5);

                // separator
                content.Add(new View
                {
                    BackgroundColor    = TColor.FromHex("#cccccc").ToNative(),
                    SizeHeight         = 1.5d.ToPixel(),
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                });
            }

            var hlayout = new View
            {
                Margin = new Extents(margin1, margin1, margin2, margin1),
                Layout = new LinearLayout
                {
                    VerticalAlignment   = VerticalAlignment.Center,
                    HorizontalAlignment = HorizontalAlignment.End,
                    LinearOrientation   = LinearLayout.Orientation.Horizontal,
                },
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.WrapContent
            };

            content.Add(hlayout);

            if (_destruction != null)
            {
                var destructionButton = new Button
                {
                    Focusable       = true,
                    Text            = _destruction,
                    Margin          = new Extents(0, margin2, 0, 0),
                    TextColor       = TColor.Black,
                    BackgroundColor = TColor.Transparent.ToNative(),
                };
                destructionButton.TextLabel.PixelSize = 15d.ToPixel();
                destructionButton.SizeWidth           = destructionButton.TextLabel.NaturalSize.Width + 15d.ToPixel() * 2;
                destructionButton.Clicked            += (s, e) => SendSubmit(_destruction);
                hlayout.Add(destructionButton);
            }

            var cancelButton = new Button
            {
                Focusable       = true,
                Text            = _cancel,
                TextColor       = TColor.Black,
                BackgroundColor = TColor.Transparent.ToNative(),
            };

            cancelButton.TextLabel.PixelSize = 15d.ToPixel();
            cancelButton.SizeWidth           = cancelButton.TextLabel.NaturalSize.Width + 15d.ToPixel() * 2;
            cancelButton.Clicked            += (s, e) => SendCancel();
            hlayout.Add(cancelButton);

            Relayout += (s, e) =>
            {
                var isHorizontal = Window.Instance.WindowSize.Width > Window.Instance.WindowSize.Height;
                content.SizeWidth = Window.Instance.WindowSize.Width * (isHorizontal ? 0.5f : 0.8f);
            };

            return(content);
        }
        public override View Run()
        {
            var scrollview = new Tizen.UIExtensions.NUI.ScrollView();

            scrollview.ContentContainer.Layout = new LinearLayout
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                LinearOrientation   = LinearLayout.Orientation.Vertical,
            };

            var view = scrollview.ContentContainer;

            view.Add(new Label
            {
                Text                  = "MaterialIconButton",
                TextColor             = Color.White,
                FontSize              = 9,
                FontAttributes        = FontAttributes.Bold,
                VerticalTextAlignment = TextAlignment.Center,
                WidthSpecification    = LayoutParamPolicies.MatchParent,
                SizeHeight            = 100,
                Padding               = new Extents(20, 10, 10, 10),
                BackgroundColor       = Color.FromHex("#2196f3").ToNative(),
                BoxShadow             = new Shadow(5, Color.FromHex("#bbbbbb").ToNative(), new Vector2(0, 5))
            });

            view.Add(new View
            {
                SizeHeight = 20,
            });

            foreach (var icon in Enum.GetValues(typeof(MaterialIcons)))
            {
                view.Add(new Label
                {
                    Padding  = new Extents(10, 0, 0, 0),
                    Text     = icon.ToString(),
                    FontSize = 7,
                    HorizontalTextAlignment = TextAlignment.Start,
                    WidthSpecification      = LayoutParamPolicies.MatchParent,
                    HeightSpecification     = LayoutParamPolicies.WrapContent,
                });

                {
                    var button = new MaterialIconButton()
                    {
                        Icon = (MaterialIcons)icon,
                    };

                    button.SizeHeight = (float)button.Measure(300, 300).Height;
                    button.SizeWidth  = (float)button.Measure(300, 300).Width;
                    view.Add(button);
                }
            }


            foreach (var icon in Enum.GetValues(typeof(MaterialIcons)).Cast <MaterialIcons>().Take(3))
            {
                view.Add(new Label
                {
                    Padding  = new Extents(10, 0, 0, 0),
                    Text     = icon.ToString(),
                    FontSize = 7,
                    HorizontalTextAlignment = TextAlignment.Start,
                    WidthSpecification      = LayoutParamPolicies.MatchParent,
                    HeightSpecification     = LayoutParamPolicies.WrapContent,
                });

                {
                    var button = new MaterialIconButton()
                    {
                        Icon = icon,
                    };

                    button.SizeHeight = 100;
                    button.SizeWidth  = 100;
                    button.UpdateBackgroundColor(Color.Yellow);
                    view.Add(button);
                }
            }

            foreach (var icon in Enum.GetValues(typeof(MaterialIcons)).Cast <MaterialIcons>().Take(3))
            {
                view.Add(new Label
                {
                    Padding  = new Extents(10, 0, 0, 0),
                    Text     = icon.ToString(),
                    FontSize = 7,
                    HorizontalTextAlignment = TextAlignment.Start,
                    WidthSpecification      = LayoutParamPolicies.MatchParent,
                    HeightSpecification     = LayoutParamPolicies.WrapContent,
                });

                {
                    var button = new MaterialIconButton()
                    {
                        Icon = icon,
                    };

                    button.SizeHeight = (float)DeviceInfo.ScalingFactor * 10;
                    button.SizeWidth  = (float)DeviceInfo.ScalingFactor * 10;
                    button.UpdateBackgroundColor(Color.Yellow);
                    view.Add(button);
                }
            }

            return(scrollview);
        }
示例#10
0
        public override View Run()
        {
            var scrollview = new Tizen.UIExtensions.NUI.ScrollView();

            scrollview.ContentContainer.Layout = new LinearLayout
            {
                VerticalAlignment   = VerticalAlignment.Center,
                HorizontalAlignment = HorizontalAlignment.Center,
                LinearOrientation   = LinearLayout.Orientation.Vertical,
            };

            var view = scrollview.ContentContainer;

            view.UpdateBackgroundColor(TColor.FromHex("#eeeeee"));

            view.Add(new TitleView
            {
                Title = "Title view 1",
                Icon  = new MaterialIconButton
                {
                    Icon       = MaterialIcons.ArrowBack,
                    SizeWidth  = (float)(25 * DeviceInfo.ScalingFactor),
                    SizeHeight = (float)(25 * DeviceInfo.ScalingFactor),
                    Color      = TColor.White
                },
                Actions =
                {
                    new MaterialIconButton
                    {
                        Icon       = MaterialIcons.MoreVert,
                        SizeWidth  = (float)(25 * DeviceInfo.ScalingFactor),
                        SizeHeight = (float)(25 * DeviceInfo.ScalingFactor),
                        Color      = TColor.White
                    },
                }
            });

            view.Add(new View
            {
                SizeHeight = 20,
            });

            var title2 = new TitleView
            {
                Title = "Title view 2"
            };

            title2.UpdateBackgroundColor(TColor.White);
            title2.Label.TextColor = TColor.Black;
            title2.Icon            = new MaterialIconButton
            {
                Icon       = MaterialIcons.Menu,
                SizeWidth  = (float)(25 * DeviceInfo.ScalingFactor),
                SizeHeight = (float)(25 * DeviceInfo.ScalingFactor),
            };
            title2.Actions.Add(new MaterialIconButton
            {
                Icon       = MaterialIcons.Close,
                SizeWidth  = (float)(25 * DeviceInfo.ScalingFactor),
                SizeHeight = (float)(25 * DeviceInfo.ScalingFactor),
            });


            view.Add(title2);

            view.Add(new View
            {
                SizeHeight = 20,
            });

            var title3 = new TitleView();

            title3.UpdateBackgroundColor(TColor.FromHex("6200EE"));
            title3.Icon = new MaterialIconButton
            {
                Icon       = MaterialIcons.ArrowBack,
                Color      = TColor.White,
                SizeWidth  = (float)(25 * DeviceInfo.ScalingFactor),
                SizeHeight = (float)(25 * DeviceInfo.ScalingFactor),
            };
            title3.Content = new Tizen.UIExtensions.NUI.Entry
            {
                PlaceholderText       = "Search",
                PlaceholderColor      = TColor.FromHex("#222222"),
                VerticalTextAlignment = TextAlignment.Center,
                HeightSpecification   = LayoutParamPolicies.MatchParent,
                WidthSpecification    = LayoutParamPolicies.MatchParent,
                Margin = new Extents(0, 10, 5, 5),
            };
            title3.Content.UpdateBackgroundColor(TColor.FromHex("#eeeeee"));
            title3.Icon = new MaterialIconButton
            {
                Icon       = MaterialIcons.Check,
                SizeWidth  = (float)(25 * DeviceInfo.ScalingFactor),
                SizeHeight = (float)(25 * DeviceInfo.ScalingFactor),
                Color      = TColor.White,
            };
            view.Add(title3);


            view.Add(new View
            {
                SizeHeight = 20,
            });

            var title4 = new TitleView();

            title4.UpdateBackgroundColor(TColor.FromHex("6200EE"));
            title4.Icon = new MaterialIconButton
            {
                Icon       = MaterialIcons.ArrowBack,
                Color      = TColor.White,
                SizeWidth  = (float)(25 * DeviceInfo.ScalingFactor),
                SizeHeight = (float)(25 * DeviceInfo.ScalingFactor),
            };
            title4.Content = new Tizen.UIExtensions.NUI.Entry
            {
                PlaceholderText       = "Search",
                PlaceholderColor      = TColor.FromHex("#222222"),
                VerticalTextAlignment = TextAlignment.Center,
                HeightSpecification   = LayoutParamPolicies.MatchParent,
                WidthSpecification    = LayoutParamPolicies.MatchParent,
                Margin = new Extents(0, 10, 5, 5),
            };
            title4.Content.UpdateBackgroundColor(TColor.FromHex("#eeeeee"));
            title4.Icon = new MaterialIconButton
            {
                Icon       = MaterialIcons.Menu,
                SizeWidth  = (float)(25 * DeviceInfo.ScalingFactor),
                SizeHeight = (float)(25 * DeviceInfo.ScalingFactor),
                Color      = TColor.White,
            };
            title4.Actions.Add(new MaterialIconButton
            {
                Icon       = MaterialIcons.Check,
                SizeWidth  = (float)(25 * DeviceInfo.ScalingFactor),
                SizeHeight = (float)(25 * DeviceInfo.ScalingFactor),
                Color      = TColor.White,
            });
            title4.Actions.Add(new MaterialIconButton
            {
                Icon       = MaterialIcons.Close,
                SizeWidth  = (float)(25 * DeviceInfo.ScalingFactor),
                SizeHeight = (float)(25 * DeviceInfo.ScalingFactor),
                Color      = TColor.White,
            });
            view.Add(title4);

            return(scrollview);
        }
            public PushPopPage(NavigationStack stack, int depth)
            {
                _stack              = stack;
                WidthSpecification  = LayoutParamPolicies.MatchParent;
                HeightSpecification = LayoutParamPolicies.MatchParent;
                var rnd = new Random();

                BackgroundColor = TColor.FromRgba(rnd.Next(100, 200), rnd.Next(100, 200), rnd.Next(100, 200), 255).ToNative();


                Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Vertical
                };

                Add(new Label
                {
                    Text = $"Text {depth}"
                });

                var push = new Button
                {
                    Text = "Push (fade)"
                };

                Add(push);
                push.Clicked += (s, e) =>
                {
                    stack.PushAnimation = (view, progress) =>
                    {
                        view.Opacity = 0.5f + 0.5f * (float)progress;
                    };
                    _ = _stack.Push(new PushPopPage(_stack, depth + 1), true);
                };

                var push2 = new Button
                {
                    Text = "Push (fade + Left)"
                };

                Add(push2);
                push2.Clicked += (s, e) =>
                {
                    float?originalX = null;
                    stack.PushAnimation = (view, progress) =>
                    {
                        if (originalX == null)
                        {
                            originalX = view.PositionX;
                        }
                        view.PositionX = originalX.Value + (float)(view.SizeWidth / 4.0f * (1 - progress));
                        view.Opacity   = 0.5f + 0.5f * (float)progress;
                    };

                    _ = _stack.Push(new PushPopPage(_stack, depth + 1), true);
                };

                var push3 = new Button
                {
                    Text = "Push (fade + Up)"
                };

                Add(push3);
                push3.Clicked += (s, e) =>
                {
                    float?originY = null;
                    stack.PushAnimation = (view, progress) =>
                    {
                        if (originY == null)
                        {
                            originY = view.PositionY;
                        }
                        view.PositionY = originY.Value + (float)(view.SizeHeight / 4.0f * (1 - progress));
                        view.Opacity   = 0.5f + 0.5f * (float)progress;
                    };

                    _ = _stack.Push(new PushPopPage(_stack, depth + 1), true);
                };

                var push4 = new Button
                {
                    Text = "Push (default)"
                };

                Add(push4);
                push4.Clicked += (s, e) =>
                {
                    stack.PushAnimation = null;
                    _ = _stack.Push(new PushPopPage(_stack, depth + 1), true);
                };



                var pop = new Button
                {
                    Text = "Pop (fade)"
                };

                Add(pop);
                pop.Clicked += (s, e) =>
                {
                    stack.PopAnimation = (view, progress) =>
                    {
                        view.Opacity = 0.5f + 0.5f * (float)(1 - progress);
                    };
                    _ = _stack.Pop(true);
                };

                var pop2 = new Button
                {
                    Text = "Pop (fade + Right)"
                };

                Add(pop2);
                pop2.Clicked += (s, e) =>
                {
                    float?originX = null;
                    stack.PopAnimation = (view, progress) =>
                    {
                        if (originX == null)
                        {
                            originX = view.PositionX;
                        }
                        view.PositionX = originX.Value + (float)(view.SizeWidth / 4.0f * progress);
                        view.Opacity   = 0.5f + 0.5f * (float)(1 - progress);
                    };
                    _ = _stack.Pop(true);
                };

                var pop3 = new Button
                {
                    Text = "Pop (fade + down)"
                };

                Add(pop3);
                pop3.Clicked += (s, e) =>
                {
                    float?originY = null;
                    stack.PopAnimation = (view, progress) =>
                    {
                        if (originY == null)
                        {
                            originY = view.PositionY;
                        }
                        view.PositionY = originY.Value + (float)(view.SizeHeight / 4.0f * progress);
                        view.Opacity   = 0.5f + 0.5f * (float)(1 - progress);
                    };
                    _ = _stack.Pop(true);
                };

                var pop4 = new Button
                {
                    Text = "Pop (default)"
                };

                Add(pop4);
                pop4.Clicked += (s, e) =>
                {
                    stack.PopAnimation = null;
                    _ = _stack.Pop(true);
                };


                Add(new Image
                {
                    ResourceUrl = Application.Current.DirectoryInfo.Resource + (depth % 2 == 0 ? "image.png" : "image2.jpg")
                });
            }