예제 #1
0
        EvasObject GetContent(object data, string part)
        {
            ShellSection section = data as ShellSection;

            var box = new EBox(Forms.NativeParent);

            box.Show();

            EImage icon = null;

            if (section.Icon != null)
            {
                icon = new EImage(Forms.NativeParent);
                icon.Show();
                box.PackEnd(icon);
                _ = icon.LoadFromImageSourceAsync(section.Icon);
            }

            var title = new Native.Label(Forms.NativeParent)
            {
                Text     = section.Title,
                FontSize = Forms.ConvertToEflFontPoint(14),
                HorizontalTextAlignment = Native.TextAlignment.Start,
                VerticalTextAlignment   = Native.TextAlignment.Center,
            };

            title.Show();
            box.PackEnd(title);
            int iconPadding = Forms.ConvertToScaledPixel(this.GetIconPadding());
            int iconSize    = Forms.ConvertToScaledPixel(this.GetIconSize());
            int cellHeight  = iconPadding * 2 + iconSize;

            box.SetLayoutCallback(() =>
            {
                var bound      = box.Geometry;
                int leftMargin = iconPadding;

                if (icon != null)
                {
                    var iconBound    = bound;
                    iconBound.X     += iconPadding;
                    iconBound.Y     += iconPadding;
                    iconBound.Width  = iconSize;
                    iconBound.Height = iconSize;
                    icon.Geometry    = iconBound;
                    leftMargin       = (2 * iconPadding + iconSize);
                }

                bound.X       += leftMargin;
                bound.Width   -= leftMargin;
                title.Geometry = bound;
            });

            box.MinimumHeight = cellHeight;
            return(box);
        }
        public override void Run(ElmSharp.Box parent)
        {
            DateTimePicker dateTime = new DateTimePicker(parent)
            {
                WeightX         = 1,
                WeightY         = 1,
                AlignmentY      = -1,
                AlignmentX      = -1,
                MinimumDateTime = new DateTime(2021, 1, 1),
                MaximumDateTime = DateTime.Now,
                DateTime        = DateTime.Now
            };

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

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

            Label label3 = new Label(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
                Text       = string.Format("Current DateTime={0}", dateTime.DateTime),
            };

            dateTime.DateTimeChanged += (object sender, DateChangedEventArgs e) =>
            {
                label1.Text = string.Format("Old DateTime={0}", e.OldDate);
                label2.Text = string.Format("New DateTime={0}", e.NewDate);
                label3.Text = string.Format("Current DateTime={0}", dateTime.DateTime);
            };

            dateTime.Show();
            label1.Show();
            label2.Show();
            label3.Show();

            parent.PackEnd(dateTime);
            parent.PackEnd(label1);
            parent.PackEnd(label2);
            parent.PackEnd(label3);
        }
        public override void Run(ElmSharp.Box parent)
        {
            DateTimePicker dateTime = new DateTimePicker(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
                DateTime   = DateTime.Today,
                Style      = "time_layout",
                Format     = "%d/%b/%Y %I:%M %p"
            };

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

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

            Label label3 = new Label(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
                Text       = string.Format("Current DateTime={0}", dateTime.DateTime),
            };

            dateTime.DateTimeChanged += (object sender, DateChangedEventArgs e) =>
            {
                label1.Text = string.Format("Old DateTime={0}", e.OldDate);
                label2.Text = string.Format("New DateTime={0}", e.NewDate);
                label3.Text = string.Format("Current DateTime={0}", dateTime.DateTime);
            };

            dateTime.Show();
            label1.Show();
            label2.Show();
            label3.Show();

            parent.PackEnd(dateTime);
            parent.PackEnd(label1);
            parent.PackEnd(label2);
            parent.PackEnd(label3);
        }
예제 #4
0
        void UpdateCurrentItem(ShellContent content)
        {
            if (_currentContent != null)
            {
                _currentContent.Hide();
                _contentArea.UnPack(_currentContent);
                _currentContent = null;
            }

            if (content == null)
            {
                return;
            }

            if (!_contentCache.ContainsKey(content))
            {
                var native = CreateShellContent(content);
                native.SetAlignment(-1, -1);
                native.SetWeight(1, 1);
                _contentCache[content] = native;
            }
            _currentContent = _contentCache[content];
            _currentContent.Show();
            _contentArea.PackEnd(_currentContent);
        }
