Ejemplo n.º 1
0
        protected override EvasObject OnGetContent(Cell cell, string part)
        {
            if (part == ImagePart)
            {
                var imgCell   = cell as ImageCell;
                int pixelSize = System.Maui.Maui.ConvertToScaledPixel(imgCell.RenderHeight);
                if (pixelSize <= 0)
                {
                    pixelSize = System.Maui.Maui.ConvertToPixel(_defaultHeight);
                }

                var image = new Native.Image(System.Maui.Maui.NativeParent)
                {
                    MinimumWidth  = pixelSize,
                    MinimumHeight = pixelSize
                };
                image.SetAlignment(-1.0, -1.0);            // fill
                image.SetWeight(1.0, 1.0);                 // expand

                var task = image.LoadFromImageSourceAsync(imgCell.ImageSource);
                return(image);
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
 protected override void OnElementChanged(ElementChangedEventArgs <ImageButton> e)
 {
     if (Control == null)
     {
         SetNativeControl(new Box(System.Maui.Maui.NativeParent));
         Control.SetLayoutCallback(OnLayout);
         _round = new Native.RoundRectangle(System.Maui.Maui.NativeParent);
         _round.Show();
         _border = new Native.BorderRectangle(System.Maui.Maui.NativeParent);
         _border.Show();
         _image = new Native.Image(System.Maui.Maui.NativeParent);
         _image.Show();
         _button = new EButton(System.Maui.Maui.NativeParent)
         {
             Style = "transparent"
         };
         _button.Clicked  += OnClicked;
         _button.Pressed  += OnPressed;
         _button.Released += OnReleased;
         _button.Show();
         Control.PackEnd(_round);
         Control.PackEnd(_image);
         Control.PackEnd(_border);
         Control.PackEnd(_button);
     }
     base.OnElementChanged(e);
 }
Ejemplo n.º 3
0
 Native.Image GetSearchHandlerIcon(ImageSource source)
 {
     Native.Image _icon = new Native.Image(System.Maui.Maui.NativeParent);
     if (source != null)
     {
         var task = _icon.LoadFromImageSourceAsync(source);
     }
     return(_icon);
 }
Ejemplo n.º 4
0
        void InitializeTabsItem(EToolbarItem item, string resource)
        {
            //The source of icon resources is https://materialdesignicons.com/
            ImageSource src = ImageSource.FromResource(resource, typeof(ShellItemRenderer).GetTypeInfo().Assembly);

            Native.Image icon = new Native.Image(System.Maui.Maui.NativeParent);
            var          task = icon.LoadFromImageSourceAsync(src);

            item.SetPartContent("elm.swallow.icon", icon);
            item.SetPartColor("bg", _backgroudColor);
            item.SetPartColor("underline", EColor.Transparent);
        }
Ejemplo n.º 5
0
        EvasObject GetContent(object data, string part)
        {
            ShellSection section = data as ShellSection;

            var box = new Native.Box(System.Maui.Maui.NativeParent);

            box.Show();

            var icon = new Native.Image(System.Maui.Maui.NativeParent)
            {
                MinimumWidth  = System.Maui.Maui.ConvertToScaledPixel(44),
                MinimumHeight = System.Maui.Maui.ConvertToScaledPixel(27)
            };
            var task = icon.LoadFromImageSourceAsync(section.Icon);

            icon.Show();

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

            title.Show();

            box.PackEnd(icon);
            box.PackEnd(title);
            box.LayoutUpdated += (object sender, LayoutEventArgs e) =>
            {
                icon.Move(e.Geometry.X + _iconPadding, e.Geometry.Y + _iconPadding);
                icon.Resize(_iconSize, _iconSize);

                title.Move(e.Geometry.X + 2 * _iconPadding + _iconSize, e.Geometry.Y);
                title.Resize(e.Geometry.Width - (2 * _iconPadding + _iconSize), e.Geometry.Height);
            };
            box.MinimumHeight = _cellHeight;
            return(box);
        }
Ejemplo n.º 6
0
        void Initialize(EvasObject parent)
        {
            _box = new Native.Box(parent)
            {
                AlignmentX = -1,
                AlignmentY = -1,
                WeightX    = 1,
                WeightY    = 1
            };
            SetContent(_box);

            _menu = new GenList(parent)
            {
                BackgroundColor = EColor.Transparent,
                Style           = "solid/default",
            };

            _menu.ItemSelected += (s, e) =>
            {
                _flyoutMenu.TryGetValue(e.Item.Data as Item, out Element element);

                SelectedItemChanged?.Invoke(this, new SelectedItemChangedEventArgs(element, -1));
            };

            _menu.Show();
            _box.PackEnd(_menu);

            _defaultClass = new GenItemClass("double_label")
            {
                GetTextHandler = (obj, part) =>
                {
                    if (part == "elm.text")
                    {
                        return(((Item)obj).Title);
                    }
                    else
                    {
                        return(null);
                    }
                },
                GetContentHandler = (obj, part) =>
                {
                    if (part == "elm.swallow.icon")
                    {
                        var icon = ((Item)obj).Icon;
                        if (icon != null)
                        {
                            var image = new Native.Image(parent)
                            {
                                MinimumWidth  = System.Maui.Maui.ConvertToScaledPixel(24),
                                MinimumHeight = System.Maui.Maui.ConvertToScaledPixel(24)
                            };
                            var result = image.LoadFromImageSourceAsync(icon);
                            return(image);
                        }
                        else
                        {
                            return(null);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
            };
        }