示例#1
0
        /// <summary>
        /// Invoked on element changes.
        /// </summary>
        /// <param name="e">Event parameters.</param>
        protected override void OnElementChanged(ElementChangedEventArgs <CarouselView> e)
        {
            if (Control == null)
            {
                _box = new ElmSharp.Box(Forms.Context.MainWindow)
                {
                    IsHorizontal = true
                };

                var scroller = new ElmSharp.Scroller(Forms.Context.MainWindow)
                {
                    HorizontalScrollBarVisiblePolicy = ElmSharp.ScrollBarVisiblePolicy.Invisible,
                    VerticalScrollBarVisiblePolicy   = ElmSharp.ScrollBarVisiblePolicy.Invisible,
                    HorizontalPageScrollLimit        = 1,
                };
                scroller.SetContent(_box);
                scroller.PageScrolled += OnScrolled;
                scroller.Resized      += OnResized;
                SetNativeControl(scroller);
            }

            if (e.NewElement != null)
            {
                UpdateContent();
                Controller.CollectionChanged += OnCollectionChanged;
            }

            base.OnElementChanged(e);
        }
示例#2
0
        void UpdateProcessVisibility()
        {
            if (Application.Current.Platform == null)
            {
                return;
            }

            if (_isProgressRunning)
            {
                _box = new ElmSharp.Box(TForms.NativeParent);
                _box.Show();

                _progress = new ElmSharp.ProgressBar(TForms.NativeParent)
                {
                    Style = "process/popup/small",
                };
                _progress.Show();
                _progress.PlayPulse();
                _box.PackEnd(_progress);

                _layout.SetPartContent("elm.swallow.content", _box, true);

                UpdateTitle();
                UpdateText();
            }
            else
            {
                _layout.SetPartContent("elm.swallow.content", null, true);
            }
        }
        public override void Run(ElmSharp.Box parent)
        {
            var page = new ElmSharp.Box(parent)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };

            page.Show();
            parent.PackEnd(page);

            foreach (var iconType in Enum.GetValues(typeof(MaterialIcons)).Cast <MaterialIcons>())
            {
                var box = new ElmSharp.Box(parent)
                {
                    IsHorizontal = true,
                    AlignmentX   = -1,
                    AlignmentY   = -1,
                    WeightX      = 1,
                    WeightY      = 1,
                };
                box.Show();

                var label = new Label(parent)
                {
                    AlignmentX = 0.5,
                    AlignmentY = -1,
                    WeightY    = 1,
                    WeightX    = 1,
                    Text       = iconType.ToString(),
                };
                label.Show();

                var icon = new MaterialIcon(parent)
                {
                    AlignmentX = 0,
                    AlignmentY = -1,
                    WeightY    = 1,
                    WeightX    = 1,
                    IconType   = iconType,
                };
                icon.Show();

                box.PackEnd(label);
                box.PackEnd(icon);

                page.PackEnd(box);
            }
        }
        public override void Run(ElmSharp.Box parent)
        {
            var searchBar = new SearchBar(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = .1,
                AlignmentX = -1,
                Text       = "searchBar"
            };

            searchBar.Show();
            parent.PackEnd(searchBar);
        }
示例#5
0
        void UpdateProcessVisibility()
        {
            if (!XForms.IsInitialized)
            {
                Log.Debug(FormsCircularUI.Tag, "Tizen Forms is not initialized");
                return;
            }

            if (_isProgressRunning)
            {
                _box = new ElmSharp.Box(XForms.NativeParent);
                _box.Show();

                _progress = new ElmSharp.ProgressBar(XForms.NativeParent)
                {
                    Style = "process/popup/small",
                };
                _progress.Show();
                _progress.PlayPulse();
                _box.PackEnd(_progress);

                _layout.SetPartContent("elm.swallow.content", _box, true);
            }
            else
            {
                if (_box != null)
                {
                    if (_progress != null)
                    {
                        _progress.Unrealize();
                        _progress = null;
                    }

                    if (_progressLabel != null)
                    {
                        _progressLabel.Unrealize();
                        _progressLabel = null;
                    }

                    _box.Unrealize();
                    _box = null;
                }
                _layout.SetPartContent("elm.swallow.content", null, true);
            }

            UpdateTitle();
            UpdateText();
        }
        public override void Run(ElmSharp.Box parent)
        {
            var entry = new EditfieldEntry(parent)
            {
                WeightX           = 1,
                WeightY           = 1,
                AlignmentY        = .1,
                AlignmentX        = -1,
                EnableClearButton = true,
                ClearButtonColor  = Color.DeepPink.ToNative(),
                Text = "EditFiledEntry"
            };

            entry.Show();
            parent.PackEnd(entry);
        }