예제 #5
0
        public override void Run(ElmSharp.Box parent)
        {
            var label = new Label(parent)
            {
                WeightX       = 1,
                WeightY       = 1,
                AlignmentY    = 0.5,
                AlignmentX    = 0.5,
                FontSize      = 30,
                FormattedText = new FormattedString
                {
                    Spans =
                    {
                        new Span
                        {
                            Text           = "Span1-bold ",
                            FontAttributes = FontAttributes.Bold,
                        },
                        new Span
                        {
                            Text            = "Span2-red ",
                            ForegroundColor = Color.Red
                        },
                        new Span
                        {
                            Text     = "Span3-Large",
                            FontSize = 60,
                        }
                    }
                }
            };

            label.Show();
            parent.PackEnd(label);
        }
예제 #6
0
        public override void Run(ElmSharp.Box parent)
        {
            var container = new Canvas(parent)
            {
                AlignmentX    = -1,
                AlignmentY    = -1,
                WeightX       = 1,
                WeightY       = 1,
                MinimumHeight = 300,
            };

            container.Show();
            parent.PackEnd(container);

            container.LayoutUpdated += (s, e) =>
            {
                foreach (var child in container.Children)
                {
                    child.Geometry = container.Geometry;
                    if (child is SKClipperView clip)
                    {
                        clip.Invalidate();
                    }
                }
            };

            var img1 = new Image(parent);

            img1.Show();
            img1.Load(Application.Current.DirectoryInfo.Resource + "animated.gif");
            img1.SetIsAnimationPlaying(true);

            var clipper = new SKClipperView(parent);

            clipper.Show();
            clipper.PaintSurface += (s, e) =>
            {
                var canvas = e.Surface.Canvas;
                var width  = e.Info.Width;
                var height = e.Info.Height;

                using (var paint = new SKPaint
                {
                    IsAntialias = true,
                    Color = SKColors.White,
                    Style = SKPaintStyle.Fill,
                })
                {
                    canvas.Clear();
                    canvas.DrawCircle(width / 2.0f, height / 2.0f, Math.Min(width / 2.0f, height / 2.0f) / 2.0f, paint);
                }

                img1.SetClipperCanvas(clipper);
            };
            clipper.Lower();
            container.Children.Add(img1);
            container.Children.Add(clipper);
        }
 void UpdateCarouselContent()
 {
     _innerContainer.UnPackAll();
     foreach (var page in Element.Children)
     {
         var nativeView = Xamarin.Forms.Platform.Tizen.Platform.GetRenderer(page).NativeView;
         _innerContainer.PackEnd(nativeView);
     }
     _pageIndex        = Element.Children.IndexOf(Element.CurrentPage);
     _isUpdateCarousel = true;
     _scroller.ScrollTo(_pageIndex, 0, false);
     Element.UpdateFocusTreePolicy();
 }
예제 #8
0
 void UpdateCarouselContent()
 {
     _innerContainer.UnPackAll();
     foreach (var page in Element.Children)
     {
         var nativeView = Xamarin.Forms.Platform.Tizen.Platform.GetRenderer(page).NativeView;
         _innerContainer.PackEnd(nativeView);
         // if possible, make the subpage focusable, this ensures that there is something
         // to focus on all pages and prevents the scroller from auto-scrolling to focused widget
         (nativeView as ElmSharp.Widget)?.AllowFocus(true);
     }
     _pageIndex = Element.Children.IndexOf(Element.CurrentPage);
     _scroller.ScrollTo(_pageIndex, 0, false);
 }
예제 #9
0
        public TVShellSectionRenderer(ShellSection section)
        {
            ShellSection = section;
            ShellSection.PropertyChanged += OnSectionPropertyChanged;
            (ShellSection.Items as INotifyCollectionChanged).CollectionChanged += OnShellSectionCollectionChanged;

            _mainLayout = new EBox(Forms.NativeParent);
            _mainLayout.SetLayoutCallback(OnLayout);

            _contentArea = new EBox(Forms.NativeParent);
            _contentArea.Show();
            _mainLayout.PackEnd(_contentArea);

            UpdateSectionItems();
            UpdateCurrentItem(ShellSection.CurrentItem);
        }
