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 btn3 = new Button
            {
                Text = "Open Prompt popup",
            };

            view.Add(btn3);
            btn3.Clicked += async(s, e) =>
            {
                try
                {
                    var result = await new PromptPopup("Prompt", "Your name", placeholder: "Name").Open();
                    await new MessagePopup("Result", $"Your name is {result}", "OK").Open();
                }
                catch (TaskCanceledException)
                {
                    _ = new MessagePopup("Result", $"Prompt is canceld", "OK").Open();
                }
            };


            return(view);
        }
Example #2
0
 public static void UpdateBackgroundColor(this EvasObject view, Color color)
 {
     if (view is Widget widget)
     {
         widget.BackgroundColor = color.ToNative();
     }
 }
Example #3
0
 internal static string ToHex(this TColor c)
 {
     if (c.IsDefault)
     {
         TLog.Warn("Trying to convert the default color to hexagonal notation, it does not works as expected.");
     }
     return(string.Format("#{0:X2}{1:X2}{2:X2}{3:X2}", c.R, c.G, c.B, c.A));
 }
 public static GColor ToGraphicsColor(this TColor color, string fallback)
 {
     if (!color.IsDefault)
     {
         return(new GColor((float)color.R, (float)color.G, (float)color.B, (float)color.A));
     }
     else
     {
         return(GColor.FromArgb(fallback));
     }
 }