示例#7
0
        protected virtual void Dispose(bool disposing)
        {
            if (_isDisposed)
            {
                return;
            }

            if (disposing)
            {
                if (_bottomButton != null)
                {
                    _bottomButton.Unrealize();
                    _bottomButton = null;
                }

                if (_box != null)
                {
                    _box.Unrealize();
                    _box = null;
                }

                if (_progress != null)
                {
                    _progress.Unrealize();
                    _progress = null;
                }

                if (_progressLabel != null)
                {
                    _progressLabel.Unrealize();
                    _progressLabel = null;
                }

                if (_popUp != null)
                {
                    _layout.Unrealize();
                    _layout = null;
                    _popUp.BackButtonPressed -= BackButtonPressedHandler;
                    _popUp.Unrealize();
                    _popUp = null;
                }
            }

            _isDisposed = true;
        }
        void UpdateProcessVisibility()
        {
            if (Application.Current.Platform == null)
            {
                return;
            }

            if (_isProgressRunning)
            {
                _box = new ElmSharp.Box(TForms.NativeParent);
                _box.Show();

                _progress = new ElmSharp.ProgressBar(TForms.NativeParent)
                {
                    Style = "process/popup/small",
                };
                _progress.Show();
                _progress.PlayPulse();
                _box.PackEnd(_progress);

                if (!string.IsNullOrEmpty(_text))
                {
                    var progressLabel = new ElmSharp.Label(TForms.NativeParent)
                    {
                        TextStyle = "DEFAULT = 'align=center'",
                    };
                    progressLabel.Text = _text;
                    progressLabel.Show();
                    _box.PackEnd(progressLabel);
                }

                _layout.SetPartContent("elm.swallow.content", _box, true);

                UpdateTitle();
                UpdateText();
            }
            else
            {
                _layout.SetPartContent("elm.swallow.content", null, true);
            }
        }
示例#9
0
        public void Dismiss()
        {
            _popUp.Hide();

            if (_bottomButton != null)
            {
                _bottomButton.Unrealize();
                _bottomButton = null;
                _popUp.SetPartContent("button1", null);
            }

            if (_box != null)
            {
                _box.Unrealize();
                _box = null;
            }

            if (_progress != null)
            {
                _progress.Unrealize();
                _progress = null;
            }

            if (_progressLabel != null)
            {
                _progressLabel.Unrealize();
                _progressLabel = null;
            }

            if (_popUp != null)
            {
                _layout.Unrealize();
                _layout = null;
                _popUp.BackButtonPressed -= BackButtonPressedHandler;
                _popUp.Unrealize();
                _popUp = null;
            }
        }