예제 #10
0
        void UpdateCarouselContent()
        {
            _innerContainer.UnPackAll();
            _layoutBound = new ESize(0, 0);
            foreach (var page in Element.Children)
            {
                var nativeView = Platform.GetOrCreateRenderer(page).NativeView;
                _innerContainer.PackEnd(nativeView);
            }
            _pageIndex = Element.Children.IndexOf(Element.CurrentPage);

            _isUpdateCarousel = true;
            _scroller.ScrollTo(_pageIndex, 0, false);
            Element.UpdateFocusTreePolicy();
            _isUpdateCarousel = false;
        }
예제 #11
0
        public ShellSectionRenderer(ShellSection section)
        {
            ShellSection = section;
            ShellSection.PropertyChanged += OnSectionPropertyChanged;
            (ShellSection.Items as INotifyCollectionChanged).CollectionChanged += OnShellSectionCollectionChanged;

            _mainLayout = new EBox(Forms.NativeParent);
            _mainLayout.SetLayoutCallback(OnLayout);

            _contentArea = new EBox(Forms.NativeParent);
            _contentArea.Show();
            _mainLayout.PackEnd(_contentArea);

            UpdateTabsItem();
            UpdateCurrentItem(ShellSection.CurrentItem);

            ((IShellController)Shell.Current).AddAppearanceObserver(this, ShellSection);
            (ShellSection as IShellSectionController).AddDisplayedPageObserver(this, UpdateDisplayedPage);
        }
예제 #12
0
        public TVShellSectionHandler(ShellSection section, IMauiContext context)
        {
            ShellSection = section;
            MauiContext  = context;
            ShellSection.PropertyChanged += OnSectionPropertyChanged;
            if (ShellSection.Items is INotifyCollectionChanged collection)
            {
                collection.CollectionChanged += OnShellSectionCollectionChanged;
            }

            _mainLayout = new EBox(PlatformParent);
            _mainLayout.SetLayoutCallback(OnLayout);

            _contentArea = new EBox(PlatformParent);
            _contentArea.Show();
            _mainLayout.PackEnd(_contentArea);

            UpdateSectionItems();
            UpdateCurrentItem(ShellSection.CurrentItem);
        }
예제 #13
0
        public ShellSectionHandler(ShellSection section, IMauiContext context)
        {
            ShellSection = section;
            MauiContext  = context;
            ShellSection.PropertyChanged += OnSectionPropertyChanged;
            if (ShellSection.Items is INotifyCollectionChanged collection)
            {
                collection.CollectionChanged += OnShellSectionCollectionChanged;
            }

            _mainLayout = new EBox(PlatformParent);
            _mainLayout.SetLayoutCallback(OnLayout);

            _contentArea = new EBox(PlatformParent);
            _contentArea.Show();
            _mainLayout.PackEnd(_contentArea);

            UpdateTabsItem();
            UpdateCurrentItem(ShellSection.CurrentItem);

            ((IShellController)Shell.Current).AddAppearanceObserver(this, ShellSection);
            (ShellSection as IShellSectionController).AddDisplayedPageObserver(this, UpdateDisplayedPage);
        }
예제 #14
0
        public ShellItemView(ShellItem item, IMauiContext context)
        {
            ShellItem   = item;
            MauiContext = context;

            //Initialize();
            _mainLayout = new EBox(NativeParent);
            _mainLayout.SetLayoutCallback(OnLayout);
            _mainLayout.Show();
            _contentHolder = new EBox(NativeParent);
            _contentHolder.Show();
            _mainLayout.PackEnd(_contentHolder);

            ShellItem.PropertyChanged += OnShellItemPropertyChanged;
            if (ShellItem.Items is INotifyCollectionChanged notifyCollectionChanged)
            {
                notifyCollectionChanged.CollectionChanged += OnShellItemsCollectionChanged;
            }
            ShellController.AddAppearanceObserver(this, ShellItem);

            UpdateTabsItems();
            UpdateCurrentItem(ShellItem.CurrentItem);
        }
