Ejemplo n.º 1
0
        void AddToolbarItem(XToolbarItem item)
        {
            var moreOptionItem = new ActionMoreOptionItem();
            var icon           = item.Icon;

            if (!string.IsNullOrEmpty(icon.File))
            {
                var img = new ElmSharp.Image(_moreOption);
                img.LoadAsync(ResourcePath.GetPath(icon.File));
                moreOptionItem.Icon = img;
            }
            var text = item.Text;

            if (!string.IsNullOrEmpty(text))
            {
                moreOptionItem.MainText = text;
            }
            if (item is CircleToolbarItem)
            {
                var subText = ((CircleToolbarItem)item).SubText;
                if (!string.IsNullOrEmpty(subText))
                {
                    moreOptionItem.SubText = subText;
                }
            }
            moreOptionItem.Action = () => ((IMenuItemController)item).Activate();
            _moreOption.Items.Add(moreOptionItem);
            _toolbarItemMap[item] = moreOptionItem;
        }
        void UpdateActionButton(bool initialize)
        {
            if (Element.ActionButton != null)
            {
                if (_actionButton == null)
                {
                    _actionButton = new ElmSharp.Button(_box)
                    {
                        Style = "bottom"
                    };
                    _actionButton.Clicked += OnActionButtonClicked;
                    _box.PackEnd(_actionButton);
                }

                SetVisibleActionButton(Element.ActionButton.IsVisible);

                Element.ActionButton.PropertyChanged += OnActionButtonItemChanged;
                _actionButton.Text = Element.ActionButton.Text?.Replace("&", "&")
                                     .Replace("<", "&lt;")
                                     .Replace(">", "&gt;")
                                     .Replace(Environment.NewLine, "<br>");

                _actionButton.IsEnabled = Element.ActionButton.IsEnable;
                if (!Element.ActionButton.IconImageSource.IsNullOrEmpty())
                {
                    var imageSource = Element.ActionButton.IconImageSource as FileImageSource;
                    var path        = ResourcePath.GetPath(imageSource);
                    var buttonImage = new ElmSharp.Image(_actionButton);
                    buttonImage.LoadAsync(path);
                    buttonImage.Show();
                    _actionButton.SetPartContent("elm.swallow.content", buttonImage);
                }
                else
                {
                    _actionButton.SetPartContent("elm.swallow.content", null);
                }

                _actionButton.BackgroundColor = Element.ActionButton.BackgroundColor.ToNative();
            }
            else
            {
                if (_actionButton != null)
                {
                    _actionButton.Clicked -= OnActionButtonClicked;
                    _box.UnPack(_actionButton);
                    _actionButton.Unrealize();
                    _actionButton = null;
                }
            }
        }
Ejemplo n.º 3
0
        void UpdateActionButton(bool initialize)
        {
            if (Element.ActionButton != null)
            {
                if (_actionButton == null)
                {
                    _actionButton = new ElmSharp.Button(_box)
                    {
                        Style = "bottom"
                    };
                    _actionButton.Clicked += OnActionButtonClicked;
                    _box.PackEnd(_actionButton);
                }

                SetVisibleActionButton(Element.ActionButton.IsVisible);

                Element.ActionButton.PropertyChanged += OnActionButtonItemChanged;
                _actionButton.Text      = Element.ActionButton.Text;
                _actionButton.IsEnabled = Element.ActionButton.IsEnable;
                if (!Element.ActionButton.IconImageSource.IsNullOrEmpty())
                {
                    var imageSource = Element.ActionButton.IconImageSource as FileImageSource;
                    var path        = ResourcePath.GetPath(imageSource);
                    var buttonImage = new ElmSharp.Image(_actionButton);
                    buttonImage.LoadAsync(path);
                    buttonImage.Show();
                    _actionButton.SetPartContent("elm.swallow.content", buttonImage);
                }

                if (Element.ActionButton.BackgroundColor != Xamarin.Forms.Color.Default)
                {
                    _actionButton.BackgroundColor = Element.ActionButton.BackgroundColor.ToNative();
                }
            }
            else
            {
                if (_actionButton != null)
                {
                    _actionButton.Clicked -= OnActionButtonClicked;
                    _box.UnPack(_actionButton);
                    _actionButton.Unrealize();
                    _actionButton = null;
                }
            }
        }
Ejemplo n.º 4
0
        public GraphicPopUpRenderer()
        {
            Console.WriteLine("GraphicPopUpRenderer()  GetHashCode:" + this.GetHashCode());
            _popUp = new Popup(Forms.NativeParent)
            {
                Style       = "toast/circle",
                Orientation = PopupOrientation.Center,
                AllowEvents = true,
            };
            var path  = ResourcePath.GetPath("tw_ic_popup_btn_check.png");
            var image = new ElmSharp.Image(_popUp);

            image.LoadAsync(path);
            image.Show();
            _popUp.SetPartContent("toast,icon", image);
            _popUp.BackButtonPressed += BackButtonPressedHandler;
            _popUp.TimedOut          += TimedOutHandler;
            _popUp.Dismissed         += _popUp_Dismissed;
        }
Ejemplo n.º 5
0
        void UpdateActionButton(bool initialize)
        {
            if (Element.ActionButton != null)
            {
                if (_actionButton == null)
                {
                    _actionButton = new ElmSharp.Button(_box)
                    {
                        Style = "bottom"
                    };
                    _actionButton.Clicked += OnActionButtonClicked;
                    _box.PackEnd(_actionButton);
                }

                SetVisibleActionButton(Element.ActionButton.IsVisible);

                Element.ActionButton.PropertyChanged += OnActionButtonItemChanged;
                _actionButton.Text      = Element.ActionButton.Text;
                _actionButton.IsEnabled = Element.ActionButton.IsEnable;
                if (Element.ActionButton.Icon != null)
                {
                    var path        = ResourcePath.GetPath(Element.ActionButton.Icon);
                    var buttonImage = new ElmSharp.Image(_actionButton);
                    buttonImage.LoadAsync(path);
                    buttonImage.Show();
                    _actionButton.SetPartContent("elm.swallow.content", buttonImage);
                }
            }
            else
            {
                if (_actionButton != null)
                {
                    _actionButton.Clicked -= OnActionButtonClicked;
                    _box.UnPack(_actionButton);
                    _actionButton.Unrealize();
                    _actionButton = null;
                }
            }
        }
        void UpdateActionButton(bool initialize)
        {
            if (initialize && Element.ActionButton == null)
            {
                return;
            }

            if (Element.ActionButton != null)
            {
                SetVisibleActionButton(Element.ActionButton.IsVisible);

                Element.ActionButton.PropertyChanged += OnActionButtonItemChanged;
                _actionButton.Text      = Element.ActionButton.Text;
                _actionButton.IsEnabled = Element.ActionButton.IsEnable;
                if (Element.ActionButton.Icon != null)
                {
                    var path        = ResourcePath.GetPath(Element.ActionButton.Icon);
                    var buttonImage = new ElmSharp.Image(_actionButton);
                    buttonImage.LoadAsync(path);
                    buttonImage.Show();
                    _actionButton.SetPartContent("elm.swallow.content", buttonImage);
                }
            }
        }
        /// <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);
        }