示例#10
0
        public override void Run(ElmSharp.Box parent)
        {
            var scrollView = new ScrollView(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
                VerticalScrollBarVisibility = ScrollBarVisibility.Always,
            };

            scrollView.Show();

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

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

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

            lineText1.Show();
            var line1 = new LineView(parent)
            {
                WeightX         = 1,
                WeightY         = 1,
                AlignmentY      = -1,
                AlignmentX      = -1,
                Stroke          = new SolidColorBrush(Color.Maroon),
                StrokeThickness = 5,
                Aspect          = Stretch.Uniform,
                X1 = 100,
                Y1 = 0,
                X2 = 500,
                Y2 = 300
            };

            line1.Show();

            content.PackEnd(lineText1);
            content.PackEnd(line1);

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

            lineText2.Show();
            var line2 = new LineView(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
                Stroke     = new LinearGradientBrush(new System.Collections.Generic.List <GradientStop>()
                {
                    new GradientStop(Color.Lavender, 0.2f),
                    new GradientStop(Color.LightSkyBlue, 0.4f),
                    new GradientStop(Color.LightCyan, 0.6f),
                    new GradientStop(Color.LightPink, 0.8f),
                    new GradientStop(Color.YellowGreen, 1.0f),
                }),
                StrokeThickness = 15,
                Aspect          = Stretch.Uniform,
                X1 = 100,
                Y1 = 300,
                X2 = 500,
                Y2 = 100
            };

            line2.Show();
            content.PackEnd(lineText2);
            content.PackEnd(line2);

            var lineText3 = new ElmSharp.Label(parent)
            {
                WeightX = 1,
                WeightY = 1,
                Text    = "LineView StrokeDashArray"
            };

            lineText3.Show();
            var line3 = new LineView(parent)
            {
                WeightX         = 1,
                WeightY         = 1,
                AlignmentY      = -1,
                AlignmentX      = -1,
                Stroke          = new SolidColorBrush(Color.PaleGoldenrod),
                StrokeThickness = 5,
                Aspect          = Stretch.Uniform,
                X1 = 100,
                Y1 = 300,
                X2 = 500,
                Y2 = 100,
                StrokeDashArray  = new float[] { 9, 3, 5, 3 },
                StrokeDashOffset = 5
            };

            line3.Show();

            content.PackEnd(lineText3);
            content.PackEnd(line3);

            var lineText4 = new ElmSharp.Label(parent)
            {
                WeightX = 1,
                WeightY = 1,
                Text    = "LineView PenLineCap Test"
            };

            lineText4.Show();
            var line4 = new LineView(parent)
            {
                WeightX         = 1,
                WeightY         = 1,
                AlignmentY      = -1,
                AlignmentX      = -1,
                Stroke          = new SolidColorBrush(Color.Red),
                StrokeThickness = 15,
                Aspect          = Stretch.Uniform,
                X1 = 100,
                Y1 = 300,
                X2 = 500,
                Y2 = 100
            };

            line4.Show();

            content.PackEnd(lineText4);
            content.PackEnd(line4);

            var lineCapButton = new Button(parent)
            {
                Text       = "Change PenLineCap",
                WeightX    = 0.5,
                WeightY    = 0.3,
                AlignmentY = -1,
                AlignmentX = -1,
            };

            lineCapButton.Show();
            lineCapButton.Clicked += (s, e) =>
            {
                switch (line4.StrokeLineCap)
                {
                case (PenLineCap.Flat):
                    line4.StrokeLineCap = PenLineCap.Round;
                    break;

                case (PenLineCap.Round):
                    line4.StrokeLineCap = PenLineCap.Square;
                    break;

                case (PenLineCap.Square):
                    line4.StrokeLineCap = PenLineCap.Flat;
                    break;
                }
            };
            content.PackEnd(lineCapButton);
        }
        public override void Run(ElmSharp.Box parent)
        {
            Button btn = new Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "Open Dialog"
            };

            btn.Show();

            Label label1 = new Label(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1
            };

            label1.Show();

            Label label2 = new Label(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1
            };

            label2.Show();

            parent.PackEnd(btn);
            parent.PackEnd(label1);
            parent.PackEnd(label2);

            DateTimePickerDialog dialog = new DateTimePickerDialog(parent)
            {
                Mode            = DateTimePickerMode.Date,
                MinimumDateTime = new DateTime(2021, 1, 1),
                MaximumDateTime = DateTime.Now,
                DateTime        = DateTime.Now
            };

            dialog.DateTimeChanged += (s, e) =>
            {
                label1.Text = e.NewDate.ToString();
            };

            dialog.PickerClosed += (s, e) =>
            {
                label2.Text = "PickerClosed";
            };

            dialog.PickerOpened += (s, e) =>
            {
                label2.Text = "PickerOpened";
            };

            btn.Clicked += (s, e) =>
            {
                dialog.Show();
            };
        }