예제 #15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Tizen.UIExtensions.ElmSharp.TVNavigationDrawer"/> class.
        /// </summary>
        /// <param name="parent"></param>
        public TVNavigationDrawer(EvasObject parent) : base(parent)
        {
            SetLayoutCallback(OnLayout);

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

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

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

            _behavior = Common.DrawerBehavior.Drawer;

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

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

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

            UpdateFocusPolicy();
        }
예제 #16
0
        public ElmSharp.EvasObject GetContent(object data, string part)
        {
            var minimumHeight = PageHeight > 800 ? 96 : 76;

            if (part == "elm.swallow.content")
            {
                DataSource2  itemSource = (DataSource2)data;
                ElmSharp.Box mainBox    = new ElmSharp.Box(Forms.NativeParent);
                mainBox.BackgroundColor = Xamarin.Forms.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>   {itemSource.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>{itemSource.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 (itemSource.ImageFilename != "")
                {
                    image = new ElmSharp.Image(right);
                    image.Load(global::Tizen.Applications.Application.Current.DirectoryInfo.Resource + itemSource.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);
            }
            return(null);
        }
예제 #17
0
        public override void Run(ElmSharp.Box parent)
        {
            var flyoutBox = new ElmSharp.Box(parent);
            var detailBox = new ElmSharp.Box(parent);

            var flyoutPage = new FlyoutPage(parent)
            {
                AlignmentX  = -1,
                AlignmentY  = -1,
                WeightX     = 1,
                WeightY     = 1,
                IsPresented = false,
                Flyout      = flyoutBox,
                Detail      = detailBox,
            };

            flyoutPage.DimArea.BackgroundColor = EColor.Blue;
            flyoutPage.DimArea.Opacity         = 100;

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

            GenItemClass defaultClass = new GenItemClass("default")
            {
                GetTextHandler = (data, part) =>
                {
                    return(data as string);
                }
            };

            for (int i = 0; i < 10; i++)
            {
                list.Append(defaultClass, $"Flyout List Item {i}");
            }

            list.Show();
            flyoutBox.PackEnd(list);

            var openLabel = new ElmSharp.Label(parent)
            {
                AlignmentX = 0.5,
                WeightX    = 1,
                Text       = $"IsPresented: {flyoutPage.IsPresented}"
            };

            var gestureLabel = new ElmSharp.Label(parent)
            {
                AlignmentX = 0.5,
                WeightX    = 1,
                Text       = $"IsGestureEnabled: {flyoutPage.IsGestureEnabled}"
            };

            var behaviorLabel = new ElmSharp.Label(parent)
            {
                AlignmentX = 0.5,
                WeightX    = 1,
                Text       = $"FlyoutLayoutBehavior: {flyoutPage.FlyoutLayoutBehavior}"
            };

            var openButton = new ElmSharp.Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "Open Flyout"
            };

            var gestureButton = new ElmSharp.Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "Enable/Disable Gesture"
            };

            var behaviorButton = new ElmSharp.Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "Default/Split Behavior"
            };

            var sRatioButton = new ElmSharp.Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "Split ratio + 10"
            };

            var dRatioButton = new ElmSharp.Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "popover ratio + 10"
            };

            var sRatioButton2 = new ElmSharp.Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "Split ratio - 10"
            };

            var dRatioButton2 = new ElmSharp.Button(parent)
            {
                AlignmentX = -1,
                WeightX    = 1,
                Text       = "popover ratio - 10"
            };

            list.ItemSelected += (s, e) =>
            {
                flyoutPage.IsPresented = false;
            };

            flyoutPage.IsPresentedChanged += (s, e) =>
            {
                openLabel.Text = $"IsPresented: {flyoutPage.IsPresented}";
            };

            openButton.Clicked += (s, e) =>
            {
                flyoutPage.IsPresented = !flyoutPage.IsPresented;
            };

            gestureButton.Clicked += (s, e) =>
            {
                flyoutPage.IsGestureEnabled = !flyoutPage.IsGestureEnabled;
                gestureLabel.Text           = $"IsGestureEnabled: {flyoutPage.IsGestureEnabled}";
            };


            sRatioButton.Clicked += (s, e) =>
            {
                flyoutPage.SplitRatio += 0.1;
            };

            sRatioButton2.Clicked += (s, e) =>
            {
                flyoutPage.SplitRatio -= 0.1;
            };

            dRatioButton.Clicked += (s, e) =>
            {
                flyoutPage.PopoverRatio += 0.1;
            };

            dRatioButton2.Clicked += (s, e) =>
            {
                flyoutPage.PopoverRatio -= 0.1;
            };

            behaviorButton.Clicked += (s, e) =>
            {
                if (flyoutPage.FlyoutLayoutBehavior == FlyoutLayoutBehavior.Default)
                {
                    flyoutPage.FlyoutLayoutBehavior = FlyoutLayoutBehavior.Split;
                }
                else
                {
                    flyoutPage.FlyoutLayoutBehavior = FlyoutLayoutBehavior.Default;
                }

                behaviorLabel.Text = $"FlyoutLayoutBehavior: {flyoutPage.FlyoutLayoutBehavior}";
                openLabel.Text     = $"IsPresented: {flyoutPage.IsPresented}";
            };


            openLabel.Show();
            gestureLabel.Show();
            behaviorLabel.Show();

            openButton.Show();
            gestureButton.Show();
            behaviorButton.Show();
            sRatioButton.Show();
            sRatioButton2.Show();
            dRatioButton.Show();
            dRatioButton2.Show();

            detailBox.PackEnd(openLabel);
            detailBox.PackEnd(gestureLabel);
            detailBox.PackEnd(behaviorLabel);

            detailBox.PackEnd(openButton);
            detailBox.PackEnd(gestureButton);
            detailBox.PackEnd(behaviorButton);
            detailBox.PackEnd(sRatioButton);
            detailBox.PackEnd(sRatioButton2);
            detailBox.PackEnd(dRatioButton);
            detailBox.PackEnd(dRatioButton2);

            flyoutBox.Show();
            detailBox.Show();
            flyoutPage.Show();
            parent.PackEnd(flyoutPage);
        }
        public override void Run(ElmSharp.Box parent)
        {
            Console.WriteLine($" run !!!");
            var data = new List <string>();

            for (int i = 0; i < 50; i++)
            {
                data.Add($"item {i}");
            }

            var drawer = new Ext.TVNavigationDrawer(parent)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1,
            };

            var naviView = new Ext.TVNavigationView(parent);

            var content = new Box(parent)
            {
                BackgroundColor = Color.White
            };

            var label = new Label(parent)
            {
                AlignmentX = 0.5,
                WeightX    = 1,
                Text       = "selected item index: / data: ",
            };

            label.Show();
            content.PackEnd(label);

            var bLabel = new Label(parent)
            {
                AlignmentX = 0.5,
                WeightX    = 1,
                Text       = "behavior: ",
            };

            bLabel.Show();
            content.PackEnd(bLabel);

            var openButton = new Button(parent)
            {
                MinimumWidth = 500,
                Text         = "open / close"
            };

            openButton.Show();
            content.PackEnd(openButton);

            var headerButton = new Button(parent)
            {
                MinimumWidth = 500,
                Text         = "add / remove header"
            };

            headerButton.Show();
            content.PackEnd(headerButton);

            var footerButton = new Button(parent)
            {
                MinimumWidth = 500,
                Text         = "add / remove footer"
            };

            footerButton.Show();
            content.PackEnd(footerButton);


            var contentButton = new Button(parent)
            {
                MinimumWidth = 500,
                Text         = "add / remove content"
            };

            contentButton.Show();
            content.PackEnd(contentButton);



            var headerButton2 = new Button(parent)
            {
                MinimumHeight = 100,
                MinimumWidth  = 300,
                Text          = "header"
            };

            headerButton2.Show();
            content.PackEnd(headerButton2);

            headerButton2.Clicked += (s, e) =>
            {
                if (_header.MinimumHeight < 200)
                {
                    _header.MinimumHeight = 300;
                }
                else
                {
                    _header.MinimumHeight = 150;
                }
            };

            openButton.Clicked += (s, e) =>
            {
                drawer.IsOpen = !drawer.IsOpen;
            };

            headerButton.Clicked += (s, e) =>
            {
                if (naviView.Header != null)
                {
                    naviView.Header = null;
                }
                else
                {
                    naviView.Header = CreateHeader(parent);
                }
            };

            footerButton.Clicked += (s, e) =>
            {
                if (naviView.Footer != null)
                {
                    naviView.Footer = null;
                }
                else
                {
                    naviView.Footer = CreateFooter(parent);
                }
            };

            contentButton.Clicked += (s, e) =>
            {
                if (naviView.Content != null)
                {
                    naviView.Content = null;
                }
                else
                {
                    naviView.Content = CreateContent(parent);
                }
            };

            naviView.Header          = CreateHeader(parent);
            naviView.Footer          = CreateFooter(parent);
            naviView.Content         = CreateContent(parent);
            naviView.BackgroundImage = CreateBackgroundImage(parent);
            //naviView.BackgroundColor = Color.Yellow;

            drawer.Main           = content;
            drawer.NavigationView = naviView;

            drawer.Show();
            parent.PackEnd(drawer);
        }
        /// <summary>
        /// Initialize ThumbnailIndex View
        /// </summary>
        private void Initialize()
        {
            Console.WriteLine("Initialize");
            _isFirstItem = true;

            _pbox = new PaddingBox(Forms.NativeParent)
            {
                Padding = new Thickness {
                    Left = 0, Right = 0, Top = 22, Bottom = 0
                },
                HeaderSize = new ElmSharp.Size(200, 19),
                HeaderGap  = 38
            };
            _pbox.Show();

            _index = new ElmSharp.Index(_pbox)
            {
                Style        = "thumbnail",
                AutoHide     = false,
                IsHorizontal = true,
                AlignmentX   = 0.5,
                AlignmentY   = 0.5,
            };
            _index.Show();
            _pbox.Header = _index;
            //index.Geometry = new Rect(0, 22, 200, 19);

            _scroller = new ElmSharp.Scroller(_pbox)
            {
                HorizontalLoop = false,
                VerticalLoop   = false,
                HorizontalScrollBarVisiblePolicy = ScrollBarVisiblePolicy.Invisible,
                VerticalScrollBarVisiblePolicy   = ScrollBarVisiblePolicy.Invisible,
                HorizontalPageScrollLimit        = 1,
                VerticalPageScrollLimit          = 0,
            };

            _scroller.PageScrolled += (s, e) =>
            {
                Console.WriteLine($" _scroller PageScrolled");
                var pageIndex = _scroller.HorizontalPageIndex;
                _items[pageIndex].Select(true);
            };
            _scroller.Show();
            _pbox.Content = _scroller;
            //_scroller.Geometry = new Rect(0, 79, 360, 281);

            var box = new ElmSharp.Box(_scroller)
            {
                IsHorizontal = true,
                AlignmentX   = 0.5,
                AlignmentY   = 0.5,
            };

            _scroller.SetContent(box);
            box.Show();

            // Create Rectangle for layout center align in Box
            var padder = new ElmSharp.Rectangle(box);

            box.PackEnd(padder);
            _items.Clear();

            // Initialize ThumbnailItems
            foreach (var item in Element.ThumbnailItems)
            {
                // create layout
                var page = new ElmSharp.Layout(box)
                {
                    WeightX    = 1.0,
                    WeightY    = 1.0,
                    AlignmentX = -1.0,
                    AlignmentY = 0.5
                };
                page.SetTheme("layout", "body_thumbnail", "default");
                page.Show();

                // set icon
                var img  = new ElmSharp.Image(page);
                var icon = item.Image;
                Console.WriteLine($"item.Image File:{icon.File}");
                img.LoadAsync(ResourcePath.GetPath(icon.File));
                page.SetPartContent("elm.icon", img);

                var indexItem = _index.Append(null);
                _items.Add(indexItem);

                // first item case
                if (_isFirstItem)
                {
                    Console.WriteLine($"_isFirstItem is true");
                    page.Resized += (s, e) =>
                    {
                        var g  = _scroller.Geometry;
                        var pg = page.Geometry;
                        padder.MinimumWidth  = (g.Width - pg.Width) / 2;
                        padder.MinimumHeight = g.Height / 2;
                        _scroller.SetPageSize(pg.Width, pg.Height);
                    };
                    indexItem.Select(true);
                }

                _isFirstItem = false;
                box.PackEnd(page);
            }

            box.PackEnd(padder);
            _index.Update(0);
        }