Example #5
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",
            };

            view.Add(btn1);
            btn1.Clicked += async(s, e) =>
            {
                _ = new MessagePopup("Popup1", "Show your popup", "OK").Open();
            };

            var btn2 = new Button
            {
                Text = "Open popup2",
            };

            view.Add(btn2);
            btn2.Clicked += async(s, e) =>
            {
                try
                {
                    var result = await new MessagePopup("Popup2", "Show your popup", "Yes", "No").Open();
                    await new MessagePopup("Result", $"Result is {result}", "OK").Open();
                }
                catch
                {
                    _ = new MessagePopup("Result", "Popup was closed", "OK").Open();
                }
            };

            return(view);
        }
        public override View Run()
        {
            var view = new View
            {
                Layout = new LinearLayout
                {
                    LinearAlignment   = LinearLayout.Alignment.Center,
                    LinearOrientation = LinearLayout.Orientation.Vertical,
                }
            };

            view.UpdateBackgroundColor(Color.FromHex("#618833"));

            var test1 = new Button
            {
                Text = "PixelBuffer Create"
            };

            view.Add(test1);

            var test2 = new Button
            {
                Text = "NativeImageQueue Create"
            };

            view.Add(test2);

            var label = new Label();

            view.Add(label);


            test1.Clicked += (s, e) =>
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                for (int i = 0; i < 1000; i++)
                {
                    using var buffer = new PixelBuffer(500, 500, PixelFormat.BGRA8888);
                    buffer.GetBuffer();
                    using var pixelData = PixelBuffer.Convert(buffer);
                    using var url       = pixelData.GenerateUrl();
                }
                stopwatch.Stop();
                label.Text = $"PixelBuffer create time : {stopwatch.ElapsedMilliseconds} ms";
            };

            test2.Clicked += (s, e) =>
            {
                Stopwatch stopwatch = Stopwatch.StartNew();
                for (int i = 0; i < 1000; i++)
                {
                    using var queue = new NativeImageQueue(500, 500, NativeImageQueue.ColorFormat.RGBA8888);
                    int width  = 0;
                    int height = 0;
                    int stride = 0;
                    var buffer = queue.DequeueBuffer(ref width, ref height, ref stride);
                    queue.EnqueueBuffer(buffer);
                }
                stopwatch.Stop();
                label.Text = $"NativeImageQueue create time : {stopwatch.ElapsedMilliseconds} ms";
            };

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

            scrollview.ContentContainer.Layout = new LinearLayout
            {
                LinearAlignment   = LinearLayout.Alignment.Center,
                LinearOrientation = LinearLayout.Orientation.Vertical,
            };

            var view = scrollview.ContentContainer;


            view.Add(new Label
            {
                Text                  = "Graphics View",
                TextColor             = Color.White,
                FontSize              = 9,
                FontAttributes        = Tizen.UIExtensions.Common.FontAttributes.Bold,
                VerticalTextAlignment = Tizen.UIExtensions.Common.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,
            });

            view.Add(new Label
            {
                Padding  = new Extents(10, 0, 0, 0),
                Text     = "ActivityIndicator",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            var hlayout = new View
            {
                Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Horizontal,
                },
                Padding = 10,
            };

            {
                var ai = new ActivityIndicator
                {
                    IsRunning = true,
                    Margin    = 5,
                };
                ai.SizeHeight = (float)ai.Measure(300, 300).Height;
                ai.SizeWidth  = (float)ai.Measure(300, 300).Width;
                view.Add(ai);
                hlayout.Add(ai);
                var timer = ElmSharp.EcoreMainloop.AddTimer(3, () =>
                {
                    ai.IsRunning = !ai.IsRunning;
                    return(true);
                });
                ai.RemovedFromWindow += (s, e) =>
                {
                    ElmSharp.EcoreMainloop.RemoveTimer(timer);
                    (s as View).Dispose();
                };
            }

            {
                var ai = new ActivityIndicator
                {
                    Color     = Color.FromHex("#ff9800"),
                    IsRunning = true,
                    Margin    = 5
                };
                ai.SizeHeight = (float)ai.Measure(300, 300).Height;
                ai.SizeWidth  = (float)ai.Measure(300, 300).Width;
                view.Add(ai);
                hlayout.Add(ai);
                var timer = ElmSharp.EcoreMainloop.AddTimer(3.3, () =>
                {
                    ai.IsRunning = !ai.IsRunning;
                    return(true);
                });
                ai.RemovedFromWindow += (s, e) =>
                {
                    ElmSharp.EcoreMainloop.RemoveTimer(timer);
                    (s as View).Dispose();
                };
            }

            {
                var ai = new ActivityIndicator
                {
                    Color     = Color.FromHex("#ffeb3b"),
                    IsRunning = true,
                    Margin    = 5
                };
                ai.SizeHeight = (float)ai.Measure(300, 300).Height;
                ai.SizeWidth  = (float)ai.Measure(300, 300).Width;
                view.Add(ai);
                hlayout.Add(ai);
                var timer = ElmSharp.EcoreMainloop.AddTimer(4, () =>
                {
                    ai.IsRunning = !ai.IsRunning;
                    return(true);
                });
                ai.RemovedFromWindow += (s, e) =>
                {
                    ElmSharp.EcoreMainloop.RemoveTimer(timer);
                    (s as View).Dispose();
                };
            }

            view.Add(hlayout);

            view.Add(new Label
            {
                Padding  = new Extents(10, 0, 0, 0),
                Text     = "ProgressBar",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            {
                var progressBar2 = new ProgressBar
                {
                    Margin             = 10,
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                    ProgressColor      = Color.GreenYellow,
                };
                progressBar2.SizeHeight = (float)progressBar2.Measure(300, 300).Height;

                view.Add(progressBar2);
                var timer = ElmSharp.EcoreMainloop.AddTimer(1, () =>
                {
                    if (progressBar2.Progress >= 1.0)
                    {
                        progressBar2.Progress = 0;
                    }

                    progressBar2.ProgressTo(progressBar2.Progress + 0.2);
                    return(true);
                });
                progressBar2.RemovedFromWindow += (s, e) => ElmSharp.EcoreMainloop.RemoveTimer(timer);
            }


            var progressBar1 = new ProgressBar
            {
                Margin             = 10,
                WidthSpecification = LayoutParamPolicies.MatchParent,
            };

            progressBar1.SizeHeight = (float)progressBar1.Measure(300, 300).Height;

            view.Add(progressBar1);

            view.Add(new View
            {
                SizeHeight         = 10,
                WidthSpecification = LayoutParamPolicies.MatchParent,
            });

            view.Add(new Label
            {
                Padding  = new Extents(10, 0, 10, 0),
                Text     = "Slider",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            {
                var slider1 = new Slider
                {
                    IsEnabled          = false,
                    Margin             = 5,
                    Value              = 0,
                    Minimum            = 0,
                    Maximum            = 1,
                    SizeHeight         = 50,
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                };
                slider1.ValueChanged += (s, e) =>
                {
                    progressBar1.Progress = slider1.Value;
                };
                view.Add(slider1);
            }

            {
                var slider1 = new Slider
                {
                    Margin             = 5,
                    Value              = 0,
                    Minimum            = 0,
                    Maximum            = 1,
                    SizeHeight         = 50,
                    MaximumTrackColor  = Color.Red,
                    MinimumTrackColor  = Color.Green,
                    ThumbColor         = Color.Yellow,
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                };
                view.Add(slider1);
            }

            {
                var slider1 = new Slider
                {
                    Margin             = 5,
                    Value              = 0,
                    Minimum            = -20,
                    Maximum            = 10,
                    SizeHeight         = 50,
                    MaximumTrackColor  = Color.Red,
                    MinimumTrackColor  = Color.Green,
                    ThumbColor         = Color.Yellow,
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                };
                view.Add(slider1);
            }

            view.Add(new Label
            {
                Padding  = new Extents(10, 0, 10, 0),
                Text     = "Button",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            {
                var button = new Tizen.UIExtensions.NUI.GraphicsView.Button
                {
                    IsEnabled    = false,
                    Margin       = 5,
                    Text         = "Clicked 0",
                    CornerRadius = 10,
                };

                button.SizeHeight = (float)button.Measure(300, 300).Height;
                button.SizeWidth  = (float)button.Measure(300, 300).Width;
                int count = 1;
                button.Clicked += (s, e) =>
                {
                    button.Text = $"Clicked {count++}";
                };
                view.Add(button);
            }

            {
                var button = new Tizen.UIExtensions.NUI.GraphicsView.Button
                {
                    Margin          = 5,
                    BackgroundColor = Color.Green,
                    Text            = "BUTTON",
                };

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

            {
                var button = new Tizen.UIExtensions.NUI.GraphicsView.Button
                {
                    Margin          = 5,
                    BackgroundColor = Color.Red,
                    Text            = "BUTTON",
                };

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

            view.Add(new Label
            {
                Padding  = new Extents(10, 0, 10, 0),
                Text     = "CheckBox",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            {
                var checkbox1 = new CheckBox
                {
                    Margin = 5,
                    Text   = "CheckBox1",
                };
                checkbox1.SizeHeight = (float)checkbox1.Measure(300, 300).Height;
                checkbox1.SizeWidth  = (float)checkbox1.Measure(300, 300).Width;
                view.Add(checkbox1);
            }
            {
                var checkbox1 = new CheckBox
                {
                    IsEnabled = false,
                    Margin    = 5,
                    Text      = "CheckBox1",
                };
                checkbox1.SizeHeight = (float)checkbox1.Measure(300, 300).Height;
                checkbox1.SizeWidth  = (float)checkbox1.Measure(300, 300).Width;
                view.Add(checkbox1);
            }
            {
                var checkbox1 = new CheckBox
                {
                    IsEnabled = false,
                    IsChecked = true,
                    Margin    = 5,
                    Text      = "CheckBox1",
                };
                checkbox1.SizeHeight = (float)checkbox1.Measure(300, 300).Height;
                checkbox1.SizeWidth  = (float)checkbox1.Measure(300, 300).Width;
                view.Add(checkbox1);
            }
            {
                var checkbox1 = new CheckBox
                {
                    Margin = 5,
                    Color  = Color.Red,
                    Text   = "Red",
                };
                checkbox1.SizeHeight = (float)checkbox1.Measure(300, 300).Height;
                checkbox1.SizeWidth  = (float)checkbox1.Measure(300, 300).Width;
                view.Add(checkbox1);
            }
            {
                var checkbox1 = new CheckBox
                {
                    Margin = 5,
                    Color  = Color.Blue,
                    Text   = "Blue",
                };
                checkbox1.SizeHeight = (float)checkbox1.Measure(300, 300).Height;
                checkbox1.SizeWidth  = (float)checkbox1.Measure(300, 300).Width;
                view.Add(checkbox1);
            }

            view.Add(new Label
            {
                Padding  = new Extents(10, 0, 10, 0),
                Text     = "Switch",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            hlayout = new View
            {
                Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Horizontal,
                },
                Padding = 10,
            };

            {
                var switch1 = new Switch
                {
                    Margin = 5,
                };
                switch1.SizeHeight = (float)switch1.Measure(300, 300).Height;
                switch1.SizeWidth  = (float)switch1.Measure(300, 300).Width;
                hlayout.Add(switch1);
            }
            {
                var switch1 = new Switch
                {
                    IsEnabled  = false,
                    Margin     = 5,
                    ThumbColor = Color.Red,
                    OnColor    = Color.Yellow
                };
                switch1.SizeHeight = (float)switch1.Measure(300, 300).Height;
                switch1.SizeWidth  = (float)switch1.Measure(300, 300).Width;
                hlayout.Add(switch1);
            }
            {
                var switch1 = new Switch
                {
                    Margin     = 5,
                    ThumbColor = Color.BlueViolet,
                    OnColor    = Color.Red,
                    IsToggled  = true,
                };
                switch1.SizeHeight = (float)switch1.Measure(300, 300).Height;
                switch1.SizeWidth  = (float)switch1.Measure(300, 300).Width;
                hlayout.Add(switch1);
            }
            view.Add(hlayout);

            view.Add(new Label
            {
                Padding  = new Extents(10, 0, 10, 0),
                Text     = "Stepper",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            var stepper = new Stepper();

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

            var stepperLabel = new Label
            {
                Text = "0",
            };

            view.Add(stepperLabel);

            stepper.ValueChanged += (s, e) => stepperLabel.Text = $"{stepper.Value}";


            view.Add(new Label
            {
                Padding  = 10,
                Text     = "Entry",
                FontSize = 7,
                HorizontalTextAlignment = Tizen.UIExtensions.Common.TextAlignment.Start,
                WidthSpecification      = LayoutParamPolicies.MatchParent,
                HeightSpecification     = LayoutParamPolicies.WrapContent,
            });

            var gEntry = new Tizen.UIExtensions.NUI.GraphicsView.Entry
            {
                Placeholder = "Entry",
            };


            gEntry.SizeHeight = (float)gEntry.Measure(600, 300).Height;
            gEntry.SizeWidth  = (float)gEntry.Measure(600, 300).Width;

            view.Add(gEntry);

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

            var gEntry2 = new Tizen.UIExtensions.NUI.GraphicsView.Entry
            {
                Placeholder      = "Entry2",
                PlaceholderColor = Color.Red,
            };

            gEntry2.SizeHeight = (float)gEntry2.Measure(600, 300).Height;
            gEntry2.SizeWidth  = (float)gEntry2.Measure(600, 300).Width;

            view.Add(gEntry2);

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


            var editor = new Tizen.UIExtensions.NUI.GraphicsView.Editor
            {
                Placeholder = "Editor"
            };

            editor.SizeHeight = 500;
            editor.SizeWidth  = (float)editor.Measure(600, 300).Width;

            view.Add(editor);


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

            return(scrollview);
        }
        public override View Run()
        {
            var main = new View
            {
                Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Vertical
                },
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
            };

            main.Add(new Label
            {
                Text                  = "Refresh Layout Test",
                TextColor             = Color.White,
                FontSize              = 9,
                FontAttributes        = Tizen.UIExtensions.Common.FontAttributes.Bold,
                VerticalTextAlignment = Tizen.UIExtensions.Common.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))
            });

            var scrollview = new Tizen.UIExtensions.NUI.ScrollView()
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
            };

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

            for (int i = 0; i < 3; i++)
            {
                var rnd   = new Random();
                var child = new View
                {
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                    SizeHeight         = 50,
                };
                child.BackgroundColor = new Tizen.NUI.Color(rnd.NextSingle(), rnd.NextSingle(), rnd.NextSingle(), 1);
                scrollview.Add(child);
            }

            var startRefresh = new Tizen.UIExtensions.NUI.Button()
            {
                Text = "StartRefresh"
            };

            scrollview.Add(startRefresh);

            var changeBg = new Tizen.UIExtensions.NUI.Button()
            {
                Text = "Change background"
            };

            scrollview.Add(changeBg);


            var changeColor = new Tizen.UIExtensions.NUI.Button()
            {
                Text = "Change Color"
            };

            scrollview.Add(changeColor);

            for (int i = 0; i < 100; i++)
            {
                var rnd   = new Random();
                var child = new View
                {
                    WidthSpecification = LayoutParamPolicies.MatchParent,
                    SizeHeight         = 50,
                };
                child.BackgroundColor = new Tizen.NUI.Color(rnd.NextSingle(), rnd.NextSingle(), rnd.NextSingle(), 1);
                scrollview.Add(child);
            }



            var wrapperView = new View
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
            };

            wrapperView.Add(scrollview);

            var refreshView = new RefreshLayout()
            {
                WidthSpecification  = LayoutParamPolicies.MatchParent,
                HeightSpecification = LayoutParamPolicies.MatchParent,
                Content             = wrapperView,
            };

            refreshView.Refreshing += async(s, e) =>
            {
                await System.Threading.Tasks.Task.Delay(2000);

                refreshView.IsRefreshing = false;
            };
            main.Add(refreshView);


            startRefresh.Clicked += (s, e) => refreshView.IsRefreshing = true;
            changeBg.Clicked     += (s, e) =>
            {
                if (refreshView.IconBackgroundColor == Color.Default)
                {
                    refreshView.IconBackgroundColor = Color.Green;
                }
                else
                {
                    refreshView.IconBackgroundColor = Color.Default;
                }
            };
            changeColor.Clicked += (s, e) =>
            {
                if (refreshView.IconColor == Color.Default)
                {
                    refreshView.IconColor = Color.Red;
                }
                else
                {
                    refreshView.IconColor = Color.Default;
                }
            };

            return(main);
        }
 public static void UpdateBackgroundColor(this View view, Color color)
 {
     view.BackgroundColor = color.IsDefault ? Color.Transparent.ToNative() : color.ToNative();
 }
Example #10
0
        public override View Run()
        {
            var view = new View
            {
                Layout = new LinearLayout
                {
                    LinearAlignment   = LinearLayout.Alignment.Center,
                    LinearOrientation = LinearLayout.Orientation.Vertical,
                }
            };

            view.UpdateBackgroundColor(Color.FromHex("#618833"));

            var canvas = new SKCanvasView()
            {
                SizeWidth  = 300,
                SizeHeight = 300,
            };

            view.Add(new Label
            {
                Text = "ImageView"
            });
            view.Add(canvas);

            var glSurface = new SKGLSurfaceView()
            {
                SizeWidth  = 300,
                SizeHeight = 300,
            };

            view.Add(new Label
            {
                Text = "GL Surface View"
            });
            view.Add(glSurface);

            canvas.PaintSurface    += OnPaintSurface;
            glSurface.PaintSurface += OnPaintSurface;


            var left = new Button
            {
                Text = "<-"
            };

            view.Add(left);
            left.Clicked += (s, e) =>
            {
                startX -= 10;
                canvas.Invalidate();
                glSurface.Invalidate();
            };

            var right = new Button
            {
                Text = "->"
            };

            view.Add(right);
            right.Clicked += (s, e) =>
            {
                startX += 10;
                canvas.Invalidate();
                glSurface.Invalidate();
            };

            var add = new Button
            {
                Text = "+"
            };

            view.Add(add);
            add.Clicked += (s, e) =>
            {
                canvas.SizeWidth    += 30;
                glSurface.SizeWidth += 30;
            };

            return(view);
        }
Example #11
0
        public override View Run()
        {
            var scrollView = new ScrollView();

            scrollView.UpdateBackgroundColor(Color.FromHex("#618833"));
            scrollView.ContentContainer.Layout = new LinearLayout
            {
                LinearOrientation = LinearLayout.Orientation.Vertical
            };

            List <CustomRenderingView> viewList = new List <CustomRenderingView>();

            for (int i = 0; i < 5; i++)
            {
                var canvas = new SKCanvasView()
                {
                    Margin     = new Extents(5, 5, 5, 5),
                    SizeWidth  = 300,
                    SizeHeight = 300,
                };
                var hlayout = new View
                {
                    SizeHeight = 310,
                    Layout     = new LinearLayout
                    {
                        LinearOrientation = LinearLayout.Orientation.Horizontal,
                        LinearAlignment   = LinearLayout.Alignment.Center,
                    }
                };

                canvas.PaintSurface += Draw;

                hlayout.Add(canvas);
                viewList.Add(canvas);
                scrollView.Add(hlayout);
            }

            timer = new Timer(10);

            timer.Tick += (s, e) =>
            {
                startx += 10;
                starty += 1;
                if (startx + 100 >= 300)
                {
                    startx = 0;
                }
                if (starty + 100 >= 300)
                {
                    starty = 0;
                }

                foreach (var view in viewList)
                {
                    view.Invalidate();
                }

                return(true);
            };

            scrollView.RemovedFromWindow += (s, e) =>
            {
                timer.Stop();
            };
            timer.Start();

            return(scrollView);
        }
        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 btn3 = new Button
                {
                    Text = "Open1",
                };
                view.Add(btn3);
                btn3.Clicked += async(s, e) =>
                {
                    try
                    {
                        var result = await new ActionSheetPopup("Choose", "Cancel", "Delete", new [] {
                            "Apple",
                            "Banana",
                            "Test",
                            "Test2",
                            "test3",
                            "bbbb"
                        }).Open();
                        _ = new MessagePopup("Result", $"You choose {result}", "OK").Open();
                    }
                    catch (TaskCanceledException)
                    {
                        _ = new MessagePopup("Result", $"Canceled", "OK").Open();
                    }
                };
            }

            {
                var btn3 = new Button
                {
                    Text = "Open2",
                };
                view.Add(btn3);
                btn3.Clicked += async(s, e) =>
                {
                    App.Stack.ShownBehindPage = true;
                    _ = App.Stack.Push(new View(), false);
                    try
                    {
                        var result = await new ActionSheetPopup("Choose", "Cancel", buttons: new string[] {
                            "Item1",
                            "Item2",
                            "Item3",
                        }).Open();
                        _ = new MessagePopup("Result", $"You choose {result}", "OK").Open();
                    }
                    catch (TaskCanceledException)
                    {
                        _ = new MessagePopup("Result", $"Canceled", "OK").Open();
                    }
                    finally
                    {
                        App.Stack.ShownBehindPage = false;
                        _ = App.Stack.Pop(false);
                    }
                };
            }



            return(view);
        }
Example #13
0
        public override View Run()
        {
            var scrollview = new Tizen.UIExtensions.NUI.ScrollView();

            scrollview.ContentContainer.Layout = new LinearLayout
            {
                LinearAlignment   = LinearLayout.Alignment.Center,
                LinearOrientation = LinearLayout.Orientation.Vertical,
            };

            var view = scrollview.ContentContainer;


            view.Add(new Label
            {
                Text                  = "RefreshIcon Test",
                TextColor             = Color.White,
                FontSize              = 9,
                FontAttributes        = Tizen.UIExtensions.Common.FontAttributes.Bold,
                VerticalTextAlignment = Tizen.UIExtensions.Common.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,
            });


            var hlayout = new View
            {
                Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Horizontal,
                },
                //BackgroundColor = Tizen.NUI.Color.Gray,
                Padding = 10,
            };


            var refreshIcon = new RefreshIcon
            {
                BorderlineColor = Tizen.NUI.Color.Red,
                BorderlineWidth = 2f,
            };

            refreshIcon.SizeHeight = (float)refreshIcon.Measure(300, 300).Height;
            refreshIcon.SizeWidth  = (float)refreshIcon.Measure(300, 300).Width;
            hlayout.Add(refreshIcon);

            var refreshIcon2 = new RefreshIcon
            {
                Color           = Color.Red,
                BackgroundColor = Color.Yellow,
            };

            refreshIcon2.SizeHeight = (float)refreshIcon2.Measure(300, 300).Height;
            refreshIcon2.SizeWidth  = (float)refreshIcon2.Measure(300, 300).Width;
            hlayout.Add(refreshIcon2);

            view.Add(hlayout);

            var slider1 = new Slider
            {
                Value              = 0,
                Minimum            = 0,
                Maximum            = 1,
                SizeHeight         = 50,
                WidthSpecification = LayoutParamPolicies.MatchParent,
            };

            view.Add(slider1);

            slider1.ValueChanged += (s, e) =>
            {
                refreshIcon.PullDistance  = (float)slider1.Value;
                refreshIcon2.PullDistance = (float)slider1.Value;
            };
            var switch1 = new Switch()
            {
                SizeHeight         = 50,
                WidthSpecification = LayoutParamPolicies.MatchParent,
            };

            view.Add(switch1);

            switch1.Toggled += (s, e) =>
            {
                refreshIcon.IsRunning  = switch1.IsToggled;
                refreshIcon2.IsRunning = switch1.IsToggled;
            };


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

            scrollview.ContentContainer.Layout = new LinearLayout
            {
                LinearAlignment   = LinearLayout.Alignment.Center,
                LinearOrientation = LinearLayout.Orientation.Vertical,
            };

            var view = scrollview.ContentContainer;


            view.Add(new Label
            {
                Text                  = "Switch Test",
                TextColor             = Color.White,
                FontSize              = 9,
                FontAttributes        = Tizen.UIExtensions.Common.FontAttributes.Bold,
                VerticalTextAlignment = Tizen.UIExtensions.Common.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,
            });


            var hlayout = new View
            {
                Layout = new LinearLayout
                {
                    LinearOrientation = LinearLayout.Orientation.Horizontal,
                },
                Padding = 10,
            };

            Switch switchtest = null;

            {
                var switch1 = new Switch
                {
                    Margin = 5,
                };
                switch1.SizeHeight = (float)switch1.Measure(300, 300).Height;
                switch1.SizeWidth  = (float)switch1.Measure(300, 300).Width;
                hlayout.Add(switch1);
            }
            {
                var switch1 = new Switch
                {
                    IsEnabled  = false,
                    Margin     = 5,
                    ThumbColor = Color.Red,
                    OnColor    = Color.Yellow
                };
                switch1.SizeHeight = (float)switch1.Measure(300, 300).Height;
                switch1.SizeWidth  = (float)switch1.Measure(300, 300).Width;
                hlayout.Add(switch1);
            }
            {
                var switch1 = new Switch
                {
                    Margin     = 5,
                    ThumbColor = Color.BlueViolet,
                    OnColor    = Color.Red,
                    IsToggled  = true,
                };
                switch1.SizeHeight = (float)switch1.Measure(300, 300).Height;
                switch1.SizeWidth  = (float)switch1.Measure(300, 300).Width;
                hlayout.Add(switch1);
                switchtest = switch1;
            }
            view.Add(hlayout);


            var btn = new Tizen.UIExtensions.NUI.Button
            {
                Text = "Toggle"
            };

            btn.Clicked += (s, e) => switchtest.IsToggled = !switchtest.IsToggled;
            scrollview.ContentContainer.Add(btn);

            return(scrollview);
        }
Example #15
0
 protected virtual void ApplyTitleColor(Color color)
 {
     this.SetTitleColor(color.ToNative());
 }
Example #16
0
 /// <summary>
 /// Creates an instance of ElmSharp.Color class based on provided Tizen.UIExtensions.Common.Color instance
 /// </summary>
 /// <returns>ElmSharp.Color instance representing a color which corresponds to the provided Tizen.UIExtensions.Common.Color</returns>
 /// <param name="c">The Tizen.UIExtensions.Common.Color instance which will be converted to a ElmSharp.Color</param>
 public static EColor ToNative(this Color c)
 {
     return(c.IsDefault ? EColor.Default :
            new EColor((int)(255.0 * c.R), (int)(255.0 * c.G), (int)(255.0 * c.B), (int)(255.0 * c.A)));
 }