示例#12
0
        public override void Run(ElmSharp.Box parent)
        {
            var scrollView = new ScrollView(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
                VerticalScrollBarVisibility = ScrollBarVisibility.Always,
            };

            scrollView.Show();

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

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

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

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

            rect1.Show();

            content.PackEnd(rectText1);
            content.PackEnd(rect1);

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

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

            rect2.Show();
            content.PackEnd(rectText2);
            content.PackEnd(rect2);

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

            rectText3.Show();
            var rect3 = new RectView(parent)
            {
                WeightX         = 1,
                WeightY         = 1,
                AlignmentY      = -1,
                AlignmentX      = -1,
                Stroke          = new SolidColorBrush(Color.PaleGoldenrod),
                StrokeThickness = 5,
                Fill            = new SolidColorBrush(Color.MediumPurple),
                Aspect          = Stretch.Fill,
                RadiusX         = 120,
                RadiusY         = 120
            };

            rect3.Show();

            content.PackEnd(rectText3);
            content.PackEnd(rect3);
        }
示例#13
0
        protected override void OnElementPropertyChanged(object sender, PropertyChangedEventArgs e)
        {
            base.OnElementPropertyChanged(sender, e);

            if (e.PropertyName.Equals("VisibleRegion") && viewReady && !isDrawn)
            {
                Control.RemoveAll();

                var scale        = ElmSharp.Elementary.GetScale();
                int windowWidth  = (int)Math.Round(OverlayWidth * scale);
                int windowHeight = (int)Math.Round(OverlayHeight * scale);

                foreach (var pin in customPins)
                {
                    var coordinates = new Geocoordinates(pin.Position.Latitude, pin.Position.Longitude);

                    Control.Add(new TPin(coordinates, PinPath));

                    int width  = windowWidth;
                    int height = windowHeight;

                    var window = new ElmSharp.Box(Control);
                    window.Show();

                    {
                        var overlay = new ElmSharp.Box(window)
                        {
                            BackgroundColor = XamarinLogoColor,
                        };
                        overlay.SetAlignment(-1.0, -1.0);                     // fill
                        overlay.SetWeight(1.0, 0.0);                          // expand on X axis
                        overlay.Show();
                        window.PackEnd(overlay);

                        if (pin.Id == XamarinId)
                        {
                            var xamarin = new ElmSharp.Image(overlay);
                            xamarin.Load(XamarinPath);
                            xamarin.SetAlignment(-1.0, -1.0);                              // fill
                            var size = xamarin.ObjectSize;
                            xamarin.MinimumWidth  = size.Width;
                            xamarin.MinimumHeight = size.Height;
                            xamarin.Show();
                            overlay.PackEnd(xamarin);

                            height += size.Height;
                        }

                        {
                            var infoBox = new ElmSharp.Box(overlay)
                            {
                                IsHorizontal = true,
                            };
                            infoBox.SetAlignment(-1.0, -1.0);                         // fill
                            infoBox.SetWeight(1.0, 0.0);                              // expand on X axis
                            infoBox.Show();
                            overlay.PackEnd(infoBox);

                            {
                                var monkey = new ElmSharp.Image(infoBox);
                                monkey.Load(MonkeyPath);
                                monkey.SetAlignment(-1.0, -1.0);                             // fill
                                monkey.SetWeight(1.0, 0.0);                                  // expand on X axis
                                monkey.Show();
                                infoBox.PackEnd(monkey);
                            }

                            {
                                var textBox = new ElmSharp.Box(infoBox);
                                textBox.SetAlignment(-1.0, -1.0);                             // fill
                                textBox.SetWeight(1.0, 0.0);                                  // expand on X axis
                                textBox.Show();
                                infoBox.PackEnd(textBox);

                                {
                                    var title = new NLabel(textBox)
                                    {
                                        Text           = pin.Label,
                                        FontAttributes = FontAttributes.Bold,
                                        TextColor      = ElmSharp.Color.White,
                                    };
                                    title.SetAlignment(-1.0, -1.0);                                 // fill
                                    title.SetWeight(1.0, 0.0);                                      // expand on X axis
                                    title.Show();
                                    textBox.PackEnd(title);
                                }

                                {
                                    var subtitle = new NLabel(textBox)
                                    {
                                        Text      = pin.Address,
                                        TextColor = ElmSharp.Color.White,
                                    };
                                    subtitle.SetAlignment(-1.0, -1.0);                                 // fill
                                    subtitle.SetWeight(1.0, 0.0);                                      // expand on X axis
                                    subtitle.Show();
                                    textBox.PackEnd(subtitle);
                                }
                            }

                            {
                                var info = new ElmSharp.Image(infoBox);
                                info.Load(InfoPath);
                                info.SetAlignment(-1.0, -1.0);                             // fill
                                info.SetWeight(1.0, 0.0);                                  // expand on X axis
                                info.Show();
                                infoBox.PackEnd(info);
                            }
                        }
                    }

                    {
                        var expander = new ElmSharp.Box(window);
                        expander.SetAlignment(-1.0, -1.0);                     // fill
                        expander.SetWeight(1.0, 1.0);                          // expand
                        expander.Show();
                        window.PackEnd(expander);
                    }

                    window.Resize(width, height);

                    Control.Add(new Overlay(coordinates, window));
                }

                isDrawn = true;
            }
        }