예제 #20
0
        public override void Run(ElmSharp.Box parent)
        {
            var scrollview = new ScrollView(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
            };

            scrollview.Show();
            scrollview.ScrollOrientation = ScrollOrientation.Vertical;
            parent.PackEnd(scrollview);

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

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


            var img1 = new Image(parent)
            {
                AlignmentX    = -1,
                AlignmentY    = -1,
                WeightX       = 1,
                WeightY       = 1,
                MinimumHeight = 300,
            };

            img1.Show();
            img1.LoadAsync(Application.Current.DirectoryInfo.Resource + "image.png");
            scrollCanvas.PackEnd(img1);

            {
                var label = new Label(parent)
                {
                    Text = "AspectFill"
                };
                label.Show();
                scrollCanvas.PackEnd(label);
                var img2 = new Image(parent)
                {
                    AlignmentX    = -1,
                    AlignmentY    = -1,
                    WeightX       = 1,
                    WeightY       = 1,
                    MinimumHeight = 300,
                };
                img2.Show();
                img2.Aspect = Aspect.AspectFill;
                img2.LoadAsync("http://i.imgur.com/9f974SC.jpg");
                img2.LoadingCompleted += (s, e) => Console.WriteLine($"Loading completed");
                scrollCanvas.PackEnd(img2);
            }

            {
                var label = new Label(parent)
                {
                    Text = "AppectFit"
                };
                label.Show();
                scrollCanvas.PackEnd(label);

                var img2 = new Image(parent)
                {
                    AlignmentX    = -1,
                    AlignmentY    = -1,
                    WeightX       = 1,
                    WeightY       = 1,
                    MinimumHeight = 300,
                };
                img2.Show();
                img2.Aspect = Aspect.AspectFit;
                img2.LoadAsync("http://i.imgur.com/9f974SC.jpg");
                img2.LoadingCompleted += (s, e) => Console.WriteLine($"Loading completed");
                scrollCanvas.PackEnd(img2);
            }

            {
                var label = new Label(parent)
                {
                    Text = "Fill"
                };
                label.Show();
                scrollCanvas.PackEnd(label);

                var img2 = new Image(parent)
                {
                    AlignmentX    = -1,
                    AlignmentY    = -1,
                    WeightX       = 1,
                    WeightY       = 1,
                    MinimumHeight = 300,
                };
                img2.Show();
                img2.Aspect = Aspect.Fill;
                img2.LoadAsync("http://i.imgur.com/9f974SC.jpg");
                img2.LoadingCompleted += (s, e) => Console.WriteLine($"Loading completed");
                scrollCanvas.PackEnd(img2);
            }

            {
                var label = new Label(parent)
                {
                    Text = "Animated"
                };
                label.Show();
                scrollCanvas.PackEnd(label);

                var animated = new Image(parent)
                {
                    AlignmentX    = -1,
                    AlignmentY    = -1,
                    WeightX       = 1,
                    WeightY       = 1,
                    MinimumHeight = 300,
                };
                animated.Show();
                animated.Aspect = Aspect.AspectFit;
                animated.LoadAsync(Application.Current.DirectoryInfo.Resource + "animated.gif");

                animated.LoadingCompleted += (s, e) =>
                {
                    Console.WriteLine($"Loading completed");
                    animated.SetIsAnimationPlaying(true);
                };
                scrollCanvas.PackEnd(animated);
            }

            {
                var label = new Label(parent)
                {
                    Text = "IsAnimationPlaying = false"
                };
                label.Show();
                scrollCanvas.PackEnd(label);

                var img2 = new Image(parent)
                {
                    AlignmentX    = -1,
                    AlignmentY    = -1,
                    WeightX       = 1,
                    WeightY       = 1,
                    MinimumHeight = 300,
                };
                img2.Show();
                img2.Aspect = Aspect.AspectFit;
                img2.LoadAsync(Application.Current.DirectoryInfo.Resource + "animated2.gif");
                img2.LoadingCompleted += (s, e) =>
                {
                    Console.WriteLine($"Loading completed");
                    (s as Image).SetIsAnimationPlaying(false);
                };
                scrollCanvas.PackEnd(img2);
            }

            scrollview.SetContentSize(720, 3000);
        }