示例#14
0
        protected override ElmSharp.EvasObject OnGetContent(Cell cell, string part)
        {
            if (part != MainContentPart)
            {
                return(null);
            }
            NativeCell viewCell      = (NativeCell)cell;
            var        minimumHeight = PageHeight > 800 ? 96 : 76;

            ElmSharp.Box mainBox = new ElmSharp.Box(Forms.NativeParent);
            mainBox.BackgroundColor = Color.LightYellow.ToNative();
            mainBox.MinimumHeight   = minimumHeight;
            mainBox.IsHorizontal    = false;
            mainBox.SetAlignment(-1, -1);
            mainBox.Show();

            ElmSharp.Box contentBox = new ElmSharp.Box(Forms.NativeParent);
            contentBox.MinimumHeight = minimumHeight;
            contentBox.IsHorizontal  = true;
            contentBox.SetAlignment(-1, -1);
            contentBox.Show();

            ElmSharp.Box left = new ElmSharp.Box(Forms.NativeParent);
            left.IsHorizontal = false;
            left.Show();
            left.SetWeight(4.0, 1);
            left.SetAlignment(-1, -1);
            contentBox.PackEnd(left);

            ElmSharp.Label titleName = new ElmSharp.Label(Forms.NativeParent);
            left.PackEnd(titleName);
            titleName.Show();
            titleName.Text         = $"<span font_size=34 font_style=italic color=#7F3300>   {viewCell.Name}</span>";
            titleName.MinimumWidth = 250;
            titleName.SetAlignment(-1, -1);

            ElmSharp.Label titleCategory = new ElmSharp.Label(Forms.NativeParent);
            left.PackEnd(titleCategory);
            titleCategory.Show();
            titleCategory.Text = $"<span align=center font_size=24 color=#008000>{viewCell.Category}</span>";
            titleCategory.SetAlignment(-1, -1);

            ElmSharp.Box right = new ElmSharp.Box(Forms.NativeParent);
            right.Show();
            right.MinimumWidth  = 96;
            right.MinimumHeight = minimumHeight;
            right.SetWeight(1, 1);
            right.SetAlignment(-1, 0);

            ElmSharp.Image image;

            if (viewCell.ImageFilename != "")
            {
                image = new ElmSharp.Image(right);
                image.Load(global::Tizen.Applications.Application.Current.DirectoryInfo.Resource + viewCell.ImageFilename + ".jpg");
                image.SetAlignment(0.5, 0.5);
                image.MinimumHeight = minimumHeight;
                image.MinimumWidth  = minimumHeight;
                image.Show();
                right.PackEnd(image);
            }

            ElmSharp.Rectangle rec = new ElmSharp.Rectangle(left);
            rec.MinimumHeight = 1;
            rec.MinimumWidth  = 400;
            rec.AlignmentX    = -1;
            rec.Color         = ElmSharp.Color.Gray;
            rec.Show();

            contentBox.PackEnd(right);

            mainBox.PackEnd(contentBox);
            mainBox.PackEnd(rec);

            return(mainBox);
        }
示例#15
0
        public override void Run(ElmSharp.Box parent)
        {
            var refreshLayout = new RefreshLayout(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
            };

            var contentBox = new Box(parent)
            {
                WeightX         = 1,
                WeightY         = 1,
                AlignmentY      = -1,
                AlignmentX      = -1,
                BackgroundColor = ElmSharp.Color.Gray
            };

            var statusLabel = new Label(parent)
            {
                Text       = "Idle",
                WeightX    = 1,
                WeightY    = 1,
                AlignmentX = -1,
                AlignmentY = -1,
                TextColor  = Color.Beige,
                HorizontalTextAlignment = TextAlignment.Center,
                VerticalTextAlignment   = TextAlignment.Center,
                FontAttributes          = FontAttributes.Bold,
                FontSize = 30
            };

            statusLabel.Move(100, 200);
            statusLabel.Resize(300, 100);
            statusLabel.Show();

            var changeIconColorButton = new Button(parent)
            {
                Text       = "Change Icon Color",
                WeightX    = 1,
                WeightY    = 1,
                AlignmentX = -1,
                AlignmentY = -1,
            };

            changeIconColorButton.Move(100, 300);
            changeIconColorButton.Resize(400, 100);
            changeIconColorButton.Clicked += (s, e) =>
            {
                if (refreshLayout.IconColor == Color.Default)
                {
                    refreshLayout.IconColor = Color.Red;
                }
                else
                {
                    refreshLayout.IconColor = Color.Default;
                }
            };
            changeIconColorButton.Show();

            var changeIconBackgroundColorButton = new Button(parent)
            {
                Text       = "Change BackgroundColor",
                WeightX    = 1,
                WeightY    = 1,
                AlignmentX = -1,
                AlignmentY = -1,
            };

            changeIconBackgroundColorButton.Move(100, 400);
            changeIconBackgroundColorButton.Resize(400, 100);
            changeIconBackgroundColorButton.Clicked += (s, e) =>
            {
                if (refreshLayout.IconBackgroundColor == Color.Yellow)
                {
                    refreshLayout.IconBackgroundColor = Color.White;
                }
                else
                {
                    refreshLayout.IconBackgroundColor = Color.Yellow;
                }
            };
            changeIconBackgroundColorButton.Show();

            var changeRefreshingButton = new Button(parent)
            {
                Text       = $"Start Refreshing",
                WeightX    = 1,
                WeightY    = 1,
                AlignmentX = -1,
                AlignmentY = -1,
            };

            changeRefreshingButton.Move(100, 500);
            changeRefreshingButton.Resize(400, 100);
            changeRefreshingButton.Clicked += (s, e) =>
            {
                refreshLayout.IsRefreshing = true;
            };
            changeRefreshingButton.Show();

            contentBox.PackEnd(statusLabel);
            contentBox.PackEnd(changeIconColorButton);
            contentBox.PackEnd(changeIconBackgroundColorButton);
            contentBox.PackEnd(changeRefreshingButton);
            contentBox.Show();

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

            scrollView.SetScrollCanvas(contentBox);
            scrollView.SetContentSize(720, 2000);
            scrollView.Show();

            refreshLayout.Content          = scrollView;
            refreshLayout.IsRefreshEnabled = true;
            refreshLayout.IsEdgeScrolling  = () =>
            {
                if (scrollView.ScrollBound.Y == 0)
                {
                    return(true);
                }
                return(false);
            };
            refreshLayout.Refreshing += async(s, e) =>
            {
                statusLabel.Text = "Refreshing";
                await Task.Delay(2000);

                refreshLayout.IsRefreshing = false;
                statusLabel.Text           = "Refreshed";
            };
            refreshLayout.Show();
            parent.PackEnd(refreshLayout);
        }
示例#16
0
        public override void Run(ElmSharp.Box parent)
        {
            var scrollView = new ScrollView(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
                VerticalScrollBarVisibility = ScrollBarVisibility.Always,
            };

            scrollView.Show();

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

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

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

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

            ellipse1.Show();

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

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

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

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

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

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

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

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

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

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

            content.PackEnd(ellipseText3);
            content.PackEnd(ellipse3);
            content.PackEnd(aspectButton);
        }