예제 #21
0
        public override void Run(ElmSharp.Box parent)
        {
            var scrollBox = new ElmSharp.Box(parent)
            {
                IsHorizontal  = true,
                WeightX       = 1,
                AlignmentX    = -1,
                MinimumHeight = 100,
            };

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

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

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

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

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

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

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

            int itemWidth  = 500;
            int itemHeight = 500;

            int itemCols = 5;
            int itemRows = 5;

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

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

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

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

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

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

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

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


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

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

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

            hScroll.Show();
            hScroll.Clicked += (s, e) =>
            {
                if (scrollview.ScrollOrientation == ScrollOrientation.Vertical || scrollview.ScrollOrientation == ScrollOrientation.Neither)
                {
                    hScroll.Text = "H-Scroll(O)";
                    scrollview.ScrollOrientation = scrollview.ScrollOrientation == ScrollOrientation.Vertical ? ScrollOrientation.Both : ScrollOrientation.Horizontal;
                }
                else
                {
                    hScroll.Text = "H-Scroll(X)";
                    scrollview.ScrollOrientation = scrollview.ScrollOrientation == ScrollOrientation.Both ? ScrollOrientation.Vertical : ScrollOrientation.Neither;
                }
            };
            menu.PackEnd(hScroll);
        }
예제 #22
0
        public override void Run(ElmSharp.Box parent)
        {
            var scrollview = new ScrollView(parent)
            {
                WeightX    = 1,
                WeightY    = 1,
                AlignmentY = -1,
                AlignmentX = -1,
            };

            scrollview.Show();
            scrollview.ScrollOrientation = ScrollOrientation.Vertical;
            parent.PackEnd(scrollview);

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

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

            RadioButton rd1 = new RadioButton(parent)
            {
                StateValue          = 1,
                Text                = "Value #1",
                TextColor           = Color.Violet,
                TextBackgroundColor = Color.Yellow,
                AlignmentX          = -1,
                AlignmentY          = 0,
                WeightX             = 1,
                WeightY             = 1
            };

            rd1.Show();

            Radio rd2 = new Radio(parent)
            {
                StateValue = 2,
                Text       = "Value #2",
                AlignmentX = -1,
                AlignmentY = 0,
                WeightX    = 1,
                WeightY    = 1
            };

            rd2.Show();

            Radio rd3 = new Radio(parent)
            {
                StateValue = 3,
                Text       = "Value #3",
                AlignmentX = -1,
                AlignmentY = 0,
                WeightX    = 1,
                WeightY    = 1
            };

            rd3.Show();

            rd2.SetGroup(rd1);
            rd3.SetGroup(rd2);

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

            label.Show();

            rd1.ValueChanged += OnRadioValueChanged;
            rd2.ValueChanged += OnRadioValueChanged;
            rd3.ValueChanged += OnRadioValueChanged;

            void OnRadioValueChanged(object sender, EventArgs e)
            {
                label.Text = string.Format("Value Changed: {0}", ((Radio)sender).GroupValue);
            }

            scrollCanvas.PackEnd(label);
            scrollCanvas.PackEnd(rd1);
            scrollCanvas.PackEnd(rd2);
            scrollCanvas.PackEnd(rd3);

            scrollview.SetContentSize(720, 3000);
        }
예제 #23
0
        void OnActionSheetRequest(Page sender, ActionSheetArguments arguments)
        {
            // Verify that the page making the request is child of this platform
            if (!PageIsInThisContext(sender))
            {
                return;
            }

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

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

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

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

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

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

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

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

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

            alert.Show();

            _alerts.Add(alert);
            alert.Dismissed += (s, e) => _alerts.Remove(alert);
        }